133 bestPosition.
x = pageSize.
x / 2;
134 bestPosition.
y = pageSize.
y / 2;
147 msg.Printf(
_(
"Cannot add %s (no footprint assigned)." ),
156 if( footprint ==
nullptr )
158 msg.Printf(
_(
"Cannot add %s (footprint '%s' not found)." ),
167 m_board->GetComponentClassManager().GetNoneComponentClass() );
171 msg.Printf(
_(
"Add %s (footprint '%s')." ),
183 pad->SetLocalRatsnestVisible(
m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
186 pad->SetNetCode( 0 );
201 msg.Printf(
_(
"Added %s (footprint '%s')." ),
214 wxString curClassName, newClassName;
218 curClassName = curClass->
GetName();
228 newClass =
m_board->GetComponentClassManager().GetEffectiveStaticComponentClass(
230 newClassName = newClass->
GetName();
233 if( curClassName == newClassName )
240 if( curClassName == wxEmptyString && newClassName != wxEmptyString )
242 msg.Printf(
_(
"Change %s component class to '%s'." ),
246 else if( curClassName != wxEmptyString && newClassName == wxEmptyString )
248 msg.Printf(
_(
"Remove %s component class (currently '%s')." ),
254 msg.Printf(
_(
"Change %s component class from '%s' to '%s'." ),
262 wxASSERT_MSG( newClass !=
nullptr,
"Component class should not be nullptr" );
266 if( curClassName == wxEmptyString && newClassName != wxEmptyString )
268 msg.Printf(
_(
"Changed %s component class to '%s'." ),
272 else if( curClassName != wxEmptyString && newClassName == wxEmptyString )
274 msg.Printf(
_(
"Removed %s component class (was '%s')." ),
280 msg.Printf(
_(
"Changed %s component class from '%s' to '%s'." ),
298 msg.Printf(
_(
"Cannot update %s (no footprint assigned)." ),
307 if( newFootprint ==
nullptr )
309 msg.Printf(
_(
"Cannot update %s (footprint '%s' not found)." ),
321 msg.Printf(
_(
"Cannot change %s footprint from '%s' to '%s' (footprint is locked)."),
332 msg.Printf(
_(
"Change %s footprint from '%s' to '%s'."),
346 msg.Printf(
_(
"Could not change %s footprint from '%s' to '%s' (footprint is locked)."),
359 msg.Printf(
_(
"Changed %s footprint from '%s' to '%s'."),
379 if( !
m_commit.GetStatus( aPcbFootprint ) )
382 copy->SetParentGroup(
nullptr );
385 bool changed =
false;
392 msg.Printf(
_(
"Change %s reference designator to %s." ),
398 msg.Printf(
_(
"Changed %s reference designator to %s." ),
414 msg.Printf(
_(
"Change %s value from %s to %s." ),
421 msg.Printf(
_(
"Changed %s value from %s to %s." ),
436 if( !aNetlistComponent->
GetKIIDs().empty() )
437 new_path.push_back( aNetlistComponent->
GetKIIDs().front() );
439 if( aPcbFootprint->
GetPath() != new_path )
443 msg.Printf(
_(
"Update %s symbol association from %s to %s." ),
450 msg.Printf(
_(
"Updated %s symbol association from %s to %s." ),
456 aPcbFootprint->
SetPath( new_path );
462 nlohmann::ordered_map<wxString, wxString> fpFieldsAsMap;
467 if( field->IsReference() || field->IsValue() || field->IsComponentClass() )
472 fpFieldsAsMap[field->GetName()] = field->GetText();
476 nlohmann::ordered_map<wxString, wxString> compFields = aNetlistComponent->
GetFields();
482 compFields.erase( wxT(
"Component Class" ) );
488 bool remove_only =
true;
490 for(
const auto& [
name, value] : compFields )
492 if( fpFieldsAsMap.count(
name ) == 0 || fpFieldsAsMap[
name] != value )
500 for(
const auto& [
name, value] : fpFieldsAsMap )
502 if( compFields.count(
name ) == 0 )
515 msg.Printf(
_(
"Update %s fields." ), aPcbFootprint->
GetReference() );
522 if( field->IsMandatory() )
525 if( compFields.count( field->GetName() ) == 0 )
529 msg.Printf(
_(
"Remove %s footprint fields not in symbol." ),
542 msg.Printf(
_(
"Updated %s fields." ), aPcbFootprint->
GetReference() );
548 for(
auto& [
name, value] : compFields )
557 aPcbFootprint->
Add( newField );
579 std::vector<PCB_FIELD*> fieldList;
580 aPcbFootprint->
GetFields( fieldList,
false );
584 if( field->IsMandatory() )
587 if( compFields.count( field->GetName() ) == 0 )
592 msg.Printf(
_(
"Removed %s footprint fields not in symbol." ),
597 aPcbFootprint->
Remove( field );
600 m_frame->GetCanvas()->GetView()->Remove( field );
615 if( !humanSheetPath.empty() )
616 sheetname = humanSheetPath;
617 else if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetname" ) ) > 0 )
618 sheetname = aNetlistComponent->
GetProperties().at( wxT(
"Sheetname" ) );
620 if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetfile" ) ) > 0 )
621 sheetfile = aNetlistComponent->
GetProperties().at( wxT(
"Sheetfile" ) );
623 if( aNetlistComponent->
GetProperties().count( wxT(
"ki_fp_filters" ) ) > 0 )
624 fpFilters = aNetlistComponent->
GetProperties().at( wxT(
"ki_fp_filters" ) );
630 msg.Printf(
_(
"Update %s sheetname to '%s'." ),
637 msg.Printf(
_(
"Updated %s sheetname to '%s'." ),
649 msg.Printf(
_(
"Update %s sheetfile to '%s'." ),
656 msg.Printf(
_(
"Updated %s sheetfile to '%s'." ),
664 if( fpFilters != aPcbFootprint->
GetFilters() )
668 msg.Printf(
_(
"Update %s footprint filters to '%s'." ),
675 msg.Printf(
_(
"Updated %s footprint filters to '%s'." ),
683 if( ( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) > 0 )
688 if( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) )
690 msg.Printf(
_(
"Add %s 'exclude from BOM' fabrication attribute." ),
695 msg.Printf(
_(
"Remove %s 'exclude from BOM' fabrication attribute." ),
703 if( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) )
706 msg.Printf(
_(
"Added %s 'exclude from BOM' fabrication attribute." ),
712 msg.Printf(
_(
"Removed %s 'exclude from BOM' fabrication attribute." ),
723 if( ( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) > 0 )
728 if( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) )
730 msg.Printf(
_(
"Add %s 'Do not place' fabrication attribute." ),
735 msg.Printf(
_(
"Remove %s 'Do not place' fabrication attribute." ),
743 if( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) )
746 msg.Printf(
_(
"Added %s 'Do not place' fabrication attribute." ),
752 msg.Printf(
_(
"Removed %s 'Do not place' fabrication attribute." ),
775 msg.Printf(
_(
"Added %s 'duplicate pad numbers are jumpers' attribute." ),
780 msg.Printf(
_(
"Removed %s 'duplicate pad numbers are jumpers' attribute." ),
788 msg.Printf(
_(
"Add %s 'duplicate pad numbers are jumpers' attribute." ),
793 msg.Printf(
_(
"Remove %s 'duplicate pad numbers are jumpers' attribute." ),
807 msg.Printf(
_(
"Updated %s jumper pad groups" ), aPcbFootprint->
GetReference() );
811 msg.Printf(
_(
"Update %s jumper pad groups" ), aPcbFootprint->
GetReference() );
817 if( changed &&
copy )
837 if( !
m_commit.GetStatus( aPcbFootprint ) )
840 copy->SetParentGroup(
nullptr );
843 bool changed =
false;
852 KIID existingGroupKIID = existingGroup ? existingGroup->
m_Uuid : 0;
855 auto it = std::find_if(
m_board->Groups().begin(),
m_board->Groups().end(),
857 return group->m_Uuid == newGroupKIID;
861 if( it !=
m_board->Groups().end() )
865 if( newGroupKIID == existingGroupKIID )
869 if( existingGroupKIID != 0 )
873 msg.Printf(
_(
"Remove %s from group '%s'." ),
879 msg.Printf(
_(
"Removed %s from group '%s'." ),
892 if( newGroupKIID != 0 )
896 msg.Printf(
_(
"Add %s to group '%s'." ),
902 msg.Printf(
_(
"Added %s group '%s'." ),
908 if( newGroup ==
nullptr )
911 const_cast<KIID&
>( newGroup->
m_Uuid ) = newGroupKIID;
924 newGroup->
AddItem( aPcbFootprint );
930 if( changed &&
copy )
950 copy->SetParentGroup(
nullptr );
953 bool changed =
false;
956 std::deque<PAD*> pads = aFootprint->
Pads();
957 std::set<wxString> padNetnames;
959 std::sort( pads.begin(), pads.end(),
962 return a->m_Uuid < b->m_Uuid;
969 wxLogTrace( wxT(
"NETLIST_UPDATE" ),
970 wxT(
"Processing pad %s of component %s" ),
974 wxString pinFunction;
979 wxLogTrace( wxT(
"NETLIST_UPDATE" ),
980 wxT(
" Found valid net: %s" ),
987 wxLogTrace( wxT(
"NETLIST_UPDATE" ),
988 wxT(
" No net found for pad %s" ),
994 if(
pad->GetPinFunction() != pinFunction )
997 pad->SetPinFunction( pinFunction );
1000 if(
pad->GetPinType() != pinType )
1003 pad->SetPinType( pinType );
1012 if( !net.
IsValid() || !
pad->IsOnCopperLayer() )
1014 if( !
pad->GetNetname().IsEmpty() )
1018 msg.Printf(
_(
"Disconnect %s pin %s." ),
1024 msg.Printf(
_(
"Disconnected %s pin %s." ),
1031 else if(
pad->IsOnCopperLayer() && !
pad->GetNumber().IsEmpty() )
1034 msg.Printf(
_(
"No net found for component %s pad %s (no pin %s in symbol)." ),
1049 if(
pad->GetNetname().IsEmpty() )
1050 pad->SetPinFunction( wxEmptyString );
1062 if(
pad->IsNoConnectPad() )
1064 netName = wxString::Format( wxS(
"%s" ),
1067 for(
int jj = 1; !padNetnames.insert( netName ).second; jj++ )
1069 netName = wxString::Format( wxS(
"%s_%d" ),
1079 if(
pad->GetNetname() != netName )
1082 if( netinfo ==
nullptr )
1089 if( netinfo ==
nullptr )
1101 msg.Printf(
_(
"Add net %s." ),
1106 if( !
pad->GetNetname().IsEmpty() )
1112 msg.Printf(
_(
"Reconnect %s pin %s from %s to %s."),
1120 msg.Printf(
_(
"Reconnected %s pin %s from %s to %s."),
1131 msg.Printf(
_(
"Connect %s pin %s to %s."),
1138 msg.Printf(
_(
"Connected %s pin %s to %s."),
1150 pad->SetNet( netinfo );
1160 if( changed &&
copy )
1173 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
1184 std::set<wxString> netlistNetnames;
1186 for(
int ii = 0; ii < (int) aNetlist.
GetCount(); ii++ )
1190 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
1202 if( netlistNetnames.count(
via->GetNetname() ) == 0 )
1204 wxString updatedNetname = wxEmptyString;
1213 if( !updatedNetname.IsEmpty() )
1217 wxString originalNetname =
via->GetNetname();
1219 msg.Printf(
_(
"Reconnect via from %s to %s." ),
1234 wxString originalNetname =
via->GetNetname();
1237 via->SetNet( netinfo );
1239 msg.Printf(
_(
"Reconnected via from %s to %s." ),
1249 msg.Printf(
_(
"Via connected to unknown net (%s)." ),
1260 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
1263 if( netlistNetnames.count( zone->GetNetname() ) == 0 )
1268 wxString updatedNetname = wxEmptyString;
1281 if( updatedNetname.IsEmpty() &&
m_oldToNewNets.count( zone->GetNetname() ) )
1286 if( !updatedNetname.IsEmpty() )
1290 wxString originalNetname = zone->GetNetname();
1292 if( !zone->GetZoneName().IsEmpty() )
1294 msg.Printf(
_(
"Reconnect copper zone '%s' from %s to %s." ),
1295 zone->GetZoneName(),
1301 msg.Printf(
_(
"Reconnect copper zone from %s to %s." ),
1317 wxString originalNetname = zone->GetNetname();
1320 zone->SetNet( netinfo );
1322 if( !zone->GetZoneName().IsEmpty() )
1324 msg.Printf(
_(
"Reconnected copper zone '%s' from %s to %s." ),
1331 msg.Printf(
_(
"Reconnected copper zone from %s to %s." ),
1342 if( !zone->GetZoneName().IsEmpty() )
1344 msg.Printf(
_(
"Copper zone '%s' has no pads connected." ),
1354 if(
m_frame->GetPcbNewSettings()->m_Display.m_DisplayInvertXAxis )
1357 if(
m_frame->GetPcbNewSettings()->m_Display.m_DisplayInvertYAxis )
1361 msg.Printf(
_(
"Copper zone on layer %s at (%s, %s) has no pads connected." ),
1388 if( netlistGroup ==
nullptr )
1391 if( netlistGroup->
name != pcbGroup->GetName() )
1396 msg.Printf(
_(
"Change group name to '%s' to '%s'." ),
EscapeHTML( pcbGroup->GetName() ),
1403 msg.Printf(
_(
"Changed group name to '%s' to '%s'." ),
EscapeHTML( pcbGroup->GetName() ),
1406 pcbGroup->SetName( netlistGroup->
name );
1410 if( netlistGroup->
libId != pcbGroup->GetDesignBlockLibId() )
1415 msg.Printf(
_(
"Change group library link to '%s'." ),
1422 msg.Printf(
_(
"Changed group library link to '%s'." ),
1425 pcbGroup->SetDesignBlockLibId( netlistGroup->
libId );
1435 std::map<COMPONENT*, FOOTPRINT*>& aFootprintMap )
1443 for(
int i = 0; i < (int) aNetlist.
GetCount(); i++ )
1446 FOOTPRINT* footprint = aFootprintMap[component];
1452 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
1456 if( padNumber.IsEmpty() )
1459 msg.Printf(
_(
"Symbol %s has pins with no number. These pins can not be matched "
1469 msg.Printf(
_(
"%s pad %s not found in %s." ),
1485 FOOTPRINT* lastPreexistingFootprint =
nullptr;
1488 std::unordered_set<wxString> sheetPaths;
1494 std::map<COMPONENT*, FOOTPRINT*> footprintMap;
1496 if( !
m_board->Footprints().empty() )
1497 lastPreexistingFootprint =
m_board->Footprints().back();
1507 net->SetIsCurrent( net->GetNetCode() == 0 );
1509 m_board->GetComponentClassManager().InitNetlistUpdate();
1515 for(
unsigned i = 0; i < aNetlist.
GetCount(); i++ )
1519 if( component->
GetProperties().count( wxT(
"exclude_from_board" ) ) )
1522 msg.Printf(
_(
"Processing symbol '%s:%s'." ),
1538 base.push_back( uuid );
1540 if( footprint->GetPath() == base )
1549 match = footprint->GetReference().CmpNoCase( component->
GetReference() ) == 0;
1564 footprintMap[ component ] = tmp;
1571 sheetPaths.insert( footprint->GetSheetname() );
1577 if( footprint == lastPreexistingFootprint )
1584 if( matchCount == 0 )
1590 footprintMap[ component ] = footprint;
1600 else if( matchCount > 1 )
1602 msg.Printf(
_(
"Multiple footprints found for %s." ),
1617 bool matched =
false;
1628 if( component && component->
GetProperties().count( wxT(
"exclude_from_board" ) ) == 0 )
1631 if( doDelete && !matched && footprint->IsLocked() && !
m_overrideLocks )
1635 msg.Printf(
_(
"Cannot remove unused footprint %s (footprint is locked)." ),
1636 footprint->GetReference() );
1640 msg.Printf(
_(
"Could not remove unused footprint %s (footprint is locked)." ),
1641 footprint->GetReference() );
1649 if( doDelete && !matched )
1653 msg.Printf(
_(
"Remove unused footprint %s." ),
1654 footprint->GetReference() );
1659 msg.Printf(
_(
"Removed unused footprint %s." ),
1660 footprint->GetReference() );
1670 for(
PAD*
pad : footprint->Pads() )
1673 pad->GetNet()->SetIsCurrent(
true );
1681 m_board->GetComponentClassManager().FinishNetlistUpdate();
1682 m_board->SynchronizeComponentClasses( sheetPaths );
1689 if( !net->IsCurrent() )
1691 msg.Printf(
_(
"Removed unused net %s." ),
1706 m_board->SynchronizeNetsAndNetClasses(
true );
1717 for(
const std::pair<const wxString, NETINFO_ITEM*>& addedNet :
m_addedNets )
1718 delete addedNet.second;
constexpr EDA_IU_SCALE pcbIUScale
wxString GetNetname() const
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
std::map< PAD *, wxString > m_padNets
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
std::map< wxString, wxString > m_oldToNewNets
void updateComponentClass(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
bool updateFootprintGroup(FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
bool updateFootprintParameters(FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
std::map< wxString, NETINFO_ITEM * > m_addedNets
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)
bool updateComponentPadConnections(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
VECTOR2I estimateFootprintInsertionPosition()
std::map< PAD *, wxString > m_padPinFunctions
std::map< ZONE *, std::vector< PAD * > > m_zoneConnectionsCache
FOOTPRINT * replaceFootprint(NETLIST &aNetlist, FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
void cacheCopperZoneConnections()
FOOTPRINT * addNewFootprint(COMPONENT *aComponent)
Information pertinent to a Pcbnew printed circuit board.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() 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 footprint information found in a netlist.
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
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()
std::vector< std::set< wxString > > & JumperPadGroups()
void RemoveItem(EDA_ITEM *aItem)
Remove item from group.
void AddItem(EDA_ITEM *aItem)
Add item to group.
void SetName(const wxString &aName)
virtual EDA_GROUP * GetParentGroup() const
virtual void SetParent(EDA_ITEM *aParent)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
wxString AsString() const
wxString GetUniStringLibId() const
Handle the data for a net.
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.
unsigned GetCount() const
COMPONENT * GetComponentByPath(const KIID_PATH &aPath)
Return a COMPONENT by aPath.
COMPONENT * GetComponentByReference(const wxString &aReference)
Return a COMPONENT by aReference.
NETLIST_GROUP * GetGroupByUuid(const KIID &aUuid)
Return a NETLIST_GROUP by aUuid.
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
static REPORTER & GetInstance()
const wxString & GetPinFunction() const
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 &settings) override
virtual void SetPosition(const VECTOR2I &aPos) override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Handle a list of polygons defining a copper zone.
PCB_LAYER_ID
A quick note on layer IDs:
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.
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
wxString UnescapeString(const wxString &aSource)
@ 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".
wxString GetCanonicalFieldName(FIELD_T aFieldType)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
VECTOR2< int32_t > VECTOR2I