KiCad PCB EDA Suite
BOARD_NETLIST_UPDATER Class Reference

Class BOARD_NETLIST_UPDATER updates 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)
 Function UpdateNetlist() More...
 
bool UpdateNetlist (const wxString &aNetlistFileName, const wxString &aCmpFileName)
 
void SetReporter (REPORTER *aReporter)
 

Sets the reporter object

More...
 
void SetDeleteSinglePadNets (bool aEnabled)
 

Enables "delete single pad nets" option

More...
 
void SetIsDryRun (bool aEnabled)
 

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

More...
 
void SetReplaceFootprints (bool aEnabled)
 

Enables replacing footprints with new ones

More...
 
void SetDeleteUnusedComponents (bool aEnabled)
 

Enables removing unused components

More...
 
void SetLookupByTimestamp (bool aEnabled)
 

Enables component lookup by timestamp instead of reference

More...
 
std::vector< MODULE * > GetAddedComponents () const
 

Private Member Functions

void cacheNetname (D_PAD *aPad, const wxString &aNetname)
 
wxString getNetname (D_PAD *aPad)
 
wxPoint estimateComponentInsertionPosition ()
 
MODULEaddNewComponent (COMPONENT *aComponent)
 
MODULEreplaceComponent (NETLIST &aNetlist, MODULE *aPcbComponent, COMPONENT *aNewComponent)
 
bool updateComponentParameters (MODULE *aPcbComponent, COMPONENT *aNewComponent)
 
bool updateComponentPadConnections (MODULE *aPcbComponent, COMPONENT *aNewComponent)
 
void cacheCopperZoneConnections ()
 
bool updateCopperZoneNets (NETLIST &aNetlist)
 
bool deleteUnusedComponents (NETLIST &aNetlist)
 
bool deleteSinglePadNets ()
 
bool testConnectivity (NETLIST &aNetlist)
 

Private Attributes

BOARD_COMMIT m_commit
 
BOARDm_board
 
REPORTERm_reporter
 
std::map< ZONE_CONTAINER *, std::vector< D_PAD * > > m_zoneConnectionsCache
 
std::map< D_PAD *, wxString > m_padNets
 
std::vector< MODULE * > m_addedComponents
 
std::map< wxString, NETINFO_ITEM * > m_addedNets
 
bool m_deleteSinglePadNets
 
bool m_deleteUnusedComponents
 
bool m_isDryRun
 
bool m_replaceFootprints
 
bool m_lookupByTimestamp
 
int m_warningCount
 
int m_errorCount
 

Detailed Description

Class BOARD_NETLIST_UPDATER updates 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 properly set, any extra unlock footprints are removed from the BOARD.

Definition at line 71 of file board_netlist_updater.h.

Constructor & Destructor Documentation

BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER ( PCB_EDIT_FRAME aFrame,
BOARD aBoard 
)

Definition at line 52 of file board_netlist_updater.cpp.

References NULL_REPORTER::GetInstance(), m_deleteSinglePadNets, m_deleteUnusedComponents, m_errorCount, m_isDryRun, m_lookupByTimestamp, m_replaceFootprints, m_reporter, and m_warningCount.

BOARD_NETLIST_UPDATER::~BOARD_NETLIST_UPDATER ( )

Definition at line 69 of file board_netlist_updater.cpp.

70 {
71 }

Member Function Documentation

MODULE * BOARD_NETLIST_UPDATER::addNewComponent ( COMPONENT aComponent)
private

Definition at line 119 of file board_netlist_updater.cpp.

References COMMIT::Add(), estimateComponentInsertionPosition(), LIB_ID::Format(), GetChars(), COMPONENT::GetFPID(), COMPONENT::GetModule(), GetNewTimeStamp(), COMPONENT::GetReference(), COMPONENT::GetTimeStamp(), m_addedComponents, m_board, m_commit, m_errorCount, m_isDryRun, m_reporter, REPORTER::Report(), REPORTER::RPT_ACTION, REPORTER::RPT_ERROR, REPORTER::RPT_INFO, EDA_ITEM::SetParent(), MODULE::SetPosition(), and EDA_ITEM::SetTimeStamp().

Referenced by GetAddedComponents(), and UpdateNetlist().

120 {
121  wxString msg;
122 
123  if( aComponent->GetModule() != NULL )
124  {
125  msg.Printf( _( "Adding new symbol \"%s:%s\" footprint \"%s\".\n" ),
126  GetChars( aComponent->GetReference() ),
127  GetChars( aComponent->GetTimeStamp() ),
128  GetChars( aComponent->GetFPID().Format() ) );
130 
131  msg.Printf( _( "Add symbol %s, footprint: %s.\n" ),
132  GetChars( aComponent->GetReference() ),
133  GetChars( aComponent->GetFPID().Format() ) );
135 
136 
137  if( !m_isDryRun )
138  {
139  // Owned by NETLIST, can only copy it.
140  MODULE* footprint = new MODULE( *aComponent->GetModule() );
141  footprint->SetParent( m_board );
143  footprint->SetTimeStamp( GetNewTimeStamp() );
144 
145  m_addedComponents.push_back( footprint );
146  m_commit.Add( footprint );
147 
148  return footprint;
149  }
150  }
151  else
152  {
153  msg.Printf( _( "Cannot add symbol %s due to missing footprint %s.\n" ),
154  GetChars( aComponent->GetReference() ),
155  GetChars( aComponent->GetFPID().Format() ) );
156 
158 
159  msg.Printf( _( "Cannot add new symbol \"%s:%s\" due to missing "
160  "footprint \"%s\".\n" ),
161  GetChars( aComponent->GetReference() ),
162  GetChars( aComponent->GetTimeStamp() ),
163  GetChars( aComponent->GetFPID().Format() ) );
164 
166  ++m_errorCount;
167  }
168 
169  return NULL;
170 }
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:166
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
MODULE * GetModule(bool aRelease=false)
Definition: pcb_netlist.h:186
const wxString & GetReference() const
Definition: pcb_netlist.h:151
timestamp_t GetNewTimeStamp()
Definition: common.cpp:160
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:224
const wxString & GetTimeStamp() const
Definition: pcb_netlist.h:170
void SetPosition(const wxPoint &aPos) override
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
UTF8 Format() const
Definition: lib_id.cpp:263
std::vector< MODULE * > m_addedComponents
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:214
void BOARD_NETLIST_UPDATER::cacheCopperZoneConnections ( )
private

