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 #include <drc/drc_rtree.h>
39 
40 class BOARD_COMMIT;
41 class PCB_BASE_FRAME;
42 class PCB_EDIT_FRAME;
43 class PICKED_ITEMS_LIST;
44 class BOARD;
45 class ZONE;
46 class TRACK;
47 class PAD;
48 class PCB_MARKER;
49 class MSG_PANEL_ITEM;
50 class NETLIST;
51 class REPORTER;
52 class SHAPE_POLY_SET;
53 class CONNECTIVITY_DATA;
54 class COMPONENT;
55 class PROJECT;
56 
57 // Forward declare endpoint from class_track.h
58 enum ENDPOINT_T : int;
59 
63 enum LAYER_T
64 {
70 };
71 
72 
76 struct LAYER
77 {
79  {
80  clear();
81  }
82 
83  void clear()
84  {
85  m_type = LT_SIGNAL;
86  m_visible = true;
87  m_number = 0;
88  m_name.clear();
89  m_userName.clear();
90  }
91 
92  /*
93  LAYER( const wxString& aName = wxEmptyString,
94  LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
95  m_name( aName ),
96  m_type( aType ),
97  m_visible( aVisible ),
98  m_number( aNumber )
99  {
100  }
101  */
102 
103  wxString m_name;
104  wxString m_userName;
106  bool m_visible;
107  int m_number;
108 
115  static const char* ShowType( LAYER_T aType );
116 
124  static LAYER_T ParseType( const char* aType );
125 };
126 
127 
128 // Helper class to handle high light nets
130 {
131  friend class BOARD;
132 
133 protected:
134  std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
135  bool m_highLightOn; // highlight active
136 
137  void Clear()
138  {
139  m_netCodes.clear();
140  m_highLightOn = false;
141  }
142 
144  {
145  Clear();
146  }
147 };
148 
154 class BOARD;
155 
157 {
158 public:
159  virtual ~BOARD_LISTENER() { }
160  virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
161  virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
162  virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
163  virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
164  virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
165  virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
166  virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
167  virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
168 };
169 
170 
171 DECL_VEC_FOR_SWIG( MARKERS, PCB_MARKER* )
173 DECL_DEQ_FOR_SWIG( TRACKS, TRACK* )
174 // Dequeue rather than Vector just so we can use moveUnflaggedItems in pcbnew_control.cpp
175 DECL_DEQ_FOR_SWIG( GROUPS, PCB_GROUP* )
176 
177 
180 enum class BOARD_USE
181 {
182  NORMAL, // A normal board
183  FPHOLDER // A board that holds a single footprint
184 };
185 
186 
191 {
192  friend class PCB_EDIT_FRAME;
193 
194 private:
197  int m_timeStamp; // actually a modification counter
198 
199  wxString m_fileName;
200  MARKERS m_markers;
201  DRAWINGS m_drawings;
202  FOOTPRINTS m_footprints;
203  TRACKS m_tracks;
204  GROUPS m_groups;
206 
208 
209  HIGH_LIGHT_INFO m_highLight; // current high light data
210  HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
211 
212  int m_fileFormatVersionAtLoad; // the version loaded from the file
213 
214  std::map<wxString, wxString> m_properties;
215  std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
216 
218  TITLE_BLOCK m_titles; // text in lower right of screen and plots
220  PROJECT* m_project; // project this board is a part of
221 
232  std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
233 
234  NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
235 
236  std::vector<BOARD_LISTENER*> m_listeners;
237 
238  // The default copy constructor & operator= are inadequate,
239  // either write one or do not use it at all
240  BOARD( const BOARD& aOther ) = delete;
241 
242  BOARD& operator=( const BOARD& aOther ) = delete;
243 
244  template <typename Func, typename... Args>
245  void InvokeListeners( Func&& aFunc, Args&&... args )
246  {
247  for( auto&& l : m_listeners )
248  ( l->*aFunc )( std::forward<Args>( args )... );
249  }
250 
251 public:
252  static inline bool ClassOf( const EDA_ITEM* aItem )
253  {
254  return aItem && PCB_T == aItem->Type();
255  }
256 
262  void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
263 
269  BOARD_USE GetBoardUse() const { return m_boardUse; }
270 
272  {
273  m_timeStamp++;
274 
275  {
276  std::unique_lock<std::mutex> cacheLock( m_CachesMutex );
277  m_InsideAreaCache.clear();
278  m_InsideCourtyardCache.clear();
279  m_InsideFCourtyardCache.clear();
280  m_InsideBCourtyardCache.clear();
281  }
282 
283  m_CopperZoneRTrees.clear();
284  }
285 
286  int GetTimeStamp() { return m_timeStamp; }
287 
293  bool IsFootprintHolder() const
294  {
296  }
297 
298  void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
299 
300  const wxString &GetFileName() const { return m_fileName; }
301 
302  TRACKS& Tracks() { return m_tracks; }
303  const TRACKS& Tracks() const { return m_tracks; }
304 
305  FOOTPRINTS& Footprints() { return m_footprints; }
306  const FOOTPRINTS& Footprints() const { return m_footprints; }
307 
308  DRAWINGS& Drawings() { return m_drawings; }
309  const DRAWINGS& Drawings() const { return m_drawings; }
310 
311  ZONES& Zones() { return m_zones; }
312  const ZONES& Zones() const { return m_zones; }
313 
314  MARKERS& Markers() { return m_markers; }
315  const MARKERS& Markers() const { return m_markers; }
316 
325  GROUPS& Groups() { return m_groups; }
326  const GROUPS& Groups() const { return m_groups; }
327 
328  const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
329 
330  const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
331  void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
332 
333  bool ResolveTextVar( wxString* token, int aDepth ) const;
334 
338 
342 
345 
346  BOARD();
347  ~BOARD();
348 
349  wxPoint GetPosition() const override;
350  void SetPosition( const wxPoint& aPos ) override;
351  const wxPoint GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
352 
353  bool IsEmpty() const
354  {
355  return m_drawings.empty() && m_footprints.empty() && m_tracks.empty() && m_zones.empty();
356  }
357 
358  void Move( const wxPoint& aMoveVector ) override;
359 
360  void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
362 
363  void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT ) override;
364 
365  void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
366 
370  void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
371 
375  void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
376 
383  {
384  return m_footprints.empty() ? nullptr : m_footprints.front();
385  }
386 
391  {
392  for( FOOTPRINT* footprint : m_footprints )
393  delete footprint;
394 
395  m_footprints.clear();
396  }
397 
402  BOARD_ITEM* GetItem( const KIID& aID ) const;
403 
404  void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
405 
409  wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const;
410  wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const;
411 
416  std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
417 
423  void BuildConnectivity();
424 
428  void DeleteMARKERs();
429 
430  void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
431 
432  PROJECT* GetProject() const { return m_project; }
433 
439  void SetProject( PROJECT* aProject );
440 
441  void ClearProject();
442 
446  std::vector<PCB_MARKER*> ResolveDRCExclusions();
447 
451  void ResetNetHighLight();
452 
456  const std::set<int>& GetHighLightNetCodes() const
457  {
458  return m_highLight.m_netCodes;
459  }
460 
466  void SetHighLightNet( int aNetCode, bool aMulti = false );
467 
471  bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
472 
479  void HighLightON( bool aValue = true );
480 
485  {
486  HighLightON( false );
487  }
488 
492  int GetCopperLayerCount() const;
493  void SetCopperLayerCount( int aCount );
494 
500  LSET GetEnabledLayers() const;
501 
507  void SetEnabledLayers( LSET aLayerMask );
508 
515  bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const
516  {
517  return GetDesignSettings().IsLayerEnabled( aLayer );
518  }
519 
526  bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
527 
533  LSET GetVisibleLayers() const;
534 
540  void SetVisibleLayers( LSET aLayerMask );
541 
542  // these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
543  // are not stored in the bitmap.
544 
550  GAL_SET GetVisibleElements() const;
551 
558  void SetVisibleElements( const GAL_SET& aMask );
559 
564  void SetVisibleAlls();
565 
572  bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
573 
580  void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
581 
588  bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
589 
594  {
595  return *m_designSettings;
596  }
597 
598  const ZONE_SETTINGS& GetZoneSettings() const override
599  {
601  }
602 
603  void SetZoneSettings( const ZONE_SETTINGS& aSettings ) override
604  {
606  }
607 
608  const PAGE_INFO& GetPageSettings() const { return m_paper; }
609  void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
610 
611  const PCB_PLOT_PARAMS& GetPlotOptions() const { return m_plotOptions; }
612  void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
613 
615  const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
616  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
617 
618  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
619 
630  bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
631  OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
632 
640  void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const;
641 
645  const PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
646 
654  const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
655 
664  bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
665 
676  static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
677  {
678  // a BOARD's standard layer name is the PCB_LAYER_ID fixed name
679  return LayerName( aLayerId );
680  }
681 
689  bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
690 
698  LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
699 
707  bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
708 
713  unsigned GetNodesCount( int aNet = -1 ) const;
714 
718  unsigned GetUnconnectedNetCount() const;
719 
723  unsigned GetPadCount() const;
724 
733  const std::vector<PAD*> GetPads() const;
734 
736  {
738  }
739 
745  NETINFO_ITEM* FindNet( int aNetcode ) const;
746 
752  NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
753 
754  const NETINFO_LIST& GetNetInfo() const
755  {
756  return m_NetInfo;
757  }
758 
760  {
761  return m_NetInfo;
762  }
763 
764 #ifndef SWIG
765 
769  {
770  return m_NetInfo.begin();
771  }
772 
777  {
778  return m_NetInfo.end();
779  }
780 #endif
781 
785  unsigned GetNetCount() const
786  {
787  return m_NetInfo.GetNetCount();
788  }
789 
796  EDA_RECT ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
797 
798  const EDA_RECT GetBoundingBox() const override
799  {
800  return ComputeBoundingBox( false );
801  }
802 
813  {
814  return ComputeBoundingBox( true );
815  }
816 
817  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
818 
831  SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
832 
842  FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
843 
850  FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
851 
858  int SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount );
859 
866  std::vector<wxString> GetNetClassAssignmentCandidates() const;
867 
876 
880  void SynchronizeProperties();
881 
882  wxString GetClass() const override
883  {
884  return wxT( "BOARD" );
885  }
886 
887 #if defined(DEBUG)
888  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
889 #endif
890 
891 
892  /*************************/
893  /* Copper Areas handling */
894  /*************************/
895 
906 
913  ZONE* GetArea( int index ) const
914  {
915  if( (unsigned) index < m_zones.size() )
916  return m_zones[index];
917 
918  return NULL;
919  }
920 
924  std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false ) const;
925 
929  int GetAreaCount() const
930  {
931  return static_cast<int>( m_zones.size() );
932  }
933 
934  /* Functions used in test, merge and cut outlines */
935 
947  ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
948  wxPoint aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
949 
958  bool NormalizeAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, ZONE* aCurrArea );
959 
969  bool OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList, ZONE* modified_area );
970 
977  bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
978 
986  PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask ) const;
987  PAD* GetPad( const wxPoint& aPosition ) const
988  {
989  return GetPad( aPosition, LSET().set() );
990  }
991 
999  PAD* GetPad( const TRACK* aTrace, ENDPOINT_T aEndPoint ) const;
1000 
1010  PAD* GetPadFast( const wxPoint& aPosition, LSET aLayerMask ) const;
1011 
1026  PAD* GetPad( std::vector<PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask ) const;
1027 
1033  void PadDelete( PAD* aPad );
1034 
1045  void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
1046 
1054  std::tuple<int, double, double> GetTrackLength( const TRACK& aTrack ) const;
1055 
1062  TRACKS TracksInNet( int aNetCode );
1063 
1076  FOOTPRINT* GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer,
1077  bool aVisibleOnly, bool aIgnoreLocked = false ) const;
1078 
1082  void ClearAllNetCodes();
1083 
1089  void MapNets( const BOARD* aDestBoard );
1090 
1091  void SanitizeNetcodes();
1092 
1101  void AddListener( BOARD_LISTENER* aListener );
1102 
1107  void RemoveListener( BOARD_LISTENER* aListener );
1108 
1113  void OnItemChanged( BOARD_ITEM* aItem );
1114 
1119  void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
1120 
1121  /*
1122  * Consistency check of internal m_groups structure.
1123  * @param repair if true, modify groups structure until it passes the sanity check.
1124  * @return empty string on success. Or error description if there's a problem.
1125  */
1126  wxString GroupsSanityCheck( bool repair = false );
1127 
1128  /*
1129  * @param repair if true, make one modification to groups structure that brings it
1130  * closer to passing the sanity check.
1131  * @return empty string on success. Or error description if there's a problem.
1132  */
1133  wxString GroupsSanityCheckInternal( bool repair );
1134 
1136  {
1137  bool create : 1;
1138  bool ungroup : 1;
1139  bool removeItems : 1;
1140  bool enter : 1;
1141  };
1142 
1143  /*
1144  * Check which selection tool group operations are legal given the selection.
1145  * @return bit field of legal ops.
1146  */
1147  GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
1148 
1149 public:
1150  // ------------ Run-time caches -------------
1151 
1152  std::mutex m_CachesMutex;
1153  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideCourtyardCache;
1154  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideFCourtyardCache;
1155  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideBCourtyardCache;
1156  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideAreaCache;
1157 
1158  std::map< ZONE*, std::unique_ptr<DRC_RTREE> > m_CopperZoneRTrees;
1159 };
1160 #endif // CLASS_BOARD_H_
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:43
const ZONE_SETTINGS & GetZoneSettings() const override
Fetch the zone settings for this container.
Definition: board.h:598
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:813
#define DECL_DEQ_FOR_SWIG(TypeName, MemberType)
Definition: macros_swig.h:51
iterator end() const
Definition: netinfo.h:441
void InvokeListeners(Func &&aFunc, Args &&... args)
Definition: board.h:245
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:2013
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:162
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1289
void SetFileFormatVersionAtLoad(int aVersion)
Definition: board.h:360
void BuildListOfNets()
Definition: board.h:735
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:798
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:608
static bool ClassOf(const EDA_ITEM *aItem)
Definition: board.h:252
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:611
Definition: typeinfo.h:84
GroupLegalOpsField GroupLegalOps(const PCB_SELECTION &selection) const
Definition: board.cpp:2155
std::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideCourtyardCache
Definition: board.h:1153
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:326
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:340
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:1922
ZONES & Zones()
Definition: board.h:311
wxString m_name
The canonical name of the layer.
Definition: board.h:103
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
Definition: board.h:344
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:1849
wxString m_fileName
Definition: board.h:199
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines) const
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:2066
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)
PAD * GetPad(const wxPoint &aPosition) const
Definition: board.h:987
Definition: board.h:67
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:331
bool IsLayerEnabled(PCB_LAYER_ID aLayerId) const
Test whether a given layer aLayerId is enabled.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:616
PAGE_INFO m_paper
Definition: board.h:217
const EDA_RECT GetBoardEdgesBoundingBox() const
Returns the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:812
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:325
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
GROUPS m_groups
Definition: board.h:204
std::map< wxString, wxString > m_properties
Definition: board.h:214
~BOARD()
Definition: board.cpp:101
bool IsHighLightNetON() const
Definition: board.h:471
MARKERS & Markers()
Definition: board.h:314
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:609
LAYER_T m_type
The type of the layer.
Definition: board.h:105
const MARKERS & Markers() const
Definition: board.h:315
NETINFO_LIST::iterator EndNets() const
Definition: board.h:776
PROJECT * GetProject() const
Definition: board.h:432
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:484
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:78
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:161
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:754
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:490
PAD * GetPad(const wxPoint &aPosition, LSET aLayerMask) const
Find a pad aPosition on aLayer.
Definition: board.cpp:1501
ZONE * GetArea(int index) const
Return the Zone at a given index.
Definition: board.h:913
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:1322
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:165
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:207
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:209
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:293
NETINFO_LIST m_NetInfo
Definition: board.h:234
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
HIGH_LIGHT_INFO m_highLightPrevious
Definition: board.h:210
The base class for create windows for drawing purpose.
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:515
bool IsFootprintLayerVisible(PCB_LAYER_ID aLayer) const
Expect either of the two layers on which a footprint can reside, and returns whether that layer is vi...
Definition: board.cpp:546
TRACKS m_tracks
Definition: board.h:203
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:1111
const wxString & GetFileName() const
Definition: board.h:300
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:160
PCB_PLOT_PARAMS m_plotOptions
Definition: board.h:219
FOOTPRINT * GetFootprint(const wxPoint &aPosition, PCB_LAYER_ID aActiveLayer, bool aVisibleOnly, bool aIgnoreLocked=false) const
Get a footprint by its bounding rectangle at aPosition on aLayer.
Definition: board.cpp:1765
const ZONES & Zones() const
Definition: board.h:312
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:95
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
std::mutex m_CachesMutex
Definition: board.h:1152
NETINFO_LIST::iterator BeginNets() const
Definition: board.h:768
PAD * GetPadFast(const wxPoint &aPosition, LSET aLayerMask) const
Return pad found at aPosition on aLayerMask using the fast search method.
Definition: board.cpp:1531
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:166
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:68
bool m_LegacyCopperEdgeClearanceLoaded
Definition: board.h:341
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:330
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:1145
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false) const
Definition: board.cpp:1829
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1434
unsigned GetNodesCount(int aNet=-1) const
Definition: board.cpp:1027
BOARD_USE m_boardUse
What is this board being used for.
Definition: board.h:196
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:1962
int GetAreaCount() const
Definition: board.h:929
LSET is a set of PCB_LAYER_IDs.
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:2044
FOOTPRINT * GetFirstFootprint() const
Gets the first footprint on the board or nullptr.
Definition: board.h:382
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:205
bool NormalizeAreaPolygon(PICKED_ITEMS_LIST *aNewZonesList, ZONE *aCurrArea)
Process an area that has been modified, by normalizing its polygon against itself.
Definition: board.cpp:1874
#define NULL
wxString GroupsSanityCheckInternal(bool repair)
Definition: board.cpp:2089
unsigned GetNetCount() const
Definition: board.h:785
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:2020
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition: board.cpp:781
ZONES m_zones
Definition: board.h:205
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...
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:315
Represent a set of closed polygons.
unsigned GetPadCount() const
Definition: board.cpp:1951
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:1937
iterator begin() const
Definition: netinfo.h:436
FOOTPRINTS & Footprints()
Definition: board.h:305
bool m_highLightOn
Definition: board.h:135
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
Definition: board.h:164
unsigned GetUnconnectedNetCount() const
Definition: board.cpp:1044
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:416
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:180
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition: board.cpp:1427
TITLE_BLOCK m_titles
Definition: board.h:218
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:2038
Helper for storing and iterating over GAL_LAYER_IDs.
int SortedNetnamesList(wxArrayString &aNames, bool aSortbyPadsCount)
Definition: board.cpp:1360
bool m_visible
Definition: board.h:106
std::vector< wxString > GetNetClassAssignmentCandidates() const
Return a list of name candidates for netclass assignment.
Definition: board.cpp:1413
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:27
Handle 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:104
void BuildConnectivity()
Builds or rebuilds the board connectivity database for the board, especially the list of connected it...
Definition: board.cpp:133
MARKERS m_markers
Definition: board.h:200
void SetFileName(const wxString &aFileName)
Definition: board.h:298
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:612
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:2053
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:232
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:759
DRAWINGS m_drawings
Definition: board.h:201
void IncrementTimeStamp()
Definition: board.h:271
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
Definition: board.cpp:1467
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:775
void ClearProject()
Definition: board.cpp:169
int GetFileFormatVersionAtLoad() const
Definition: board.h:361
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:83
const std::set< int > & GetHighLightNetCodes() const
Definition: board.h:456
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
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:139
void clear()
Definition: board.h:83
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:134
Handle the data for a net.
Definition: netinfo.h:64
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:1989
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:167
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:614
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:1673
const DRAWINGS & Drawings() const
Definition: board.h:309
Board layer functions and definitions.
int m_fileFormatVersionAtLoad
Definition: board.h:212
Container to hold information pertinent to a layer of a BOARD.
Definition: board.h:76
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
const FOOTPRINTS & Footprints() const
Definition: board.h:306
wxPoint GetPosition() const override
Definition: board.cpp:236
BOARD()
Definition: board.cpp:59
int GetTimeStamp()
Definition: board.h:286
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:163
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition: board.cpp:928
void GetSortedPadListByXthenYCoord(std::vector< PAD * > &aVector, int aNetCode=-1) const
First empties then fills the vector with all pads and sorts them by increasing x coordinate,...
Definition: board.cpp:1658
int GetCopperLayerCount() const
Definition: board.cpp:435
void SanitizeNetcodes()
Definition: board.cpp:2003
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
Definition: board.h:215
Handle the component boundary box.
Definition: eda_rect.h:42
The main frame for Pcbnew.
void SetZoneSettings(const ZONE_SETTINGS &aSettings) override
Set the zone settings for this container.
Definition: board.h:603
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:2032
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
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:882
const TRACKS & Tracks() const
Definition: board.h:303
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1050
std::map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTrees
Definition: board.h:1158
unsigned GetNetCount() const
Definition: netinfo.h:339
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition: board.cpp:982
wxString GroupsSanityCheck(bool repair=false)
Definition: board.cpp:2076
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:46
virtual ~BOARD_LISTENER()
Definition: board.h:159
FOOTPRINTS m_footprints
Definition: board.h:202
void DeleteAllFootprints()
Removes all footprints from the deque and frees the memory associated with them.
Definition: board.h:390
const wxPoint GetFocusPosition() const override
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: board.h:351
ZONE_SETTINGS & GetDefaultZoneSettings()
Abstract interface for BOARD_ITEMs capable of storing other items inside.
int m_number
The layer ID.
Definition: board.h:107
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::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideBCourtyardCache
Definition: board.h:1155
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:1683
SEARCH_RESULT
Definition: eda_item.h:41
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:63
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition: board.h:269
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:60
std::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideAreaCache
Definition: board.h:1156
DRAWINGS & Drawings()
Definition: board.h:308
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition: board.cpp:892
bool IsEmpty() const
Definition: board.h:353
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition: board.h:336
void ClearAllNetCodes()
Reset all items' netcodes to 0 (no net).
Definition: board.cpp:1982
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:236
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
TRACKS & Tracks()
Definition: board.h:302
void buildListOfNets()
Rebuild the list of NETINFO_ITEMs.
HIGH_LIGHT_INFO()
Definition: board.h:143
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:262
Definition: track.h:83
const TITLE_BLOCK & GetTitleBlock() const
Definition: board.h:615
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition: board.cpp:1310
PROJECT * m_project
Definition: board.h:220
int m_timeStamp
Definition: board.h:197
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:676
void Clear()
Definition: board.h:137
Container for design settings for a BOARD object.
std::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideFCourtyardCache
Definition: board.h:1154
GAL_SET m_LegacyVisibleItems
Definition: board.h:337