KiCad PCB EDA Suite
backannotate.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 Alexander Shuklin <Jasuramme@gmail.com>
5  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 
26 #include <backannotate.h>
27 #include <boost/property_tree/ptree.hpp>
28 #include <confirm.h>
29 #include <dsnlexer.h>
30 #include <ptree.h>
31 #include <reporter.h>
32 #include <sch_edit_frame.h>
33 #include <sch_sheet_path.h>
34 #include <schematic.h>
35 #include <kiface_i.h>
37 
38 BACK_ANNOTATE::BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
39  bool aProcessFootprints, bool aProcessValues,
40  bool aProcessReferences, bool aProcessNetNames,
41  bool aIgnoreOtherProjects, bool aDryRun ) :
42  m_reporter( aReporter ),
43  m_matchByReference( aRelinkFootprints ),
44  m_processFootprints( aProcessFootprints ),
45  m_processValues( aProcessValues ),
46  m_processReferences( aProcessReferences ),
47  m_processNetNames( aProcessNetNames ),
48  m_ignoreOtherProjects( aIgnoreOtherProjects ),
49  m_dryRun( aDryRun ),
50  m_frame( aFrame ),
51  m_changesCount( 0 ),
52  m_appendUndo( false )
53 {
54 }
55 
56 
58 {
59 }
60 
61 
62 bool BACK_ANNOTATE::BackAnnotateSymbols( const std::string& aNetlist )
63 {
64  m_changesCount = 0;
65  m_appendUndo = false;
66  wxString msg;
67 
69  {
70  m_reporter.ReportTail( _( "Select at least one property to back annotate." ),
72  return false;
73  }
74 
75  getPcbModulesFromString( aNetlist );
76 
78  sheets.GetComponents( m_refs, false );
80 
81  getChangeList();
84 
86 
87  return true;
88 }
89 
90 bool BACK_ANNOTATE::FetchNetlistFromPCB( std::string& aNetlist )
91 {
92  if( Kiface().IsSingle() )
93  {
94  DisplayErrorMessage( m_frame, _( "Cannot fetch PCB netlist because eeschema is opened "
95  "in stand-alone mode.\n"
96  "You must launch the KiCad project manager and create "
97  "a project." ) );
98  return false;
99  }
100 
101  KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, false );
102 
103  if( !frame )
104  {
105  wxFileName fn( m_frame->Prj().GetProjectFullName() );
106  fn.SetExt( PcbFileExtension );
107 
108  frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, true );
109  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
110  }
111 
113  return true;
114 }
115 
116 
118 {
119  std::string nullPayload;
120 
122 }
123 
124 
125 void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
126 {
127  auto getStr = []( const PTREE& pt ) -> wxString
128  {
129  return UTF8( pt.front().first );
130  };
131 
132  DSNLEXER lexer( aPayload, FROM_UTF8( __func__ ) );
133  PTREE doc;
134 
135  // NOTE: KiCad's PTREE scanner constructs a property *name* tree, not a property tree.
136  // Every token in the s-expr is stored as a property name; the property's value is then
137  // either the nested s-exprs or an empty PTREE; there are *no* literal property values.
138 
139  Scan( &doc, &lexer );
140 
141  PTREE& tree = doc.get_child( "pcb_netlist" );
142  wxString msg;
143  m_pcbModules.clear();
144 
145  for( const std::pair<const std::string, PTREE>& item : tree )
146  {
147  wxString path, value, footprint;
148  std::map<wxString, wxString> pinNetMap;
149  wxASSERT( item.first == "ref" );
150  wxString ref = getStr( item.second );
151 
152  try
153  {
154  if( m_matchByReference )
155  path = ref;
156  else
157  path = getStr( item.second.get_child( "timestamp" ) );
158 
159  if( path == "" )
160  {
161  msg.Printf( _( "Footprint \"%s\" has no symbol associated." ), ref );
163  continue;
164  }
165 
166  footprint = getStr( item.second.get_child( "fpid" ) );
167  value = getStr( item.second.get_child( "value" ) );
168 
169  boost::optional<const PTREE&> nets = item.second.get_child_optional( "nets" );
170 
171  if( nets )
172  {
173  for( const std::pair<const std::string, PTREE>& pin_net : nets.get() )
174  {
175  wxASSERT( pin_net.first == "pin_net" );
176  wxString pinNumber = UTF8( pin_net.second.front().first );
177  wxString netName = UTF8( pin_net.second.back().first );
178  pinNetMap[ pinNumber ] = netName;
179  }
180  }
181  }
182  catch( ... )
183  {
184  wxLogWarning( "Cannot parse PCB netlist for back-annotation" );
185  }
186 
187  // Use lower_bound for not to iterate over map twice
188  auto nearestItem = m_pcbModules.lower_bound( path );
189 
190  if( nearestItem != m_pcbModules.end() && nearestItem->first == path )
191  {
192  // Module with this path already exists - generate error
193  msg.Printf( _( "Pcb footprints \"%s\" and \"%s\" linked to same symbol" ),
194  nearestItem->second->m_ref, ref );
196  }
197  else
198  {
199  // Add module to the map
200  auto data = std::make_shared<PCB_MODULE_DATA>( ref, footprint, value, pinNetMap );
201  m_pcbModules.insert( nearestItem, std::make_pair( path, data ) );
202  }
203  }
204 }
205 
206 
208 {
209  for( std::pair<const wxString, std::shared_ptr<PCB_MODULE_DATA>>& module : m_pcbModules )
210  {
211  const wxString& pcbPath = module.first;
212  auto& pcbData = module.second;
213  int refIndex;
214  bool foundInMultiunit = false;
215 
216  for( std::pair<const wxString, SCH_REFERENCE_LIST>& item : m_multiUnitsRefs )
217  {
218  SCH_REFERENCE_LIST& refList = item.second;
219 
220  if( m_matchByReference )
221  refIndex = refList.FindRef( pcbPath );
222  else
223  refIndex = refList.FindRefByPath( pcbPath );
224 
225  if( refIndex >= 0 )
226  {
227  // If module linked to multi unit symbol, we add all symbol's units to
228  // the change list
229  foundInMultiunit = true;
230 
231  for( size_t i = 0; i < refList.GetCount(); ++i )
232  {
233  refList[i].GetComp()->ClearFlags( SKIP_STRUCT );
234  m_changelist.emplace_back( CHANGELIST_ITEM( refList[i], pcbData ) );
235  }
236 
237  break;
238  }
239  }
240 
241  if( foundInMultiunit )
242  continue;
243 
244  if( m_matchByReference )
245  refIndex = m_refs.FindRef( pcbPath );
246  else
247  refIndex = m_refs.FindRefByPath( pcbPath );
248 
249  if( refIndex >= 0 )
250  {
251  m_refs[refIndex].GetComp()->ClearFlags( SKIP_STRUCT );
252  m_changelist.emplace_back( CHANGELIST_ITEM( m_refs[refIndex], pcbData ) );
253  }
254  else
255  {
256  // Haven't found linked symbol in multiunits or common refs. Generate error
257  wxString msg;
258  msg.Printf( _( "Cannot find symbol for \"%s\" footprint" ), pcbData->m_ref );
260  }
261  }
262 }
263 
265 {
267 
268  std::sort( m_changelist.begin(), m_changelist.end(),
269  []( const CHANGELIST_ITEM& a, const CHANGELIST_ITEM& b )
270  {
271  return SCH_REFERENCE_LIST::sortByTimeStamp( a.first, b.first );
272  } );
273 
274  size_t i = 0;
275 
276  for( auto& item : m_changelist )
277  {
278  // Refs and changelist are both sorted by paths, so we just go over m_refs and
279  // generate errors before we will find m_refs member to which item linked
280  while( i < m_refs.GetCount() && m_refs[i].GetPath() != item.first.GetPath() )
281  {
282  wxString msg;
283  msg.Printf( _( "Cannot find footprint for \"%s\" symbol" ), m_refs[i++].GetFullRef() );
285  }
286 
287  ++i;
288  }
289 
291  {
292  m_reporter.ReportTail( _( "Cannot relink footprints because schematic is not fully annotated" ),
294  }
295 }
296 
297 
299 {
300  if( m_processFootprints && aFirst.m_footprint != aSecond.m_footprint )
301  return false;
302 
303  if( m_processValues && aFirst.m_value != aSecond.m_value )
304  return false;
305 
306  return true;
307 }
308 
310 {
311  std::sort( m_changelist.begin(), m_changelist.end(),
312  []( CHANGELIST_ITEM& a, CHANGELIST_ITEM& b )
313  {
314  return a.first.GetComp() > b.first.GetComp();
315  } );
316 
317  // We don't check that if no footprints or values updating
319  return;
320 
321  // We will count how many times every component used in our changelist
322  // Component in this case is SCH_COMPONENT which can be used by more than one symbol
323  int usageCount = 1;
324 
325  for( auto it = m_changelist.begin(); it != m_changelist.end(); ++it )
326  {
327  int compUsage = it->first.GetComp()->GetInstanceReferences().size();
328 
329  if( compUsage == 1 )
330  continue;
331 
332  // If that's not the last reference in list and references share same component
333  if( ( it + 1 ) != m_changelist.end() && it->first.GetComp() == ( it + 1 )->first.GetComp() )
334  {
335  ++usageCount;
336 
337  if( !checkReuseViolation( *it->second, *( it + 1 )->second ) )
338  {
339  // Refs share same component but have different values or footprints
340  it->first.GetComp()->SetFlags( SKIP_STRUCT );
341 
342  wxString msg;
343  msg.Printf( _( "\"%s\" and \"%s\" use the same schematic symbol.\n"
344  "They cannot have different footprints or values." ),
345  ( it + 1 )->second->m_ref,
346  it->second->m_ref );
348  }
349  }
350  else
351  {
352  /* Next ref uses different component, so we count all components number for current
353  one. We compare that number to stored in the component itself. If that differs, it
354  means that this particular component is reused in some other project. */
355  if( !m_ignoreOtherProjects && compUsage > usageCount )
356  {
357  SCH_COMPONENT* comp = it->first.GetComp();
358  PCB_MODULE_DATA tmp{ "",
359  comp->GetField( FOOTPRINT )->GetText(),
360  comp->GetField( VALUE )->GetText(),
361  {} };
362 
363  if( !checkReuseViolation( tmp, *it->second ) )
364  {
365  it->first.GetComp()->SetFlags( SKIP_STRUCT );
366 
367  wxString msg;
368  msg.Printf( _( "Unable to change \"%s\" footprint or value because associated"
369  " symbol is reused in the another project" ),
370  it->second->m_ref );
372  }
373  }
374  usageCount = 1;
375  }
376  }
377 }
378 
379 
381 {
382  std::set<wxString> handledNetChanges;
383  wxString msg;
384 
385  // Apply changes from change list
386  for( CHANGELIST_ITEM& item : m_changelist )
387  {
388  SCH_REFERENCE& ref = item.first;
389  PCB_MODULE_DATA& module = *item.second;
390  SCH_COMPONENT* comp = ref.GetComp();
391  SCH_SCREEN* screen = ref.GetSheetPath().LastScreen();
392  wxString oldFootprint = comp->GetField( FOOTPRINT )->GetText();
393  wxString oldValue = comp->GetField( VALUE )->GetText();
394  bool skip = ( ref.GetComp()->GetFlags() & SKIP_STRUCT ) > 0;
395 
396  if( m_processReferences && ref.GetRef() != module.m_ref && !skip )
397  {
398  ++m_changesCount;
399  msg.Printf( _( "Change \"%s\" reference designator to \"%s\"." ),
400  ref.GetFullRef(),
401  module.m_ref );
402 
403  if( !m_dryRun )
404  {
406  m_appendUndo = true;
407  comp->SetRef( &ref.GetSheetPath(), module.m_ref );
408  }
409 
411  }
412 
413  if( m_processFootprints && oldFootprint != module.m_footprint && !skip )
414  {
415  ++m_changesCount;
416  msg.Printf( _( "Change %s footprint from \"%s\" to \"%s\"." ),
417  ref.GetFullRef(),
418  comp->GetField( FOOTPRINT )->GetText(),
419  module.m_footprint );
420 
421  if( !m_dryRun )
422  {
424  m_appendUndo = true;
425  ref.GetComp()->GetField( FOOTPRINT )->SetText( module.m_footprint );
426  }
427 
429  }
430 
431  if( m_processValues && oldValue != module.m_value && !skip )
432  {
433  ++m_changesCount;
434  msg.Printf( _( "Change %s value from \"%s\" to \"%s\"." ),
435  ref.GetFullRef(),
436  comp->GetField( VALUE )->GetText(),
437  module.m_value );
438 
439  if( !m_dryRun )
440  {
442  m_appendUndo = true;
443  comp->GetField( VALUE )->SetText( module.m_value );
444  }
445 
447  }
448 
449  if( m_processNetNames )
450  {
451  for( const std::pair<const wxString, wxString>& entry : module.m_pinMap )
452  {
453  const wxString& pinNumber = entry.first;
454  const wxString& shortNetName = entry.second;
455  LIB_PIN* pin = comp->GetPin( pinNumber );
456  SCH_CONNECTION* conn = comp->GetConnectionForPin( pin, ref.GetSheetPath() );
457 
458  wxString key = shortNetName + ref.GetSheetPath().PathAsString();
459 
460  if( handledNetChanges.count( key ) )
461  continue;
462  else
463  handledNetChanges.insert( key );
464 
465  if( conn && conn->Name( true ) != shortNetName )
466  processNetNameChange( conn, conn->Name( true ), shortNetName );
467  }
468  }
469  }
470 
472 }
473 
474 
476 {
478 
479  // Initial orientation from the pin
480  switch( aPin->GetLibPin()->GetOrientation() )
481  {
482  case PIN_UP: spin = LABEL_SPIN_STYLE::BOTTOM; break;
483  case PIN_DOWN: spin = LABEL_SPIN_STYLE::UP; break;
484  case PIN_LEFT: spin = LABEL_SPIN_STYLE::LEFT; break;
485  case PIN_RIGHT: spin = LABEL_SPIN_STYLE::RIGHT; break;
486  }
487 
488  // Reorient based on the actual component orientation now
489  struct ORIENT
490  {
491  int flag;
492  int n_rots;
493  int mirror_x;
494  int mirror_y;
495  }
496  orientations[] =
497  {
498  { CMP_ORIENT_0, 0, 0, 0 },
499  { CMP_ORIENT_90, 1, 0, 0 },
500  { CMP_ORIENT_180, 2, 0, 0 },
501  { CMP_ORIENT_270, 3, 0, 0 },
502  { CMP_MIRROR_X + CMP_ORIENT_0, 0, 1, 0 },
503  { CMP_MIRROR_X + CMP_ORIENT_90, 1, 1, 0 },
504  { CMP_MIRROR_Y, 0, 0, 1 },
505  { CMP_MIRROR_X + CMP_ORIENT_270, 3, 1, 0 },
506  { CMP_MIRROR_Y + CMP_ORIENT_0, 0, 0, 1 },
507  { CMP_MIRROR_Y + CMP_ORIENT_90, 1, 0, 1 },
508  { CMP_MIRROR_Y + CMP_ORIENT_180, 2, 0, 1 },
509  { CMP_MIRROR_Y + CMP_ORIENT_270, 3, 0, 1 }
510  };
511 
512  ORIENT o = orientations[ 0 ];
513 
514  SCH_COMPONENT* comp = aPin->GetParentComponent();
515 
516  if( !comp )
517  return spin;
518 
519  int compOrient = comp->GetOrientation();
520 
521  for( auto& i : orientations )
522  {
523  if( i.flag == compOrient )
524  {
525  o = i;
526  break;
527  }
528  }
529 
530  for( int i = 0; i < o.n_rots; i++ )
531  spin = spin.RotateCCW();
532 
533  if( o.mirror_x )
534  spin = spin.MirrorX();
535 
536  if( o.mirror_y )
537  spin = spin.MirrorY();
538 
539  return spin;
540 }
541 
542 void BACK_ANNOTATE::processNetNameChange( SCH_CONNECTION* aConn, const wxString& aOldName,
543  const wxString& aNewName )
544 {
545  wxString msg;
546  SCH_ITEM* driver = aConn->Driver();
547 
548  auto editMatchingLabels =
549  [this]( SCH_SCREEN* aScreen, KICAD_T aType, const wxString& oldName,
550  const wxString& newName )
551  {
552  for( SCH_ITEM* schItem : aScreen->Items().OfType( aType ) )
553  {
554  SCH_TEXT* label = static_cast<SCH_TEXT*>( schItem );
555 
556  if( EscapeString( label->GetShownText(), CTX_NETNAME ) == oldName )
557  {
558  m_frame->SaveCopyInUndoList( aScreen, label, UR_CHANGED, m_appendUndo );
559  m_appendUndo = true;
560  static_cast<SCH_TEXT*>( label )->SetText( newName );
561  }
562  }
563  };
564 
565  switch( driver->Type() )
566  {
567  case SCH_LABEL_T:
568  ++m_changesCount;
569  msg.Printf( _( "Change \"%s\" labels to \"%s\"." ), aOldName, aNewName );
570 
571  if( !m_dryRun )
572  {
573  SCH_SCREEN* screen = aConn->Sheet().LastScreen();
574 
575  for( SCH_ITEM* label : screen->Items().OfType( SCH_LABEL_T ) )
576  {
577  SCH_CONNECTION* conn = label->Connection( aConn->Sheet() );
578 
579  if( conn && conn->Driver() == driver )
580  {
582  m_appendUndo = true;
583  static_cast<SCH_TEXT*>( label )->SetText( aNewName );
584  }
585  }
586  }
587 
589  break;
590 
591  case SCH_GLOBAL_LABEL_T:
592  ++m_changesCount;
593  msg.Printf( _( "Change \"%s\" global labels to \"%s\"." ), aOldName, aNewName );
594 
595  if( !m_dryRun )
596  {
597  for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
598  editMatchingLabels( sheet.LastScreen(), SCH_GLOBAL_LABEL_T, aOldName, aNewName );
599  }
600 
602  break;
603 
604  case SCH_HIER_LABEL_T:
605  ++m_changesCount;
606  msg.Printf( _( "Change \"%s\" hierarchical label to \"%s\"." ), aOldName, aNewName );
607 
608  if( !m_dryRun )
609  {
610  SCH_SCREEN* screen = aConn->Sheet().LastScreen();
611  editMatchingLabels( screen, SCH_HIER_LABEL_T, aOldName, aNewName );
612 
613  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( driver->GetParent() );
614  wxASSERT( sheet );
615 
616  if( !sheet )
617  break;
618 
619  screen = sheet->GetScreen();
620 
621  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
622  {
623  if( EscapeString( pin->GetShownText(), CTX_NETNAME ) == aOldName )
624  {
626  m_appendUndo = true;
627  static_cast<SCH_TEXT*>( pin )->SetText( aNewName );
628  }
629  }
630  }
631 
633  break;
634 
635  case SCH_SHEET_PIN_T:
636  ++m_changesCount;
637  msg.Printf( _( "Change \"%s\" hierarchical label to \"%s\"." ), aOldName, aNewName );
638 
639  if( !m_dryRun )
640  {
641  SCH_SCREEN* screen = aConn->Sheet().LastScreen();
642  m_frame->SaveCopyInUndoList( screen, driver, UR_CHANGED, m_appendUndo );
643  m_appendUndo = true;
644  static_cast<SCH_TEXT*>( driver )->SetText( aNewName );
645 
646  SCH_SHEET* sheet = static_cast<SCH_SHEET_PIN*>( driver )->GetParent();
647  screen = sheet->GetScreen();
648  editMatchingLabels( screen, SCH_HIER_LABEL_T, aOldName, aNewName );
649  }
650 
652  break;
653 
654  case SCH_PIN_T:
655  {
656  SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
657  LABEL_SPIN_STYLE spin = orientLabel( schPin );
658 
659  if( schPin->IsPowerConnection() )
660  {
661  msg.Printf( _( "Net \"%s\" cannot be changed to \"%s\" because it "
662  "is driven by a power pin." ),
663  aOldName,
664  aNewName );
665 
667  break;
668  }
669 
670  ++m_changesCount;
671  msg.Printf( _( "Add label \"%s\" to net \"%s\"." ), aNewName, aOldName );
672 
673  if( !m_dryRun )
674  {
675  SCHEMATIC_SETTINGS& settings = m_frame->Schematic().Settings();
676  SCH_LABEL* label = new SCH_LABEL( driver->GetPosition(), aNewName );
677  label->SetParent( &m_frame->Schematic() );
678  label->SetTextSize( wxSize( settings.m_DefaultTextSize,
679  settings.m_DefaultTextSize ) );
680  label->SetLabelSpinStyle( spin );
681  label->SetFlags( IS_NEW );
682 
683  SCH_SCREEN* screen = aConn->Sheet().LastScreen();
685  m_appendUndo = true;
686  }
687 
689  }
690  break;
691 
692  default:
693  break;
694  }
695 }
UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to...
Definition: utf8.h:73
SCH_SHEET_LIST.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:118
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:65
static bool sortByTimeStamp(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
BACK_ANNOTATE(SCH_EDIT_FRAME *aFrame, REPORTER &aReporter, bool aRelinkFootprints, bool aProcessFootprints, bool aProcessValues, bool aProcessReferences, bool aProcessNetNames, bool aIgnoreOtherProjects, bool aDryRun)
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:114
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:92
int GetOrientation()
Get the display symbol orientation.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
SCH_EDIT_FRAME * m_frame
Definition: backannotate.h:119
This file is part of the common library.
int FindRefByPath(const wxString &aPath) const
searches the list for a component with the given KIID path
const SCH_SHEET_PATH & GetSheetPath() const
int GetOrientation() const
Definition: lib_pin.h:152
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Function Scan fills an empty PTREE with information from a KiCad s-expresion stream.
Definition: ptree.cpp:90
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
void PushNewLinksToPCB()
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:138
SCH_COMPONENT * GetComp() const
bool m_processNetNames
Definition: backannotate.h:111
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Function ReportTail Places the report at the end of the list, for objects that support report orderin...
Definition: reporter.h:94
std::map< wxString, wxString > m_pinMap
Definition: backannotate.h:74
bool m_processFootprints
Definition: backannotate.h:108
PCB_MODULES_MAP m_pcbModules
Definition: backannotate.h:115
wxString PathAsString() const
Function PathAsString the path uses the time stamps which do not changes even when editing sheet para...
LIB_PIN * GetPin(const wxString &number)
Find a symbol pin by number.
Schematic editor (Eeschema) main window.
bool m_processReferences
Definition: backannotate.h:110
void getPcbModulesFromString(const std::string &aPayload)
Parse netlist sent over KiWay epress mail interface and fill m_pcbModules.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:238
bool ReadyToNetlist(bool aSilent=false, bool aSilentAnnotate=false)
Checks if we are ready to write a netlist file for the current schematic.
Definition: lib_pin.h:55
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
bool m_matchByReference
Definition: backannotate.h:107
Field Name Module PCB, i.e. "16DIP300".
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool BackAnnotateSymbols(const std::string &aNetlist)
Run back annotation algorithm.
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierarchy,...
int FindRef(const wxString &aPath) const
searches the list for a component with a given reference.
void checkForUnusedSymbols()
Check if some symbols are not represented in PCB modules and vice versa.
REPORTER & m_reporter
Definition: backannotate.h:105
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
bool checkReuseViolation(PCB_MODULE_DATA &aFirst, PCB_MODULE_DATA &aSecond)
Check if modules has different data.
wxString GetRef() const
boost::property_tree::ptree PTREE
Definition: ptree.h:54
bool m_processValues
Definition: backannotate.h:109
void SortByTimeStamp()
Function SortComponentsByTimeStamp sort the flat list by Time Stamp (sheet path + timestamp).
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
bool FetchNetlistFromPCB(std::string &aNetlist)
Get netlist from the PCBnew.
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:342
std::pair< SCH_REFERENCE, std::shared_ptr< PCB_MODULE_DATA > > CHANGELIST_ITEM
Definition: backannotate.h:80
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false) const
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of...
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
SCH_ITEM * Driver() const
void processNetNameChange(SCH_CONNECTION *aConn, const wxString &aOldName, const wxString &aNewName)
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
SCH_CONNECTION * GetConnectionForPin(LIB_PIN *aPin, const SCH_SHEET_PATH &aSheet)
Retrieves the connection for a given pin of the component.
const wxString & Name(bool aIgnoreSheet=false) const
#define PcbFileExtension
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
SCH_SHEET_PATH.
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:117
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:484
LABEL_SPIN_STYLE MirrorY()
Definition: sch_text.h:127
void getChangeList()
Create changelist
LABEL_SPIN_STYLE RotateCCW()
Definition: sch_text.h:89
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:362
virtual REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Function ReportHead Places the report at the beginning of the list for objects that support ordering.
Definition: reporter.h:103
unsigned GetCount() const
Function GetCount.
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
void checkSharedSchematicErrors()
Check for errors connected to reusing schematic in project or between projects.
Field Value of part, i.e. "3.3K".
wxString GetFullRef()
Return reference name with unit altogether
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:432
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
SCH_SHEET_PATH Sheet() const
bool m_ignoreOtherProjects
Definition: backannotate.h:112
LABEL_SPIN_STYLE MirrorX()
Definition: sch_text.h:108
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
SCH_SCREEN * LastScreen()
Function LastScreen.
void applyChangelist()
Apply changelist to the schematic.
static LABEL_SPIN_STYLE orientLabel(SCH_PIN *aPin)
Struct to hold PCBnew module data.
Definition: backannotate.h:61
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
#define _(s)
Definition: 3d_actions.cpp:33
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
These Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which ar...
Definition: string.cpp:50
EE_RTREE & Items()
Definition: sch_screen.h:158
Schematic symbol object.
Definition: sch_component.h:88
These settings were stored in SCH_BASE_FRAME previously.
SCH_REFERENCE_LIST m_refs
Definition: backannotate.h:116
bool IsPowerConnection() const
Definition: sch_pin.h:110
std::deque< CHANGELIST_ITEM > m_changelist
Definition: backannotate.h:118
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:230
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:234
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:81
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:187
DSNLEXER implements a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:79
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.
SCH_MULTI_UNIT_REFERENCE_MAP m_multiUnitsRefs
Definition: backannotate.h:117
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193