71 m_LegacyDesignSettingsLoaded( false ),
72 m_LegacyCopperEdgeClearanceLoaded( false ),
73 m_LegacyNetclassesLoaded( false ),
96 int infinity = ( std::numeric_limits<int>::max() / 2 ) -
pcbIUScale.
mmToIU( 1 );
108 bds.
m_NetSettings->m_DefaultNetClass->SetDescription(
_(
"This is the default net class." ) );
127 item->SetParentGroup(
nullptr );
179 if( aProject && !aReferenceOnly )
196 std::shared_ptr<NET_SETTINGS>& projectSettings =
project.NetSettings();
198 projectSettings->m_DefaultNetClass = legacySettings->m_DefaultNetClass;
199 projectSettings->m_NetClasses = legacySettings->m_NetClasses;
200 projectSettings->m_NetClassPatternAssignments =
201 std::move( legacySettings->m_NetClassPatternAssignments );
221 project.m_BoardSettings =
nullptr;
272 std::set<std::pair<KIID, KIID>> m_ratsnestExclusions;
278 const std::shared_ptr<RC_ITEM>& rcItem = marker->GetRCItem();
279 m_ratsnestExclusions.emplace( rcItem->GetMainItemID(), rcItem->GetAuxItemID() );
280 m_ratsnestExclusions.emplace( rcItem->GetAuxItemID(), rcItem->GetMainItemID() );
289 std::pair<KIID, KIID> ids = { aEdge.GetSourceNode()->Parent()->m_Uuid,
290 aEdge.GetTargetNode()->Parent()->m_Uuid };
292 aEdge.
SetVisible( m_ratsnestExclusions.count( ids ) == 0 );
308 marker->SetExcluded(
true );
313 std::vector<PCB_MARKER*> newMarkers;
322 newMarkers.push_back( marker );
334 if( token->Contains(
':' ) )
337 wxString ref = token->BeforeFirst(
':', &remainder );
352 wxString var = *token;
379 wxLogWarning( wxT(
"This should not be called on the BOARD object") );
386 [&] (
EDA_ITEM* item,
void* testData )
393 brdItem->
Move( aMoveVector );
441 if (
m_layers[ layer ].m_name == aLayerName ||
m_layers[ layer ].m_userName == aLayerName )
464 if( !
m_layers[aLayer].m_userName.IsEmpty() )
474 wxCHECK( !aLayerName.IsEmpty(),
false );
477 if( aLayerName.Find( wxChar(
'"' ) ) != wxNOT_FOUND )
532 if( strcmp( aType,
"signal" ) == 0 )
534 else if( strcmp( aType,
"power" ) == 0 )
536 else if( strcmp( aType,
"mixed" ) == 0 )
538 else if( strcmp( aType,
"jumper" ) == 0 )
559 if( aStartLayer > aEndLayer )
560 std::swap( aStartLayer, aEndLayer );
562 if( aEndLayer ==
B_Cu )
565 return aEndLayer - aStartLayer;
613 for(
size_t i = 0; i < aSet.size(); i++ )
654 track->SetLocalRatsnestVisible( isEnabled );
658 for(
PAD*
pad : footprint->Pads() )
659 pad->SetLocalRatsnestVisible( isEnabled );
663 zone->SetLocalRatsnestVisible( isEnabled );
680 default: wxFAIL_MSG( wxT(
"BOARD::IsModuleLayerVisible(): bad layer" ) );
return true;
706 std::vector<ZONE*> zones = aZones;
715 aReporter->
Report(
_(
"Tessellating copper zones..." ) );
718 std::vector<std::future<size_t>> returns;
720 returns.reserve( zones.size() );
722 auto cache_zones = [aReporter](
ZONE* aZone ) ->
size_t
727 aZone->CacheTriangulation();
735 for(
ZONE* zone : zones )
736 returns.emplace_back(
tp.submit( cache_zones, zone ) );
739 for(
const std::future<size_t>& ret : returns )
741 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
743 while( status != std::future_status::ready )
748 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
756 if( aBoardItem ==
nullptr )
758 wxFAIL_MSG( wxT(
"BOARD::Add() param error: aBoardItem nullptr" ) );
762 switch( aBoardItem->
Type() )
790 wxFAIL_MSG( wxT(
"BOARD::Add() Cannot place Track on non-copper layer" ) );
830 msg.Printf( wxT(
"BOARD::Add() needs work: BOARD_ITEM type (%d) not handled" ),
831 aBoardItem->
Type() );
841 if( !aSkipConnectivity )
866 wxASSERT( aBoardItem );
868 switch( aBoardItem->
Type() )
877 for(
PAD*
pad : fp->Pads() )
879 if(
pad->GetNet() == item )
880 pad->SetNet( unconnected );
886 if( zone->GetNet() == item )
887 zone->SetNet( unconnected );
892 if( track->GetNet() == item )
893 track->SetNet( unconnected );
937 wxFAIL_MSG( wxT(
"BOARD::Remove() needs more ::Type() support" ) );
984 remaining.push_back( marker );
1008 if( track->m_Uuid == aID )
1014 if( footprint->m_Uuid == aID )
1017 for(
PAD*
pad : footprint->Pads() )
1019 if(
pad->m_Uuid == aID )
1023 if( footprint->Reference().m_Uuid == aID )
1024 return &footprint->Reference();
1026 if( footprint->Value().m_Uuid == aID )
1027 return &footprint->Value();
1029 for(
BOARD_ITEM* drawing : footprint->GraphicalItems() )
1031 if( drawing->m_Uuid == aID )
1037 if( zone->m_Uuid == aID )
1043 if(
group->m_Uuid == aID )
1050 if( zone->m_Uuid == aID )
1056 if( drawing->m_Uuid == aID )
1062 if( marker->m_Uuid == aID )
1068 if(
group->m_Uuid == aID )
1073 return const_cast<BOARD*
>( this );
1086 aMap[ track->m_Uuid ] = track;
1090 aMap[ footprint->m_Uuid ] = footprint;
1092 for(
PAD*
pad : footprint->Pads() )
1093 aMap[
pad->m_Uuid ] =
pad;
1095 aMap[ footprint->Reference().m_Uuid ] = &footprint->Reference();
1096 aMap[ footprint->Value().m_Uuid ] = &footprint->Value();
1098 for(
BOARD_ITEM* drawing : footprint->GraphicalItems() )
1099 aMap[ drawing->m_Uuid ] = drawing;
1103 aMap[ zone->m_Uuid ] = zone;
1106 aMap[ drawing->m_Uuid ] = drawing;
1109 aMap[ marker->m_Uuid ] = marker;
1119 size_t sourceLen = aSource.length();
1121 for(
size_t i = 0; i < sourceLen; ++i )
1123 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
1126 bool isCrossRef =
false;
1128 for( i = i + 2; i < sourceLen; ++i )
1130 if( aSource[i] ==
'}' )
1133 if( aSource[i] ==
':' )
1136 token.append( aSource[i] );
1142 wxString ref = token.BeforeFirst(
':', &remainder );
1146 if( footprint->GetReference().CmpNoCase( ref ) == 0 )
1148 wxString
test( remainder );
1150 if( footprint->ResolveTextVar( &
test ) )
1151 token = footprint->m_Uuid.AsString() + wxT(
":" ) + remainder;
1158 newbuf.append( wxT(
"${" ) + token + wxT(
"}" ) );
1162 newbuf.append( aSource[i] );
1173 size_t sourceLen = aSource.length();
1175 for(
size_t i = 0; i < sourceLen; ++i )
1177 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
1180 bool isCrossRef =
false;
1182 for( i = i + 2; i < sourceLen; ++i )
1184 if( aSource[i] ==
'}' )
1187 if( aSource[i] ==
':' )
1190 token.append( aSource[i] );
1196 wxString ref = token.BeforeFirst(
':', &remainder );
1201 token =
static_cast<FOOTPRINT*
>( refItem )->GetReference() + wxT(
":" )
1206 newbuf.append( wxT(
"${" ) + token + wxT(
"}" ) );
1210 newbuf.append( aSource[i] );
1220 unsigned retval = 0;
1224 for(
PAD*
pad : footprint->Pads() )
1226 if( ( aNet == -1 &&
pad->GetNetCode() > 0 ) || aNet ==
pad->GetNetCode() )
1242 if( aBoardEdgesOnly )
1251 if( ( item->GetLayerSet() & visible ).any() )
1252 bbox.
Merge( item->GetBoundingBox() );
1258 if( !( footprint->GetLayerSet() & visible ).any() )
1261 if( aBoardEdgesOnly )
1263 for(
const BOARD_ITEM* edge : footprint->GraphicalItems() )
1266 bbox.
Merge( edge->GetBoundingBox() );
1271 bbox.
Merge( footprint->GetBoundingBox(
true, showInvisibleText ) );
1275 if( !aBoardEdgesOnly )
1280 if( ( track->GetLayerSet() & visible ).any() )
1281 bbox.
Merge( track->GetBoundingBox() );
1287 if( ( aZone->GetLayerSet() & visible ).any() )
1288 bbox.
Merge( aZone->GetBoundingBox() );
1300 int trackSegmentCount = 0;
1301 std::set<int> netCodes;
1309 trackSegmentCount++;
1311 if( item->GetNetCode() > 0 )
1312 netCodes.insert( item->GetNetCode() );
1317 for(
PAD*
pad : footprint->Pads() )
1321 if(
pad->GetNetCode() > 0 )
1322 netCodes.insert(
pad->GetNetCode() );
1328 aList.emplace_back(
_(
"Track Segments" ),
wxString::Format( wxT(
"%d" ), trackSegmentCount ) );
1329 aList.emplace_back(
_(
"Nets" ),
wxString::Format( wxT(
"%d" ), (
int) netCodes.size() ) );
1330 aList.emplace_back(
_(
"Unrouted" ),
wxString::Format( wxT(
"%d" ), unconnected ) );
1335 const std::vector<KICAD_T>& scanTypes )
1337#if 0 && defined(DEBUG)
1338 std::cout <<
GetClass().mb_str() <<
' ';
1341 bool footprintsScanned =
false;
1342 bool drawingsScanned =
false;
1343 bool tracksScanned =
false;
1345 for(
KICAD_T scanType : scanTypes )
1372 if( !footprintsScanned )
1374 if( IterateForward<FOOTPRINT*>(
m_footprints, inspector, testData, scanTypes )
1380 footprintsScanned =
true;
1395 if( !drawingsScanned )
1397 if( IterateForward<BOARD_ITEM*>(
m_drawings, inspector, testData, scanTypes )
1403 drawingsScanned =
true;
1411 if( !tracksScanned )
1413 if( IterateForward<PCB_TRACK*>(
m_tracks, inspector, testData, scanTypes )
1419 tracksScanned =
true;
1443 if( IterateForward<PCB_GROUP*>(
m_groups, inspector, testData, { scanType } )
1485 if( aReference == footprint->GetReference() )
1497 if( footprint->GetPath() == aPath )
1507 std::set<wxString> names;
1511 if( !net->GetNetname().IsEmpty() )
1512 names.insert( net->GetNetname() );
1534 std::shared_ptr<NETCLASS>& defaultNetClass = bds.
m_NetSettings->m_DefaultNetClass;
1537 net->SetNetClass( bds.
m_NetSettings->GetEffectiveNetClass( net->GetNetname() ) );
1539 if( aResetTrackAndViaSizes )
1558 int error_count = 0;
1562 if( !zone->IsOnCopperLayer() )
1568 if( zone->GetNetCode() != 0 )
1581 zone->SetNetCode( -1 );
1592 if( !aLayerSet.any() )
1599 if( footprint->HitTest( aPosition ) )
1600 pad = footprint->GetPad( aPosition, aLayerSet );
1616 return GetPad( aPosition, lset );
1624 for(
PAD*
pad : footprint->Pads() )
1626 if(
pad->GetPosition() != aPosition )
1630 if( (
pad->GetLayerSet() & aLayerSet ).any() )
1643 int idxmax = aPadList.size() - 1;
1645 int delta = aPadList.size();
1658 PAD*
pad = aPadList[idx];
1660 if(
pad->GetPosition() == aPosition )
1663 if( ( aLayerSet &
pad->GetLayerSet() ).any() )
1670 for(
int ii = idx+1; ii <= idxmax; ii++ )
1674 if(
pad->GetPosition() != aPosition )
1677 if( ( aLayerSet &
pad->GetLayerSet() ).any() )
1681 for(
int ii = idx - 1 ;ii >=0; ii-- )
1685 if(
pad->GetPosition() != aPosition )
1688 if( ( aLayerSet &
pad->GetLayerSet() ).any() )
1696 if(
pad->GetPosition().x == aPosition.
x )
1698 if(
pad->GetPosition().y < aPosition.
y )
1713 else if(
pad->GetPosition().x < aPosition.
x )
1751 for(
PAD*
pad : footprint->Pads( ) )
1753 if( aNetCode < 0 || pad->GetNetCode() == aNetCode )
1754 aVector.push_back(
pad );
1765 double length = 0.0;
1766 double package_length = 0.0;
1774 { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T } ) )
1780 if( track->Type() ==
PCB_VIA_T && useHeight )
1790 length += track->GetLength();
1795 SEG trackSeg( track->GetStart(), track->GetEnd() );
1796 double segLen = trackSeg.
Length();
1797 double segInPadLen = 0;
1799 for(
auto pad_it : connectivity->GetConnectedPads( item ) )
1803 bool hitStart =
pad->HitTest( track->GetStart(), track->GetWidth() / 2 );
1804 bool hitEnd =
pad->HitTest( track->GetEnd(), track->GetWidth() / 2 );
1806 if( hitStart && hitEnd )
1811 else if( hitStart || hitEnd )
1816 if(
pad->GetEffectivePolygon()->Collide( trackSeg, 0,
nullptr, &loc ) )
1824 segLen = trackSeg.
Length();
1833 length += segLen + segInPadLen;
1835 else if(
PAD*
pad = dyn_cast<PAD*>( item ) )
1837 package_length +=
pad->GetPadToDieLength();
1841 return std::make_tuple( count, length, package_length );
1846 bool aVisibleOnly,
bool aIgnoreLocked )
const
1850 int min_dim = 0x7FFFFFFF;
1851 int alt_min_dim = 0x7FFFFFFF;
1852 bool current_layer_back =
IsBackLayer( aActiveLayer );
1857 if( !candidate->HitTest( aPosition ) )
1861 if( aIgnoreLocked && candidate->IsLocked() )
1869 BOX2I bb = candidate->GetBoundingBox(
false,
false );
1875 int dist = ( aPosition.
x - offx ) * ( aPosition.
x - offx ) +
1876 ( aPosition.
y - offy ) * ( aPosition.
y - offy );
1880 if( dist <= min_dim )
1883 footprint = candidate;
1889 if( dist <= alt_min_dim )
1892 alt_footprint = candidate;
1903 return alt_footprint;
1911 std::list<ZONE*> zones;
1914 zones.push_back( zone );
1916 if( aIncludeZonesInFootprints )
1920 for(
FP_ZONE* zone : footprint->Zones() )
1921 zones.push_back( zone );
1937 m_zones.push_back( new_area );
1960 chainingEpsilon, aErrorHandler );
1971 std::vector<PAD*> allPads;
1975 for(
PAD*
pad : footprint->Pads() )
1976 allPads.push_back(
pad );
1985 std::vector<BOARD_CONNECTED_ITEM*> items;
1988 items.push_back( track );
1992 for(
PAD*
pad : footprint->Pads() )
1993 items.push_back(
pad );
1997 items.push_back( zone );
2010 item->SetNet( netInfo );
2021 if(
FindNet( item->GetNetCode() ) ==
nullptr )
2103 return wxEmptyString;
2122 std::unordered_set<PCB_GROUP*> knownCycleFreeGroups;
2124 std::unordered_set<PCB_GROUP*> currentChainGroups;
2126 std::unordered_set<PCB_GROUP*> toCheckGroups;
2130 toCheckGroups.insert(
group);
2132 while( !toCheckGroups.empty() )
2134 currentChainGroups.clear();
2139 if( currentChainGroups.find(
group ) != currentChainGroups.end() )
2144 return "Cycle detected in group membership";
2146 else if( knownCycleFreeGroups.find(
group ) != knownCycleFreeGroups.end() )
2152 currentChainGroups.insert(
group );
2154 toCheckGroups.erase(
group );
2167 knownCycleFreeGroups.insert( currentChainGroups.begin(), currentChainGroups.end() );
2177 bool hasGroup =
false;
2178 bool hasMember =
false;
2223 if( aFirst->
Type() != aSecond->
Type() )
2224 return aFirst->
Type() < aSecond->
Type();
2233 return shape->
Compare( other );
2239 return text->Compare( other );
2246 return textbox->PCB_SHAPE::Compare( other ) && textbox->EDA_TEXT::Compare( other );
2261 if( !track->IsOnLayer( aLayer ) )
2264 track->TransformShapeToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
2270 footprint->TransformPadsToPolySet( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
2273 footprint->TransformFPShapesToPolySet( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE,
2278 for(
const ZONE* zone : footprint->Zones() )
2280 if( zone->GetLayerSet().test( aLayer ) )
2281 zone->TransformSolidAreasShapesToPolygon( aLayer, aOutlines );
2288 if( zone->GetLayerSet().test( aLayer ) )
2289 zone->TransformSolidAreasShapesToPolygon( aLayer, aOutlines );
2295 if( !item->IsOnLayer( aLayer ) )
2298 switch( item->Type() )
2310 text->TransformTextToPolySet( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
2319 textbox->PCB_SHAPE::TransformShapeToPolygon( aOutlines, aLayer, 0, maxError,
@ NORMAL
Use all material properties from model file.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
constexpr EDA_IU_SCALE pcbIUScale
bool sortPadsByXthenYCoord(PAD *const &aLH, PAD *const &aRH)
Used by #GetSortedPadListByXCoord to sort a pad list by X coordinate value.
BOARD_USE
Flags to specify how the board is being used.
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
void SetCustomDiffPairWidth(int aWidth)
Sets custom track width for differential pairs (i.e.
std::shared_ptr< NET_SETTINGS > m_NetSettings
void SetCustomTrackWidth(int aWidth)
Sets custom width for track (i.e.
void SetEnabledLayers(LSET aMask)
Change the bit-mask of enabled layers to aMask.
LSET GetEnabledLayers() const
Return a bit-mask of all the layers that are enabled.
void SetCustomViaSize(int aSize)
Set custom size for via diameter (i.e.
void SetCustomDiffPairGap(int aGap)
Sets custom gap for differential pairs (i.e.
bool IsLayerEnabled(PCB_LAYER_ID aLayerId) const
Test whether a given layer aLayerId is enabled.
BOARD_STACKUP & GetStackupDescriptor()
void SetCustomViaDrill(int aDrill)
Sets custom size for via drill (i.e.
void SetDefaultZoneSettings(const ZONE_SETTINGS &aSettings)
int GetCopperLayerCount() const
ZONE_SETTINGS & GetDefaultZoneSettings()
bool m_UseHeightForLengthCalcs
Enable inclusion of stackup height in track length measurements and length tuning.
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
void SetCustomDiffPairViaGap(int aGap)
Sets custom via gap for differential pairs (i.e.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
PCB_GROUP * GetParentGroup() const
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
static VECTOR2I ZeroOffset
A value of wxPoint(0,0) which can be passed to the Draw() functions.
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem)
virtual void OnBoardHighlightNetChanged(BOARD &aBoard)
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Manage layers needed to make a physical board.
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
Information pertinent to a Pcbnew printed circuit board.
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...
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...
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_EnclosedByAreaCache
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SetPosition(const VECTOR2I &aPos) override
std::map< wxString, wxString > m_properties
int m_fileFormatVersionAtLoad
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
std::vector< ZONE * > m_DRCCopperZones
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
GAL_SET m_LegacyVisibleItems
void SetZoneSettings(const ZONE_SETTINGS &aSettings) override
Set the zone settings for this container.
PAD * GetPadFast(const VECTOR2I &aPosition, LSET aLayerMask) const
Return pad found at aPosition on aLayerMask using the fast search method.
LAYER m_layers[PCB_LAYER_ID_COUNT]
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
const ZONE_SETTINGS & GetZoneSettings() const override
Fetch the zone settings for this container.
void MapNets(const BOARD *aDestBoard)
Map all nets in the given board to nets with the same name (if any) in the destination board.
void RemoveAllListeners()
Remove all listeners.
std::unique_ptr< BOARD_DESIGN_SETTINGS > m_designSettings
All of the board design settings are stored as a JSON object inside the project file.
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
void SetProperties(const std::map< wxString, wxString > &aProps)
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
HIGH_LIGHT_INFO m_highLight
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Return the type of the copper layer given by aLayer.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
BOARD_ITEM * GetItem(const KIID &aID) const
void InvokeListeners(Func &&aFunc, Args &&... args)
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
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.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
void ResetNetHighLight()
Reset all high light data to the init state.
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false) const
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines) const
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
bool ResolveTextVar(wxString *token, int aDepth) const
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
void Move(const VECTOR2I &aMoveVector) override
Move this object.
TITLE_BLOCK & GetTitleBlock()
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
FOOTPRINTS & Footprints()
HIGH_LIGHT_INFO m_highLightPrevious
std::unique_ptr< DRC_RTREE > m_CopperItemRTreeCache
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
GroupLegalOpsField GroupLegalOps(const PCB_SELECTION &selection) const
Check which selection tool group operations are legal given the selection.
int GetCopperLayerCount() const
std::vector< BOARD_LISTENER * > m_listeners
const PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsCourtyardCache
void IncrementTimeStamp()
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsFCourtyardCache
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
int m_DRCMaxPhysicalClearance
GROUPS & Groups()
The groups must maintain the following invariants.
FOOTPRINT * FindFootprintByPath(const KIID_PATH &aPath) const
Search for a FOOTPRINT within this board with the given path.
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.
std::unordered_map< wxString, LSET > m_LayerExpressionCache
wxString GroupsSanityCheckInternal(bool repair)
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
wxString GetClass() const override
Return the class name.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
void SetCopperLayerCount(int aCount)
std::unordered_map< const ZONE *, BOX2I > m_ZoneBBoxCache
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsBCourtyardCache
TRACKS TracksInNet(int aNetCode)
Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
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.
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
unsigned GetNodesCount(int aNet=-1) const
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
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,...
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
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.
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
PROJECT * GetProject() const
std::tuple< int, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
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.
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::vector< ZONE * > m_DRCZones
PAD * GetPad(const VECTOR2I &aPosition, LSET aLayerMask) const
Find a pad aPosition on aLayer.
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
std::vector< PCB_MARKER * > ResolveDRCExclusions()
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
void DeleteMARKERs()
Delete all MARKERS from the board.
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_IntersectsAreaCache
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
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.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
VECTOR2I GetPosition() const override
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
coord_type GetHeight() const
coord_type GetWidth() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
std::shared_ptr< const CN_ANCHOR > GetSourceNode() const
void SetVisible(bool aVisible)
std::shared_ptr< const CN_ANCHOR > GetTargetNode() const
static DELETED_BOARD_ITEM * GetInstance()
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM_FLAGS GetFlags() const
int Compare(const EDA_SHAPE *aOther) const
A specialization of ZONE for use in footprints.
Helper for storing and iterating over GAL_LAYER_IDs.
static const std::vector< KICAD_T > BoardLevelItems
A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT,...
static const std::vector< KICAD_T > Tracks
A scan list for only TRACKs and ARCs.
std::set< int > m_netCodes
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
void SetExcluded(bool aExcluded)
void SetParent(JSON_SETTINGS *aParent, bool aLoadFromFile=true)
static const char Default[]
the name of the default NETCLASS
Handle the data for a net.
void SetNetCode(int aNetCode)
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
static const int ORPHANED
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
static NETINFO_ITEM * OrphanedItem()
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
unsigned GetNetCount() const
void RemoveNet(NETINFO_ITEM *aNet)
Remove a net from the net list.
NETINFO_ITEM * GetNetItem(int aNetCode) const
void AppendNet(NETINFO_ITEM *aNewElement)
Add aNewElement to the end of the net list.
VECTOR2I GetPosition() const override
Describe the page size and margins of a paper page on which to eventually print or plot.
A set of BOARD_ITEMs (i.e., without duplicates).
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
static PCB_MARKER * Deserialize(const wxString &data)
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
const VECTOR2I & GetEndPoint(ENDPOINT_T aEndPoint) const
Return the selected endpoint (start or end)
bool m_Printing
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
A progress reporter interface for use in multi-threaded environments.
virtual bool IsCancelled() const =0
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual void AdvanceProgress()=0
Increment the progress bar length (inside the current virtual zone).
The backing store for a PROJECT, in JSON format.
LSET m_VisibleLayers
Board settings.
GAL_SET m_VisibleItems
The GAL layers (aka items) that are turned on for viewing (.
Container for project specific data.
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
virtual bool TextVarResolver(wxString *aToken) const
virtual PROJECT_FILE & GetProjectFile() const
virtual std::map< wxString, wxString > & GetTextVars() const
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
int Length() const
Return the length (this).
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void Simplify(POLYGON_MODE aFastMode)
int NewOutline()
Creates a new hole in a given outline.
bool TextVarResolver(wxString *aToken, const PROJECT *aProject) const
ZONE_SETTINGS handles zones parameters.
Handle a list of polygons defining a copper zone.
void SetMinThickness(int aMinThickness)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET * Outline()
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
void SetLayerSet(LSET aLayerSet) override
bool AppendCorner(VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
bool BuildBoardPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler)
Extracts the board outlines and build a closed polygon from lines, arcs and circle items on edge cut ...
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
const INSPECTOR_FUNC & INSPECTOR
std::function< INSPECT_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Used to inspect and possibly collect the (search) results of iterating over a list or tree of KICAD_T...
#define STRUCT_DELETED
flag indication structures to be erased
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
@ GAL_LAYER_ID_BITMASK_END
This is the end of the layers used for visibility bit masks in legacy board files.
@ LAYER_MOD_FR
show footprints on front
@ LAYER_MOD_BK
show footprints on back
PCB_LAYER_ID
A quick note on layer IDs:
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
void delete_matching(_Container &__c, _Value __value)
Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything).
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Class that computes missing connections on a PCB.
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
constexpr int mmToIU(double mm) const
Container to hold information pertinent to a layer of a BOARD.
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
LAYER_T m_type
The type of the layer.
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
wxString m_name
The canonical name of the layer.
wxString m_userName
The user defined name of the layer.
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::thread_pool thread_pool
double EuclideanNorm(const VECTOR2I &vector)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.