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_track.h>
42 #include <class_zone.h>
43 
44 #include "pcb_netlist.h"
46 #include <reporter.h>
47 
48 #include "board_netlist_updater.h"
49 
50 #include <pcb_edit_frame.h>
51 
52 
54  m_frame( aFrame ),
55  m_commit( aFrame ),
56  m_board( aBoard )
57 {
59 
60  m_deleteSinglePadNets = true;
62  m_isDryRun = false;
63  m_replaceFootprints = true;
64  m_lookupByTimestamp = false;
65  m_warnForNoNetPads = false;
66 
67  m_warningCount = 0;
68  m_errorCount = 0;
70 }
71 
72 
74 {
75 }
76 
77 
78 // These functions allow inspection of pad nets during dry runs by keeping a cache of
79 // current pad netnames indexed by pad.
80 
81 void BOARD_NETLIST_UPDATER::cacheNetname( D_PAD* aPad, const wxString& aNetname )
82 {
83  m_padNets[ aPad ] = aNetname;
84 }
85 
86 
88 {
89  if( m_isDryRun && m_padNets.count( aPad ) )
90  return m_padNets[ aPad ];
91  else
92  return aPad->GetNetname();
93 }
94 
95 
96 void BOARD_NETLIST_UPDATER::cachePinFunction( D_PAD* aPad, const wxString& aPinFunction )
97 {
98  m_padPinFunctions[ aPad ] = aPinFunction;
99 }
100 
101 
103 {
104  if( m_isDryRun && m_padPinFunctions.count( aPad ) )
105  return m_padPinFunctions[ aPad ];
106  else
107  return aPad->GetPinFunction();
108 }
109 
110 
112 {
113  wxPoint bestPosition;
114 
115  if( !m_board->IsEmpty() )
116  {
117  // Position new components below any existing board features.
119 
120  if( bbox.GetWidth() || bbox.GetHeight() )
121  {
122  bestPosition.x = bbox.Centre().x;
123  bestPosition.y = bbox.GetBottom() + Millimeter2iu( 10 );
124  }
125  }
126  else
127  {
128  // Position new components in the center of the page when the board is empty.
129  wxSize pageSize = m_board->GetPageSettings().GetSizeIU();
130 
131  bestPosition.x = pageSize.GetWidth() / 2;
132  bestPosition.y = pageSize.GetHeight() / 2;
133  }
134 
135  return bestPosition;
136 }
137 
138 
140 {
141  wxString msg;
142 
143  if( aComponent->GetFPID().empty() )
144  {
145  msg.Printf( _( "Cannot add %s (no footprint assigned)." ),
146  aComponent->GetReference(),
147  aComponent->GetFPID().Format().wx_str() );
149  ++m_errorCount;
150  return nullptr;
151  }
152 
153  MODULE* footprint = m_frame->LoadFootprint( aComponent->GetFPID() );
154 
155  if( footprint == nullptr )
156  {
157  msg.Printf( _( "Cannot add %s (footprint \"%s\" not found)." ),
158  aComponent->GetReference(),
159  aComponent->GetFPID().Format().wx_str() );
161  ++m_errorCount;
162  return nullptr;
163  }
164 
165  msg.Printf( _( "Add %s (footprint \"%s\")." ),
166  aComponent->GetReference(),
167  aComponent->GetFPID().Format().wx_str() );
169 
170  // Set the pads ratsnest settings to the global settings
171  bool set_ratsnest = m_frame->GetDisplayOptions().m_ShowGlobalRatsnest;
172  for ( auto pad : footprint->Pads() )
173  pad->SetLocalRatsnestVisible( set_ratsnest );
174 
176 
177  if( !m_isDryRun )
178  {
179  footprint->SetParent( m_board );
181  footprint->SetTimeStamp( GetNewTimeStamp() );
182 
183  m_addedComponents.push_back( footprint );
184  m_commit.Add( footprint );
185 
186  return footprint;
187  }
188  else
189  delete footprint;
190 
191  return NULL;
192 }
193 
194 
196  COMPONENT* aNewComponent )
197 {
198  wxString msg;
199 
200  if( aNewComponent->GetFPID().empty() )
201  {
202  msg.Printf( _( "Cannot update %s (no footprint assigned)." ),
203  aNewComponent->GetReference(),
204  aNewComponent->GetFPID().Format().wx_str() );
206  ++m_errorCount;
207  return nullptr;
208  }
209 
210  MODULE* newFootprint = m_frame->LoadFootprint( aNewComponent->GetFPID() );
211 
212  if( newFootprint == nullptr )
213  {
214  msg.Printf( _( "Cannot update %s (footprint \"%s\" not found)." ),
215  aNewComponent->GetReference(),
216  aNewComponent->GetFPID().Format().wx_str() );
218  ++m_errorCount;
219  return nullptr;
220  }
221 
222  msg.Printf( _( "Change %s footprint from \"%s\" to \"%s\"."),
223  aPcbComponent->GetReference(),
224  aPcbComponent->GetFPID().Format().wx_str(),
225  aNewComponent->GetFPID().Format().wx_str() );
227 
229 
230  if( !m_isDryRun )
231  {
232  m_frame->Exchange_Module( aPcbComponent, newFootprint, m_commit );
233  return newFootprint;
234  }
235  else
236  delete newFootprint;
237 
238  return nullptr;
239 }
240 
241 
243  COMPONENT* aNewComponent )
244 {
245  wxString msg;
246 
247  // Create a copy only if the module has not been added during this update
248  MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
249  bool changed = false;
250 
251  // Test for reference designator field change.
252  if( aPcbComponent->GetReference() != aNewComponent->GetReference() )
253  {
254  msg.Printf( _( "Change %s reference to %s." ),
255  aPcbComponent->GetReference(),
256  aNewComponent->GetReference() );
258 
259  if ( !m_isDryRun )
260  {
261  changed = true;
262  aPcbComponent->SetReference( aNewComponent->GetReference() );
263  }
264  }
265 
266  // Test for value field change.
267  if( aPcbComponent->GetValue() != aNewComponent->GetValue() )
268  {
269  msg.Printf( _( "Change %s value from %s to %s." ),
270  aPcbComponent->GetReference(),
271  aPcbComponent->GetValue(),
272  aNewComponent->GetValue() );
274 
275  if( !m_isDryRun )
276  {
277  changed = true;
278  aPcbComponent->SetValue( aNewComponent->GetValue() );
279  }
280  }
281 
282  // Test for time stamp change.
283  if( aPcbComponent->GetPath() != aNewComponent->GetTimeStamp() )
284  {
285  msg.Printf( _( "Change symbol path \"%s:%s\" to \"%s\"." ),
286  aPcbComponent->GetReference(),
287  aPcbComponent->GetPath(),
288  aNewComponent->GetTimeStamp() );
290 
291  if( !m_isDryRun )
292  {
293  changed = true;
294  aPcbComponent->SetPath( aNewComponent->GetTimeStamp() );
295  }
296  }
297 
298  if( changed && copy )
299  m_commit.Modified( aPcbComponent, copy );
300  else
301  delete copy;
302 
303  return true;
304 }
305 
306 
308  COMPONENT* aNewComponent )
309 {
310  wxString msg;
311 
312  // Create a copy only if the module has not been added during this update
313  MODULE* copy = m_commit.GetStatus( aPcbComponent ) ? nullptr : (MODULE*) aPcbComponent->Clone();
314  bool changed = false;
315 
316  // At this point, the component footprint is updated. Now update the nets.
317  for( auto pad : aPcbComponent->Pads() )
318  {
319  const COMPONENT_NET& net = aNewComponent->GetNet( pad->GetName() );
320 
321  wxString pinFunction;
322 
323  if( net.IsValid() ) // i.e. the pad has a name
324  pinFunction = net.GetPinFunction();
325 
326  if( !m_isDryRun )
327  {
328  if( pad->GetPinFunction() != pinFunction )
329  {
330  changed = true;
331  pad->SetPinFunction( pinFunction );
332  }
333  }
334  else
335  cachePinFunction( pad, pinFunction );
336 
337  // Test if new footprint pad has no net (pads not on copper layers have no net).
338  if( !net.IsValid() || !pad->IsOnCopperLayer() )
339  {
340  if( !pad->GetNetname().IsEmpty() )
341  {
342  msg.Printf( _( "Disconnect %s pin %s." ),
343  aPcbComponent->GetReference(),
344  pad->GetName() );
346  }
347  else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetName().IsEmpty() )
348  {
349  // pad is connectable but has no net found in netlist
350  msg.Printf( _( "No net for component %s pin %s." ),
351  aPcbComponent->GetReference(),
352  pad->GetName() );
354  }
355 
356  if( !m_isDryRun )
357  {
358  changed = true;
359  pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
360 
361  // If the pad has no net from netlist (i.e. not in netlist
362  // it cannot have a pin function
363  if( pad->GetNetname().IsEmpty() )
364  pad->SetPinFunction( wxEmptyString );
365 
366  }
367  else
368  cacheNetname( pad, wxEmptyString );
369  }
370  else // New footprint pad has a net.
371  {
372  const wxString& netName = net.GetNetName();
373  NETINFO_ITEM* netinfo = m_board->FindNet( netName );
374 
375  if( netinfo && !m_isDryRun )
376  netinfo->SetIsCurrent( true );
377 
378  if( pad->GetNetname() != netName )
379  {
380 
381  if( netinfo == nullptr )
382  {
383  // It might be a new net that has not been added to the board yet
384  if( m_addedNets.count( netName ) )
385  netinfo = m_addedNets[ netName ];
386  }
387 
388  if( netinfo == nullptr )
389  {
390  netinfo = new NETINFO_ITEM( m_board, netName );
391 
392  // It is a new net, we have to add it
393  if( !m_isDryRun )
394  {
395  changed = true;
396  m_commit.Add( netinfo );
397  }
398 
399  m_addedNets[netName] = netinfo;
400  msg.Printf( _( "Add net %s." ), UnescapeString( netName ) );
402  }
403 
404  if( !pad->GetNetname().IsEmpty() )
405  {
406  m_oldToNewNets[ pad->GetNetname() ] = netName;
407 
408  msg.Printf( _( "Reconnect %s pin %s from %s to %s."),
409  aPcbComponent->GetReference(),
410  pad->GetName(),
411  UnescapeString( pad->GetNetname() ),
412  UnescapeString( netName ) );
413  }
414  else
415  {
416  msg.Printf( _( "Connect %s pin %s to %s."),
417  aPcbComponent->GetReference(),
418  pad->GetName(),
419  UnescapeString( netName ) );
420  }
422 
423  if( !m_isDryRun )
424  {
425  changed = true;
426  pad->SetNet( netinfo );
427  }
428  else
429  cacheNetname( pad, netName );
430  }
431  }
432  }
433 
434  if( changed && copy )
435  m_commit.Modified( aPcbComponent, copy );
436  else
437  delete copy;
438 
439  return true;
440 }
441 
442 
444 {
445  for( int ii = 0; ii < m_board->GetAreaCount(); ii++ )
446  {
447  ZONE_CONTAINER* zone = m_board->GetArea( ii );
448 
449  if( !zone->IsOnCopperLayer() || zone->GetIsKeepout() )
450  continue;
451 
452  m_zoneConnectionsCache[ zone ] = m_board->GetConnectivity()->GetConnectedPads( zone );
453  }
454 }
455 
456 
458 {
459  wxString msg;
460  std::set<wxString> netlistNetnames;
461 
462  for( int ii = 0; ii < (int) aNetlist.GetCount(); ii++ )
463  {
464  const COMPONENT* component = aNetlist.GetComponent( ii );
465  for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
466  {
467  const COMPONENT_NET& net = component->GetNet( jj );
468  netlistNetnames.insert( net.GetNetName() );
469  }
470  }
471 
472  for( auto via : m_board->Tracks() )
473  {
474  if( via->Type() != PCB_VIA_T )
475  continue;
476 
477  if( netlistNetnames.count( via->GetNetname() ) == 0 )
478  {
479  wxString updatedNetname = wxEmptyString;
480 
481  // Take via name from name change map if it didn't match to a new pad
482  // (this is useful for stitching vias that don't connect to tracks)
483  if( m_oldToNewNets.count( via->GetNetname() ) )
484  {
485  updatedNetname = m_oldToNewNets[via->GetNetname()];
486  }
487 
488  if( !updatedNetname.IsEmpty() )
489  {
490  msg.Printf( _( "Reconnect via from %s to %s." ),
491  UnescapeString( via->GetNetname() ), UnescapeString( updatedNetname ) );
493 
494  if( !m_isDryRun )
495  {
496  NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
497 
498  if( !netinfo )
499  netinfo = m_addedNets[updatedNetname];
500 
501  if( netinfo )
502  {
503  m_commit.Modify( via );
504  via->SetNet( netinfo );
505  }
506  }
507  }
508  else
509  {
510  msg.Printf( _( "Via connected to unknown net (%s)." ),
511  UnescapeString( via->GetNetname() ) );
513  ++m_warningCount;
514  }
515  }
516  }
517 
518  // Test copper zones to detect "dead" nets (nets without any pad):
519  for( int i = 0; i < m_board->GetAreaCount(); i++ )
520  {
521  ZONE_CONTAINER* zone = m_board->GetArea( i );
522 
523  if( !zone->IsOnCopperLayer() || zone->GetIsKeepout() )
524  continue;
525 
526  if( netlistNetnames.count( zone->GetNetname() ) == 0 )
527  {
528  // Look for a pad in the zone's connected-pad-cache which has been updated to
529  // a new net and use that. While this won't always be the right net, the dead
530  // net is guaranteed to be wrong.
531  wxString updatedNetname = wxEmptyString;
532 
533  for( D_PAD* pad : m_zoneConnectionsCache[ zone ] )
534  {
535  if( getNetname( pad ) != zone->GetNetname() )
536  {
537  updatedNetname = getNetname( pad );
538  break;
539  }
540  }
541 
542  // Take zone name from name change map if it didn't match to a new pad
543  // (this is useful for zones on internal layers)
544  if( updatedNetname.IsEmpty() && m_oldToNewNets.count( zone->GetNetname() ) )
545  {
546  updatedNetname = m_oldToNewNets[ zone->GetNetname() ];
547  }
548 
549  if( !updatedNetname.IsEmpty() )
550  {
551  msg.Printf( _( "Reconnect copper zone from %s to %s." ),
552  UnescapeString( zone->GetNetname() ),
553  UnescapeString( updatedNetname ) );
555 
556  if( !m_isDryRun )
557  {
558  NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
559 
560  if( !netinfo )
561  netinfo = m_addedNets[ updatedNetname ];
562 
563  if( netinfo )
564  {
565  m_commit.Modify( zone );
566  zone->SetNet( netinfo );
567  }
568  }
569  }
570  else
571  {
572  msg.Printf( _( "Copper zone (%s) has no pads connected." ),
573  UnescapeString( zone->GetNetname() ) );
575  ++m_warningCount;
576  }
577  }
578  }
579 
580  return true;
581 }
582 
583 
585 {
586  wxString msg;
587  const COMPONENT* component;
588 
589  for( auto module : m_board->Modules() )
590  {
591 
592  if( m_lookupByTimestamp )
593  component = aNetlist.GetComponentByTimeStamp( module->GetPath() );
594  else
595  component = aNetlist.GetComponentByReference( module->GetReference() );
596 
597  if( component == NULL )
598  {
599  if( module->IsLocked() )
600  {
601  msg.Printf( _( "Cannot remove unused footprint %s (locked)." ), module->GetReference() );
603  continue;
604  }
605 
606  msg.Printf( _( "Remove unused footprint %s." ), module->GetReference() );
608 
609  if( !m_isDryRun )
610  m_commit.Remove( module );
611  }
612  }
613 
614  return true;
615 }
616 
617 
619 {
620  int count = 0;
621  wxString netname;
622  wxString msg;
623  D_PAD* previouspad = NULL;
624 
625  // We need the pad list for next tests.
626 
628 
629  std::vector<D_PAD*> padlist = m_board->GetPads();
630 
631  // Sort pads by netlist name
632  std::sort( padlist.begin(), padlist.end(),
633  [ this ]( D_PAD* a, D_PAD* b ) -> bool { return getNetname( a ) < getNetname( b ); } );
634 
635  for( D_PAD* pad : padlist )
636  {
637  if( getNetname( pad ).IsEmpty() )
638  continue;
639 
640  if( netname != getNetname( pad ) ) // End of net
641  {
642  if( previouspad && count == 1 )
643  {
644  // First, see if we have a copper zone attached to this pad.
645  // If so, this is not really a single pad net
646 
647  for( ZONE_CONTAINER* zone : m_board->Zones() )
648  {
649  if( !zone->IsOnCopperLayer() )
650  continue;
651 
652  if( zone->GetIsKeepout() )
653  continue;
654 
655  if( zone->GetNetname() == getNetname( previouspad ) )
656  {
657  count++;
658  break;
659  }
660  }
661 
662  if( count == 1 ) // Really one pad, and nothing else
663  {
664  msg.Printf( _( "Remove single pad net %s." ),
665  UnescapeString( getNetname( previouspad ) ) );
667 
668  if( !m_isDryRun )
669  previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
670  else
671  cacheNetname( previouspad, wxEmptyString );
672  }
673  }
674 
675  netname = getNetname( pad );
676  count = 1;
677  }
678  else
679  {
680  count++;
681  }
682 
683  previouspad = pad;
684  }
685 
686  // Examine last pad
687  if( count == 1 )
688  {
689  if( !m_isDryRun )
690  previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
691  else
692  cacheNetname( previouspad, wxEmptyString );
693  }
694 
695  return true;
696 }
697 
698 
700 {
701  // Verify that board contains all pads in netlist: if it doesn't then footprints are
702  // wrong or missing.
703  // Note that we use references to find the footprints as they're already updated by this
704  // point (whether by-reference or by-timestamp).
705 
706  wxString msg;
707  wxString padname;
708 
709  for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
710  {
711  const COMPONENT* component = aNetlist.GetComponent( i );
712  MODULE* footprint = m_board->FindModuleByReference( component->GetReference() );
713 
714  if( footprint == NULL ) // It can be missing in partial designs
715  continue;
716 
717  // Explore all pins/pads in component
718  for( unsigned jj = 0; jj < component->GetNetCount(); jj++ )
719  {
720  const COMPONENT_NET& net = component->GetNet( jj );
721  padname = net.GetPinName();
722 
723  if( footprint->FindPadByName( padname ) )
724  continue; // OK, pad found
725 
726  // not found: bad footprint, report error
727  msg.Printf( _( "%s pad %s not found in %s." ),
728  component->GetReference(),
729  padname,
730  footprint->GetFPID().Format().wx_str() );
732  ++m_errorCount;
733  }
734  }
735 
736  return true;
737 }
738 
739 
741 {
742  wxString msg;
743  m_errorCount = 0;
744  m_warningCount = 0;
746  MODULE* lastPreexistingFootprint = m_board->Modules().empty() ? NULL : m_board->Modules().back();
747 
749 
750  if( !m_isDryRun )
751  {
752  m_board->SetStatus( 0 );
753 
754  // Mark all nets (except <no net>) as stale; we'll update those to current that
755  // we find in the netlist
756  for( NETINFO_ITEM* net : m_board->GetNetInfo() )
757  net->SetIsCurrent( net->GetNet() == 0 );
758  }
759 
760  for( unsigned i = 0; i < aNetlist.GetCount(); i++ )
761  {
762  COMPONENT* component = aNetlist.GetComponent( i );
763  int matchCount = 0;
764  MODULE* tmp;
765 
766  msg.Printf( _( "Processing component \"%s:%s:%s\"." ),
767  component->GetReference(),
768  component->GetTimeStamp(),
769  component->GetFPID().Format().wx_str() );
771 
772  for( auto footprint : m_board->Modules() )
773  {
774  bool match = false;
775 
776  if( footprint )
777  {
778  if( m_lookupByTimestamp )
779  match = footprint->GetPath() == component->GetTimeStamp();
780  else
781  match = footprint->GetReference().CmpNoCase( component->GetReference() ) == 0;
782  }
783 
784  if( match )
785  {
786  tmp = footprint;
787 
788  if( m_replaceFootprints && component->GetFPID() != footprint->GetFPID() )
789  tmp = replaceComponent( aNetlist, footprint, component );
790 
791  if( tmp )
792  {
793  updateComponentParameters( tmp, component );
794  updateComponentPadConnections( tmp, component );
795  }
796 
797  matchCount++;
798  }
799 
800  if( footprint == lastPreexistingFootprint )
801  {
802  // No sense going through the newly-created footprints: end of loop
803  break;
804  }
805  }
806 
807  if( matchCount == 0 )
808  {
809  tmp = addNewComponent( component );
810 
811  if( tmp )
812  {
813  updateComponentParameters( tmp, component );
814  updateComponentPadConnections( tmp, component );
815  }
816  }
817  else if( matchCount > 1 )
818  {
819  msg.Printf( _( "Multiple footprints found for \"%s\"." ),
820  component->GetReference() );
822  }
823  }
824 
825  updateCopperZoneNets( aNetlist );
826 
828  deleteUnusedComponents( aNetlist );
829 
830  if( !m_isDryRun )
831  {
832  m_commit.Push( _( "Update netlist" ) );
833  m_board->GetConnectivity()->Build( m_board );
834  testConnectivity( aNetlist );
835 
836  // Now the connectivity data is rebuilt, we can delete single pads nets
839  }
841  // We can delete single net pads in dry run mode only if no new footprints
842  // are added, because these new footprints are not actually added to the board
843  // and the current pad list is wrong in this case.
845 
846  if( m_isDryRun )
847  {
848  for( const auto& it : m_addedNets )
849  delete it.second;
850 
851  m_addedNets.clear();
852  }
853 
854  // Update the ratsnest
857 
858  msg.Printf( _( "Total warnings: %d, errors: %d." ), m_warningCount, m_errorCount );
860 
861  if( m_errorCount )
862  {
863  m_reporter->ReportTail( _( "Errors occurred during the netlist update. Unless you fix them "
864  "your board will not be consistent with the schematics." ),
866  return false;
867  }
868 
869  m_reporter->ReportTail( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
870  return true;
871 }
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
void BuildListOfNets()
Definition: class_board.h:716
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:545
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:791
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:228
int GetWidth() const
Definition: eda_rect.h:119
PADS & Pads()
Definition: class_module.h:173
const wxString GetValue() const
Function GetValue.
Definition: class_module.h:461
BOARD_NETLIST_UPDATER class definition.
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:259
int GetStatus(EDA_ITEM *aItem)
Returns status of an item.
Definition: commit.cpp:132
const LIB_ID & GetFPID() const
Definition: class_module.h:219
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 wxString & GetPinFunction() const
Definition: class_pad.h:211
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
Definitions for tracks, vias and zones.
int GetBottom() const
Definition: eda_rect.h:124
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:436
std::map< wxString, NETINFO_ITEM * > m_addedNets
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:169
COMPONENT_NET is used to store the component pin name to net name (and pin function) associations sto...
Definition: pcb_netlist.h:49
timestamp_t GetNewTimeStamp()
Definition: common.cpp:215
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:65
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:948
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:217
#define NULL
wxString getNetname(D_PAD *aPad)
MODULES & Modules()
Definition: class_board.h:226
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
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
wxString getPinFunction(D_PAD *aPad)
unsigned GetNetCount() const
Definition: pcb_netlist.h:140
const wxString & GetReference() const
Definition: pcb_netlist.h:154
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:300
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:446
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:737
const COMPONENT_NET & GetNet(unsigned aIndex) const
Definition: pcb_netlist.h:142
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:631
Pad object description.
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:85
const wxString & GetPinFunction() const
Definition: pcb_netlist.h:66
bool IsValid() const
Definition: pcb_netlist.h:68
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:268
void cachePinFunction(D_PAD *aPad, const wxString &aPinFunction)
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.
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
ZONE_CONTAINERS & Zones()
Definition: class_board.h:240
MODULE * LoadFootprint(const LIB_ID &aFootprintId)
Function LoadFootprint attempts to load aFootprintId from the footprint library table.
bool updateComponentParameters(MODULE *aPcbComponent, COMPONENT *aNewComponent)
std::map< D_PAD *, wxString > m_padPinFunctions
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:160
#define _(s)
Definition: 3d_actions.cpp:31
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
wxString wx_str() const
Definition: utf8.cpp:51
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
PCB_EDIT_FRAME is the main frame for Pcbnew.
void SetValue(const wxString &aValue)
Function SetValue.
Definition: class_module.h:470
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:253
wxPoint Centre() const
Definition: eda_rect.h:62
const wxString & GetPinName() const
Definition: pcb_netlist.h:64
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:156
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:913
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:256
void SetPath(const wxString &aPath)
Definition: class_module.h:229
const wxString & GetTimeStamp() const
Definition: pcb_netlist.h:173
TRACKS & Tracks()
Definition: class_board.h:217
bool IsOnCopperLayer() const override
Function IsOnCopperLayer.
Definition: class_zone.cpp:210
COMPONENT * GetComponentByTimeStamp(const wxString &aTimeStamp)
Function GetComponentByTimeStamp returns a COMPONENT by aTimeStamp.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:212
MODULE * addNewComponent(COMPONENT *aComponent)