127 bestPosition.
x = pageSize.
x / 2;
128 bestPosition.
y = pageSize.
y / 2;
141 msg.Printf(
_(
"Cannot add %s (no footprint assigned)." ),
150 if( footprint ==
nullptr )
152 msg.Printf(
_(
"Cannot add %s (footprint '%s' not found)." ),
164 msg.Printf(
_(
"Add %s (footprint '%s')." ),
179 pad->SetNetCode( 0 );
194 msg.Printf(
_(
"Added %s (footprint '%s')." ),
207 wxString curClassName, newClassName;
226 if( curClassName == newClassName )
233 if( curClassName == wxEmptyString && newClassName != wxEmptyString )
235 msg.Printf(
_(
"Change %s component class to '%s'." ),
239 else if( curClassName != wxEmptyString && newClassName == wxEmptyString )
241 msg.Printf(
_(
"Remove %s component class (currently '%s')." ),
247 msg.Printf(
_(
"Change %s component class from '%s' to '%s'." ),
255 wxASSERT_MSG( newClass !=
nullptr,
"Component class should not be nullptr" );
259 if( curClassName == wxEmptyString && newClassName != wxEmptyString )
261 msg.Printf(
_(
"Changed %s component class to '%s'." ),
265 else if( curClassName != wxEmptyString && newClassName == wxEmptyString )
267 msg.Printf(
_(
"Removed %s component class (was '%s')." ),
273 msg.Printf(
_(
"Changed %s component class from '%s' to '%s'." ),
291 msg.Printf(
_(
"Cannot update %s (no footprint assigned)." ),
300 if( newFootprint ==
nullptr )
302 msg.Printf(
_(
"Cannot update %s (footprint '%s' not found)." ),
314 msg.Printf(
_(
"Cannot change %s footprint from '%s' to '%s' (footprint is locked)."),
325 msg.Printf(
_(
"Change %s footprint from '%s' to '%s'."),
339 msg.Printf(
_(
"Could not change %s footprint from '%s' to '%s' (footprint is locked)."),
352 msg.Printf(
_(
"Changed %s footprint from '%s' to '%s'."),
375 copy->SetParentGroup(
nullptr );
378 bool changed =
false;
385 msg.Printf(
_(
"Change %s reference designator to %s." ),
391 msg.Printf(
_(
"Changed %s reference designator to %s." ),
407 msg.Printf(
_(
"Change %s value from %s to %s." ),
414 msg.Printf(
_(
"Changed %s value from %s to %s." ),
429 if( !aNetlistComponent->
GetKIIDs().empty() )
430 new_path.push_back( aNetlistComponent->
GetKIIDs().front() );
432 if( aPcbFootprint->
GetPath() != new_path )
436 msg.Printf(
_(
"Update %s symbol association from %s to %s." ),
443 msg.Printf(
_(
"Updated %s symbol association from %s to %s." ),
449 aPcbFootprint->
SetPath( new_path );
455 nlohmann::ordered_map<wxString, wxString> fpFieldsAsMap;
460 if( field->IsReference() || field->IsValue() || field->IsComponentClass() )
465 fpFieldsAsMap[field->GetName()] = field->GetText();
469 nlohmann::ordered_map<wxString, wxString> compFields = aNetlistComponent->
GetFields();
475 compFields.erase( wxT(
"Component Class" ) );
482 for( std::pair<wxString, wxString> field : compFields )
484 if( fpFieldsAsMap.count( field.first ) == 0 || fpFieldsAsMap[field.first] != field.second )
495 msg.Printf(
_(
"Update %s fields." ), aPcbFootprint->
GetReference() );
501 if( field->IsMandatoryField() )
504 if( compFields.count( field->GetName() ) == 0 )
506 msg.Printf(
_(
"Remove %s footprint fields not in symbol." ),
515 msg.Printf(
_(
"Updated %s fields." ), aPcbFootprint->
GetReference() );
521 for(
auto& [
name, value] : compFields )
552 if( field->IsMandatoryField() )
555 if( compFields.count( field->GetName() ) == 0 )
560 msg.Printf(
_(
"Removed %s footprint fields not in symbol." ),
565 aPcbFootprint->
RemoveField( field->GetCanonicalName() );
580 if( !humanSheetPath.empty() )
581 sheetname = humanSheetPath;
582 else if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetname" ) ) > 0 )
583 sheetname = aNetlistComponent->
GetProperties().at( wxT(
"Sheetname" ) );
585 if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetfile" ) ) > 0 )
586 sheetfile = aNetlistComponent->
GetProperties().at( wxT(
"Sheetfile" ) );
588 if( aNetlistComponent->
GetProperties().count( wxT(
"ki_fp_filters" ) ) > 0 )
589 fpFilters = aNetlistComponent->
GetProperties().at( wxT(
"ki_fp_filters" ) );
595 msg.Printf(
_(
"Update %s sheetname to '%s'." ),
602 msg.Printf(
_(
"Updated %s sheetname to '%s'." ),
614 msg.Printf(
_(
"Update %s sheetfile to '%s'." ),
621 msg.Printf(
_(
"Updated %s sheetfile to '%s'." ),
629 if( fpFilters != aPcbFootprint->
GetFilters() )
633 msg.Printf(
_(
"Update %s footprint filters to '%s'." ),
640 msg.Printf(
_(
"Updated %s footprint filters to '%s'." ),
648 if( ( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) > 0 )
653 if( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) )
655 msg.Printf(
_(
"Add %s 'exclude from BOM' fabrication attribute." ),
660 msg.Printf(
_(
"Remove %s 'exclude from BOM' fabrication attribute." ),
668 if( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) )
671 msg.Printf(
_(
"Added %s 'exclude from BOM' fabrication attribute." ),
676 attributes &= ~FP_EXCLUDE_FROM_BOM;
677 msg.Printf(
_(
"Removed %s 'exclude from BOM' fabrication attribute." ),
688 if( ( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) > 0 )
693 if( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) )
695 msg.Printf(
_(
"Add %s 'Do not place' fabrication attribute." ),
700 msg.Printf(
_(
"Remove %s 'Do not place' fabrication attribute." ),
708 if( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) )
711 msg.Printf(
_(
"Added %s 'Do not place' fabrication attribute." ),
716 attributes &= ~FP_DNP;
717 msg.Printf(
_(
"Removed %s 'Do not place' fabrication attribute." ),
728 if( changed &&
copy )
748 copy->SetParentGroup(
nullptr );
751 bool changed =
false;
754 std::deque<PAD*> pads = aFootprint->
Pads();
755 std::set<wxString> padNetnames;
757 std::sort( pads.begin(), pads.end(),
760 return a->m_Uuid < b->m_Uuid;
767 wxString pinFunction;
778 if(
pad->GetPinFunction() != pinFunction )
781 pad->SetPinFunction( pinFunction );
784 if(
pad->GetPinType() != pinType )
787 pad->SetPinType( pinType );
796 if( !net.
IsValid() || !
pad->IsOnCopperLayer() )
798 if( !
pad->GetNetname().IsEmpty() )
802 msg.Printf(
_(
"Disconnect %s pin %s." ),
808 msg.Printf(
_(
"Disconnected %s pin %s." ),
815 else if(
pad->IsOnCopperLayer() && !
pad->GetNumber().IsEmpty() )
818 msg.Printf(
_(
"No net found for component %s pad %s (no pin %s in symbol)." ),
833 if(
pad->GetNetname().IsEmpty() )
834 pad->SetPinFunction( wxEmptyString );
846 if(
pad->IsNoConnectPad() )
848 netName = wxString::Format( wxS(
"%s" ),
851 for(
int jj = 1; !padNetnames.insert( netName ).second; jj++ )
853 netName = wxString::Format( wxS(
"%s_%d" ),
863 if(
pad->GetNetname() != netName )
866 if( netinfo ==
nullptr )
873 if( netinfo ==
nullptr )
885 msg.Printf(
_(
"Add net %s." ),
890 if( !
pad->GetNetname().IsEmpty() )
896 msg.Printf(
_(
"Reconnect %s pin %s from %s to %s."),
904 msg.Printf(
_(
"Reconnected %s pin %s from %s to %s."),
915 msg.Printf(
_(
"Connect %s pin %s to %s."),
922 msg.Printf(
_(
"Connected %s pin %s to %s."),
934 pad->SetNet( netinfo );
944 if( changed &&
copy )
957 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
968 std::set<wxString> netlistNetnames;
970 for(
int ii = 0; ii < (int) aNetlist.
GetCount(); ii++ )
974 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
986 if( netlistNetnames.count(
via->GetNetname() ) == 0 )
988 wxString updatedNetname = wxEmptyString;
997 if( !updatedNetname.IsEmpty() )
1001 wxString originalNetname =
via->GetNetname();
1003 msg.Printf(
_(
"Reconnect via from %s to %s." ),
1018 wxString originalNetname =
via->GetNetname();
1021 via->SetNet( netinfo );
1023 msg.Printf(
_(
"Reconnected via from %s to %s." ),
1033 msg.Printf(
_(
"Via connected to unknown net (%s)." ),
1044 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
1047 if( netlistNetnames.count( zone->GetNetname() ) == 0 )
1052 wxString updatedNetname = wxEmptyString;
1065 if( updatedNetname.IsEmpty() &&
m_oldToNewNets.count( zone->GetNetname() ) )
1070 if( !updatedNetname.IsEmpty() )
1074 wxString originalNetname = zone->GetNetname();
1076 if( !zone->GetZoneName().IsEmpty() )
1078 msg.Printf(
_(
"Reconnect copper zone '%s' from %s to %s." ),
1079 zone->GetZoneName(),
1085 msg.Printf(
_(
"Reconnect copper zone from %s to %s." ),
1101 wxString originalNetname = zone->GetNetname();
1104 zone->SetNet( netinfo );
1106 if( !zone->GetZoneName().IsEmpty() )
1108 msg.Printf(
_(
"Reconnected copper zone '%s' from %s to %s." ),
1115 msg.Printf(
_(
"Reconnected copper zone from %s to %s." ),
1126 if( !zone->GetZoneName().IsEmpty() )
1128 msg.Printf(
_(
"Copper zone '%s' has no pads connected." ),
1134 VECTOR2I pos = zone->GetPosition();
1145 msg.Printf(
_(
"Copper zone on layer %s at (%s, %s) has no pads connected." ),
1162 std::map<COMPONENT*, FOOTPRINT*>& aFootprintMap )
1170 for(
int i = 0; i < (int) aNetlist.
GetCount(); i++ )
1173 FOOTPRINT* footprint = aFootprintMap[component];
1179 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
1183 if( padNumber.IsEmpty() )
1186 msg.Printf(
_(
"Symbol %s has pins with no number. These pins can not be matched "
1196 msg.Printf(
_(
"%s pad %s not found in %s." ),
1212 FOOTPRINT* lastPreexistingFootprint =
nullptr;
1220 std::map<COMPONENT*, FOOTPRINT*> footprintMap;
1233 net->SetIsCurrent( net->GetNetCode() == 0 );
1241 for(
unsigned i = 0; i < aNetlist.
GetCount(); i++ )
1245 if( component->
GetProperties().count( wxT(
"exclude_from_board" ) ) )
1248 msg.Printf(
_(
"Processing symbol '%s:%s'." ),
1264 base.push_back( uuid );
1266 if( footprint->GetPath() == base )
1275 match = footprint->GetReference().CmpNoCase( component->
GetReference() ) == 0;
1287 footprintMap[ component ] = tmp;
1297 if( footprint == lastPreexistingFootprint )
1304 if( matchCount == 0 )
1310 footprintMap[ component ] = footprint;
1317 else if( matchCount > 1 )
1319 msg.Printf(
_(
"Multiple footprints found for %s." ),
1333 bool matched =
false;
1344 if( component && component->
GetProperties().count( wxT(
"exclude_from_board" ) ) == 0 )
1347 if( doDelete && !matched && footprint->IsLocked() && !
m_overrideLocks )
1351 msg.Printf(
_(
"Cannot remove unused footprint %s (footprint is locked)." ),
1352 footprint->GetReference() );
1356 msg.Printf(
_(
"Could not remove unused footprint %s (footprint is locked)." ),
1357 footprint->GetReference() );
1365 if( doDelete && !matched )
1369 msg.Printf(
_(
"Remove unused footprint %s." ),
1370 footprint->GetReference() );
1374 if( footprint->GetParentGroup() )
1378 msg.Printf(
_(
"Removed unused footprint %s." ),
1379 footprint->GetReference() );
1389 for(
PAD*
pad : footprint->Pads() )
1392 pad->GetNet()->SetIsCurrent(
true );
1407 if( !net->IsCurrent() )
1409 msg.Printf(
_(
"Removed unused net %s." ),
1434 for(
const std::pair<const wxString, NETINFO_ITEM*>& addedNet :
m_addedNets )
1435 delete addedNet.second;
constexpr EDA_IU_SCALE pcbIUScale
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
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 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)
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.
const NETINFO_LIST & GetNetInfo() const
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
const PAGE_INFO & GetPageSettings() const
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
const ZONES & Zones() const
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr coord_type GetBottom() const
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been removed.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy, BASE_SCREEN *aScreen=nullptr)
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
void FinishNetlistUpdate()
Cleans up the manager after a board update Must be called after updating the PCB from the netlist.
static wxString GetFullClassNameForConstituents(std::unordered_set< wxString > &classNames)
Gets the full effective class name for the given set of constituent classes.
const COMPONENT_CLASS * GetNoneComponentClass() const
Returns the unassigned component class.
void InitNetlistUpdate()
Prepare the manager for a board update Must be called prior to updating the PCB from the netlist.
COMPONENT_CLASS * GetEffectiveComponentClass(std::unordered_set< wxString > &classNames)
Gets an effective component class for the given constituent class names.
const wxString & GetFullName() 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
const std::vector< KIID > & GetKIIDs() const
const LIB_ID & GetFPID() const
unsigned GetNetCount() const
std::unordered_set< wxString > & GetComponentClassNames()
virtual void SetParent(EDA_ITEM *aParent)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
wxString AsString() 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.
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
static REPORTER & GetInstance()
const wxString & GetPinFunction() const
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
DISPLAY_OPTIONS m_Display
PCBNEW_SETTINGS * GetPcbNewSettings() const
FOOTPRINT * LoadFootprint(const LIB_ID &aFootprintId)
Attempt to load aFootprintId from the footprint library table.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
The main frame for Pcbnew.
void OnModify() override
Must be called after a board change to set the modified flag.
void ExchangeFootprint(FOOTPRINT *aExisting, FOOTPRINT *aNew, BOARD_COMMIT &aCommit, bool deleteExtraTexts=true, bool resetTextLayers=true, bool resetTextEffects=true, bool resetFabricationAttrs=true, bool resetTextContent=true, bool reset3DModels=true, bool *aUpdated=nullptr)
Replace aExisting footprint by aNew footprint using the Existing footprint settings (position,...
void SetName(const wxString &aName)
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.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
Handle a list of polygons defining a copper zone.
PCB_LAYER_ID
A quick note on layer IDs:
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
wxString UnescapeString(const wxString &aSource)
constexpr int mmToIU(double mm) const
bool m_DisplayInvertYAxis
bool m_DisplayInvertXAxis
bool m_ShowGlobalRatsnest
wxString GetCanonicalFieldName(int idx)
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)