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-2021 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_item_container.h>
29 #include <common.h> // Needed for stl hash extensions
30 #include <convert_drawsegment_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
32 #include <netinfo.h>
33 #include <pcb_item_containers.h>
34 #include <pcb_plot_params.h>
35 #include <title_block.h>
36 #include <tools/pcb_selection.h>
37 #include <mutex>
38 #include <list>
39 
42 class BOARD_COMMIT;
43 class DRC_RTREE;
44 class PCB_BASE_FRAME;
45 class PCB_EDIT_FRAME;
46 class PICKED_ITEMS_LIST;
47 class BOARD;
48 class FOOTPRINT;
49 class ZONE;
50 class PCB_TRACK;
51 class PAD;
52 class PCB_GROUP;
53 class PCB_MARKER;
54 class MSG_PANEL_ITEM;
55 class NETLIST;
56 class REPORTER;
57 class SHAPE_POLY_SET;
58 class CONNECTIVITY_DATA;
59 class COMPONENT;
60 class PROJECT;
61 
62 // Forward declare endpoint from class_track.h
63 enum ENDPOINT_T : int;
64 
68 enum LAYER_T
69 {
75 };
76 
77 
81 struct LAYER
82 {
84  {
85  clear();
86  }
87 
88  void clear()
89  {
90  m_type = LT_SIGNAL;
91  m_visible = true;
92  m_number = 0;
93  m_name.clear();
94  m_userName.clear();
95  }
96 
97  /*
98  LAYER( const wxString& aName = wxEmptyString,
99  LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
100  m_name( aName ),
101  m_type( aType ),
102  m_visible( aVisible ),
103  m_number( aNumber )
104  {
105  }
106  */
107 
108  wxString m_name;
109  wxString m_userName;
111  bool m_visible;
112  int m_number;
113 
120  static const char* ShowType( LAYER_T aType );
121 
129  static LAYER_T ParseType( const char* aType );
130 };
131 
132 
133 // Helper class to handle high light nets
135 {
136 protected:
137  std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
138  bool m_highLightOn; // highlight active
139 
140  void Clear()
141  {
142  m_netCodes.clear();
143  m_highLightOn = false;
144  }
145 
147  {
148  Clear();
149  }
150 
151 private:
152  friend class BOARD;
153 };
154 
160 class BOARD;
161 
163 {
164 public:
165  virtual ~BOARD_LISTENER() { }
166  virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
167  virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
168  virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
169  virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
170  virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
171  virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
172  virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
173  virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
174 };
175 
176 
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 public:
193  static inline bool ClassOf( const EDA_ITEM* aItem )
194  {
195  return aItem && PCB_T == aItem->Type();
196  }
197 
203  void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
204 
210  BOARD_USE GetBoardUse() const { return m_boardUse; }
211 
212  void IncrementTimeStamp();
213 
214  int GetTimeStamp() { return m_timeStamp; }
215 
221  bool IsFootprintHolder() const
222  {
224  }
225 
226  void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
227 
228  const wxString &GetFileName() const { return m_fileName; }
229 
230  TRACKS& Tracks() { return m_tracks; }
231  const TRACKS& Tracks() const { return m_tracks; }
232 
233  FOOTPRINTS& Footprints() { return m_footprints; }
234  const FOOTPRINTS& Footprints() const { return m_footprints; }
235 
236  DRAWINGS& Drawings() { return m_drawings; }
237  const DRAWINGS& Drawings() const { return m_drawings; }
238 
239  ZONES& Zones() { return m_zones; }
240  const ZONES& Zones() const { return m_zones; }
241 
242  MARKERS& Markers() { return m_markers; }
243  const MARKERS& Markers() const { return m_markers; }
244 
253  GROUPS& Groups() { return m_groups; }
254  const GROUPS& Groups() const { return m_groups; }
255 
256  const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
257 
258  const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
259  void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
260 
261  bool ResolveTextVar( wxString* token, int aDepth ) const;
262 
266 
270 
273 
274  BOARD();
275  ~BOARD();
276 
277  wxPoint GetPosition() const override;
278  void SetPosition( const wxPoint& aPos ) override;
279  const wxPoint GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
280 
281  bool IsEmpty() const
282  {
283  return m_drawings.empty() && m_footprints.empty() && m_tracks.empty() && m_zones.empty();
284  }
285 
286  void Move( const wxPoint& aMoveVector ) override;
287 
288  void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
290 
291  void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
292  const wxString& GetGenerator() const { return m_generator; }
293 
294  void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT ) override;
295 
296  void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
297 
302  void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
303 
308  void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
309 
318  {
319  return m_footprints.empty() ? nullptr : m_footprints.front();
320  }
321 
325  void DeleteAllFootprints();
326 
330  BOARD_ITEM* GetItem( const KIID& aID ) const;
331 
332  void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
333 
337  wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const;
338  wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const;
339 
344  std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
345 
351  void BuildConnectivity();
352 
356  void DeleteMARKERs();
357 
358  void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
359 
360  PROJECT* GetProject() const { return m_project; }
361 
369  void SetProject( PROJECT* aProject );
370 
371  void ClearProject();
372 
376  std::vector<PCB_MARKER*> ResolveDRCExclusions();
377 
381  void ResetNetHighLight();
382 
386  const std::set<int>& GetHighLightNetCodes() const
387  {
388  return m_highLight.m_netCodes;
389  }
390 
397  void SetHighLightNet( int aNetCode, bool aMulti = false );
398 
402  bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
403 
411  void HighLightON( bool aValue = true );
412 
417  {
418  HighLightON( false );
419  }
420 
424  int GetCopperLayerCount() const;
425  void SetCopperLayerCount( int aCount );
426 
432  LSET GetEnabledLayers() const;
433 
439  void SetEnabledLayers( LSET aLayerMask );
440 
447  bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const;
448 
456  bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
457 
463  LSET GetVisibleLayers() const;
464 
471  void SetVisibleLayers( LSET aLayerMask );
472 
473  // these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
474  // are not stored in the bitmap.
475 
482  GAL_SET GetVisibleElements() const;
483 
490  void SetVisibleElements( const GAL_SET& aMask );
491 
497  void SetVisibleAlls();
498 
506  bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
507 
515  void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
516 
524  bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
525 
530 
531  const ZONE_SETTINGS& GetZoneSettings() const override;
532 
533  void SetZoneSettings( const ZONE_SETTINGS& aSettings ) override;
534 
535  const PAGE_INFO& GetPageSettings() const { return m_paper; }
536  void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
537 
538  const PCB_PLOT_PARAMS& GetPlotOptions() const { return m_plotOptions; }
539  void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
540 
542  const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
543  void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
544 
545  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
546 
558  bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines,
559  OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
560 
571  void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const;
572 
576  const PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
577 
584  const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
585 
593  bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
594 
605  static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
606  {
607  // a BOARD's standard layer name is the PCB_LAYER_ID fixed name
608  return LayerName( aLayerId );
609  }
610 
618  bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
619 
626  LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
627 
635  bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
636 
641  unsigned GetNodesCount( int aNet = -1 ) const;
642 
646  unsigned GetUnconnectedNetCount() const;
647 
651  unsigned GetPadCount() const;
652 
661  const std::vector<PAD*> GetPads() const;
662 
664  {
666  }
667 
674  NETINFO_ITEM* FindNet( int aNetcode ) const;
675 
682  NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
683 
684  const NETINFO_LIST& GetNetInfo() const
685  {
686  return m_NetInfo;
687  }
688 
690  {
691  return m_NetInfo;
692  }
693 
694 #ifndef SWIG
695 
699  {
700  return m_NetInfo.begin();
701  }
702 
707  {
708  return m_NetInfo.end();
709  }
710 #endif
711 
715  unsigned GetNetCount() const
716  {
717  return m_NetInfo.GetNetCount();
718  }
719 
726  EDA_RECT ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
727 
728  const EDA_RECT GetBoundingBox() const override
729  {
730  return ComputeBoundingBox( false );
731  }
732 
743  {
744  return ComputeBoundingBox( true );
745  }
746 
747  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
748 
761  SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
762 
771  FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
772 
779  FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
780 
787  std::vector<wxString> GetNetClassAssignmentCandidates() const;
788 
797 
801  void SynchronizeProperties();
802 
803  wxString GetClass() const override
804  {
805  return wxT( "BOARD" );
806  }
807 
808 #if defined(DEBUG)
809  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
810 #endif
811 
812 
813  /*************************/
814  /* Copper Areas handling */
815  /*************************/
816 
827 
834  ZONE* GetArea( int index ) const
835  {
836  if( (unsigned) index < m_zones.size() )
837  return m_zones[index];
838 
839  return nullptr;
840  }
841 
845  std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false ) const;
846 
850  int GetAreaCount() const
851  {
852  return static_cast<int>( m_zones.size() );
853  }
854 
855  /* Functions used in test, merge and cut outlines */
856 
869  ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
870  wxPoint aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
871 
882  bool NormalizeAreaPolygon( PICKED_ITEMS_LIST* aNewZonesList, ZONE* aCurrArea );
883 
895  bool OnAreaPolygonModified( PICKED_ITEMS_LIST* aModifiedZonesList, ZONE* modified_area );
896 
904  bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
905 
913  PAD* GetPad( const wxPoint& aPosition, LSET aLayerMask ) const;
914  PAD* GetPad( const wxPoint& aPosition ) const
915  {
916  return GetPad( aPosition, LSET().set() );
917  }
918 
926  PAD* GetPad( const PCB_TRACK* aTrace, ENDPOINT_T aEndPoint ) const;
927 
937  PAD* GetPadFast( const wxPoint& aPosition, LSET aLayerMask ) const;
938 
953  PAD* GetPad( std::vector<PAD*>& aPadList, const wxPoint& aPosition, LSET aLayerMask ) const;
954 
961  void PadDelete( PAD* aPad );
962 
974  void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
975 
983  std::tuple<int, double, double> GetTrackLength( const PCB_TRACK& aTrack ) const;
984 
992  TRACKS TracksInNet( int aNetCode );
993 
1006  FOOTPRINT* GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer,
1007  bool aVisibleOnly, bool aIgnoreLocked = false ) const;
1008 
1012  void ClearAllNetCodes();
1013 
1019  void MapNets( const BOARD* aDestBoard );
1020 
1021  void SanitizeNetcodes();
1022 
1031  void AddListener( BOARD_LISTENER* aListener );
1032 
1037  void RemoveListener( BOARD_LISTENER* aListener );
1038 
1043  void OnItemChanged( BOARD_ITEM* aItem );
1044 
1049  void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
1050 
1057  wxString GroupsSanityCheck( bool repair = false );
1058 
1064  wxString GroupsSanityCheckInternal( bool repair );
1065 
1067  {
1068  bool create : 1;
1069  bool ungroup : 1;
1070  bool removeItems : 1;
1071  bool enter : 1;
1072  };
1073 
1079  GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
1080 
1081  // ------------ Run-time caches -------------
1082  std::mutex m_CachesMutex;
1083  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideCourtyardCache;
1084  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideFCourtyardCache;
1085  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideBCourtyardCache;
1086  std::map< std::pair<BOARD_ITEM*, BOARD_ITEM*>, bool > m_InsideAreaCache;
1087 
1088  std::map< ZONE*, std::unique_ptr<DRC_RTREE> > m_CopperZoneRTrees;
1089 
1090 private:
1091  // The default copy constructor & operator= are inadequate,
1092  // either write one or do not use it at all
1093  BOARD( const BOARD& aOther ) = delete;
1094 
1095  BOARD& operator=( const BOARD& aOther ) = delete;
1096 
1097  template <typename Func, typename... Args>
1098  void InvokeListeners( Func&& aFunc, Args&&... args )
1099  {
1100  for( auto&& l : m_listeners )
1101  ( l->*aFunc )( std::forward<Args>( args )... );
1102  }
1103 
1104  friend class PCB_EDIT_FRAME;
1105 
1108  int m_timeStamp; // actually a modification counter
1109 
1110  wxString m_fileName;
1111  MARKERS m_markers;
1112  DRAWINGS m_drawings;
1113  FOOTPRINTS m_footprints;
1114  TRACKS m_tracks;
1115  GROUPS m_groups;
1117 
1119 
1120  HIGH_LIGHT_INFO m_highLight; // current high light data
1121  HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
1122 
1123  int m_fileFormatVersionAtLoad; // the version loaded from the file
1124  wxString m_generator; // the generator tag from the file
1125 
1126  std::map<wxString, wxString> m_properties;
1127  std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
1128 
1130  TITLE_BLOCK m_titles; // text in lower right of screen and plots
1132  PROJECT* m_project; // project this board is a part of
1133 
1144  std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
1145 
1146  NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
1147 
1148  std::vector<BOARD_LISTENER*> m_listeners;
1149 };
1150 
1151 #endif // CLASS_BOARD_H_
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:43
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:867
iterator end() const
Definition: netinfo.h:441
void InvokeListeners(Func &&aFunc, Args &&... args)
Definition: board.h:1098
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:1989
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:168
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1343
void SetFileFormatVersionAtLoad(int aVersion)
Definition: board.h:288
void BuildListOfNets()
Definition: board.h:663
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:728
const PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
Definition: board.cpp:338
const PAGE_INFO & GetPageSettings() const
Definition: board.h:535
static bool ClassOf(const EDA_ITEM *aItem)
Definition: board.h:193
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:538
Definition: typeinfo.h:84
GroupLegalOpsField GroupLegalOps(const PCB_SELECTION &selection) const
Check which selection tool group operations are legal given the selection.
Definition: board.cpp:2131
std::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideCourtyardCache
Definition: board.h:1083
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:537
const GROUPS & Groups() const
Definition: board.h:254
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:268
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:1898
ZONES & Zones()
Definition: board.h:239
const ZONE_SETTINGS & GetZoneSettings() const override
Fetch the zone settings for this container.
Definition: board.cpp:594
wxString m_name
The canonical name of the layer.
Definition: board.h:108
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
Definition: board.h:272
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:1825
wxString m_fileName
Definition: board.h:1110
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:2042
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
PAD * GetPad(const wxPoint &aPosition) const
Definition: board.h:914
Definition: board.h:72
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:259
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:543
PAGE_INFO m_paper
Definition: board.h:1129
const EDA_RECT GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:742
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:253
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
GROUPS m_groups
Definition: board.h:1115
std::map< wxString, wxString > m_properties
Definition: board.h:1126
~BOARD()
Definition: board.cpp:104
bool IsHighLightNetON() const
Definition: board.h:402
MARKERS & Markers()
Definition: board.h:242
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:536
LAYER_T m_type
The type of the layer.
Definition: board.h:110
const MARKERS & Markers() const
Definition: board.h:243
NETINFO_LIST::iterator EndNets() const
Definition: board.h:706
PROJECT * GetProject() const
Definition: board.h:360
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
void SetCopperLayerCount(int aCount)
Definition: board.cpp:459
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:479
void HighLightOFF()
Disable net highlight.
Definition: board.h:416
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:504
LAYER()
Definition: board.h:83
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:167
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:684
functions to convert a shape built with DRAWSEGMENTS to a polygon.
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:514
PAD * GetPad(const wxPoint &aPosition, LSET aLayerMask) const
Find a pad aPosition on aLayer.
Definition: board.cpp:1476
ZONE * GetArea(int index) const
Return the Zone at a given index.
Definition: board.h:834
void SetPosition(const wxPoint &aPos) override
Definition: board.cpp:260
FOOTPRINT * FindFootprintByPath(const KIID_PATH &aPath) const
Search for a FOOTPRINT within this board with the given path.
Definition: board.cpp:1376
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:171
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:465
LAYER m_layers[PCB_LAYER_ID_COUNT]
Definition: board.h:1118
const wxString & GetGenerator() const
Definition: board.h:292
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
Definition: board.cpp:408
HIGH_LIGHT_INFO m_highLight
Definition: board.h:1120
NETINFO_LIST m_NetInfo
Definition: board.h:1146
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:221
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
HIGH_LIGHT_INFO m_highLightPrevious
Definition: board.h:1121
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.cpp:491
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:570
TRACKS m_tracks
Definition: board.h:1114
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:1165
const wxString & GetFileName() const
Definition: board.h:228
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:166
PCB_PLOT_PARAMS m_plotOptions
Definition: board.h:1131
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
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:1741
const ZONES & Zones() const
Definition: board.h:240
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
std::mutex m_CachesMutex
Definition: board.h:1082
NETINFO_LIST::iterator BeginNets() const
Definition: board.h:698
PAD * GetPadFast(const wxPoint &aPosition, LSET aLayerMask) const
Return pad found at aPosition on aLayerMask using the fast search method.
Definition: board.cpp:1506
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:172
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:702
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Definition: board.cpp:425
Definition: board.h:73
bool m_LegacyCopperEdgeClearanceLoaded
Definition: board.h:269
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:258
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:1199
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false) const
Definition: board.cpp:1805
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1409
unsigned GetNodesCount(int aNet=-1) const
Definition: board.cpp:1081
BOARD_USE m_boardUse
What is this board being used for.
Definition: board.h:1107
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:606
Definition: kiid.h:44
std::vector< PCB_MARKER * > ResolveDRCExclusions()
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition: board.cpp:206
PCB_LAYER_ID
A quick note on layer IDs:
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition: board.cpp:1938
int GetAreaCount() const
Definition: board.h:850
LSET is a set of PCB_LAYER_IDs.
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:2020
ENDPOINT_T
Definition: pcb_track.h:52
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:317
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:206
bool NormalizeAreaPolygon(PICKED_ITEMS_LIST *aNewZonesList, ZONE *aCurrArea)
Process an area that has been modified, by normalizing its polygon against itself.
Definition: board.cpp:1850
wxString GroupsSanityCheckInternal(bool repair)
Definition: board.cpp:2065
unsigned GetNetCount() const
Definition: board.h:715
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:1996
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition: board.cpp:826
ZONES m_zones
Definition: board.h:1116
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:1927
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:497
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition: board.cpp:525
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:1913
iterator begin() const
Definition: netinfo.h:436
FOOTPRINTS & Footprints()
Definition: board.h:233
bool m_highLightOn
Definition: board.h:138
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
Definition: board.h:170
unsigned GetUnconnectedNetCount() const
Definition: board.cpp:1098
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:376
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:344
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Return the type of the copper layer given by aLayer.
Definition: board.cpp:326
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:1402
TITLE_BLOCK m_titles
Definition: board.h:1130
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:2014
Helper for storing and iterating over GAL_LAYER_IDs.
bool m_visible
Definition: board.h:111
std::vector< wxString > GetNetClassAssignmentCandidates() const
Return a list of name candidates for netclass assignment.
Definition: board.cpp:1388
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:56
wxString m_userName
The user defined name of the layer.
Definition: board.h:109
void BuildConnectivity()
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:136
MARKERS m_markers
Definition: board.h:1111
void SetFileName(const wxString &aFileName)
Definition: board.h:226
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:539
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:2029
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:1144
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
Definition: board.cpp:438
Parameters and options when plotting/printing a board.
NETINFO_LIST & GetNetInfo()
Definition: board.h:689
DRAWINGS m_drawings
Definition: board.h:1112
void IncrementTimeStamp()
Definition: board.cpp:191
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
Definition: board.cpp:1442
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:820
void ClearProject()
Definition: board.cpp:172
int GetFileFormatVersionAtLoad() const
Definition: board.h:289
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84
const std::set< int > & GetHighLightNetCodes() const
Definition: board.h:386
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:304
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:531
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:696
EDA_UNITS
Definition: eda_units.h:38
void SetProject(PROJECT *aProject)
Link a board to a given project.
Definition: board.cpp:142
void clear()
Definition: board.h:88
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Definition: board.cpp:394
void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: board.cpp:266
std::set< int > m_netCodes
Definition: board.h:137
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:1965
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:471
virtual void OnBoardHighlightNetChanged(BOARD &aBoard)
Definition: board.h:173
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:541
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:1648
const DRAWINGS & Drawings() const
Definition: board.h:237
Board layer functions and definitions.
int m_fileFormatVersionAtLoad
Definition: board.h:1123
wxString m_generator
Definition: board.h:1124
Container to hold information pertinent to a layer of a BOARD.
Definition: board.h:81
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
const FOOTPRINTS & Footprints() const
Definition: board.h:234
wxPoint GetPosition() const override
Definition: board.cpp:254
BOARD()
Definition: board.cpp:62
int GetTimeStamp()
Definition: board.h:214
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:169
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition: board.cpp:982
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:1633
int GetCopperLayerCount() const
Definition: board.cpp:453
void SanitizeNetcodes()
Definition: board.cpp:1979
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
Definition: board.h:1127
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.cpp:600
void SetGenerator(const wxString &aGenerator)
Definition: board.h:291
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:2008
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:708
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:803
const TRACKS & Tracks() const
Definition: board.h:231
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1104
std::map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTrees
Definition: board.h:1088
unsigned GetNetCount() const
Definition: netinfo.h:339
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition: board.cpp:1036
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
Definition: board.cpp:2052
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:46
virtual ~BOARD_LISTENER()
Definition: board.h:165
FOOTPRINTS m_footprints
Definition: board.h:1113
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:858
const wxPoint GetFocusPosition() const override
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: board.h:279
Abstract interface for BOARD_ITEMs capable of storing other items inside.
int m_number
The layer ID.
Definition: board.h:112
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
std::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideBCourtyardCache
Definition: board.h:1085
Definition: pad.h:57
const wxPoint GetCenter() const
Definition: eda_rect.h:104
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition: drc_rtree.h:44
SEARCH_RESULT
Definition: eda_item.h:41
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:238
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
Definition: board.h:68
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition: board.h:210
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:74
std::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideAreaCache
Definition: board.h:1086
DRAWINGS & Drawings()
Definition: board.h:236
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition: board.cpp:946
bool IsEmpty() const
Definition: board.h:281
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition: board.h:264
void ClearAllNetCodes()
Reset all items' netcodes to 0 (no net).
Definition: board.cpp:1958
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:485
std::vector< BOARD_LISTENER * > m_listeners
Definition: board.h:1148
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
TRACKS & Tracks()
Definition: board.h:230
void buildListOfNets()
Rebuild the list of NETINFO_ITEMs.
HIGH_LIGHT_INFO()
Definition: board.h:146
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:203
const TITLE_BLOCK & GetTitleBlock() const
Definition: board.h:542
std::tuple< int, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
Definition: board.cpp:1658
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition: board.cpp:1364
PROJECT * m_project
Definition: board.h:1132
int m_timeStamp
Definition: board.h:1108
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:605
void Clear()
Definition: board.h:140
Container for design settings for a BOARD object.
std::map< std::pair< BOARD_ITEM *, BOARD_ITEM * >, bool > m_InsideFCourtyardCache
Definition: board.h:1084
GAL_SET m_LegacyVisibleItems
Definition: board.h:265