59 m_commit( aFrame->GetToolManager() ),
86 const wxString previous = net->GetNetChain();
89 if( !previous.IsEmpty() &&
next.IsEmpty() && aReporter && !aDryRun )
93 _(
"Net chain assignment '%s' on net '%s' cleared by netlist "
95 previous, net->GetNetname() ),
101 net->SetNetChain(
next );
103 if( previous !=
next )
105 for(
int i = 0; i < 2; ++i )
106 net->ClearTerminalPad( i );
120 netSettings->ClearNetChainClasses();
121 netSettings->ClearNetChainNetClasses();
124 netSettings->SetNetChainClass(
chain, className );
127 netSettings->SetNetChainNetClass(
chain, netclass );
189 bestPosition.
x = pageSize.
x / 2;
190 bestPosition.
y = pageSize.
y / 2;
207 if( aFootprintId.
empty() )
209 msg.Printf(
_(
"Cannot add %s (no footprint assigned)." ),
218 if( footprint ==
nullptr )
220 msg.Printf(
_(
"Cannot add %s (footprint '%s' not found)." ),
229 m_board->GetComponentClassManager().GetNoneComponentClass() );
233 msg.Printf(
_(
"Add %s (footprint '%s')." ),
244 bool showRatsnest =
true;
247 showRatsnest =
m_settings->m_Display.m_ShowGlobalRatsnest;
249 pad->SetLocalRatsnestVisible( showRatsnest );
252 pad->SetNetCode( 0 );
268 msg.Printf(
_(
"Added %s (footprint '%s')." ),
281 wxString curClassName, newClassName;
285 curClassName = curClass->
GetName();
295 newClass =
m_board->GetComponentClassManager().GetEffectiveStaticComponentClass(
297 newClassName = newClass->
GetName();
300 if( curClassName == newClassName )
309 copy->SetParentGroup(
nullptr );
316 if( curClassName == wxEmptyString && newClassName != wxEmptyString )
318 msg.Printf(
_(
"Change %s component class to '%s'." ),
322 else if( curClassName != wxEmptyString && newClassName == wxEmptyString )
324 msg.Printf(
_(
"Remove %s component class (currently '%s')." ),
330 msg.Printf(
_(
"Change %s component class from '%s' to '%s'." ),
338 wxASSERT_MSG( newClass !=
nullptr,
"Component class should not be nullptr" );
342 if( curClassName == wxEmptyString && newClassName != wxEmptyString )
344 msg.Printf(
_(
"Changed %s component class to '%s'." ),
348 else if( curClassName != wxEmptyString && newClassName == wxEmptyString )
350 msg.Printf(
_(
"Removed %s component class (was '%s')." ),
356 msg.Printf(
_(
"Changed %s component class from '%s' to '%s'." ),
379 msg.Printf(
_(
"Cannot update %s (no footprint assigned)." ),
388 if( newFootprint ==
nullptr )
390 msg.Printf(
_(
"Cannot update %s (footprint '%s' not found)." ),
402 msg.Printf(
_(
"Cannot change %s footprint from '%s' to '%s' (footprint is locked)."),
413 msg.Printf(
_(
"Change %s footprint from '%s' to '%s'."),
427 msg.Printf(
_(
"Could not change %s footprint from '%s' to '%s' (footprint is locked)."),
442 m_frame->GetPcbNewSettings()->m_FlipDirection,
true );
444 msg.Printf(
_(
"Changed %s footprint from '%s' to '%s'."),
470 firstAssociatedVariant = &
test;
479 if( !
m_commit.GetStatus( aFootprint ) )
482 copy->SetParentGroup(
nullptr );
485 bool changed =
false;
492 msg.Printf(
_(
"Change %s reference designator to %s." ),
498 msg.Printf(
_(
"Changed %s reference designator to %s." ),
512 if( firstAssociatedVariant !=
nullptr
522 msg.Printf(
_(
"Change %s value from %s to %s." ),
529 msg.Printf(
_(
"Changed %s value from %s to %s." ),
544 if( !aNetlistComponent->
GetKIIDs().empty() )
545 new_path.push_back( aNetlistComponent->
GetKIIDs().front() );
547 if( aFootprint->
GetPath() != new_path )
551 msg.Printf(
_(
"Update %s symbol association from %s to %s." ),
558 msg.Printf(
_(
"Updated %s symbol association from %s to %s." ),
564 aFootprint->
SetPath( new_path );
570 nlohmann::ordered_map<wxString, wxString> fpFieldsAsMap;
575 if( field->IsReference() || field->IsValue() || field->IsComponentClass() )
580 fpFieldsAsMap[field->GetName()] = field->GetText();
583 nlohmann::ordered_map<wxString, wxString> compFields = aNetlistComponent->
GetFields();
585 if( firstAssociatedVariant !=
nullptr )
587 for(
const auto& [
name, value] : firstAssociatedVariant->
m_fields )
588 compFields[
name] = value;
597 compFields.erase( wxT(
"Component Class" ) );
602 bool remove_only =
true;
604 for(
const auto& [
name, value] : compFields )
606 if( fpFieldsAsMap.count(
name ) == 0 || fpFieldsAsMap[
name] != value )
614 for(
const auto& [
name, value] : fpFieldsAsMap )
616 if( compFields.count(
name ) == 0 )
629 msg.Printf(
_(
"Update %s fields." ), aFootprint->
GetReference() );
636 if( field->IsMandatory() )
639 if( compFields.count( field->GetName() ) == 0 )
643 msg.Printf(
_(
"Remove %s footprint fields not in symbol." ), aFootprint->
GetReference() );
655 msg.Printf(
_(
"Updated %s fields." ), aFootprint->
GetReference() );
661 for(
auto& [
name, value] : compFields )
670 aFootprint->
Add( newField );
691 std::vector<PCB_FIELD*> fieldList;
692 aFootprint->
GetFields( fieldList,
false );
696 if( field->IsMandatory() )
699 if( compFields.count( field->GetName() ) == 0 )
704 msg.Printf(
_(
"Removed %s footprint fields not in symbol." ), aFootprint->
GetReference() );
708 aFootprint->
Remove( field );
711 m_frame->GetCanvas()->GetView()->Remove( field );
726 if( !humanSheetPath.empty() )
727 sheetname = humanSheetPath;
728 else if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetname" ) ) > 0 )
729 sheetname = aNetlistComponent->
GetProperties().at( wxT(
"Sheetname" ) );
731 if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetfile" ) ) > 0 )
732 sheetfile = aNetlistComponent->
GetProperties().at( wxT(
"Sheetfile" ) );
734 if( aNetlistComponent->
GetProperties().count( wxT(
"ki_fp_filters" ) ) > 0 )
735 fpFilters = aNetlistComponent->
GetProperties().at( wxT(
"ki_fp_filters" ) );
741 msg.Printf(
_(
"Update %s sheetname to '%s'." ),
747 msg.Printf(
_(
"Updated %s sheetname to '%s'." ),
762 msg.Printf(
_(
"Update %s sheetfile to '%s'." ),
768 msg.Printf(
_(
"Updated %s sheetfile to '%s'." ),
783 msg.Printf(
_(
"Update %s footprint filters to '%s'." ),
789 msg.Printf(
_(
"Updated %s footprint filters to '%s'." ),
800 bool netlistExcludeFromBOM = aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) > 0;
809 if( netlistExcludeFromBOM )
810 msg.Printf(
_(
"Add %s 'exclude from BOM' fabrication attribute." ), aFootprint->
GetReference() );
812 msg.Printf(
_(
"Remove %s 'exclude from BOM' fabrication attribute." ), aFootprint->
GetReference() );
818 if( netlistExcludeFromBOM )
821 msg.Printf(
_(
"Added %s 'exclude from BOM' fabrication attribute." ), aFootprint->
GetReference() );
826 msg.Printf(
_(
"Removed %s 'exclude from BOM' fabrication attribute." ), aFootprint->
GetReference() );
836 bool netlistExcludeFromSim = aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_sim" ) ) > 0;
846 if( netlistExcludeFromSim )
847 msg.Printf(
_(
"Add %s 'exclude from simulation' attribute." ), aFootprint->
GetReference() );
849 msg.Printf(
_(
"Remove %s 'exclude from simulation' attribute." ), aFootprint->
GetReference() );
855 if( netlistExcludeFromSim )
858 msg.Printf(
_(
"Added %s 'exclude from simulation' attribute." ), aFootprint->
GetReference() );
863 msg.Printf(
_(
"Removed %s 'exclude from simulation' attribute." ), aFootprint->
GetReference() );
873 bool netlistDNP = aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) > 0;
875 if( firstAssociatedVariant !=
nullptr && firstAssociatedVariant->
m_hasDnp )
876 netlistDNP = firstAssociatedVariant->
m_dnp;
883 msg.Printf(
_(
"Add %s 'Do not place' fabrication attribute." ), aFootprint->
GetReference() );
885 msg.Printf(
_(
"Remove %s 'Do not place' fabrication attribute." ), aFootprint->
GetReference() );
894 msg.Printf(
_(
"Added %s 'Do not place' fabrication attribute." ), aFootprint->
GetReference() );
899 msg.Printf(
_(
"Removed %s 'Do not place' fabrication attribute." ), aFootprint->
GetReference() );
909 bool netlistExcludeFromPosFiles = aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_pos_files" ) ) > 0;
919 if( netlistExcludeFromPosFiles )
921 msg.Printf(
_(
"Add %s 'exclude from position files' fabrication attribute." ),
926 msg.Printf(
_(
"Remove %s 'exclude from position files' fabrication attribute." ),
934 if( netlistExcludeFromPosFiles )
937 msg.Printf(
_(
"Added %s 'exclude from position files' fabrication attribute." ),
943 msg.Printf(
_(
"Removed %s 'exclude from position files' fabrication attribute." ),
966 msg.Printf(
_(
"Added %s 'duplicate pad numbers are jumpers' attribute." ),
971 msg.Printf(
_(
"Removed %s 'duplicate pad numbers are jumpers' attribute." ),
979 msg.Printf(
_(
"Add %s 'duplicate pad numbers are jumpers' attribute." ),
984 msg.Printf(
_(
"Remove %s 'duplicate pad numbers are jumpers' attribute." ),
998 msg.Printf(
_(
"Updated %s jumper pad groups" ), aFootprint->
GetReference() );
1002 msg.Printf(
_(
"Update %s jumper pad groups" ), aFootprint->
GetReference() );
1008 if( changed &&
copy )
1021 if(
group->m_Uuid == aUuid )
1050 KIID existingGroupKIID = existingGroup ? existingGroup->
m_Uuid : 0;
1053 if( newGroupKIID == existingGroupKIID )
1064 copy->SetParentGroup(
nullptr );
1067 bool changed =
false;
1074 if( existingGroupKIID != 0 )
1078 msg.Printf(
_(
"Remove %s from group '%s'." ),
1084 msg.Printf(
_(
"Removed %s from group '%s'." ),
1092 if( existingGroup->
GetItems().size() < 2 )
1103 if( newGroupKIID != 0 )
1107 msg.Printf(
_(
"Add %s to group '%s'." ),
1113 msg.Printf(
_(
"Added %s to group '%s'." ),
1119 if( newGroup ==
nullptr )
1128 newGroup->
AddItem( aPcbFootprint );
1134 if( changed &&
copy )
1153 copy->SetParentGroup(
nullptr );
1156 bool changed =
false;
1159 std::deque<PAD*> pads = aFootprint->
Pads();
1160 std::set<wxString> padNetnames;
1162 std::sort( pads.begin(), pads.end(),
1165 return a->m_Uuid < b->m_Uuid;
1172 wxLogTrace( wxT(
"NETLIST_UPDATE" ),
1173 wxT(
"Processing pad %s of component %s" ),
1177 wxString pinFunction;
1182 wxLogTrace( wxT(
"NETLIST_UPDATE" ),
1183 wxT(
" Found valid net: %s" ),
1190 wxLogTrace( wxT(
"NETLIST_UPDATE" ),
1191 wxT(
" No net found for pad %s" ),
1197 if(
pad->GetPinFunction() != pinFunction )
1200 pad->SetPinFunction( pinFunction );
1203 if(
pad->GetPinType() != pinType )
1206 pad->SetPinType( pinType );
1215 if( !net.
IsValid() || !
pad->IsOnCopperLayer() )
1217 if( !
pad->GetNetname().IsEmpty() )
1221 msg.Printf(
_(
"Disconnect %s pin %s." ),
1227 msg.Printf(
_(
"Disconnected %s pin %s." ),
1234 else if(
pad->IsOnCopperLayer() && !
pad->GetNumber().IsEmpty() )
1237 msg.Printf(
_(
"No net found for component %s pad %s (no pin %s in symbol)." ),
1255 if(
pad->GetNetname().IsEmpty() && !
pad->GetPinFunction().IsEmpty() )
1258 pad->SetPinFunction( wxEmptyString );
1270 if(
pad->IsNoConnectPad() )
1272 netName = wxString::Format( wxS(
"%s" ), net.
GetNetName() );
1274 for(
int jj = 1; !padNetnames.insert( netName ).second
1278 netName = wxString::Format( wxS(
"%s_%d" ), net.
GetNetName(), jj );
1287 if(
pad->GetNetname() != netName )
1290 if( netinfo ==
nullptr )
1297 if( netinfo ==
nullptr )
1309 msg.Printf(
_(
"Add net %s." ),
1314 if( !
pad->GetNetname().IsEmpty() )
1320 msg.Printf(
_(
"Reconnect %s pin %s from %s to %s."),
1328 msg.Printf(
_(
"Reconnected %s pin %s from %s to %s."),
1339 msg.Printf(
_(
"Connect %s pin %s to %s."),
1346 msg.Printf(
_(
"Connected %s pin %s to %s."),
1358 pad->SetNet( netinfo );
1368 if( changed &&
copy )
1380 std::vector<FOOTPRINT::FP_UNIT_INFO> newUnits;
1383 newUnits.push_back( { u.m_unitName, u.m_pins } );
1385 const std::vector<FOOTPRINT::FP_UNIT_INFO>& curUnits = aFootprint->
GetUnitInfo();
1387 if( std::ranges::equal( curUnits, newUnits,
1388 [](
const auto& a,
const auto& b )
1390 return a.m_unitName == b.m_unitName && a.m_pins == b.m_pins;
1398 msg.Printf(
_(
"Update %s unit metadata." ), aFootprint->
GetReference() );
1406 if( !
m_commit.GetStatus( aFootprint ) )
1409 copy->SetParentGroup(
nullptr );
1414 msg.Printf(
_(
"Updated %s unit metadata." ), aFootprint->
GetReference() );
1429 return aBoardFpid == aSchematicFpid;
1434 const std::vector<FOOTPRINT*>& aFootprints,
1435 const LIB_ID& aBaseFpid )
1440 if( aBaseFpid.
empty() )
1452 std::vector<VARIANT_INFO> variantInfo;
1453 variantInfo.reserve( variants.size() );
1455 for(
const auto& [variantName, variant] : variants )
1457 LIB_ID variantFPID = aBaseFpid;
1459 auto fieldIt = variant.m_fields.find( FOOTPRINT_FIELD_NAME );
1461 if( fieldIt != variant.m_fields.end() && !fieldIt->second.IsEmpty() )
1465 if( parsedId.
Parse( fieldIt->second,
true ) >= 0 )
1467 msg.Printf(
_(
"Invalid footprint ID '%s' for variant '%s' on %s." ),
1476 variantFPID = parsedId;
1480 variantInfo.push_back( { variantName, &variant, variantFPID } );
1483 for(
FOOTPRINT* footprint : aFootprints )
1493 copy->SetParentGroup(
nullptr );
1496 bool changed =
false;
1498 auto printAttributeMessage =
1499 [&](
bool add,
const wxString& attrName,
const wxString& variantName )
1503 if( aFootprints.size() > 1 )
1505 msg.Printf( add ?
_(
"Add %s '%s' attribute to variant %s (footprint %s)." )
1506 :
_(
"Remove %s '%s' attribute from variant %s (footprint %s)." ),
1507 footprint->GetReference(),
1510 footprint->GetFPIDAsString() );
1514 msg.Printf( add ?
_(
"Add %s '%s' attribute to variant %s." )
1515 :
_(
"Remove %s '%s' attribute from variant %s." ),
1516 footprint->GetReference(),
1523 if( aFootprints.size() > 1 )
1525 msg.Printf( add ?
_(
"Added %s '%s' attribute to variant %s (footprint %s)." )
1526 :
_(
"Removed %s '%s' attribute from variant %s (footprint %s)." ),
1527 footprint->GetReference(),
1530 footprint->GetFPIDAsString() );
1534 msg.Printf( add ?
_(
"Added %s '%s' attribute to variant %s." )
1535 :
_(
"Removed %s '%s' attribute from variant %s." ),
1536 footprint->GetReference(),
1543 bool isBaseFootprint =
fpidsEquivalent( footprint->GetFPID(), aBaseFpid );
1548 const bool baseFootprintDnp = footprint->IsDNP();
1549 bool effectiveFootprintDnp = baseFootprintDnp;
1556 if( !isBaseFootprint && !effectiveFootprintDnp )
1558 msg.Printf(
m_isDryRun ?
_(
"Add %s 'Do not place' fabrication attribute." )
1559 :
_(
"Added %s 'Do not place' fabrication attribute." ),
1560 footprint->GetReference() );
1565 footprint->SetDNP(
true );
1569 effectiveFootprintDnp =
true;
1573 std::set<wxString> excessVariants;
1575 for(
const auto& [variantName,
_] : footprint->GetVariants() )
1576 excessVariants.insert( variantName );
1578 for(
const VARIANT_INFO&
info : variantInfo )
1590 if( !isAssociatedFootprint && aFootprints.size() <= 1 )
1593 excessVariants.erase(
info.name );
1594 bool targetDnp = variant.
m_hasDnp ? variant.
m_dnp : baseFootprintDnp;
1595 bool currentDnp = currentVariant ? currentVariant->
GetDNP() : effectiveFootprintDnp;
1601 if( !isAssociatedFootprint )
1604 if( currentDnp != targetDnp )
1606 printAttributeMessage( targetDnp,
_(
"Do not place" ),
info.name );
1611 fpVariant->SetDNP( targetDnp );
1619 : footprint->IsExcludedFromBOM();
1621 : footprint->IsExcludedFromBOM();
1623 if( currentExcludedFromBOM != targetExcludedFromBOM )
1625 printAttributeMessage( targetExcludedFromBOM,
_(
"exclude from BOM" ),
info.name );
1630 fpVariant->SetExcludedFromBOM( targetExcludedFromBOM );
1638 : footprint->IsExcludedFromSim();
1640 : footprint->IsExcludedFromSim();
1642 if( currentExcludedFromSim != targetExcludedFromSim )
1644 printAttributeMessage( targetExcludedFromSim,
_(
"exclude from simulation" ),
info.name );
1649 fpVariant->SetExcludedFromSim( targetExcludedFromSim );
1657 : footprint->IsExcludedFromPosFiles();
1659 : footprint->IsExcludedFromPosFiles();
1661 if( currentExcludedFromPosFiles != targetExcludedFromPosFiles )
1663 printAttributeMessage( targetExcludedFromPosFiles,
_(
"exclude from position files" ),
info.name );
1668 fpVariant->SetExcludedFromPosFiles( targetExcludedFromPosFiles );
1677 std::map<wxString, wxString> fpFieldsAsMap;
1679 for(
PCB_FIELD* field : footprint->GetFields() )
1680 fpFieldsAsMap[field->GetName()] = field->GetText();
1682 for(
const auto& [fieldName, fieldValue] : variant.
m_fields )
1684 if( fieldName.CmpNoCase( FOOTPRINT_FIELD_NAME ) == 0 )
1687 wxString currentValue;
1689 if( currentVariant && currentVariant->
HasFieldValue( fieldName ) )
1692 currentValue = fpFieldsAsMap[fieldName];
1694 fpFieldsAsMap.erase( fieldName );
1696 if( currentValue != fieldValue )
1700 if( aFootprints.size() > 1 )
1702 msg.Printf(
_(
"Change %s field '%s' to '%s' on variant %s (footprint %s)." ),
1703 footprint->GetReference(),
1707 footprint->GetFPIDAsString() );
1711 msg.Printf(
_(
"Change %s field '%s' to '%s' on variant %s." ),
1712 footprint->GetReference(),
1720 if( aFootprints.size() > 1 )
1722 msg.Printf(
_(
"Changed %s field '%s' to '%s' on variant %s (footprint %s)." ),
1723 footprint->GetReference(),
1727 footprint->GetFPIDAsString() );
1731 msg.Printf(
_(
"Changed %s field '%s' to '%s' on variant %s." ),
1732 footprint->GetReference(),
1739 fpVariant->SetFieldValue( fieldName, fieldValue );
1749 for(
const auto& [fieldName, fieldValue] : fpFieldsAsMap )
1751 if( fieldName.CmpNoCase( FOOTPRINT_FIELD_NAME ) == 0 )
1754 if( currentVariant && currentVariant->
HasFieldValue( fieldName ) )
1758 if( aFootprints.size() > 1 )
1760 msg.Printf(
_(
"Remove %s field '%s' override on variant %s (footprint %s)." ),
1761 footprint->GetReference(),
1764 footprint->GetFPIDAsString() );
1768 msg.Printf(
_(
"Remove %s field '%s' override on variant %s." ),
1769 footprint->GetReference(),
1776 if( aFootprints.size() > 1 )
1778 msg.Printf(
_(
"Removed %s field '%s' override on variant %s (footprint %s)." ),
1779 footprint->GetReference(),
1782 footprint->GetFPIDAsString() );
1786 msg.Printf(
_(
"Removed %s field '%s' override on variant %s." ),
1787 footprint->GetReference(),
1802 for(
const wxString& excess : excessVariants )
1806 msg.Printf(
_(
"Remove variant %s:%s no longer associated with footprint %s." ),
1807 footprint->GetReference(),
1809 footprint->GetFPIDAsString() );
1813 msg.Printf(
_(
"Removed variant %s:%s no longer associated with footprint %s." ),
1814 footprint->GetReference(),
1816 footprint->GetFPIDAsString() );
1818 footprint->DeleteVariant( excess );
1837 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
1848 std::set<wxString> netlistNetnames;
1850 for(
int ii = 0; ii < (int) aNetlist.
GetCount(); ii++ )
1854 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
1866 if( netlistNetnames.count(
via->GetNetname() ) == 0 )
1868 wxString updatedNetname = wxEmptyString;
1877 if( !updatedNetname.IsEmpty() )
1881 wxString originalNetname =
via->GetNetname();
1883 msg.Printf(
_(
"Reconnect via from %s to %s." ),
1898 wxString originalNetname =
via->GetNetname();
1901 via->SetNet( netinfo );
1903 msg.Printf(
_(
"Reconnected via from %s to %s." ),
1913 msg.Printf(
_(
"Via connected to unknown net (%s)." ),
1925 auto isInNetlist = [&](
const wxString& aNetName ) ->
bool
1927 if( netlistNetnames.count( aNetName ) )
1932 for(
const wxString& netName : netlistNetnames )
1934 if( aNetName.StartsWith( netName ) )
1944 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
1947 if( !isInNetlist( zone->GetNetname() ) )
1952 wxString updatedNetname = wxEmptyString;
1965 if( updatedNetname.IsEmpty() &&
m_oldToNewNets.count( zone->GetNetname() ) )
1970 if( !updatedNetname.IsEmpty() )
1974 wxString originalNetname = zone->GetNetname();
1976 if( !zone->GetZoneName().IsEmpty() )
1978 msg.Printf(
_(
"Reconnect copper zone '%s' from %s to %s." ),
1979 zone->GetZoneName(),
1985 msg.Printf(
_(
"Reconnect copper zone from %s to %s." ),
2001 wxString originalNetname = zone->GetNetname();
2004 zone->SetNet( netinfo );
2006 if( !zone->GetZoneName().IsEmpty() )
2008 msg.Printf(
_(
"Reconnected copper zone '%s' from %s to %s." ),
2015 msg.Printf(
_(
"Reconnected copper zone from %s to %s." ),
2026 if( !zone->GetZoneName().IsEmpty() )
2028 msg.Printf(
_(
"Copper zone '%s' has no pads connected." ),
2033 wxString layerNames = zone->LayerMaskDescribe();
2038 if(
m_settings->m_Display.m_DisplayInvertXAxis )
2041 if(
m_settings->m_Display.m_DisplayInvertYAxis )
2045 msg.Printf(
_(
"Copper zone on %s at (%s, %s) has no pads connected to net \"%s\"." ),
2055 zone->GetNetname() );
2075 for(
size_t ii = 0; ii <
m_board->Groups().size(); ++ii )
2080 if( !childNetlistGroup )
2090 msg.Printf(
_(
"Add group '%s' to group '%s'." ),
EscapeHTML( childGroup->
GetName() ),
2103 if( netlistGroup ==
nullptr )
2106 if( netlistGroup->
name != pcbGroup->GetName() )
2110 msg.Printf(
_(
"Change group name from '%s' to '%s'." ),
2116 msg.Printf(
_(
"Changed group name from '%s' to '%s'." ),
2120 pcbGroup->SetName( netlistGroup->
name );
2126 if( netlistGroup->
libId != pcbGroup->GetDesignBlockLibId() )
2130 msg.Printf(
_(
"Change group library link from '%s' to '%s'." ),
2131 EscapeHTML( pcbGroup->GetDesignBlockLibId().GetUniStringLibId() ),
2136 msg.Printf(
_(
"Changed group library link from '%s' to '%s'." ),
2137 EscapeHTML( pcbGroup->GetDesignBlockLibId().GetUniStringLibId() ),
2140 pcbGroup->SetDesignBlockLibId( netlistGroup->
libId );
2157 if( !childGroup || childGroup == pcbGroup || childGroup->
GetParentGroup() == pcbGroup )
2164 msg.Printf(
_(
"Add group '%s' to group '%s'." ),
EscapeHTML( childGroup->
GetName() ),
2169 msg.Printf(
_(
"Added group '%s' to group '%s'." ),
EscapeHTML( childGroup->
GetName() ),
2173 pcbGroup->AddItem( childGroup );
2187 if( !childNetlistGroup || !childGroup->GetParentGroup() )
2193 if( !parentNetlistGroup )
2196 const std::vector<KIID_PATH>& members = parentNetlistGroup->
members;
2198 if( std::find( members.begin(), members.end(), childNetlistGroup->
path ) != members.end() )
2203 msg.Printf(
_(
"Remove group '%s' from group '%s'." ),
EscapeHTML( childGroup->GetName() ),
2208 msg.Printf(
_(
"Removed group '%s' from group '%s'." ),
EscapeHTML( childGroup->GetName() ),
2223 std::map<COMPONENT*, FOOTPRINT*>& aFootprintMap )
2231 for(
int i = 0; i < (int) aNetlist.
GetCount(); i++ )
2234 FOOTPRINT* footprint = aFootprintMap[component];
2240 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
2244 if( padNumber.IsEmpty() )
2247 msg.Printf(
_(
"Symbol %s has pins with no number. These pins can not be matched "
2257 msg.Printf(
_(
"%s pad %s not found in %s." ),
2273 FOOTPRINT* lastPreexistingFootprint =
nullptr;
2276 std::unordered_set<wxString> sheetPaths;
2277 std::unordered_set<FOOTPRINT*> usedFootprints;
2283 std::map<COMPONENT*, FOOTPRINT*> footprintMap;
2285 if( !
m_board->Footprints().empty() )
2286 lastPreexistingFootprint =
m_board->Footprints().back();
2296 net->SetIsCurrent( net->GetNetCode() == 0 );
2298 m_board->GetComponentClassManager().InitNetlistUpdate();
2302 for(
unsigned ii = 0; ii < aNetlist.
GetCount(); ii++ )
2306 for(
unsigned jj = 0; jj <
comp->GetNetCount(); jj++ )
2313 for(
unsigned i = 0; i < aNetlist.
GetCount(); i++ )
2317 if( component->
GetProperties().count( wxT(
"exclude_from_board" ) ) )
2320 msg.Printf(
_(
"Processing symbol '%s:%s'." ),
2326 const bool hasBaseFpid = !baseFpid.
empty();
2330 msg.Printf(
_(
"Warning: %s footprint '%s' is missing a library name. "
2331 "Use the full 'Library:Footprint' format to avoid repeated update "
2339 std::vector<FOOTPRINT*> matchingFootprints;
2350 base.push_back( uuid );
2352 if( footprint->GetPath() == base )
2361 match = footprint->GetReference().CmpNoCase( component->
GetReference() ) == 0;
2366 if( footprint->IsBoardOnly() )
2368 msg.Printf(
_(
"Found a footprint matching %s, but the footprint's 'Not in schematic' "
2369 "flag indicates there should be no matching symbol." ),
2376 matchingFootprints.push_back( footprint );
2380 if( footprint == lastPreexistingFootprint )
2387 std::vector<LIB_ID> expectedFpids;
2388 std::unordered_set<wxString> expectedFpidKeys;
2390 auto addExpectedFpid =
2391 [&](
const LIB_ID& aFpid )
2396 wxString key = aFpid.Format();
2398 if( expectedFpidKeys.insert( key ).second )
2399 expectedFpids.push_back( aFpid );
2402 addExpectedFpid( baseFpid );
2406 for(
const auto& [variantName, variant] : component->
GetVariants() )
2408 auto fieldIt = variant.m_fields.find( footprintFieldName );
2410 if( fieldIt == variant.m_fields.end() || fieldIt->second.IsEmpty() )
2415 if( parsedId.
Parse( fieldIt->second,
true ) >= 0 )
2417 msg.Printf(
_(
"Invalid footprint ID '%s' for variant '%s' on %s." ),
2426 addExpectedFpid( parsedId );
2429 auto isExpectedFpid =
2430 [&](
const LIB_ID& aFpid ) ->
bool
2435 if( expectedFpidKeys.count( aFpid.Format() ) > 0 )
2447 auto takeMatchingFootprint =
2450 for(
FOOTPRINT* footprint : matchingFootprints )
2452 if( usedFootprints.count( footprint ) )
2462 std::vector<FOOTPRINT*> componentFootprints;
2463 componentFootprints.reserve( expectedFpids.size() );
2467 baseFootprint = takeMatchingFootprint( baseFpid );
2468 else if( !matchingFootprints.empty() )
2469 baseFootprint = matchingFootprints.front();
2475 for(
FOOTPRINT* footprint : matchingFootprints )
2477 if( usedFootprints.count( footprint ) )
2480 if( isExpectedFpid( footprint->GetFPID() ) )
2483 replaceCandidate = footprint;
2487 if( replaceCandidate )
2492 baseFootprint = replaced;
2494 baseFootprint = replaceCandidate;
2500 for(
FOOTPRINT* footprint : matchingFootprints )
2502 if( usedFootprints.count( footprint ) )
2505 if( isExpectedFpid( footprint->GetFPID() ) )
2508 baseFootprint = footprint;
2513 if( !baseFootprint && ( hasBaseFpid || expectedFpids.empty() ) )
2518 componentFootprints.push_back( baseFootprint );
2519 usedFootprints.insert( baseFootprint );
2520 footprintMap[ component ] = baseFootprint;
2523 for(
const LIB_ID& fpid : expectedFpids )
2531 FOOTPRINT* footprint = takeMatchingFootprint( fpid );
2538 componentFootprints.push_back( footprint );
2539 usedFootprints.insert( footprint );
2543 for(
FOOTPRINT* footprint : componentFootprints )
2554 sheetPaths.insert( footprint->GetSheetname() );
2557 if( !componentFootprints.empty() )
2569 bool matched =
false;
2572 bool isStaleVariantFootprint =
false;
2574 if( usedFootprints.count( footprint ) )
2585 if( component && component->
GetProperties().count( wxT(
"exclude_from_board" ) ) == 0 )
2593 isStaleVariantFootprint =
true;
2604 if( isStaleVariantFootprint )
2610 if( doDelete && !matched && footprint->IsLocked() && !
m_overrideLocks )
2614 msg.Printf(
_(
"Cannot remove unused footprint %s (footprint is locked)." ),
2615 footprint->GetReference() );
2619 msg.Printf(
_(
"Could not remove unused footprint %s (footprint is locked)." ),
2620 footprint->GetReference() );
2628 if( doDelete && !matched )
2632 msg.Printf(
_(
"Remove unused footprint %s." ),
2633 footprint->GetReference() );
2638 msg.Printf(
_(
"Removed unused footprint %s." ),
2639 footprint->GetReference() );
2649 for(
PAD*
pad : footprint->Pads() )
2652 pad->GetNet()->SetIsCurrent(
true );
2659 m_board->ClearNetChainColors();
2662 m_board->GetComponentClassManager().FinishNetlistUpdate();
2663 m_board->SynchronizeComponentClasses( sheetPaths );
2670 if( !net->IsCurrent() )
2672 msg.Printf(
_(
"Removed unused net %s." ),
EscapeHTML( net->GetNetname() ) );
2680 const std::vector<wxString>& netlistVariants = aNetlist.
GetVariantNames();
2682 if( !netlistVariants.empty() || !
m_board->GetVariantNames().empty() )
2686 auto findBoardVariantName =
2687 [&](
const wxString& aVariantName ) -> wxString
2689 for(
const wxString&
name :
m_board->GetVariantNames() )
2691 if(
name.CmpNoCase( aVariantName ) == 0 )
2695 return wxEmptyString;
2698 std::vector<wxString> updatedVariantNames;
2699 updatedVariantNames.reserve( netlistVariants.size() );
2701 for(
const wxString& variantName : netlistVariants )
2703 wxString actualName = findBoardVariantName( variantName );
2705 if( actualName.IsEmpty() )
2707 m_board->AddVariant( variantName );
2708 actualName = findBoardVariantName( variantName );
2710 if( !actualName.IsEmpty() )
2712 msg.Printf(
_(
"Added variant '%s'." ), actualName );
2717 if( actualName.IsEmpty() )
2722 wxString oldDescription =
m_board->GetVariantDescription( actualName );
2724 if( newDescription != oldDescription )
2726 m_board->SetVariantDescription( actualName, newDescription );
2727 msg.Printf(
_(
"Updated description for variant '%s'." ), actualName );
2731 updatedVariantNames.push_back( actualName );
2734 std::vector<wxString> variantsToRemove;
2736 for(
const wxString& existingName :
m_board->GetVariantNames() )
2740 for(
const wxString& variantName : netlistVariants )
2742 if( existingName.CmpNoCase( variantName ) == 0 )
2750 variantsToRemove.push_back( existingName );
2753 for(
const wxString& variantName : variantsToRemove )
2755 m_board->DeleteVariant( variantName );
2756 msg.Printf(
_(
"Removed variant '%s'." ), variantName );
2760 if( !updatedVariantNames.empty() )
2761 m_board->SetVariantNames( updatedVariantNames );
2780 if( !colorStr.IsEmpty() )
2793 m_board->SynchronizeNetsAndNetClasses(
true );
2797 PAD* pads[2] = {
nullptr,
nullptr };
2799 for(
size_t i = 0; i < terminalPins.size() && i < 2; ++i )
2801 const wxString& ref = terminalPins[i].first;
2802 const wxString&
pin = terminalPins[i].second;
2808 PAD* candidate =
nullptr;
2809 PAD* best =
nullptr;
2810 int bestDist = std::numeric_limits<int>::max();
2819 if( !best || dist < bestDist || ( dist == bestDist && candidate->
m_Uuid < best->
m_Uuid ) )
2829 for(
int i = 0; i < 2; ++i )
2841 if( net != termNet && net->
GetNetChain() ==
chain && net->GetTerminalPad( i ) )
2842 net->ClearTerminalPad( i );
2857 for(
const std::pair<const wxString, NETINFO_ITEM*>& addedNet :
m_addedNets )
2858 delete addedNet.second;
constexpr EDA_IU_SCALE pcbIUScale
wxString GetNetname() const
NETINFO_ITEM * GetNet() const
Return NETINFO_ITEM object for a given item.
std::shared_ptr< NET_SETTINGS > m_NetSettings
bool IsLocked() const override
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
std::map< PAD *, wxString > m_padNets
PCBNEW_SETTINGS * m_settings
bool m_deleteUnusedFootprints
void cacheNetname(PAD *aPad, const wxString &aNetname)
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
wxString getNetname(PAD *aPad)
wxString getPinFunction(PAD *aPad)
std::vector< FOOTPRINT * > m_addedFootprints
bool updateFootprintParameters(FOOTPRINT *aFootprint, COMPONENT *aNetlistComponent)
std::map< wxString, wxString > m_oldToNewNets
static void ApplyChainAssignments(BOARD *aBoard, const NETLIST &aNetlist, REPORTER *aReporter, bool aDryRun)
Apply the netlist's chain assignments to every NETINFO_ITEM on the board.
static void ApplyChainNetclasses(BOARD *aBoard, const NETLIST &aNetlist)
Mirror the netlist's chain-to-class and chain-to-netclass maps into the project's NET_SETTINGS.
bool updateFootprintGroup(FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
static bool fpidsEquivalent(const LIB_ID &aBoardFpid, const LIB_ID &aSchematicFpid)
Compare a board footprint ID against a schematic-derived footprint ID, ignoring the library nickname ...
PCB_GROUP * addBoardGroup(const NETLIST_GROUP &aNetlistGroup)
std::map< wxString, NETINFO_ITEM * > m_addedNets
std::vector< PCB_GROUP * > m_addedGroups
bool testConnectivity(NETLIST &aNetlist, std::map< COMPONENT *, FOOTPRINT * > &aFootprintMap)
bool updateCopperZoneNets(NETLIST &aNetlist)
void cachePinFunction(PAD *aPad, const wxString &aPinFunction)
bool updateGroups(NETLIST &aNetlist)
BOARD_NETLIST_UPDATER(PCB_EDIT_FRAME *aFrame, BOARD *aBoard)
Construct an updater for interactive use from the board editor.
bool updateComponentClass(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
bool updateComponentPadConnections(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
VECTOR2I estimateFootprintInsertionPosition()
std::map< PAD *, wxString > m_padPinFunctions
void applyComponentVariants(COMPONENT *aComponent, const std::vector< FOOTPRINT * > &aFootprints, const LIB_ID &aBaseFpid)
std::map< ZONE *, std::vector< PAD * > > m_zoneConnectionsCache
FOOTPRINT * replaceFootprint(NETLIST &aNetlist, FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
void cacheCopperZoneConnections()
bool updateComponentUnits(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
FOOTPRINT * addNewFootprint(COMPONENT *aComponent)
std::set< wxString > m_schematicNetNames
PCB_GROUP * findBoardGroup(const KIID &aUuid) const
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
BOARD_DESIGN_SETTINGS & GetDesignSettings()
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
static wxString GetFullClassNameForConstituents(const std::unordered_set< wxString > &classNames)
Gets the full effective class name for the given set of constituent classes.
A lightweight representation of a component class.
const wxString & GetName() const
Fetches the full name of this component class.
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
const wxString & GetNetName() const
const wxString & GetPinFunction() const
const wxString & GetPinName() const
const wxString & GetPinType() const
Store all of the related component information found in a netlist.
const std::vector< UNIT_INFO > & GetUnitInfo() const
const wxString & GetHumanReadablePath() const
const COMPONENT_NET & GetNet(unsigned aIndex) const
const KIID_PATH & GetPath() const
const wxString & GetReference() const
const wxString & GetValue() const
const nlohmann::ordered_map< wxString, wxString > & GetFields() const
const std::map< wxString, wxString > & GetProperties() const
const CASE_INSENSITIVE_MAP< COMPONENT_VARIANT > & GetVariants() const
NETLIST_GROUP * GetGroup() const
const std::vector< KIID > & GetKIIDs() const
bool GetDuplicatePadNumbersAreJumpers() const
const LIB_ID & GetFPID() const
unsigned GetNetCount() const
std::unordered_set< wxString > & GetComponentClassNames()
JUMPER_GROUP_SET & JumperPadGroups()
std::unordered_set< EDA_ITEM * > & GetItems()
void RemoveItem(EDA_ITEM *aItem)
Remove item from group.
void AddItem(EDA_ITEM *aItem)
Add item to group.
virtual EDA_GROUP * GetParentGroup() const
virtual void SetParent(EDA_ITEM *aParent)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
A color representation with 4 components: red, green, blue, alpha.
bool SetFromHexString(const wxString &aColorString)
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
wxString GetUniStringLibId() const
const UTF8 & GetLibItemName() const
Handle the data for a net.
const wxString & GetNetChain() const
void SetTerminal(int aIndex, PAD *aPad)
Set the terminal-pad pointer and the persisted UUID at aIndex from a single pad, keeping the two view...
void SetIsCurrent(bool isCurrent)
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
const std::map< wxString, std::vector< std::pair< wxString, wxString > > > & GetNetChainTerminalPins() const
NETLIST_GROUP * GetParentGroup(const KIID_PATH &aMemberPath)
Return the NETLIST_GROUP that lists aMemberPath among its members.
const std::vector< wxString > & GetVariantNames() const
unsigned GetCount() const
COMPONENT * GetComponentByPath(const KIID_PATH &aPath)
Return a COMPONENT by aPath.
COMPONENT * GetComponentByReference(const wxString &aReference)
Return a COMPONENT by aReference.
const std::map< wxString, wxString > & GetNetChainNetClasses() const
const std::map< wxString, wxString > & GetSignalChainClasses() const
NETLIST_GROUP * GetGroupByUuid(const KIID &aUuid)
Return a NETLIST_GROUP by aUuid.
const std::map< wxString, wxString > & GetNetChainColors() const
NETLIST_GROUP * GetGroupByPath(const KIID_PATH &aPath)
Return a NETLIST_GROUP by aPath.
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
wxString GetNetChainFor(const wxString &aNet) const
wxString GetVariantDescription(const wxString &aVariantName) const
A singleton reporter that reports to nowhere.
const wxString & GetPinFunction() const
VECTOR2I GetPosition() const override
The main frame for Pcbnew.
void SetName(const wxString &aName)
A set of BOARD_ITEMs (i.e., without duplicates).
EDA_ITEM * AsEdaItem() override
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &aSettings, bool aCheckSide) override
void SetPosition(const VECTOR2I &aPos) override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Handle a list of polygons defining a copper zone.
KICOMMON_API wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
Class to handle a set of BOARD_ITEMs.
FOOTPRINT * LoadFootprintFromProject(BOARD *aBoard, const LIB_ID &aFootprintId, bool aKeepUuid)
Load a footprint from the project library table and apply board default settings.
T * GetAppSettings(const char *aFilename)
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
wxString UnescapeString(const wxString &aSource)
bool m_excludedFromPosFiles
bool m_hasExcludedFromBOM
bool m_hasExcludedFromSim
bool m_hasExcludedFromPosFiles
nlohmann::ordered_map< wxString, wxString > m_fields
std::vector< KIID > members
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
@ USER
The field ID hasn't been set yet; field is invalid.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
VECTOR3I expected(15, 30, 45)
static std::string netlistValue(const SEXPR::SEXPR &aNode, const std::string &aHead)
const SHAPE_LINE_CHAIN chain
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
VECTOR2< int32_t > VECTOR2I