Definition at line 442 of file board_netlist_updater.cpp.

References BOARD::GetArea(), BOARD::GetAreaCount(), BOARD::GetConnectivity(), ZONE_CONTAINER::GetIsKeepout(), ZONE_CONTAINER::IsOnCopperLayer(), m_board, and m_zoneConnectionsCache.

Referenced by GetAddedComponents(), and UpdateNetlist().

443 {
444  for( int ii = 0; ii < m_board->GetAreaCount(); ii++ )
445  {
446  ZONE_CONTAINER* zone = m_board->GetArea( ii );
447 
448  if( !zone->IsOnCopperLayer() || zone->GetIsKeepout() )
449  continue;
450 
451  m_zoneConnectionsCache[ zone ] = m_board->GetConnectivity()->GetConnectedPads( zone );
452  }
453 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
std::map< ZONE_CONTAINER *, std::vector< D_PAD * > > m_zoneConnectionsCache
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:602
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1015
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.cpp:181
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:986
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:293
void BOARD_NETLIST_UPDATER::cacheNetname ( D_PAD aPad,
const wxString &  aNetname 
)
private

Definition at line 77 of file board_netlist_updater.cpp.

References m_padNets.

Referenced by deleteSinglePadNets(), GetAddedComponents(), and updateComponentPadConnections().

78 {
79  m_padNets[ aPad ] = aNetname;
80 }
std::map< D_PAD *, wxString > m_padNets
bool BOARD_NETLIST_UPDATER::deleteSinglePadNets ( )
private

Definition at line 576 of file board_netlist_updater.cpp.

References BOARD::BuildListOfNets(), cacheNetname(), BOARD::GetArea(), BOARD::GetAreaCount(), GetChars(), ZONE_CONTAINER::GetIsKeepout(), D_PAD::GetName(), BOARD_CONNECTED_ITEM::GetNetname(), getNetname(), BOARD::GetPads(), D_PAD::GetParent(), MODULE::GetReference(), ZONE_CONTAINER::IsOnCopperLayer(), m_board, m_isDryRun, m_reporter, REPORTER::Report(), REPORTER::RPT_ACTION, BOARD_CONNECTED_ITEM::SetNetCode(), and NETINFO_LIST::UNCONNECTED.

Referenced by GetAddedComponents(), and UpdateNetlist().

577 {
578  int count = 0;
579  wxString netname;
580  wxString msg;
581  D_PAD* pad = NULL;
582  D_PAD* previouspad = NULL;
583 
584  // We need the pad list for next tests.
585 
587 
588  std::vector<D_PAD*> padlist = m_board->GetPads();
589 
590  if( m_isDryRun )
591  {
592  // During a dry run changes are only stored in the m_padNets cache, so we must sort
593  // the list ourselves.
594  std::sort( padlist.begin(), padlist.end(),
595  [ this ]( D_PAD* a, D_PAD* b ) -> bool { return getNetname( a ) < getNetname( b ); } );
596  }
597 
598  for( unsigned kk = 0; kk < padlist.size(); kk++ )
599  {
600  pad = padlist[kk];
601 
602  if( getNetname( pad ).IsEmpty() )
603  continue;
604 
605  if( netname != getNetname( pad ) ) // End of net
606  {
607  if( previouspad && count == 1 )
608  {
609  // First, see if we have a copper zone attached to this pad.
610  // If so, this is not really a single pad net
611 
612  for( int ii = 0; ii < m_board->GetAreaCount(); ii++ )
613  {
614  ZONE_CONTAINER* zone = m_board->GetArea( ii );
615 
616  if( !zone->IsOnCopperLayer() )
617  continue;
618 
619  if( zone->GetIsKeepout() )
620  continue;
621 
622  if( zone->GetNetname() == getNetname( previouspad ) )
623  {
624  count++;
625  break;
626  }
627  }
628 
629  if( count == 1 ) // Really one pad, and nothing else
630  {
631  msg.Printf( _( "Remove single pad net %s." ),
632  GetChars( getNetname( previouspad ) ) );
634 
635  msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad \"%s\"\n" ),
636  GetChars( getNetname( previouspad ) ),
637  GetChars( previouspad->GetParent()->GetReference() ),
638  GetChars( previouspad->GetName() ) );
640 
641  if( !m_isDryRun )
642  previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
643  else
644  cacheNetname( previouspad, wxEmptyString );
645  }
646  }
647 
648  netname = getNetname( pad );
649  count = 1;
650  }
651  else
652  {
653  count++;
654  }
655 
656  previouspad = pad;
657  }
658 
659  // Examine last pad
660  if( pad && count == 1 )
661  {
662  if( !m_isDryRun )
664  else
665  cacheNetname( pad, wxEmptyString );
666  }
667 
668  return true;
669 }
void BuildListOfNets()
Definition: class_board.h:726
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
void cacheNetname(D_PAD *aPad, const wxString &aNetname)
MODULE * GetParent() const
Definition: class_pad.h:162
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:602
wxString getNetname(D_PAD *aPad)
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
const wxString & GetName() const
Definition: class_pad.h:190
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1015
const std::vector< D_PAD * > GetPads()
Function GetPads returns a reference to a list of all the pads.
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.cpp:181
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetNetname() const
Function GetNetname.
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:986
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:458
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:461
bool BOARD_NETLIST_UPDATER::deleteUnusedComponents ( NETLIST aNetlist)
private

