126 bestPosition.
x = pageSize.
x / 2;
127 bestPosition.
y = pageSize.
y / 2;
140 msg.Printf(
_(
"Cannot add %s (no footprint assigned)." ),
150 if( footprint ==
nullptr )
152 msg.Printf(
_(
"Cannot add %s (footprint '%s' not found)." ),
162 msg.Printf(
_(
"Add %s (footprint '%s')." ),
177 pad->SetNetCode( 0 );
192 msg.Printf(
_(
"Added %s (footprint '%s')." ),
210 msg.Printf(
_(
"Cannot update %s (no footprint assigned)." ),
220 if( newFootprint ==
nullptr )
222 msg.Printf(
_(
"Cannot update %s (footprint '%s' not found)." ),
232 msg.Printf(
_(
"Change %s footprint from '%s' to '%s'."),
238 newFootprint =
nullptr;
244 msg.Printf(
_(
"Changed %s footprint from '%s' to '%s'."),
267 copy->SetParentGroup(
nullptr );
270 bool changed =
false;
277 msg.Printf(
_(
"Change %s reference designator to %s." ),
283 msg.Printf(
_(
"Changed %s reference designator to %s." ),
299 msg.Printf(
_(
"Change %s value from %s to %s." ),
306 msg.Printf(
_(
"Changed %s value from %s to %s." ),
330 if( !aNetlistComponent->
GetKIIDs().empty() )
331 new_path.push_back( aNetlistComponent->
GetKIIDs().front() );
333 if( aPcbFootprint->
GetPath() != new_path )
337 msg.Printf(
_(
"Update %s symbol association from %s to %s." ),
344 msg.Printf(
_(
"Updated %s symbol association from %s to %s." ),
350 aPcbFootprint->
SetPath( new_path );
356 nlohmann::ordered_map<wxString, wxString> fpFieldsAsMap;
361 if( field->IsReference() || field->IsValue() || field->IsFootprint() )
364 fpFieldsAsMap[field->GetName()] = field->GetText();
368 nlohmann::ordered_map<wxString, wxString> compFields = aNetlistComponent->
GetFields();
378 for( std::pair<wxString, wxString> field : compFields )
380 if( fpFieldsAsMap.count( field.first ) == 0 || fpFieldsAsMap[field.first] != field.second )
391 msg.Printf(
_(
"Update %s fields." ), aPcbFootprint->
GetReference() );
397 if( field->IsMandatoryField() )
400 if( compFields.count( field->GetName() ) == 0 )
402 msg.Printf(
_(
"Remove %s footprint fields not in symbol." ),
411 msg.Printf(
_(
"Updated %s fields." ), aPcbFootprint->
GetReference() );
417 for(
auto& [
name, value] : compFields )
442 view->
Add( newField );
452 if( field->IsMandatoryField() )
455 if( compFields.count( field->GetName() ) == 0 )
460 msg.Printf(
_(
"Removed %s footprint fields not in symbol." ),
465 aPcbFootprint->
RemoveField( field->GetCanonicalName() );
478 if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetname" ) ) > 0 )
479 sheetname = aNetlistComponent->
GetProperties().at( wxT(
"Sheetname" ) );
481 if( aNetlistComponent->
GetProperties().count( wxT(
"Sheetfile" ) ) > 0 )
482 sheetfile = aNetlistComponent->
GetProperties().at( wxT(
"Sheetfile" ) );
484 if( aNetlistComponent->
GetProperties().count( wxT(
"ki_fp_filters" ) ) > 0 )
485 fpFilters = aNetlistComponent->
GetProperties().at( wxT(
"ki_fp_filters" ) );
491 msg.Printf(
_(
"Update %s sheetname to '%s'." ),
498 msg.Printf(
_(
"Updated %s sheetname to '%s'." ),
510 msg.Printf(
_(
"Update %s sheetfile to '%s'." ),
517 msg.Printf(
_(
"Updated %s sheetfile to '%s'." ),
525 if( fpFilters != aPcbFootprint->
GetFilters() )
529 msg.Printf(
_(
"Update %s footprint filters to '%s'." ),
536 msg.Printf(
_(
"Updated %s footprint filters to '%s'." ),
544 if( ( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) > 0 )
549 if( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) )
551 msg.Printf(
_(
"Add %s 'exclude from BOM' fabrication attribute." ),
556 msg.Printf(
_(
"Remove %s 'exclude from BOM' fabrication attribute." ),
564 if( aNetlistComponent->
GetProperties().count( wxT(
"exclude_from_bom" ) ) )
567 msg.Printf(
_(
"Added %s 'exclude from BOM' fabrication attribute." ),
572 attributes &= ~FP_EXCLUDE_FROM_BOM;
573 msg.Printf(
_(
"Removed %s 'exclude from BOM' fabrication attribute." ),
584 if( ( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) > 0 )
589 if( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) )
591 msg.Printf(
_(
"Add %s 'Do not place' fabrication attribute." ),
596 msg.Printf(
_(
"Remove %s 'Do not place' fabrication attribute." ),
604 if( aNetlistComponent->
GetProperties().count( wxT(
"dnp" ) ) )
607 msg.Printf(
_(
"Added %s 'Do not place' fabrication attribute." ),
612 attributes &= ~FP_DNP;
613 msg.Printf(
_(
"Removed %s 'Do not place' fabrication attribute." ),
624 if( changed &&
copy )
644 copy->SetParentGroup(
nullptr );
647 bool changed =
false;
650 PADS pads = aFootprint->
Pads();
651 std::set<wxString> padNetnames;
653 std::sort( pads.begin(), pads.end(),
656 return a->m_Uuid < b->m_Uuid;
663 wxString pinFunction;
674 if(
pad->GetPinFunction() != pinFunction )
677 pad->SetPinFunction( pinFunction );
680 if(
pad->GetPinType() != pinType )
683 pad->SetPinType( pinType );
692 if( !net.
IsValid() || !
pad->IsOnCopperLayer() )
694 if( !
pad->GetNetname().IsEmpty() )
698 msg.Printf(
_(
"Disconnect %s pin %s." ),
704 msg.Printf(
_(
"Disconnected %s pin %s." ),
711 else if(
pad->IsOnCopperLayer() && !
pad->GetNumber().IsEmpty() )
714 msg.Printf(
_(
"No net found for component %s pad %s (no pin %s in symbol)." ),
729 if(
pad->GetNetname().IsEmpty() )
730 pad->SetPinFunction( wxEmptyString );
742 if(
pad->IsNoConnectPad() )
744 for(
int jj = 0; !padNetnames.insert( netName ).second; jj++ )
745 netName = wxString::Format( wxS(
"%s_%d" ), net.
GetNetName(), jj );
753 if(
pad->GetNetname() != netName )
756 if( netinfo ==
nullptr )
763 if( netinfo ==
nullptr )
779 if( !
pad->GetNetname().IsEmpty() )
785 msg.Printf(
_(
"Reconnect %s pin %s from %s to %s."),
793 msg.Printf(
_(
"Reconnected %s pin %s from %s to %s."),
804 msg.Printf(
_(
"Connect %s pin %s to %s."),
811 msg.Printf(
_(
"Connected %s pin %s to %s."),
823 pad->SetNet( netinfo );
833 if( changed &&
copy )
846 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
857 std::set<wxString> netlistNetnames;
859 for(
int ii = 0; ii < (int) aNetlist.
GetCount(); ii++ )
863 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
875 if( netlistNetnames.count(
via->GetNetname() ) == 0 )
877 wxString updatedNetname = wxEmptyString;
886 if( !updatedNetname.IsEmpty() )
890 wxString originalNetname =
via->GetNetname();
892 msg.Printf(
_(
"Reconnect via from %s to %s." ),
907 wxString originalNetname =
via->GetNetname();
910 via->SetNet( netinfo );
912 msg.Printf(
_(
"Reconnected via from %s to %s." ),
922 msg.Printf(
_(
"Via connected to unknown net (%s)." ),
933 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
936 if( netlistNetnames.count( zone->GetNetname() ) == 0 )
941 wxString updatedNetname = wxEmptyString;
954 if( updatedNetname.IsEmpty() &&
m_oldToNewNets.count( zone->GetNetname() ) )
959 if( !updatedNetname.IsEmpty() )
963 wxString originalNetname = zone->GetNetname();
965 if( !zone->GetZoneName().IsEmpty() )
967 msg.Printf(
_(
"Reconnect copper zone '%s' from %s to %s." ),
974 msg.Printf(
_(
"Reconnect copper zone from %s to %s." ),
990 wxString originalNetname = zone->GetNetname();
993 zone->SetNet( netinfo );
995 if( !zone->GetZoneName().IsEmpty() )
997 msg.Printf(
_(
"Reconnected copper zone '%s' from %s to %s." ),
1004 msg.Printf(
_(
"Reconnected copper zone from %s to %s." ),
1015 if( !zone->GetZoneName().IsEmpty() )
1017 msg.Printf(
_(
"Copper zone '%s' has no pads connected." ),
1018 zone->GetZoneName() );
1023 VECTOR2I pos = zone->GetPosition();
1025 msg.Printf(
_(
"Copper zone on layer %s at (%s, %s) has no pads connected." ),
1042 std::map<COMPONENT*, FOOTPRINT*>& aFootprintMap )
1050 for(
int i = 0; i < (int) aNetlist.
GetCount(); i++ )
1053 FOOTPRINT* footprint = aFootprintMap[component];
1059 for(
unsigned jj = 0; jj < component->
GetNetCount(); jj++ )
1063 if( padNumber.IsEmpty() )
1066 msg.Printf(
_(
"Symbol %s has pins with no number. These pins can not be matched "
1076 msg.Printf(
_(
"%s pad %s not found in %s." ),
1092 FOOTPRINT* lastPreexistingFootprint =
nullptr;
1100 std::map<COMPONENT*, FOOTPRINT*> footprintMap;
1113 net->SetIsCurrent( net->GetNetCode() == 0 );
1119 for(
unsigned i = 0; i < aNetlist.
GetCount(); i++ )
1123 if( component->
GetProperties().count( wxT(
"exclude_from_board" ) ) )
1126 msg.Printf(
_(
"Processing symbol '%s:%s'." ),
1142 base.push_back( uuid );
1144 if( footprint->GetPath() == base )
1153 match = footprint->GetReference().CmpNoCase( component->
GetReference() ) == 0;
1165 footprintMap[ component ] = tmp;
1174 if( footprint == lastPreexistingFootprint )
1181 if( matchCount == 0 )
1187 footprintMap[ component ] = footprint;
1193 else if( matchCount > 1 )
1195 msg.Printf(
_(
"Multiple footprints found for '%s'." ), component->
GetReference() );
1208 bool matched =
false;
1219 if( component && component->
GetProperties().count( wxT(
"exclude_from_board" ) ) == 0 )
1222 if( doDelete && !matched && footprint->IsLocked() )
1226 msg.Printf(
_(
"Cannot remove unused footprint %s (locked)." ),
1227 footprint->GetReference() );
1231 msg.Printf(
_(
"Could not remove unused footprint %s (locked)." ),
1232 footprint->GetReference() );
1240 if( doDelete && !matched )
1244 msg.Printf(
_(
"Remove unused footprint %s." ), footprint->GetReference() );
1249 msg.Printf(
_(
"Removed unused footprint %s." ), footprint->GetReference() );
1259 for(
PAD*
pad : footprint->Pads() )
1262 pad->GetNet()->SetIsCurrent(
true );
1274 if( !net->IsCurrent() )
1276 msg.Printf(
_(
"Removed unused net %s." ), net->GetNetname() );
1298 for(
const std::pair<const wxString, NETINFO_ITEM*>& addedNet :
m_addedNets )
1299 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.
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
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.
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.
FOOTPRINTS & Footprints()
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
coord_type GetHeight() const
coord_type GetWidth() const
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)
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 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
virtual void SetParent(EDA_ITEM *aParent)
virtual void SetVisible(bool aVisible)
virtual void SetText(const wxString &aText)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
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 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 UnescapeString(const wxString &aSource)
constexpr int mmToIU(double mm) const
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)