126 else if( layer >=
User_1 && layer & 1 )
139 int infinity = ( std::numeric_limits<int>::max() / 2 ) -
pcbIUScale.mmToIU( 1 );
223 if( aProject && !aReferenceOnly )
240 std::shared_ptr<NET_SETTINGS>& projectSettings =
project.NetSettings();
242 projectSettings->SetDefaultNetclass( legacySettings->GetDefaultNetclass() );
243 projectSettings->SetNetclasses( legacySettings->GetNetclasses() );
244 projectSettings->SetNetclassPatternAssignments(
245 std::move( legacySettings->GetNetclassPatternAssignments() ) );
265 project.m_BoardSettings =
nullptr;
276 std::unique_lock<std::shared_mutex> writeLock(
m_CachesMutex );
317 std::set<std::pair<KIID, KIID>> m_ratsnestExclusions;
323 const std::shared_ptr<RC_ITEM>& rcItem = marker->GetRCItem();
324 m_ratsnestExclusions.emplace( rcItem->GetMainItemID(), rcItem->GetAuxItemID() );
325 m_ratsnestExclusions.emplace( rcItem->GetAuxItemID(), rcItem->GetMainItemID() );
338 aEdge.
SetVisible( m_ratsnestExclusions.count( ids ) == 0 );
353 if( marker->IsExcluded() )
355 wxString serialized = marker->SerializeToString();
357 m_designSettings->m_DrcExclusionComments[serialized] = marker->GetComment();
368 prjSettings->m_DrcExclusionComments =
m_designSettings->m_DrcExclusionComments;
374std::set<wxString>::iterator
FindByFirstNFields( std::set<wxString>& strSet,
const wxString& searchStr,
char delimiter,
377 wxString searchPrefix = searchStr;
380 int delimiterCount = 0;
383 while( pos < searchPrefix.length() && delimiterCount < n )
385 if( searchPrefix[pos] == delimiter )
391 if( delimiterCount == n )
392 searchPrefix = searchPrefix.Left( pos - 1 );
394 for(
auto it = strSet.begin(); it != strSet.end(); ++it )
396 if( it->StartsWith( searchPrefix + delimiter ) || *it == searchPrefix )
406 std::map<wxString, wxString> comments =
m_designSettings->m_DrcExclusionComments;
413 std::set<wxString>::iterator it;
414 wxString serialized = marker->SerializeToString();
415 wxString matchedExclusion;
417 if( !serialized.Contains(
"unconnected_items" ) )
419 it = exclusions.find( serialized );
421 if( it != exclusions.end() )
422 matchedExclusion = *it;
426 const int numberOfFieldsExcludingIds = 3;
427 const char delimiter =
'|';
428 it =
FindByFirstNFields( exclusions, serialized, delimiter, numberOfFieldsExcludingIds );
430 if( it != exclusions.end() )
431 matchedExclusion = *it;
434 if( it != exclusions.end() )
436 marker->SetExcluded(
true, comments[matchedExclusion] );
440 m_designSettings->m_DrcExclusionComments[matchedExclusion] = comments[matchedExclusion];
442 exclusions.erase( it );
446 std::vector<PCB_MARKER*> newMarkers;
450 for(
const wxString& serialized : exclusions )
461 for(
const KIID& uuid : ids )
463 if( uuidCount < 1 || uuid !=
niluuid )
478 newMarkers.push_back( marker );
482 m_designSettings->m_DrcExclusionComments[serialized] = comments[serialized];
493 auto add = [&](
const wxString& aVar )
496 aVars->push_back( aVar );
499 add( wxT(
"LAYER" ) );
500 add( wxT(
"FILENAME" ) );
501 add( wxT(
"FILEPATH" ) );
502 add( wxT(
"PROJECTNAME" ) );
503 add( wxT(
"DRC_ERROR <message_text>" ) );
504 add( wxT(
"DRC_WARNING <message_text>" ) );
505 add( wxT(
"VARIANT" ) );
506 add( wxT(
"VARIANT_DESC" ) );
512 for( std::pair<wxString, wxString> entry :
GetProject()->GetTextVars() )
520 if( token->Contains(
':' ) )
523 wxString ref = token->BeforeFirst(
':', &remainder );
532 *token = std::move( remainder );
543 if( footprint->GetReference().CmpNoCase( ref ) == 0 )
545 wxString remainderCopy = remainder;
547 if( footprint->ResolveTextVar( &remainderCopy, aDepth + 1 ) )
549 *token = std::move( remainderCopy );
554 *token = wxString::Format( wxT(
"<Unresolved: %s:%s>" ), footprint->GetReference(), remainder );
562 *token = wxString::Format( wxT(
"<Unknown reference: %s>" ), ref );
567 if( token->IsSameAs( wxT(
"FILENAME" ) ) )
570 *token = fn.GetFullName();
573 else if( token->IsSameAs( wxT(
"FILEPATH" ) ) )
576 *token = fn.GetFullPath();
579 else if( token->IsSameAs( wxT(
"VARIANT" ) ) )
584 else if( token->IsSameAs( wxT(
"VARIANT_DESC" ) ) )
589 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) &&
GetProject() )
595 wxString var = *token;
628 wxLogWarning( wxT(
"This should not be called on the BOARD object" ) );
643 board_item->
Move( aMoveVector );
674 aFunction( footprint );
682 aFunction( drawing );
688 catch( std::bad_function_call& )
690 wxFAIL_MSG( wxT(
"Error running BOARD::RunOnChildren" ) );
728 for(
auto& [layer_id, layer] :
m_layers )
730 if( layer.m_name == aLayerName || layer.m_userName == aLayerName )
755 if( it !=
m_layers.end() && !it->second.m_userName.IsEmpty() )
756 return it->second.m_userName;
765 if( aLayerName.IsEmpty() )
768 m_layers[aLayer].m_userName.clear();
774 if( aLayerName.Find( wxChar(
'"' ) ) != wxNOT_FOUND )
779 m_layers[aLayer].m_userName = aLayerName;
808 return it->second.m_type;
824 m_layers[aLayer].m_type = aLayerType;
842 case LT_AUX:
return "auxiliary";
851 if( strcmp( aType,
"signal" ) == 0 )
853 else if( strcmp( aType,
"power" ) == 0 )
855 else if( strcmp( aType,
"mixed" ) == 0 )
857 else if( strcmp( aType,
"jumper" ) == 0 )
859 else if( strcmp( aType,
"auxiliary" ) == 0 )
861 else if( strcmp( aType,
"front" ) == 0 )
863 else if( strcmp( aType,
"back" ) == 0 )
878 if(
m_layers[layer].m_opposite != layer )
884 wxString principalName =
m_layers[layer].m_userName.AfterFirst(
'.' );
897 wxString candidate =
m_layers[ii].m_userName.AfterFirst(
'.' );
899 if( !candidate.IsEmpty() && candidate == principalName )
911 int next = layer + 2;
976 if( aStartLayer > aEndLayer )
977 std::swap( aStartLayer, aEndLayer );
979 if( aEndLayer ==
B_Cu )
982 return aEndLayer - aStartLayer;
1021 m_project->GetLocalSettings().m_VisibleLayers = aLayerSet;
1030 for(
size_t i = 0; i < aSet.size(); i++ )
1071 track->SetLocalRatsnestVisible( isEnabled );
1075 for(
PAD*
pad : footprint->Pads() )
1076 pad->SetLocalRatsnestVisible( isEnabled );
1080 zone->SetLocalRatsnestVisible( isEnabled );
1096 default: wxFAIL_MSG( wxT(
"BOARD::IsModuleLayerVisible(): bad layer" ) );
return true;
1131 std::unique_lock<std::shared_mutex> writeLock(
m_CachesMutex );
1136 worstClearance = std::max( worstClearance, zone->GetLocalClearance().value() );
1140 for(
PAD*
pad : footprint->Pads() )
1142 std::optional<int>
override =
pad->GetClearanceOverrides(
nullptr );
1144 if(
override.has_value() )
1145 worstClearance = std::max( worstClearance,
override.value() );
1148 for(
ZONE* zone : footprint->Zones() )
1149 worstClearance = std::max( worstClearance, zone->GetLocalClearance().value() );
1161 std::vector<ZONE*> zones = aZones;
1170 aReporter->
Report(
_(
"Tessellating copper zones..." ) );
1173 std::vector<std::future<size_t>> returns;
1175 returns.reserve( zones.size() );
1178 [&
tp]( std::function<void()> aTask )
1180 tp.detach_task( std::move( aTask ) );
1183 auto cache_zones = [aReporter, &submitter](
ZONE* aZone ) ->
size_t
1196 for(
ZONE* zone : zones )
1197 returns.emplace_back(
tp.submit_task(
1200 return cache_zones( zone );
1204 for(
const std::future<size_t>& ret : returns )
1206 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
1208 while( status != std::future_status::ready )
1213 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
1222 aFunction( footprint->GetEmbeddedFiles() );
1239 embeddedFile->data_hash = file->
data_hash;
1240 embeddedFile->is_valid = file->
is_valid;
1249 if( aBoardItem ==
nullptr )
1251 wxFAIL_MSG( wxT(
"BOARD::Add() param error: aBoardItem nullptr" ) );
1257 switch( aBoardItem->
Type() )
1287 wxFAIL_MSG( wxString::Format(
"BOARD::Add() Cannot place Track on non-copper layer: %d = %s",
1288 static_cast<int>( aBoardItem->
GetLayer() ),
1350 wxFAIL_MSG( wxString::Format( wxT(
"BOARD::Add() item type %s not handled" ), aBoardItem->
GetClass() ) );
1357 if( !aSkipConnectivity )
1379 for(
int ii = (
int)
m_zones.size() - 1; ii >= 0; --ii )
1397 wxASSERT( aBoardItem );
1402 parentGroup && !( parentGroup->AsEdaItem()->GetFlags() &
STRUCT_DELETED ) )
1404 parentGroup->RemoveItem( aBoardItem );
1409 switch( aBoardItem->
Type() )
1418 if( boardItem->GetNet() == netItem )
1419 boardItem->SetNet( unconnected );
1478 wxFAIL_MSG( wxString::Format( wxT(
"BOARD::Remove() item type %s not handled" ), aBoardItem->
GetClass() ) );
1492 std::vector<BOARD_ITEM*> removed;
1493 std::vector<NETINFO_ITEM*> removedNets;
1495 for(
const KICAD_T& type : aTypes )
1502 removed.emplace_back( item );
1503 removedNets.emplace_back( item );
1517 std::copy(
m_groups.begin(),
m_groups.end(), std::back_inserter( removed ) );
1522 std::copy(
m_points.begin(),
m_points.end(), std::back_inserter( removed ) );
1527 std::copy(
m_zones.begin(),
m_zones.end(), std::back_inserter( removed ) );
1542 std::copy(
m_tracks.begin(),
m_tracks.end(), std::back_inserter( removed ) );
1547 case PCB_VIA_T: wxFAIL_MSG( wxT(
"Use PCB_TRACE_T to remove all tracks, arcs, and vias" ) );
break;
1565 case PCB_BARCODE_T: wxFAIL_MSG( wxT(
"Use PCB_SHAPE_T to remove all graphics and text" ) );
break;
1567 default: wxFAIL_MSG( wxT(
"BOARD::RemoveAll() needs more ::Type() support" ) );
1594 for(
int i = 0; i < collector.
GetCount(); i++ )
1614 via->LayerPair( &top_layer, &bottom_layer );
1616 if( top_layer != aLayer && bottom_layer != aLayer )
1631 bool modified =
false;
1632 bool removedItemLayers =
false;
1638 for(
int i = 0; i < collector.
GetCount(); i++ )
1659 removedItemLayers =
true;
1662 else if(
via->IsOnLayer( aLayer ) )
1666 via->LayerPair( &top_layer, &bottom_layer );
1668 if( top_layer == aLayer || bottom_layer == aLayer )
1678 removedItemLayers =
true;
1685 layers.
reset( aLayer );
1698 removedItemLayers =
true;
1702 if( removedItemLayers )
1711 return wxString::Format(
_(
"PCB" ) );
1726 aView->
Update( dimension );
1732 aItem->
Visit( inspector,
nullptr,
1753 std::vector<PCB_MARKER*> remaining;
1765 remaining.push_back( marker );
1776 std::vector<FOOTPRINT*> footprints;
1781 for(
FOOTPRINT* footprint : footprints )
1788 std::vector<FOOTPRINT*> footprints;
1793 for(
FOOTPRINT* footprint : footprints )
1794 footprint->SetParent(
nullptr );
1811 if(
group->m_Uuid == aID )
1817 if( generator->m_Uuid == aID )
1823 if( track->m_Uuid == aID )
1829 if( footprint->m_Uuid == aID )
1832 for(
PAD*
pad : footprint->Pads() )
1834 if(
pad->m_Uuid == aID )
1838 for(
PCB_FIELD* field : footprint->GetFields() )
1840 wxCHECK2( field,
continue );
1842 if( field && field->m_Uuid == aID )
1846 for(
BOARD_ITEM* drawing : footprint->GraphicalItems() )
1848 if( drawing->m_Uuid == aID )
1854 if( zone->m_Uuid == aID )
1860 if(
group->m_Uuid == aID )
1864 for(
PCB_POINT* point : footprint->Points() )
1866 if( point->m_Uuid == aID )
1873 if( zone->m_Uuid == aID )
1883 if( cell->m_Uuid == aID )
1888 if( drawing->m_Uuid == aID )
1894 if( marker->m_Uuid == aID )
1900 if( point->m_Uuid == aID )
1906 if( netInfo->m_Uuid == aID )
1911 return const_cast<BOARD*
>( this );
1914 if( aAllowNullptrReturn )
1930 if( item && item->
m_Uuid == aId )
2029 if( it->second == aItem )
2039 wxCHECK_RET( aItem,
"BOARD::RebindItemUuid() requires a valid item" );
2044 if( aItem->
m_Uuid == aNewId )
2052 wxFAIL_MSG( wxString::Format(
"BOARD::RebindItemUuid() duplicate target UUID: %s",
2071 wxCHECK2( aItem,
return );
2073 if( ids.count( aItem->m_Uuid ) )
2079 ids.insert( aItem->m_Uuid );
2085 processItem( footprint );
2091 for(
PAD*
pad : footprint->Pads() )
2096 processItem( track );
2101 processItem( &footprint->Reference() );
2102 processItem( &footprint->Value() );
2104 for(
BOARD_ITEM* item : footprint->GraphicalItems() )
2105 processItem( item );
2107 for(
ZONE* zone : footprint->Zones() )
2108 processItem( zone );
2111 processItem(
group );
2118 switch( item->Type() )
2127 processItem( item );
2142 aMap[track->m_Uuid] = track;
2146 aMap[footprint->m_Uuid] = footprint;
2148 for(
PAD*
pad : footprint->Pads() )
2151 aMap[footprint->Reference().m_Uuid] = &footprint->Reference();
2152 aMap[footprint->Value().m_Uuid] = &footprint->Value();
2154 for(
BOARD_ITEM* drawing : footprint->GraphicalItems() )
2155 aMap[drawing->m_Uuid] = drawing;
2159 aMap[zone->m_Uuid] = zone;
2162 aMap[drawing->m_Uuid] = drawing;
2165 aMap[marker->m_Uuid] = marker;
2171 aMap[point->m_Uuid] = point;
2174 aMap[generator->m_Uuid] = generator;
2181 size_t sourceLen = aSource.length();
2183 for(
size_t i = 0; i < sourceLen; ++i )
2187 if( aSource[i] ==
'\\' && i + 2 < sourceLen && aSource[i + 2] ==
'{' &&
2188 ( aSource[i + 1] ==
'$' || aSource[i + 1] ==
'@' ) )
2191 newbuf.append( aSource[i] );
2192 newbuf.append( aSource[i + 1] );
2193 newbuf.append( aSource[i + 2] );
2198 for( i = i + 1; i < sourceLen && braceDepth > 0; ++i )
2200 if( aSource[i] ==
'{' )
2202 else if( aSource[i] ==
'}' )
2205 newbuf.append( aSource[i] );
2211 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i + 1] ==
'{' )
2214 bool isCrossRef =
false;
2216 for( i = i + 2; i < sourceLen; ++i )
2218 if( aSource[i] ==
'}' )
2221 if( aSource[i] ==
':' )
2224 token.append( aSource[i] );
2230 wxString ref = token.BeforeFirst(
':', &remainder );
2234 if( footprint->GetReference().CmpNoCase( ref ) == 0 )
2236 wxString
test( remainder );
2238 if( footprint->ResolveTextVar( &
test ) )
2239 token = footprint->m_Uuid.AsString() + wxT(
":" ) + remainder;
2246 newbuf.append( wxT(
"${" ) + token + wxT(
"}" ) );
2250 newbuf.append( aSource[i] );
2261 size_t sourceLen = aSource.length();
2263 for(
size_t i = 0; i < sourceLen; ++i )
2267 if( aSource[i] ==
'\\' && i + 2 < sourceLen && aSource[i + 2] ==
'{' &&
2268 ( aSource[i + 1] ==
'$' || aSource[i + 1] ==
'@' ) )
2271 newbuf.append( aSource[i] );
2272 newbuf.append( aSource[i + 1] );
2273 newbuf.append( aSource[i + 2] );
2278 for( i = i + 1; i < sourceLen && braceDepth > 0; ++i )
2280 if( aSource[i] ==
'{' )
2282 else if( aSource[i] ==
'}' )
2285 newbuf.append( aSource[i] );
2291 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i + 1] ==
'{' )
2294 bool isCrossRef =
false;
2296 for( i = i + 2; i < sourceLen; ++i )
2298 if( aSource[i] ==
'}' )
2301 if( aSource[i] ==
':' )
2304 token.append( aSource[i] );
2310 wxString ref = token.BeforeFirst(
':', &remainder );
2315 token =
static_cast<FOOTPRINT*
>( refItem )->GetReference() + wxT(
":" ) + remainder;
2319 newbuf.append( wxT(
"${" ) + token + wxT(
"}" ) );
2323 newbuf.append( aSource[i] );
2333 unsigned retval = 0;
2337 for(
PAD*
pad : footprint->Pads() )
2339 if( ( aNet == -1 &&
pad->GetNetCode() > 0 ) || aNet ==
pad->GetNetCode() )
2353 if( aPhysicalLayersOnly )
2361 if( aBoardEdgesOnly )
2370 if( ( item->GetLayerSet() & visible ).any() )
2371 bbox.
Merge( item->GetBoundingBox() );
2377 if( aBoardEdgesOnly )
2379 for(
const BOARD_ITEM* edge : footprint->GraphicalItems() )
2382 bbox.
Merge( edge->GetBoundingBox() );
2385 else if( ( footprint->GetLayerSet() & visible ).any() )
2387 bbox.
Merge( footprint->GetBoundingBox(
true ) );
2391 if( !aBoardEdgesOnly )
2396 if( ( track->GetLayerSet() & visible ).any() )
2397 bbox.
Merge( track->GetBoundingBox() );
2403 if( ( aZone->GetLayerSet() & visible ).any() )
2404 bbox.
Merge( aZone->GetBoundingBox() );
2409 bbox.
Merge( point->GetBoundingBox() );
2421 int trackSegmentCount = 0;
2422 std::set<int> netCodes;
2430 trackSegmentCount++;
2432 if( item->GetNetCode() > 0 )
2433 netCodes.insert( item->GetNetCode() );
2438 for(
PAD*
pad : footprint->Pads() )
2442 if(
pad->GetNetCode() > 0 )
2443 netCodes.insert(
pad->GetNetCode() );
2447 aList.emplace_back(
_(
"Pads" ), wxString::Format( wxT(
"%d" ), padCount ) );
2448 aList.emplace_back(
_(
"Vias" ), wxString::Format( wxT(
"%d" ), viaCount ) );
2449 aList.emplace_back(
_(
"Track Segments" ), wxString::Format( wxT(
"%d" ), trackSegmentCount ) );
2450 aList.emplace_back(
_(
"Nets" ), wxString::Format( wxT(
"%d" ), (
int) netCodes.size() ) );
2451 aList.emplace_back(
_(
"Unrouted" ), wxString::Format( wxT(
"%d" ), unconnected ) );
2457#if 0 && defined( DEBUG )
2458 std::cout <<
GetClass().mb_str() <<
' ';
2461 bool footprintsScanned =
false;
2462 bool drawingsScanned =
false;
2463 bool tracksScanned =
false;
2465 for(
KICAD_T scanType : scanTypes )
2497 if( !footprintsScanned )
2504 footprintsScanned =
true;
2507 if( !drawingsScanned )
2514 drawingsScanned =
true;
2522 if( !tracksScanned )
2529 tracksScanned =
true;
2553 if( !footprintsScanned )
2560 footprintsScanned =
true;
2572 if( !footprintsScanned )
2579 footprintsScanned =
true;
2615 return m_NetInfo.GetNetItem( aNetcode );
2621 return m_NetInfo.GetNetItem( aNetname );
2630 for(
auto it = aNetName.rbegin(); it != aNetName.rend() && rv == 0; ++it, ++count )
2634 if( ( ch >=
'0' && ch <=
'9' ) || ch ==
'_' )
2638 else if( ch ==
'+' )
2640 aComplementNet = wxT(
"-" );
2643 else if( ch ==
'-' )
2645 aComplementNet = wxT(
"+" );
2648 else if( ch ==
'N' )
2650 aComplementNet = wxT(
"P" );
2653 else if( ch ==
'P' )
2655 aComplementNet = wxT(
"N" );
2664 if( rv != 0 && count >= 1 )
2666 aComplementNet = aNetName.Left( aNetName.length() - count ) + aComplementNet + aNetName.Right( count - 1 );
2678 wxString coupledNetName;
2681 return FindNet( coupledNetName );
2692 if( aReference == footprint->GetReference() )
2704 if( footprint->GetPath() == aPath )
2716 if(
PAD*
pad = footprint->FindPadByUuid( aUuid ) )
2730 if( net->GetNetChain() == aNetChain )
2732 for(
int i = 0; i < 2; ++i )
2734 PAD*
pad = net->GetTerminalPad( i );
2736 if(
pad &&
pad->m_Uuid == aPrev )
2737 net->SetTerminalPad( i, newPad );
2746 std::set<wxString> names;
2750 if( !net->GetNetname().IsEmpty() )
2751 names.insert( net->GetNetname() );
2766 const wxString& aVariantName )
2768 for(
const wxString&
name : aNames )
2770 if(
name.CmpNoCase( aVariantName ) == 0 )
2774 return wxEmptyString;
2790 if( actualName.IsEmpty() )
2812 if( aVariantName.IsEmpty()
2827 [&](
const wxString&
name )
2829 return name.CmpNoCase( aVariantName ) == 0;
2834 wxString actualName = *it;
2844 fp->DeleteVariant( actualName );
2855 [&](
const wxString&
name )
2857 return name.CmpNoCase( aOldName ) == 0;
2862 wxString actualOldName = *it;
2867 if( !existingName.IsEmpty() && existingName.CmpNoCase( actualOldName ) != 0 )
2870 if( actualOldName == aNewName )
2880 if( !descIt->second.IsEmpty() )
2892 fp->RenameVariant( actualOldName, aNewName );
2900 return wxEmptyString;
2904 if( actualName.IsEmpty() )
2905 return wxEmptyString;
2912 return wxEmptyString;
2923 if( actualName.IsEmpty() )
2926 if( aDescription.IsEmpty() )
2935 wxArrayString names;
2966 if( aResetTrackAndViaSizes )
2988 settings->GetComponentClassAssignments(), settings->GetEnableSheetComponentClasses(), aNewSheetPaths );
2994 int error_count = 0;
2998 if( !zone->IsOnCopperLayer() )
3004 if( zone->GetNetCode() != 0 )
3017 zone->SetNetCode( -1 );
3032 if( footprint->HitTest( aPosition ) )
3033 pad = footprint->GetPad( aPosition, aLayerSet.any() ? aLayerSet :
LSET::AllCuMask() );
3049 return GetPad( aPosition, lset );
3057 int idxmax = aPadList.size() - 1;
3059 int delta = aPadList.size();
3072 PAD*
pad = aPadList[idx];
3074 if(
pad->GetPosition() == aPosition )
3077 if( ( aLayerSet &
pad->GetLayerSet() ).any() )
3084 for(
int ii = idx + 1; ii <= idxmax; ii++ )
3088 if(
pad->GetPosition() != aPosition )
3091 if( ( aLayerSet &
pad->GetLayerSet() ).any() )
3095 for(
int ii = idx - 1; ii >= 0; ii-- )
3099 if(
pad->GetPosition() != aPosition )
3102 if( ( aLayerSet &
pad->GetLayerSet() ).any() )
3110 if(
pad->GetPosition().x == aPosition.
x )
3112 if(
pad->GetPosition().y < aPosition.
y )
3127 else if(
pad->GetPosition().x < aPosition.
x )
3165 for(
PAD*
pad : footprint->Pads() )
3167 if( aNetCode < 0 || pad->GetNetCode() == aNetCode )
3168 aVector.push_back(
pad );
3190 std::vector<LENGTH_DELAY_CALCULATION_ITEM> items;
3196 if( item.
Type() != LENGTH_DELAY_CALCULATION_ITEM::TYPE::UNKNOWN )
3197 items.push_back( std::move( item ) );
3201 .OptimiseVias =
true, .MergeTracks =
true, .OptimiseTracesInPads =
true, .InferViaInPad =
false
3213 bool aIgnoreLocked )
const
3217 int min_dim = 0x7FFFFFFF;
3218 int alt_min_dim = 0x7FFFFFFF;
3219 bool current_layer_back =
IsBackLayer( aActiveLayer );
3224 if( !candidate->HitTest( aPosition ) )
3228 if( aIgnoreLocked && candidate->IsLocked() )
3236 BOX2I bb = candidate->GetBoundingBox(
false );
3243 ( aPosition.
x - offx ) * ( aPosition.
x - offx ) + ( aPosition.
y - offy ) * ( aPosition.
y - offy );
3247 if( dist <= min_dim )
3250 footprint = candidate;
3256 if( dist <= alt_min_dim )
3259 alt_footprint = candidate;
3270 return alt_footprint;
3278 std::list<ZONE*> zones;
3281 zones.push_back( zone );
3283 if( aIncludeZonesInFootprints )
3287 for(
ZONE* zone : footprint->Zones() )
3288 zones.push_back( zone );
3304 m_zones.push_back( new_area );
3323 bool aIncludeNPTHAsOutlines )
3329 aInferOutlineIfNecessary, aErrorHandler, aAllowUseArcsInPolygons );
3332 if( aIncludeNPTHAsOutlines )
3336 for(
PAD*
pad : fp->Pads() )
3384 std::set<KIFONT::OUTLINE_FONT*>
fonts;
3397 if( permission == PERMISSION::EDITABLE || permission == PERMISSION::INSTALLABLE )
3398 fonts.insert( outlineFont );
3419 std::vector<PAD*> allPads;
3423 for(
PAD*
pad : footprint->Pads() )
3424 allPads.push_back(
pad );
3433 std::vector<BOARD_CONNECTED_ITEM*> items;
3436 items.push_back( track );
3440 for(
PAD*
pad : footprint->Pads() )
3441 items.push_back(
pad );
3443 for(
ZONE* zone : footprint->Zones() )
3444 items.push_back( zone );
3446 for(
BOARD_ITEM* dwg : footprint->GraphicalItems() )
3449 items.push_back( bci );
3454 items.push_back( zone );
3459 items.push_back( bci );
3473 item->SetNet( netInfo );
3477 aDestBoard->
Add( newNet );
3478 item->SetNet( newNet );
3488 if(
FindNet( item->GetNetCode() ) ==
nullptr )
3532 std::vector<BOARD_ITEM*>& aChangedItems )
3555 bool already =
m_highLight.m_netCodes.count( aNetCode );
3586 return wxEmptyString;
3605 std::unordered_set<EDA_GROUP*> knownCycleFreeGroups;
3607 std::unordered_set<EDA_GROUP*> currentChainGroups;
3609 std::unordered_set<EDA_GROUP*> toCheckGroups;
3613 toCheckGroups.insert(
group );
3616 toCheckGroups.insert( gen );
3618 while( !toCheckGroups.empty() )
3620 currentChainGroups.clear();
3625 if( currentChainGroups.find(
group ) != currentChainGroups.end() )
3630 return "Cycle detected in group membership";
3632 else if( knownCycleFreeGroups.find(
group ) != knownCycleFreeGroups.end() )
3638 currentChainGroups.insert(
group );
3640 toCheckGroups.erase(
group );
3642 group =
group->AsEdaItem()->GetParentGroup();
3653 knownCycleFreeGroups.insert( currentChainGroups.begin(), currentChainGroups.end() );
3684 if( aFirst->
Type() != aSecond->
Type() )
3685 return aFirst->
Type() < aSecond->
Type();
3694 return shape->
Compare( other ) < 0;
3700 return text->Compare( other ) < 0;
3707 int shapeCmp = textbox->PCB_SHAPE::Compare( other );
3710 return shapeCmp < 0;
3712 return textbox->EDA_TEXT::Compare( other ) < 0;
3741 if( !track->IsOnLayer( aLayer ) )
3744 track->TransformShapeToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
3750 footprint->TransformPadsToPolySet( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
3752 footprint->TransformFPShapesToPolySet( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE,
true,
3756 for(
const ZONE* zone : footprint->Zones() )
3758 if( zone->GetLayerSet().test( aLayer ) )
3759 zone->TransformSolidAreasShapesToPolygon( aLayer, aOutlines );
3766 if( zone->GetLayerSet().test( aLayer ) )
3767 zone->TransformSolidAreasShapesToPolygon( aLayer, aOutlines );
3773 if( !item->IsOnLayer( aLayer ) )
3776 switch( item->Type() )
3804 textbox->PCB_SHAPE::TransformShapeToPolygon( aOutlines, aLayer, 0, maxError,
ERROR_INSIDE );
3813 table->TransformGraphicItemsToPolySet( aOutlines, maxError,
ERROR_INSIDE, aRenderSettings );
3839 std::copy(
m_tracks.begin(),
m_tracks.end(), std::inserter( items, items.end() ) );
3840 std::copy(
m_zones.begin(),
m_zones.end(), std::inserter( items, items.end() ) );
3844 std::copy(
m_markers.begin(),
m_markers.end(), std::inserter( items, items.end() ) );
3845 std::copy(
m_groups.begin(),
m_groups.end(), std::inserter( items, items.end() ) );
3846 std::copy(
m_points.begin(),
m_points.end(), std::inserter( items, items.end() ) );
3857 const BOARD& other =
static_cast<const BOARD&
>( aItem );
3868 for(
auto it1 = thisNetNames.begin(), it2 = otherNetNames.begin();
3869 it1 != thisNetNames.end() && it2 != otherNetNames.end(); ++it1, ++it2 )
3873 if( it1->first != it2->first )
3908 wxArrayString ourVars;
3909 m_titles.GetContextualTextVars( &ourVars );
3911 wxArrayString otherVars;
3914 if( ourVars != otherVars )
3938 for(
PAD*
pad : footprint->Pads() )
3956 for(
PAD*
pad : footprint->Pads() )
3977 wxString projPath =
project->GetProjectPath();
3979 if( projPath.IsEmpty() )
3983 if( !projPath.IsSameAs( aProjectPath ) )
3985 wxLogTrace(
traceAutoSave, wxS(
"[history] pcb saver skipping - project path mismatch: %s vs %s" ), projPath,
3992 if( boardPath.IsEmpty() )
3996 if( !boardPath.StartsWith( projPath ) )
3998 wxLogTrace(
traceAutoSave, wxS(
"[history] pcb saver skipping - board not under project: %s" ), boardPath );
4002 wxString rel = boardPath.Mid( projPath.length() );
4017 entry.
formatMode = KICAD_FORMAT::FORMAT_MODE::COMPACT_TEXT_PROPERTIES;
4019 aFileData.push_back( std::move( entry ) );
4021 wxLogTrace(
traceAutoSave, wxS(
"[history] pcb saver serialized %zu bytes for '%s'" ),
4022 aFileData.back().content.size(), rel );
4026 wxLogTrace(
traceAutoSave, wxS(
"[history] pcb saver serialize failed: %s" ), wxString::FromUTF8( ioe.
What() ) );
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.
std::set< wxString >::iterator FindByFirstNFields(std::set< wxString > &strSet, const wxString &searchStr, char delimiter, int n)
static wxString FindVariantNameCaseInsensitive(const std::vector< wxString > &aNames, const wxString &aVariantName)
#define DEFAULT_CHAINING_EPSILON_MM
BOARD_USE
Flags to specify how the board is being used.
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
BASE_SET & reset(size_t pos)
BASE_SET & set(size_t pos)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
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.
void SetEnabledLayers(const LSET &aMask)
Change the bit-mask of enabled layers to aMask.
std::shared_ptr< NET_SETTINGS > m_NetSettings
void SetCustomTrackWidth(int aWidth)
Sets custom width for track (i.e.
void SetCustomViaSize(int aSize)
Set custom size for via diameter (i.e.
const LSET & GetEnabledLayers() const
Return a bit-mask of all the layers that are enabled.
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.
void SetUserDefinedLayerCount(int aNewLayerCount)
Set the number of user defined layers to aNewLayerCount.
BOARD_STACKUP & GetStackupDescriptor()
void SetCustomViaDrill(int aDrill)
Sets custom size for via drill (i.e.
int GetCopperLayerCount() const
int GetUserDefinedLayerCount() const
void SetCopperLayerCount(int aNewLayerCount)
Set the copper layer count to aNewLayerCount.
void SetCustomDiffPairViaGap(int aGap)
Sets custom via gap for differential pairs (i.e.
BOARD_ITEM_CONTAINER(BOARD_ITEM *aParent, KICAD_T aType)
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
virtual void SetLayerSet(const LSET &aLayers)
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
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 OnBoardRatsnestChanged(BOARD &aBoard)
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
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 * > &aBoardItems)
virtual void OnBoardCompositeUpdate(BOARD &aBoard, std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems)
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems)
Manage layers needed to make a physical board.
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
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...
ZONE * m_SolderMaskBridges
void GetContextualTextVars(wxArrayString *aVars) const
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...
BOARD_STACKUP GetStackupOrDefault() const
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_EnclosedByAreaCache
std::map< ZONE *, std::map< PCB_LAYER_ID, ISOLATED_ISLANDS > > m_ZoneIsolatedIslandsMap
PCB_LAYER_ID GetCopperLayerStackMaxId() const
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.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
PAD * GetPad(const VECTOR2I &aPosition, const LSET &aLayerMask) const
Find a pad aPosition on aLayer.
int GetUserDefinedLayerCount() const
void SetPosition(const VECTOR2I &aPos) override
std::map< wxString, wxString > m_properties
void CacheItemById(BOARD_ITEM *aItem) const
Add an item to the item-by-id cache.
std::unordered_map< const BOARD_ITEM *, wxString > m_ItemNetclassCache
EMBEDDED_FILES * GetEmbeddedFiles() override
int m_fileFormatVersionAtLoad
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
void UncacheItemById(const KIID &aId) const
Remove an item from the item-by-id cache.
void SetCurrentVariant(const wxString &aVariant)
std::vector< ZONE * > m_DRCCopperZones
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void MapNets(BOARD *aDestBoard)
Map all nets in the given board to nets with the same name (if any) in the destination board.
GAL_SET m_LegacyVisibleItems
std::vector< wxString > m_variantNames
LENGTH_DELAY_CALCULATION * GetLengthCalculation() const
Returns the track length calculator.
wxArrayString GetVariantNamesForUI() const
Return the variant names for UI display.
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.
const GENERATORS & Generators() const
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.
int m_outlinesChainingEpsilon
the max distance between 2 end point to see them connected when building the board outlines
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.
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
BOARD_USE m_boardUse
What is this board being used for.
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 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,...
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
void SetProperties(const std::map< wxString, wxString > &aProps)
bool IsBackLayer(PCB_LAYER_ID aLayer) const
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
std::map< wxString, wxString > m_variantDescriptions
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.
void UpdateBoardOutline()
const ZONES & Zones() const
void BulkRemoveStaleTeardrops(BOARD_COMMIT &aCommit)
Remove all teardrop zones with the STRUCT_DELETED flag set.
void DeleteVariant(const wxString &aVariantName)
void InvokeListeners(Func &&aFunc, Args &&... args)
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings)
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
void InitializeClearanceCache()
Initialize the clearance cache for all board items.
EMBEDDED_FILES * m_embeddedFilesDelegate
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 IsFrontLayer(PCB_LAYER_ID aLayer) const
const GROUPS & Groups() const
The groups must maintain the following invariants.
void SaveToHistory(const wxString &aProjectPath, std::vector< HISTORY_FILE_DATA > &aFileData)
Serialize board into HISTORY_FILE_DATA for non-blocking history commit.
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.
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
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...
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
bool ResolveTextVar(wxString *token, int aDepth) const
const MARKERS & Markers() const
void UncacheChildrenById(const BOARD_ITEM *aParent)
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
std::unique_ptr< class BOARD_TEXT_VAR_ADAPTER > m_textVarAdapter
TITLE_BLOCK & GetTitleBlock()
void FixupEmbeddedData()
After loading a file from disk, the footprints do not yet contain the full data for their embedded fi...
int GetMaxClearanceValue() const
Returns the maximum clearance value for any object on the board.
void InvalidateClearanceCache(const KIID &aUuid)
Invalidate the clearance cache for a specific item.
PAD * FindPadByUuid(const KIID &aUuid) const
std::unordered_map< const BOARD_ITEM *, KIID > m_cachedIdByItem
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
HIGH_LIGHT_INFO m_highLightPrevious
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.
bool HasVariant(const wxString &aVariantName) const
void AddVariant(const wxString &aVariantName)
int GetCopperLayerCount() const
std::vector< BOARD_LISTENER * > m_listeners
bool RemoveAllItemsOnLayer(PCB_LAYER_ID aLayer)
Removes all owned items other than footprints existing on the given board layer, and modifies the sta...
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsCourtyardCache
void IncrementTimeStamp()
int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet)
Fetch the coupled netname for a given net.
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsFCourtyardCache
std::unique_ptr< LENGTH_DELAY_CALCULATION > m_lengthDelayCalc
const FOOTPRINTS & Footprints() const
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
Get the list of all outline fonts used in the board.
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.
const BOARD_ITEM_SET GetItemSet()
const TRACKS & Tracks() const
int m_DRCMaxPhysicalClearance
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
BOARD_ITEM * GetCachedItemById(const KIID &aId) const
Return a cached item for aId if the entry is still self-consistent.
wxString GroupsSanityCheckInternal(bool repair)
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
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.
std::unique_ptr< COMPONENT_CLASS_MANAGER > m_componentClassManager
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...
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< const ZONE *, SHAPE_POLY_SET > m_DeflatedZoneOutlineCache
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.
bool HasItemsOnLayer(PCB_LAYER_ID aLayer)
const wxString & GetFileName() const
bool operator==(const BOARD_ITEM &aOther) const override
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
int GetPadWithCastellatedAttrCount()
wxString GetVariantDescription(const wxString &aVariantName) const
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)
std::map< PCB_LAYER_ID, std::vector< ZONE * > > m_DRCCopperZonesByLayer
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
std::shared_ptr< DRC_RTREE > m_CopperItemRTreeCache
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
void DetachAllFootprints()
Remove all footprints without deleting.
std::map< int, LAYER > m_layers
wxString GetCurrentVariant() const
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
int GetOutlinesChainingEpsilon()
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...
void ReplaceNetChainTerminalPad(const wxString &aNetChain, const KIID &aPrev, const KIID &aNew)
void UncacheItemByPtr(const BOARD_ITEM *aItem)
Remove every cache entry that still points to aItem.
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.
wxString m_currentVariant
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
int GetPadWithPressFitAttrCount()
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.
void RenameVariant(const wxString &aOldName, const wxString &aNewName)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::vector< ZONE * > m_DRCZones
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
void RebindItemUuid(BOARD_ITEM *aItem, const KIID &aNewId)
Rebind the UUID of an attached item and keep the item-by-id cache coherent.
int RepairDuplicateItemUuids()
Rebind duplicate attached-item UUIDs so each live board item has a unique ID.
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
std::unordered_map< KIID, BOARD_ITEM * > m_itemByIdCache
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
std::shared_mutex m_CachesMutex
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aPhysicalLayersOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
bool SynchronizeComponentClasses(const std::unordered_set< wxString > &aNewSheetPaths) const
Copy component class / component class generator information from the project settings.
BOARD_ITEM * CacheAndReturnItemById(const KIID &aId, BOARD_ITEM *aItem) const
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< wxString, std::vector< ZONE * > > m_ZonesByNameCache
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_IntersectsAreaCache
std::optional< int > m_maxClearanceValue
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
void SetEnabledLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void CacheChildrenById(const BOARD_ITEM *aParent)
void SynchronizeTuningProfileProperties()
Ensure that all time domain properties providers are in sync with current settings.
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
bool m_LegacyCopperEdgeClearanceLoaded
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 SetVariantDescription(const wxString &aVariantName, const wxString &aDescription)
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.
void EmbedFonts() override
Finds all fonts used in the board and embeds them in the file if permissions allow.
PCB_BOARD_OUTLINE * m_boardOutline
void SetUserDefinedLayerCount(int aCount)
const DRAWINGS & Drawings() const
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr size_type GetHeight() const
BOARD_CONNECTED_ITEM * Parent() const
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
int GetCount() const
Return the number of objects in the list.
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
A class to manage Component Classes in a board context.
void RunOnUnconnectedEdges(std::function< bool(CN_EDGE &)> aFunc)
unsigned int GetUnconnectedCount(bool aVisibileOnly) const
static DELETED_BOARD_ITEM * GetInstance()
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
virtual VECTOR2I GetPosition() const
virtual void ClearEditFlags()
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
static INSPECT_RESULT IterateForward(std::deque< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
This changes first parameter to avoid the DList and use the main queue instead.
virtual INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
int Compare(const EDA_SHAPE *aOther) const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
EMBEDDED_FILE * GetEmbeddedFile(const wxString &aName) const
Returns the embedded file with the given name or nullptr if it does not exist.
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
const std::map< wxString, EMBEDDED_FILE * > & EmbeddedFileMap() const
Helper for storing and iterating over GAL_LAYER_IDs.
static GAL_SET DefaultVisible()
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.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
FONT is an abstract base class for both outline and stroke fonts.
virtual bool IsOutline() const
Class OUTLINE_FONT implements outline font drawing.
EMBEDDING_PERMISSION GetEmbeddingPermission() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsBOARD_ITEM() const
virtual wxString GetClass() const =0
Return the class name.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
wxString AsString() const
Lightweight class which holds a pad, via, or a routed trace outline.
TYPE Type() const
Gets the routing item type.
Class which calculates lengths (and associated routing statistics) in a BOARD context.
LENGTH_DELAY_CALCULATION_ITEM GetLengthCalculationItem(const BOARD_CONNECTED_ITEM *aBoardItem) const
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM.
LENGTH_DELAY_STATS CalculateLengthDetails(std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr, LENGTH_DELAY_LAYER_OPT aLayerOpt=LENGTH_DELAY_LAYER_OPT::NO_LAYER_DETAIL, LENGTH_DELAY_DOMAIN_OPT aDomain=LENGTH_DELAY_DOMAIN_OPT::NO_DELAY_DETAIL) const
Calculates the electrical length of the given items.
LSET is a set of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
std::shared_ptr< RC_ITEM > GetRCItem() const
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
void SetParent(JSON_SETTINGS *aParent, bool aLoadFromFile=true)
static const char Default[]
the name of the default NETCLASS
void SetDescription(const wxString &aDesc)
Handle the data for a net.
wxString GetClass() const override
Return the class name.
const wxString & GetNetname() const
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
static const int ORPHANED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
static NETINFO_ITEM * OrphanedItem()
NETINFO_ITEM meaning that there was no net assigned for an item, as there was no board storing net li...
unsigned GetNetCount() const
const NETNAMES_MAP & NetsByName() const
Return the name map, at least for python.
void ClearAllCaches()
Clears the effective netclass cache for all nets.
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const wxString &aNetName)
Fetches the effective (may be aggregate) netclass for the given net name.
std::shared_ptr< NETCLASS > GetDefaultNetclass()
Gets the default netclass for the project.
void SetDefaultNetclass(std::shared_ptr< NETCLASS > netclass)
Sets the default netclass for the project Calling user is responsible for resetting the effective net...
VECTOR2I GetPosition() const override
const VECTOR2D & GetSizeMils() const
wxPrintOrientation GetWxOrientation() const
static double GetCustomHeightMils()
wxPaperSize GetPaperId() const
static double GetCustomWidthMils()
static int Compare(const PCB_BARCODE *aBarcode, const PCB_BARCODE *aOther)
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool ignoreLineWidth=false) const override
Convert the barcode (text + symbol shapes) to polygonal geometry suitable for filling/collision tests...
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
DIM_UNITS_MODE GetUnitsMode() const
A set of BOARD_ITEMs (i.e., without duplicates).
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
void FormatBoardToFormatter(OUTPUTFORMATTER *aOut, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr)
Serialize a BOARD to an OUTPUTFORMATTER without file I/O or Prettify.
Collect all BOARD_ITEM objects on a given layer.
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Test a BOARD_ITEM using this class's Inspector method, which does the collection.
void SetLayerId(PCB_LAYER_ID aLayerId)
static PCB_MARKER * DeserializeFromString(const wxString &data)
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
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.
static int Compare(const PCB_TABLE *aTable, const PCB_TABLE *aOther)
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, 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)
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.
std::shared_ptr< COMPONENT_CLASS_SETTINGS > & ComponentClassSettings()
Container for project specific data.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual PROJECT_FILE & GetProjectFile() const
std::vector< KIID > GetIDs() const
Represent a set of closed polygons.
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
int OutlineCount() const
Return the number of outlines in the set.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
std::function< void(std::function< void()>)> TASK_SUBMITTER
Callback that submits a unit of work for asynchronous execution.
const wxString & GetComment(int aIdx) const
static void GetContextualTextVars(wxArrayString *aVars)
Handle a list of polygons defining a copper zone.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
bool SetNetCode(int aNetCode, bool aNoAssert) override
Override that clamps the netcode to 0 when this zone is in copper-thieving fill mode.
bool IsTeardropArea() const
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, bool aInferOutlineIfNecessary, OUTLINE_ERROR_HANDLER *aErrorHandler, bool aAllowUseArcsInPolygons)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
static bool empty(const wxTextEntryBase *aCtrl)
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
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
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ GAL_LAYER_ID_BITMASK_END
This is the end of the layers used for visibility bit masks in legacy board files.
@ LAYER_FOOTPRINTS_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)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
std::map< wxString, NETINFO_ITEM * > NETNAMES_MAP
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ PRESSFIT
a PTH with a hole diameter with tight tolerances for press fit pin
@ CASTELLATED
a pad with a castellated through hole
BARCODE class definition.
Class to handle a set of BOARD_ITEMs.
std::deque< PCB_TRACK * > TRACKS
Class that computes missing connections on a PCB.
wxString GetDefaultVariantName()
int SortVariantNames(const wxString &aLhs, const wxString &aRhs)
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
std::vector< char > decompressedData
std::string compressedEncodedData
Data produced by a registered saver on the UI thread, consumed by either the background local-history...
std::string content
Serialized content (mutually exclusive with sourcePath)
KICAD_FORMAT::FORMAT_MODE formatMode
wxString relativePath
Destination path relative to the project root.
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.
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Holds length measurement result details and statistics.
Struct to control which optimisations the length calculation code runs on the given path objects.
static const long long MM
std::vector< std::vector< std::string > > table
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::priority_thread_pool thread_pool
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ 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_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ 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_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
@ 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
VECTOR2< int32_t > VECTOR2I
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.