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 <kicad_string.h>
36 #include <kiface_i.h>
38 
39 BACK_ANNOTATE::BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
40  bool aProcessFootprints, bool aProcessValues,
41  bool aProcessReferences, bool aProcessNetNames,
42  bool aDryRun ) :
43  m_reporter( aReporter ),
44  m_matchByReference( aRelinkFootprints ),
45  m_processFootprints( aProcessFootprints ),
46  m_processValues( aProcessValues ),
47  m_processReferences( aProcessReferences ),
48  m_processNetNames( aProcessNetNames ),
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();
83 
85 
86  return true;
87 }
88 
89 bool BACK_ANNOTATE::FetchNetlistFromPCB( std::string& aNetlist )
90 {
91  if( Kiface().IsSingle() )
92  {
93  DisplayErrorMessage( m_frame, _( "Cannot fetch PCB netlist because eeschema is opened "
94  "in stand-alone mode.\n"
95  "You must launch the KiCad project manager and create "
96  "a project." ) );
97  return false;
98  }
99 
100  KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, false );
101 
102  if( !frame )
103  {
104  wxFileName fn( m_frame->Prj().GetProjectFullName() );
105  fn.SetExt( PcbFileExtension );
106 
107  frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, true );
108  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
109  }
110 
112  return true;
113 }
114 
115 
117 {
118  std::string nullPayload;
119 
121 }
122 
123 
124 void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
125 {
126  auto getStr = []( const PTREE& pt ) -> wxString
127  {
128  return UTF8( pt.front().first );
129  };
130 
131  DSNLEXER lexer( aPayload, FROM_UTF8( __func__ ) );
132  PTREE doc;
133 
134  // NOTE: KiCad's PTREE scanner constructs a property *name* tree, not a property tree.
135  // Every token in the s-expr is stored as a property name; the property's value is then
136  // either the nested s-exprs or an empty PTREE; there are *no* literal property values.
137 
138  Scan( &doc, &lexer );
139 
140  PTREE& tree = doc.get_child( "pcb_netlist" );
141  wxString msg;
142  m_pcbModules.clear();
143 
144  for( const std::pair<const std::string, PTREE>& item : tree )
145  {
146  wxString path, value, footprint;
147  std::map<wxString, wxString> pinNetMap;
148  wxASSERT( item.first == "ref" );
149  wxString ref = getStr( item.second );
150 
151  try
152  {
153  if( m_matchByReference )
154  path = ref;
155  else
156  path = getStr( item.second.get_child( "timestamp" ) );
157 
158  if( path == "" )
159  {
160  msg.Printf( _( "Footprint \"%s\" has no symbol associated." ), ref );
162  continue;
163  }
164 
165  footprint = getStr( item.second.get_child( "fpid" ) );
166  value = getStr( item.second.get_child( "value" ) );
167 
168  boost::optional<const PTREE&> nets = item.second.get_child_optional( "nets" );
169 
170  if( nets )
171  {
172  for( const std::pair<const std::string, PTREE>& pin_net : nets.get() )
173  {
174  wxASSERT( pin_net.first == "pin_net" );
175  wxString pinNumber = UTF8( pin_net.second.front().first );
176  wxString netName = UTF8( pin_net.second.back().first );
177  pinNetMap[ pinNumber ] = netName;
178  }
179  }
180  }
181  catch( ... )
182  {
183  wxLogWarning( "Cannot parse PCB netlist for back-annotation" );
184  }
185 
186  // Use lower_bound for not to iterate over map twice
187  auto nearestItem = m_pcbModules.lower_bound( path );
188 
189  if( nearestItem != m_pcbModules.end() && nearestItem->first == path )
190  {
191  // Module with this path already exists - generate error
192  msg.Printf( _( "Pcb footprints \"%s\" and \"%s\" linked to same symbol" ),
193  nearestItem->second->m_ref, ref );
195  }
196  else
197  {
198  // Add module to the map
199  auto data = std::make_shared<PCB_MODULE_DATA>( ref, footprint, value, pinNetMap );
200  m_pcbModules.insert( nearestItem, std::make_pair( path, data ) );
201  }
202  }
203 }
204 
205 
207 {
208  for( std::pair<const wxString, std::shared_ptr<PCB_MODULE_DATA>>& module : m_pcbModules )
209  {
210  const wxString& pcbPath = module.first;
211  auto& pcbData = module.second;
212  int refIndex;
213  bool foundInMultiunit = false;
214 
215  for( std::pair<const wxString, SCH_REFERENCE_LIST>& item : m_multiUnitsRefs )
216  {
217  SCH_REFERENCE_LIST& refList = item.second;
218 
219  if( m_matchByReference )
220  refIndex = refList.FindRef( pcbPath );
221  else
222  refIndex = refList.FindRefByPath( pcbPath );
223 
224  if( refIndex >= 0 )
225  {
226  // If module linked to multi unit symbol, we add all symbol's units to
227  // the change list
228  foundInMultiunit = true;
229 
230  for( size_t i = 0; i < refList.GetCount(); ++i )
231  {
232  refList[i].GetComp()->ClearFlags( SKIP_STRUCT );
233  m_changelist.emplace_back( CHANGELIST_ITEM( refList[i], pcbData ) );
234  }
235 
236  break;
237  }
238  }
239 
240  if( foundInMultiunit )
241  continue;
242 
243  if( m_matchByReference )
244  refIndex = m_refs.FindRef( pcbPath );
245  else
246  refIndex = m_refs.FindRefByPath( pcbPath );
247 
248  if( refIndex >= 0 )
249  {
250  m_refs[refIndex].GetComp()->ClearFlags( SKIP_STRUCT );
251  m_changelist.emplace_back( CHANGELIST_ITEM( m_refs[refIndex], pcbData ) );
252  }
253  else
254  {
255  // Haven't found linked symbol in multiunits or common refs. Generate error
256  wxString msg;
257  msg.Printf( _( "Cannot find symbol for \"%s\" footprint" ), pcbData->m_ref );
259  }
260  }
261 }
262 
264 {
266 
267  std::sort( m_changelist.begin(), m_changelist.end(),
268  []( const CHANGELIST_ITEM& a, const CHANGELIST_ITEM& b )
269  {
270  return SCH_REFERENCE_LIST::sortByTimeStamp( a.first, b.first );
271  } );
272 
273  size_t i = 0;
274 
275  for( auto& item : m_changelist )
276  {
277  // Refs and changelist are both sorted by paths, so we just go over m_refs and
278  // generate errors before we will find m_refs member to which item linked
279  while( i < m_refs.GetCount() && m_refs[i].GetPath() != item.first.GetPath() )
280  {
281  wxString msg;
282  msg.Printf( _( "Cannot find footprint for \"%s\" symbol" ), m_refs[i++].GetFullRef() );
284  }
285 
286  ++i;
287  }
288 
290  {
291  m_reporter.ReportTail( _( "Cannot relink footprints because schematic is not fully annotated" ),
293  }
294 }
295 
296 
298 {
299  std::set<wxString> handledNetChanges;
300  wxString msg;
301 
302  // Apply changes from change list
303  for( CHANGELIST_ITEM& item : m_changelist )
304  {
305  SCH_REFERENCE& ref = item.first;
306  PCB_MODULE_DATA& module = *item.second;
307  SCH_COMPONENT* comp = ref.GetComp();
308  SCH_SCREEN* screen = ref.GetSheetPath().LastScreen();
309  wxString oldFootprint = ref.GetFootprint();
310  wxString oldValue = ref.GetValue();
311  bool skip = ( ref.GetComp()->GetFlags() & SKIP_STRUCT ) > 0;
312 
313  if( m_processReferences && ref.GetRef() != module.m_ref && !skip )
314  {
315  ++m_changesCount;
316  msg.Printf( _( "Change \"%s\" reference designator to \"%s\"." ),
317  ref.GetFullRef(),
318  module.m_ref );
319 
320  if( !m_dryRun )
321  {
323  m_appendUndo = true;
324  comp->SetRef( &ref.GetSheetPath(), module.m_ref );
325  }
326 
328  }
329 
330  if( m_processFootprints && oldFootprint != module.m_footprint && !skip )
331  {
332  ++m_changesCount;
333  msg.Printf( _( "Change %s footprint from \"%s\" to \"%s\"." ),
334  ref.GetFullRef(),
335  oldFootprint,
336  module.m_footprint );
337 
338  if( !m_dryRun )
339  {
341  m_appendUndo = true;
342  comp->SetFootprint( &ref.GetSheetPath(), module.m_footprint );
343  }
344 
346  }
347 
348  if( m_processValues && oldValue != module.m_value && !skip )
349  {
350  ++m_changesCount;
351  msg.Printf( _( "Change %s value from \"%s\" to \"%s\"." ),
352  ref.GetFullRef(),
353  oldValue,
354  module.m_value );
355 
356  if( !m_dryRun )
357  {
359  m_appendUndo = true;
360  comp->SetValue( &ref.GetSheetPath(), module.m_value );
361  }
362 
364  }
365 
366  if( m_processNetNames )
367  {
368  for( const std::pair<const wxString, wxString>& entry : module.m_pinMap )
369  {
370  const wxString& pinNumber = entry.first;
371  const wxString& shortNetName = entry.second;
372  SCH_PIN* pin = comp->GetPin( pinNumber );
373  SCH_CONNECTION* conn = pin->Connection( &ref.GetSheetPath() );
374 
375  wxString key = shortNetName + ref.GetSheetPath().PathAsString();
376 
377  if( handledNetChanges.count( key ) )
378  continue;
379  else
380  handledNetChanges.insert( key );
381 
382  if( conn && conn->Name( true ) != shortNetName )
383  processNetNameChange( conn, conn->Name( true ), shortNetName );
384  }
385  }
386  }
387 
388  if( !m_dryRun )
389  {
392  }
393 
395 }
396 
397 
399 {
401 
402  // Initial orientation from the pin
403  switch( aPin->GetLibPin()->GetOrientation() )
404  {
405  case PIN_UP: spin = LABEL_SPIN_STYLE::BOTTOM; break;
406  case PIN_DOWN: spin = LABEL_SPIN_STYLE::UP; break;
407  case PIN_LEFT: spin = LABEL_SPIN_STYLE::LEFT; break;
408  case PIN_RIGHT: spin = LABEL_SPIN_STYLE::RIGHT; break;
409  }
410 
411  // Reorient based on the actual component orientation now
412  struct ORIENT
413  {
414  int flag;
415  int n_rots;
416  int mirror_x;
417  int mirror_y;
418  }
419  orientations[] =
420  {
421  { CMP_ORIENT_0, 0, 0, 0 },
422  { CMP_ORIENT_90, 1, 0, 0 },
423  { CMP_ORIENT_180, 2, 0, 0 },
424  { CMP_ORIENT_270, 3, 0, 0 },
425  { CMP_MIRROR_X + CMP_ORIENT_0, 0, 1, 0 },
426  { CMP_MIRROR_X + CMP_ORIENT_90, 1, 1, 0 },
427  { CMP_MIRROR_Y, 0, 0, 1 },
428  { CMP_MIRROR_X + CMP_ORIENT_270, 3, 1, 0 },
429  { CMP_MIRROR_Y + CMP_ORIENT_0, 0, 0, 1 },
430  { CMP_MIRROR_Y + CMP_ORIENT_90, 1, 0, 1 },
431  { CMP_MIRROR_Y + CMP_ORIENT_180, 2, 0, 1 },
432  { CMP_MIRROR_Y + CMP_ORIENT_270, 3, 0, 1 }
433  };
434 
435  ORIENT o = orientations[ 0 ];
436 
437  SCH_COMPONENT* comp = aPin->GetParentComponent();
438 
439  if( !comp )
440  return spin;
441 
442  int compOrient = comp->GetOrientation();
443 
444  for( auto& i : orientations )
445  {
446  if( i.flag == compOrient )
447  {
448  o = i;
449  break;
450  }
451  }
452 
453  for( int i = 0; i < o.n_rots; i++ )
454  spin = spin.RotateCCW();
455 
456  if( o.mirror_x )
457  spin = spin.MirrorX();
458 
459  if( o.mirror_y )
460  spin = spin.MirrorY();
461 
462  return spin;
463 }
464 
465 void BACK_ANNOTATE::processNetNameChange( SCH_CONNECTION* aConn, const wxString& aOldName,
466  const wxString& aNewName )
467 {
468  wxString msg;
469  SCH_ITEM* driver = aConn->Driver();
470 
471  auto editMatchingLabels =
472  [this]( SCH_SCREEN* aScreen, KICAD_T aType, const wxString& oldName,
473  const wxString& newName )
474  {
475  for( SCH_ITEM* schItem : aScreen->Items().OfType( aType ) )
476  {
477  SCH_TEXT* label = static_cast<SCH_TEXT*>( schItem );
478 
479  if( EscapeString( label->GetShownText(), CTX_NETNAME ) == oldName )
480  {
482  m_appendUndo = true;
483  static_cast<SCH_TEXT*>( label )->SetText( newName );
484  }
485  }
486  };
487 
488  switch( driver->Type() )
489  {
490  case SCH_LABEL_T:
491  ++m_changesCount;
492  msg.Printf( _( "Change \"%s\" labels to \"%s\"." ), aOldName, aNewName );
493 
494  if( !m_dryRun )
495  {
496  SCH_SHEET_PATH sheet = aConn->Sheet();
497  SCH_SCREEN* screen = sheet.LastScreen();
498 
499  for( SCH_ITEM* label : screen->Items().OfType( SCH_LABEL_T ) )
500  {
501  SCH_CONNECTION* conn = label->Connection( &sheet );
502 
503  if( conn && conn->Driver() == driver )
504  {
506  m_appendUndo = true;
507  static_cast<SCH_TEXT*>( label )->SetText( aNewName );
508  }
509  }
510  }
511 
513  break;
514 
515  case SCH_GLOBAL_LABEL_T:
516  ++m_changesCount;
517  msg.Printf( _( "Change \"%s\" global labels to \"%s\"." ), aOldName, aNewName );
518 
519  if( !m_dryRun )
520  {
521  for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
522  editMatchingLabels( sheet.LastScreen(), SCH_GLOBAL_LABEL_T, aOldName, aNewName );
523  }
524 
526  break;
527 
528  case SCH_HIER_LABEL_T:
529  ++m_changesCount;
530  msg.Printf( _( "Change \"%s\" hierarchical label to \"%s\"." ), aOldName, aNewName );
531 
532  if( !m_dryRun )
533  {
534  SCH_SCREEN* screen = aConn->Sheet().LastScreen();
535  editMatchingLabels( screen, SCH_HIER_LABEL_T, aOldName, aNewName );
536 
537  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( driver->GetParent() );
538  wxASSERT( sheet );
539 
540  if( !sheet )
541  break;
542 
543  screen = sheet->GetScreen();
544 
545  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
546  {
547  if( EscapeString( pin->GetShownText(), CTX_NETNAME ) == aOldName )
548  {
550  m_appendUndo = true;
551  static_cast<SCH_TEXT*>( pin )->SetText( aNewName );
552  }
553  }
554  }
555 
557  break;
558 
559  case SCH_SHEET_PIN_T:
560  ++m_changesCount;
561  msg.Printf( _( "Change \"%s\" hierarchical label to \"%s\"." ), aOldName, aNewName );
562 
563  if( !m_dryRun )
564  {
565  SCH_SCREEN* screen = aConn->Sheet().LastScreen();
567  m_appendUndo = true;
568  static_cast<SCH_TEXT*>( driver )->SetText( aNewName );
569 
570  SCH_SHEET* sheet = static_cast<SCH_SHEET_PIN*>( driver )->GetParent();
571  screen = sheet->GetScreen();
572  editMatchingLabels( screen, SCH_HIER_LABEL_T, aOldName, aNewName );
573  }
574 
576  break;
577 
578  case SCH_PIN_T:
579  {
580  SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
581  LABEL_SPIN_STYLE spin = orientLabel( schPin );
582 
583  if( schPin->IsPowerConnection() )
584  {
585  msg.Printf( _( "Net \"%s\" cannot be changed to \"%s\" because it "
586  "is driven by a power pin." ),
587  aOldName,
588  aNewName );
589 
591  break;
592  }
593 
594  ++m_changesCount;
595  msg.Printf( _( "Add label \"%s\" to net \"%s\"." ), aNewName, aOldName );
596 
597  if( !m_dryRun )
598  {
599  SCHEMATIC_SETTINGS& settings = m_frame->Schematic().Settings();
600  SCH_LABEL* label = new SCH_LABEL( driver->GetPosition(), aNewName );
601  label->SetParent( &m_frame->Schematic() );
602  label->SetTextSize( wxSize( settings.m_DefaultTextSize,
603  settings.m_DefaultTextSize ) );
604  label->SetLabelSpinStyle( spin );
605  label->SetFlags( IS_NEW );
606 
607  SCH_SCREEN* screen = aConn->Sheet().LastScreen();
609  m_appendUndo = true;
610  }
611 
613  }
614  break;
615 
616  default:
617  break;
618  }
619 }
UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to...
Definition: utf8.h:73
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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:120
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:67
static bool sortByTimeStamp(const SCH_REFERENCE &item1, const SCH_REFERENCE &item2)
BACK_ANNOTATE(SCH_EDIT_FRAME *aFrame, REPORTER &aReporter, bool aRelinkFootprints, bool aProcessFootprints, bool aProcessValues, bool aProcessReferences, bool aProcessNetNames, bool aDryRun)
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:61
void UpdateNetHighlightStatus()
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:109
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:91
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:253
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
SCH_EDIT_FRAME * m_frame
Definition: backannotate.h:118
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:125
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Function Scan fills an empty PTREE with information from a KiCad s-expresion stream.
Definition: ptree.cpp:86
void PushNewLinksToPCB()
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:124
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:114
SCH_PIN * GetPin(const wxString &number)
Find a symbol pin by number.
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
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:244
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:50
virtual wxPoint GetPosition() const
Definition: eda_item.h:326
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:287
bool m_matchByReference
Definition: backannotate.h:107
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: eda_item.h:185
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
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 footprints and vice versa.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:147
REPORTER & m_reporter
Definition: backannotate.h:105
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: eda_item.h:221
wxString Name(bool aIgnoreSheet=false) const
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:343
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
Add a SCH_REFERENCE object to aReferences for each component in the list of sheets.
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
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
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: eda_item.h:184
const wxString GetFootprint() const
#define PcbFileExtension
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:85
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:115
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_text.cpp:486
LABEL_SPIN_STYLE MirrorY()
Definition: sch_text.h:128
void getChangeList()
Create changelist
LABEL_SPIN_STYLE RotateCCW()
Definition: sch_text.h:90
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:367
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.
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:437
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
LABEL_SPIN_STYLE MirrorX()
Definition: sch_text.h:109
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()
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
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:77
EE_RTREE & Items()
Definition: sch_screen.h:159
Schematic symbol object.
Definition: sch_component.h:79
These settings were stored in SCH_BASE_FRAME previously.
const wxString GetValue() const
SCH_REFERENCE_LIST m_refs
Definition: backannotate.h:115
bool IsPowerConnection() const
Definition: sch_pin.h:125
std::deque< CHANGELIST_ITEM > m_changelist
Definition: backannotate.h:117
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: eda_item.h:117
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:232
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
STATUS_FLAGS GetFlags() const
Definition: eda_item.h:223
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:127
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
DSNLEXER implements a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:79
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
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:116
KICAD_T Type() const
Function Type()
Definition: eda_item.h:182