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
31#include <embedded_files.h>
32#include <common.h> // Needed for stl hash extensions
33#include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER
35#include <hash.h>
36#include <layer_ids.h>
37#include <lset.h>
38#include <netinfo.h>
39#include <pcb_item_containers.h>
40#include <pcb_plot_params.h>
41#include <title_block.h>
42#include <tools/pcb_selection.h>
43#include <shared_mutex>
44#include <project.h>
45#include <list>
46
49class BOARD_COMMIT;
50class DRC_RTREE;
51class PCB_BASE_FRAME;
52class PCB_EDIT_FRAME;
55class BOARD;
56class FOOTPRINT;
57class ZONE;
58class PCB_TRACK;
59class PAD;
60class PCB_GROUP;
61class PCB_GENERATOR;
62class PCB_MARKER;
63class MSG_PANEL_ITEM;
64class NETLIST;
65class REPORTER;
67class COMPONENT;
68class PROJECT;
71
72namespace KIGFX
73{
74class RENDER_SETTINGS;
75};
76
77
78namespace KIFONT
79{
80 class OUTLINE_FONT;
81}
82
83struct ISOLATED_ISLANDS;
84
85// The default value for m_outlinesChainingEpsilon to convert a board outlines to polygons
86// It is the max dist between 2 end points to see them connected
87#define DEFAULT_CHAINING_EPSILON_MM 0.01
88
89// Forward declare endpoint from class_track.h
90enum ENDPOINT_T : int;
91
92
94{
97
98 bool operator==(const PTR_PTR_CACHE_KEY& other) const
99 {
100 return A == other.A && B == other.B;
101 }
102};
103
105{
108
109 bool operator==(const PTR_LAYER_CACHE_KEY& other) const
110 {
111 return A == other.A && Layer == other.Layer;
112 }
113};
114
116{
120
121 bool operator==(const PTR_PTR_LAYER_CACHE_KEY& other) const
122 {
123 return A == other.A && B == other.B && Layer == other.Layer;
124 }
125};
126
128{
130 layers(),
131 has_error( false )
132 {}
133
135 layers( { aLayer } ),
136 has_error( false )
137 {}
138
141};
142
143
144namespace std
145{
146 template <>
147 struct hash<PTR_PTR_CACHE_KEY>
148 {
149 std::size_t operator()( const PTR_PTR_CACHE_KEY& k ) const
150 {
151 std::size_t seed = 0xa82de1c0;
152 hash_combine( seed, k.A, k.B );
153 return seed;
154 }
155 };
156
157 template <>
159 {
160 std::size_t operator()( const PTR_LAYER_CACHE_KEY& k ) const
161 {
162 std::size_t seed = 0xa82de1c0;
163 hash_combine( seed, k.A, k.Layer );
164 return seed;
165 }
166 };
167
168 template <>
170 {
171 std::size_t operator()( const PTR_PTR_LAYER_CACHE_KEY& k ) const
172 {
173 std::size_t seed = 0xa82de1c0;
174 hash_combine( seed, k.A, k.B, k.Layer );
175 return seed;
176 }
177 };
178}
179
180
195
196
200struct LAYER
201{
203 {
204 clear();
205 }
206
207 void clear()
208 {
210 m_visible = true;
211 m_number = 0;
212 m_name.clear();
213 m_userName.clear();
215 }
216
217 /*
218 LAYER( const wxString& aName = wxEmptyString,
219 LAYER_T aType = LT_SIGNAL, bool aVisible = true, int aNumber = -1 ) :
220 m_name( aName ),
221 m_type( aType ),
222 m_visible( aVisible ),
223 m_number( aNumber )
224 {
225 }
226 */
227
228 wxString m_name;
229 wxString m_userName;
234
241 static const char* ShowType( LAYER_T aType );
242
250 static LAYER_T ParseType( const char* aType );
251};
252
253
254// Helper class to handle high light nets
256{
257protected:
258 std::set<int> m_netCodes; // net(s) selected for highlight (-1 when no net selected )
259 bool m_highLightOn; // highlight active
260
261 void Clear()
262 {
263 m_netCodes.clear();
264 m_highLightOn = false;
265 }
266
268 {
269 Clear();
270 }
271
272private:
273 friend class BOARD;
274};
275
281class BOARD;
282
284{
285public:
286 virtual ~BOARD_LISTENER() { }
287 virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
288 virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) { }
289 virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
290 virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) { }
291 virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) { }
292 virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) { }
293 virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) { }
294 virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) { }
295 virtual void OnBoardRatsnestChanged( BOARD& aBoard ) { }
296 virtual void OnBoardCompositeUpdate( BOARD& aBoard, std::vector<BOARD_ITEM*>& aAddedItems,
297 std::vector<BOARD_ITEM*>& aRemovedItems,
298 std::vector<BOARD_ITEM*>& aChangedItems )
299 {
300 }
301};
302
306typedef std::set<BOARD_ITEM*, CompareByUuid> BOARD_ITEM_SET;
307
311enum class BOARD_USE
312{
313 NORMAL, // A normal board
314 FPHOLDER // A board that holds a single footprint
315};
316
317
322{
323public:
324 static inline bool ClassOf( const EDA_ITEM* aItem )
325 {
326 return aItem && PCB_T == aItem->Type();
327 }
328
334 void SetBoardUse( BOARD_USE aUse ) { m_boardUse = aUse; }
335
341 BOARD_USE GetBoardUse() const { return m_boardUse; }
342
343 void IncrementTimeStamp();
344
345 int GetTimeStamp() const { return m_timeStamp; }
346
352 bool IsFootprintHolder() const
353 {
355 }
356
357 void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
358
359 const wxString &GetFileName() const { return m_fileName; }
360
361 const TRACKS& Tracks() const { return m_tracks; }
362
363 const FOOTPRINTS& Footprints() const { return m_footprints; }
364
365 const DRAWINGS& Drawings() const { return m_drawings; }
366
367 const ZONES& Zones() const { return m_zones; }
368
369 const GENERATORS& Generators() const { return m_generators; }
370
373 void UpdateBoardOutline();
374
375 const MARKERS& Markers() const { return m_markers; }
376
377 const PCB_POINTS& Points() const { return m_points; }
378
379 // SWIG requires non-const accessors for some reason to make the custom iterators in board.i
380 // work. It would be good to remove this if we can figure out how to fix that.
381#ifdef SWIG
382 DRAWINGS& Drawings() { return m_drawings; }
383 TRACKS& Tracks() { return m_tracks; }
384#endif
385
387
396 const GROUPS& Groups() const { return m_groups; }
397
398 const std::vector<BOARD_CONNECTED_ITEM*> AllConnectedItems();
399
400 const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
401 void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
402
403 // Variant system
404 wxString GetCurrentVariant() const { return m_currentVariant; }
405 void SetCurrentVariant( const wxString& aVariant );
406
407 const std::vector<wxString>& GetVariantNames() const { return m_variantNames; }
408 void SetVariantNames( const std::vector<wxString>& aNames ) { m_variantNames = aNames; }
409
410 bool HasVariant( const wxString& aVariantName ) const;
411 void AddVariant( const wxString& aVariantName );
412 void DeleteVariant( const wxString& aVariantName );
413 void RenameVariant( const wxString& aOldName, const wxString& aNewName );
414
415 wxString GetVariantDescription( const wxString& aVariantName ) const;
416 void SetVariantDescription( const wxString& aVariantName, const wxString& aDescription );
417
426 wxArrayString GetVariantNamesForUI() const;
427
428 void GetContextualTextVars( wxArrayString* aVars ) const;
429 bool ResolveTextVar( wxString* token, int aDepth ) const;
430
434
438
441
442 BOARD();
443 ~BOARD();
444
445 VECTOR2I GetPosition() const override;
446 void SetPosition( const VECTOR2I& aPos ) override;
447 const VECTOR2I GetFocusPosition() const override { return GetBoundingBox().GetCenter(); }
448
449 bool IsEmpty() const;
450
451 void Move( const VECTOR2I& aMoveVector ) override;
452
453 void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
454
455 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
457
458 void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
459 const wxString& GetGenerator() const { return m_generator; }
460
462 void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
463 bool aSkipConnectivity = false ) override;
464
466 void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
467
476 void RemoveAll( std::initializer_list<KICAD_T> aTypes = { PCB_NETINFO_T, PCB_MARKER_T,
480
481 bool HasItemsOnLayer( PCB_LAYER_ID aLayer );
482
491 bool RemoveAllItemsOnLayer( PCB_LAYER_ID aLayer );
492
497 void BulkRemoveStaleTeardrops( BOARD_COMMIT& aCommit );
498
503 void FinalizeBulkAdd( std::vector<BOARD_ITEM*>& aNewItems );
504
509 void FinalizeBulkRemove( std::vector<BOARD_ITEM*>& aRemovedItems );
510
516 void FixupEmbeddedData();
517
518 void RunOnNestedEmbeddedFiles( const std::function<void( EMBEDDED_FILES* )>& aFunction ) override;
519
520 void CacheTriangulation( PROGRESS_REPORTER* aReporter = nullptr,
521 const std::vector<ZONE*>& aZones = {} );
522
531 {
532 return m_footprints.empty() ? nullptr : m_footprints.front();
533 }
534
538 void DeleteAllFootprints();
539
543 void DetachAllFootprints();
544
549 BOARD_ITEM* ResolveItem( const KIID& aID, bool aAllowNullptrReturn = false ) const;
550
551 void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
552
556 wxString ConvertCrossReferencesToKIIDs( const wxString& aSource ) const;
557 wxString ConvertKIIDsToCrossReferences( const wxString& aSource ) const;
558
563 std::shared_ptr<CONNECTIVITY_DATA> GetConnectivity() const { return m_connectivity; }
564
570 bool BuildConnectivity( PROGRESS_REPORTER* aReporter = nullptr );
571
575 void DeleteMARKERs();
576
577 void DeleteMARKERs( bool aWarningsAndErrors, bool aExclusions );
578
579 PROJECT* GetProject() const { return m_project; }
580
589 void SetProject( PROJECT* aProject, bool aReferenceOnly = false );
590
591 void ClearProject();
592
600 std::vector<PCB_MARKER*> ResolveDRCExclusions( bool aCreateMarkers );
601
605 void RecordDRCExclusions();
606
611
615 void ResetNetHighLight();
616
620 const std::set<int>& GetHighLightNetCodes() const
621 {
622 return m_highLight.m_netCodes;
623 }
624
631 void SetHighLightNet( int aNetCode, bool aMulti = false );
632
636 bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
637
645 void HighLightON( bool aValue = true );
646
651 {
652 HighLightON( false );
653 }
654
658 int GetCopperLayerCount() const;
659 void SetCopperLayerCount( int aCount );
660
661 int GetUserDefinedLayerCount() const;
662 void SetUserDefinedLayerCount( int aCount );
663
669
670 PCB_LAYER_ID FlipLayer( PCB_LAYER_ID aLayer ) const;
671
672 int LayerDepth( PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer ) const;
673
679 const LSET& GetEnabledLayers() const;
680 LSET GetLayerSet() const override { return GetEnabledLayers(); }
681
687 void SetEnabledLayers( const LSET& aLayerMask );
688 void SetLayerSet( const LSET& aLayerMask ) override { SetEnabledLayers( aLayerMask ); }
689
696 bool IsLayerEnabled( PCB_LAYER_ID aLayer ) const;
697
705 bool IsLayerVisible( PCB_LAYER_ID aLayer ) const;
706
712 const LSET& GetVisibleLayers() const;
713
720 void SetVisibleLayers( const LSET& aLayerMask );
721
722 // these 2 functions are not tidy at this time, since there are PCB_LAYER_IDs that
723 // are not stored in the bitmap.
724
732
739 void SetVisibleElements( const GAL_SET& aMask );
740
746 void SetVisibleAlls();
747
755 bool IsElementVisible( GAL_LAYER_ID aLayer ) const;
756
764 void SetElementVisibility( GAL_LAYER_ID aLayer, bool aNewState );
765
773 bool IsFootprintLayerVisible( PCB_LAYER_ID aLayer ) const;
774
779 void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings );
780
788 void InvalidateClearanceCache( const KIID& aUuid );
789
796
798
799 const PAGE_INFO& GetPageSettings() const { return m_paper; }
800 void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
801
803 void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; }
804
806 const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
807 void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
808
809 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
810
812 void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; }
813
818 void UpdateUserUnits( BOARD_ITEM* aItem, KIGFX::VIEW* aView );
819
840 bool GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, bool aInferOutlineIfNecessary,
841 OUTLINE_ERROR_HANDLER* aErrorHandler = nullptr,
842 bool aAllowUseArcsInPolygons = false, bool aIncludeNPTHAsOutlines = false );
843
853
867 KIGFX::RENDER_SETTINGS* aRenderSettings = nullptr ) const;
868
872 PCB_LAYER_ID GetLayerID( const wxString& aLayerName ) const;
873
880 const wxString GetLayerName( PCB_LAYER_ID aLayer ) const;
881
889 bool SetLayerName( PCB_LAYER_ID aLayer, const wxString& aLayerName );
890
901 static wxString GetStandardLayerName( PCB_LAYER_ID aLayerId )
902 {
903 // a BOARD's standard layer name is the PCB_LAYER_ID fixed name
904 return LayerName( aLayerId );
905 }
906
914 bool SetLayerDescr( PCB_LAYER_ID aIndex, const LAYER& aLayer );
915
919 bool IsFrontLayer( PCB_LAYER_ID aLayer ) const;
920
924 bool IsBackLayer( PCB_LAYER_ID aLayer ) const;
925
932 LAYER_T GetLayerType( PCB_LAYER_ID aLayer ) const;
933
941 bool SetLayerType( PCB_LAYER_ID aLayer, LAYER_T aLayerType );
942
947 unsigned GetNodesCount( int aNet = -1 ) const;
948
957 const std::vector<PAD*> GetPads() const;
958
960 {
961 m_NetInfo.buildListOfNets();
962 }
963
970 NETINFO_ITEM* FindNet( int aNetcode ) const;
971
978 NETINFO_ITEM* FindNet( const wxString& aNetname ) const;
979
989 int MatchDpSuffix( const wxString& aNetName, wxString& aComplementNet );
990
994 NETINFO_ITEM* DpCoupledNet( const NETINFO_ITEM* aNet );
995
997 {
998 return m_NetInfo;
999 }
1000
1002 {
1003 m_NetInfo.RemoveUnusedNets( aCommit );
1004 }
1005
1006#ifndef SWIG
1011 {
1012 return m_NetInfo.begin();
1013 }
1014
1019 {
1020 return m_NetInfo.end();
1021 }
1022#endif
1023
1027 unsigned GetNetCount() const
1028 {
1029 return m_NetInfo.GetNetCount();
1030 }
1031
1036
1041
1048 BOX2I ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
1049
1050 const BOX2I GetBoundingBox() const override
1051 {
1052 return ComputeBoundingBox( false );
1053 }
1054
1065 {
1066 return ComputeBoundingBox( true );
1067 }
1068
1069 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
1070
1082 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
1083 const std::vector<KICAD_T>& scanTypes ) override;
1084
1093 FOOTPRINT* FindFootprintByReference( const wxString& aReference ) const;
1094
1101 FOOTPRINT* FindFootprintByPath( const KIID_PATH& aPath ) const;
1102
1106 std::set<wxString> GetNetClassAssignmentCandidates() const;
1107
1115 void SynchronizeNetsAndNetClasses( bool aResetTrackAndViaSizes );
1116
1120 bool SynchronizeComponentClasses( const std::unordered_set<wxString>& aNewSheetPaths ) const;
1121
1125 void SynchronizeProperties();
1126
1131
1135 double Similarity( const BOARD_ITEM& aOther ) const override
1136 {
1137 return 1.0;
1138 }
1139
1140 bool operator==( const BOARD_ITEM& aOther ) const override;
1141
1142 wxString GetClass() const override
1143 {
1144 return wxT( "BOARD" );
1145 }
1146
1147#if defined(DEBUG)
1148 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
1149#endif
1150
1151
1152 /*************************/
1153 /* Copper Areas handling */
1154 /*************************/
1155
1166
1173 ZONE* GetArea( int index ) const
1174 {
1175 if( (unsigned) index < m_zones.size() )
1176 return m_zones[index];
1177
1178 return nullptr;
1179 }
1180
1184 std::list<ZONE*> GetZoneList( bool aIncludeZonesInFootprints = false ) const;
1185
1189 int GetAreaCount() const
1190 {
1191 return static_cast<int>( m_zones.size() );
1192 }
1193
1194 /* Functions used in test, merge and cut outlines */
1195
1208 ZONE* AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
1209 VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch );
1210
1218 bool TestZoneIntersection( ZONE* aZone1, ZONE* aZone2 );
1219
1227 PAD* GetPad( const VECTOR2I& aPosition, const LSET& aLayerMask ) const;
1228 PAD* GetPad( const VECTOR2I& aPosition ) const
1229 {
1230 return GetPad( aPosition, LSET().set() );
1231 }
1232
1240 PAD* GetPad( const PCB_TRACK* aTrace, ENDPOINT_T aEndPoint ) const;
1241
1256 PAD* GetPad( std::vector<PAD*>& aPadList, const VECTOR2I& aPosition, const LSET& aLayerMask ) const;
1257
1269 void GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetCode = -1 ) const;
1270
1278 std::tuple<int, double, double, double, double> GetTrackLength( const PCB_TRACK& aTrack ) const;
1279
1287 TRACKS TracksInNet( int aNetCode );
1288
1301 FOOTPRINT* GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveLayer,
1302 bool aVisibleOnly, bool aIgnoreLocked = false ) const;
1303
1309 int GetMaxClearanceValue() const;
1310
1316 void MapNets( BOARD* aDestBoard );
1317
1318 void SanitizeNetcodes();
1319
1328 void AddListener( BOARD_LISTENER* aListener );
1329
1334 void RemoveListener( BOARD_LISTENER* aListener );
1335
1339 void RemoveAllListeners();
1340
1345 void OnItemChanged( BOARD_ITEM* aItem );
1346
1351 void OnItemsChanged( std::vector<BOARD_ITEM*>& aItems );
1352
1357 void OnItemsCompositeUpdate( std::vector<BOARD_ITEM*>& aAddedItems,
1358 std::vector<BOARD_ITEM*>& aRemovedItems,
1359 std::vector<BOARD_ITEM*>& aChangedItems );
1360
1364 void OnRatsnestChanged();
1365
1372 wxString GroupsSanityCheck( bool repair = false );
1373
1379 wxString GroupsSanityCheckInternal( bool repair );
1380
1381 bool LegacyTeardrops() const { return m_legacyTeardrops; }
1382 void SetLegacyTeardrops( bool aFlag ) { m_legacyTeardrops = aFlag; }
1383
1384 EMBEDDED_FILES* GetEmbeddedFiles() override;
1385 const EMBEDDED_FILES* GetEmbeddedFiles() const;
1386
1388
1392 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
1393
1397 void EmbedFonts() override;
1398
1403
1408
1410
1419 void SaveToHistory( const wxString& aProjectPath, std::vector<wxString>& aFiles );
1420
1421 const std::unordered_map<KIID, BOARD_ITEM*>& GetItemByIdCache() const
1422 {
1423 return m_itemByIdCache;
1424 }
1425
1433 {
1434 m_itemByIdCache.insert( { aItem->m_Uuid, aItem } );
1435 }
1436
1443 void UncacheItemById( const KIID& aId )
1444 {
1445 m_itemByIdCache.erase( aId );
1446 }
1447
1448 // --------- Item order comparators ---------
1449
1451 {
1452 bool operator() ( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
1453 };
1454
1456 {
1457 bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
1458 };
1459
1460public:
1461 // ------------ Run-time caches -------------
1462 mutable std::shared_mutex m_CachesMutex;
1463 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsCourtyardCache;
1464 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsFCourtyardCache;
1465 std::unordered_map<PTR_PTR_CACHE_KEY, bool> m_IntersectsBCourtyardCache;
1466 std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_IntersectsAreaCache;
1467 std::unordered_map<PTR_PTR_LAYER_CACHE_KEY, bool> m_EnclosedByAreaCache;
1468 std::unordered_map< wxString, LSET > m_LayerExpressionCache;
1469 std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
1470 std::shared_ptr<DRC_RTREE> m_CopperItemRTreeCache;
1471 mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
1472 mutable std::optional<int> m_maxClearanceValue;
1473
1474 mutable std::unordered_map<const BOARD_ITEM*, wxString> m_ItemNetclassCache;
1475
1476 // Zone name lookup cache for DRC rule area functions like enclosedByArea/intersectsArea.
1477 // Maps zone names to vectors of matching zones to avoid O(n) zone iteration per lookup.
1478 mutable std::unordered_map<wxString, std::vector<ZONE*>> m_ZonesByNameCache;
1479
1480 // Deflated zone outline cache for DRC area checks. Caches the deflated outline for each zone
1481 // to avoid repeated expensive deflation operations during collidesWithArea calls.
1482 mutable std::unordered_map<const ZONE*, SHAPE_POLY_SET> m_DeflatedZoneOutlineCache;
1483
1484 // ------------ DRC caches -------------
1485 std::vector<ZONE*> m_DRCZones;
1486 std::vector<ZONE*> m_DRCCopperZones;
1489 ZONE* m_SolderMaskBridges; // A container to build bridges on solder mask layers
1490 std::map<ZONE*, std::map<PCB_LAYER_ID, ISOLATED_ISLANDS>> m_ZoneIsolatedIslandsMap;
1491
1492private:
1493 // The default copy constructor & operator= are inadequate,
1494 // either write one or do not use it at all
1495 BOARD( const BOARD& aOther ) = delete;
1496
1497 BOARD& operator=( const BOARD& aOther ) = delete;
1498
1499 template <typename Func, typename... Args>
1500 void InvokeListeners( Func&& aFunc, Args&&... args )
1501 {
1502 for( auto&& l : m_listeners )
1503 ( l->*aFunc )( std::forward<Args>( args )... );
1504 }
1505
1506 // Refresh user layer opposites.
1507 void recalcOpposites();
1508
1509 friend class PCB_EDIT_FRAME;
1510
1511private:
1514
1517 int m_timeStamp; // actually a modification counter
1518
1519 wxString m_fileName;
1520
1521 // These containers only have const accessors and must only be modified by Add()/Remove()
1522 MARKERS m_markers;
1523 DRAWINGS m_drawings;
1524 FOOTPRINTS m_footprints;
1526 GROUPS m_groups;
1528 GENERATORS m_generators;
1530 PCB_POINTS m_points;
1531
1532 // Cache for fast access to items in the containers above by KIID, including children
1533 std::unordered_map<KIID, BOARD_ITEM*> m_itemByIdCache;
1534
1535 std::map<int, LAYER> m_layers; // layer data
1536
1537 HIGH_LIGHT_INFO m_highLight; // current high light data
1538 HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data
1539
1540 int m_fileFormatVersionAtLoad; // the version loaded from the file
1541 wxString m_generator; // the generator tag from the file
1542
1543 std::map<wxString, wxString> m_properties;
1544 std::shared_ptr<CONNECTIVITY_DATA> m_connectivity;
1545
1547 TITLE_BLOCK m_titles; // text in lower right of screen and plots
1549 PROJECT* m_project; // project this board is a part of
1551
1552 // Variant system
1553 wxString m_currentVariant; // Currently active variant (empty = default)
1554 std::vector<wxString> m_variantNames; // All variant names in the board
1555 std::map<wxString, wxString> m_variantDescriptions; // Descriptions for each variant
1556
1567 std::unique_ptr<BOARD_DESIGN_SETTINGS> m_designSettings;
1568
1573 bool m_legacyTeardrops = false;
1574
1575 NETINFO_LIST m_NetInfo; // net info list (name, design constraints...
1576
1577 std::vector<BOARD_LISTENER*> m_listeners;
1578
1580
1581 // Used for dummy boards, such as a footprint holder, where we don't want to make a copy
1582 // of all the parent's embedded data.
1584
1585 std::unique_ptr<COMPONENT_CLASS_MANAGER> m_componentClassManager;
1586 std::unique_ptr<LENGTH_DELAY_CALCULATION> m_lengthDelayCalc;
1587};
1588
1589
1590#endif // CLASS_BOARD_H_
int index
BOARD_USE
Flags to specify how the board is being used.
Definition board.h:312
@ FPHOLDER
Definition board.h:314
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
Definition board.h:185
@ LT_POWER
Definition board.h:188
@ LT_FRONT
Definition board.h:192
@ LT_MIXED
Definition board.h:189
@ LT_BACK
Definition board.h:193
@ LT_UNDEFINED
Definition board.h:186
@ LT_JUMPER
Definition board.h:190
@ LT_AUX
Definition board.h:191
@ LT_SIGNAL
Definition board.h:187
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
Definition board.h:306
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:83
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:85
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
Definition board.h:291
virtual void OnBoardRatsnestChanged(BOARD &aBoard)
Definition board.h:295
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
Definition board.h:288
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition board.h:292
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition board.h:289
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem)
Definition board.h:287
virtual void OnBoardHighlightNetChanged(BOARD &aBoard)
Definition board.h:294
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
Definition board.h:290
virtual void OnBoardCompositeUpdate(BOARD &aBoard, std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems)
Definition board.h:296
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
Definition board.h:293
virtual ~BOARD_LISTENER()
Definition board.h:286
Manage layers needed to make a physical board.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
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:2211
ZONE * m_SolderMaskBridges
Definition board.h:1489
void GetContextualTextVars(wxArrayString *aVars) const
Definition board.cpp:476
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:1073
BOARD_STACKUP GetStackupOrDefault() const
Definition board.cpp:2891
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition board.h:803
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_EnclosedByAreaCache
Definition board.h:1467
std::map< ZONE *, std::map< PCB_LAYER_ID, ISOLATED_ISLANDS > > m_ZoneIsolatedIslandsMap
Definition board.h:1490
PCB_LAYER_ID GetCopperLayerStackMaxId() const
Definition board.cpp:944
GENERATORS m_generators
Definition board.h:1528
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:3225
const NETINFO_LIST & GetNetInfo() const
Definition board.h:996
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
Definition board.h:436
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition board.h:352
PAD * GetPad(const VECTOR2I &aPosition, const LSET &aLayerMask) const
Find a pad aPosition on aLayer.
Definition board.cpp:2741
int GetUserDefinedLayerCount() const
Definition board.cpp:933
void recalcOpposites()
Definition board.cpp:854
void SetPosition(const VECTOR2I &aPos) override
Definition board.cpp:611
std::map< wxString, wxString > m_properties
Definition board.h:1543
std::unordered_map< const BOARD_ITEM *, wxString > m_ItemNetclassCache
Definition board.h:1474
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition board.cpp:3077
int m_fileFormatVersionAtLoad
Definition board.h:1540
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
Definition board.cpp:2429
void SetCurrentVariant(const wxString &aVariant)
Definition board.cpp:2502
std::vector< ZONE * > m_DRCCopperZones
Definition board.h:1486
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:1001
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition board.h:341
void SetVariantNames(const std::vector< wxString > &aNames)
Definition board.h:408
const std::vector< wxString > & GetVariantNames() const
Definition board.h:407
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1224
const std::set< int > & GetHighLightNetCodes() const
Definition board.h:620
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:3172
bool m_legacyTeardrops
Teardrops in 7.0 were applied as a post-processing step (rather than from pad and via properties).
Definition board.h:1573
TITLE_BLOCK m_titles
Definition board.h:1547
GAL_SET m_LegacyVisibleItems
Definition board.h:433
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
Definition board.h:334
ZONE * GetArea(int index) const
Return the Zone at a given index.
Definition board.h:1173
std::vector< wxString > m_variantNames
Definition board.h:1554
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition board.h:1064
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition board.h:1050
LENGTH_DELAY_CALCULATION * GetLengthCalculation() const
Returns the track length calculator.
Definition board.h:1402
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
Definition board.cpp:2648
void BuildListOfNets()
Definition board.h:959
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:1196
const GENERATORS & Generators() const
Definition board.h:369
void SetFileName(const wxString &aFileName)
Definition board.h:357
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition board.h:901
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
Definition board.cpp:3146
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition board.h:680
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:1035
int m_outlinesChainingEpsilon
the max distance between 2 end point to see them connected when building the board outlines
Definition board.h:1513
void UncacheItemById(const KIID &aId)
Remove an item from the item-by-id cache.
Definition board.h:1443
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:2902
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
Definition board.cpp:2468
BOARD_USE m_boardUse
What is this board being used for.
Definition board.h:1516
PCB_BOARD_OUTLINE * BoardOutline()
Definition board.h:371
PAGE_INFO m_paper
Definition board.h:1546
void RemoveAllListeners()
Remove all listeners.
Definition board.cpp:3219
FOOTPRINTS m_footprints
Definition board.h:1524
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:1567
friend class PCB_EDIT_FRAME
Definition board.h:1509
void SetEmbeddedFilesDelegate(EMBEDDED_FILES *aDelegate)
Definition board.h:1387
const PCB_POINTS & Points() const
Definition board.h:377
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:3437
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:3200
const PAGE_INFO & GetPageSettings() const
Definition board.h:799
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition board.cpp:1698
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition board.h:401
bool IsBackLayer(PCB_LAYER_ID aLayer) const
Definition board.cpp:779
BOARD(const BOARD &aOther)=delete
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
Definition board.cpp:1029
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition board.cpp:3259
HIGH_LIGHT_INFO m_highLight
Definition board.h:1537
std::map< wxString, wxString > m_variantDescriptions
Definition board.h:1555
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Return the type of the copper layer given by aLayer.
Definition board.cpp:702
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition board.cpp:2362
EDA_UNITS m_userUnits
Definition board.h:1550
void UpdateBoardOutline()
Definition board.cpp:3623
const ZONES & Zones() const
Definition board.h:367
void BulkRemoveStaleTeardrops(BOARD_COMMIT &aCommit)
Remove all teardrop zones with the STRUCT_DELETED flag set.
Definition board.cpp:1366
void DeleteVariant(const wxString &aVariantName)
Definition board.cpp:2536
void InvokeListeners(Func &&aFunc, Args &&... args)
Definition board.h:1500
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings)
Definition board.cpp:1090
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:983
void SanitizeNetcodes()
Definition board.cpp:3190
void InitializeClearanceCache()
Initialize the clearance cache for all board items.
Definition board.cpp:1103
EMBEDDED_FILES * m_embeddedFilesDelegate
Definition board.h:1583
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:3011
bool IsFrontLayer(PCB_LAYER_ID aLayer) const
Definition board.cpp:773
const GROUPS & Groups() const
The groups must maintain the following invariants.
Definition board.h:396
~BOARD()
Definition board.cpp:157
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:192
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:995
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Definition board.cpp:785
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
Definition board.cpp:331
DRAWINGS m_drawings
Definition board.h:1523
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:3237
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
Definition board.cpp:2707
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:2668
EDA_UNITS GetUserUnits()
Definition board.h:811
void ResetNetHighLight()
Reset all high light data to the init state.
Definition board.cpp:3250
PCB_PLOT_PARAMS m_plotOptions
Definition board.h:1548
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
Definition board.cpp:748
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false) const
Definition board.cpp:2991
bool ResolveTextVar(wxString *token, int aDepth) const
Definition board.cpp:503
const MARKERS & Markers() const
Definition board.h:375
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition board.h:530
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
Definition board.cpp:914
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition board.cpp:3132
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition board.cpp:617
TITLE_BLOCK & GetTitleBlock()
Definition board.h:805
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition board.cpp:2107
void FixupEmbeddedData()
After loading a file from disk, the footprints do not yet contain the full data for their embedded fi...
Definition board.cpp:1203
int GetMaxClearanceValue() const
Returns the maximum clearance value for any object on the board.
Definition board.cpp:1110
ZONES m_zones
Definition board.h:1527
void InvalidateClearanceCache(const KIID &aUuid)
Invalidate the clearance cache for a specific item.
Definition board.cpp:1096
PAD * GetPad(const VECTOR2I &aPosition) const
Definition board.h:1228
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
Definition board.cpp:710
HIGH_LIGHT_INFO m_highLightPrevious
Definition board.h:1538
const VECTOR2I GetFocusPosition() const override
Similar to GetPosition() but allows items to return their visual center rather than their anchor.
Definition board.h:447
void HighLightOFF()
Disable net highlight.
Definition board.h:650
NETINFO_LIST m_NetInfo
Definition board.h:1575
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition board.h:432
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
Definition board.cpp:1018
void SetOutlinesChainingEpsilon(int aValue)
Definition board.h:852
bool HasVariant(const wxString &aVariantName) const
Definition board.cpp:2519
NETINFO_LIST::iterator EndNets() const
Definition board.h:1018
void AddVariant(const wxString &aVariantName)
Definition board.cpp:2525
int GetCopperLayerCount() const
Definition board.cpp:921
int m_timeStamp
Definition board.h:1517
std::vector< BOARD_LISTENER * > m_listeners
Definition board.h:1577
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:1612
const std::map< wxString, wxString > & GetProperties() const
Definition board.h:400
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsCourtyardCache
Definition board.h:1463
void IncrementTimeStamp()
Definition board.cpp:260
int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet)
Fetch the coupled netname for a given net.
Definition board.cpp:2381
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsFCourtyardCache
Definition board.h:1464
PCB_POINTS m_points
Definition board.h:1530
std::unique_ptr< LENGTH_DELAY_CALCULATION > m_lengthDelayCalc
Definition board.h:1586
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
Definition board.h:1001
const FOOTPRINTS & Footprints() const
Definition board.h:363
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
Definition board.h:1544
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
Get the list of all outline fonts used in the board.
Definition board.cpp:3095
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:1485
const BOARD_ITEM_SET GetItemSet()
Definition board.cpp:3539
const TRACKS & Tracks() const
Definition board.h:361
int m_DRCMaxPhysicalClearance
Definition board.h:1488
const PCB_BOARD_OUTLINE * BoardOutline() const
Definition board.h:372
FOOTPRINT * FindFootprintByPath(const KIID_PATH &aPath) const
Search for a FOOTPRINT within this board with the given path.
Definition board.cpp:2456
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:1360
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition board.h:800
std::unordered_map< wxString, LSET > m_LayerExpressionCache
Definition board.h:1468
bool m_embedFonts
Definition board.h:1579
wxString GroupsSanityCheckInternal(bool repair)
Definition board.cpp:3296
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
Definition board.cpp:3244
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition board.cpp:1937
wxString GetClass() const override
Return the class name.
Definition board.h:1142
std::unique_ptr< COMPONENT_CLASS_MANAGER > m_componentClassManager
Definition board.h:1585
NETINFO_LIST::iterator BeginNets() const
Definition board.h:1010
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:3036
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
Definition board.h:440
void SetCopperLayerCount(int aCount)
Definition board.cpp:927
std::unordered_map< const ZONE *, BOX2I > m_ZoneBBoxCache
Definition board.h:1471
std::unordered_map< const ZONE *, SHAPE_POLY_SET > m_DeflatedZoneOutlineCache
Definition board.h:1482
wxString m_generator
Definition board.h:1541
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsBCourtyardCache
Definition board.h:1465
TRACKS TracksInNet(int aNetCode)
Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
Definition board.cpp:680
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition board.cpp:202
PROJECT * m_project
Definition board.h:1549
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:2927
bool HasItemsOnLayer(PCB_LAYER_ID aLayer)
Definition board.cpp:1566
const wxString & GetFileName() const
Definition board.h:359
bool operator==(const BOARD_ITEM &aOther) const override
Definition board.cpp:3555
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition board.cpp:388
int GetPadWithCastellatedAttrCount()
Definition board.cpp:3652
wxString GetVariantDescription(const wxString &aVariantName) const
Definition board.cpp:2612
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition board.cpp:2444
unsigned GetNodesCount(int aNet=-1) const
Definition board.cpp:2090
bool IsHighLightNetON() const
Definition board.h:636
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition board.cpp:1895
int GetFileFormatVersionAtLoad() const
Definition board.h:456
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
Definition board.cpp:1041
std::shared_ptr< DRC_RTREE > m_CopperItemRTreeCache
Definition board.h:1470
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
Definition board.cpp:804
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition board.h:802
BOARD & operator=(const BOARD &aOther)=delete
void CacheItemById(BOARD_ITEM *aItem)
Add an item to the item-by-id cache.
Definition board.h:1432
wxString m_fileName
Definition board.h:1519
const wxString & GetGenerator() const
Adds an item to the container.
Definition board.h:459
int GetAreaCount() const
Definition board.h:1189
void DetachAllFootprints()
Remove all footprints without deleting.
Definition board.cpp:1765
void SetLegacyTeardrops(bool aFlag)
Definition board.h:1382
std::map< int, LAYER > m_layers
Definition board.h:1535
wxString GetCurrentVariant() const
Definition board.h:404
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
Definition board.cpp:638
int GetOutlinesChainingEpsilon()
Definition board.h:851
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:2876
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:975
int m_DRCMaxClearance
Definition board.h:1487
void ClearProject()
Definition board.cpp:240
void SetLayerSet(const LSET &aLayerMask) override
Definition board.h:688
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition board.h:1469
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:1354
wxString m_currentVariant
Definition board.h:1553
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
Definition board.cpp:957
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition board.cpp:1753
PROJECT * GetProject() const
Definition board.h:579
bool IsEmpty() const
Definition board.cpp:599
int GetPadWithPressFitAttrCount()
Definition board.cpp:3634
bool LegacyTeardrops() const
Definition board.h:1381
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:2173
const TITLE_BLOCK & GetTitleBlock() const
Definition board.h:806
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
Definition board.cpp:3282
void RenameVariant(const wxString &aOldName, const wxString &aNewName)
Definition board.cpp:2564
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1084
std::vector< ZONE * > m_DRCZones
Definition board.h:1485
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:969
void SetGenerator(const wxString &aGenerator)
Definition board.h:458
BOARD()
Definition board.cpp:85
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition board.cpp:300
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition board.cpp:2017
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
Definition board.cpp:2482
std::unordered_map< KIID, BOARD_ITEM * > m_itemByIdCache
Definition board.h:1533
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
Definition board.cpp:3207
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
Definition board.h:1407
std::shared_mutex m_CachesMutex
Definition board.h:1462
unsigned GetNetCount() const
Definition board.h:1027
const std::unordered_map< KIID, BOARD_ITEM * > & GetItemByIdCache() const
Definition board.h:1421
bool SynchronizeComponentClasses(const std::unordered_set< wxString > &aNewSheetPaths) const
Copy component class / component class generator information from the project settings.
Definition board.cpp:2698
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1720
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition board.cpp:1383
std::unordered_map< wxString, std::vector< ZONE * > > m_ZonesByNameCache
Definition board.h:1478
GROUPS m_groups
Definition board.h:1526
PROJECT::ELEM ProjectElementType() override
Definition board.h:1409
MARKERS m_markers
Definition board.h:1522
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_IntersectsAreaCache
Definition board.h:1466
std::optional< int > m_maxClearanceValue
Definition board.h:1472
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition board.cpp:3272
void SetEnabledLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:989
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition board.h:807
void SynchronizeTuningProfileProperties()
Ensure that all time domain properties providers are in sync with current settings.
Definition board.cpp:2662
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
TRACKS m_tracks
Definition board.h:1525
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Definition board.cpp:1777
bool m_LegacyCopperEdgeClearanceLoaded
Definition board.h:437
int GetTimeStamp() const
Definition board.h:345
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:3231
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:563
VECTOR2I GetPosition() const override
Definition board.cpp:605
void SetVariantDescription(const wxString &aVariantName, const wxString &aDescription)
Definition board.cpp:2631
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
Definition board.cpp:1142
static bool ClassOf(const EDA_ITEM *aItem)
Definition board.h:324
void SetUserUnits(EDA_UNITS aUnits)
Definition board.h:812
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
Definition board.cpp:1008
void SaveToHistory(const wxString &aProjectPath, std::vector< wxString > &aFiles)
Save board file to the .history directory.
Definition board.cpp:3670
void EmbedFonts() override
Finds all fonts used in the board and embeds them in the file if permissions allow.
Definition board.cpp:3122
double Similarity(const BOARD_ITEM &aOther) const override
Return the Similarity.
Definition board.h:1135
PCB_BOARD_OUTLINE * m_boardOutline
Definition board.h:1529
void SetUserDefinedLayerCount(int aCount)
Definition board.cpp:939
const DRAWINGS & Drawings() const
Definition board.h:365
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition board.cpp:1692
void SetFileFormatVersionAtLoad(int aVersion)
Definition board.h:455
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:521
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:39
EMBEDDED_FILES()=default
Helper for storing and iterating over GAL_LAYER_IDs.
Definition layer_ids.h:403
void Clear()
Definition board.h:261
friend class BOARD
Definition board.h:273
std::set< int > m_netCodes
Definition board.h:258
bool m_highLightOn
Definition board.h:259
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:66
Definition kiid.h:49
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:54
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Definition netinfo.h:273
Container for NETINFO_ITEM elements, which are the nets.
Definition netinfo.h:212
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:92
Container for project specific data.
Definition project.h:65
ELEM
The set of #_ELEMs that a PROJECT can hold.
Definition project.h:71
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
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
The common library.
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:50
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
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
ENDPOINT_T
Definition pcb_track.h:60
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition board.cpp:3386
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition board.cpp:3365
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:134
bool has_error
Definition board.h:140
LSET layers
Definition board.h:139
int m_opposite
Similar layer on opposite side of the board, if any.
Definition board.h:233
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
Definition board.cpp:833
void clear()
Definition board.h:207
LAYER_T m_type
The type of the layer.
Definition board.h:230
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Definition board.cpp:817
LAYER()
Definition board.h:202
wxString m_name
The canonical name of the layer.
Definition board.h:228
wxString m_userName
The user defined name of the layer.
Definition board.h:229
bool m_visible
Definition board.h:231
int m_number
The layer ID.
Definition board.h:232
BOARD_ITEM * A
Definition board.h:106
bool operator==(const PTR_LAYER_CACHE_KEY &other) const
Definition board.h:109
PCB_LAYER_ID Layer
Definition board.h:107
BOARD_ITEM * A
Definition board.h:95
BOARD_ITEM * B
Definition board.h:96
bool operator==(const PTR_PTR_CACHE_KEY &other) const
Definition board.h:98
bool operator==(const PTR_PTR_LAYER_CACHE_KEY &other) const
Definition board.h:121
BOARD_ITEM * B
Definition board.h:118
BOARD_ITEM * A
Definition board.h:117
PCB_LAYER_ID Layer
Definition board.h:119
std::size_t operator()(const PTR_LAYER_CACHE_KEY &k) const
Definition board.h:160
std::size_t operator()(const PTR_PTR_CACHE_KEY &k) const
Definition board.h:149
std::size_t operator()(const PTR_PTR_LAYER_CACHE_KEY &k) const
Definition board.h:171
@ PCB_T
Definition typeinfo.h:82
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:88
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:91
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:111
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:108
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:99
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:86
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition typeinfo.h:110
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:96
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.