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, [email protected]
5 * Copyright (C) 1992-2022 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
29#include <common.h> // Needed for stl hash extensions
30#include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
31#include <hash.h>
32#include <layer_ids.h>
33#include <netinfo.h>
34#include <pcb_item_containers.h>
35#include <pcb_plot_params.h>
36#include <title_block.h>
37#include <tools/pcb_selection.h>
38#include <mutex>
39#include <list>
40
43class BOARD_COMMIT;
44class DRC_RTREE;
45class PCB_BASE_FRAME;
46class PCB_EDIT_FRAME;
48class BOARD;
49class FOOTPRINT;
50class ZONE;
51class PCB_TRACK;
52class PAD;
53class PCB_GROUP;
54class PCB_MARKER;
55class MSG_PANEL_ITEM;
56class NETLIST;
57class REPORTER;
58class SHAPE_POLY_SET;
60class COMPONENT;
61class PROJECT;
63
64// Forward declare endpoint from class_track.h
65enum ENDPOINT_T : int;
66
67
69{
72
73 bool operator==(const PTR_PTR_CACHE_KEY& other) const
74 {
75 return A == other.A && B == other.B;
76 }
77};
78
80{
83
84 bool operator==(const PTR_LAYER_CACHE_KEY& other) const
85 {
86 return A == other.A && Layer == other.Layer;
87 }
88};
89
91{
95
96 bool operator==(const PTR_PTR_LAYER_CACHE_KEY& other) const
97 {
98 return A == other.A && B == other.B && Layer == other.Layer;
99 }
100};
101
102namespace std
103{
104 template <>
105 struct hash<PTR_PTR_CACHE_KEY>
106 {
107 std::size_t operator()( const PTR_PTR_CACHE_KEY& k ) const
108 {
109 std::size_t seed = 0xa82de1c0;
110 hash_combine( seed, k.A, k.B );
111 return seed;
112 }
113 };
114
115 template <>
117 {
118 std::size_t operator()( const PTR_LAYER_CACHE_KEY& k ) const
119 {
120 std::size_t seed = 0xa82de1c0;
121 hash_combine( seed, k.A, k.Layer );
122 return seed;
123 }
124 };
125
126 template <>
128 {
129 std::size_t operator()( const PTR_PTR_LAYER_CACHE_KEY& k ) const
130 {
131 std::size_t seed = 0xa82de1c0;
132 hash_combine( seed, k.A, k.B, k.Layer );
133 return seed;
134 }
135 };
136}
137
138
143{
150
151
155struct LAYER
156{
158 {
159 clear();
160 }
161
162 void clear()
163 {
165 m_visible = true;
166 m_number = 0;
167 m_name.clear();
168 m_userName.clear();
169 }
170
171 /*
172 LAYER( const wxString& aName = wxEmptyString,
173 LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
174 m_name( aName ),
175 m_type( aType ),
176 m_visible( aVisible ),
177 m_number( aNumber )
178 {
179 }
180 */
181
182 wxString m_name;
183 wxString m_userName;
187
194 static const char* ShowType( LAYER_T aType );
195
203 static LAYER_T ParseType( const char* aType );
204};
205
206
207// Helper class to handle high light nets
209{
210protected:
211 std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
212 bool m_highLightOn; // highlight active
213
214 void Clear()
215 {
216 m_netCodes.clear();
217 m_highLightOn = false;
218 }
219
221 {
222 Clear();
223 }
224
225private:
226 friend class BOARD;
227};
228
234class BOARD;
235
237{
238public:
239 virtual ~BOARD_LISTENER() { }
240 virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
241 virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
242 virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
243 virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
244 virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
245 virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
246 virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItem ) { }
247 virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
248};
249
250
254enum class BOARD_USE
255{
256 NORMAL, // A normal board
257 FPHOLDER // A board that holds a single footprint
258};
259
260
265{
266public:
267 static inline bool ClassOf( const EDA_ITEM* aItem )
268 {
269 return aItem && PCB_T == aItem->Type();
270 }
271
277 void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
278
284 BOARD_USE GetBoardUse() const { return m_boardUse; }
285
286 void IncrementTimeStamp();
287
288 int GetTimeStamp() const { return m_timeStamp; }
289
295 bool IsFootprintHolder() const
296 {
298 }
299
300 void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
301
302 const wxString &GetFileName() const { return m_fileName; }
303
304 TRACKS& Tracks() { return m_tracks; }
305 const TRACKS& Tracks() const { return m_tracks; }
306
307 FOOTPRINTS& Footprints() { return m_footprints; }
308 const FOOTPRINTS& Footprints() const { return m_footprints; }
309
310 DRAWINGS& Drawings() { return m_drawings; }
311 const DRAWINGS& Drawings() const { return m_drawings; }
312
313 ZONES& Zones() { return m_zones; }
314 const ZONES& Zones() const { return m_zones; }
315
316 MARKERS& Markers() { return m_markers; }
317 const MARKERS& Markers() const { return m_markers; }
318
327 GROUPS& Groups() { return m_groups; }
328 const GROUPS& Groups() const { return m_groups; }
329
330 const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
331
332 const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
333 void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
334
335 bool ResolveTextVar( wxString* token, int aDepth ) const;
336
340
344
347
348 BOARD();
349 ~BOARD();
350
351 VECTOR2I GetPosition() const override;
352 void SetPosition( const VECTOR2I& aPos ) override;
353 const VECTOR2I GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
354
355 bool IsEmpty() const
356 {
357 return m_drawings.empty() && m_footprints.empty() && m_tracks.empty() && m_zones.empty();
358 }
359
360 void Move( const VECTOR2I& aMoveVector ) override;
361
362 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
364
365 void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
366 const wxString& GetGenerator() const { return m_generator; }
367
369 void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
370 bool aSkipConnectivity = false ) override;
371
373 void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
374
379 void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
380
385 void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
386
387 void CacheTriangulation( PROGRESS_REPORTER* aReporter = nullptr,
388 const std::vector<ZONE*>& aZones = {} );
389
398 {
399 return m_footprints.empty() ? nullptr : m_footprints.front();
400 }
401
405 void DeleteAllFootprints();
406
410 BOARD_ITEM* GetItem( const KIID& aID ) const;
411
412 void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
413
417 wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const;
418 wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const;
419
424 std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
425
431 void BuildConnectivity( PROGRESS_REPORTER* aReporter = nullptr );
432
436 void DeleteMARKERs();
437
438 void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
439
440 PROJECT* GetProject() const { return m_project; }
441
450 void SetProject( PROJECT* aProject, bool aReferenceOnly = false );
451
452 void ClearProject();
453
457 std::vector<PCB_MARKER*> ResolveDRCExclusions();
458
462 void ResetNetHighLight();
463
467 const std::set<int>& GetHighLightNetCodes() const
468 {
469 return m_highLight.m_netCodes;
470 }
471
478 void SetHighLightNet( int aNetCode, bool aMulti = false );
479
484
492 void HighLightON( bool aValue = true );
493
498 {
499 HighLightON( false );
500 }
501
505 int GetCopperLayerCount() const;
506 void SetCopperLayerCount( int aCount );
507
513 LSET GetEnabledLayers() const;
514
520 void SetEnabledLayers( LSET aLayerMask );
521
528 bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const;
529
537 bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
538
544 LSET GetVisibleLayers() const;
545
552 void SetVisibleLayers( LSET aLayerMask );
553
554 // these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
555 // are not stored in the bitmap.
556
564
571 void SetVisibleElements( const GAL_SET& aMask );
572
578 void SetVisibleAlls();
579
587 bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
588
596 void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
597
605 bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
606
611
612 const ZONE_SETTINGS& GetZoneSettings() const override;
613
614 void SetZoneSettings( const ZONE_SETTINGS& aSettings ) override;
615
617 void SetTentVias( bool aFlag ) { m_plotOptions.SetPlotViaOnMaskLayer( !aFlag ); }
618
619 const PAGE_INFO& GetPageSettings() const { return m_paper; }
620 void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
621
623 void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
624
626 const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
627 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
628
629 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
630
643 OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr );
644
655 void ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_SET& aOutlines ) const;
656
660 const PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
661
668 const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
669
677 bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
678
689 static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
690 {
691 // a BOARD's standard layer name is the PCB_LAYER_ID fixed name
692 return LayerName( aLayerId );
693 }
694
702 bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
703
710 LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
711
719 bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
720
725 unsigned GetNodesCount( int aNet = -1 ) const;
726
730 unsigned GetUnconnectedNetCount() const;
731
740 const std::vector<PAD*> GetPads() const;
741
743 {
745 }
746
753 NETINFO_ITEM* FindNet( int aNetcode ) const;
754
761 NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
762
764 {
765 return m_NetInfo;
766 }
767
769 {
770 return m_NetInfo;
771 }
772
773#ifndef SWIG
778 {
779 return m_NetInfo.begin();
780 }
781
786 {
787 return m_NetInfo.end();
788 }
789#endif
790
794 unsigned GetNetCount() const
795 {
796 return m_NetInfo.GetNetCount();
797 }
798
805 BOX2I ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
806
807 const BOX2I GetBoundingBox() const override
808 {
809 return ComputeBoundingBox( false );
810 }
811
822 {
823 return ComputeBoundingBox( true );
824 }
825
826 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
827
839 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
840 const std::vector<KICAD_T>& scanTypes ) override;
841
850 FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
851
858 FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
859
863 std::set<wxString> GetNetClassAssignmentCandidates() const;
864
873
878
879 wxString GetClass() const override
880 {
881 return wxT( "BOARD" );
882 }
883
884#if defined(DEBUG)
885 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
886#endif
887
888
889 /*************************/
890 /* Copper Areas handling */
891 /*************************/
892
903
910 ZONE* GetArea( int index ) const
911 {
912 if( (unsigned) index < m_zones.size() )
913 return m_zones[index];
914
915 return nullptr;
916 }
917
921 std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false ) const;
922
926 int GetAreaCount() const
927 {
928 return static_cast<int>( m_zones.size() );
929 }
930
931 /* Functions used in test, merge and cut outlines */
932
945 ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
946 VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
947
955 bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
956
964 PAD* GetPad( const VECTOR2I& aPosition, LSET aLayerMask ) const;
965 PAD* GetPad( const VECTOR2I& aPosition ) const
966 {
967 return GetPad( aPosition, LSET().set() );
968 }
969
977 PAD* GetPad( const PCB_TRACK* aTrace, ENDPOINT_T aEndPoint ) const;
978
988 PAD* GetPadFast( const VECTOR2I& aPosition, LSET aLayerMask ) const;
989
1004 PAD* GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, LSET aLayerMask ) const;
1005
1012 void PadDelete( PAD* aPad );
1013
1025 void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
1026
1034 std::tuple<int, double, double> GetTrackLength( const PCB_TRACK& aTrack ) const;
1035
1043 TRACKS TracksInNet( int aNetCode );
1044
1057 FOOTPRINT* GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveLayer,
1058 bool aVisibleOnly, bool aIgnoreLocked = false ) const;
1059
1065 void MapNets( const BOARD* aDestBoard );
1066
1067 void SanitizeNetcodes();
1068
1077 void AddListener( BOARD_LISTENER* aListener );
1078
1083 void RemoveListener( BOARD_LISTENER* aListener );
1084
1088 void RemoveAllListeners();
1089
1094 void OnItemChanged( BOARD_ITEM* aItem );
1095
1100 void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
1101
1108 wxString GroupsSanityCheck( bool repair = false );
1109
1115 wxString GroupsSanityCheckInternal( bool repair );
1116
1118 {
1119 bool create : 1;
1120 bool ungroup : 1;
1121 bool removeItems : 1;
1122 bool enter : 1;
1123 };
1124
1130 GroupLegalOpsField GroupLegalOps( const PCB_SELECTION& selection ) const;
1131
1132 // --------- Item order comparators ---------
1133
1135 {
1136 bool operator() ( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
1137 };
1138
1140 {
1141 bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
1142 };
1143
1144 // ------------ Run-time caches -------------
1145 std::mutex m_CachesMutex;
1146 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsCourtyardCache;
1147 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsFCourtyardCache;
1148 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsBCourtyardCache;
1149 std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_IntersectsAreaCache;
1150 std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_EnclosedByAreaCache;
1151 std::unordered_map< wxString, LSET > m_LayerExpressionCache;
1152 std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
1153 std::unique_ptr<DRC_RTREE> m_CopperItemRTreeCache;
1154
1155 // ------------ DRC caches -------------
1156 std::vector<ZONE*> m_DRCZones;
1157 std::vector<ZONE*> m_DRCCopperZones;
1161
1162private:
1163 // The default copy constructor & operator= are inadequate,
1164 // either write one or do not use it at all
1165 BOARD( const BOARD& aOther ) = delete;
1166
1167 BOARD& operator=( const BOARD& aOther ) = delete;
1168
1169 template <typename Func, typename... Args>
1170 void InvokeListeners( Func&& aFunc, Args&&... args )
1171 {
1172 for( auto&& l : m_listeners )
1173 ( l->*aFunc )( std::forward<Args>( args )... );
1174 }
1175
1176 friend class PCB_EDIT_FRAME;
1177
1180 int m_timeStamp; // actually a modification counter
1181
1182 wxString m_fileName;
1183 MARKERS m_markers;
1184 DRAWINGS m_drawings;
1185 FOOTPRINTS m_footprints;
1186 TRACKS m_tracks;
1187 GROUPS m_groups;
1189
1191
1192 HIGH_LIGHT_INFO m_highLight; // current high light data
1193 HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
1194
1195 int m_fileFormatVersionAtLoad; // the version loaded from the file
1196 wxString m_generator; // the generator tag from the file
1197
1198 std::map<wxString, wxString> m_properties;
1199 std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
1200
1202 TITLE_BLOCK m_titles; // text in lower right of screen and plots
1204 PROJECT* m_project; // project this board is a part of
1205
1216 std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
1217
1218 NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
1219
1220 std::vector<BOARD_LISTENER*> m_listeners;
1221};
1222
1223
1224#endif // CLASS_BOARD_H_
@ NORMAL
Use all material properties from model file.
BOARD_USE
Flags to specify how the board is being used.
Definition: board.h:255
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
Definition: board.h:143
@ LT_POWER
Definition: board.h:146
@ LT_MIXED
Definition: board.h:147
@ LT_UNDEFINED
Definition: board.h:144
@ LT_JUMPER
Definition: board.h:148
@ LT_SIGNAL
Definition: board.h:145
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:52
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:88
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
Definition: board.h:244
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:241
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:246
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:245
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:242
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition: board.h:240
virtual void OnBoardHighlightNetChanged(BOARD &aBoard)
Definition: board.h:247
virtual ~BOARD_LISTENER()
Definition: board.h:239
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Definition: board.h:243
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< 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:1256
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:590
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: board.h:623
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_EnclosedByAreaCache
Definition: board.h:1150
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:1981
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:763
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
Definition: board.h:342
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:295
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:485
void SetPosition(const VECTOR2I &aPos) override
Definition: board.cpp:305
std::map< wxString, wxString > m_properties
Definition: board.h:1198
int m_fileFormatVersionAtLoad
Definition: board.h:1195
NETINFO_LIST & GetNetInfo()
Definition: board.h:768
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:499
void SetTentVias(bool aFlag)
Definition: board.h:617
std::vector< ZONE * > m_DRCCopperZones
Definition: board.h:1157
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition: board.h:284
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:670
const std::set< int > & GetHighLightNetCodes() const
Definition: board.h:467
TITLE_BLOCK m_titles
Definition: board.h:1202
unsigned GetUnconnectedNetCount() const
Definition: board.cpp:1151
GAL_SET m_LegacyVisibleItems
Definition: board.h:339
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition: board.h:277
ZONE * GetArea(int index) const
Return the Zone at a given index.
Definition: board.h:910
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:821
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:807
void SetZoneSettings(const ZONE_SETTINGS &aSettings) override
Set the zone settings for this container.
Definition: board.cpp:614
void BuildListOfNets()
Definition: board.h:742
PAD * GetPadFast(const VECTOR2I &aPosition, LSET aLayerMask) const
Return pad found at aPosition on aLayerMask using the fast search method.
Definition: board.cpp:1539
LAYER m_layers[PCB_LAYER_ID_COUNT]
Definition: board.h:1190
void SetFileName(const wxString &aFileName)
Definition: board.h:300
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:689
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition: board.cpp:1912
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:551
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
Definition: board.cpp:1427
BOARD_USE m_boardUse
What is this board being used for.
Definition: board.h:1179
PAGE_INFO m_paper
Definition: board.h:1201
const ZONE_SETTINGS & GetZoneSettings() const override
Fetch the zone settings for this container.
Definition: board.cpp:608
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:1932
void RemoveAllListeners()
Remove all listeners.
Definition: board.cpp:1975
FOOTPRINTS m_footprints
Definition: board.h:1185
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:1216
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:505
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:1956
const PAGE_INFO & GetPageSettings() const
Definition: board.h:619
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: board.h:333
BOARD(const BOARD &aOther)=delete
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition: board.cpp:545
ZONES & Zones()
Definition: board.h:313
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:2002
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:1681
HIGH_LIGHT_INFO m_highLight
Definition: board.h:1192
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Return the type of the copper layer given by aLayer.
Definition: board.cpp:352
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1382
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:917
const ZONES & Zones() const
Definition: board.h:314
void InvokeListeners(Func &&aFunc, Args &&... args)
Definition: board.h:1170
void SanitizeNetcodes()
Definition: board.cpp:1946
ZONE * AddArea(PICKED_ITEMS_LIST *aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer, VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch)
Add an empty copper area to board areas list.
Definition: board.cpp:1858
const GROUPS & Groups() const
Definition: board.h:328
~BOARD()
Definition: board.cpp:121
void SynchronizeNetsAndNetClasses()
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1450
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:511
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Definition: board.cpp:418
DRAWINGS m_drawings
Definition: board.h:1184
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
Definition: board.cpp:1475
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:1993
PCB_PLOT_PARAMS m_plotOptions
Definition: board.h:1203
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition: board.cpp:400
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false) const
Definition: board.cpp:1838
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,...
Definition: board.cpp:2183
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:283
const MARKERS & Markers() const
Definition: board.h:317
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:397
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition: board.cpp:1898
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:1883
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: board.cpp:311
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:625
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1157
ZONES m_zones
Definition: board.h:1188
PAD * GetPad(const VECTOR2I &aPosition) const
Definition: board.h:965
FOOTPRINTS & Footprints()
Definition: board.h:307
HIGH_LIGHT_INFO m_highLightPrevious
Definition: board.h:1193
const VECTOR2I GetFocusPosition() const override
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: board.h:353
void HighLightOFF()
Disable net highlight.
Definition: board.h:497
std::unique_ptr< DRC_RTREE > m_CopperItemRTreeCache
Definition: board.h:1153
NETINFO_LIST m_NetInfo
Definition: board.h:1218
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition: board.h:338
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition: board.cpp:534
NETINFO_LIST::iterator EndNets() const
Definition: board.h:785
GroupLegalOpsField GroupLegalOps(const PCB_SELECTION &selection) const
Check which selection tool group operations are legal given the selection.
Definition: board.cpp:2104
int GetCopperLayerCount() const
Definition: board.cpp:473
int m_timeStamp
Definition: board.h:1180
std::vector< BOARD_LISTENER * > m_listeners
Definition: board.h:1220
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:332
const PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
Definition: board.cpp:364
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsCourtyardCache
Definition: board.h:1146
void IncrementTimeStamp()
Definition: board.cpp:215
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsFCourtyardCache
Definition: board.h:1147
const FOOTPRINTS & Footprints() const
Definition: board.h:308
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
Definition: board.h:1199
const TRACKS & Tracks() const
Definition: board.h:305
int m_DRCMaxPhysicalClearance
Definition: board.h:1159
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:327
FOOTPRINT * FindFootprintByPath(const KIID_PATH &aPath) const
Search for a FOOTPRINT within this board with the given path.
Definition: board.cpp:1415
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:773
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:620
bool GetTentVias() const
Definition: board.h:616
std::unordered_map< wxString, LSET > m_LayerExpressionCache
Definition: board.h:1151
wxString GroupsSanityCheckInternal(bool repair)
Definition: board.cpp:2038
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition: board.cpp:1032
TRACKS & Tracks()
Definition: board.h:304
wxString GetClass() const override
Return the class name.
Definition: board.h:879
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition: board.cpp:517
NETINFO_LIST::iterator BeginNets() const
Definition: board.h:777
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
Definition: board.h:346
void SetCopperLayerCount(int aCount)
Definition: board.cpp:479
MARKERS & Markers()
Definition: board.h:316
wxString m_generator
Definition: board.h:1196
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsBCourtyardCache
Definition: board.h:1148
TRACKS TracksInNet(int aNetCode)
Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
Definition: board.cpp:330
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:161
PROJECT * m_project
Definition: board.h:1204
FOOTPRINT * GetFootprint(const VECTOR2I &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:1774
const wxString & GetFileName() const
Definition: board.h:302
ZONE * m_SolderMask
Definition: board.h:1160
DRAWINGS & Drawings()
Definition: board.h:310
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition: board.cpp:1403
unsigned GetNodesCount(int aNet=-1) const
Definition: board.cpp:1134
bool IsHighLightNetON() const
Definition: board.h:483
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition: board.cpp:996
int GetFileFormatVersionAtLoad() const
Definition: board.h:363
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition: board.cpp:557
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
Definition: board.cpp:430
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:622
BOARD & operator=(const BOARD &aOther)=delete
wxString m_fileName
Definition: board.h:1182
const wxString & GetGenerator() const
Adds an item to the container.
Definition: board.h:366
int GetAreaCount() const
Definition: board.h:926
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:1666
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:491
int m_DRCMaxClearance
Definition: board.h:1158
void ClearProject()
Definition: board.cpp:195
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: board.cpp:870
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1152
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:767
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition: board.cpp:908
PROJECT * GetProject() const
Definition: board.h:440
bool IsEmpty() const
Definition: board.h:355
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:1691
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:1218
const TITLE_BLOCK & GetTitleBlock() const
Definition: board.h:626
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
Definition: board.cpp:2025
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:602
std::vector< ZONE * > m_DRCZones
Definition: board.h:1156
PAD * GetPad(const VECTOR2I &aPosition, LSET aLayerMask) const
Find a pad aPosition on aLayer.
Definition: board.cpp:1509
void SetGenerator(const wxString &aGenerator)
Definition: board.h:365
BOARD()
Definition: board.cpp:69
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition: board.cpp:1086
std::vector< PCB_MARKER * > ResolveDRCExclusions()
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition: board.cpp:237
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition: board.cpp:1441
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition: board.cpp:1963
unsigned GetNetCount() const
Definition: board.h:794
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition: board.cpp:876
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:779
GROUPS m_groups
Definition: board.h:1187
MARKERS m_markers
Definition: board.h:1183
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_IntersectsAreaCache
Definition: board.h:1149
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:2015
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: board.h:627
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
TRACKS m_tracks
Definition: board.h:1186
bool m_LegacyCopperEdgeClearanceLoaded
Definition: board.h:343
int GetTimeStamp() const
Definition: board.h:288
std::mutex m_CachesMutex
Definition: board.h:1145
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:1987
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
VECTOR2I GetPosition() const override
Definition: board.cpp:299
void BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:155
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
Definition: board.cpp:620
static bool ClassOf(const EDA_ITEM *aItem)
Definition: board.h:267
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:524
const DRAWINGS & Drawings() const
Definition: board.h:311
void SetFileFormatVersionAtLoad(int aVersion)
Definition: board.h:362
const Vec GetCenter() const
Definition: box2.h:195
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:85
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition: drc_rtree.h:48
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:111
Helper for storing and iterating over GAL_LAYER_IDs.
Definition: layer_ids.h:296
void Clear()
Definition: board.h:214
HIGH_LIGHT_INFO()
Definition: board.h:220
std::set< int > m_netCodes
Definition: board.h:211
bool m_highLightOn
Definition: board.h:212
Definition: kiid.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Handle the data for a net.
Definition: netinfo.h:66
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:324
iterator begin() const
Definition: netinfo.h:444
unsigned GetNetCount() const
Definition: netinfo.h:347
iterator end() const
Definition: netinfo.h:449
void buildListOfNets()
Rebuild the list of NETINFO_ITEMs.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:213
Definition: pad.h:58
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
The main frame for Pcbnew.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
Parameters and options when plotting/printing a board.
void SetPlotViaOnMaskLayer(bool aFlag)
bool GetPlotViaOnMaskLayer() const
A holder to handle information on schematic or board items.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
Definition: project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
Represent a set of closed polygons.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
The common library.
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
std::vector< ZONE * > ZONES
Definition: eagle_plugin.h:44
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:92
static void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
Definition: hash.h:34
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:30
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:190
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137
Definition: bitmap.cpp:64
ENDPOINT_T
Definition: pcb_track.h:54
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition: board.cpp:2150
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition: board.cpp:2129
Container to hold information pertinent to a layer of a BOARD.
Definition: board.h:156
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
Definition: board.cpp:458
void clear()
Definition: board.h:162
LAYER_T m_type
The type of the layer.
Definition: board.h:184
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Definition: board.cpp:445
LAYER()
Definition: board.h:157
wxString m_name
The canonical name of the layer.
Definition: board.h:182
wxString m_userName
The user defined name of the layer.
Definition: board.h:183
bool m_visible
Definition: board.h:185
int m_number
The layer ID.
Definition: board.h:186
BOARD_ITEM * A
Definition: board.h:81
bool operator==(const PTR_LAYER_CACHE_KEY &other) const
Definition: board.h:84
PCB_LAYER_ID Layer
Definition: board.h:82
BOARD_ITEM * A
Definition: board.h:70
BOARD_ITEM * B
Definition: board.h:71
bool operator==(const PTR_PTR_CACHE_KEY &other) const
Definition: board.h:73
bool operator==(const PTR_PTR_LAYER_CACHE_KEY &other) const
Definition: board.h:96
BOARD_ITEM * B
Definition: board.h:93
BOARD_ITEM * A
Definition: board.h:92
PCB_LAYER_ID Layer
Definition: board.h:94
std::size_t operator()(const PTR_LAYER_CACHE_KEY &k) const
Definition: board.h:118
std::size_t operator()(const PTR_PTR_CACHE_KEY &k) const
Definition: board.h:107
std::size_t operator()(const PTR_PTR_LAYER_CACHE_KEY &k) const
Definition: board.h:129
@ PCB_T
Definition: typeinfo.h:82
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.
Definition: zone_settings.h:49