Definition at line 533 of file board_netlist_updater.cpp.

References GetChars(), NETLIST::GetComponentByReference(), NETLIST::GetComponentByTimeStamp(), m_board, m_commit, m_isDryRun, m_lookupByTimestamp, BOARD::m_Modules, m_reporter, MODULE::Next(), COMMIT::Remove(), REPORTER::Report(), REPORTER::RPT_ACTION, REPORTER::RPT_INFO, and REPORTER::RPT_WARNING.

Referenced by GetAddedComponents(), and UpdateNetlist().

534 {
535  wxString msg;
536  MODULE* nextModule;
537  const COMPONENT* component;
538 
539  for( MODULE* module = m_board->m_Modules; module != NULL; module = nextModule )
540  {
541  nextModule = module->Next();
542 
543  if( m_lookupByTimestamp )
544  component = aNetlist.GetComponentByTimeStamp( module->GetPath() );
545  else
546  component = aNetlist.GetComponentByReference( module->GetReference() );
547 
548  if( component == NULL )
549  {
550  if( module->IsLocked() )
551  {
552  msg.Printf( _( "Footprint %s is locked, skipping removal.\n" ),
553  GetChars( module->GetReference() ) );
555  continue;
556  }
557 
558  msg.Printf( _( "Remove footprint %s." ),
559  GetChars( module->GetReference() ) );
561 
562  msg.Printf( _( "Removing unused footprint \"%s:%s\".\n" ),
563  GetChars( module->GetReference() ),
564  GetChars( module->GetPath() ) );
566 
567  if( !m_isDryRun )
568  m_commit.Remove( module );
569  }
570  }
571 
572  return true;
573 }
MODULE * Next() const
Definition: class_module.h:121
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
DLIST< MODULE > m_Modules
Definition: class_board.h:247
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
COMPONENT * GetComponentByReference(const wxString &aReference)
Function GetComponentByReference returns a COMPONENT by aReference.
COMPONENT * GetComponentByTimeStamp(const wxString &aTimeStamp)
Function GetComponentByTimeStamp returns a COMPONENT by aTimeStamp.
wxPoint BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition ( )
private

Definition at line 91 of file board_netlist_updater.cpp.

References EDA_RECT::Centre(), BOARD::GetBoardEdgesBoundingBox(), EDA_RECT::GetBottom(), EDA_RECT::GetHeight(), BOARD::GetPageSettings(), EDA_RECT::GetWidth(), BOARD::IsEmpty(), m_board, wxPoint::x, and wxPoint::y.

Referenced by addNewComponent(), and GetAddedComponents().

92 {
93  wxPoint bestPosition;
94 
95  if( !m_board->IsEmpty() )
96  {
97  // Position new components below any existing board features.
99 
100  if( bbox.GetWidth() || bbox.GetHeight() )
101  {
102  bestPosition.x = bbox.Centre().x;
103  bestPosition.y = bbox.GetBottom() + Millimeter2iu( 10 );
104  }
105  }
106  else
107  {
108  // Position new components in the center of the page when the board is empty.
109  wxSize pageSize = m_board->GetPageSettings().GetSizeIU();
110 
111  bestPosition.x = pageSize.GetWidth() / 2;
112  bestPosition.y = pageSize.GetHeight() / 2;
113  }
114 
115  return bestPosition;
116 }
int GetHeight() const
Definition: eda_rect.h:118
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:801
bool IsEmpty() const
Definition: class_board.h:271
int GetBottom() const
Definition: eda_rect.h:122
wxPoint Centre() const
Definition: eda_rect.h:60
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:550
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
int GetWidth() const
Definition: eda_rect.h:117
wxString BOARD_NETLIST_UPDATER::getNetname ( D_PAD aPad)
private

Definition at line 82 of file board_netlist_updater.cpp.

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

Referenced by deleteSinglePadNets(), GetAddedComponents(), and updateCopperZoneNets().

83 {
84  if( m_isDryRun && m_padNets.count( aPad ) )
85  return m_padNets[ aPad ];
86  else
87  return aPad->GetNetname();
88 }
std::map< D_PAD *, wxString > m_padNets
const wxString & GetNetname() const
Function GetNetname.
MODULE * BOARD_NETLIST_UPDATER::replaceComponent ( NETLIST aNetlist,
MODULE aPcbComponent,
COMPONENT aNewComponent 
)
private

Definition at line 173 of file board_netlist_updater.cpp.

References COMMIT::Add(), MODULE::CopyNetlistSettings(), LIB_ID::empty(), LIB_ID::Format(), GetChars(), COMPONENT::GetFPID(), MODULE::GetFPID(), COMPONENT::GetModule(), MODULE::GetPath(), MODULE::GetReference(), NETLIST::IsFindByTimeStamp(), m_board, m_commit, m_errorCount, m_isDryRun, m_replaceFootprints, m_reporter, COMMIT::Remove(), REPORTER::Report(), REPORTER::RPT_ACTION, REPORTER::RPT_ERROR, REPORTER::RPT_INFO, EDA_ITEM::SetParent(), MODULE::SetPath(), and MODULE::SetReference().

