KiCad PCB EDA Suite
BOARD_NETLIST_UPDATER Class Reference

Update the BOARD with a new netlist. More...

#include <board_netlist_updater.h>

Public Member Functions

 BOARD_NETLIST_UPDATER (PCB_EDIT_FRAME *aFrame, BOARD *aBoard)
 
 ~BOARD_NETLIST_UPDATER ()
 
bool UpdateNetlist (NETLIST &aNetlist)
 Update the board's components according to the new netlist. More...
 
void SetReporter (REPORTER *aReporter)
 Enable dry run mode (just report, no changes to PCB). More...
 
void SetIsDryRun (bool aEnabled)
 
void SetReplaceFootprints (bool aEnabled)
 
void SetDeleteUnusedFootprints (bool aEnabled)
 
void SetLookupByTimestamp (bool aEnabled)
 
std::vector< FOOTPRINT * > GetAddedFootprints () const
 

Private Member Functions

void cacheNetname (PAD *aPad, const wxString &aNetname)
 
wxString getNetname (PAD *aPad)
 
void cachePinFunction (PAD *aPad, const wxString &aPinFunction)
 
wxString getPinFunction (PAD *aPad)
 
VECTOR2I estimateFootprintInsertionPosition ()
 
FOOTPRINTaddNewFootprint (COMPONENT *aComponent)
 
