KiCad PCB EDA Suite
board_netlist_updater.cpp
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
10  * Copyright (C) 2015 CERN
11  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
12  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
13  *
14  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, you may find one here:
28  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
29  * or you may search the http://www.gnu.org website for the version 2 license,
30  * or you may write to the Free Software Foundation, Inc.,
31  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
32  */
33 
34 
35 #include <common.h> // for PAGE_INFO
36 
37 #include <class_board.h>
38 #include <netinfo.h>
39 #include <class_module.h>
40 #include <class_pad.h>
41 #include <class_zone.h>
42 
43 #include "pcb_netlist.h"
45 #include <reporter.h>
46 
47 #include "board_netlist_updater.h"
48 
49 #include <pcb_edit_frame.h>
50 
51 
53  m_frame( aFrame ),
54  m_commit( aFrame ),
55  m_board( aBoard )
56 {
58 
59  m_deleteSinglePadNets = true;
61  m_isDryRun = false;
62  m_replaceFootprints = true;
63  m_lookupByTimestamp = false;
64  m_warnForNoNetPads = false;
65 
66  m_warningCount = 0;
67  m_errorCount = 0;
69 }
70 
71 
73 {
74 }
75 
76 
77 // These functions allow inspection of pad nets during dry runs by keeping a cache of
78 // current pad netnames indexed by pad.
79 
80 void BOARD_NETLIST_UPDATER::cacheNetname( D_PAD* aPad, const wxString& aNetname )
81 {
82  m_padNets[ aPad ] = aNetname;
83 }
84 
86 {
87  if( m_isDryRun && m_padNets.count( aPad ) )
88  return m_padNets[ aPad ];
89  else
90  return aPad->GetNetname();
91 }
92 
93 
95 {
96  wxPoint bestPosition;
97 
98  if( !m_board->IsEmpty() )
99  {
100  // Position new components below any existing board features.
102 
103  if( bbox.GetWidth() || bbox.GetHeight() )
104  {
105  bestPosition.x = bbox.Centre().x;
106  bestPosition.y = bbox.GetBottom() + Millimeter2iu( 10 );
107  }
108  }
109  else
110  {
111  // Position new components in the center of the page when the board is empty.
112  wxSize pageSize = m_board->GetPageSettings().GetSizeIU();
113 
114  bestPosition.x = pageSize.GetWidth() / 2;
115  bestPosition.y = pageSize.GetHeight() / 2;
116  }
117 
118  return bestPosition;
119 }
120 
121 
123 {
124  wxString msg;
125 
126  if( aComponent->GetFPID().empty() )
127  {
128  msg.Printf( _( "Cannot add %s (no footprint assigned)." ),
129  aComponent->GetReference(),
130  aComponent->GetFPID().Format().wx_str() );
132  ++m_errorCount;
133  return nullptr;
134  }
135 
136  MODULE* footprint = m_frame->LoadFootprint( aComponent->GetFPID() );
137 
138  if( footprint == nullptr )
139  {
140  msg.Printf( _( "Cannot add %s (footprint \"%s\" not found)." ),
141  aComponent->GetReference(),
142  aComponent->GetFPID().Format().wx_str() );
144  ++m_errorCount;
145  return nullptr;
146  }
147 
148  msg.Printf( _( "Add %s (footprint \"%s\")." ),
149  aComponent->GetReference(),
150  aComponent->GetFPID().Format().wx_str() );
152 
153  // Set the pads ratsnest settings to the global settings
154  bool set_ratsnest = m_frame->GetDisplayOptions().m_ShowGlobalRatsnest;
155  for ( auto pad : footprint->Pads() )
156  pad->SetLocalRatsnestVisible( set_ratsnest );
157 
159 
160  if( !m_isDryRun )
161  {
162  footprint->SetParent( m_board );
164  footprint->SetTimeStamp( GetNewTimeStamp() );
165 
166  m_addedComponents.push_back( footprint );
167  m_commit.Add( footprint );
168 
169  return footprint;
170  }
171  else
172  delete footprint;
173 
174  return NULL;
175 }
176 
177 
179  COMPONENT* aNewComponent )
180 {
181  wxString msg;
182 
183  if( aNewComponent->GetFPID().empty() )
184  {
185  msg.Printf( _( "Cannot update %s (no footprint assigned)." ),
186  aNewComponent->GetReference(),
187  aNewComponent->GetFPID().Format().wx_str() );
189  ++m_errorCount;
190  return nullptr;
191  }
192 
193  MODULE* newFootprint = m_frame->LoadFootprint( aNewComponent->GetFPID() );
194 
195  if( newFootprint == nullptr )
196  {
197  msg.Printf( _( "Cannot update %s (footprint \"%s\" not found)." ),
198  aNewComponent->GetReference(),
199  aNewComponent->GetFPID().Format().wx_str() );
201  ++m_errorCount;
202  return nullptr;
203  }
204 
205  msg.Printf( _( "Change %s footprint from \"%s\" to \"%s\"."),
206  aPcbComponent->GetReference(),
207  aPcbComponent->GetFPID().Format().wx_str(),
208  aNewComponent->GetFPID().Format().wx_str() );
210 
212 
213  if( !m_isDryRun )
214  {
215  m_frame->Exchange_Module( aPcbComponent, newFootprint, m_commit );
216  return newFootprint;
217  }
218  else
219  delete newFootprint;
220 
221  return nullptr;
222 }
223 
224 
226  COMPONENT* aNewComponent )
227 {
228  wxString msg;
229 
230  // Create a copy only if the module has not been added during this update
231  MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
232  bool changed = false;
233 
234  // Test for reference designator field change.
235  if( aPcbComponent->GetReference() != aNewComponent->GetReference() )
236  {
237  msg.Printf( _( "Change %s reference to %s." ),
238  aPcbComponent->GetReference(),
239  aNewComponent->GetReference() );
241 
242  if ( !m_isDryRun )
243  {
244  changed = true;
245  aPcbComponent->SetReference( aNewComponent->GetReference() );
246  }
247  }
248 
249  // Test for value field change.
250  if( aPcbComponent->GetValue() != aNewComponent->GetValue() )
251  {
252  msg.Printf( _( "Change %s value from %s to %s." ),
253  aPcbComponent->GetReference(),
254  aPcbComponent->GetValue(),
255  aNewComponent->GetValue() );
257 
258  if( !m_isDryRun )
259  {
260  changed = true;
261  aPcbComponent->SetValue( aNewComponent->GetValue() );
262  }
263  }
264 
265  // Test for time stamp change.
266  if( aPcbComponent->GetPath() != aNewComponent->GetTimeStamp() )
267  {
268  msg.Printf( _( "Change symbol path \"%s:%s\" to \"%s\"." ),
269  aPcbComponent->GetReference(),
270  aPcbComponent->GetPath(),
271  aNewComponent->GetTimeStamp() );
273 
274  if( !m_isDryRun )
275  {
276  changed = true;
277  aPcbComponent->SetPath( aNewComponent->GetTimeStamp() );
278  }
279  }
280 
281  if( changed && copy )
282  m_commit.Modified( aPcbComponent, copy );
283  else
284  delete copy;
285 
286  return true;
287 }
288 
289 
291  COMPONENT* aNewComponent )
292 {
293  wxString msg;
294 
295  // Create a copy only if the module has not been added during this update
296  MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
297  bool changed = false;
298 
299  // At this point, the component footprint is updated. Now update the nets.
300  for( auto pad : aPcbComponent->Pads() )
301  {
302  COMPONENT_NET net = aNewComponent->GetNet( pad->GetName() );
303 
304  // Test if new footprint pad has no net (pads not on copper layers have no net).
305  if( !net.IsValid() || !pad->IsOnCopperLayer() )
306  {
307  if( !pad->GetNetname().IsEmpty() )
308  {
309  msg.Printf( _( "Disconnect %s pin %s." ),
310  aPcbComponent->GetReference(),
311  pad->GetName() );
313  }
314  else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetName().IsEmpty() )
315  {
316  // pad is connectable but has no net found in netlist
317  msg.Printf( _( "No net for component %s pin %s." ),
318  aPcbComponent->GetReference(),
319  pad->GetName() );
321  }
322  if( !m_isDryRun )
323  {
324  changed = true;
325  pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
326  }
327  else
328  cacheNetname( pad, wxEmptyString );
329  }
330  else // New footprint pad has a net.
331  {
332  const wxString& netName = net.GetNetName();
333  NETINFO_ITEM* netinfo = m_board->FindNet( netName );
334 
335  if( netinfo && !m_isDryRun )
336  netinfo->SetIsCurrent( true );
337 
338  if( pad->GetNetname() != netName )
339  {
340 
341  if( netinfo == nullptr )
342  {
343  // It might be a new net that has not been added to the board yet
344  if( m_addedNets.count( netName ) )
345  netinfo = m_addedNets[ netName ];
346  }
347 
348  if( netinfo == nullptr )
349  {
350  netinfo = new NETINFO_ITEM( m_board, netName );
351 
352  // It is a new net, we have to add it
353  if( !m_isDryRun )
354  {
355  changed = true;
356  m_commit.Add( netinfo );
357  }
358 
359  m_addedNets[netName] = netinfo;
360  msg.Printf( _( "Add net %s." ), UnescapeString( netName ) );
362  }
363 
364  if( !pad->GetNetname().IsEmpty() )
365  {
366  m_oldToNewNets[ pad->GetNetname() ] = netName;
367 
368  msg.Printf( _( "Reconnect %s pin %s from %s to %s."),
369  aPcbComponent->GetReference(),
370  pad->GetName(),
371  UnescapeString( pad->GetNetname() ),
372  UnescapeString( netName ) );
373  }
374  else
375  {
376  msg.Printf( _( "Connect %s pin %s to %s."),
377  aPcbComponent->GetReference(),
378  pad->GetName(),
379  UnescapeString( netName ) );
380  }
382 
383  if( !m_isDryRun )
384  {
385  changed = true;
386  pad->SetNet( netinfo );
387  }
388  else
389  cacheNetname( pad, netName );
390  }
391  }
392  }
393 
394  if( changed && copy )
395  m_commit.Modified( aPcbComponent, copy );
396  else
397  delete copy;
398 
399  return true;
400 }
401 
402 
404 {
405  for( int ii = 0; ii < m_board->GetAreaCount(); ii++ )
406  {
407  ZONE_CONTAINER* zone = m_board->GetArea( ii );
408 
409  if( !zone->IsOnCopperLayer() || zone->GetIsKeepout() )
410  continue;
411 
412  m_zoneConnectionsCache[ zone ] = m_board->GetConnectivity()->GetConnectedPads( zone );
413  }
414 }
415 
416 
418 {
419  wxString msg;
420  std::set<wxString> netlistNetnames;
421 
422  for( int ii = 0; ii < (int) aNetlist.GetCount(); ii++ )
423  {
424  const COMPONENT* component = aNetlist.GetComponent( ii );
425  for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
426  {
427  const COMPONENT_NET& net = component->GetNet( jj );
428  netlistNetnames.insert( net.GetNetName() );
429  }
430  }
431 
432  for( auto via : m_board->Tracks() )
433  {
434  if( via->Type() != PCB_VIA_T )
435  continue;
436 
437  if( netlistNetnames.count( via->GetNetname() ) == 0 )
438  {
439  wxString updatedNetname = wxEmptyString;
440 
441  // Take via name from name change map if it didn't match to a new pad
442  // (this is useful for stitching vias that don't connect to tracks)
443  if( m_oldToNewNets.count( via->GetNetname() ) )
444  {
445  updatedNetname = m_oldToNewNets[via->GetNetname()];
446  }
447 
448  if( !updatedNetname.IsEmpty() )
449  {
450  msg.Printf( _( "Reconnect via from %s to %s." ),
451  UnescapeString( via->GetNetname() ), UnescapeString( updatedNetname ) );
453 
454  if( !m_isDryRun )
455  {
456  NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
457 
458  if( !netinfo )
459  netinfo = m_addedNets[updatedNetname];
460 
461  if( netinfo )
462  {
463  m_commit.Modify( via );
464  via->SetNet( netinfo );
465  }
466  }
467  }
468  else
469  {
470  msg.Printf( _( "Via connected to unknown net (%s)." ),
471  UnescapeString( via->GetNetname() ) );
473  ++m_warningCount;
474  }
475  }
476  }
477 
478  // Test copper zones to detect "dead" nets (nets without any pad):
479  for( int i = 0; i < m_board->GetAreaCount(); i++ )
480  {
481  ZONE_CONTAINER* zone = m_board->GetArea( i );
482 
483  if( !zone->IsOnCopperLayer() || zone->GetIsKeepout() )
484  continue;
485 
486  if( netlistNetnames.count( zone->GetNetname() ) == 0 )
487  {
488  // Look for a pad in the zone's connected-pad-cache which has been updated to
489  // a new net and use that. While this won't always be the right net, the dead
490  // net is guaranteed to be wrong.
491  wxString updatedNetname = wxEmptyString;
492 
493  for( D_PAD* pad : m_zoneConnectionsCache[ zone ] )
494  {
495  if( getNetname( pad ) != zone->GetNetname() )
496  {
497  updatedNetname = getNetname( pad );
498  break;
499  }
500  }
501 
502  // Take zone name from name change map if it didn't match to a new pad
503  // (this is useful for zones on internal layers)
504  if( updatedNetname.IsEmpty() && m_oldToNewNets.count( zone->GetNetname() ) )
505  {
506  updatedNetname = m_oldToNewNets[ zone->GetNetname() ];
507  }
508 
509  if( !updatedNetname.IsEmpty() )
510  {
511  msg.Printf( _( "Reconnect copper zone from %s to %s." ),
512  UnescapeString( zone->GetNetname() ),
513  UnescapeString( updatedNetname ) );
515 
516  if( !m_isDryRun )
517  {
518  NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
519 
520  if( !netinfo )
521  netinfo = m_addedNets[ updatedNetname ];
522 
523  if( netinfo )
524  {
525  m_commit.Modify( zone );
526  zone->SetNet( netinfo );
527  }
528  }
529  }
530  else
531  {
532  msg.Printf( _( "Copper zone (%s) has no pads connected." ),
533  UnescapeString( zone->GetNetname() ) );
535  ++m_warningCount;
536  }
537  }
538  }
539 
540  return true;
541 }
542 
543 
545 {
546  wxString msg;
547  const COMPONENT* component;
548 
549  for( auto module : m_board->Modules() )
550  {
551 
552  if( m_lookupByTimestamp )
553  component = aNetlist.GetComponentByTimeStamp( module->GetPath() );
554  else
555  component = aNetlist.GetComponentByReference( module->GetReference() );
556 
557  if( component == NULL )
558  {
559  if( module->IsLocked() )
560  {
561  msg.Printf( _( "Cannot remove unused footprint %s (locked)." ), module->GetReference() );
563  continue;
564  }
565 
566  msg.Printf( _( "Remove unused footprint %s." ), module->GetReference() );
568 
569  if( !m_isDryRun )
570  m_commit.Remove( module );
571  }
572  }
573 
574  return true;
575 }
576 
577 
579 {
580  int count = 0;
581  wxString netname;
582  wxString msg;
583  D_PAD* previouspad = NULL;
584 
585  // We need the pad list for next tests.
586 
588 
589  std::vector<D_PAD*> padlist = m_board->GetPads();
590 
591  // Sort pads by netlist name
592  std::sort( padlist.begin(), padlist.end(),
593  [ this ]( D_PAD* a, D_PAD* b ) -> bool { return getNetname( a ) < getNetname( b ); } );
594 
595  for( D_PAD* pad : padlist )
596  {
597  if( getNetname( pad ).IsEmpty() )
598  continue;
599 
600  if( netname != getNetname( pad ) ) // End of net
601  {
602  if( previouspad && count == 1 )
603  {
604  // First, see if we have a copper zone attached to this pad.
605  // If so, this is not really a single pad net
606 
607  for( ZONE_CONTAINER* zone : m_board->Zones() )
608  {
609  if( !zone->IsOnCopperLayer() )
610  continue;
611 
612  if( zone->GetIsKeepout() )
613  continue;
614 
615  if( zone->GetNetname() == getNetname( previouspad ) )
616  {
617  count++;
618  break;
619  }
620  }
621 
622  if( count == 1 ) // Really one pad, and nothing else
623  {
624  msg.Printf( _( "Remove single pad net %s." ),
625  UnescapeString( getNetname( previouspad ) ) );
627 
628  if( !m_isDryRun )
629  previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
630  else
631  cacheNetname( previouspad, wxEmptyString );
632  }
633  }
634 
635  netname = getNetname( pad );
636  count = 1;
637  }
638  else
639  {
640  count++;
641  }
642 
643  previouspad = pad;
644  }
645 
646  // Examine last pad
647  if( count == 1 )
648  {
649  if( !m_isDryRun )
650  previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
651  else
652  cacheNetname( previouspad, wxEmptyString );
653  }
654 
655  return true;
656 }
657 
658 
660 {
661  // Verify that board contains all pads in netlist: if it doesn't then footprints are
662  // wrong or missing.
663  // Note that we use references to find the footprints as they're already updated by this
664  // point (whether by-reference or by-timestamp).
665 
666  wxString msg;
667  wxString padname;
668 
669  for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
670  {
671  const COMPONENT* component = aNetlist.GetComponent( i );
672  MODULE* footprint = m_board->FindModuleByReference( component->GetReference() );
673 
674  if( footprint == NULL ) // It can be missing in partial designs
675  continue;
676 
677  // Explore all pins/pads in component
678  for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
679  {
680  const COMPONENT_NET& net = component->GetNet( jj );
681  padname = net.GetPinName();
682 
683  if( footprint->FindPadByName( padname ) )
684  continue; // OK, pad found
685 
686  // not found: bad footprint, report error
687  msg.Printf( _( "%s pad %s not found in %s." ),
688  component->GetReference(),
689  padname,
690  footprint->GetFPID().Format().wx_str() );
692  ++m_errorCount;
693  }
694  }
695 
696  return true;
697 }
698 
699 
701 {
702  wxString msg;
703  m_errorCount = 0;
704  m_warningCount = 0;
706  MODULE* lastPreexistingFootprint = m_board->Modules().empty() ? NULL : m_board->Modules().back();
707 
709 
710  if( !m_isDryRun )
711  {
712  m_board->SetStatus( 0 );
713 
714  // Mark all nets (except <no net>) as stale; we'll update those to current that
715  // we find in the netlist
716  for( NETINFO_ITEM* net : m_board->GetNetInfo() )
717  net->SetIsCurrent( net->GetNet() == 0 );
718  }
719 
720  for( unsigned i = 0; i < aNetlist.GetCount(); i++ )
721  {
722  COMPONENT* component = aNetlist.GetComponent( i );
723  int matchCount = 0;
724  MODULE* tmp;
725 
726  msg.Printf( _( "Processing component \"%s:%s:%s\"." ),
727  component->GetReference(),
728  component->GetTimeStamp(),
729  component->GetFPID().Format().wx_str() );
731 
732  for( auto footprint : m_board->Modules() )
733  {
734  bool match = false;
735 
736  if( footprint )
737  {
738  if( m_lookupByTimestamp )
739  match = footprint->GetPath() == component->GetTimeStamp();
740  else
741  match = footprint->GetReference().CmpNoCase( component->GetReference() ) == 0;
742  }
743 
744  if( match )
745  {
746  tmp = footprint;
747 
748  if( m_replaceFootprints && component->GetFPID() != footprint->GetFPID() )
749  tmp = replaceComponent( aNetlist, footprint, component );
750 
751  if( tmp )
752  {
753  updateComponentParameters( tmp, component );
754  updateComponentPadConnections( tmp, component );
755  }
756 
757  matchCount++;
758  }
759 
760  if( footprint == lastPreexistingFootprint )
761  {
762  // No sense going through the newly-created footprints: end of loop
763  break;
764  }
765  }
766 
767  if( matchCount == 0 )
768  {
769  tmp = addNewComponent( component );
770 
771  if( tmp )
772  {
773  updateComponentParameters( tmp, component );
774  updateComponentPadConnections( tmp, component );
775  }
776  }
777  else if( matchCount > 1 )
778  {
779  msg.Printf( _( "Multiple footprints found for \"%s\"." ),
780  component->GetReference() );
782  }
783  }
784 
785  updateCopperZoneNets( aNetlist );
786 
788  deleteUnusedComponents( aNetlist );
789 
790  if( !m_isDryRun )
791  {
792  m_commit.Push( _( "Update netlist" ) );
793  m_board->GetConnectivity()->Build( m_board );
794  testConnectivity( aNetlist );
795 
796  // Now the connectivity data is rebuilt, we can delete single pads nets
799  }
801  // We can delete single net pads in dry run mode only if no new footprints
802  // are added, because these new footprints are not actually added to the board
803  // and the current pad list is wrong in this case.
805 
806  if( m_isDryRun )
807  {
808  for( auto it : m_addedNets )
809  delete it.second;
810 
811  m_addedNets.clear();
812  }
813 
814  // Update the ratsnest
817 
818  msg.Printf( _( "Total warnings: %d, errors: %d." ), m_warningCount, m_errorCount );
820 
821  if( m_errorCount )
822  {
823  m_reporter->ReportTail( _( "Errors occurred during the netlist update. Unless you fix them "
824  "your board will not be consistent with the schematics." ),
826  return false;
827  }
828 
829  m_reporter->ReportTail( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
830  return true;
831 }
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
void BuildListOfNets()
Definition: class_board.h:717
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
MODULE * replaceComponent(NETLIST &aNetlist, MODULE *aPcbComponent, COMPONENT *aNewComponent)
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:546
void cacheNetname(D_PAD *aPad, const wxString &aNetname)
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:792
void SetIsCurrent(bool isCurrent)
Definition: netinfo.h:243
std::map< ZONE_CONTAINER *, std::vector< D_PAD * > > m_zoneConnectionsCache
const wxString & GetPath() const
Definition: class_module.h:231
int GetWidth() const
Definition: eda_rect.h:119
PADS & Pads()
Definition: class_module.h:176
const wxString GetValue() const
Function GetValue.
Definition: class_module.h:457
BOARD_NETLIST_UPDATER class definition.
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
int GetStatus(EDA_ITEM *aItem)
Returns status of an item.
Definition: commit.cpp:132
const LIB_ID & GetFPID() const
Definition: class_module.h:222
bool updateComponentPadConnections(MODULE *aPcbComponent, COMPONENT *aNewComponent)
bool updateCopperZoneNets(NETLIST &aNetlist)
bool testConnectivity(NETLIST &aNetlist)
void Exchange_Module(MODULE *aSrc, MODULE *aDest, BOARD_COMMIT &aCommit, bool deleteExtraTexts=true, bool resetTextLayers=true, bool resetTextEffects=true, bool reset3DModels=true)
Function Exchange_Module Replaces OldModule by NewModule, using OldModule settings: position,...
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions returns the display options current in use Display options are relative to...
bool UpdateNetlist(NETLIST &aNetlist)
Function UpdateNetlist()
bool empty() const
Definition: lib_id.h:186
int GetBottom() const
Definition: eda_rect.h:124
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:432
std::map< wxString, NETINFO_ITEM * > m_addedNets
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:166
Class COMPONENT_NET is used to store the component pin name to net name associations stored in a netl...
Definition: pcb_netlist.h:48
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
D_PAD * FindPadByName(const wxString &aPadName) const
Function FindPadByName returns a D_PAD* with a matching name.
const wxString & GetNetName() const
Definition: pcb_netlist.h:63
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:949
Class NETLIST stores all of information read from a netlist along with the flags used to update the N...
Definition: pcb_netlist.h:214
wxString getNetname(D_PAD *aPad)
MODULES & Modules()
Definition: class_board.h:227
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:225
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:111
unsigned GetNetCount() const
Definition: pcb_netlist.h:137
const wxString & GetReference() const
Definition: pcb_netlist.h:151
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:301
std::map< wxString, wxString > m_oldToNewNets
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Sets net using a net code.
void SetReference(const wxString &aReference)
Function SetReference.
Definition: class_module.h:442
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
COMMIT & Remove(EDA_ITEM *aItem)
Removes a new item from the model
Definition: commit.h:90
void SetPosition(const wxPoint &aPos) override
const wxString & GetNetname() const
Function GetNetname.
NETINFO_LIST & GetNetInfo()
Definition: class_board.h:738
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:139
#define _(s)
std::map< D_PAD *, wxString > m_padNets
int GetHeight() const
Definition: eda_rect.h:120
UTF8 Format() const
Definition: lib_id.cpp:237
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:630
Pad object description.
Class COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:83
bool IsValid() const
Definition: pcb_netlist.h:65
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
COMMIT & Modified(EDA_ITEM *aItem, EDA_ITEM *aCopy)
Creates an undo entry for an item that has been already modified.
Definition: commit.h:110
const std::vector< D_PAD * > GetPads()
Function GetPads returns a reference to a list of all the pads.
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
ZONE_CONTAINERS & Zones()
Definition: class_board.h:241
MODULE * LoadFootprint(const LIB_ID &aFootprintId)
Function LoadFootprint attempts to load aFootprintId from the footprint library table.
bool updateComponentParameters(MODULE *aPcbComponent, COMPONENT *aNewComponent)
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
size_t i
Definition: json11.cpp:649
wxString wx_str() const
Definition: utf8.cpp:51
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
void SetValue(const wxString &aValue)
Function SetValue.
Definition: class_module.h:466
The common library.
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
MODULE * FindModuleByReference(const wxString &aReference) const
Function FindModuleByReference searches for a MODULE within this board with the given reference desig...
void SetStatus(STATUS_FLAGS aStatus)
Definition: base_struct.h:263
wxPoint Centre() const
Definition: eda_rect.h:62
const wxString & GetPinName() const
Definition: pcb_netlist.h:61
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 & GetValue() const
Definition: pcb_netlist.h:153
COMPONENT * GetComponentByReference(const wxString &aReference)
Function GetComponentByReference returns a COMPONENT by aReference.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
std::vector< MODULE * > m_addedComponents
Module description (excepted pads)
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:914
static REPORTER & GetInstance()
Definition: reporter.cpp:104
BOARD_NETLIST_UPDATER(PCB_EDIT_FRAME *aFrame, BOARD *aBoard)
bool deleteUnusedComponents(NETLIST &aNetlist)
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:463
bool IsEmpty() const
Definition: class_board.h:257
void SetPath(const wxString &aPath)
Definition: class_module.h:232
const wxString & GetTimeStamp() const
Definition: pcb_netlist.h:170
TRACKS & Tracks()
Definition: class_board.h:218
bool IsOnCopperLayer() const override
Function IsOnCopperLayer.
Definition: class_zone.cpp:209
COMPONENT * GetComponentByTimeStamp(const wxString &aTimeStamp)
Function GetComponentByTimeStamp returns a COMPONENT by aTimeStamp.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:215
MODULE * addNewComponent(COMPONENT *aComponent)