KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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
30#include <embedded_files.h>
31#include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
33#include <hash.h>
34#include <layer_ids.h>
35#include <lset.h>
36#include <netinfo.h>
37#include <pcb_item_containers.h>
38#include <pcb_plot_params.h>
39#include <title_block.h>
40#include <zone_settings.h>
41#include <shared_mutex>
42#include <unordered_set>
43#include <project.h>
44#include <list>
45
49class BOARD_COMMIT;
51class DRC_RTREE;
52class PCB_BASE_FRAME;
53class PCB_EDIT_FRAME;
56class BOARD;
57class FOOTPRINT;
58class ZONE;
59class PCB_TRACK;
60class PAD;
61class PCB_GROUP;
62class PCB_GENERATOR;
63class PCB_MARKER;
64class MSG_PANEL_ITEM;
65class NETLIST;
66class REPORTER;
68class COMPONENT;
69class PROJECT;
72
73namespace KIGFX
74{
75class RENDER_SETTINGS;
76};
77
78
79namespace KIFONT
80{
81 class OUTLINE_FONT;
82}
83
84struct ISOLATED_ISLANDS;
85
86// The default value for m_outlinesChainingEpsilon to convert a board outlines to polygons
87// It is the max dist between 2 end points to see them connected
88#define DEFAULT_CHAINING_EPSILON_MM 0.01
89
90// Forward declare endpoint from class_track.h
91enum ENDPOINT_T : int;
92
93
95{
98
99 bool operator==(const PTR_PTR_CACHE_KEY& other) const
100 {
101 return A == other.A && B == other.B;
102 }
103};
104
106{
109
110 bool operator==(const PTR_LAYER_CACHE_KEY& other) const
111 {
112 return A == other.A && Layer == other.Layer;
113 }
114};
115
117{
121
122 bool operator==(const PTR_PTR_LAYER_CACHE_KEY& other) const
123 {
124 return A == other.A && B == other.B && Layer == other.Layer;
125 }
126};
127
129{
131 layers(),
132 has_error( false )
133 {}
134
136 layers( { aLayer } ),
137 has_error( false )
138 {}
139
142};
143
144
145namespace std
146{
147 template <>
148 struct hash<PTR_PTR_CACHE_KEY>
149 {
150 std::size_t operator()( const PTR_PTR_CACHE_KEY& k ) const
151 {
152 std::size_t seed = 0xa82de1c0;
153 hash_combine( seed, k.A, k.B );
154 return seed;
155 }
156 };
157
158 template <>
160 {
161 std::size_t operator()( const PTR_LAYER_CACHE_KEY& k ) const
162 {
163 std::size_t seed = 0xa82de1c0;
164 hash_combine( seed, k.A, k.Layer );
165 return seed;
166 }
167 };
168
169 template <>
171 {
172 std::size_t operator()( const PTR_PTR_LAYER_CACHE_KEY& k ) const
173 {
174 std::size_t seed = 0xa82de1c0;
175 hash_combine( seed, k.A, k.B, k.Layer );
176 return seed;
177 }
178 };
179}
180
181
196
197
201struct LAYER
202{
204 {
205 clear();
206 }
207
208 void clear()
209 {
211 m_visible = true;
212 m_number = 0;
213 m_name.clear();
214 m_userName.clear();
216 }
217
218 /*
219 LAYER( const wxString& aName = wxEmptyString,
220 LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
221 m_name( aName ),
222 m_type( aType ),
223 m_visible( aVisible ),
224 m_number( aNumber )
225 {
226 }
227 */
228
229 wxString m_name;
230 wxString m_userName;
235
242 static const char* ShowType( LAYER_T aType );
243
251 static LAYER_T ParseType( const char* aType );
252};
253
254
255// Helper class to handle high light nets
257{
258protected:
259 std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
260 bool m_highLightOn; // highlight active
261
262 void Clear()
263 {
264 m_netCodes.clear();
265 m_highLightOn = false;
266 }
267
269 {
270 Clear();
271 }
272
273private:
274 friend class BOARD;
275};
276
282class BOARD;
283
285{
286public:
287 virtual ~BOARD_LISTENER() { }
288 virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
289 virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) { }
290 virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
291 virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) { }
292 virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
293 virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
294 virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) { }
295 virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
296 virtual void OnBoardRatsnestChanged( BOARD& aBoard ) { }
297 virtual void OnBoardCompositeUpdate( BOARD& aBoard, std::vector<BOARD_ITEM*>& aAddedItems,
298 std::vector<BOARD_ITEM*>& aRemovedItems,
299 std::vector<BOARD_ITEM*>& aChangedItems )
300 {
301 }
302};
303
307typedef std::set<BOARD_ITEM*, CompareByUuid> BOARD_ITEM_SET;
308
312enum class BOARD_USE
313{
314 NORMAL, // A normal board
315 FPHOLDER // A board that holds a single footprint
316};
317
318
323{
324public:
325 static inline bool ClassOf( const EDA_ITEM* aItem )
326 {
327 return aItem && PCB_T == aItem->Type();
328 }
329
335 void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
336
342 BOARD_USE GetBoardUse() const { return m_boardUse; }
343
344 void IncrementTimeStamp();
345
346 int GetTimeStamp() const { return m_timeStamp; }
347
353 bool IsFootprintHolder() const
354 {
356 }
357
358 void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
359
360 const wxString &GetFileName() const { return m_fileName; }
361
362 const TRACKS& Tracks() const { return m_tracks; }
363
364 const FOOTPRINTS& Footprints() const { return m_footprints; }
365
366 const DRAWINGS& Drawings() const { return m_drawings; }
367
368 const ZONES& Zones() const { return m_zones; }
369
370 const GENERATORS& Generators() const { return m_generators; }
371
374 void UpdateBoardOutline();
375
376 const MARKERS& Markers() const { return m_markers; }
377
378 const PCB_POINTS& Points() const { return m_points; }
379
381
390 const GROUPS& Groups() const { return m_groups; }
391
392 const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
393
394 const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
395 void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
396
397 // Variant system
398 wxString GetCurrentVariant() const { return m_currentVariant; }
399 void SetCurrentVariant( const wxString& aVariant );
400
401 const std::vector<wxString>& GetVariantNames() const { return m_variantNames; }
402 void SetVariantNames( const std::vector<wxString>& aNames ) { m_variantNames = aNames; }
403
404 bool HasVariant( const wxString& aVariantName ) const;
405 void AddVariant( const wxString& aVariantName );
406 void DeleteVariant( const wxString& aVariantName );
407 void RenameVariant( const wxString& aOldName, const wxString& aNewName );
408
409 wxString GetVariantDescription( const wxString& aVariantName ) const;
410 void SetVariantDescription( const wxString& aVariantName, const wxString& aDescription );
411
420 wxArrayString GetVariantNamesForUI() const;
421
422 void GetContextualTextVars( wxArrayString* aVars ) const;
423 bool ResolveTextVar( wxString* token, int aDepth ) const;
424
428
432
435
436 BOARD();
437 ~BOARD();
438
439 VECTOR2I GetPosition() const override;
440 void SetPosition( const VECTOR2I& aPos ) override;
441 const VECTOR2I GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
442
443 bool IsEmpty() const;
444
445 void Move( const VECTOR2I& aMoveVector ) override;
446
447 void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
448
449 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
451
452 void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
453 const wxString& GetGenerator() const { return m_generator; }
454
456 void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
457 bool aSkipConnectivity = false ) override;
458
460 void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
461
470 void RemoveAll( std::initializer_list<KICAD_T> aTypes = { PCB_NETINFO_T, PCB_MARKER_T,
474
475 bool HasItemsOnLayer( PCB_LAYER_ID aLayer );
476
485 bool RemoveAllItemsOnLayer( PCB_LAYER_ID aLayer );
486
491 void BulkRemoveStaleTeardrops( BOARD_COMMIT& aCommit );
492
497 void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
498
503 void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
504
510 void FixupEmbeddedData();
511
512 void RunOnNestedEmbeddedFiles( const std::function<void( EMBEDDED_FILES* )>& aFunction ) override;
513
514 void CacheTriangulation( PROGRESS_REPORTER* aReporter = nullptr,
515 const std::vector<ZONE*>& aZones = {} );
516
525 {
526 return m_footprints.empty() ? nullptr : m_footprints.front();
527 }
528
532 void DeleteAllFootprints();
533
537 void DetachAllFootprints();
538
543 BOARD_ITEM* ResolveItem( const KIID& aID, bool aAllowNullptrReturn = false ) const;
544
548 void RebindItemUuid( BOARD_ITEM* aItem, const KIID& aNewId );
549
558
559 void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
560
564 wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const;
565 wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const;
566
571 std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
572
578 bool BuildConnectivity( PROGRESS_REPORTER* aReporter = nullptr );
579
583 void DeleteMARKERs();
584
585 void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
586
587 PROJECT* GetProject() const { return m_project; }
588
597 void SetProject( PROJECT* aProject, bool aReferenceOnly = false );
598
599 void ClearProject();
600
608 std::vector<PCB_MARKER*> ResolveDRCExclusions( bool aCreateMarkers );
609
613 void RecordDRCExclusions();
614
619
623 void ResetNetHighLight();
624
628 const std::set<int>& GetHighLightNetCodes() const
629 {
630 return m_highLight.m_netCodes;
631 }
632
639 void SetHighLightNet( int aNetCode, bool aMulti = false );
640
644 bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
645
653 void HighLightON( bool aValue = true );
654
659 {
660 HighLightON( false );
661 }
662
666 int GetCopperLayerCount() const;
667 void SetCopperLayerCount( int aCount );
668
669 int GetUserDefinedLayerCount() const;
670 void SetUserDefinedLayerCount( int aCount );
671
677
678 PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayer ) const;
679
680 int LayerDepth( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer ) const;
681
687 const LSET& GetEnabledLayers() const;
688 LSET GetLayerSet() const override { return GetEnabledLayers(); }
689
695 void SetEnabledLayers( const LSET& aLayerMask );
696 void SetLayerSet( const LSET& aLayerMask ) override { SetEnabledLayers( aLayerMask ); }
697
704 bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const;
705
713 bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
714
720 const LSET& GetVisibleLayers() const;
721
728 void SetVisibleLayers( const LSET& aLayerMask );
729
730 // these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
731 // are not stored in the bitmap.
732
740
747 void SetVisibleElements( const GAL_SET& aMask );
748
754 void SetVisibleAlls();
755
763 bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
764
772 void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
773
781 bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
782
787 void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings );
788
796 void InvalidateClearanceCache( const KIID& aUuid );
797
804
806
807 const PAGE_INFO& GetPageSettings() const { return m_paper; }
808 void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
809
811 void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
812
814 const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
815 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
816
817 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
818
820 void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
821
826 void UpdateUserUnits( BOARD_ITEM* aItem, KIGFX::VIEW* aView );
827
848 bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, bool aInferOutlineIfNecessary,
849 OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr,
850 bool aAllowUseArcsInPolygons = false, bool aIncludeNPTHAsOutlines = false );
851
861
875 KIGFX::RENDER_SETTINGS* aRenderSettings = nullptr ) const;
876
880 PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
881
888 const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
889
897 bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
898
909 static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
910 {
911 // a BOARD's standard layer name is the PCB_LAYER_ID fixed name
912 return LayerName( aLayerId );
913 }
914
922 bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
923
927 bool IsFrontLayer( PCB_LAYER_ID aLayer ) const;
928
932 bool IsBackLayer( PCB_LAYER_ID aLayer ) const;
933
940 LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
941
949 bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
950
955 unsigned GetNodesCount( int aNet = -1 ) const;
956
965 const std::vector<PAD*> GetPads() const;
966
968 {
969 m_NetInfo.buildListOfNets();
970 }
971
978 NETINFO_ITEM* FindNet( int aNetcode ) const;
979
986 NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
987
997 int MatchDpSuffix( const wxString& aNetName, wxString& aComplementNet );
998
1002 NETINFO_ITEM* DpCoupledNet( const NETINFO_ITEM* aNet );
1003
1005 {
1006 return m_NetInfo;
1007 }
1008
1010 {
1011 m_NetInfo.RemoveUnusedNets( aCommit );
1012 }
1013
1018 {
1019 return m_NetInfo.begin();
1020 }
1021
1026 {
1027 return m_NetInfo.end();
1028 }
1029
1033 unsigned GetNetCount() const
1034 {
1035 return m_NetInfo.GetNetCount();
1036 }
1037
1042
1047
1054 BOX2I ComputeBoundingBox( bool aBoardEdgesOnly = false, bool aPhysicalLayersOnly = false ) const;
1055
1056 const BOX2I GetBoundingBox() const override
1057 {
1058 return ComputeBoundingBox( false, false );
1059 }
1060
1071 {
1072 return ComputeBoundingBox( true, true );
1073 }
1074
1075 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
1076
1088 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
1089 const std::vector<KICAD_T>& scanTypes ) override;
1090
1099 FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
1100
1107 FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
1108
1112 std::set<wxString> GetNetClassAssignmentCandidates() const;
1113
1121 void SynchronizeNetsAndNetClasses( bool aResetTrackAndViaSizes );
1122
1126 bool SynchronizeComponentClasses( const std::unordered_set<wxString>& aNewSheetPaths ) const;
1127
1131 void SynchronizeProperties();
1132
1137
1141 double Similarity( const BOARD_ITEM& aOther ) const override
1142 {
1143 return 1.0;
1144 }
1145
1146 bool operator==( const BOARD_ITEM& aOther ) const override;
1147
1148 wxString GetClass() const override
1149 {
1150 return wxT( "BOARD" );
1151 }
1152
1153#if defined(DEBUG)
1154 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1155#endif
1156
1157
1158 /*************************/
1159 /* Copper Areas handling */
1160 /*************************/
1161
1172
1179 ZONE* GetArea( int index ) const
1180 {
1181 if( (unsigned) index < m_zones.size() )
1182 return m_zones[index];
1183
1184 return nullptr;
1185 }
1186
1190 std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false ) const;
1191
1195 int GetAreaCount() const
1196 {
1197 return static_cast<int>( m_zones.size() );
1198 }
1199
1200 /* Functions used in test, merge and cut outlines */
1201
1214 ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
1215 VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
1216
1224 bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
1225
1233 PAD* GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask ) const;
1234 PAD* GetPad( const VECTOR2I& aPosition ) const
1235 {
1236 return GetPad( aPosition, LSET().set() );
1237 }
1238
1246 PAD* GetPad( const PCB_TRACK* aTrace, ENDPOINT_T aEndPoint ) const;
1247
1262 PAD* GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, const LSET& aLayerMask ) const;
1263
1275 void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
1276
1284 std::tuple<int, double, double, double, double> GetTrackLength( const PCB_TRACK& aTrack ) const;
1285
1293 TRACKS TracksInNet( int aNetCode );
1294
1307 FOOTPRINT* GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveLayer,
1308 bool aVisibleOnly, bool aIgnoreLocked = false ) const;
1309
1315 int GetMaxClearanceValue() const;
1316
1322 void MapNets( BOARD* aDestBoard );
1323
1324 void SanitizeNetcodes();
1325
1334 void AddListener( BOARD_LISTENER* aListener );
1335
1340 void RemoveListener( BOARD_LISTENER* aListener );
1341
1345 void RemoveAllListeners();
1346
1351 void OnItemChanged( BOARD_ITEM* aItem );
1352
1357 void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
1358
1363 void OnItemsCompositeUpdate( std::vector<BOARD_ITEM*>& aAddedItems,
1364 std::vector<BOARD_ITEM*>& aRemovedItems,
1365 std::vector<BOARD_ITEM*>& aChangedItems );
1366
1370 void OnRatsnestChanged();
1371
1378 wxString GroupsSanityCheck( bool repair = false );
1379
1385 wxString GroupsSanityCheckInternal( bool repair );
1386
1387 bool LegacyTeardrops() const { return m_legacyTeardrops; }
1388 void SetLegacyTeardrops( bool aFlag ) { m_legacyTeardrops = aFlag; }
1389
1390 EMBEDDED_FILES* GetEmbeddedFiles() override;
1391 const EMBEDDED_FILES* GetEmbeddedFiles() const;
1392
1394
1398 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
1399
1403 void EmbedFonts() override;
1404
1409
1414
1416
1426 void SaveToHistory( const wxString& aProjectPath, std::vector<HISTORY_FILE_DATA>& aFileData );
1427
1428 const std::unordered_map<KIID, BOARD_ITEM*>& GetItemByIdCache() const
1429 {
1430 return m_itemByIdCache;
1431 }
1432
1433 bool IsItemIndexedById( const BOARD_ITEM* aItem ) const
1434 {
1435 return m_cachedIdByItem.contains( aItem );
1436 }
1437
1445 BOARD_ITEM* GetCachedItemById( const KIID& aId ) const;
1446
1453 void CacheItemById( BOARD_ITEM* aItem ) const;
1454
1461 void UncacheItemById( const KIID& aId ) const;
1462
1464 {
1465 wxCHECK( aItem, /* void */ );
1466
1467 CacheItemById( aItem );
1468
1469 aItem->RunOnChildren(
1470 [this]( BOARD_ITEM* aChild )
1471 {
1472 CacheItemSubtreeById( aChild );
1473 },
1475 }
1476
1477 void CacheChildrenById( const BOARD_ITEM* aParent )
1478 {
1479 wxCHECK( aParent, /* void */ );
1480
1481 aParent->RunOnChildren(
1482 [this]( BOARD_ITEM* aChild )
1483 {
1484 CacheItemSubtreeById( aChild );
1485 },
1487 }
1488
1490 {
1491 wxCHECK( aItem, /* void */ );
1492
1493 UncacheItemById( aItem->m_Uuid );
1494
1495 aItem->RunOnChildren(
1496 [this]( BOARD_ITEM* aChild )
1497 {
1498 UncacheItemSubtreeById( aChild );
1499 },
1501 }
1502
1503 void UncacheChildrenById( const BOARD_ITEM* aParent )
1504 {
1505 wxCHECK( aParent, /* void */ );
1506
1507 aParent->RunOnChildren(
1508 [this]( BOARD_ITEM* aChild )
1509 {
1510 UncacheItemSubtreeById( aChild );
1511 },
1513 }
1514
1521 void UncacheItemByPtr( const BOARD_ITEM* aItem );
1522
1523 BOARD_ITEM* CacheAndReturnItemById( const KIID& aId, BOARD_ITEM* aItem ) const;
1524
1525 // --------- Item order comparators ---------
1526
1528 {
1529 bool operator() ( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
1530 };
1531
1533 {
1534 bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
1535 };
1536
1537public:
1538 // ------------ Run-time caches -------------
1539 mutable std::shared_mutex m_CachesMutex;
1540 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsCourtyardCache;
1541 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsFCourtyardCache;
1542 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsBCourtyardCache;
1543 std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_IntersectsAreaCache;
1544 std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_EnclosedByAreaCache;
1545 std::unordered_map< wxString, LSET > m_LayerExpressionCache;
1546 std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
1547 std::shared_ptr<DRC_RTREE> m_CopperItemRTreeCache;
1548 mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
1549 mutable std::optional<int> m_maxClearanceValue;
1550
1551 mutable std::unordered_map<const BOARD_ITEM*, wxString> m_ItemNetclassCache;
1552
1553 // Zone name lookup cache for DRC rule area functions like enclosedByArea/intersectsArea.
1554 // Maps zone names to vectors of matching zones to avoid O(n) zone iteration per lookup.
1555 mutable std::unordered_map<wxString, std::vector<ZONE*>> m_ZonesByNameCache;
1556
1557 // Deflated zone outline cache for DRC area checks. Caches the deflated outline for each zone
1558 // to avoid repeated expensive deflation operations during collidesWithArea calls.
1559 mutable std::unordered_map<const ZONE*, SHAPE_POLY_SET> m_DeflatedZoneOutlineCache;
1560
1561 // ------------ DRC caches -------------
1562 std::vector<ZONE*> m_DRCZones;
1563 std::vector<ZONE*> m_DRCCopperZones;
1564 std::map<PCB_LAYER_ID, std::vector<ZONE*>> m_DRCCopperZonesByLayer;
1567 ZONE* m_SolderMaskBridges; // A container to build bridges on solder mask layers
1568 std::map<ZONE*, std::map<PCB_LAYER_ID, ISOLATED_ISLANDS>> m_ZoneIsolatedIslandsMap;
1569
1570private:
1571 // The default copy constructor & operator= are inadequate,
1572 // either write one or do not use it at all
1573 BOARD( const BOARD& aOther ) = delete;
1574
1575 BOARD& operator=( const BOARD& aOther ) = delete;
1576
1577 template <typename Func, typename... Args>
1578 void InvokeListeners( Func&& aFunc, Args&&... args )
1579 {
1580 for( auto&& l : m_listeners )
1581 ( l->*aFunc )( std::forward<Args>( args )... );
1582 }
1583
1584 // Refresh user layer opposites.
1585 void recalcOpposites();
1586
1587 friend class PCB_EDIT_FRAME;
1588
1589private:
1592
1595 int m_timeStamp; // actually a modification counter
1596
1597 wxString m_fileName;
1598
1599 // These containers only have const accessors and must only be modified by Add()/Remove()
1609
1610 // Cache for fast access to items in the containers above by KIID, including children.
1611 // Mutable because it's a performance cache that can be populated during const lookups.
1612 // NOT protected by m_CachesMutex. Only safe for single-threaded access (UI, serialization).
1613 mutable std::unordered_map<KIID, BOARD_ITEM*> m_itemByIdCache;
1614 mutable std::unordered_map<const BOARD_ITEM*, KIID> m_cachedIdByItem;
1615
1616 std::map<int, LAYER> m_layers; // layer data
1617
1618 HIGH_LIGHT_INFO m_highLight; // current high light data
1619 HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
1620
1621 int m_fileFormatVersionAtLoad; // the version loaded from the file
1622 wxString m_generator; // the generator tag from the file
1623
1624 std::map<wxString, wxString> m_properties;
1625 std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
1626
1628 TITLE_BLOCK m_titles; // text in lower right of screen and plots
1630 PROJECT* m_project; // project this board is a part of
1632
1633 // Variant system
1634 wxString m_currentVariant; // Currently active variant (empty = default)
1635 std::vector<wxString> m_variantNames; // All variant names in the board
1636 std::map<wxString, wxString> m_variantDescriptions; // Descriptions for each variant
1637
1648 std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
1649
1654 bool m_legacyTeardrops = false;
1655
1656 NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
1657
1658 std::vector<BOARD_LISTENER*> m_listeners;
1659
1661
1662 // Used for dummy boards, such as a footprint holder, where we don't want to make a copy
1663 // of all the parent's embedded data.
1665
1666 std::unique_ptr<COMPONENT_CLASS_MANAGER> m_componentClassManager;
1667 std::unique_ptr<LENGTH_DELAY_CALCULATION> m_lengthDelayCalc;
1668};
1669
1670
1671#endif // CLASS_BOARD_H_
int index
BOARD_USE
Flags to specify how the board is being used.
Definition board.h:313
@ FPHOLDER
Definition board.h:315
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
Definition board.h:186
@ LT_POWER
Definition board.h:189
@ LT_FRONT
Definition board.h:193
@ LT_MIXED
Definition board.h:190
@ LT_BACK
Definition board.h:194
@ LT_UNDEFINED
Definition board.h:187
@ LT_JUMPER
Definition board.h:191
@ LT_AUX
Definition board.h:192
@ LT_SIGNAL
Definition board.h:188
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
Definition board.h:307
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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.
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
Definition board_item.h:232
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
Definition board.h:292
virtual void OnBoardRatsnestChanged(BOARD &aBoard)
Definition board.h:296
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
Definition board.h:289
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition board.h:293
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition board.h:290
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition board.h:288
virtual void OnBoardHighlightNetChanged(BOARD &aBoard)
Definition board.h:295
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
Definition board.h:291
virtual void OnBoardCompositeUpdate(BOARD &aBoard, std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems)
Definition board.h:297
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
Definition board.h:294
virtual ~BOARD_LISTENER()
Definition board.h:287
Manage layers needed to make a physical board.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
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:2430
ZONE * m_SolderMaskBridges
Definition board.h:1567
void GetContextualTextVars(wxArrayString *aVars) const
Definition board.cpp:483
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:1080
BOARD_STACKUP GetStackupOrDefault() const
Definition board.cpp:3110
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition board.h:811
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_EnclosedByAreaCache
Definition board.h:1544
std::map< ZONE *, std::map< PCB_LAYER_ID, ISOLATED_ISLANDS > > m_ZoneIsolatedIslandsMap
Definition board.h:1568
PCB_LAYER_ID GetCopperLayerStackMaxId() const
Definition board.cpp:951
GENERATORS m_generators
Definition board.h:1606
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:3453
const NETINFO_LIST & GetNetInfo() const
Definition board.h:1004
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
Definition board.h:430
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition board.h:353
PAD * GetPad(const VECTOR2I &aPosition, const LSET &aLayerMask) const
Find a pad aPosition on aLayer.
Definition board.cpp:2960
int GetUserDefinedLayerCount() const
Definition board.cpp:940
void recalcOpposites()
Definition board.cpp:861
void CacheItemSubtreeById(BOARD_ITEM *aItem)
Definition board.h:1463
void SetPosition(const VECTOR2I &aPos) override
Definition board.cpp:618
std::map< wxString, wxString > m_properties
Definition board.h:1624
void CacheItemById(BOARD_ITEM *aItem) const
Add an item to the item-by-id cache.
Definition board.cpp:1913
std::unordered_map< const BOARD_ITEM *, wxString > m_ItemNetclassCache
Definition board.h:1551
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition board.cpp:3296
int m_fileFormatVersionAtLoad
Definition board.h:1621
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
Definition board.cpp:2648
void UncacheItemById(const KIID &aId) const
Remove an item from the item-by-id cache.
Definition board.cpp:1942
void SetCurrentVariant(const wxString &aVariant)
Definition board.cpp:2721
std::vector< ZONE * > m_DRCCopperZones
Definition board.h:1563
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition board.cpp:1008
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition board.h:342
void SetVariantNames(const std::vector< wxString > &aNames)
Definition board.h:402
const std::vector< wxString > & GetVariantNames() const
Definition board.h:401
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1237
const std::set< int > & GetHighLightNetCodes() const
Definition board.h:628
void MapNets(BOARD *aDestBoard)
Map all nets in the given board to nets with the same name (if any) in the destination board.
Definition board.cpp:3400
bool m_legacyTeardrops
Teardrops in 7.0 were applied as a post-processing step (rather than from pad and via properties).
Definition board.h:1654
TITLE_BLOCK m_titles
Definition board.h:1628
GAL_SET m_LegacyVisibleItems
Definition board.h:427
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition board.h:335
ZONE * GetArea(int index) const
Return the Zone at a given index.
Definition board.h:1179
std::vector< wxString > m_variantNames
Definition board.h:1635
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition board.h:1070
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition board.h:1056
LENGTH_DELAY_CALCULATION * GetLengthCalculation() const
Returns the track length calculator.
Definition board.h:1408
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
Definition board.cpp:2867
void BuildListOfNets()
Definition board.h:967
void RunOnNestedEmbeddedFiles(const std::function< void(EMBEDDED_FILES *)> &aFunction) override
Provide access to nested embedded files, such as symbols in schematics and footprints in boards.
Definition board.cpp:1209
const GENERATORS & Generators() const
Definition board.h:370
void SetFileName(const wxString &aFileName)
Definition board.h:358
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition board.h:909
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition board.cpp:3365
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition board.h:688
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:1042
int m_outlinesChainingEpsilon
the max distance between 2 end point to see them connected when building the board outlines
Definition board.h:1591
std::tuple< int, double, double, 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:3121
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
Definition board.cpp:2687
BOARD_USE m_boardUse
What is this board being used for.
Definition board.h:1594
PCB_BOARD_OUTLINE * BoardOutline()
Definition board.h:372
PAGE_INFO m_paper
Definition board.h:1627
void RemoveAllListeners()
Remove all listeners.
Definition board.cpp:3447
FOOTPRINTS m_footprints
Definition board.h:1602
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:1648
friend class PCB_EDIT_FRAME
Definition board.h:1587
void SetEmbeddedFilesDelegate(EMBEDDED_FILES *aDelegate)
Definition board.h:1393
const PCB_POINTS & Points() const
Definition board.h:378
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines, KIGFX::RENDER_SETTINGS *aRenderSettings=nullptr) const
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
Definition board.cpp:3665
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:3428
const PAGE_INFO & GetPageSettings() const
Definition board.h:807
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition board.cpp:1696
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition board.h:395
bool IsBackLayer(PCB_LAYER_ID aLayer) const
Definition board.cpp:786
BOARD(const BOARD &aOther)=delete
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition board.cpp:1036
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition board.cpp:3487
HIGH_LIGHT_INFO m_highLight
Definition board.h:1618
std::map< wxString, wxString > m_variantDescriptions
Definition board.h:1636
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Return the type of the copper layer given by aLayer.
Definition board.cpp:709
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2581
EDA_UNITS m_userUnits
Definition board.h:1631
void UpdateBoardOutline()
Definition board.cpp:3852
const ZONES & Zones() const
Definition board.h:368
void BulkRemoveStaleTeardrops(BOARD_COMMIT &aCommit)
Remove all teardrop zones with the STRUCT_DELETED flag set.
Definition board.cpp:1367
void DeleteVariant(const wxString &aVariantName)
Definition board.cpp:2755
void InvokeListeners(Func &&aFunc, Args &&... args)
Definition board.h:1578
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings)
Definition board.cpp:1097
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:990
void SanitizeNetcodes()
Definition board.cpp:3418
void InitializeClearanceCache()
Initialize the clearance cache for all board items.
Definition board.cpp:1110
EMBEDDED_FILES * m_embeddedFilesDelegate
Definition board.h:1664
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:3230
bool IsFrontLayer(PCB_LAYER_ID aLayer) const
Definition board.cpp:780
const GROUPS & Groups() const
The groups must maintain the following invariants.
Definition board.h:390
~BOARD()
Definition board.cpp:163
void SaveToHistory(const wxString &aProjectPath, std::vector< HISTORY_FILE_DATA > &aFileData)
Serialize board into HISTORY_FILE_DATA for non-blocking history commit.
Definition board.cpp:3899
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:195
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:1002
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Definition board.cpp:792
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
Definition board.cpp:338
DRAWINGS m_drawings
Definition board.h:1601
void OnItemsCompositeUpdate(std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems)
Notify the board and its listeners that items on the board have been modified in a composite operatio...
Definition board.cpp:3465
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
Definition board.cpp:2926
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:2887
EDA_UNITS GetUserUnits()
Definition board.h:819
void ResetNetHighLight()
Reset all high light data to the init state.
Definition board.cpp:3478
PCB_PLOT_PARAMS m_plotOptions
Definition board.h:1629
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition board.cpp:755
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false) const
Definition board.cpp:3210
bool ResolveTextVar(wxString *token, int aDepth) const
Definition board.cpp:510
const MARKERS & Markers() const
Definition board.h:376
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition board.h:524
void UncacheChildrenById(const BOARD_ITEM *aParent)
Definition board.h:1503
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
Definition board.cpp:921
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition board.cpp:3351
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition board.cpp:624
TITLE_BLOCK & GetTitleBlock()
Definition board.h:813
void FixupEmbeddedData()
After loading a file from disk, the footprints do not yet contain the full data for their embedded fi...
Definition board.cpp:1216
int GetMaxClearanceValue() const
Returns the maximum clearance value for any object on the board.
Definition board.cpp:1117
ZONES m_zones
Definition board.h:1605
void InvalidateClearanceCache(const KIID &aUuid)
Invalidate the clearance cache for a specific item.
Definition board.cpp:1103
PAD * GetPad(const VECTOR2I &aPosition) const
Definition board.h:1234
std::unordered_map< const BOARD_ITEM *, KIID > m_cachedIdByItem
Definition board.h:1614
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
Definition board.cpp:717
HIGH_LIGHT_INFO m_highLightPrevious
Definition board.h:1619
const VECTOR2I GetFocusPosition() const override
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition board.h:441
void HighLightOFF()
Disable net highlight.
Definition board.h:658
NETINFO_LIST m_NetInfo
Definition board.h:1656
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition board.h:426
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition board.cpp:1025
void SetOutlinesChainingEpsilon(int aValue)
Definition board.h:860
bool HasVariant(const wxString &aVariantName) const
Definition board.cpp:2738
NETINFO_LIST::iterator EndNets() const
Definition board.h:1025
void AddVariant(const wxString &aVariantName)
Definition board.cpp:2744
int GetCopperLayerCount() const
Definition board.cpp:928
int m_timeStamp
Definition board.h:1595
std::vector< BOARD_LISTENER * > m_listeners
Definition board.h:1658
bool RemoveAllItemsOnLayer(PCB_LAYER_ID aLayer)
Removes all owned items other than footprints existing on the given board layer, and modifies the sta...
Definition board.cpp:1610
const std::map< wxString, wxString > & GetProperties() const
Definition board.h:394
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsCourtyardCache
Definition board.h:1540
void IncrementTimeStamp()
Definition board.cpp:266
int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet)
Fetch the coupled netname for a given net.
Definition board.cpp:2600
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsFCourtyardCache
Definition board.h:1541
PCB_POINTS m_points
Definition board.h:1608
std::unique_ptr< LENGTH_DELAY_CALCULATION > m_lengthDelayCalc
Definition board.h:1667
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
Definition board.h:1009
const FOOTPRINTS & Footprints() const
Definition board.h:364
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
Definition board.h:1625
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
Get the list of all outline fonts used in the board.
Definition board.cpp:3314
void RemoveAll(std::initializer_list< KICAD_T > aTypes={ PCB_NETINFO_T, PCB_MARKER_T, PCB_GROUP_T, PCB_ZONE_T, PCB_GENERATOR_T, PCB_FOOTPRINT_T, PCB_TRACE_T, PCB_SHAPE_T })
An efficient way to remove all items of a certain type from the board.
Definition board.cpp:1480
const BOARD_ITEM_SET GetItemSet()
Definition board.cpp:3767
const TRACKS & Tracks() const
Definition board.h:362
int m_DRCMaxPhysicalClearance
Definition board.h:1566
const PCB_BOARD_OUTLINE * BoardOutline() const
Definition board.h:373
FOOTPRINT * FindFootprintByPath(const KIID_PATH &aPath) const
Search for a FOOTPRINT within this board with the given path.
Definition board.cpp:2675
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:1361
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition board.h:808
std::unordered_map< wxString, LSET > m_LayerExpressionCache
Definition board.h:1545
BOARD_ITEM * GetCachedItemById(const KIID &aId) const
Return a cached item for aId if the entry is still self-consistent.
Definition board.cpp:1896
bool m_embedFonts
Definition board.h:1660
wxString GroupsSanityCheckInternal(bool repair)
Definition board.cpp:3524
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
Definition board.cpp:3472
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition board.cpp:2153
wxString GetClass() const override
Return the class name.
Definition board.h:1148
std::unique_ptr< COMPONENT_CLASS_MANAGER > m_componentClassManager
Definition board.h:1666
NETINFO_LIST::iterator BeginNets() const
Definition board.h:1017
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, bool aInferOutlineIfNecessary, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition board.cpp:3255
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
Definition board.h:434
void SetCopperLayerCount(int aCount)
Definition board.cpp:934
std::unordered_map< const ZONE *, BOX2I > m_ZoneBBoxCache
Definition board.h:1548
std::unordered_map< const ZONE *, SHAPE_POLY_SET > m_DeflatedZoneOutlineCache
Definition board.h:1559
wxString m_generator
Definition board.h:1622
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsBCourtyardCache
Definition board.h:1542
TRACKS TracksInNet(int aNetCode)
Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
Definition board.cpp:687
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition board.cpp:205
PROJECT * m_project
Definition board.h:1630
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:3146
bool HasItemsOnLayer(PCB_LAYER_ID aLayer)
Definition board.cpp:1564
const wxString & GetFileName() const
Definition board.h:360
bool operator==(const BOARD_ITEM &aOther) const override
Definition board.cpp:3784
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition board.cpp:395
int GetPadWithCastellatedAttrCount()
Definition board.cpp:3881
wxString GetVariantDescription(const wxString &aVariantName) const
Definition board.cpp:2831
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition board.cpp:2663
unsigned GetNodesCount(int aNet=-1) const
Definition board.cpp:2306
bool IsHighLightNetON() const
Definition board.h:644
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition board.cpp:2111
int GetFileFormatVersionAtLoad() const
Definition board.h:450
std::map< PCB_LAYER_ID, std::vector< ZONE * > > m_DRCCopperZonesByLayer
Definition board.h:1564
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition board.cpp:1048
std::shared_ptr< DRC_RTREE > m_CopperItemRTreeCache
Definition board.h:1547
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
Definition board.cpp:811
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition board.h:810
BOARD & operator=(const BOARD &aOther)=delete
wxString m_fileName
Definition board.h:1597
const wxString & GetGenerator() const
Adds an item to the container.
Definition board.h:453
int GetAreaCount() const
Definition board.h:1195
void DetachAllFootprints()
Remove all footprints without deleting.
Definition board.cpp:1767
void SetLegacyTeardrops(bool aFlag)
Definition board.h:1388
std::map< int, LAYER > m_layers
Definition board.h:1616
wxString GetCurrentVariant() const
Definition board.h:398
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
Definition board.cpp:645
int GetOutlinesChainingEpsilon()
Definition board.h:859
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:3095
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:982
int m_DRCMaxClearance
Definition board.h:1565
void ClearProject()
Definition board.cpp:246
void UncacheItemByPtr(const BOARD_ITEM *aItem)
Remove every cache entry that still points to aItem.
Definition board.cpp:1989
void SetLayerSet(const LSET &aLayerMask) override
Definition board.h:696
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition board.h:1546
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:1355
wxString m_currentVariant
Definition board.h:1634
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
Definition board.cpp:964
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition board.cpp:1755
PROJECT * GetProject() const
Definition board.h:587
bool IsEmpty() const
Definition board.cpp:606
int GetPadWithPressFitAttrCount()
Definition board.cpp:3863
bool LegacyTeardrops() const
Definition board.h:1387
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:2392
const TITLE_BLOCK & GetTitleBlock() const
Definition board.h:814
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
Definition board.cpp:3510
void RenameVariant(const wxString &aOldName, const wxString &aNewName)
Definition board.cpp:2783
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1091
std::vector< ZONE * > m_DRCZones
Definition board.h:1562
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:976
void SetGenerator(const wxString &aGenerator)
Definition board.h:452
BOARD()
Definition board.cpp:91
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition board.cpp:307
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition board.cpp:2233
void RebindItemUuid(BOARD_ITEM *aItem, const KIID &aNewId)
Rebind the UUID of an attached item and keep the item-by-id cache coherent.
Definition board.cpp:2012
int RepairDuplicateItemUuids()
Rebind duplicate attached-item UUIDs so each live board item has a unique ID.
Definition board.cpp:2038
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition board.cpp:2701
std::unordered_map< KIID, BOARD_ITEM * > m_itemByIdCache
Definition board.h:1613
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition board.cpp:3435
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
Definition board.h:1413
std::shared_mutex m_CachesMutex
Definition board.h:1539
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aPhysicalLayersOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition board.cpp:2323
unsigned GetNetCount() const
Definition board.h:1033
const std::unordered_map< KIID, BOARD_ITEM * > & GetItemByIdCache() const
Definition board.h:1428
bool SynchronizeComponentClasses(const std::unordered_set< wxString > &aNewSheetPaths) const
Copy component class / component class generator information from the project settings.
Definition board.cpp:2917
BOARD_ITEM * CacheAndReturnItemById(const KIID &aId, BOARD_ITEM *aItem) const
Definition board.cpp:1961
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1718
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition board.cpp:1384
std::unordered_map< wxString, std::vector< ZONE * > > m_ZonesByNameCache
Definition board.h:1555
GROUPS m_groups
Definition board.h:1604
PROJECT::ELEM ProjectElementType() override
Definition board.h:1415
MARKERS m_markers
Definition board.h:1600
bool IsItemIndexedById(const BOARD_ITEM *aItem) const
Definition board.h:1433
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_IntersectsAreaCache
Definition board.h:1543
std::optional< int > m_maxClearanceValue
Definition board.h:1549
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition board.cpp:3500
void SetEnabledLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:996
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition board.h:815
void CacheChildrenById(const BOARD_ITEM *aParent)
Definition board.h:1477
void SynchronizeTuningProfileProperties()
Ensure that all time domain properties providers are in sync with current settings.
Definition board.cpp:2881
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
TRACKS m_tracks
Definition board.h:1603
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Definition board.cpp:1779
bool m_LegacyCopperEdgeClearanceLoaded
Definition board.h:431
int GetTimeStamp() const
Definition board.h:346
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:3459
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:571
VECTOR2I GetPosition() const override
Definition board.cpp:612
void SetVariantDescription(const wxString &aVariantName, const wxString &aDescription)
Definition board.cpp:2850
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
Definition board.cpp:1149
static bool ClassOf(const EDA_ITEM *aItem)
Definition board.h:325
void SetUserUnits(EDA_UNITS aUnits)
Definition board.h:820
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:1015
void EmbedFonts() override
Finds all fonts used in the board and embeds them in the file if permissions allow.
Definition board.cpp:3341
double Similarity(const BOARD_ITEM &aOther) const override
Return the Similarity.
Definition board.h:1141
PCB_BOARD_OUTLINE * m_boardOutline
Definition board.h:1607
void SetUserDefinedLayerCount(int aCount)
Definition board.cpp:946
const DRAWINGS & Drawings() const
Definition board.h:366
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition board.cpp:1690
void UncacheItemSubtreeById(const BOARD_ITEM *aItem)
Definition board.h:1489
void SetFileFormatVersionAtLoad(int aVersion)
Definition board.h:449
constexpr const Vec GetCenter() const
Definition box2.h:230
A class to manage Component Classes in a board context.
Store all of the related component information found in a netlist.
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition drc_rtree.h:50
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:528
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
EMBEDDED_FILES()=default
Helper for storing and iterating over GAL_LAYER_IDs.
Definition layer_ids.h:405
void Clear()
Definition board.h:262
friend class BOARD
Definition board.h:274
std::set< int > m_netCodes
Definition board.h:259
bool m_highLightOn
Definition board.h:260
Class OUTLINE_FONT implements outline font drawing.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:67
Definition kiid.h:48
Class which calculates lengths (and associated routing statistics) in a BOARD context.
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:54
Handle the data for a net.
Definition netinfo.h:50
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Definition netinfo.h:253
Container for NETINFO_ITEM elements, which are the nets.
Definition netinfo.h:193
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition pad.h:55
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:79
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:53
Parameters and options when plotting/printing a board.
A holder to handle information on schematic or board items.
A progress reporter interface for use in multi-threaded environments.
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
Definition project.h:93
Container for project specific data.
Definition project.h:66
ELEM
The set of #_ELEMs that a PROJECT can hold.
Definition project.h:72
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
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
Handle a list of polygons defining a copper zone.
Definition zone.h:74
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
#define LAYER(n, l)
RECURSE_MODE
Definition eda_item.h:52
@ NO_RECURSE
Definition eda_item.h:54
INSPECT_RESULT
Definition eda_item.h:46
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:93
EDA_UNITS
Definition eda_units.h:48
static constexpr void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
Definition hash.h:32
NORMAL
Follows standard pretty-printing rules.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition layer_id.cpp:31
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:228
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
STL namespace.
std::vector< ZONE * > ZONES
std::vector< PCB_MARKER * > MARKERS
std::deque< FOOTPRINT * > FOOTPRINTS
std::deque< PCB_TRACK * > TRACKS
std::deque< PCB_GROUP * > GROUPS
std::deque< PCB_GENERATOR * > GENERATORS
std::deque< BOARD_ITEM * > DRAWINGS
std::deque< PCB_POINT * > PCB_POINTS
ENDPOINT_T
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition board.cpp:3614
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition board.cpp:3593
Data produced by a registered saver on the UI thread, consumed by the background commit thread.
A struct recording the isolated and single-pad islands within a zone.
Definition zone.h:61
LAYERS_CHECKED(PCB_LAYER_ID aLayer)
Definition board.h:135
bool has_error
Definition board.h:141
LSET layers
Definition board.h:140
int m_opposite
Similar layer on opposite side of the board, if any.
Definition board.h:234
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
Definition board.cpp:840
void clear()
Definition board.h:208
LAYER_T m_type
The type of the layer.
Definition board.h:231
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Definition board.cpp:824
LAYER()
Definition board.h:203
wxString m_name
The canonical name of the layer.
Definition board.h:229
wxString m_userName
The user defined name of the layer.
Definition board.h:230
bool m_visible
Definition board.h:232
int m_number
The layer ID.
Definition board.h:233
BOARD_ITEM * A
Definition board.h:107
bool operator==(const PTR_LAYER_CACHE_KEY &other) const
Definition board.h:110
PCB_LAYER_ID Layer
Definition board.h:108
BOARD_ITEM * A
Definition board.h:96
BOARD_ITEM * B
Definition board.h:97
bool operator==(const PTR_PTR_CACHE_KEY &other) const
Definition board.h:99
bool operator==(const PTR_PTR_LAYER_CACHE_KEY &other) const
Definition board.h:122
BOARD_ITEM * B
Definition board.h:119
BOARD_ITEM * A
Definition board.h:118
PCB_LAYER_ID Layer
Definition board.h:120
std::size_t operator()(const PTR_LAYER_CACHE_KEY &k) const
Definition board.h:161
std::size_t operator()(const PTR_PTR_CACHE_KEY &k) const
Definition board.h:150
std::size_t operator()(const PTR_PTR_LAYER_CACHE_KEY &k) const
Definition board.h:172
const uint32_t seed
@ PCB_T
Definition typeinfo.h:79
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:85
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:88
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:108
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:105
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:96
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:83
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition typeinfo.h:107
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:93
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.