Referenced by GetAddedComponents(), and UpdateNetlist().

174 {
175  wxString msg;
176 
177  if( !m_replaceFootprints )
178  return NULL;
179 
180  // Test if the footprint has not changed
181  if( aNewComponent->GetFPID().empty() || aPcbComponent->GetFPID() == aNewComponent->GetFPID() )
182  return NULL;
183 
184  if( aNewComponent->GetModule() != NULL )
185  {
186  msg.Printf( _( "Change symbol %s footprint from %s to %s.\n"),
187  GetChars( aPcbComponent->GetReference() ),
188  GetChars( aPcbComponent->GetFPID().Format() ),
189  GetChars( aNewComponent->GetFPID().Format() ) );
190 
192 
193  msg.Printf( _( "Replacing symbol \"%s:%s\" footprint \"%s\" with "
194  "\"%s\".\n" ),
195  GetChars( aPcbComponent->GetReference() ),
196  GetChars( aPcbComponent->GetPath() ),
197  GetChars( aPcbComponent->GetFPID().Format() ),
198  GetChars( aNewComponent->GetFPID().Format() ) );
199 
201 
202  if( !m_isDryRun )
203  {
204  wxASSERT( aPcbComponent != NULL );
205 
206  MODULE* newFootprint = new MODULE( *aNewComponent->GetModule() );
207  newFootprint->SetParent( m_board );
208 
209  if( aNetlist.IsFindByTimeStamp() )
210  newFootprint->SetReference( aPcbComponent->GetReference() );
211  else
212  newFootprint->SetPath( aPcbComponent->GetPath() );
213 
214  aPcbComponent->CopyNetlistSettings( newFootprint, false );
215  m_commit.Remove( aPcbComponent );
216  m_commit.Add( newFootprint );
217 
218  return newFootprint;
219  }
220  }
221  else
222  {
223  msg.Printf( _( "Cannot change symbol %s footprint due to missing "
224  "footprint %s.\n" ),
225  GetChars( aPcbComponent->GetReference() ),
226  GetChars( aNewComponent->GetFPID().Format() ) );
227 
229 
230  msg.Printf( _( "Cannot replace symbol \"%s:%s\" due to missing "
231  "footprint \"%s\".\n" ),
232  GetChars( aPcbComponent->GetReference() ),
233  GetChars( aPcbComponent->GetPath() ),
234  GetChars( aNewComponent->GetFPID().Format() ) );
235 
237 
238  ++m_errorCount;
239  }
240 
241  return NULL;
242 }
bool empty() const
Definition: lib_id.h:190
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:166
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
MODULE * GetModule(bool aRelease=false)
Definition: pcb_netlist.h:186
const LIB_ID & GetFPID() const
Definition: class_module.h:191
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:224
bool IsFindByTimeStamp() const
Definition: pcb_netlist.h:313
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:468
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:458
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
UTF8 Format() const
Definition: lib_id.cpp:263
void CopyNetlistSettings(MODULE *aModule, bool aCopyLocalSettings)
Function CopyNetlistSettings copies the netlist settings to aModule.
const wxString & GetPath() const
Definition: class_module.h:200
void SetPath(const wxString &aPath)
Definition: class_module.h:201
void BOARD_NETLIST_UPDATER::SetDeleteSinglePadNets ( bool  aEnabled)
inline

Enables "delete single pad nets" option

Definition at line 97 of file board_netlist_updater.h.

References m_deleteSinglePadNets.

Referenced by PCB_EDIT_FRAME::KiwayMailIn().

98  {
99  m_deleteSinglePadNets = aEnabled;
100  }
void BOARD_NETLIST_UPDATER::SetDeleteUnusedComponents ( bool  aEnabled)
inline

Enables removing unused components

Definition at line 115 of file board_netlist_updater.h.

References m_deleteUnusedComponents.

Referenced by PCB_EDIT_FRAME::KiwayMailIn().

116  {
117  m_deleteUnusedComponents = aEnabled;
118  }
void BOARD_NETLIST_UPDATER::SetIsDryRun ( bool  aEnabled)
inline

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

Definition at line 103 of file board_netlist_updater.h.

References m_isDryRun.

104  {
105  m_isDryRun = aEnabled;
106  }
void BOARD_NETLIST_UPDATER::SetLookupByTimestamp ( bool  aEnabled)
inline

Enables component lookup by timestamp instead of reference

Definition at line 121 of file board_netlist_updater.h.

References m_lookupByTimestamp.

Referenced by PCB_EDIT_FRAME::KiwayMailIn().

122  {
123  m_lookupByTimestamp = aEnabled;
124  }
void BOARD_NETLIST_UPDATER::SetReplaceFootprints ( bool  aEnabled)
inline

Enables replacing footprints with new ones

Definition at line 109 of file board_netlist_updater.h.

References m_replaceFootprints.

Referenced by PCB_EDIT_FRAME::KiwayMailIn().

110  {
111  m_replaceFootprints = aEnabled;
112  }
void BOARD_NETLIST_UPDATER::SetReporter ( REPORTER aReporter)
inline

Sets the reporter object

Definition at line 91 of file board_netlist_updater.h.

References m_reporter.

Referenced by DIALOG_UPDATE_PCB::PerformUpdate().