FOOTPRINTreplaceFootprint (NETLIST &aNetlist, FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
 
bool updateFootprintParameters (FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
 
bool updateComponentPadConnections (FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
 
void cacheCopperZoneConnections ()
 
bool updateCopperZoneNets (NETLIST &aNetlist)
 
bool testConnectivity (NETLIST &aNetlist, std::map< COMPONENT *, FOOTPRINT * > &aFootprintMap)
 

Private Attributes

PCB_EDIT_FRAMEm_frame
 
BOARD_COMMIT m_commit
 
BOARDm_board
 
REPORTERm_reporter
 
std::map< ZONE *, std::vector< PAD * > > m_zoneConnectionsCache
 
std::map< wxString, wxString > m_oldToNewNets
 
std::map< PAD *, wxString > m_padNets
 
std::map< PAD *, wxString > m_padPinFunctions
 
std::vector< FOOTPRINT * > m_addedFootprints
 
std::map< wxString, NETINFO_ITEM * > m_addedNets
 
bool m_deleteUnusedFootprints
 
bool m_isDryRun
 
bool m_replaceFootprints
 
bool m_lookupByTimestamp
 
int m_warningCount
 
int m_errorCount
 
int m_newFootprintsCount
 

Detailed Description

Update the BOARD with a new netlist.

The changes are made to the board are as follows they are not disabled in the status settings in the NETLIST:

  • If a new component is found in the NETLIST and not in the BOARD, it is added to the BOARD.
  • If a the component in the NETLIST is already on the BOARD, then one or more of the following actions can occur:
    • If the footprint name in the NETLIST does not match the footprint name on the BOARD, the footprint on the BOARD is replaced with the footprint specified in the NETLIST and the proper parameters are copied from the existing footprint.
    • If the reference designator in the NETLIST does not match the reference designator on the BOARD, the reference designator is updated from the NETLIST.
    • If the value field in the NETLIST does not match the value field on the BOARD, the value field is updated from the NETLIST.
    • If the time stamp in the NETLIST does not match the time stamp on the BOARD, the time stamp is updated from the NETLIST.
  • After each footprint is added or update as described above, each footprint pad net name is compared and updated to the value defined in the NETLIST.
  • After all of the footprints have been added, updated, and net names and pin function properly set, any extra unlocked footprints are removed from the BOARD.

Definition at line 65 of file board_netlist_updater.h.

Constructor & Destructor Documentation

◆ BOARD_NETLIST_UPDATER()

BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER ( PCB_EDIT_FRAME aFrame,
BOARD aBoard 
)

Definition at line 49 of file board_netlist_updater.cpp.

References NULL_REPORTER::GetInstance(), m_deleteUnusedFootprints, m_errorCount, m_isDryRun, m_lookupByTimestamp, m_newFootprintsCount, m_replaceFootprints, m_reporter, and m_warningCount.

◆ ~BOARD_NETLIST_UPDATER()

BOARD_NETLIST_UPDATER::~BOARD_NETLIST_UPDATER ( )

Definition at line 67 of file board_netlist_updater.cpp.

68{
69}

Member Function Documentation

◆ addNewFootprint()

FOOTPRINT * BOARD_NETLIST_UPDATER::addNewFootprint ( COMPONENT aComponent)
private

Definition at line 133 of file board_netlist_updater.cpp.

134{
135 wxString msg;
136
137 if( aComponent->GetFPID().empty() )
138 {
139 msg.Printf( _( "Cannot add %s (no footprint assigned)." ),
140 aComponent->GetReference(),
141 aComponent->GetFPID().Format().wx_str() );
143 ++m_errorCount;
144 return nullptr;
145 }
146
147 FOOTPRINT* footprint = m_frame->LoadFootprint( aComponent->GetFPID() );
148
149 if( footprint == nullptr )
150 {
151 msg.Printf( _( "Cannot add %s (footprint '%s' not found)." ),
152 aComponent->GetReference(),
153 aComponent->GetFPID().Format().wx_str() );
155 ++m_errorCount;
156 return nullptr;
157 }
158
159 if( m_isDryRun )
160 {
161 msg.Printf( _( "Add %s (footprint '%s')." ),
162 aComponent->GetReference(),
163 aComponent->GetFPID().Format().wx_str() );
164
165 delete footprint;
166 footprint = nullptr;
167 }
168 else
169 {
170 for( PAD* pad : footprint->Pads() )
171 {
172 // Set the pads ratsnest settings to the global settings
173 pad->SetLocalRatsnestVisible( m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest );
174
175 // Pads in the library all have orphaned nets. Replace with Default.
176 pad->SetNetCode( 0 );
177 }
178
179 footprint->SetParent( m_board );
181
182 // This flag is used to prevent connectivity from considering the footprint during its
183 // initial build after the footprint is committed, because we're going to immediately start
184 // a move operation on the footprint and don't want its pads to drive nets onto vias/tracks
185 // it happens to land on at the initial position.
186 footprint->SetAttributes( footprint->GetAttributes() | FP_JUST_ADDED );
187
188 m_addedFootprints.push_back( footprint );
189 m_commit.Add( footprint );
190
191 msg.Printf( _( "Added %s (footprint '%s')." ),
192 aComponent->GetReference(),
193 aComponent->GetFPID().Format().wx_str() );
194 }
195
198 return footprint;
199}
std::vector< FOOTPRINT * > m_addedFootprints
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
Definition: commit.h:78
const wxString & GetReference() const
Definition: pcb_netlist.h:126
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:138
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:1658
void SetAttributes(int aAttributes)
Definition: footprint.h:251
int GetAttributes() const
Definition: footprint.h:250
PADS & Pads()
Definition: footprint.h:170
bool empty() const
Definition: lib_id.h:186
UTF8 Format() const
Definition: lib_id.cpp:117
Definition: pad.h:59
DISPLAY_OPTIONS m_Display
PCBNEW_SETTINGS * GetPcbNewSettings() const
FOOTPRINT * LoadFootprint(const LIB_ID &aFootprintId)
Attempt to load aFootprintId from the footprint library table.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
wxString wx_str() const
Definition: utf8.cpp:46
#define _(s)
@ FP_JUST_ADDED
Definition: footprint.h:73
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_ACTION

References _, COMMIT::Add(), LIB_ID::empty(), estimateFootprintInsertionPosition(), LIB_ID::Format(), FP_JUST_ADDED, FOOTPRINT::GetAttributes(), COMPONENT::GetFPID(), PCB_BASE_FRAME::GetPcbNewSettings(), COMPONENT::GetReference(), PCB_BASE_FRAME::LoadFootprint(), m_addedFootprints, m_board, m_commit, PCBNEW_SETTINGS::m_Display, m_errorCount, m_frame, m_isDryRun, m_newFootprintsCount, m_reporter, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_ShowGlobalRatsnest, pad, FOOTPRINT::Pads(), REPORTER::Report(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, FOOTPRINT::SetAttributes(), EDA_ITEM::SetParent(), FOOTPRINT::SetPosition(), and UTF8::wx_str().

Referenced by UpdateNetlist().

◆ cacheCopperZoneConnections()

void BOARD_NETLIST_UPDATER::cacheCopperZoneConnections ( )
private

Definition at line 645 of file board_netlist_updater.cpp.

646{
647 for( ZONE* zone : m_board->Zones() )
648 {
649 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
650 continue;
651
652 m_zoneConnectionsCache[ zone ] = m_board->GetConnectivity()->GetConnectedPads( zone );
653 }
654}
std::map< ZONE *, std::vector< PAD * > > m_zoneConnectionsCache
ZONES & Zones()
Definition: board.h:313
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
Handle a list of polygons defining a copper zone.
Definition: zone.h:57

References BOARD::GetConnectivity(), m_board, m_zoneConnectionsCache, and BOARD::Zones().

Referenced by UpdateNetlist().

◆ cacheNetname()

void BOARD_NETLIST_UPDATER::cacheNetname ( PAD aPad,
const wxString &  aNetname 
)
private

Definition at line 75 of file board_netlist_updater.cpp.

76{
77 m_padNets[ aPad ] = aNetname;
78}
std::map< PAD *, wxString > m_padNets

References m_padNets.

Referenced by updateComponentPadConnections().

◆ cachePinFunction()

void BOARD_NETLIST_UPDATER::cachePinFunction ( PAD aPad,
const wxString &  aPinFunction 
)
private

Definition at line 90 of file board_netlist_updater.cpp.

91{
92 m_padPinFunctions[ aPad ] = aPinFunction;
93}
std::map< PAD *, wxString > m_padPinFunctions

References m_padPinFunctions.

Referenced by updateComponentPadConnections().

◆ estimateFootprintInsertionPosition()

VECTOR2I BOARD_NETLIST_UPDATER::estimateFootprintInsertionPosition ( )
private

Definition at line 105 of file board_netlist_updater.cpp.

106{
107 VECTOR2I bestPosition;
108
109 if( !m_board->IsEmpty() )
110 {
111 // Position new components below any existing board features.
113
114 if( bbox.GetWidth() || bbox.GetHeight() )
115 {
116 bestPosition.x = bbox.Centre().x;
117 bestPosition.y = bbox.GetBottom() + pcbIUScale.mmToIU( 10 );
118 }
119 }
120 else
121 {
122 // Position new components in the center of the page when the board is empty.
124
125 bestPosition.x = pageSize.GetWidth() / 2;
126 bestPosition.y = pageSize.GetHeight() / 2;
127 }
128
129 return bestPosition;
130}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition: board.h:823
const PAGE_INFO & GetPageSettings() const
Definition: board.h:626
bool IsEmpty() const
Definition: board.h:355
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
Vec Centre() const
Definition: box2.h:70
coord_type GetBottom() const
Definition: box2.h:190
const wxSize GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:162
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int mmToIU(double mm) const
Definition: base_units.h:89

References BOX2< Vec >::Centre(), BOARD::GetBoardEdgesBoundingBox(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetHeight(), BOARD::GetPageSettings(), PAGE_INFO::GetSizeIU(), BOX2< Vec >::GetWidth(), BOARD::IsEmpty(), EDA_IU_SCALE::IU_PER_MILS, m_board, EDA_IU_SCALE::mmToIU(), pcbIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by addNewFootprint().

◆ GetAddedFootprints()

std::vector< FOOTPRINT * > BOARD_NETLIST_UPDATER::GetAddedFootprints ( ) const
inline

Definition at line 92 of file board_netlist_updater.h.

92{ return m_addedFootprints; }

References m_addedFootprints.

Referenced by PCB_EDIT_FRAME::OnNetlistChanged().

◆ getNetname()

wxString BOARD_NETLIST_UPDATER::getNetname ( PAD aPad)
private

Definition at line 81 of file board_netlist_updater.cpp.

82{
83 if( m_isDryRun && m_padNets.count( aPad ) )
84 return m_padNets[ aPad ];
85 else
86 return aPad->GetNetname();
87}

References BOARD_CONNECTED_ITEM::GetNetname(), m_isDryRun, and m_padNets.

Referenced by updateCopperZoneNets().

◆ getPinFunction()

wxString BOARD_NETLIST_UPDATER::getPinFunction ( PAD aPad)
private

Definition at line 96 of file board_netlist_updater.cpp.

97{
98 if( m_isDryRun && m_padPinFunctions.count( aPad ) )
99 return m_padPinFunctions[ aPad ];
100 else
101 return aPad->GetPinFunction();
102}
const wxString & GetPinFunction() const
Definition: pad.h:146

References PAD::GetPinFunction(), m_isDryRun, and m_padPinFunctions.

◆ replaceFootprint()

FOOTPRINT * BOARD_NETLIST_UPDATER::replaceFootprint ( NETLIST aNetlist,
FOOTPRINT aFootprint,
COMPONENT aNewComponent 
)
private

Definition at line 202 of file board_netlist_updater.cpp.

204{
205 wxString msg;
206
207 if( aNewComponent->GetFPID().empty() )
208 {
209 msg.Printf( _( "Cannot update %s (no footprint assigned)." ),
210 aNewComponent->GetReference(),
211 aNewComponent->GetFPID().Format().wx_str() );
213 ++m_errorCount;
214 return nullptr;
215 }
216
217 FOOTPRINT* newFootprint = m_frame->LoadFootprint( aNewComponent->GetFPID() );
218
219 if( newFootprint == nullptr )
220 {
221 msg.Printf( _( "Cannot update %s (footprint '%s' not found)." ),
222 aNewComponent->GetReference(),
223 aNewComponent->GetFPID().Format().wx_str() );
225 ++m_errorCount;
226 return nullptr;
227 }
228
229 if( m_isDryRun )
230 {
231 msg.Printf( _( "Change %s footprint from '%s' to '%s'."),
232 aFootprint->GetReference(),
233 aFootprint->GetFPID().Format().wx_str(),
234 aNewComponent->GetFPID().Format().wx_str() );
235
236 delete newFootprint;
237 newFootprint = nullptr;
238 }
239 else
240 {
241 m_frame->ExchangeFootprint( aFootprint, newFootprint, m_commit );
242
243 msg.Printf( _( "Changed %s footprint from '%s' to '%s'."),
244 aFootprint->GetReference(),
245 aFootprint->GetFPID().Format().wx_str(),
246 aNewComponent->GetFPID().Format().wx_str() );
247 }
248
251 return newFootprint;
252}
const LIB_ID & GetFPID() const
Definition: footprint.h:212
const wxString & GetReference() const
Definition: footprint.h:519
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,...

References _, LIB_ID::empty(), PCB_EDIT_FRAME::ExchangeFootprint(), LIB_ID::Format(), FOOTPRINT::GetFPID(), COMPONENT::GetFPID(), FOOTPRINT::GetReference(), COMPONENT::GetReference(), PCB_BASE_FRAME::LoadFootprint(), m_commit, m_errorCount, m_frame, m_isDryRun, m_newFootprintsCount, m_reporter, REPORTER::Report(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, and UTF8::wx_str().

Referenced by UpdateNetlist().

◆ SetDeleteUnusedFootprints()

void BOARD_NETLIST_UPDATER::SetDeleteUnusedFootprints ( bool  aEnabled)
inline

◆ SetIsDryRun()

void BOARD_NETLIST_UPDATER::SetIsDryRun ( bool  aEnabled)
inline

Definition at line 84 of file board_netlist_updater.h.

84{ m_isDryRun = aEnabled; }

References m_isDryRun.

Referenced by DIALOG_NETLIST_IMPORT::loadNetlist(), and DIALOG_UPDATE_PCB::PerformUpdate().

◆ SetLookupByTimestamp()

void BOARD_NETLIST_UPDATER::SetLookupByTimestamp ( bool  aEnabled)
inline

◆ SetReplaceFootprints()

void BOARD_NETLIST_UPDATER::SetReplaceFootprints ( bool  aEnabled)
inline

◆ SetReporter()

void BOARD_NETLIST_UPDATER::SetReporter ( REPORTER aReporter)
inline

Enable dry run mode (just report, no changes to PCB).

Definition at line 81 of file board_netlist_updater.h.

References m_reporter.

Referenced by DIALOG_NETLIST_IMPORT::loadNetlist(), and DIALOG_UPDATE_PCB::PerformUpdate().

◆ testConnectivity()

bool BOARD_NETLIST_UPDATER::testConnectivity ( NETLIST aNetlist,
std::map< COMPONENT *, FOOTPRINT * > &  aFootprintMap 
)
private

Definition at line 836 of file board_netlist_updater.cpp.

838{
839 // Verify that board contains all pads in netlist: if it doesn't then footprints are
840 // wrong or missing.
841
842 wxString msg;
843 wxString padNumber;
844
845 for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
846 {
847 COMPONENT* component = aNetlist.GetComponent( i );
848 FOOTPRINT* footprint = aFootprintMap[component];
849
850 if( !footprint ) // It can be missing in partial designs
851 continue;
852
853 // Explore all pins/pads in component
854 for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
855 {
856 padNumber = component->GetNet( jj ).GetPinName();
857
858 if( padNumber.IsEmpty() )
859 {
860 // bad symbol, report error
861 msg.Printf( _( "Symbol %s has pins with no number. These pins can not be matched "
862 "to pads in %s." ),
863 component->GetReference(),
864 footprint->GetFPID().Format().wx_str() );
866 ++m_errorCount;
867 }
868 else if( !footprint->FindPadByNumber( padNumber ) )
869 {
870 // not found: bad footprint, report error
871 msg.Printf( _( "%s pad %s not found in %s." ),
872 component->GetReference(),
873 padNumber,
874 footprint->GetFPID().Format().wx_str() );
876 ++m_errorCount;
877 }
878 }
879 }
880
881 return true;
882}
const wxString & GetPinName() const
Definition: pcb_netlist.h:57
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:85
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:111
unsigned GetNetCount() const
Definition: pcb_netlist.h:109
PAD * FindPadByNumber(const wxString &aPadNumber, PAD *aSearchAfterMe=nullptr) const
Return a PAD with a matching number.
Definition: footprint.cpp:1162
unsigned GetCount() const
Definition: pcb_netlist.h:234
COMPONENT * GetComponent(unsigned aIndex)
Return the COMPONENT at aIndex.
Definition: pcb_netlist.h:242

References _, FOOTPRINT::FindPadByNumber(), LIB_ID::Format(), NETLIST::GetComponent(), NETLIST::GetCount(), FOOTPRINT::GetFPID(), COMPONENT::GetNet(), COMPONENT::GetNetCount(), COMPONENT_NET::GetPinName(), COMPONENT::GetReference(), m_errorCount, m_reporter, REPORTER::Report(), RPT_SEVERITY_ERROR, and UTF8::wx_str().

Referenced by UpdateNetlist().

◆ updateComponentPadConnections()

bool BOARD_NETLIST_UPDATER::updateComponentPadConnections ( FOOTPRINT aFootprint,
COMPONENT aNewComponent 
)
private

Definition at line 454 of file board_netlist_updater.cpp.

456{
457 wxString msg;
458
459 // Create a copy only if the footprint has not been added during this update
460 FOOTPRINT* copy = nullptr;
461
462 if( m_commit.GetStatus( aFootprint ) )
463 {
464 copy = static_cast<FOOTPRINT*>( aFootprint->Clone() );
465 copy->SetParentGroup( nullptr );
466 }
467
468 bool changed = false;
469
470 // At this point, the component footprint is updated. Now update the nets.
471 for( PAD* pad : aFootprint->Pads() )
472 {
473 const COMPONENT_NET& net = aNewComponent->GetNet( pad->GetNumber() );
474
475 wxString pinFunction;
476 wxString pinType;
477
478 if( net.IsValid() ) // i.e. the pad has a name
479 {
480 pinFunction = net.GetPinFunction();
481 pinType = net.GetPinType();
482 }
483
484 if( !m_isDryRun )
485 {
486 if( pad->GetPinFunction() != pinFunction )
487 {
488 changed = true;
489 pad->SetPinFunction( pinFunction );
490 }
491
492 if( pad->GetPinType() != pinType )
493 {
494 changed = true;
495 pad->SetPinType( pinType );
496 }
497 }
498 else
499 {
500 cachePinFunction( pad, pinFunction );
501 }
502
503 // Test if new footprint pad has no net (pads not on copper layers have no net).
504 if( !net.IsValid() || !pad->IsOnCopperLayer() )
505 {
506 if( !pad->GetNetname().IsEmpty() )
507 {
508 if( m_isDryRun )
509 {
510 msg.Printf( _( "Disconnect %s pin %s." ),
511 aFootprint->GetReference(),
512 pad->GetNumber() );
513 }
514 else
515 {
516 msg.Printf( _( "Disconnected %s pin %s." ),
517 aFootprint->GetReference(),
518 pad->GetNumber() );
519 }
520
522 }
523 else if( pad->IsOnCopperLayer() && !pad->GetNumber().IsEmpty() )
524 {
525 // pad is connectable but has no net found in netlist
526 msg.Printf( _( "No net found for symbol %s pin %s." ),
527 aFootprint->GetReference(),
528 pad->GetNumber() );
530 }
531
532 if( !m_isDryRun )
533 {
534 changed = true;
535 pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
536
537 // If the pad has no net from netlist (i.e. not in netlist
538 // it cannot have a pin function
539 if( pad->GetNetname().IsEmpty() )
540 pad->SetPinFunction( wxEmptyString );
541
542 }
543 else
544 {
545 cacheNetname( pad, wxEmptyString );
546 }
547 }
548 else // New footprint pad has a net.
549 {
550 const wxString& netName = net.GetNetName();
551 NETINFO_ITEM* netinfo = m_board->FindNet( netName );
552
553 if( netinfo && !m_isDryRun )
554 netinfo->SetIsCurrent( true );
555
556 if( pad->GetNetname() != netName )
557 {
558
559 if( netinfo == nullptr )
560 {
561 // It might be a new net that has not been added to the board yet
562 if( m_addedNets.count( netName ) )
563 netinfo = m_addedNets[ netName ];
564 }
565
566 if( netinfo == nullptr )
567 {
568 netinfo = new NETINFO_ITEM( m_board, netName );
569
570 // It is a new net, we have to add it
571 if( !m_isDryRun )
572 {
573 changed = true;
574 m_commit.Add( netinfo );
575 }
576
577 m_addedNets[netName] = netinfo;
578 msg.Printf( _( "Add net %s." ), UnescapeString( netName ) );
580 }
581
582 if( !pad->GetNetname().IsEmpty() )
583 {
584 m_oldToNewNets[ pad->GetNetname() ] = netName;
585
586 if( m_isDryRun )
587 {
588 msg.Printf( _( "Reconnect %s pin %s from %s to %s."),
589 aFootprint->GetReference(),
590 pad->GetNumber(),
591 UnescapeString( pad->GetNetname() ),
592 UnescapeString( netName ) );
593 }
594 else
595 {
596 msg.Printf( _( "Reconnected %s pin %s from %s to %s."),
597 aFootprint->GetReference(),
598 pad->GetNumber(),
599 UnescapeString( pad->GetNetname() ),
600 UnescapeString( netName ) );
601 }
602 }
603 else
604 {
605 if( m_isDryRun )
606 {
607 msg.Printf( _( "Connect %s pin %s to %s."),
608 aFootprint->GetReference(),
609 pad->GetNumber(),
610 UnescapeString( netName ) );
611 }
612 else
613 {
614 msg.Printf( _( "Connected %s pin %s to %s."),
615 aFootprint->GetReference(),
616 pad->GetNumber(),
617 UnescapeString( netName ) );
618 }
619 }
620
622
623 if( !m_isDryRun )
624 {
625 changed = true;
626 pad->SetNet( netinfo );
627 }
628 else
629 {
630 cacheNetname( pad, netName );
631 }
632 }
633 }
634 }
635
636 if( changed && copy )
637 m_commit.Modified( aFootprint, copy );
638 else if( copy )
639 delete copy;
640
641 return true;
642}
void cacheNetname(PAD *aPad, const wxString &aNetname)
std::map< wxString, wxString > m_oldToNewNets
std::map< wxString, NETINFO_ITEM * > m_addedNets
void cachePinFunction(PAD *aPad, const wxString &aPinFunction)
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1417
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy)
Definition: commit.h:110
int GetStatus(EDA_ITEM *aItem)
Definition: commit.cpp:123
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
Definition: pcb_netlist.h:44
const wxString & GetNetName() const
Definition: pcb_netlist.h:58
bool IsValid() const
Definition: pcb_netlist.h:62
const wxString & GetPinFunction() const
Definition: pcb_netlist.h:59
const wxString & GetPinType() const
Definition: pcb_netlist.h:60
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1361
Handle the data for a net.
Definition: netinfo.h:66
void SetIsCurrent(bool isCurrent)
Definition: netinfo.h:150
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:373
@ RPT_SEVERITY_WARNING
wxString UnescapeString(const wxString &aSource)

References _, COMMIT::Add(), cacheNetname(), cachePinFunction(), FOOTPRINT::Clone(), copy, BOARD::FindNet(), COMPONENT::GetNet(), COMPONENT_NET::GetNetName(), COMPONENT_NET::GetPinFunction(), COMPONENT_NET::GetPinType(), FOOTPRINT::GetReference(), COMMIT::GetStatus(), COMPONENT_NET::IsValid(), m_addedNets, m_board, m_commit, m_isDryRun, m_oldToNewNets, m_reporter, COMMIT::Modified(), pad, FOOTPRINT::Pads(), REPORTER::Report(), RPT_SEVERITY_ACTION, RPT_SEVERITY_WARNING, NETINFO_ITEM::SetIsCurrent(), NETINFO_LIST::UNCONNECTED, and UnescapeString().

Referenced by UpdateNetlist().

◆ updateCopperZoneNets()

bool BOARD_NETLIST_UPDATER::updateCopperZoneNets ( NETLIST aNetlist)
private

Definition at line 657 of file board_netlist_updater.cpp.

658{
659 wxString msg;
660 std::set<wxString> netlistNetnames;
661
662 for( int ii = 0; ii < (int) aNetlist.GetCount(); ii++ )
663 {
664 const COMPONENT* component = aNetlist.GetComponent( ii );
665
666 for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
667 {
668 const COMPONENT_NET& net = component->GetNet( jj );
669 netlistNetnames.insert( net.GetNetName() );
670 }
671 }
672
673 for( PCB_TRACK* via : m_board->Tracks() )
674 {
675 if( via->Type() != PCB_VIA_T )
676 continue;
677
678 if( netlistNetnames.count( via->GetNetname() ) == 0 )
679 {
680 wxString updatedNetname = wxEmptyString;
681
682 // Take via name from name change map if it didn't match to a new pad
683 // (this is useful for stitching vias that don't connect to tracks)
684 if( m_oldToNewNets.count( via->GetNetname() ) )
685 {
686 updatedNetname = m_oldToNewNets[via->GetNetname()];
687 }
688
689 if( !updatedNetname.IsEmpty() )
690 {
691 if( m_isDryRun )
692 {
693 msg.Printf( _( "Reconnect via from %s to %s." ),
694 UnescapeString( via->GetNetname() ),
695 UnescapeString( updatedNetname ) );
696
698 }
699 else
700 {
701 NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
702
703 if( !netinfo )
704 netinfo = m_addedNets[updatedNetname];
705
706 if( netinfo )
707 {
709 via->SetNet( netinfo );
710
711 msg.Printf( _( "Reconnected via from %s to %s." ),
712 UnescapeString( via->GetNetname() ),
713 UnescapeString( updatedNetname ) );
714
716 }
717 }
718 }
719 else
720 {
721 msg.Printf( _( "Via connected to unknown net (%s)." ),
722 UnescapeString( via->GetNetname() ) );
725 }
726 }
727 }
728
729 // Test copper zones to detect "dead" nets (nets without any pad):
730 for( ZONE* zone : m_board->Zones() )
731 {
732 if( !zone->IsOnCopperLayer() || zone->GetIsRuleArea() )
733 continue;
734
735 if( netlistNetnames.count( zone->GetNetname() ) == 0 )
736 {
737 // Look for a pad in the zone's connected-pad-cache which has been updated to
738 // a new net and use that. While this won't always be the right net, the dead
739 // net is guaranteed to be wrong.
740 wxString updatedNetname = wxEmptyString;
741
742 for( PAD* pad : m_zoneConnectionsCache[ zone ] )
743 {
744 if( getNetname( pad ) != zone->GetNetname() )
745 {
746 updatedNetname = getNetname( pad );
747 break;
748 }
749 }
750
751 // Take zone name from name change map if it didn't match to a new pad
752 // (this is useful for zones on internal layers)
753 if( updatedNetname.IsEmpty() && m_oldToNewNets.count( zone->GetNetname() ) )
754 {
755 updatedNetname = m_oldToNewNets[ zone->GetNetname() ];
756 }
757
758 if( !updatedNetname.IsEmpty() )
759 {
760 if( m_isDryRun )
761 {
762 if( !zone->GetZoneName().IsEmpty() )
763 {
764 msg.Printf( _( "Reconnect copper zone '%s' from %s to %s." ),
765 zone->GetZoneName(),
766 UnescapeString( zone->GetNetname() ),
767 UnescapeString( updatedNetname ) );
768 }
769 else
770 {
771 msg.Printf( _( "Reconnect copper zone from %s to %s." ),
772 UnescapeString( zone->GetNetname() ),
773 UnescapeString( updatedNetname ) );
774 }
775
777 }
778 else
779 {
780 NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
781
782 if( !netinfo )
783 netinfo = m_addedNets[ updatedNetname ];
784
785 if( netinfo )
786 {
787 m_commit.Modify( zone );
788 zone->SetNet( netinfo );
789
790 if( !zone->GetZoneName().IsEmpty() )
791 {
792 msg.Printf( _( "Reconnected copper zone '%s' from %s to %s." ),
793 zone->GetZoneName(),
794 UnescapeString( zone->GetNetname() ),
795 UnescapeString( updatedNetname ) );
796 }
797 else
798 {
799 msg.Printf( _( "Reconnected copper zone from %s to %s." ),
800 UnescapeString( zone->GetNetname() ),
801 UnescapeString( updatedNetname ) );
802 }
803
805 }
806 }
807 }
808 else
809 {
810 if( !zone->GetZoneName().IsEmpty() )
811 {
812 msg.Printf( _( "Copper zone '%s' has no pads connected." ),
813 zone->GetZoneName() );
814 }
815 else
816 {
817 PCB_LAYER_ID layer = zone->GetLayer();
818 VECTOR2I pos = zone->GetPosition();
819
820 msg.Printf( _( "Copper zone on layer %s at (%s, %s) has no pads connected." ),
821 m_board->GetLayerName( layer ),
824 }
825
828 }
829 }
830 }
831
832 return true;
833}
wxString getNetname(PAD *aPad)
TRACKS & Tracks()
Definition: board.h:304
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:413
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102

References _, BOARD::FindNet(), NETLIST::GetComponent(), NETLIST::GetCount(), BOARD::GetLayerName(), COMPONENT::GetNet(), COMPONENT::GetNetCount(), COMPONENT_NET::GetNetName(), getNetname(), m_addedNets, m_board, m_commit, m_frame, m_isDryRun, m_oldToNewNets, m_reporter, m_warningCount, m_zoneConnectionsCache, UNITS_PROVIDER::MessageTextFromValue(), COMMIT::Modify(), pad, PCB_VIA_T, REPORTER::Report(), RPT_SEVERITY_ACTION, RPT_SEVERITY_WARNING, BOARD::Tracks(), UnescapeString(), via, VECTOR2< T >::x, VECTOR2< T >::y, and BOARD::Zones().

Referenced by UpdateNetlist().

◆ updateFootprintParameters()

bool BOARD_NETLIST_UPDATER::updateFootprintParameters ( FOOTPRINT aPcbFootprint,
COMPONENT aNetlistComponent 
)
private

Definition at line 255 of file board_netlist_updater.cpp.

257{
258 wxString msg;
259
260 // Create a copy only if the footprint has not been added during this update
261 FOOTPRINT* copy = nullptr;
262
263 if( !m_commit.GetStatus( aPcbFootprint ) )
264 {
265 copy = static_cast<FOOTPRINT*>( aPcbFootprint->Clone() );
266 copy->SetParentGroup( nullptr );
267 }
268
269 bool changed = false;
270
271 // Test for reference designator field change.
272 if( aPcbFootprint->GetReference() != aNetlistComponent->GetReference() )
273 {
274 if( m_isDryRun )
275 {
276 msg.Printf( _( "Change %s reference designator to %s." ),
277 aPcbFootprint->GetReference(),
278 aNetlistComponent->GetReference() );
279 }
280 else
281 {
282 msg.Printf( _( "Changed %s reference designator to %s." ),
283 aPcbFootprint->GetReference(),
284 aNetlistComponent->GetReference() );
285
286 changed = true;
287 aPcbFootprint->SetReference( aNetlistComponent->GetReference() );
288 }
289
291 }
292
293 // Test for value field change.
294 if( aPcbFootprint->GetValue() != aNetlistComponent->GetValue() )
295 {
296 if( m_isDryRun )
297 {
298 msg.Printf( _( "Change %s value from %s to %s." ),
299 aPcbFootprint->GetReference(),
300 aPcbFootprint->GetValue(),
301 aNetlistComponent->GetValue() );
302 }
303 else
304 {
305 msg.Printf( _( "Changed %s value from %s to %s." ),
306 aPcbFootprint->GetReference(),
307 aPcbFootprint->GetValue(),
308 aNetlistComponent->GetValue() );
309
310 changed = true;
311 aPcbFootprint->SetValue( aNetlistComponent->GetValue() );
312 }
313
315 }
316
317 // Test for time stamp change.
318 KIID_PATH new_path = aNetlistComponent->GetPath();
319
320 if( !aNetlistComponent->GetKIIDs().empty() )
321 new_path.push_back( aNetlistComponent->GetKIIDs().front() );
322
323 if( aPcbFootprint->GetPath() != new_path )
324 {
325 if( m_isDryRun )
326 {
327 msg.Printf( _( "Update %s symbol association from %s to %s." ),
328 aPcbFootprint->GetReference(),
329 aPcbFootprint->GetPath().AsString(),
330 new_path.AsString() );
331 }
332 else
333 {
334 msg.Printf( _( "Updated %s symbol association from %s to %s." ),
335 aPcbFootprint->GetReference(),
336 aPcbFootprint->GetPath().AsString(),
337 new_path.AsString() );
338
339 changed = true;
340 aPcbFootprint->SetPath( new_path );
341 }
342
344 }
345
346 if( aPcbFootprint->GetProperties() != aNetlistComponent->GetProperties() )
347 {
348 if( m_isDryRun )
349 {
350 msg.Printf( _( "Update %s properties." ),
351 aPcbFootprint->GetReference() );
352 }
353 else
354 {
355 msg.Printf( _( "Updated %s properties." ),
356 aPcbFootprint->GetReference() );
357
358 changed = true;
359 aPcbFootprint->SetProperties( aNetlistComponent->GetProperties() );
360 }
361
363 }
364
365 if( ( aNetlistComponent->GetProperties().count( wxT( "exclude_from_bom" ) ) > 0 )
366 != ( ( aPcbFootprint->GetAttributes() & FP_EXCLUDE_FROM_BOM ) > 0 ) )
367 {
368 if( m_isDryRun )
369 {
370 if( aNetlistComponent->GetProperties().count( wxT( "exclude_from_bom" ) ) )
371 {
372 msg.Printf( _( "Add %s 'exclude from BOM' fabrication attribute." ),
373 aPcbFootprint->GetReference() );
374 }
375 else
376 {
377 msg.Printf( _( "Remove %s 'exclude from BOM' fabrication attribute." ),
378 aPcbFootprint->GetReference() );
379 }
380 }
381 else
382 {
383 int attributes = aPcbFootprint->GetAttributes();
384
385 if( aNetlistComponent->GetProperties().count( wxT( "exclude_from_bom" ) ) )
386 {
387 attributes |= FP_EXCLUDE_FROM_BOM;
388 msg.Printf( _( "Added %s 'exclude from BOM' fabrication attribute." ),
389 aPcbFootprint->GetReference() );
390 }
391 else
392 {
393 attributes &= ~FP_EXCLUDE_FROM_BOM;
394 msg.Printf( _( "Removed %s 'exclude from BOM' fabrication attribute." ),
395 aPcbFootprint->GetReference() );
396 }
397
398 changed = true;
399 aPcbFootprint->SetAttributes( attributes );
400 }
401
403 }
404
405 if( ( aNetlistComponent->GetProperties().count( wxT( "dnp" ) ) > 0 )
406 != ( ( aPcbFootprint->GetAttributes() & FP_EXCLUDE_FROM_POS_FILES ) > 0 ) )
407 {
408 if( m_isDryRun )
409 {
410 if( aNetlistComponent->GetProperties().count( wxT( "dnp" ) ) )
411 {
412 msg.Printf( _( "Add %s 'exclude from position files' fabrication attribute." ),
413 aPcbFootprint->GetReference() );
414 }
415 else
416 {
417 msg.Printf( _( "Remove %s 'exclude from position files' fabrication attribute." ),
418 aPcbFootprint->GetReference() );
419 }
420 }
421 else
422 {
423 int attributes = aPcbFootprint->GetAttributes();
424
425 if( aNetlistComponent->GetProperties().count( wxT( "dnp" ) ) )
426 {
427 attributes |= FP_EXCLUDE_FROM_POS_FILES;
428 msg.Printf( _( "Added %s 'exclude from position files' fabrication attribute." ),
429 aPcbFootprint->GetReference() );
430 }
431 else
432 {
433 attributes &= ~FP_EXCLUDE_FROM_POS_FILES;
434 msg.Printf( _( "Removed %s 'exclude from position files' fabrication attribute." ),
435 aPcbFootprint->GetReference() );
436 }
437
438 changed = true;
439 aPcbFootprint->SetAttributes( attributes );
440 }
441
443 }
444
445 if( changed && copy )
446 m_commit.Modified( aPcbFootprint, copy );
447 else if( copy )
448 delete copy;
449
450 return true;
451}
const KIID_PATH & GetPath() const
Definition: pcb_netlist.h:143
const wxString & GetValue() const
Definition: pcb_netlist.h:129
const std::map< wxString, wxString > & GetProperties() const
Definition: pcb_netlist.h:135
const std::vector< KIID > & GetKIIDs() const
Definition: pcb_netlist.h:145
void SetPath(const KIID_PATH &aPath)
Definition: footprint.h:225
void SetReference(const wxString &aReference)
Definition: footprint.h:528
void SetValue(const wxString &aValue)
Definition: footprint.h:555
const wxString & GetValue() const
Definition: footprint.h:547
void SetProperties(const std::map< wxString, wxString > &aProps)
Definition: footprint.h:575
const KIID_PATH & GetPath() const
Definition: footprint.h:224
const std::map< wxString, wxString > & GetProperties() const
Definition: footprint.h:574
wxString AsString() const
Definition: kiid.cpp:332
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:70
@ FP_EXCLUDE_FROM_BOM
Definition: footprint.h:71

References _, KIID_PATH::AsString(), FOOTPRINT::Clone(), copy, FP_EXCLUDE_FROM_BOM, FP_EXCLUDE_FROM_POS_FILES, FOOTPRINT::GetAttributes(), COMPONENT::GetKIIDs(), FOOTPRINT::GetPath(), COMPONENT::GetPath(), FOOTPRINT::GetProperties(), COMPONENT::GetProperties(), FOOTPRINT::GetReference(), COMPONENT::GetReference(), COMMIT::GetStatus(), FOOTPRINT::GetValue(), COMPONENT::GetValue(), m_commit, m_isDryRun, m_reporter, COMMIT::Modified(), REPORTER::Report(), RPT_SEVERITY_ACTION, FOOTPRINT::SetAttributes(), FOOTPRINT::SetPath(), FOOTPRINT::SetProperties(), FOOTPRINT::SetReference(), and FOOTPRINT::SetValue().

Referenced by UpdateNetlist().

◆ UpdateNetlist()

bool BOARD_NETLIST_UPDATER::UpdateNetlist ( NETLIST aNetlist)

Update the board's components according to the new netlist.

See BOARD_NETLIST_UPDATER class description for the details of the process.

Parameters
aNetlistthe new netlist
Returns
true if process was completed successfully

Definition at line 885 of file board_netlist_updater.cpp.

886{
887 FOOTPRINT* lastPreexistingFootprint = nullptr;
888 COMPONENT* component = nullptr;
889 wxString msg;
890
891 m_errorCount = 0;
892 m_warningCount = 0;
894
895 std::map<COMPONENT*, FOOTPRINT*> footprintMap;
896
897 if( !m_board->Footprints().empty() )
898 lastPreexistingFootprint = m_board->Footprints().back();
899
901
902 // First mark all nets (except <no net>) as stale; we'll update those which are current
903 // in the following two loops.
904 //
905 if( !m_isDryRun )
906 {
907 m_board->SetStatus( 0 );
908
909 for( NETINFO_ITEM* net : m_board->GetNetInfo() )
910 net->SetIsCurrent( net->GetNetCode() == 0 );
911 }
912
913 // Next go through the netlist updating all board footprints which have matching component
914 // entries and adding new footprints for those that don't.
915 //
916 for( unsigned i = 0; i < aNetlist.GetCount(); i++ )
917 {
918 component = aNetlist.GetComponent( i );
919
920 if( component->GetProperties().count( wxT( "exclude_from_board" ) ) )
921 continue;
922
923 msg.Printf( _( "Processing symbol '%s:%s'." ),
924 component->GetReference(),
925 component->GetFPID().Format().wx_str() );
927
928 int matchCount = 0;
929
930 for( FOOTPRINT* footprint : m_board->Footprints() )
931 {
932 bool match = false;
933
935 {
936 for( const KIID& uuid : component->GetKIIDs() )
937 {
938 KIID_PATH base = component->GetPath();
939 base.push_back( uuid );
940
941 if( footprint->GetPath() == base )
942 {
943 match = true;
944 break;
945 }
946 }
947 }
948 else
949 {
950 match = footprint->GetReference().CmpNoCase( component->GetReference() ) == 0;
951 }
952
953 if( match )
954 {
955 FOOTPRINT* tmp = footprint;
956
957 if( m_replaceFootprints && component->GetFPID() != footprint->GetFPID() )
958 tmp = replaceFootprint( aNetlist, footprint, component );
959
960 if( tmp )
961 {
962 footprintMap[ component ] = tmp;
963
964 updateFootprintParameters( tmp, component );
965 updateComponentPadConnections( tmp, component );
966 }
967
968 matchCount++;
969 }
970
971 if( footprint == lastPreexistingFootprint )
972 {
973 // No sense going through the newly-created footprints: end of loop
974 break;
975 }
976 }
977
978 if( matchCount == 0 )
979 {
980 FOOTPRINT* footprint = addNewFootprint( component );
981
982 if( footprint )
983 {
984 footprintMap[ component ] = footprint;
985
986 updateFootprintParameters( footprint, component );
987 updateComponentPadConnections( footprint, component );
988 }
989 }
990 else if( matchCount > 1 )
991 {
992 msg.Printf( _( "Multiple footprints found for '%s'." ), component->GetReference() );
994 m_errorCount++;
995 }
996 }
997
998 updateCopperZoneNets( aNetlist );
999
1000 // Finally go through the board footprints and update all those that *don't* have matching
1001 // component entries.
1002 //
1003 for( FOOTPRINT* footprint : m_board->Footprints() )
1004 {
1005 bool matched = false;
1006 bool doDelete = m_deleteUnusedFootprints;
1007
1008 if( ( footprint->GetAttributes() & FP_BOARD_ONLY ) > 0 )
1009 doDelete = false;
1010
1012 component = aNetlist.GetComponentByPath( footprint->GetPath() );
1013 else
1014 component = aNetlist.GetComponentByReference( footprint->GetReference() );
1015
1016 if( component && component->GetProperties().count( wxT( "exclude_from_board" ) ) == 0 )
1017 matched = true;
1018
1019 if( doDelete && !matched && footprint->IsLocked() )
1020 {
1021 if( m_isDryRun )
1022 {
1023 msg.Printf( _( "Cannot remove unused footprint %s (locked)." ),
1024 footprint->GetReference() );
1025 }
1026 else
1027 {
1028 msg.Printf( _( "Could not remove unused footprint %s (locked)." ),
1029 footprint->GetReference() );
1030 }
1031
1033 m_errorCount++;
1034 doDelete = false;
1035 }
1036
1037 if( doDelete && !matched )
1038 {
1039 if( m_isDryRun )
1040 {
1041 msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() );
1042 }
1043 else
1044 {
1045 m_commit.Remove( footprint );
1046 msg.Printf( _( "Removed unused footprint %s." ), footprint->GetReference() );
1047 }
1048
1050 }
1051 else if( !m_isDryRun )
1052 {
1053 if( !matched )
1054 footprint->SetPath( KIID_PATH() );
1055
1056 for( PAD* pad : footprint->Pads() )
1057 {
1058 if( pad->GetNet() )
1059 pad->GetNet()->SetIsCurrent( true );
1060 }
1061 }
1062 }
1063
1064 if( !m_isDryRun )
1065 {
1067 testConnectivity( aNetlist, footprintMap );
1068
1069 for( NETINFO_ITEM* net : m_board->GetNetInfo() )
1070 {
1071 if( !net->IsCurrent() )
1072 {
1073 msg.Printf( _( "Removed unused net %s." ), net->GetNetname() );
1075 m_commit.Removed( net );
1076 }
1077 }
1078
1081
1082 // When new footprints are added, the automatic zone refill is disabled because:
1083 // * it creates crashes when calculating dynamic ratsnests if auto refill is enabled.
1084 // (the auto refills rebuild the connectivity with incomplete data)
1085 // * it is useless because zones will be refilled after placing new footprints
1086 m_commit.Push( _( "Update netlist" ), m_newFootprintsCount ? ZONE_FILL_OP : 0 );
1087
1090 }
1091
1092 if( m_isDryRun )
1093 {
1094 for( const std::pair<const wxString, NETINFO_ITEM*>& addedNet : m_addedNets )
1095 delete addedNet.second;
1096
1097 m_addedNets.clear();
1098 }
1099
1100 // Update the ratsnest
1103
1104 msg.Printf( _( "Total warnings: %d, errors: %d." ), m_warningCount, m_errorCount );
1106
1107 return true;
1108}
#define ZONE_FILL_OP
Definition: board_commit.h:43
void SetResolveNetConflicts(bool aResolve=true)
Sets a flag that will cause Push() to resolve net conflicts on track/via clusters instead of the defa...
Definition: board_commit.h:73
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
bool updateFootprintParameters(FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
bool testConnectivity(NETLIST &aNetlist, std::map< COMPONENT *, FOOTPRINT * > &aFootprintMap)
bool updateCopperZoneNets(NETLIST &aNetlist)
bool updateComponentPadConnections(FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
FOOTPRINT * replaceFootprint(NETLIST &aNetlist, FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
FOOTPRINT * addNewFootprint(COMPONENT *aComponent)
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:765
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1485
FOOTPRINTS & Footprints()
Definition: board.h:307
void BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition: board.cpp:162
COMMIT & Removed(EDA_ITEM *aItem)
Modify a given item in the model.
Definition: commit.h:96
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
Definition: commit.h:90
void SetStatus(EDA_ITEM_FLAGS aStatus)
Definition: eda_item.h:140
bool IsLocked() const override
Definition: footprint.h:340
Definition: kiid.h:48
void RemoveUnusedNets()
COMPONENT * GetComponentByPath(const KIID_PATH &aPath)
Return a COMPONENT by aPath.
COMPONENT * GetComponentByReference(const wxString &aReference)
Return a COMPONENT by aReference.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
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.
Definition: reporter.h:99
@ FP_BOARD_ONLY
Definition: footprint.h:72
@ RPT_SEVERITY_INFO

References _, addNewFootprint(), BOARD::BuildConnectivity(), cacheCopperZoneConnections(), BOARD::Footprints(), LIB_ID::Format(), FP_BOARD_ONLY, NETLIST::GetComponent(), NETLIST::GetComponentByPath(), NETLIST::GetComponentByReference(), NETLIST::GetCount(), COMPONENT::GetFPID(), COMPONENT::GetKIIDs(), BOARD::GetNetInfo(), COMPONENT::GetPath(), COMPONENT::GetProperties(), COMPONENT::GetReference(), m_addedNets, m_board, m_commit, m_deleteUnusedFootprints, m_errorCount, m_frame, m_isDryRun, m_lookupByTimestamp, m_newFootprintsCount, m_replaceFootprints, m_reporter, m_warningCount, pad, BOARD_COMMIT::Push(), COMMIT::Remove(), COMMIT::Removed(), NETINFO_LIST::RemoveUnusedNets(), replaceFootprint(), REPORTER::Report(), REPORTER::ReportTail(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, RPT_SEVERITY_INFO, PCB_EDIT_FRAME::SaveProjectSettings(), BOARD_COMMIT::SetResolveNetConflicts(), EDA_ITEM::SetStatus(), BOARD::SynchronizeNetsAndNetClasses(), testConnectivity(), updateComponentPadConnections(), updateCopperZoneNets(), updateFootprintParameters(), UTF8::wx_str(), and ZONE_FILL_OP.

Referenced by PCB_EDIT_FRAME::KiwayMailIn(), DIALOG_NETLIST_IMPORT::loadNetlist(), and DIALOG_UPDATE_PCB::PerformUpdate().

Member Data Documentation

◆ m_addedFootprints

std::vector<FOOTPRINT*> BOARD_NETLIST_UPDATER::m_addedFootprints
private

Definition at line 127 of file board_netlist_updater.h.

Referenced by addNewFootprint(), and GetAddedFootprints().

◆ m_addedNets

std::map<wxString, NETINFO_ITEM*> BOARD_NETLIST_UPDATER::m_addedNets
private

◆ m_board

◆ m_commit

◆ m_deleteUnusedFootprints

bool BOARD_NETLIST_UPDATER::m_deleteUnusedFootprints
private

◆ m_errorCount

int BOARD_NETLIST_UPDATER::m_errorCount
private

◆ m_frame

PCB_EDIT_FRAME* BOARD_NETLIST_UPDATER::m_frame
private

◆ m_isDryRun

◆ m_lookupByTimestamp

bool BOARD_NETLIST_UPDATER::m_lookupByTimestamp
private

◆ m_newFootprintsCount

int BOARD_NETLIST_UPDATER::m_newFootprintsCount
private

◆ m_oldToNewNets

std::map<wxString, wxString> BOARD_NETLIST_UPDATER::m_oldToNewNets
private

Definition at line 124 of file board_netlist_updater.h.

Referenced by updateComponentPadConnections(), and updateCopperZoneNets().

◆ m_padNets

std::map<PAD*, wxString> BOARD_NETLIST_UPDATER::m_padNets
private

Definition at line 125 of file board_netlist_updater.h.

Referenced by cacheNetname(), and getNetname().

◆ m_padPinFunctions

std::map<PAD*, wxString> BOARD_NETLIST_UPDATER::m_padPinFunctions
private

Definition at line 126 of file board_netlist_updater.h.

Referenced by cachePinFunction(), and getPinFunction().

◆ m_replaceFootprints

bool BOARD_NETLIST_UPDATER::m_replaceFootprints
private

◆ m_reporter

◆ m_warningCount

int BOARD_NETLIST_UPDATER::m_warningCount
private

◆ m_zoneConnectionsCache

std::map<ZONE*, std::vector<PAD*> > BOARD_NETLIST_UPDATER::m_zoneConnectionsCache
private

Definition at line 123 of file board_netlist_updater.h.

Referenced by cacheCopperZoneConnections(), and updateCopperZoneNets().


The documentation for this class was generated from the following files: