KiCad PCB EDA Suite
sch_sheet_path.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <fctsys.h>
27 
28 #include <sch_screen.h>
29 #include <sch_item.h>
30 #include <sch_marker.h>
31 #include <sch_reference_list.h>
32 #include <class_library.h>
33 #include <sch_sheet_path.h>
34 #include <sch_component.h>
35 #include <sch_sheet.h>
36 #include <schematic.h>
37 #include <template_fieldnames.h>
38 #include <trace_helpers.h>
39 
40 #include <boost/functional/hash.hpp>
41 #include <wx/filename.h>
42 #include "erc_item.h"
43 
44 
50 {
51 public:
53  SCH_ITEM( nullptr, NOT_USED )
54  {}
55 
56  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override
57  {
58  return _( "(Deleted Item)" );
59  }
60 
61  wxString GetClass() const override
62  {
63  return wxT( "DELETED_SHEET_ITEM" );
64  }
65 
67  {
68  static DELETED_SHEET_ITEM* item = nullptr;
69 
70  if( !item )
71  item = new DELETED_SHEET_ITEM();
72 
73  return item;
74  }
75 
76  // pure virtuals:
77  void SetPosition( const wxPoint& ) override {}
78  void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override {}
79  void Move( const wxPoint& aMoveVector ) override {}
80  void MirrorY( int aYaxis_position ) override {}
81  void MirrorX( int aXaxis_position ) override {}
82  void Rotate( wxPoint aPosition ) override {}
83 
84 #if defined(DEBUG)
85  void Show( int , std::ostream& ) const override {}
86 #endif
87 };
88 
89 
90 namespace std
91 {
93  {
94  return path.GetCurrentHash();
95  }
96 }
97 
98 
100 {
101  m_pageNumber = 0;
102  m_current_hash = 0;
103 }
104 
105 
107 {
108  initFromOther( aOther );
109 }
110 
111 
113 {
114  initFromOther( aOther );
115  return *this;
116 }
117 
118 
120 {
121  m_sheets = aOther.m_sheets;
122  m_pageNumber = aOther.m_pageNumber;
124 
125  // Note: don't copy m_recursion_test_cache as it is slow and we want SCH_SHEET_PATHS to be
126  // very fast to construct for use in the connectivity algorithm.
127 }
128 
129 
131 {
132  m_current_hash = 0;
133 
134  for( auto sheet : m_sheets )
135  boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() );
136 }
137 
138 
139 int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const
140 {
141  if( size() > aSheetPathToTest.size() )
142  return 1;
143 
144  if( size() < aSheetPathToTest.size() )
145  return -1;
146 
147  //otherwise, same number of sheets.
148  for( unsigned i = 0; i < size(); i++ )
149  {
150  if( at( i )->m_Uuid < aSheetPathToTest.at( i )->m_Uuid )
151  return -1;
152 
153  if( at( i )->m_Uuid != aSheetPathToTest.at( i )->m_Uuid )
154  return 1;
155  }
156 
157  return 0;
158 }
159 
160 
162 {
163  if( !empty() )
164  return m_sheets.back();
165 
166  return nullptr;
167 }
168 
169 
171 {
172  SCH_SHEET* lastSheet = Last();
173 
174  if( lastSheet )
175  return lastSheet->GetScreen();
176 
177  return nullptr;
178 }
179 
180 
182 {
183  SCH_SHEET* lastSheet = Last();
184 
185  if( lastSheet )
186  return lastSheet->GetScreen();
187 
188  return nullptr;
189 }
190 
191 
193 {
194  wxString s;
195 
196  s = wxT( "/" ); // This is the root path
197 
198  // Start at 1 to avoid the root sheet, which does not need to be added to the path.
199  // It's timestamp changes anyway.
200  for( unsigned i = 1; i < size(); i++ )
201  s += at( i )->m_Uuid.AsString() + "/";
202 
203  return s;
204 }
205 
206 
208 {
209  KIID_PATH path;
210 
211  for( const SCH_SHEET* sheet : m_sheets )
212  path.push_back( sheet->m_Uuid );
213 
214  return path;
215 }
216 
217 
218 wxString SCH_SHEET_PATH::GetRootPathName( bool aUseShortName )
219 {
220  // return a PathName for the root sheet (like "/" or "<root>"
221  // DO NOT use it in netlists, because it can easily break these netlists
222  // especially after translation, because many netlists (i.e. spice) do not accept any char
223  // Use only the short name ("/") and the full name only in messages
224  return aUseShortName ? wxT( "/" ) : _( "<root_sheet>" );
225 }
226 
227 
229 {
230  wxString s;
231 
232  if( size() == 1 )
233  return GetRootPathName( true ); // Use only the short name in netlists
234 
235  s = wxT( "/" );
236 
237  // Start at 1 to avoid the root sheet, as above.
238  for( unsigned i = 1; i < size(); i++ )
239  s = s + at( i )->GetFields()[ SHEETNAME ].GetShownText() + wxT( "/" );
240 
241  return s;
242 }
243 
244 
246 {
247  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
248  {
249  auto component = static_cast<SCH_COMPONENT*>( item );
250  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
251  component->GetField( VALUE )->SetText( component->GetValue( this ) );
252  component->GetField( FOOTPRINT )->SetText( component->GetFootprint( this ) );
253  component->UpdateUnit( component->GetUnitSelection( this ) );
254  }
255 }
256 
257 
258 
259 void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
260  bool aForceIncludeOrphanComponents ) const
261 {
262  for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
263  {
264  SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
265 
266  // Skip pseudo components, which have a reference starting with #. This mainly
267  // affects power symbols.
268  if( aIncludePowerSymbols || component->GetRef( this )[0] != wxT( '#' ) )
269  {
270  LIB_PART* part = component->GetPartRef().get();
271 
272  if( part || aForceIncludeOrphanComponents )
273  {
274  SCH_REFERENCE schReference( component, part, *this );
275 
276  schReference.SetSheetNumber( m_pageNumber );
277  aReferences.AddItem( schReference );
278  }
279  }
280  }
281 }
282 
283 
285  bool aIncludePowerSymbols ) const
286 {
287  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
288  {
289  auto component = static_cast<SCH_COMPONENT*>( item );
290 
291  // Skip pseudo components, which have a reference starting with #. This mainly
292  // affects power symbols.
293  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
294  continue;
295 
296  LIB_PART* part = component->GetPartRef().get();
297 
298  if( part && part->GetUnitCount() > 1 )
299  {
300  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
301  schReference.SetSheetNumber( m_pageNumber );
302  wxString reference_str = schReference.GetRef();
303 
304  // Never lock unassigned references
305  if( reference_str[reference_str.Len() - 1] == '?' )
306  continue;
307 
308  aRefList[reference_str].AddItem( schReference );
309  }
310  }
311 }
312 
313 
315 {
316  return m_current_hash == d1.GetCurrentHash();
317 }
318 
319 
320 bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName )
321 {
322  auto pair = std::make_pair( aSrcFileName, aDestFileName );
323 
324  if( m_recursion_test_cache.count( pair ) )
325  return m_recursion_test_cache.at( pair );
326 
327  SCHEMATIC* sch = LastScreen()->Schematic();
328 
329  wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_PATH::TestForRecursion!" );
330 
331  wxFileName rootFn = sch->GetFileName();
332  wxFileName srcFn = aSrcFileName;
333  wxFileName destFn = aDestFileName;
334 
335  if( srcFn.IsRelative() )
336  srcFn.MakeAbsolute( rootFn.GetPath() );
337 
338  if( destFn.IsRelative() )
339  destFn.MakeAbsolute( rootFn.GetPath() );
340 
341 
342  // The source and destination sheet file names cannot be the same.
343  if( srcFn == destFn )
344  {
345  m_recursion_test_cache[pair] = true;
346  return true;
347  }
348 
352  unsigned i = 0;
353 
354  while( i < size() )
355  {
356  wxFileName cmpFn = at( i )->GetFileName();
357 
358  if( cmpFn.IsRelative() )
359  cmpFn.MakeAbsolute( rootFn.GetPath() );
360 
361  // Test if the file name of the destination sheet is in anywhere in this sheet path.
362  if( cmpFn == destFn )
363  break;
364 
365  i++;
366  }
367 
368  // The destination sheet file name was not found in the sheet path or the destination
369  // sheet file name is the root sheet so no recursion is possible.
370  if( i >= size() || i == 0 )
371  {
372  m_recursion_test_cache[pair] = false;
373  return false;
374  }
375 
376  // Walk back up to the root sheet to see if the source file name is already a parent in
377  // the sheet path. If so, recursion will occur.
378  do
379  {
380  i -= 1;
381 
382  wxFileName cmpFn = at( i )->GetFileName();
383 
384  if( cmpFn.IsRelative() )
385  cmpFn.MakeAbsolute( rootFn.GetPath() );
386 
387  if( cmpFn == srcFn )
388  {
389  m_recursion_test_cache[pair] = true;
390  return true;
391  }
392 
393  } while( i != 0 );
394 
395  // The source sheet file name is not a parent of the destination sheet file name.
396  m_recursion_test_cache[pair] = false;
397  return false;
398 }
399 
400 
402 {
403  if( aSheet != NULL )
404  BuildSheetList( aSheet );
405 }
406 
407 
409 {
410  wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
411 
412  std::vector<SCH_SHEET*> badSheets;
413 
414  m_currentSheetPath.push_back( aSheet );
415 
421  m_currentSheetPath.SetPageNumber( size() + 1 );
422  push_back( m_currentSheetPath );
423 
425  {
426  std::vector<SCH_ITEM*> childSheets;
427  m_currentSheetPath.LastScreen()->GetSheets( &childSheets );
428 
429  for( SCH_ITEM* item : childSheets )
430  {
431  auto sheet = static_cast<SCH_SHEET*>( item );
432 
434  sheet->GetFileName(), aSheet->GetFileName() ) )
435  BuildSheetList( sheet );
436  else
437  badSheets.push_back( sheet );
438  }
439  }
440 
441  for( auto sheet : badSheets )
442  {
445  }
446 
448 }
449 
450 
451 bool SCH_SHEET_LIST::NameExists( const wxString& aSheetName )
452 {
453  for( const SCH_SHEET_PATH& sheet : *this )
454  {
455  if( sheet.Last()->GetName() == aSheetName )
456  return true;
457  }
458 
459  return false;
460 }
461 
462 
464 {
465  for( const SCH_SHEET_PATH& sheet : *this )
466  {
467  if( sheet.LastScreen() && sheet.LastScreen()->IsModify() )
468  return true;
469  }
470 
471  return false;
472 }
473 
474 
476 {
477  for( const SCH_SHEET_PATH& sheet : *this )
478  {
479  if( sheet.LastScreen() )
480  sheet.LastScreen()->ClrModify();
481  }
482 }
483 
484 
486 {
487  for( const SCH_SHEET_PATH& sheet : *this )
488  {
489  SCH_SCREEN* screen = sheet.LastScreen();
490 
491  for( SCH_ITEM* aItem : screen->Items() )
492  {
493  if( aItem->m_Uuid == aID )
494  {
495  if( aPathOut )
496  *aPathOut = sheet;
497 
498  return aItem;
499  }
500  else if( aItem->Type() == SCH_COMPONENT_T )
501  {
502  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( aItem );
503 
504  for( SCH_FIELD& field : comp->GetFields() )
505  {
506  if( field.m_Uuid == aID )
507  {
508  if( aPathOut )
509  *aPathOut = sheet;
510 
511  return &field;
512  }
513  }
514 
515  for( SCH_PIN* pin : comp->GetPins() )
516  {
517  if( pin->m_Uuid == aID )
518  {
519  if( aPathOut )
520  *aPathOut = sheet;
521 
522  return pin;
523  }
524  }
525  }
526  else if( aItem->Type() == SCH_SHEET_T )
527  {
528  SCH_SHEET* sch_sheet = static_cast<SCH_SHEET*>( aItem );
529 
530  for( SCH_FIELD& field : sch_sheet->GetFields() )
531  {
532  if( field.m_Uuid == aID )
533  {
534  if( aPathOut )
535  *aPathOut = sheet;
536  return &field;
537  }
538  }
539 
540  for( SCH_SHEET_PIN* pin : sch_sheet->GetPins() )
541  {
542  if( pin->m_Uuid == aID )
543  {
544  if( aPathOut )
545  *aPathOut = sheet;
546 
547  return pin;
548  }
549  }
550  }
551  }
552  }
553 
554  // Not found; weak reference has been deleted.
556 }
557 
558 
559 void SCH_SHEET_LIST::FillItemMap( std::map<KIID, EDA_ITEM*>& aMap )
560 {
561  for( const SCH_SHEET_PATH& sheet : *this )
562  {
563  SCH_SCREEN* screen = sheet.LastScreen();
564 
565  for( SCH_ITEM* aItem : screen->Items() )
566  {
567  aMap[ aItem->m_Uuid ] = aItem;
568 
569  if( aItem->Type() == SCH_COMPONENT_T )
570  {
571  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( aItem );
572 
573  for( SCH_FIELD& field : comp->GetFields() )
574  aMap[ field.m_Uuid ] = &field;
575 
576  for( SCH_PIN* pin : comp->GetPins() )
577  aMap[ pin->m_Uuid ] = pin;
578  }
579  else if( aItem->Type() == SCH_SHEET_T )
580  {
581  SCH_SHEET* sch_sheet = static_cast<SCH_SHEET*>( aItem );
582 
583  for( SCH_FIELD& field : sch_sheet->GetFields() )
584  aMap[ field.m_Uuid ] = &field;
585 
586  for( SCH_SHEET_PIN* pin : sch_sheet->GetPins() )
587  aMap[ pin->m_Uuid ] = pin;
588  }
589  }
590  }
591 }
592 
593 
595 {
596  // List of reference for power symbols
597  SCH_REFERENCE_LIST references;
598 
599  // Map of locked components (not used, but needed by Annotate()
600  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
601 
602  // Build the list of power components:
603  for( SCH_SHEET_PATH& sheet : *this )
604  {
605  for( auto item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
606  {
607  auto component = static_cast<SCH_COMPONENT*>( item );
608  LIB_PART* part = component->GetPartRef().get();
609 
610  if( !part || !part->IsPower() )
611  continue;
612 
613  if( part )
614  {
615  SCH_REFERENCE schReference( component, part, sheet );
616  references.AddItem( schReference );
617  }
618  }
619  }
620 
621  // Find duplicate, and silently clear annotation of duplicate
622  std::map<wxString, int> ref_list; // stores the existing references
623 
624  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
625  {
626  wxString curr_ref = references[ii].GetRef();
627 
628  if( ref_list.find( curr_ref ) == ref_list.end() )
629  {
630  ref_list[curr_ref] = ii;
631  continue;
632  }
633 
634  // Possible duplicate, if the ref ends by a number:
635  if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
636  continue; // not annotated
637 
638  // Duplicate: clear annotation by removing the number ending the ref
639  while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
640  curr_ref.RemoveLast();
641 
642  references[ii].SetRef( curr_ref );
643  }
644 
645 
646  // Break full components reference in name (prefix) and number:
647  // example: IC1 become IC, and 1
648  references.SplitReferences();
649 
650  // Ensure all power symbols have the reference starting by '#'
651  // (No sure this is really useful)
652  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
653  {
654  if( references[ii].GetRef()[0] != '#' )
655  {
656  wxString new_ref = "#" + references[ii].GetRef();
657  references[ii].SetRef( new_ref );
658  }
659  }
660 
661  // Recalculate and update reference numbers in schematic
662  references.Annotate( false, 0, 100, lockedComponents );
663  references.UpdateAnnotation();
664 }
665 
666 
667 void SCH_SHEET_LIST::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
668  bool aForceIncludeOrphanComponents ) const
669 {
670  for( const SCH_SHEET_PATH& sheet : *this )
671  sheet.GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents );
672 }
673 
674 
676  bool aIncludePowerSymbols ) const
677 {
678  for( SCH_SHEET_PATHS::const_iterator it = begin(); it != end(); ++it )
679  {
681  (*it).GetMultiUnitComponents( tempMap );
682 
683  for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
684  {
685  // Merge this list into the main one
686  unsigned n_refs = pair.second.GetCount();
687 
688  for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
689  {
690  aRefList[pair.first].AddItem( pair.second[thisRef] );
691  }
692  }
693  }
694 }
695 
696 
697 bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
698  const wxString& aDestFileName )
699 {
700  if( empty() )
701  return false;
702 
703  SCHEMATIC* sch = at( 0 ).LastScreen()->Schematic();
704 
705  wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_LIST::TestForRecursion!" );
706 
707  wxFileName rootFn = sch->GetFileName();
708  wxFileName destFn = aDestFileName;
709 
710  if( destFn.IsRelative() )
711  destFn.MakeAbsolute( rootFn.GetPath() );
712 
713  // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
714  for( unsigned i = 0; i < size(); i++ )
715  {
716  // Test each SCH_SHEET_PATH in the source sheet.
717  for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
718  {
719  const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
720 
721  for( unsigned k = 0; k < sheetPath->size(); k++ )
722  {
723  if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
724  aDestFileName ) )
725  return true;
726  }
727  }
728  }
729 
730  // The source sheet file can safely be added to the destination sheet file.
731  return false;
732 }
733 
734 
736 {
737  for( SCH_SHEET_PATH& sheetpath : *this )
738  {
739  if( sheetpath.LastScreen() == aScreen )
740  return &sheetpath;
741  }
742 
743  return nullptr;
744 }
745 
746 
748  const std::vector<COMPONENT_INSTANCE_REFERENCE>& aSymbolInstances )
749 {
750  SCH_REFERENCE_LIST symbolInstances;
751 
752  GetComponents( symbolInstances, true, true );
753 
754  std::map<KIID_PATH, wxString> pathNameCache;
755 
756  // Calculating the name of a path is somewhat expensive; on large designs with many components
757  // this can blow up to a serious amount of time when loading the schematic
758  auto getName = [&pathNameCache]( const KIID_PATH& aPath ) -> const wxString&
759  {
760  if( pathNameCache.count( aPath ) )
761  return pathNameCache.at( aPath );
762 
763  pathNameCache[aPath] = aPath.AsString();
764  return pathNameCache[aPath];
765  };
766 
767  for( size_t i = 0; i < symbolInstances.GetCount(); i++ )
768  {
769  // The instance paths are stored in the file sans root path so the comparison
770  // should not include the root path.
771  wxString path = symbolInstances[i].GetPath();
772 
773  auto it = std::find_if( aSymbolInstances.begin(), aSymbolInstances.end(),
774  [ path, &getName ]( const COMPONENT_INSTANCE_REFERENCE& r ) -> bool
775  {
776  return path == getName( r.m_Path );
777  } );
778 
779  if( it == aSymbolInstances.end() )
780  {
781  wxLogTrace( traceSchSheetPaths, "No symbol instance found for path \"%s\"", path );
782  continue;
783  }
784 
785  SCH_COMPONENT* symbol = symbolInstances[i].GetComp();
786 
787  wxCHECK2( symbol, continue );
788 
789  // Symbol instance paths are stored and looked up in memory with the root path so use
790  // the full path here.
791  symbol->AddHierarchicalReference( symbolInstances[i].GetSheetPath().Path(),
792  it->m_Reference, it->m_Unit, it->m_Value,
793  it->m_Footprint );
794  symbol->GetField( REFERENCE )->SetText( it->m_Reference );
795  }
796 }
797 
798 
799 std::vector<KIID_PATH> SCH_SHEET_LIST::GetPaths() const
800 {
801  std::vector<KIID_PATH> paths;
802 
803  for( const SCH_SHEET_PATH& sheetPath : *this )
804  paths.emplace_back( sheetPath.Path() );
805 
806  return paths;
807 }
808 
809 
810 void SCH_SHEET_LIST::ReplaceLegacySheetPaths( const std::vector<KIID_PATH>& aOldSheetPaths )
811 {
812  wxCHECK( size() == aOldSheetPaths.size(), /* void */ );
813 
814  for( size_t i = 0; i < size(); i++ )
815  {
816  const KIID_PATH oldSheetPath = aOldSheetPaths.at( i );
817  const KIID_PATH newSheetPath = at( i ).Path();
818  SCH_SCREEN* screen = at(i).LastScreen();
819 
820  wxCHECK( screen, /* void */ );
821 
822  for( SCH_ITEM* symbol : screen->Items().OfType( SCH_COMPONENT_T ) )
823  {
824  static_cast<SCH_COMPONENT*>( symbol )->ReplaceInstanceSheetPath( oldSheetPath,
825  newSheetPath );
826  }
827  }
828 }
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
EDA_UNITS
Definition: common.h:198
void SetSheetNumber(int aSheetNumber)
SCH_SHEET_LIST.
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
void UpdateSymbolInstances(const std::vector< COMPONENT_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
bool IsModified()
Function IsModified checks the entire hierarchy for any modifications.
void initFromOther(const SCH_SHEET_PATH &aOther)
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:243
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 sheet.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr)
Fetch a SCH_ITEM by ID.
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
bool operator==(const SCH_SHEET_PATH &d1) const
void SetPageNumber(int aPageNumber)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
the 3d code uses this value
Definition: typeinfo.h:80
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void AddItem(SCH_REFERENCE &aItem)
Function AddItem adds a SCH_REFERENCE object to the list of references.
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
void GetSheets(std::vector< SCH_ITEM * > *aItems)
Similar to GetItems().OfType( SCH_SHEET_T ), but return the sheets in a deterministic order (L-R,...
Definition: sch_screen.cpp:962
wxString AsString() const
Definition: common.cpp:165
Template specialization to enable wxStrings for certain containers (e.g. unordered_map)
Definition: bitmap.cpp:56
std::map< std::pair< wxString, wxString >, bool > m_recursion_test_cache
Page numbers are maintained by the sheet load order.
wxString PathAsString() const
Function PathAsString the path uses the time stamps which do not changes even when editing sheet para...
A singleton item of this class is returned for a weak reference that no longer exists.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:118
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
wxString GetClass() const override
Function GetClass returns the class name.
SCH_SHEET_PATH * FindSheetForScreen(SCH_SCREEN *aScreen)
Function FindSheetForScreen.
Field Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
SCH_SHEET_LIST(SCH_SHEET *aSheet=NULL)
Constructor build a flattened list of SCH_SHEET_PATH objects from aSheet.
static void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
Definition: hash_eda.h:64
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 ...
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,...
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
void pop_back()
Forwarded method from std::vector.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
wxString GetRef() const
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
Definition: common.h:68
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Function TestForRecursion.
void UpdateAnnotation()
function UpdateAnnotation Updates the reference components for the schematic project (or the current ...
static wxString GetRootPathName(bool aUseShortName=true)
SCH_SHEET_PATH & operator=(const SCH_SHEET_PATH &aOther)
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
wxString GetName() const
Definition: sch_sheet.h:280
#define NULL
int GetUnitCount() const override
For items with units, return the number of units.
size_t size() const
Forwarded method from std::vector.
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...
SCH_SHEET_PATH m_currentSheetPath
A simple container for schematic symbol instance infromation.
std::vector< SCH_SHEET * > m_sheets
size_t operator()(const SCH_SHEET_PATH &path) const
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Define a library symbol object.
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap)
Function Annotate set the reference designators in the list that have not been annotated.
wxLogTrace helper definitions.
void SetPosition(const wxPoint &) override
bool IsModify() const
Definition: base_screen.h:104
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
SCH_SHEET_PATH.
std::unique_ptr< LIB_PART > & GetPartRef()
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:496
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
void MirrorX(int aXaxis_position) override
Mirror item relative to the X axis about aXaxis_position.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Type SCH_MULTI_UNIT_REFERENCE_MAP is used to create a map of reference designators for multi-unit par...
bool NameExists(const wxString &aSheetName)
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
void MirrorY(int aYaxis_position) override
Mirror item relative to the Y axis about aYaxis_position.
const KIID m_Uuid
Definition: base_struct.h:162
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:362
unsigned GetCount() const
Function GetCount.
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
Field Value of part, i.e. "3.3K".
const SCH_SHEET * GetSheet(unsigned aIndex) const
bool IsPower() const
SCH_SCREEN * LastScreen()
Function LastScreen.
static DELETED_SHEET_ITEM * GetInstance()
void SplitReferences()
Function SplitReferences attempts to split all reference designators into a name (U) and number (1).
#define _(s)
Definition: 3d_actions.cpp:33
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:91
size_t GetCurrentHash() const
EE_RTREE & Items()
Definition: sch_screen.h:158
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
std::vector< KIID_PATH > GetPaths() const
void ReplaceLegacySheetPaths(const std::vector< KIID_PATH > &aOldSheetPaths)
Update all of the symbol sheet paths to the sheet paths defined in aOldSheetPaths.
void ClrModify()
Definition: base_screen.h:101
Schematic symbol object.
Definition: sch_component.h:80
static bool empty(const wxTextEntryBase *aCtrl)
bool empty() const
Forwarded method from std::vector.
void AnnotatePowerSymbols()
Function AnnotatePowerSymbols Silently annotates the not yet annotated power symbols of the entire hi...
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit, const wxString &aValue=wxEmptyString, const wxString &aFootprint=wxEmptyString)
Add a full hierarchical reference to this symbol.
Definition for part library class.
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
void SetModify()
Definition: base_screen.h:100
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
bool TestForRecursion(const wxString &aSrcFileName, const wxString &aDestFileName)
Function TestForRecursion.
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Function Cmp Compare if this is the same sheet path as aSheetPathToTest.
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.