92  {
93  m_reporter = aReporter;
94  }
bool BOARD_NETLIST_UPDATER::testConnectivity ( NETLIST aNetlist)
private

Definition at line 672 of file board_netlist_updater.cpp.

References BOARD::FindModuleByReference(), MODULE::FindPadByName(), LIB_ID::Format(), GetChars(), NETLIST::GetComponent(), NETLIST::GetCount(), MODULE::GetFPID(), COMPONENT::GetNet(), COMPONENT::GetNetCount(), COMPONENT_NET::GetPinName(), COMPONENT::GetReference(), i, m_board, m_errorCount, m_reporter, REPORTER::Report(), and REPORTER::RPT_ERROR.

Referenced by GetAddedComponents(), and UpdateNetlist().

673 {
674  // Verify that board contains all pads in netlist: if it doesn't then footprints are
675  // wrong or missing.
676  // Note that we use references to find the footprints as they're already updated by this
677  // point (whether by-reference or by-timestamp).
678 
679  wxString msg;
680  wxString padname;
681 
682  for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
683  {
684  const COMPONENT* component = aNetlist.GetComponent( i );
685  MODULE* footprint = m_board->FindModuleByReference( component->GetReference() );
686 
687  if( footprint == NULL ) // It can be missing in partial designs
688  continue;
689 
690  // Explore all pins/pads in component
691  for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
692  {
693  const COMPONENT_NET& net = component->GetNet( jj );
694  padname = net.GetPinName();
695 
696  if( footprint->FindPadByName( padname ) )
697  continue; // OK, pad found
698 
699  // not found: bad footprint, report error
700  msg.Printf( _( "Component %s pad %s not found in footprint %s\n" ),
701  GetChars( component->GetReference() ),
702  GetChars( padname ),
703  GetChars( footprint->GetFPID().Format() ) );
705  ++m_errorCount;
706  }
707  }
708 
709  return true;
710 }
const wxString & GetPinName() const
Definition: pcb_netlist.h:61
D_PAD * FindPadByName(const wxString &aPadName) const
Function FindPadByName returns a D_PAD* with a matching name.
MODULE * FindModuleByReference(const wxString &aReference) const
Function FindModuleByReference searches for a MODULE within this board with the given reference desig...
const wxString & GetReference() const
Definition: pcb_netlist.h:151
Class COMPONENT_NET is used to store the component pin name to net name associations stored in a netl...
Definition: pcb_netlist.h:48
const LIB_ID & GetFPID() const
Definition: class_module.h:191
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
size_t i
Definition: json11.cpp:597
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
UTF8 Format() const
Definition: lib_id.cpp:263
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:139
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
unsigned GetNetCount() const
Definition: pcb_netlist.h:137
bool BOARD_NETLIST_UPDATER::updateComponentPadConnections ( MODULE aPcbComponent,
COMPONENT aNewComponent 
)
private

Definition at line 330 of file board_netlist_updater.cpp.

References COMMIT::Add(), cacheNetname(), MODULE::Clone(), BOARD::FindNet(), GetChars(), COMPONENT::GetNet(), COMPONENT_NET::GetNetName(), MODULE::GetPath(), MODULE::GetReference(), COMMIT::GetStatus(), COMPONENT_NET::IsValid(), m_addedNets, m_board, m_commit, m_isDryRun, m_reporter, COMMIT::Modified(), D_PAD::Next(), MODULE::PadsList(), REPORTER::Report(), REPORTER::RPT_ACTION, REPORTER::RPT_INFO, and NETINFO_LIST::UNCONNECTED.

Referenced by GetAddedComponents(), and UpdateNetlist().

