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 
66  // pure virtuals:
67  void SetPosition( const wxPoint& ) override {}
68  void Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset ) override {}
69  void Move( const wxPoint& aMoveVector ) override {}
70  void MirrorY( int aYaxis_position ) override {}
71  void MirrorX( int aXaxis_position ) override {}
72  void Rotate( wxPoint aPosition ) override {}
73 
74 #if defined(DEBUG)
75  void Show( int , std::ostream& ) const override {}
76 #endif
77 };
78 
80 
81 
82 namespace std
83 {
85  {
86  return path.GetCurrentHash();
87  }
88 }
89 
90 
92 {
93  m_pageNumber = 0;
94  m_current_hash = 0;
95 }
96 
97 
99 {
100  m_current_hash = 0;
101 
102  for( auto sheet : m_sheets )
103  boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() );
104 }
105 
106 
107 int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const
108 {
109  if( size() > aSheetPathToTest.size() )
110  return 1;
111 
112  if( size() < aSheetPathToTest.size() )
113  return -1;
114 
115  //otherwise, same number of sheets.
116  for( unsigned i = 0; i < size(); i++ )
117  {
118  if( at( i )->m_Uuid < aSheetPathToTest.at( i )->m_Uuid )
119  return -1;
120 
121  if( at( i )->m_Uuid != aSheetPathToTest.at( i )->m_Uuid )
122  return 1;
123  }
124 
125  return 0;
126 }
127 
128 
130 {
131  if( !empty() )
132  return m_sheets.back();
133 
134  return nullptr;
135 }
136 
137 
139 {
140  SCH_SHEET* lastSheet = Last();
141 
142  if( lastSheet )
143  return lastSheet->GetScreen();
144 
145  return nullptr;
146 }
147 
148 
150 {
151  SCH_SHEET* lastSheet = Last();
152 
153  if( lastSheet )
154  return lastSheet->GetScreen();
155 
156  return nullptr;
157 }
158 
159 
161 {
162  wxString s;
163 
164  s = wxT( "/" ); // This is the root path
165 
166  // Start at 1 to avoid the root sheet, which does not need to be added to the path.
167  // It's timestamp changes anyway.
168  for( unsigned i = 1; i < size(); i++ )
169  s += at( i )->m_Uuid.AsString() + "/";
170 
171  return s;
172 }
173 
174 
176 {
177  KIID_PATH path;
178 
179  for( const SCH_SHEET* sheet : m_sheets )
180  path.push_back( sheet->m_Uuid );
181 
182  return path;
183 }
184 
185 
186 wxString SCH_SHEET_PATH::GetRootPathName( bool aUseShortName )
187 {
188  // return a PathName for the root sheet (like "/" or "<root>"
189  // DO NOT use it in netlists, because it can easily break these netlists
190  // especially after translation, because many netlists (i.e. spice) do not accept any char
191  // Use only the short name ("/") and the full name only in messages
192  return aUseShortName ? wxT( "/" ) : _( "<root_sheet>" );
193 }
194 
195 
197 {
198  wxString s;
199 
200  if( size() == 1 )
201  return GetRootPathName( true ); // Use only the short name in netlists
202 
203  s = wxT( "/" );
204 
205  // Start at 1 to avoid the root sheet, as above.
206  for( unsigned i = 1; i < size(); i++ )
207  s = s + at( i )->GetFields()[ SHEETNAME ].GetShownText() + wxT( "/" );
208 
209  return s;
210 }
211 
212 
214 {
215  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
216  {
217  auto component = static_cast<SCH_COMPONENT*>( item );
218  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
219  component->UpdateUnit( component->GetUnitSelection( this ) );
220  }
221 }
222 
223 
224 
225 void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
226  bool aForceIncludeOrphanComponents ) const
227 {
228  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
229  {
230  auto component = static_cast<SCH_COMPONENT*>( item );
231 
232  // Skip pseudo components, which have a reference starting with #. This mainly
233  // affects power symbols.
234  if( aIncludePowerSymbols || component->GetRef( this )[0] != wxT( '#' ) )
235  {
236  LIB_PART* part = component->GetPartRef().get();
237 
238  if( part || aForceIncludeOrphanComponents )
239  {
240  SCH_REFERENCE schReference( component, part, *this );
241 
242  schReference.SetSheetNumber( m_pageNumber );
243  aReferences.AddItem( schReference );
244  }
245  }
246  }
247 }
248 
249 
251  bool aIncludePowerSymbols ) const
252 {
253  for( auto item : LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
254  {
255  auto component = static_cast<SCH_COMPONENT*>( item );
256 
257  // Skip pseudo components, which have a reference starting with #. This mainly
258  // affects power symbols.
259  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
260  continue;
261 
262  LIB_PART* part = component->GetPartRef().get();
263 
264  if( part && part->GetUnitCount() > 1 )
265  {
266  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
267  schReference.SetSheetNumber( m_pageNumber );
268  wxString reference_str = schReference.GetRef();
269 
270  // Never lock unassigned references
271  if( reference_str[reference_str.Len() - 1] == '?' )
272  continue;
273 
274  aRefList[reference_str].AddItem( schReference );
275  }
276  }
277 }
278 
279 
280 bool SCH_SHEET_PATH::SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
281  bool aSetVisible )
282 {
283  SCH_SCREEN* screen = LastScreen();
284 
285  if( screen == NULL )
286  return false;
287 
288  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
289 }
290 
291 
293 {
294  return m_current_hash == d1.GetCurrentHash();
295 }
296 
297 
298 bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName )
299 {
300  auto pair = std::make_pair( aSrcFileName, aDestFileName );
301 
302  if( m_recursion_test_cache.count( pair ) )
303  return m_recursion_test_cache.at( pair );
304 
305  SCHEMATIC* sch = LastScreen()->Schematic();
306 
307  wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_PATH::TestForRecursion!" );
308 
309  wxFileName rootFn = sch->GetFileName();
310  wxFileName srcFn = aSrcFileName;
311  wxFileName destFn = aDestFileName;
312 
313  if( srcFn.IsRelative() )
314  srcFn.MakeAbsolute( rootFn.GetPath() );
315 
316  if( destFn.IsRelative() )
317  destFn.MakeAbsolute( rootFn.GetPath() );
318 
319 
320  // The source and destination sheet file names cannot be the same.
321  if( srcFn == destFn )
322  {
323  m_recursion_test_cache[pair] = true;
324  return true;
325  }
326 
330  unsigned i = 0;
331 
332  while( i < size() )
333  {
334  wxFileName cmpFn = at( i )->GetFileName();
335 
336  if( cmpFn.IsRelative() )
337  cmpFn.MakeAbsolute( rootFn.GetPath() );
338 
339  // Test if the file name of the destination sheet is in anywhere in this sheet path.
340  if( cmpFn == destFn )
341  break;
342 
343  i++;
344  }
345 
346  // The destination sheet file name was not found in the sheet path or the destination
347  // sheet file name is the root sheet so no recursion is possible.
348  if( i >= size() || i == 0 )
349  {
350  m_recursion_test_cache[pair] = false;
351  return false;
352  }
353 
354  // Walk back up to the root sheet to see if the source file name is already a parent in
355  // the sheet path. If so, recursion will occur.
356  do
357  {
358  i -= 1;
359 
360  wxFileName cmpFn = at( i )->GetFileName();
361 
362  if( cmpFn.IsRelative() )
363  cmpFn.MakeAbsolute( rootFn.GetPath() );
364 
365  if( cmpFn == srcFn )
366  {
367  m_recursion_test_cache[pair] = true;
368  return true;
369  }
370 
371  } while( i != 0 );
372 
373  // The source sheet file name is not a parent of the destination sheet file name.
374  m_recursion_test_cache[pair] = false;
375  return false;
376 }
377 
378 
380 {
381  if( aSheet != NULL )
382  BuildSheetList( aSheet );
383 }
384 
385 
387 {
388  wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
389 
390  std::vector<SCH_SHEET*> badSheets;
391 
392  m_currentSheetPath.push_back( aSheet );
393 
399  m_currentSheetPath.SetPageNumber( size() + 1 );
400  push_back( m_currentSheetPath );
401 
403  {
404  std::vector<SCH_ITEM*> childSheets;
405  m_currentSheetPath.LastScreen()->GetSheets( &childSheets );
406 
407  for( SCH_ITEM* item : childSheets )
408  {
409  auto sheet = static_cast<SCH_SHEET*>( item );
410 
412  sheet->GetFileName(), aSheet->GetFileName() ) )
413  BuildSheetList( sheet );
414  else
415  badSheets.push_back( sheet );
416  }
417  }
418 
419  for( auto sheet : badSheets )
420  {
423  }
424 
426 }
427 
428 
429 bool SCH_SHEET_LIST::NameExists( const wxString& aSheetName )
430 {
431  for( const SCH_SHEET_PATH& sheet : *this )
432  {
433  if( sheet.Last()->GetName() == aSheetName )
434  return true;
435  }
436 
437  return false;
438 }
439 
440 
442 {
443  for( const SCH_SHEET_PATH& sheet : *this )
444  {
445  if( sheet.LastScreen() && sheet.LastScreen()->IsModify() )
446  return true;
447  }
448 
449  return false;
450 }
451 
452 
454 {
455  for( const SCH_SHEET_PATH& sheet : *this )
456  {
457  if( sheet.LastScreen() )
458  sheet.LastScreen()->ClrModify();
459  }
460 }
461 
462 
464 {
465  for( const SCH_SHEET_PATH& sheet : *this )
466  {
467  SCH_SCREEN* screen = sheet.LastScreen();
468 
469  for( SCH_ITEM* aItem : screen->Items() )
470  {
471  if( aItem->m_Uuid == aID )
472  {
473  if( aPathOut )
474  *aPathOut = sheet;
475 
476  return aItem;
477  }
478  else if( aItem->Type() == SCH_COMPONENT_T )
479  {
480  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( aItem );
481 
482  for( SCH_FIELD& field : comp->GetFields() )
483  {
484  if( field.m_Uuid == aID )
485  {
486  if( aPathOut )
487  *aPathOut = sheet;
488 
489  return &field;
490  }
491  }
492 
493  for( SCH_PIN* pin : comp->GetSchPins() )
494  {
495  if( pin->m_Uuid == aID )
496  {
497  if( aPathOut )
498  *aPathOut = sheet;
499 
500  return pin;
501  }
502  }
503  }
504  else if( aItem->Type() == SCH_SHEET_T )
505  {
506  SCH_SHEET* sch_sheet = static_cast<SCH_SHEET*>( aItem );
507 
508  for( SCH_FIELD& field : sch_sheet->GetFields() )
509  {
510  if( field.m_Uuid == aID )
511  {
512  if( aPathOut )
513  *aPathOut = sheet;
514  return &field;
515  }
516  }
517 
518  for( SCH_SHEET_PIN* pin : sch_sheet->GetPins() )
519  {
520  if( pin->m_Uuid == aID )
521  {
522  if( aPathOut )
523  *aPathOut = sheet;
524 
525  return pin;
526  }
527  }
528  }
529  }
530  }
531 
532  // Not found; weak reference has been deleted.
533  if( !g_DeletedItem )
535 
536  return g_DeletedItem;
537 }
538 
539 
540 void SCH_SHEET_LIST::FillItemMap( std::map<KIID, EDA_ITEM*>& aMap )
541 {
542  for( const SCH_SHEET_PATH& sheet : *this )
543  {
544  SCH_SCREEN* screen = sheet.LastScreen();
545 
546  for( SCH_ITEM* aItem : screen->Items() )
547  {
548  aMap[ aItem->m_Uuid ] = aItem;
549 
550  if( aItem->Type() == SCH_COMPONENT_T )
551  {
552  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( aItem );
553 
554  for( SCH_FIELD& field : comp->GetFields() )
555  aMap[ field.m_Uuid ] = &field;
556 
557  for( SCH_PIN* pin : comp->GetSchPins() )
558  aMap[ pin->m_Uuid ] = pin;
559  }
560  else if( aItem->Type() == SCH_SHEET_T )
561  {
562  SCH_SHEET* sch_sheet = static_cast<SCH_SHEET*>( aItem );
563 
564  for( SCH_FIELD& field : sch_sheet->GetFields() )
565  aMap[ field.m_Uuid ] = &field;
566 
567  for( SCH_SHEET_PIN* pin : sch_sheet->GetPins() )
568  aMap[ pin->m_Uuid ] = pin;
569  }
570  }
571  }
572 }
573 
574 
576 {
577  // List of reference for power symbols
578  SCH_REFERENCE_LIST references;
579 
580  // Map of locked components (not used, but needed by Annotate()
581  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
582 
583  // Build the list of power components:
584  for( SCH_SHEET_PATH& sheet : *this )
585  {
586  for( auto item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
587  {
588  auto component = static_cast<SCH_COMPONENT*>( item );
589  LIB_PART* part = component->GetPartRef().get();
590 
591  if( !part || !part->IsPower() )
592  continue;
593 
594  if( part )
595  {
596  SCH_REFERENCE schReference( component, part, sheet );
597  references.AddItem( schReference );
598  }
599  }
600  }
601 
602  // Find duplicate, and silently clear annotation of duplicate
603  std::map<wxString, int> ref_list; // stores the existing references
604 
605  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
606  {
607  wxString curr_ref = references[ii].GetRef();
608 
609  if( ref_list.find( curr_ref ) == ref_list.end() )
610  {
611  ref_list[curr_ref] = ii;
612  continue;
613  }
614 
615  // Possible duplicate, if the ref ends by a number:
616  if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
617  continue; // not annotated
618 
619  // Duplicate: clear annotation by removing the number ending the ref
620  while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
621  curr_ref.RemoveLast();
622 
623  references[ii].SetRef( curr_ref );
624  }
625 
626 
627  // Break full components reference in name (prefix) and number:
628  // example: IC1 become IC, and 1
629  references.SplitReferences();
630 
631  // Ensure all power symbols have the reference starting by '#'
632  // (No sure this is really useful)
633  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
634  {
635  if( references[ii].GetRef()[0] != '#' )
636  {
637  wxString new_ref = "#" + references[ii].GetRef();
638  references[ii].SetRef( new_ref );
639  }
640  }
641 
642  // Recalculate and update reference numbers in schematic
643  references.Annotate( false, 0, 100, lockedComponents );
644  references.UpdateAnnotation();
645 }
646 
647 
648 void SCH_SHEET_LIST::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
649  bool aForceIncludeOrphanComponents ) const
650 {
651  for( const SCH_SHEET_PATH& sheet : *this )
652  sheet.GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents );
653 }
654 
655 
657  bool aIncludePowerSymbols ) const
658 {
659  for( SCH_SHEET_PATHS::const_iterator it = begin(); it != end(); ++it )
660  {
662  (*it).GetMultiUnitComponents( tempMap );
663 
664  for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
665  {
666  // Merge this list into the main one
667  unsigned n_refs = pair.second.GetCount();
668 
669  for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
670  {
671  aRefList[pair.first].AddItem( pair.second[thisRef] );
672  }
673  }
674  }
675 }
676 
677 
678 bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference,
679  const wxString& aFootPrint, bool aSetVisible )
680 {
681  bool found = false;
682 
683  for( SCH_SHEET_PATH& sheet : *this )
684  found = sheet.SetComponentFootprint( aReference, aFootPrint, aSetVisible );
685 
686  return found;
687 }
688 
689 
690 bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
691  const wxString& aDestFileName )
692 {
693  if( empty() )
694  return false;
695 
696  SCHEMATIC* sch = at( 0 ).LastScreen()->Schematic();
697 
698  wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_LIST::TestForRecursion!" );
699 
700  wxFileName rootFn = sch->GetFileName();
701  wxFileName destFn = aDestFileName;
702 
703  if( destFn.IsRelative() )
704  destFn.MakeAbsolute( rootFn.GetPath() );
705 
706  // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
707  for( unsigned i = 0; i < size(); i++ )
708  {
709  // Test each SCH_SHEET_PATH in the source sheet.
710  for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
711  {
712  const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
713 
714  for( unsigned k = 0; k < sheetPath->size(); k++ )
715  {
716  if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
717  aDestFileName ) )
718  return true;
719  }
720  }
721  }
722 
723  // The source sheet file can safely be added to the destination sheet file.
724  return false;
725 }
726 
727 
729 {
730  for( SCH_SHEET_PATH& sheetpath : *this )
731  {
732  if( sheetpath.LastScreen() == aScreen )
733  return &sheetpath;
734  }
735 
736  return nullptr;
737 }
738 
739 
741  const std::vector<COMPONENT_INSTANCE_REFERENCE>& aSymbolInstances )
742 {
743  SCH_REFERENCE_LIST symbolInstances;
744 
745  GetComponents( symbolInstances, true, true );
746 
747  for( size_t i = 0; i < symbolInstances.GetCount(); i++ )
748  {
749  // The instance paths are stored in the file sans root path so the comparison
750  // should not include the root path.
751  wxString path = symbolInstances[i].GetPath();
752 
753  auto it = std::find_if( aSymbolInstances.begin(), aSymbolInstances.end(),
754  [ path ]( const COMPONENT_INSTANCE_REFERENCE& r ) -> bool
755  {
756  return path == r.m_Path.AsString();
757  }
758  );
759 
760  if( it == aSymbolInstances.end() )
761  {
762  wxLogTrace( traceSchSheetPaths, "No symbol instance found for path \"%s\"", path );
763  continue;
764  }
765 
766  SCH_COMPONENT* symbol = symbolInstances[i].GetComp();
767 
768  wxCHECK2( symbol, continue );
769 
770  // Symbol instance paths are stored and looked up in memory with the root path so use
771  // the full path here.
772  symbol->AddHierarchicalReference( symbolInstances[i].GetSheetPath().Path(),
773  it->m_Reference, it->m_Unit );
774  symbol->GetField( REFERENCE )->SetText( it->m_Reference );
775  }
776 }
777 
778 
779 std::vector<KIID_PATH> SCH_SHEET_LIST::GetPaths() const
780 {
781  std::vector<KIID_PATH> paths;
782 
783  for( auto sheetPath : *this )
784  paths.emplace_back( sheetPath.Path() );
785 
786  return paths;
787 }
788 
789 
790 void SCH_SHEET_LIST::ReplaceLegacySheetPaths( const std::vector<KIID_PATH>& aOldSheetPaths )
791 {
792  wxCHECK( size() == aOldSheetPaths.size(), /* void */ );
793 
794  for( size_t i = 0; i < size(); i++ )
795  {
796  const KIID_PATH oldSheetPath = aOldSheetPaths.at( i );
797  const KIID_PATH newSheetPath = at( i ).Path();
798  SCH_SCREEN* screen = at(i).LastScreen();
799 
800  wxCHECK( screen, /* void */ );
801 
802  for( auto symbol : screen->Items().OfType( SCH_COMPONENT_T ) )
803  {
804  static_cast<SCH_COMPONENT*>( symbol )->ReplaceInstanceSheetPath( oldSheetPath,
805  newSheetPath );
806  }
807  }
808 }
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.
DELETED_SHEET_ITEM * g_DeletedItem
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.
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:245
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:952
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:128
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 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.
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)
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
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.
bool SetComponentFootprint(const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Function SetFootprintField searches all the sheets for a component with aReference and set the footpr...
std::vector< SCH_SHEET * > m_sheets
size_t operator()(const SCH_SHEET_PATH &path) const
bool SetComponentFootprint(const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Function SetFootprintField searches last sheet in the path for a component with aReference and set th...
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
Set the schematic item position to aPosition.
bool IsModify() const
Definition: base_screen.h:187
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
SCH_SHEET_PATH.
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)
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.
const SCH_SHEET * GetSheet(unsigned aIndex) const
bool IsPower() const
SCH_SCREEN * LastScreen()
Function LastScreen.
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:93
size_t GetCurrentHash() const
EE_RTREE & Items()
Definition: sch_screen.h:162
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:184
Schematic symbol object.
Definition: sch_component.h:88
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)
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:183
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:186
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_PIN_PTRS GetSchPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.
bool SetComponentFootprint(SCH_SHEET_PATH *aSheetPath, const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Search this screen for a symbol with aReference and set the footprint field to aFootPrint if found.