KiCad PCB EDA Suite
board.h
Go to the documentation of this file.
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-2020 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 
25 #ifndef CLASS_BOARD_H_
26 #define CLASS_BOARD_H_
27 
28 #include <board_design_settings.h>
29 #include <board_item_container.h>
30 #include <pcb_group.h>
31 #include <footprint.h>
32 #include <common.h> // Needed for stl hash extensions
34 #include <netinfo.h>
35 #include <pcb_plot_params.h>
36 #include <title_block.h>
37 #include <tools/pcb_selection.h>
38 
39 class BOARD_COMMIT;
40 class PCB_BASE_FRAME;
41 class PCB_EDIT_FRAME;
42 class PICKED_ITEMS_LIST;
43 class BOARD;
44 class ZONE;
45 class TRACK;
46 class PAD;
47 class PCB_MARKER;
48 class MSG_PANEL_ITEM;
49 class NETLIST;
50 class REPORTER;
51 class SHAPE_POLY_SET;
52 class CONNECTIVITY_DATA;
53 class COMPONENT;
54 class PROJECT;
55 
56 // Forward declare endpoint from class_track.h
57 enum ENDPOINT_T : int;
58 
62 enum LAYER_T
63 {
69 };
70 
71 
75 struct LAYER
76 {
78  {
79  clear();
80  }
81 
82  void clear()
83  {
84  m_type = LT_SIGNAL;
85  m_visible = true;
86  m_number = 0;
87  m_name.clear();
88  m_userName.clear();
89  }
90 
91  /*
92  LAYER( const wxString& aName = wxEmptyString,
93  LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
94  m_name( aName ),
95  m_type( aType ),
96  m_visible( aVisible ),
97  m_number( aNumber )
98  {
99  }
100  */
101 
102  wxString m_name;
103  wxString m_userName;
105  bool m_visible;
106  int m_number;
107 
114  static const char* ShowType( LAYER_T aType );
115 
123  static LAYER_T ParseType( const char* aType );
124 };
125 
126 
127 // Helper class to handle high light nets
129 {
130  friend class BOARD;
131 
132 protected:
133  std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
134  bool m_highLightOn; // highlight active
135 
136  void Clear()
137  {
138  m_netCodes.clear();
139  m_highLightOn = false;
140  }
141 
143  {
144  Clear();
145  }
146 };
147 
153 class BOARD;
154 
156 {
157 public:
158  virtual ~BOARD_LISTENER() { }
159  virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
160  virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
161  virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
162  virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
163  virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
164  virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
165  virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
166  virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
167 };
168 
169 
170 DECL_VEC_FOR_SWIG( MARKERS, PCB_MARKER* )
172 DECL_DEQ_FOR_SWIG( TRACKS, TRACK* )
173 // Dequeue rather than Vector just so we can use moveUnflaggedItems in pcbnew_control.cpp
174 DECL_DEQ_FOR_SWIG( GROUPS, PCB_GROUP* )
175 
176 
179 enum class BOARD_USE
180 {
181  NORMAL, // A normal board
182  FPHOLDER // A board that holds a single footprint
183 };
184 
185 
190 {
191  friend class PCB_EDIT_FRAME;
192 
193 private:
196 
197  wxString m_fileName;
198  MARKERS m_markers;
199  DRAWINGS m_drawings;
200  FOOTPRINTS m_footprints;
201  TRACKS m_tracks;
202  GROUPS m_groups;
204 
206 
207  HIGH_LIGHT_INFO m_highLight; // current high light data
208  HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
209 
210  int m_fileFormatVersionAtLoad; // the version loaded from the file
211 
212  std::map<wxString, wxString> m_properties;
213  std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
214 
216  TITLE_BLOCK m_titles; // text in lower right of screen and plots
218  PROJECT* m_project; // project this board is a part of
219 
230  std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
231 
232  NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
233 
234  std::vector<BOARD_LISTENER*> m_listeners;
235 
236  // The default copy constructor & operator= are inadequate,
237  // either write one or do not use it at all
238  BOARD( const BOARD& aOther ) = delete;
239 
240  BOARD& operator=( const BOARD& aOther ) = delete;
241 
242  template <typename Func, typename... Args>
243  void InvokeListeners( Func&& aFunc, Args&&... args )
244  {
245  for( auto&& l : m_listeners )
246  ( l->*aFunc )( std::forward<Args>( args )... );
247  }
248 
249 public:
250  static inline bool ClassOf( const EDA_ITEM* aItem )
251  {
252  return aItem && PCB_T == aItem->Type();
253  }
254 
260  void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
261 
267  BOARD_USE GetBoardUse() const { return m_boardUse; }
268 
274  bool IsFootprintHolder() const
275  {
277  }
278 
279  void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
280 
281  const wxString &GetFileName() const { return m_fileName; }
282 
283  TRACKS& Tracks() { return m_tracks; }
284  const TRACKS& Tracks() const { return m_tracks; }
285 
286  FOOTPRINTS& Footprints() { return m_footprints; }
287  const FOOTPRINTS& Footprints() const { return m_footprints; }
288 
289  DRAWINGS& Drawings() { return m_drawings; }
290  const DRAWINGS& Drawings() const { return m_drawings; }
291 
292  ZONES& Zones() { return m_zones; }
293  const ZONES& Zones() const { return m_zones; }
294 
295  MARKERS& Markers() { return m_markers; }
296  const MARKERS& Markers() const { return m_markers; }
297 
306  GROUPS& Groups() { return m_groups; }
307  const GROUPS& Groups() const { return m_groups; }
308 
309  const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
310 
311  const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
312  void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
313 
314  bool ResolveTextVar( wxString* token, int aDepth ) const;
315 
319 
323 
326 
327  BOARD();
328  ~BOARD();
329 
330  wxPoint GetPosition() const override;
331  void SetPosition( const wxPoint& aPos ) override;
332  const wxPoint GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
333 
334  bool IsEmpty() const
335  {
336  return m_drawings.empty() && m_footprints.empty() && m_tracks.empty() && m_zones.empty();
337  }
338 
339  void Move( const wxPoint& aMoveVector ) override;
340 
341  void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
343 
344  void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT ) override;
345 
346  void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
347 
351  void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
352 
356  void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
357 
364  {
365  return m_footprints.empty() ? nullptr : m_footprints.front();
366  }
367 
372  {
373  for( FOOTPRINT* footprint : m_footprints )
374  delete footprint;
375 
376  m_footprints.clear();
377  }
378 
383  BOARD_ITEM* GetItem( const KIID& aID ) const;
384 
385  void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
386 
390  wxString ConvertCrossReferencesToKIIDs( const wxString& aSource );
391  wxString ConvertKIIDsToCrossReferences( const wxString& aSource );
392 
397  std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
398 
404  void BuildConnectivity();
405 
409  void DeleteMARKERs();
410 
411  void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
412 
413  PROJECT* GetProject() const { return m_project; }
414 
420  void SetProject( PROJECT* aProject );
421 
422  void ClearProject();
423 
427  std::vector<PCB_MARKER*> ResolveDRCExclusions();
428 
432  void ResetNetHighLight();
433 
437  const std::set<int>& GetHighLightNetCodes() const
438  {
439  return m_highLight.m_netCodes;
440  }
441 
447  void SetHighLightNet( int aNetCode, bool aMulti = false );
448 
452  bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
453 
460  void HighLightON( bool aValue = true );
461 
466  {
467  HighLightON( false );
468  }
469 
473  int GetCopperLayerCount() const;
474  void SetCopperLayerCount( int aCount );
475 
481  LSET GetEnabledLayers() const;
482 
488  void SetEnabledLayers( LSET aLayerMask );
489 
496  bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const
497  {
498  return GetDesignSettings().IsLayerEnabled( aLayer );
499  }
500 
507  bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
508 
514  LSET GetVisibleLayers() const;
515 
521  void SetVisibleLayers( LSET aLayerMask );
522 
523  // these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
524  // are not stored in the bitmap.
525 
531  GAL_SET GetVisibleElements() const;
532 
539  void SetVisibleElements( const GAL_SET& aMask );
540 
545  void SetVisibleAlls();
546 
553  bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
554 
561  void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
562 
569  bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer );
570 
575  {
576  return *m_designSettings;
577  }
578 
579  const ZONE_SETTINGS& GetZoneSettings() const override
580  {
582  }
583 
584  void SetZoneSettings( const ZONE_SETTINGS& aSettings ) override
585  {
587  }
588 
589  const PAGE_INFO& GetPageSettings() const { return m_paper; }
590  void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
591 
592  const PCB_PLOT_PARAMS& GetPlotOptions() const { return m_plotOptions; }
593  void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
594 
596  const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
597  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
598 
599  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
600 
611  bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
612  OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
613 
622 
626  const PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
627 
635  const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
636 
645  bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
646 
657  static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
658  {
659  // a BOARD's standard layer name is the PCB_LAYER_ID fixed name
660  return LayerName( aLayerId );
661  }
662 
670  bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
671 
679  LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
680 
688  bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
689 
694  unsigned GetNodesCount( int aNet = -1 ) const;
695 
699  unsigned GetUnconnectedNetCount() const;
700 
704  unsigned GetPadCount() const;
705 
714  const std::vector<PAD*> GetPads() const;
715 
717  {
719  }
720 
726  NETINFO_ITEM* FindNet( int aNetcode ) const;
727 
733  NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
734 
735  const NETINFO_LIST& GetNetInfo() const
736  {
737  return m_NetInfo;
738  }
739 
741  {
742  return m_NetInfo;
743  }
744 
745 #ifndef SWIG
746 
750  {
751  return m_NetInfo.begin();
752  }
753 
758  {
759  return m_NetInfo.end();
760  }
761 #endif
762 
766  unsigned GetNetCount() const
767  {
768  return m_NetInfo.GetNetCount();
769  }
770 
777  EDA_RECT ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
778 
779  const EDA_RECT GetBoundingBox() const override
780  {
781  return ComputeBoundingBox( false );
782  }
783 
794  {
795  return ComputeBoundingBox( true );
796  }
797 
798  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
799 
812  SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
813 
823  FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
824 
831  FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
832 
839  int SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount );
840 
847  std::vector<wxString> GetNetClassAssignmentCandidates();
848 
857 
861  void SynchronizeProperties();
862 
863  wxString GetClass() const override
864  {
865  return wxT( "BOARD" );
866  }
867 
868 #if defined(DEBUG)
869  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
870 #endif
871 
872 
873  /*************************/
874  /* Copper Areas handling */
875  /*************************/
876 
887 
894  ZONE* GetArea( int index ) const
895  {
896  if( (unsigned) index < m_zones.size() )
897  return m_zones[index];
898 
899  return NULL;
900  }
901 
905  std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false );
906 
910  int GetAreaCount() const
911  {
912  return static_cast<int>( m_zones.size() );
913  }
914 
915  /* Functions used in test, merge and cut outlines */
916 
928  ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
929  wxPoint aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
930 
939  bool NormalizeAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, ZONE* aCurrArea );
940 
950  bool OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList, ZONE* modified_area );
951 
960  bool CombineAllZonesInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode );
961 
966  bool TestZoneIntersections( ZONE* aZone );
967 
974  bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
975 
984  bool CombineZones( PICKED_ITEMS_LIST* aDeletedList, ZONE* aRefZone, ZONE* aZoneToCombine );
985 
993  PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask );
994  PAD* GetPad( const wxPoint& aPosition )
995  {
996  return GetPad( aPosition, LSET().set() );
997  }
998 
1006  PAD* GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint );
1007 
1017  PAD* GetPadFast( const wxPoint& aPosition, LSET aLayerMask );
1018 
1033  PAD* GetPad( std::vector<PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask );
1034 
1040  void PadDelete( PAD* aPad );
1041 
1052  void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 );
1053 
1061  std::tuple<int, double, double> GetTrackLength( const TRACK& aTrack ) const;
1062 
1069  TRACKS TracksInNet( int aNetCode );
1070 
1083  FOOTPRINT* GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer,
1084  bool aVisibleOnly, bool aIgnoreLocked = false );
1085 
1089  void ClearAllNetCodes();
1090 
1096  void MapNets( const BOARD* aDestBoard );
1097 
1098  void SanitizeNetcodes();
1099 
1108  void AddListener( BOARD_LISTENER* aListener );
1109 
1114  void RemoveListener( BOARD_LISTENER* aListener );
1115 
1120  void OnItemChanged( BOARD_ITEM* aItem );
1121 
1126  void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
1127 
1128  /*
1129  * Consistency check of internal m_groups structure.
1130  * @param repair if true, modify groups structure until it passes the sanity check.
1131  * @return empty string on success. Or error description if there's a problem.
1132  */
1133  wxString GroupsSanityCheck( bool repair = false );
1134 
1135  /*
1136  * @param repair if true, make one modification to groups structure that brings it
1137  * closer to passing the sanity check.
1138  * @return empty string on success. Or error description if there's a problem.
1139  */
1140  wxString GroupsSanityCheckInternal( bool repair );
1141 
1143  {
1144  bool create : 1;
1145  bool ungroup : 1;
1146  bool removeItems : 1;
1147  bool enter : 1;
1148  };
1149 
1150  /*
1151  * Check which selection tool group operations are legal given the selection.
1152  * @return bit field of legal ops.
1153  */
1154  GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
1155 };
1156 #endif // CLASS_BOARD_H_
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:42
const ZONE_SETTINGS & GetZoneSettings() const override
Fetch the zone settings for this container.
Definition: board.h:579
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:785
#define DECL_DEQ_FOR_SWIG(TypeName, MemberType)
Definition: macros_swig.h:51
iterator end() const
Definition: netinfo.h:458
void InvokeListeners(Func &&aFunc, Args &&... args)
Definition: board.h:243
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
Definition: board.cpp:1946
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Definition: netinfo.h:407
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:161
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1261
PAD * GetPad(const wxPoint &aPosition, LSET aLayerMask)
Find a pad aPosition on aLayer.
Definition: board.cpp:1473
void SetFileFormatVersionAtLoad(int aVersion)
Definition: board.h:341
void BuildListOfNets()
Definition: board.h:716
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:779
const PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
Definition: board.cpp:320
ENDPOINT_T
Definition: track.h:60
const PAGE_INFO & GetPageSettings() const
Definition: board.h:589
static bool ClassOf(const EDA_ITEM *aItem)
Definition: board.h:250
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:592
Definition: typeinfo.h:84
GroupLegalOpsField GroupLegalOps(const PCB_SELECTION &selection) const
Definition: board.cpp:2086
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:513
const GROUPS & Groups() const
Definition: board.h:307
Container for project specific data.
Definition: project.h:62
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
Definition: board.h:321
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition: board.cpp:1855
ZONES & Zones()
Definition: board.h:292
wxString m_name
The canonical name of the layer.
Definition: board.h:102
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
Definition: board.h:325
ZONE * AddArea(PICKED_ITEMS_LIST *aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer, wxPoint aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch)
Add an empty copper area to board areas list.
Definition: board.cpp:1782
wxString m_fileName
Definition: board.h:197
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:1999
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
void SetDefaultZoneSettings(const ZONE_SETTINGS &aSettings)
Definition: board.h:66
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:312
bool IsLayerEnabled(PCB_LAYER_ID aLayerId) const
Test whether a given layer aLayerId is enabled.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:597
PAGE_INFO m_paper
Definition: board.h:215
const EDA_RECT GetBoardEdgesBoundingBox() const
Returns the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:793
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:306
PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates)
Definition: pcb_group.h:50
GROUPS m_groups
Definition: board.h:202
std::map< wxString, wxString > m_properties
Definition: board.h:212
~BOARD()
Definition: board.cpp:102
bool IsHighLightNetON() const
Definition: board.h:452
MARKERS & Markers()
Definition: board.h:295
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:590
LAYER_T m_type
The type of the layer.
Definition: board.h:104
const MARKERS & Markers() const
Definition: board.h:296
NETINFO_LIST::iterator EndNets() const
Definition: board.h:757
PROJECT * GetProject() const
Definition: board.h:413
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
void SetCopperLayerCount(int aCount)
Definition: board.cpp:441
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:461
void HighLightOFF()
Disable net highlight.
Definition: board.h:465
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:480
LAYER()
Definition: board.h:77
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:574
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:160
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:735
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:490
ZONE * GetArea(int index) const
Return the Zone at a given index.
Definition: board.h:894
void SetPosition(const wxPoint &aPos) override
Definition: board.cpp:242
FOOTPRINT * FindFootprintByPath(const KIID_PATH &aPath) const
Search for a FOOTPRINT within this board with the given path.
Definition: board.cpp:1294
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:164
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:447
LAYER m_layers[PCB_LAYER_ID_COUNT]
Definition: board.h:205
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
Definition: board.cpp:390
HIGH_LIGHT_INFO m_highLight
Definition: board.h:207
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:274
NETINFO_LIST m_NetInfo
Definition: board.h:232
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
HIGH_LIGHT_INFO m_highLightPrevious
Definition: board.h:208
The base class for create windows for drawing purpose.
wxString ConvertKIIDsToCrossReferences(const wxString &aSource)
Definition: board.cpp:954
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.h:496
TRACKS m_tracks
Definition: board.h:201
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: board.cpp:1083
const wxString & GetFileName() const
Definition: board.h:281
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:159
PCB_PLOT_PARAMS m_plotOptions
Definition: board.h:217
const ZONES & Zones() const
Definition: board.h:293
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:94
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
NETINFO_LIST::iterator BeginNets() const
Definition: board.h:749
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:165
void FinalizeBulkRemove(std::vector< BOARD_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
Definition: board.cpp:659
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Definition: board.cpp:407
Definition: board.h:67
FOOTPRINT * GetFootprint(const wxPoint &aPosition, PCB_LAYER_ID aActiveLayer, bool aVisibleOnly, bool aIgnoreLocked=false)
Get a footprint by its bounding rectangle at aPosition on aLayer.
Definition: board.cpp:1698
bool m_LegacyCopperEdgeClearanceLoaded
Definition: board.h:322
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:311
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: board.cpp:1117
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1406
unsigned GetNodesCount(int aNet=-1) const
Definition: board.cpp:999
BOARD_USE m_boardUse
What is this board being used for.
Definition: board.h:195
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:563
Definition: kiid.h:44
std::vector< PCB_MARKER * > ResolveDRCExclusions()
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition: board.cpp:188
PCB_LAYER_ID
A quick note on layer IDs:
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition: board.cpp:1895
int GetAreaCount() const
Definition: board.h:910
LSET is a set of PCB_LAYER_IDs.
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:1977
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:363
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:200
bool NormalizeAreaPolygon(PICKED_ITEMS_LIST *aNewZonesList, ZONE *aCurrArea)
Process an area that has been modified, by normalizing its polygon against itself.
Definition: board.cpp:1807
#define NULL
wxString GroupsSanityCheckInternal(bool repair)
Definition: board.cpp:2020
unsigned GetNetCount() const
Definition: board.h:766
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:1953
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition: board.cpp:753
ZONES m_zones
Definition: board.h:203
bool OnAreaPolygonModified(PICKED_ITEMS_LIST *aModifiedZonesList, ZONE *modified_area)
Process an area that has been modified, by normalizing its polygon and merging the intersecting polyg...
NETINFO_LIST is a container class for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:326
SHAPE_POLY_SET.
unsigned GetPadCount() const
Definition: board.cpp:1884
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:473
GAL_SET GetVisibleElements() const
Returns a set of all the element categories that are visible.
Definition: board.cpp:501
Use all material properties from model file.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition: board.cpp:1870
PAD * GetPadFast(const wxPoint &aPosition, LSET aLayerMask)
Return pad found at aPosition on aLayerMask using the fast search method.
Definition: board.cpp:1503
iterator begin() const
Definition: netinfo.h:453
FOOTPRINTS & Footprints()
Definition: board.h:286
bool TestZoneIntersections(ZONE *aZone)
Check for intersection of a given copper area with other areas in same net.
bool m_highLightOn
Definition: board.h:134
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
Definition: board.h:163
unsigned GetUnconnectedNetCount() const
Definition: board.cpp:1016
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:358
BOARD & operator=(const BOARD &aOther)=delete
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:397
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Return the type of the copper layer given by aLayer.
Definition: board.cpp:308
BOARD_USE
Flags to specify how the board is being used.
Definition: board.h:179
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition: board.cpp:1399
TITLE_BLOCK m_titles
Definition: board.h:216
void OnItemsChanged(std::vector< BOARD_ITEM * > &aItems)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:1971
Helper for storing and iterating over GAL_LAYER_IDs.
int SortedNetnamesList(wxArrayString &aNames, bool aSortbyPadsCount)
Definition: board.cpp:1332
bool m_visible
Definition: board.h:105
PAD * GetPad(const wxPoint &aPosition)
Definition: board.h:994
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines)
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
void GetSortedPadListByXthenYCoord(std::vector< PAD * > &aVector, int aNetCode=-1)
First empties then fills the vector with all pads and sorts them by increasing x coordinate,...
Definition: board.cpp:1630
bool CombineAllZonesInNet(PICKED_ITEMS_LIST *aDeletedList, int aNetCode)
Check all copper areas in net for intersections, combining them if found.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:27
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
wxString m_userName
The user defined name of the layer.
Definition: board.h:103
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
Definition: board.cpp:134
MARKERS m_markers
Definition: board.h:198
void SetFileName(const wxString &aFileName)
Definition: board.h:279
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:593
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:1986
A holder to handle information on schematic or board items.
std::unique_ptr< BOARD_DESIGN_SETTINGS > m_designSettings
All of the board design settings are stored as a JSON object inside the project file.
Definition: board.h:230
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
Definition: board.cpp:420
PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
NETINFO_LIST & GetNetInfo()
Definition: board.h:740
DRAWINGS m_drawings
Definition: board.h:199
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
Definition: board.cpp:1439
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: board.cpp:747
void ClearProject()
Definition: board.cpp:169
int GetFileFormatVersionAtLoad() const
Definition: board.h:342
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:85
const std::set< int > & GetHighLightNetCodes() const
Definition: board.h:437
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
TRACKS TracksInNet(int aNetCode)
Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
Definition: board.cpp:286
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:507
bool CombineZones(PICKED_ITEMS_LIST *aDeletedList, ZONE *aRefZone, ZONE *aZoneToCombine)
If possible, combine 2 copper areas.
void FinalizeBulkAdd(std::vector< BOARD_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
Definition: board.cpp:653
EDA_UNITS
Definition: eda_units.h:38
void SetProject(PROJECT *aProject)
Links a board to a given project.
Definition: board.cpp:140
void clear()
Definition: board.h:82
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Definition: board.cpp:376
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: board.cpp:248
std::set< int > m_netCodes
Definition: board.h:133
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
void MapNets(const BOARD *aDestBoard)
Map all nets in the given board to nets with the same name (if any) in the destination board.
Definition: board.cpp:1922
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:453
virtual void OnBoardHighlightNetChanged(BOARD &aBoard)
Definition: board.h:166
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:595
void PadDelete(PAD *aPad)
Delete a given pad from the BOARD by removing it from its footprint and from the m_NetInfo.
Definition: board.cpp:1645
const DRAWINGS & Drawings() const
Definition: board.h:290
Board layer functions and definitions.
int m_fileFormatVersionAtLoad
Definition: board.h:210
Container to hold information pertinent to a layer of a BOARD.
Definition: board.h:75
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:189
const FOOTPRINTS & Footprints() const
Definition: board.h:287
wxPoint GetPosition() const override
Definition: board.cpp:236
BOARD()
Definition: board.cpp:61
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:162
int GetCopperLayerCount() const
Definition: board.cpp:435
void SanitizeNetcodes()
Definition: board.cpp:1936
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
Definition: board.h:213
Handle the component boundary box.
Definition: eda_rect.h:42
PCB_EDIT_FRAME is the main frame for Pcbnew.
void SetZoneSettings(const ZONE_SETTINGS &aSettings) override
Set the zone settings for this container.
Definition: board.h:584
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:1965
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:665
The common library.
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const wxPoint &pt)> OUTLINE_ERROR_HANDLER
wxString GetClass() const override
Return the class name.
Definition: board.h:863
const TRACKS & Tracks() const
Definition: board.h:284
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1022
unsigned GetNetCount() const
Function GetNetCount.
Definition: netinfo.h:353
wxString GroupsSanityCheck(bool repair=false)
Definition: board.cpp:2009
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:46
virtual ~BOARD_LISTENER()
Definition: board.h:158
FOOTPRINTS m_footprints
Definition: board.h:200
void DeleteAllFootprints()
Removes all footprints from the deque and frees the memory associated with them.
Definition: board.h:371
const wxPoint GetFocusPosition() const override
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: board.h:332
ZONE_SETTINGS & GetDefaultZoneSettings()
Abstract interface for BOARD_ITEMs capable of storing other items inside.
int m_number
The layer ID.
Definition: board.h:106
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
#define DECL_VEC_FOR_SWIG(TypeName, MemberType)
Declare a std::vector but no swig template.
Definition: macros_swig.h:50
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false)
Definition: board.cpp:1762
bool IsFootprintLayerVisible(PCB_LAYER_ID aLayer)
Expect either of the two layers on which a footprint can reside, and returns whether that layer is vi...
Definition: board.cpp:546
Definition: pad.h:60
const wxPoint GetCenter() const
Definition: eda_rect.h:109
std::tuple< int, double, double > GetTrackLength(const TRACK &aTrack) const
Returns data on the length and number of track segments connected to a given track.
Definition: board.cpp:1655
SEARCH_RESULT
Definition: eda_item.h:40
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:220
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
Definition: board.h:62
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition: board.h:267
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:60
std::vector< wxString > GetNetClassAssignmentCandidates()
Return a list of name candidates for netclass assignment.
Definition: board.cpp:1385
DRAWINGS & Drawings()
Definition: board.h:289
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition: board.cpp:864
bool IsEmpty() const
Definition: board.h:334
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource)
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition: board.cpp:900
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition: board.h:317
void ClearAllNetCodes()
Reset all items' netcodes to 0 (no net).
Definition: board.cpp:1915
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings Changes the bit-mask of ena...
Definition: board.cpp:467
std::vector< BOARD_LISTENER * > m_listeners
Definition: board.h:234
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
TRACKS & Tracks()
Definition: board.h:283
void buildListOfNets()
Function buildListOfNets builds or rebuilds the list of NETINFO_ITEMs The list is sorted by names.
HIGH_LIGHT_INFO()
Definition: board.h:142
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:260
Definition: track.h:83
const TITLE_BLOCK & GetTitleBlock() const
Definition: board.h:596
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition: board.cpp:1282
PROJECT * m_project
Definition: board.h:218
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:161
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:657
void Clear()
Definition: board.h:136
Container for design settings for a BOARD object.
GAL_SET m_LegacyVisibleItems
Definition: board.h:318