331 {
332  wxString msg;
333 
334  // Create a copy only if the module has not been added during this update
335  MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
336  bool changed = false;
337 
338  // At this point, the component footprint is updated. Now update the nets.
339  for( D_PAD* pad = aPcbComponent->PadsList(); pad; pad = pad->Next() )
340  {
341  COMPONENT_NET net = aNewComponent->GetNet( pad->GetName() );
342 
343  if( !net.IsValid() ) // New footprint pad has no net.
344  {
345  if( !pad->GetNetname().IsEmpty() )
346  {
347  msg.Printf( _( "Disconnect symbol %s pin %s.\n" ),
348  GetChars( aPcbComponent->GetReference() ),
349  GetChars( pad->GetName() ) );
351 
352  msg.Printf( _( "Clearing symbol \"%s:%s\" pin \"%s\" net name.\n" ),
353  GetChars( aPcbComponent->GetReference() ),
354  GetChars( aPcbComponent->GetPath() ),
355  GetChars( pad->GetName() ) );
357  }
358 
359  if( !m_isDryRun )
360  {
361  changed = true;
362  pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
363  }
364  else
365  cacheNetname( pad, wxEmptyString );
366  }
367  else // New footprint pad has a net.
368  {
369  if( net.GetNetName() != pad->GetNetname() )
370  {
371  const wxString& netName = net.GetNetName();
372  NETINFO_ITEM* netinfo = m_board->FindNet( netName );
373 
374  if( netinfo == nullptr )
375  {
376  // It might be a new net that has not been added to the board yet
377  if( m_addedNets.count( netName ) )
378  netinfo = m_addedNets[ netName ];
379  }
380 
381  if( netinfo == nullptr )
382  {
383  // It is a new net, we have to add it
384  if( !m_isDryRun )
385  {
386  changed = true;
387  netinfo = new NETINFO_ITEM( m_board, netName );
388  m_commit.Add( netinfo );
389  m_addedNets[netName] = netinfo;
390  }
391 
392  msg.Printf( _( "Add net %s.\n" ), GetChars( netName ) );
394  }
395 
396  if( !pad->GetNetname().IsEmpty() )
397  {
398  msg.Printf( _( "Reconnect symbol %s pin %s from net %s to net %s.\n"),
399  GetChars( aPcbComponent->GetReference() ),
400  GetChars( pad->GetName() ),
401  GetChars( pad->GetNetname() ),
402  GetChars( netName ) );
403 
404  } else {
405  msg.Printf( _( "Connect symbol %s pin %s to net %s.\n"),
406  GetChars( aPcbComponent->GetReference() ),
407  GetChars( pad->GetName() ),
408  GetChars( netName ) );
409  }
410 
412 
413  msg.Printf( _( "Changing symbol \"%s:%s\" pin \"%s\" net name from "
414  "\"%s\" to \"%s\".\n" ),
415  GetChars( aPcbComponent->GetReference() ),
416  GetChars( aPcbComponent->GetPath() ),
417  GetChars( pad->GetName() ),
418  GetChars( pad->GetNetname() ),
419  GetChars( netName ) );
421 
422  if( !m_isDryRun )
423  {
424  changed = true;
425  pad->SetNet( netinfo );
426  }
427  else
428  cacheNetname( pad, netName );
429  }
430  }
431  }
432 
433  if( changed && copy )
434  m_commit.Modified( aPcbComponent, copy );
435  else
436  delete copy;
437 
438  return true;
439 }
void cacheNetname(D_PAD *aPad, const wxString &aNetname)
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
int GetStatus(EDA_ITEM *aItem)
Returns status of an item.
Definition: commit.cpp:120
bool IsValid() const
Definition: pcb_netlist.h:65
std::map< wxString, NETINFO_ITEM * > m_addedNets
Class COMPONENT_NET is used to store the component pin name to net name associations stored in a netl...
Definition: pcb_netlist.h:48
const wxString & GetNetName() const
Definition: pcb_netlist.h:63
D_PAD * Next() const
Definition: class_pad.h:160
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy)
Creates an undo entry for an item that has been already modified.
Definition: commit.h:110
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:458
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:139
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
const wxString & GetPath() const
Definition: class_module.h:200
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:461
bool BOARD_NETLIST_UPDATER::updateComponentParameters ( MODULE aPcbComponent,
COMPONENT aNewComponent 
)
private

Definition at line 245 of file board_netlist_updater.cpp.

References MODULE::Clone(), GetChars(), MODULE::GetPath(), COMPONENT::GetReference(), MODULE::GetReference(), COMMIT::GetStatus(), COMPONENT::GetTimeStamp(), COMPONENT::GetValue(), MODULE::GetValue(), m_commit, m_isDryRun, m_reporter, COMMIT::Modified(), REPORTER::Report(), REPORTER::RPT_ACTION, REPORTER::RPT_INFO, MODULE::SetPath(), MODULE::SetReference(), and MODULE::SetValue().

Referenced by GetAddedComponents(), and UpdateNetlist().

246 {
247  wxString msg;
248 
249  if( !aPcbComponent )
250  return false;
251 
252  // Create a copy only if the module has not been added during this update
253  MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
254  bool changed = false;
255 
256  // Test for reference designator field change.
257  if( aPcbComponent->GetReference() != aNewComponent->GetReference() )
258  {
259  msg.Printf( _( "Change symbol %s reference to %s.\n" ),
260  GetChars( aPcbComponent->GetReference() ),
261  GetChars( aNewComponent->GetReference() ) );
262 
264 
265  msg.Printf( _( "Changing symbol \"%s:%s\" reference to \"%s\".\n" ),
266  GetChars( aPcbComponent->GetReference() ),
267  GetChars( aPcbComponent->GetPath() ),
268  GetChars( aNewComponent->GetReference() ) );
269 
271 
272  if ( !m_isDryRun )
273  {
274  changed = true;
275  aPcbComponent->SetReference( aNewComponent->GetReference() );
276  }
277  }
278 
279  // Test for value field change.
280  if( aPcbComponent->GetValue() != aNewComponent->GetValue() )
281  {
282  msg.Printf( _( "Change symbol %s value from %s to %s.\n" ),
283  GetChars( aPcbComponent->GetReference() ),
284  GetChars( aPcbComponent->GetValue() ),
285  GetChars( aNewComponent->GetValue() ) );
286 
288 
289  msg.Printf( _( "Changing symbol \"%s:%s\" value from \"%s\" to \"%s\".\n" ),
290  GetChars( aPcbComponent->GetReference() ),
291  GetChars( aPcbComponent->GetPath() ),
292  GetChars( aPcbComponent->GetValue() ),
293  GetChars( aNewComponent->GetValue() ) );
294 
296 
297  if( !m_isDryRun )
298  {
299  changed = true;
300  aPcbComponent->SetValue( aNewComponent->GetValue() );
301  }
302  }
303 
304  // Test for time stamp change.
305  if( aPcbComponent->GetPath() != aNewComponent->GetTimeStamp() )
306  {
307  msg.Printf( _( "Changing symbol path \"%s:%s\" to \"%s\".\n" ),
308  GetChars( aPcbComponent->GetReference() ),
309  GetChars( aPcbComponent->GetPath() ),
310  GetChars( aNewComponent->GetTimeStamp() ) );
311 
313 
314  if( !m_isDryRun )
315  {
316  changed = true;
317  aPcbComponent->SetPath( aNewComponent->GetTimeStamp() );
318  }
319  }
320 
321  if( changed && copy )
322  m_commit.Modified( aPcbComponent, copy );
323  else
324  delete copy;
325 
326  return true;
327 }
const wxString & GetValue() const
Function GetValue.
Definition: class_module.h:486
int GetStatus(EDA_ITEM *aItem)
Returns status of an item.
Definition: commit.cpp:120
const wxString & GetReference() const
Definition: pcb_netlist.h:151
const wxString & GetValue() const
Definition: pcb_netlist.h:153
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:468
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
const wxString & GetTimeStamp() const
Definition: pcb_netlist.h:170
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy)
Creates an undo entry for an item that has been already modified.
Definition: commit.h:110
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:458
void SetValue(const wxString &aValue)
Function SetValue.
Definition: class_module.h:495
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
const wxString & GetPath() const
Definition: class_module.h:200
void SetPath(const wxString &aPath)
Definition: class_module.h:201
bool BOARD_NETLIST_UPDATER::updateCopperZoneNets ( NETLIST aNetlist)
private

