You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1323 lines
44 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef CLASS_BOARD_H_
  25. #define CLASS_BOARD_H_
  26. #include <board_item_container.h>
  27. #include <common.h> // Needed for stl hash extensions
  28. #include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
  29. #include <hash.h>
  30. #include <layer_ids.h>
  31. #include <netinfo.h>
  32. #include <pcb_item_containers.h>
  33. #include <pcb_plot_params.h>
  34. #include <title_block.h>
  35. #include <tools/pcb_selection.h>
  36. #include <mutex>
  37. #include <list>
  38. class BOARD_DESIGN_SETTINGS;
  39. class BOARD_CONNECTED_ITEM;
  40. class BOARD_COMMIT;
  41. class DRC_RTREE;
  42. class PCB_BASE_FRAME;
  43. class PCB_EDIT_FRAME;
  44. class PICKED_ITEMS_LIST;
  45. class BOARD;
  46. class FOOTPRINT;
  47. class ZONE;
  48. class PCB_TRACK;
  49. class PAD;
  50. class PCB_GROUP;
  51. class PCB_GENERATOR;
  52. class PCB_MARKER;
  53. class MSG_PANEL_ITEM;
  54. class NETLIST;
  55. class REPORTER;
  56. class SHAPE_POLY_SET;
  57. class CONNECTIVITY_DATA;
  58. class COMPONENT;
  59. class PROJECT;
  60. class PROGRESS_REPORTER;
  61. struct ISOLATED_ISLANDS;
  62. // The default value for m_outlinesChainingEpsilon to convert a board outlines to polygons
  63. // It is the max dist between 2 end points to see them connected
  64. #define DEFAULT_CHAINING_EPSILON_MM 0.01
  65. // Forward declare endpoint from class_track.h
  66. enum ENDPOINT_T : int;
  67. struct PTR_PTR_CACHE_KEY
  68. {
  69. BOARD_ITEM* A;
  70. BOARD_ITEM* B;
  71. bool operator==(const PTR_PTR_CACHE_KEY& other) const
  72. {
  73. return A == other.A && B == other.B;
  74. }
  75. };
  76. struct PTR_LAYER_CACHE_KEY
  77. {
  78. BOARD_ITEM* A;
  79. PCB_LAYER_ID Layer;
  80. bool operator==(const PTR_LAYER_CACHE_KEY& other) const
  81. {
  82. return A == other.A && Layer == other.Layer;
  83. }
  84. };
  85. struct PTR_PTR_LAYER_CACHE_KEY
  86. {
  87. BOARD_ITEM* A;
  88. BOARD_ITEM* B;
  89. PCB_LAYER_ID Layer;
  90. bool operator==(const PTR_PTR_LAYER_CACHE_KEY& other) const
  91. {
  92. return A == other.A && B == other.B && Layer == other.Layer;
  93. }
  94. };
  95. namespace std
  96. {
  97. template <>
  98. struct hash<PTR_PTR_CACHE_KEY>
  99. {
  100. std::size_t operator()( const PTR_PTR_CACHE_KEY& k ) const
  101. {
  102. std::size_t seed = 0xa82de1c0;
  103. hash_combine( seed, k.A, k.B );
  104. return seed;
  105. }
  106. };
  107. template <>
  108. struct hash<PTR_LAYER_CACHE_KEY>
  109. {
  110. std::size_t operator()( const PTR_LAYER_CACHE_KEY& k ) const
  111. {
  112. std::size_t seed = 0xa82de1c0;
  113. hash_combine( seed, k.A, k.Layer );
  114. return seed;
  115. }
  116. };
  117. template <>
  118. struct hash<PTR_PTR_LAYER_CACHE_KEY>
  119. {
  120. std::size_t operator()( const PTR_PTR_LAYER_CACHE_KEY& k ) const
  121. {
  122. std::size_t seed = 0xa82de1c0;
  123. hash_combine( seed, k.A, k.B, k.Layer );
  124. return seed;
  125. }
  126. };
  127. }
  128. /**
  129. * The allowed types of layers, same as Specctra DSN spec.
  130. */
  131. enum LAYER_T
  132. {
  133. LT_UNDEFINED = -1,
  134. LT_SIGNAL,
  135. LT_POWER,
  136. LT_MIXED,
  137. LT_JUMPER
  138. };
  139. /**
  140. * Container to hold information pertinent to a layer of a BOARD.
  141. */
  142. struct LAYER
  143. {
  144. LAYER()
  145. {
  146. clear();
  147. }
  148. void clear()
  149. {
  150. m_type = LT_SIGNAL;
  151. m_visible = true;
  152. m_number = 0;
  153. m_name.clear();
  154. m_userName.clear();
  155. }
  156. /*
  157. LAYER( const wxString& aName = wxEmptyString,
  158. LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
  159. m_name( aName ),
  160. m_type( aType ),
  161. m_visible( aVisible ),
  162. m_number( aNumber )
  163. {
  164. }
  165. */
  166. wxString m_name; ///< The canonical name of the layer. @see #LSET::Name
  167. wxString m_userName; ///< The user defined name of the layer.
  168. LAYER_T m_type; ///< The type of the layer. @see #LAYER_T
  169. bool m_visible;
  170. int m_number; ///< The layer ID. @see PCB_LAYER_ID
  171. /**
  172. * Convert a #LAYER_T enum to a string representation of the layer type.
  173. *
  174. * @param aType The #LAYER_T to convert
  175. * @return The string representation of the layer type.
  176. */
  177. static const char* ShowType( LAYER_T aType );
  178. /**
  179. * Convert a string to a #LAYER_T
  180. *
  181. * @param aType The layer name to convert.
  182. * @return The binary representation of the layer type, or
  183. * LAYER_T(-1) if the string is invalid.
  184. */
  185. static LAYER_T ParseType( const char* aType );
  186. };
  187. // Helper class to handle high light nets
  188. class HIGH_LIGHT_INFO
  189. {
  190. protected:
  191. std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
  192. bool m_highLightOn; // highlight active
  193. void Clear()
  194. {
  195. m_netCodes.clear();
  196. m_highLightOn = false;
  197. }
  198. HIGH_LIGHT_INFO()
  199. {
  200. Clear();
  201. }
  202. private:
  203. friend class BOARD;
  204. };
  205. /**
  206. * Provide an interface to hook into board modifications and get callbacks
  207. * on certain modifications that are made to the board. This allows updating
  208. * auxiliary views other than the primary board editor view.
  209. */
  210. class BOARD;
  211. class BOARD_LISTENER
  212. {
  213. public:
  214. virtual ~BOARD_LISTENER() { }
  215. virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
  216. virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
  217. virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
  218. virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
  219. virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
  220. virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
  221. virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
  222. virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
  223. virtual void OnBoardRatsnestChanged( BOARD& aBoard ) { }
  224. };
  225. /**
  226. * Set of BOARD_ITEMs ordered by UUID.
  227. */
  228. typedef std::set<BOARD_ITEM*, CompareByUuid> BOARD_ITEM_SET;
  229. /**
  230. * Flags to specify how the board is being used.
  231. */
  232. enum class BOARD_USE
  233. {
  234. NORMAL, // A normal board
  235. FPHOLDER // A board that holds a single footprint
  236. };
  237. /**
  238. * Information pertinent to a Pcbnew printed circuit board.
  239. */
  240. class BOARD : public BOARD_ITEM_CONTAINER
  241. {
  242. public:
  243. static inline bool ClassOf( const EDA_ITEM* aItem )
  244. {
  245. return aItem && PCB_T == aItem->Type();
  246. }
  247. /**
  248. * Set what the board is going to be used for.
  249. *
  250. * @param aUse is the flag
  251. */
  252. void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
  253. /**
  254. * Get what the board use is.
  255. *
  256. * @return what the board is being used for
  257. */
  258. BOARD_USE GetBoardUse() const { return m_boardUse; }
  259. void IncrementTimeStamp();
  260. int GetTimeStamp() const { return m_timeStamp; }
  261. /**
  262. * Find out if the board is being used to hold a single footprint for editing/viewing.
  263. *
  264. * @return if the board is just holding a footprint
  265. */
  266. bool IsFootprintHolder() const
  267. {
  268. return m_boardUse == BOARD_USE::FPHOLDER;
  269. }
  270. void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
  271. const wxString &GetFileName() const { return m_fileName; }
  272. TRACKS& Tracks() { return m_tracks; }
  273. const TRACKS& Tracks() const { return m_tracks; }
  274. FOOTPRINTS& Footprints() { return m_footprints; }
  275. const FOOTPRINTS& Footprints() const { return m_footprints; }
  276. DRAWINGS& Drawings() { return m_drawings; }
  277. const DRAWINGS& Drawings() const { return m_drawings; }
  278. ZONES& Zones() { return m_zones; }
  279. const ZONES& Zones() const { return m_zones; }
  280. GENERATORS& Generators() { return m_generators; }
  281. const GENERATORS& Generators() const { return m_generators; }
  282. MARKERS& Markers() { return m_markers; }
  283. const MARKERS& Markers() const { return m_markers; }
  284. const BOARD_ITEM_SET GetItemSet();
  285. /**
  286. * The groups must maintain the following invariants. These are checked by
  287. * GroupsSanityCheck():
  288. * - An item may appear in at most one group
  289. * - Each group must contain at least one item
  290. * - If a group specifies a name, it must be unique
  291. * - The graph of groups containing subgroups must be cyclic.
  292. */
  293. GROUPS& Groups() { return m_groups; }
  294. const GROUPS& Groups() const { return m_groups; }
  295. const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
  296. const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
  297. void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
  298. void GetContextualTextVars( wxArrayString* aVars ) const;
  299. bool ResolveTextVar( wxString* token, int aDepth ) const;
  300. /// Visibility settings stored in board prior to 6.0, only used for loading legacy files
  301. LSET m_LegacyVisibleLayers;
  302. GAL_SET m_LegacyVisibleItems;
  303. /// True if the legacy board design settings were loaded from a file
  304. bool m_LegacyDesignSettingsLoaded;
  305. bool m_LegacyCopperEdgeClearanceLoaded;
  306. /// True if netclasses were loaded from the file
  307. bool m_LegacyNetclassesLoaded;
  308. BOARD();
  309. ~BOARD();
  310. VECTOR2I GetPosition() const override;
  311. void SetPosition( const VECTOR2I& aPos ) override;
  312. const VECTOR2I GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
  313. bool IsEmpty() const
  314. {
  315. return m_drawings.empty() && m_footprints.empty() && m_tracks.empty() && m_zones.empty();
  316. }
  317. void Move( const VECTOR2I& aMoveVector ) override;
  318. void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
  319. int GetFileFormatVersionAtLoad() const { return m_fileFormatVersionAtLoad; }
  320. void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
  321. const wxString& GetGenerator() const { return m_generator; }
  322. ///< @copydoc BOARD_ITEM_CONTAINER::Add()
  323. void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
  324. bool aSkipConnectivity = false ) override;
  325. ///< @copydoc BOARD_ITEM_CONTAINER::Remove()
  326. void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
  327. /**
  328. * Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for
  329. * listeners.
  330. */
  331. void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
  332. /**
  333. * Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event
  334. * for listeners.
  335. */
  336. void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
  337. void CacheTriangulation( PROGRESS_REPORTER* aReporter = nullptr,
  338. const std::vector<ZONE*>& aZones = {} );
  339. /**
  340. * Get the first footprint on the board or nullptr.
  341. *
  342. * This is used primarily by the footprint editor which knows there is only one.
  343. *
  344. * @return first footprint or null pointer
  345. */
  346. FOOTPRINT* GetFirstFootprint() const
  347. {
  348. return m_footprints.empty() ? nullptr : m_footprints.front();
  349. }
  350. /**
  351. * Remove all footprints from the deque and free the memory associated with them.
  352. */
  353. void DeleteAllFootprints();
  354. /**
  355. * @return null if aID is null. Returns an object of Type() == NOT_USED if the aID is not found.
  356. */
  357. BOARD_ITEM* GetItem( const KIID& aID ) const;
  358. void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
  359. /**
  360. * Convert cross-references back and forth between ${refDes:field} and ${kiid:field}
  361. */
  362. wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const;
  363. wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const;
  364. /**
  365. * Return a list of missing connections between components/tracks.
  366. * @return an object that contains information about missing connections.
  367. */
  368. std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
  369. /**
  370. * Build or rebuild the board connectivity database for the board,
  371. * especially the list of connected items, list of nets and rastnest data
  372. * Needed after loading a board to have the connectivity database updated.
  373. */
  374. bool BuildConnectivity( PROGRESS_REPORTER* aReporter = nullptr );
  375. /**
  376. * Delete all MARKERS from the board.
  377. */
  378. void DeleteMARKERs();
  379. void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
  380. PROJECT* GetProject() const { return m_project; }
  381. /**
  382. * Link a board to a given project.
  383. *
  384. * Should be called immediately after loading board in order for everything to work.
  385. *
  386. * @param aProject is a loaded project to link to.
  387. * @param aReferenceOnly avoids taking ownership of settings stored in project if true
  388. */
  389. void SetProject( PROJECT* aProject, bool aReferenceOnly = false );
  390. void ClearProject();
  391. /**
  392. * Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
  393. *
  394. * @param aCreateMarkers if true, create markers from serialized data; if false only
  395. * use serialized data to set existing markers to excluded.
  396. * The former is used on board load; the later after a DRC.
  397. */
  398. std::vector<PCB_MARKER*> ResolveDRCExclusions( bool aCreateMarkers );
  399. /**
  400. * Scan existing markers and record data from any that are Excluded.
  401. */
  402. void RecordDRCExclusions();
  403. /**
  404. * Update the visibility flags on the current unconnected ratsnest lines.
  405. */
  406. void UpdateRatsnestExclusions();
  407. /**
  408. * Reset all high light data to the init state
  409. */
  410. void ResetNetHighLight();
  411. /**
  412. * @return the set of net codes that should be highlighted
  413. */
  414. const std::set<int>& GetHighLightNetCodes() const
  415. {
  416. return m_highLight.m_netCodes;
  417. }
  418. /**
  419. * Select the netcode to be highlighted.
  420. *
  421. * @param aNetCode is the net to highlight.
  422. * @param aMulti is true if you want to add a highlighted net without clearing the old one.
  423. */
  424. void SetHighLightNet( int aNetCode, bool aMulti = false );
  425. /**
  426. * @return true if a net is currently highlighted
  427. */
  428. bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
  429. /**
  430. * Enable or disable net highlighting.
  431. *
  432. * If a netcode >= 0 has been set with SetHighLightNet and aValue is true, the net will be
  433. * highlighted. If aValue is false, net highlighting will be disabled regardless of
  434. * the highlight netcode being set.
  435. */
  436. void HighLightON( bool aValue = true );
  437. /**
  438. * Disable net highlight.
  439. */
  440. void HighLightOFF()
  441. {
  442. HighLightON( false );
  443. }
  444. /**
  445. * @return The number of copper layers in the BOARD.
  446. */
  447. int GetCopperLayerCount() const;
  448. void SetCopperLayerCount( int aCount );
  449. int LayerDepth( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer ) const;
  450. /**
  451. * A proxy function that calls the corresponding function in m_BoardSettings.
  452. *
  453. * @return the enabled layers in bit-mapped form.
  454. */
  455. LSET GetEnabledLayers() const;
  456. /**
  457. * A proxy function that calls the correspondent function in m_BoardSettings.
  458. *
  459. * @param aLayerMask the new bit-mask of enabled layers.
  460. */
  461. void SetEnabledLayers( LSET aLayerMask );
  462. /**
  463. * A proxy function that calls the correspondent function in m_BoardSettings
  464. * tests whether a given layer is enabled
  465. * @param aLayer = The layer to be tested
  466. * @return true if the layer is visible.
  467. */
  468. bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const;
  469. /**
  470. * A proxy function that calls the correspondent function in m_BoardSettings
  471. * tests whether a given layer is visible
  472. *
  473. * @param aLayer is the layer to be tested.
  474. * @return true if the layer is visible otherwise false.
  475. */
  476. bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
  477. /**
  478. * A proxy function that calls the correspondent function in m_BoardSettings.
  479. *
  480. * @return the visible layers in bit-mapped form.
  481. */
  482. LSET GetVisibleLayers() const;
  483. /**
  484. * A proxy function that calls the correspondent function in m_BoardSettings
  485. * changes the bit-mask of visible layers.
  486. *
  487. * @param aLayerMask is the new bit-mask of visible layers.
  488. */
  489. void SetVisibleLayers( LSET aLayerMask );
  490. // these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
  491. // are not stored in the bitmap.
  492. /**
  493. * Return a set of all the element categories that are visible.
  494. *
  495. * @return the set of visible GAL layers.
  496. * @see enum GAL_LAYER_ID
  497. */
  498. GAL_SET GetVisibleElements() const;
  499. /**
  500. * A proxy function that calls the correspondent function in m_BoardSettings.
  501. *
  502. * @param aMask is the new bit-mask of visible element bitmap or-ed from enum GAL_LAYER_ID
  503. * @see enum GAL_LAYER_ID
  504. */
  505. void SetVisibleElements( const GAL_SET& aMask );
  506. /**
  507. * Change the bit-mask of visible element categories and layers.
  508. *
  509. * @see enum GAL_LAYER_ID
  510. */
  511. void SetVisibleAlls();
  512. /**
  513. * Test whether a given element category is visible.
  514. *
  515. * @param aLayer is from the enum by the same name.
  516. * @return true if the element is visible otherwise false.
  517. * @see enum GAL_LAYER_ID
  518. */
  519. bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
  520. /**
  521. * Change the visibility of an element category.
  522. *
  523. * @param aLayer is from the enum by the same name.
  524. * @param aNewState is the new visibility state of the element category.
  525. * @see enum GAL_LAYER_ID
  526. */
  527. void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
  528. /**
  529. * Expect either of the two layers on which a footprint can reside, and returns
  530. * whether that layer is visible.
  531. *
  532. * @param aLayer is one of the two allowed layers for footprints: F_Cu or B_Cu
  533. * @return true if the layer is visible, otherwise false.
  534. */
  535. bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
  536. /**
  537. * @return the BOARD_DESIGN_SETTINGS for this BOARD
  538. */
  539. BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
  540. // Tented vias are vias covered by solder mask. So because the solder mask is a negative
  541. // layer, tented vias are NOT plotted on solder mask layers
  542. bool GetTentVias() const { return !m_plotOptions.GetPlotViaOnMaskLayer(); }
  543. void SetTentVias( bool aFlag ) { m_plotOptions.SetPlotViaOnMaskLayer( !aFlag ); }
  544. const PAGE_INFO& GetPageSettings() const { return m_paper; }
  545. void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
  546. const PCB_PLOT_PARAMS& GetPlotOptions() const { return m_plotOptions; }
  547. void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
  548. TITLE_BLOCK& GetTitleBlock() { return m_titles; }
  549. const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
  550. void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
  551. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
  552. EDA_UNITS GetUserUnits() { return m_userUnits; }
  553. void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
  554. /**
  555. * Update any references within aItem (or its descendants) to the user units. Primarily
  556. * for automatic-unit dimensions.
  557. */
  558. void UpdateUserUnits( BOARD_ITEM* aItem, KIGFX::VIEW* aView );
  559. /**
  560. * Extract the board outlines and build a closed polygon from lines, arcs and circle items
  561. * on edge cut layer.
  562. *
  563. * Any closed outline inside the main outline is a hole. All contours should be closed,
  564. * i.e. have valid vertices to build a closed polygon.
  565. *
  566. * @param aOutlines is the #SHAPE_POLY_SET to fill in with outlines/holes.
  567. * @param aErrorHandler is an optional DRC_ITEM error handler.
  568. * @param aAllowUseArcsInPolygons = an optional option to allow adding arcs in
  569. * SHAPE_LINE_CHAIN polylines/polygons when building outlines from aShapeList
  570. * This is mainly for export to STEP files
  571. * @param aIncludeNPTHAsOutlines = an optional option to include NPTH pad holes
  572. * in board outlines. These holes can be seen like holes created by closed shapes
  573. * drawn on edge cut layer inside the board main outline.
  574. * @return true if success, false if a contour is not valid
  575. */
  576. bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
  577. OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr,
  578. bool aAllowUseArcsInPolygons = false,
  579. bool aIncludeNPTHAsOutlines = false );
  580. /**
  581. * @return a epsilon value that is the max distance between 2 points to see them
  582. * at the same coordinate when building the board outlines and tray to connect 2 end points
  583. * when buildind the outlines of the board
  584. * Too small value do not allow connecting 2 shapes (i.e. segments) not exactly connected
  585. * Too large value do not allow safely connecting 2 shapes like very short segments.
  586. */
  587. int GetOutlinesChainingEpsilon() { return( m_outlinesChainingEpsilon ); }
  588. void SetOutlinesChainingEpsilon( int aValue) { m_outlinesChainingEpsilon = aValue; }
  589. /**
  590. * Build a set of polygons which are the outlines of copper items (pads, tracks, vias, texts,
  591. * zones).
  592. *
  593. * Holes in vias or pads are ignored. The polygons are not merged. This is useful to
  594. * export the shape of copper layers to dxf polygons or 3D viewer/
  595. *
  596. * @param aLayer is a copper layer, like B_Cu, etc.
  597. * @param aOutlines is the SHAPE_POLY_SET to fill in with items outline.
  598. */
  599. void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const;
  600. /**
  601. * Return the ID of a layer.
  602. */
  603. PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
  604. /**
  605. * Return the name of a \a aLayer.
  606. *
  607. * @param aLayer is the #PCB_LAYER_ID of the layer.
  608. * @return a string containing the name of the layer.
  609. */
  610. const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
  611. /**
  612. * Changes the name of the layer given by aLayer.
  613. * @param aLayer A layer, like B_Cu, etc.
  614. * @param aLayerName The new layer name
  615. * @return true if aLayerName was legal and unique among other layer names at other layer
  616. * indices and aLayer was within range, else false.
  617. */
  618. bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
  619. /**
  620. * Return an "English Standard" name of a PCB layer when given \a aLayerNumber.
  621. *
  622. * This function is static so it can be called without a BOARD instance. Use
  623. * GetLayerName() if want the layer names of a specific BOARD, which could
  624. * be different than the default if the user has renamed any copper layers.
  625. *
  626. * @param aLayerId is the layer identifier (index) to fetch.
  627. * @return a string containing the layer name or "BAD INDEX" if aLayerId is not legal.
  628. */
  629. static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
  630. {
  631. // a BOARD's standard layer name is the PCB_LAYER_ID fixed name
  632. return LayerName( aLayerId );
  633. }
  634. /**
  635. * Return the type of the copper layer given by aLayer.
  636. *
  637. * @param aIndex A layer index in m_Layer
  638. * @param aLayer A reference to a LAYER description.
  639. * @return false if the index was out of range.
  640. */
  641. bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
  642. /**
  643. * Return the type of the copper layer given by aLayer.
  644. *
  645. * @param aLayer A layer index, like B_Cu, etc.
  646. * @return the layer type, or LAYER_T(-1) if the index was out of range.
  647. */
  648. LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
  649. /**
  650. * Change the type of the layer given by aLayer.
  651. *
  652. * @param aLayer A layer index, like B_Cu, etc.
  653. * @param aLayerType The new layer type.
  654. * @return true if aLayerType was legal and aLayer was within range, else false.
  655. */
  656. bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
  657. /**
  658. * @param aNet Only count nodes belonging to this net.
  659. * @return the number of pads members of nets (i.e. with netcode > 0).
  660. */
  661. unsigned GetNodesCount( int aNet = -1 ) const;
  662. /**
  663. * Return a reference to a list of all the pads.
  664. *
  665. * The returned list is not sorted and contains pointers to PADS, but those pointers do
  666. * not convey ownership of the respective PADs.
  667. *
  668. * @return a full list of pads.
  669. */
  670. const std::vector<PAD*> GetPads() const;
  671. void BuildListOfNets()
  672. {
  673. m_NetInfo.buildListOfNets();
  674. }
  675. /**
  676. * Search for a net with the given netcode.
  677. *
  678. * @param aNetcode A netcode to search for.
  679. * @return the net if found or NULL if not found.
  680. */
  681. NETINFO_ITEM* FindNet( int aNetcode ) const;
  682. /**
  683. * Search for a net with the given name.
  684. *
  685. * @param aNetname A Netname to search for.
  686. * @return the net if found or NULL if not found.
  687. */
  688. NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
  689. /**
  690. * Fetch the coupled netname for a given net.
  691. *
  692. * This accepts netnames suffixed by 'P', 'N', '+', '-', as well as additional numbers and
  693. * underscores following the suffix. So NET_P_123 is a valid positive net name matched to
  694. * NET_N_123.
  695. *
  696. * @return the polarity of the given net (or 0 if it is not a diffpair net).
  697. */
  698. int MatchDpSuffix( const wxString& aNetName, wxString& aComplementNet );
  699. /**
  700. * @return the coupled net for a given net. If not a diffpair, nullptr is returned.
  701. */
  702. NETINFO_ITEM* DpCoupledNet( const NETINFO_ITEM* aNet );
  703. const NETINFO_LIST& GetNetInfo() const
  704. {
  705. return m_NetInfo;
  706. }
  707. void RemoveUnusedNets( BOARD_COMMIT* aCommit )
  708. {
  709. m_NetInfo.RemoveUnusedNets( aCommit );
  710. }
  711. #ifndef SWIG
  712. /**
  713. * @return iterator to the first element of the NETINFO_ITEMs list.
  714. */
  715. NETINFO_LIST::iterator BeginNets() const
  716. {
  717. return m_NetInfo.begin();
  718. }
  719. /**
  720. * @return iterator to the last element of the NETINFO_ITEMs list.
  721. */
  722. NETINFO_LIST::iterator EndNets() const
  723. {
  724. return m_NetInfo.end();
  725. }
  726. #endif
  727. /**
  728. * @return the number of nets (NETINFO_ITEM).
  729. */
  730. unsigned GetNetCount() const
  731. {
  732. return m_NetInfo.GetNetCount();
  733. }
  734. /**
  735. * Calculate the bounding box containing all board items (or board edge segments).
  736. *
  737. * @param aBoardEdgesOnly is true if we are interested in board edge segments only.
  738. * @return the board's bounding box.
  739. */
  740. BOX2I ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
  741. const BOX2I GetBoundingBox() const override
  742. {
  743. return ComputeBoundingBox( false );
  744. }
  745. /**
  746. * Return the board bounding box calculated using exclusively the board edges (graphics
  747. * on Edge.Cuts layer).
  748. *
  749. * If there are items outside of the area limited by Edge.Cuts graphics, the items will
  750. * not be taken into account.
  751. *
  752. * @return bounding box calculated using exclusively the board edges.
  753. */
  754. const BOX2I GetBoardEdgesBoundingBox() const
  755. {
  756. return ComputeBoundingBox( true );
  757. }
  758. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  759. /**
  760. * May be re-implemented for each derived class in order to handle
  761. * all the types given by its member data. Implementations should call
  762. * inspector->Inspect() on types in scanTypes[], and may use IterateForward()
  763. * to do so on lists of such data.
  764. * @param inspector An INSPECTOR instance to use in the inspection.
  765. * @param testData Arbitrary data used by the inspector.
  766. * @param scanTypes Which KICAD_T types are of interest and the order to process them in.
  767. * @return SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE, and
  768. * determined by the inspector.
  769. */
  770. INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
  771. const std::vector<KICAD_T>& scanTypes ) override;
  772. /**
  773. * Search for a FOOTPRINT within this board with the given reference designator.
  774. *
  775. * Finds only the first one, if there is more than one such FOOTPRINT.
  776. *
  777. * @param aReference The reference designator of the FOOTPRINT to find.
  778. * @return If found the FOOTPRINT having the given reference designator, else nullptr.
  779. */
  780. FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
  781. /**
  782. * Search for a FOOTPRINT within this board with the given path.
  783. *
  784. * @param aPath The path ([sheetUUID, .., symbolUUID]) to search for.
  785. * @return If found, the FOOTPRINT having the given uuid, else NULL.
  786. */
  787. FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
  788. /**
  789. * Return the set of netname candidates for netclass assignment.
  790. */
  791. std::set<wxString> GetNetClassAssignmentCandidates() const;
  792. /**
  793. * Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
  794. *
  795. * Must be called after a Design Rules edit, or after reading a netlist (or editing
  796. * the list of nets) Also this function removes the non existing nets in netclasses
  797. * and add net nets in default netclass (this happens after reading a netlist)
  798. */
  799. void SynchronizeNetsAndNetClasses( bool aResetTrackAndViaSizes );
  800. /**
  801. * Copy the current project's text variables into the boards property cache.
  802. */
  803. void SynchronizeProperties();
  804. /**
  805. * Return the Similarity. Because we compare board to board, we just return 1.0 here
  806. */
  807. double Similarity( const BOARD_ITEM& aOther ) const override
  808. {
  809. return 1.0;
  810. }
  811. bool operator==( const BOARD_ITEM& aOther ) const override;
  812. wxString GetClass() const override
  813. {
  814. return wxT( "BOARD" );
  815. }
  816. #if defined(DEBUG)
  817. void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
  818. #endif
  819. /*************************/
  820. /* Copper Areas handling */
  821. /*************************/
  822. /**
  823. * Set the .m_NetCode member of all copper areas, according to the area Net Name
  824. * The SetNetCodesFromNetNames is an equivalent to net name, for fast comparisons.
  825. * However the Netcode is an arbitrary equivalence, it must be set after each netlist read
  826. * or net change
  827. * Must be called after pad netcodes are calculated
  828. * @return : error count
  829. * For non copper areas, netcode is set to 0
  830. */
  831. int SetAreasNetCodesFromNetNames();
  832. /**
  833. * Return the Zone at a given index.
  834. *
  835. * @param index The array type index into a collection of ZONE *.
  836. * @return a pointer to the Area or NULL if index out of range.
  837. */
  838. ZONE* GetArea( int index ) const
  839. {
  840. if( (unsigned) index < m_zones.size() )
  841. return m_zones[index];
  842. return nullptr;
  843. }
  844. /**
  845. * @return a std::list of pointers to all board zones (possibly including zones in footprints)
  846. */
  847. std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false ) const;
  848. /**
  849. * @return The number of copper pour areas or ZONEs.
  850. */
  851. int GetAreaCount() const
  852. {
  853. return static_cast<int>( m_zones.size() );
  854. }
  855. /* Functions used in test, merge and cut outlines */
  856. /**
  857. * Add an empty copper area to board areas list.
  858. *
  859. * @param aNewZonesList is a PICKED_ITEMS_LIST * where to store new areas pickers (useful
  860. * in undo commands) can be NULL.
  861. * @param aNetcode is the netcode of the copper area (0 = no net).
  862. * @param aLayer is the layer of area.
  863. * @param aStartPointPosition is position of the first point of the polygon outline of this
  864. * area.
  865. * @param aHatch is the hatch option.
  866. * @return a reference to the new area.
  867. */
  868. ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
  869. VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
  870. /**
  871. * Test for intersection of 2 copper areas.
  872. *
  873. * @param aZone1 is the area reference.
  874. * @param aZone2 is the area to compare for intersection calculations.
  875. * @return false if no intersection, true if intersection.
  876. */
  877. bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
  878. /**
  879. * Find a pad \a aPosition on \a aLayer.
  880. *
  881. * @param aPosition A VECTOR2I object containing the position to hit test.
  882. * @param aLayerMask A layer or layers to mask the hit test.
  883. * @return A pointer to a PAD object if found or NULL if not found.
  884. */
  885. PAD* GetPad( const VECTOR2I& aPosition, LSET aLayerMask ) const;
  886. PAD* GetPad( const VECTOR2I& aPosition ) const
  887. {
  888. return GetPad( aPosition, LSET().set() );
  889. }
  890. /**
  891. * Find a pad connected to \a aEndPoint of \a aTrace.
  892. *
  893. * @param aTrace A pointer to a PCB_TRACK object to hit test against.
  894. * @param aEndPoint The end point of \a aTrace the hit test against.
  895. * @return A pointer to a PAD object if found or NULL if not found.
  896. */
  897. PAD* GetPad( const PCB_TRACK* aTrace, ENDPOINT_T aEndPoint ) const;
  898. /**
  899. * Return pad found at \a aPosition on \a aLayerMask using the fast search method.
  900. * <p>
  901. * The fast search method only works if the pad list has already been built.
  902. * </p>
  903. * @param aPosition A VECTOR2I object containing the position to hit test.
  904. * @param aLayerMask A layer or layers to mask the hit test.
  905. * @return A pointer to a PAD object if found or NULL if not found.
  906. */
  907. PAD* GetPadFast( const VECTOR2I& aPosition, LSET aLayerMask ) const;
  908. /**
  909. * Locate the pad connected at \a aPosition on \a aLayer starting at list position
  910. * \a aPad
  911. * <p>
  912. * This function uses a fast search in this sorted pad list and it is faster than
  913. * GetPadFast(). This list is a sorted pad list must be built before calling this
  914. * function.
  915. * </p>
  916. * @note The normal pad list is sorted by increasing netcodes.
  917. * @param aPadList is the list of pads candidates (a std::vector<PAD*>).
  918. * @param aPosition A VECTOR2I object containing the position to test.
  919. * @param aLayerMask A layer or layers to mask the hit test.
  920. * @return a PAD object pointer to the connected pad.
  921. */
  922. PAD* GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, LSET aLayerMask ) const;
  923. /**
  924. * First empties then fills the vector with all pads and sorts them by increasing x
  925. * coordinate, and for increasing y coordinate for same values of x coordinates. The vector
  926. * only holds pointers to the pads and those pointers are only references to pads which are
  927. * owned by the BOARD through other links.
  928. *
  929. * @param aVector Where to put the pad pointers.
  930. * @param aNetCode = the netcode filter:
  931. * = -1 to build the full pad list.
  932. * = a given netcode to build the pad list relative to the given net
  933. */
  934. void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
  935. /**
  936. * Return data on the length and number of track segments connected to a given track.
  937. * This uses the connectivity data for the board to calculate connections
  938. *
  939. * @param aTrack Starting track (can also be a via) to check against for connection.
  940. * @return a tuple containing <number, length, package length>
  941. */
  942. std::tuple<int, double, double> GetTrackLength( const PCB_TRACK& aTrack ) const;
  943. /**
  944. * Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
  945. * Used from python.
  946. *
  947. * @param aNetCode gives the id of the net.
  948. * @return list of track which are in the net identified by @a aNetCode.
  949. */
  950. TRACKS TracksInNet( int aNetCode );
  951. /**
  952. * Get a footprint by its bounding rectangle at \a aPosition on \a aLayer.
  953. *
  954. * If more than one footprint is at \a aPosition, then the closest footprint on the
  955. * active layer is returned. The distance is calculated via manhattan distance from
  956. * the center of the bounding rectangle to \a aPosition.
  957. *
  958. * @param aPosition A VECTOR2I object containing the position to test.
  959. * @param aActiveLayer Layer to test.
  960. * @param aVisibleOnly Search only the visible layers if true.
  961. * @param aIgnoreLocked Ignore locked footprints when true.
  962. */
  963. FOOTPRINT* GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveLayer,
  964. bool aVisibleOnly, bool aIgnoreLocked = false ) const;
  965. /**
  966. * Returns the maximum clearance value for any object on the board. This considers
  967. * the clearances from board design settings as well as embedded clearances in footprints,
  968. * pads and zones. Includes electrical, physical, hole and edge clearances.
  969. */
  970. int GetMaxClearanceValue() const;
  971. /**
  972. * Map all nets in the given board to nets with the same name (if any) in the destination
  973. * board. This allows us to share layouts which came from the same hierarchical sheet in
  974. * the schematic.
  975. */
  976. void MapNets( const BOARD* aDestBoard );
  977. void SanitizeNetcodes();
  978. /**
  979. * Add a listener to the board to receive calls whenever something on the
  980. * board has been modified. The board does not take ownership of the
  981. * listener object. Make sure to call RemoveListener before deleting the
  982. * listener object. The order of listener invocations is not guaranteed.
  983. * If the specified listener object has been added before, it will not be
  984. * added again.
  985. */
  986. void AddListener( BOARD_LISTENER* aListener );
  987. /**
  988. * Remove the specified listener. If it has not been added before, it
  989. * will do nothing.
  990. */
  991. void RemoveListener( BOARD_LISTENER* aListener );
  992. /**
  993. * Remove all listeners
  994. */
  995. void RemoveAllListeners();
  996. /**
  997. * Notify the board and its listeners that an item on the board has
  998. * been modified in some way.
  999. */
  1000. void OnItemChanged( BOARD_ITEM* aItem );
  1001. /**
  1002. * Notify the board and its listeners that an item on the board has
  1003. * been modified in some way.
  1004. */
  1005. void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
  1006. /**
  1007. * Notify the board and its listeners that the ratsnest has been recomputed.
  1008. */
  1009. void OnRatsnestChanged();
  1010. /**
  1011. * Consistency check of internal m_groups structure.
  1012. *
  1013. * @param repair if true, modify groups structure until it passes the sanity check.
  1014. * @return empty string on success. Or error description if there's a problem.
  1015. */
  1016. wxString GroupsSanityCheck( bool repair = false );
  1017. /**
  1018. * @param repair if true, make one modification to groups structure that brings it
  1019. * closer to passing the sanity check.
  1020. * @return empty string on success. Or error description if there's a problem.
  1021. */
  1022. wxString GroupsSanityCheckInternal( bool repair );
  1023. struct GroupLegalOpsField
  1024. {
  1025. bool create : 1;
  1026. bool ungroup : 1;
  1027. bool removeItems : 1;
  1028. };
  1029. /**
  1030. * Check which selection tool group operations are legal given the selection.
  1031. *
  1032. * @return bit field of legal ops.
  1033. */
  1034. GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
  1035. bool LegacyTeardrops() const { return m_legacyTeardrops; }
  1036. void SetLegacyTeardrops( bool aFlag ) { m_legacyTeardrops = aFlag; }
  1037. // --------- Item order comparators ---------
  1038. struct cmp_items
  1039. {
  1040. bool operator() ( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
  1041. };
  1042. struct cmp_drawings
  1043. {
  1044. bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
  1045. };
  1046. // ------------ Run-time caches -------------
  1047. std::mutex m_CachesMutex;
  1048. std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsCourtyardCache;
  1049. std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsFCourtyardCache;
  1050. std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsBCourtyardCache;
  1051. std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_IntersectsAreaCache;
  1052. std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_EnclosedByAreaCache;
  1053. std::unordered_map< wxString, LSET > m_LayerExpressionCache;
  1054. std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
  1055. std::shared_ptr<DRC_RTREE> m_CopperItemRTreeCache;
  1056. mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
  1057. // ------------ DRC caches -------------
  1058. std::vector<ZONE*> m_DRCZones;
  1059. std::vector<ZONE*> m_DRCCopperZones;
  1060. int m_DRCMaxClearance;
  1061. int m_DRCMaxPhysicalClearance;
  1062. ZONE* m_SolderMaskBridges; // A container to build bridges on solder mask layers
  1063. std::map<ZONE*, std::map<PCB_LAYER_ID, ISOLATED_ISLANDS>> m_ZoneIsolatedIslandsMap;
  1064. private:
  1065. // The default copy constructor & operator= are inadequate,
  1066. // either write one or do not use it at all
  1067. BOARD( const BOARD& aOther ) = delete;
  1068. BOARD& operator=( const BOARD& aOther ) = delete;
  1069. template <typename Func, typename... Args>
  1070. void InvokeListeners( Func&& aFunc, Args&&... args )
  1071. {
  1072. for( auto&& l : m_listeners )
  1073. ( l->*aFunc )( std::forward<Args>( args )... );
  1074. }
  1075. friend class PCB_EDIT_FRAME;
  1076. /// the max distance between 2 end point to see them connected when building the board outlines
  1077. int m_outlinesChainingEpsilon;
  1078. /// What is this board being used for
  1079. BOARD_USE m_boardUse;
  1080. int m_timeStamp; // actually a modification counter
  1081. wxString m_fileName;
  1082. MARKERS m_markers;
  1083. DRAWINGS m_drawings;
  1084. FOOTPRINTS m_footprints;
  1085. TRACKS m_tracks;
  1086. GROUPS m_groups;
  1087. ZONES m_zones;
  1088. GENERATORS m_generators;
  1089. LAYER m_layers[PCB_LAYER_ID_COUNT];
  1090. HIGH_LIGHT_INFO m_highLight; // current high light data
  1091. HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
  1092. int m_fileFormatVersionAtLoad; // the version loaded from the file
  1093. wxString m_generator; // the generator tag from the file
  1094. std::map<wxString, wxString> m_properties;
  1095. std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
  1096. PAGE_INFO m_paper;
  1097. TITLE_BLOCK m_titles; // text in lower right of screen and plots
  1098. PCB_PLOT_PARAMS m_plotOptions;
  1099. PROJECT* m_project; // project this board is a part of
  1100. EDA_UNITS m_userUnits;
  1101. /**
  1102. * All of the board design settings are stored as a JSON object inside the project file. The
  1103. * object itself is located here because the alternative is to require a valid project be
  1104. * passed in when constructing a BOARD, since things in the BOARD constructor rely on access
  1105. * to the BOARD_DESIGN_SETTINGS object.
  1106. *
  1107. * A reference to this object is set up in the PROJECT_FILE for the PROJECT this board is
  1108. * part of, so that the JSON load/store operations work. This link is established when
  1109. * boards are loaded from disk.
  1110. */
  1111. std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
  1112. /**
  1113. * Teardrops in 7.0 were applied as a post-processing step (rather than from pad and via
  1114. * properties). If this flag is set, then auto-teardrop-generation will be disabled.
  1115. */
  1116. bool m_legacyTeardrops = false;
  1117. NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
  1118. std::vector<BOARD_LISTENER*> m_listeners;
  1119. };
  1120. #endif // CLASS_BOARD_H_