Definition at line 456 of file board_netlist_updater.cpp.

References BOARD::FindNet(), BOARD::GetArea(), BOARD::GetAreaCount(), NETLIST::GetComponent(), NETLIST::GetCount(), ZONE_CONTAINER::GetIsKeepout(), COMPONENT::GetNet(), COMPONENT::GetNetCount(), COMPONENT_NET::GetNetName(), BOARD_CONNECTED_ITEM::GetNetname(), getNetname(), i, ZONE_CONTAINER::IsOnCopperLayer(), m_addedNets, m_board, m_commit, m_isDryRun, m_reporter, m_warningCount, m_zoneConnectionsCache, COMMIT::Modify(), REPORTER::Report(), REPORTER::RPT_ACTION, REPORTER::RPT_INFO, and REPORTER::RPT_WARNING.

Referenced by GetAddedComponents(), and UpdateNetlist().

457 {
458  wxString msg;
459  std::set<wxString> netlistNetnames;
460 
461  for( int ii = 0; ii < (int) aNetlist.GetCount(); ii++ )
462  {
463  const COMPONENT* component = aNetlist.GetComponent( ii );
464  for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
465  {
466  const COMPONENT_NET& net = component->GetNet( jj );
467  netlistNetnames.insert( net.GetNetName() );
468  }
469  }
470 
471  // Test copper zones to detect "dead" nets (nets without any pad):
472  for( int i = 0; i < m_board->GetAreaCount(); i++ )
473  {
474  ZONE_CONTAINER* zone = m_board->GetArea( i );
475 
476  if( !zone->IsOnCopperLayer() || zone->GetIsKeepout() )
477  continue;
478 
479  if( netlistNetnames.count( zone->GetNetname() ) == 0 )
480  {
481  // Look for a pad in the zone's connected-pad-cache which has been updated to
482  // a new net and use that. While this won't always be the right net, the dead
483  // net is guaranteed to be wrong.
484  wxString updatedNetname = wxEmptyString;
485 
486  for( D_PAD* pad : m_zoneConnectionsCache[ zone ] )
487  {
488  if( getNetname( pad ) != zone->GetNetname() )
489  {
490  updatedNetname = getNetname( pad );
491  break;
492  }
493  }
494 
495  if( !updatedNetname.IsEmpty() )
496  {
497  msg.Printf( _( "Reconnect copper zone from net \"%s\" to net \"%s\"." ),
498  zone->GetNetname(), updatedNetname );
500 
501  msg.Printf( _( "Changing copper zone net name from \"%s\" to \"%s\"." ),
502  zone->GetNetname(), updatedNetname );
504 
505  if( !m_isDryRun )
506  {
507  NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
508 
509  if( !netinfo )
510  netinfo = m_addedNets[ updatedNetname ];
511 
512  if( netinfo )
513  {
514  m_commit.Modify( zone );
515  zone->SetNet( netinfo );
516  }
517  }
518  }
519  else
520  {
521  msg.Printf( _( "Copper zone (net \"%s\") has no pads connected." ),
522  zone->GetNetname() );
524  ++m_warningCount;
525  }
526  }
527  }
528 
529  return true;
530 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
std::map< ZONE_CONTAINER *, std::vector< D_PAD * > > m_zoneConnectionsCache
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:602
std::map< wxString, NETINFO_ITEM * > m_addedNets
Class COMPONENT_NET is used to store the component pin name to net name associations stored in a netl...
Definition: pcb_netlist.h:48
wxString getNetname(D_PAD *aPad)
const wxString & GetNetName() const
Definition: pcb_netlist.h:63
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1015
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.cpp:181
const wxString & GetNetname() const
Function GetNetname.
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:986
size_t i
Definition: json11.cpp:597
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:139
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
unsigned GetNetCount() const
Definition: pcb_netlist.h:137
bool BOARD_NETLIST_UPDATER::UpdateNetlist ( NETLIST aNetlist)

Function UpdateNetlist()

Updates 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 713 of file board_netlist_updater.cpp.

References addNewComponent(), cacheCopperZoneConnections(), deleteSinglePadNets(), deleteUnusedComponents(), BOARD::FindModule(), LIB_ID::Format(), GetChars(), NETLIST::GetComponent(), BOARD::GetConnectivity(), NETLIST::GetCount(), COMPONENT::GetFPID(), COMPONENT::GetReference(), COMPONENT::GetTimeStamp(), i, NETLIST::IsFindByTimeStamp(), m_board, m_commit, m_deleteSinglePadNets, m_deleteUnusedComponents, m_errorCount, m_isDryRun, m_reporter, m_warningCount, BOARD_COMMIT::Push(), replaceComponent(), REPORTER::Report(), REPORTER::ReportTail(), REPORTER::RPT_ACTION, REPORTER::RPT_ERROR, REPORTER::RPT_INFO, EDA_ITEM::SetStatus(), testConnectivity(), updateComponentPadConnections(), updateComponentParameters(), and updateCopperZoneNets().

Referenced by PCB_EDIT_FRAME::KiwayMailIn().

714 {
715  wxString msg;
716  m_errorCount = 0;
717  m_warningCount = 0;
718 
720 
721  if( !m_isDryRun )
722  {
723  m_board->SetStatus( 0 );
724  }
725 
726  for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
727  {
728  COMPONENT* component = aNetlist.GetComponent( i );
729  MODULE* footprint = NULL;
730 
731  msg.Printf( _( "Processing component \"%s:%s:%s\".\n" ),
732  GetChars( component->GetReference() ),
733  GetChars( component->GetTimeStamp() ),
734  GetChars( component->GetFPID().Format() ) );
736 
737  if( aNetlist.IsFindByTimeStamp() )
738  footprint = m_board->FindModule( component->GetTimeStamp(), true );
739  else
740  footprint = m_board->FindModule( component->GetReference() );
741 
742  if( footprint ) // An existing footprint.
743  {
744  MODULE* newFootprint = replaceComponent( aNetlist, footprint, component );
745 
746  if( newFootprint )
747  footprint = newFootprint;
748  }
749  else
750  {
751  footprint = addNewComponent( component );
752  }
753 
754  if( footprint )
755  {
756  updateComponentParameters( footprint, component );
757  updateComponentPadConnections( footprint, component );
758  }
759  }
760 
761  updateCopperZoneNets( aNetlist );
762 
764  deleteUnusedComponents( aNetlist );
765 
768 
769  if( !m_isDryRun )
770  {
771  m_commit.Push( _( "Update netlist" ) );
772  m_board->GetConnectivity()->Build( m_board );
773  testConnectivity( aNetlist );
774  }
775 
776  // Update the ratsnest
779 
780  msg.Printf( _( "Total warnings: %d, errors: %d." ), m_warningCount, m_errorCount );
782 
783  if( m_errorCount )
784  {
785  m_reporter->ReportTail( _( "Errors occurred during the netlist update. Unless you "
786  "fix them, your board will not be consistent with the schematics." ),
788 
789  return false;
790  }
791  else
792  {
793  m_reporter->ReportTail( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
794  }
795 
796  return true;
797 }
MODULE * replaceComponent(NETLIST &aNetlist, MODULE *aPcbComponent, COMPONENT *aNewComponent)
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:166
bool updateComponentPadConnections(MODULE *aPcbComponent, COMPONENT *aNewComponent)
bool updateCopperZoneNets(NETLIST &aNetlist)
MODULE * FindModule(const wxString &aRefOrTimeStamp, bool aSearchByTimeStamp=false) const
Function FindModule searches for a module matching aRefOrTimeStamp depending on the state of aSearchB...
bool testConnectivity(NETLIST &aNetlist)
const wxString & GetReference() const
Definition: pcb_netlist.h:151
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)
Function ReportTail Places the report at the end of the list, for objects that support report orderin...
Definition: reporter.h:109
bool IsFindByTimeStamp() const
Definition: pcb_netlist.h:313
const wxString & GetTimeStamp() const
Definition: pcb_netlist.h:170
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
bool updateComponentParameters(MODULE *aPcbComponent, COMPONENT *aNewComponent)
size_t i
Definition: json11.cpp:597
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
void SetStatus(STATUS_FLAGS aStatus)
Definition: base_struct.h:262
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
UTF8 Format() const
Definition: lib_id.cpp:263
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
bool deleteUnusedComponents(NETLIST &aNetlist)
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:293
MODULE * addNewComponent(COMPONENT *aComponent)
bool BOARD_NETLIST_UPDATER::UpdateNetlist ( const wxString &  aNetlistFileName,
const wxString &  aCmpFileName 
)

Definition at line 800 of file board_netlist_updater.cpp.

802 {
803  return false;
804 }

Member Data Documentation

std::vector<MODULE*> BOARD_NETLIST_UPDATER::m_addedComponents
private

Definition at line 152 of file board_netlist_updater.h.

Referenced by addNewComponent(), and GetAddedComponents().

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

Definition at line 153 of file board_netlist_updater.h.

Referenced by updateComponentPadConnections(), and updateCopperZoneNets().

bool BOARD_NETLIST_UPDATER::m_deleteSinglePadNets
private
bool BOARD_NETLIST_UPDATER::m_deleteUnusedComponents
private
int BOARD_NETLIST_UPDATER::m_errorCount
private
bool BOARD_NETLIST_UPDATER::m_lookupByTimestamp
private
std::map< D_PAD*, wxString > BOARD_NETLIST_UPDATER::m_padNets
private

Definition at line 151 of file board_netlist_updater.h.

Referenced by cacheNetname(), and getNetname().

bool BOARD_NETLIST_UPDATER::m_replaceFootprints
private
int BOARD_NETLIST_UPDATER::m_warningCount
private
std::map< ZONE_CONTAINER*, std::vector<D_PAD*> > BOARD_NETLIST_UPDATER::m_zoneConnectionsCache
private

Definition at line 150 of file board_netlist_updater.h.

Referenced by cacheCopperZoneConnections(), and updateCopperZoneNets().


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