KiCad PCB EDA Suite
SCH_SHEET_LIST Class Reference

Class SCH_SHEET_LIST. More...

#include <sch_sheet_path.h>

Inheritance diagram for SCH_SHEET_LIST:

Public Member Functions

 SCH_SHEET_LIST (SCH_SHEET *aSheet=NULL)
 Constructor build a flattened list of SCH_SHEET_PATH objects from aSheet. More...
 
 ~SCH_SHEET_LIST ()
 
SCH_SHEET_PATHGetSheetByPath (const wxString &aPath, bool aHumanReadable=true)
 Function GetSheetByPath returns a sheet matching the path name in aPath. More...
 
bool IsModified ()
 Function IsModified checks the entire hierarchy for any modifications. More...
 
void ClearModifyStatus ()
 
void AnnotatePowerSymbols ()
 Function AnnotatePowerSymbols Silently annotates the not yet annotated power symbols of the entire hierarchy of the sheet path list. More...
 
void GetComponents (SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false)
 Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of sheets. More...
 
void GetMultiUnitComponents (SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
 Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the list of sheets. More...
 
SCH_ITEMFindNextItem (KICAD_T aType, SCH_SHEET_PATH **aSheetFound=NULL, SCH_ITEM *aLastItem=NULL, bool aWrap=true)
 Function FindNextItem searches the entire schematic for the next schematic object. More...
 
SCH_ITEMFindPreviousItem (KICAD_T aType, SCH_SHEET_PATH **aSheetFound=NULL, SCH_ITEM *aLastItem=NULL, bool aWrap=true)
 Function FindPreviousItem searches the entire schematic for the previous schematic item. More...
 
bool SetComponentFootprint (const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
 Function SetFootprintField searches all the sheets for a component with aReference and set the footprint field to aFootPrint if found. More...
 
bool IsComplexHierarchy () const
 Function IsComplexHierarchy searches all of the sheets for duplicate files names which indicates a complex hierarchy. More...
 
bool TestForRecursion (const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
 Function TestForRecursion. More...
 
SCH_SHEETFindSheetByName (const wxString &aSheetName)
 Function FindSheetByName. More...
 
void BuildSheetList (SCH_SHEET *aSheet)
 Function BuildSheetList builds the list of sheets and their sheet path from aSheet. More...
 

Private Attributes

bool m_isRootSheet
 
SCH_SHEET_PATH m_currentSheetPath
 

Detailed Description

Class SCH_SHEET_LIST.

handles a list of SCH_SHEET_PATH objects in a flattened hierarchy.

SCH_SHEET objects are not unique, there can be many sheets with the same filename and that share the same SCH_SCREEN reference. Each The schematic file (SCH_SCREEN) may be shared between these sheets and component references are specific to a sheet path. When a sheet is entered, component references and sheet page number are updated.

Definition at line 375 of file sch_sheet_path.h.

Constructor & Destructor Documentation

◆ SCH_SHEET_LIST()

SCH_SHEET_LIST::SCH_SHEET_LIST ( SCH_SHEET aSheet = NULL)

Constructor build a flattened list of SCH_SHEET_PATH objects from aSheet.

If aSheet == NULL, then this is an empty hierarchy which the user can populate.

Definition at line 441 of file sch_sheet_path.cpp.

442 {
443  m_isRootSheet = false;
444 
445  if( aSheet != NULL )
446  BuildSheetList( aSheet );
447 }
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.

References BuildSheetList(), and m_isRootSheet.

◆ ~SCH_SHEET_LIST()

SCH_SHEET_LIST::~SCH_SHEET_LIST ( )
inline

Definition at line 391 of file sch_sheet_path.h.

391 {}

Member Function Documentation

◆ AnnotatePowerSymbols()

void SCH_SHEET_LIST::AnnotatePowerSymbols ( )

Function AnnotatePowerSymbols Silently annotates the not yet annotated power symbols of the entire hierarchy of the sheet path list.

It is called before creating a netlist, to annotate power symbols, without prompting the user about not annotated or duplicate for these symbols, if only these symbols need annotation ( a very frequent case ).

Definition at line 525 of file sch_sheet_path.cpp.

526 {
527  // List of reference for power symbols
528  SCH_REFERENCE_LIST references;
529 
530  // Map of locked components (not used, but needed by Annotate()
531  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
532 
533  // Build the list of power components:
534  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
535  {
536  SCH_SHEET_PATH& spath = *it;
537 
538  for( EDA_ITEM* item = spath.LastDrawList(); item; item = item->Next() )
539  {
540  if( item->Type() != SCH_COMPONENT_T )
541  continue;
542 
543  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
544  LIB_PART* part = component->GetPartRef().lock().get();
545 
546  if( !part || !part->IsPower() )
547  continue;
548 
549  if( part )
550  {
551  SCH_REFERENCE schReference( component, part, spath );
552  references.AddItem( schReference );
553  }
554  }
555  }
556 
557  // Find duplicate, and silently clear annotation of duplicate
558  std::map<wxString, int> ref_list; // stores the existing references
559 
560  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
561  {
562  wxString curr_ref = references[ii].GetRef();
563 
564  if( ref_list.find( curr_ref ) == ref_list.end() )
565  {
566  ref_list[curr_ref] = ii;
567  continue;
568  }
569 
570  // Possible duplicate, if the ref ends by a number:
571  if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
572  continue; // not annotated
573 
574  // Duplicate: clear annotation by removing the number ending the ref
575  while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
576  curr_ref.RemoveLast();
577 
578  references[ii].SetRef( curr_ref );
579  }
580 
581 
582  // Break full components reference in name (prefix) and number:
583  // example: IC1 become IC, and 1
584  references.SplitReferences();
585 
586  // Ensure all power symbols have the reference starting by '#'
587  // (No sure this is really useful)
588  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
589  {
590  if( references[ii].GetRef()[0] != '#' )
591  {
592  wxString new_ref = "#" + references[ii].GetRef();
593  references[ii].SetRef( new_ref );
594  }
595  }
596 
597  // Recalculate and update reference numbers in schematic
598  references.Annotate( false, 0, 100, lockedComponents );
599  references.UpdateAnnotation();
600 }
PART_REF & GetPartRef()
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
SCH_ITEM * Next() const
Definition: sch_item.h:153
void AddItem(SCH_REFERENCE &aItem)
Function AddItem adds a SCH_REFERENCE object to the list of references.
Class SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierar...
void UpdateAnnotation()
function UpdateAnnotation Updates the reference components for the schematic project (or the current ...
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.
Class SCH_SHEET_PATH.
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...
SCH_ITEM * LastDrawList() const
Function LastDrawList.
bool IsPower() const
void SplitReferences()
Function SplitReferences attempts to split all reference designators into a name (U) and number (1).
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
unsigned GetCount()
Function GetCount.
Class SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.

References SCH_REFERENCE_LIST::AddItem(), SCH_REFERENCE_LIST::Annotate(), SCH_REFERENCE_LIST::GetCount(), SCH_COMPONENT::GetPartRef(), LIB_PART::IsPower(), SCH_SHEET_PATH::LastDrawList(), SCH_ITEM::Next(), SCH_COMPONENT_T, SCH_REFERENCE_LIST::SplitReferences(), and SCH_REFERENCE_LIST::UpdateAnnotation().

Referenced by SCH_EDIT_FRAME::CreateNetlist(), SCH_EDIT_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::prepareForNetlist(), and DIALOG_ERC::TestErc().

◆ BuildSheetList()

void SCH_SHEET_LIST::BuildSheetList ( SCH_SHEET aSheet)

Function BuildSheetList builds the list of sheets and their sheet path from aSheet.

If aSheet is the root sheet, the full sheet path and sheet list are built.

Parameters
aSheetis the starting sheet from which the list is built, or NULL indicating that g_RootSheet should be used.
Exceptions
std::bad_allocif the memory for the sheet path list could not be allocated.
Todo:
: Schematic page number is currently a left over relic and is generated as SCH_SHEET_PATH object is pushed to the list. This only has meaning when entire hierarchy is created from the root sheet down.

Definition at line 466 of file sch_sheet_path.cpp.

467 {
468  wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
469 
470  if( aSheet == g_RootSheet )
471  m_isRootSheet = true;
472 
473  m_currentSheetPath.push_back( aSheet );
474 
480  m_currentSheetPath.SetPageNumber( size() + 1 );
481  push_back( m_currentSheetPath );
482 
483  if( aSheet->GetScreen() )
484  {
486 
487  while( item )
488  {
489  if( item->Type() == SCH_SHEET_T )
490  {
491  SCH_SHEET* sheet = (SCH_SHEET*) item;
492  BuildSheetList( sheet );
493  }
494 
495  item = item->Next();
496  }
497  }
498 
500 }
void SetPageNumber(int aPageNumber)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:268
void pop_back()
Forwarded method from std::vector.
EDA_ITEM * Next() const
Definition: base_struct.h:212
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_SHEET_PATH m_currentSheetPath
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
SCH_ITEM * LastDrawList() const
Function LastDrawList.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References g_RootSheet, SCH_SHEET::GetScreen(), SCH_SHEET_PATH::LastDrawList(), m_currentSheetPath, m_isRootSheet, EDA_ITEM::Next(), SCH_SHEET_PATH::pop_back(), SCH_SHEET_PATH::push_back(), SCH_SHEET_T, SCH_SHEET_PATH::SetPageNumber(), and EDA_ITEM::Type().

Referenced by DIALOG_PLOT_SCHEMATIC::CreateDXFFile(), DIALOG_PLOT_SCHEMATIC::createHPGLFile(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::createPSFile(), DIALOG_PLOT_SCHEMATIC::createSVGFile(), SCH_EDIT_FRAME::FindComponentAndItem(), and SCH_SHEET_LIST().

◆ ClearModifyStatus()

void SCH_SHEET_LIST::ClearModifyStatus ( )

Definition at line 515 of file sch_sheet_path.cpp.

516 {
517  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
518  {
519  if( (*it).LastScreen() )
520  (*it).LastScreen()->ClrModify();
521  }
522 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER

Referenced by SCH_EDIT_FRAME::OnCloseWindow().

◆ FindNextItem()

SCH_ITEM * SCH_SHEET_LIST::FindNextItem ( KICAD_T  aType,
SCH_SHEET_PATH **  aSheetFound = NULL,
SCH_ITEM aLastItem = NULL,
bool  aWrap = true 
)

Function FindNextItem searches the entire schematic for the next schematic object.

Parameters
aType- The type of schematic item to find.
aSheetFound- The sheet the item was found in. NULL if the next item is not found.
aLastItem- Find next item after aLastItem if not NULL.
aWrap- Wrap past around the end of the list of sheets.
Returns
If found, Returns the next schematic item. Otherwise, returns NULL.

Definition at line 632 of file sch_sheet_path.cpp.

634 {
635  bool hasWrapped = false;
636  bool firstItemFound = false;
637 
638  SCH_ITEM* drawItem = NULL;
639  SCH_SHEET_PATHS_ITER it = begin();
640 
641  while( it != end() )
642  {
643  drawItem = (*it).LastDrawList();
644 
645  while( drawItem )
646  {
647  if( drawItem->Type() == aType )
648  {
649  if( aLastItem == NULL || firstItemFound )
650  {
651  if( aSheetFoundIn )
652  *aSheetFoundIn = &(*it);
653 
654  return drawItem;
655  }
656  else if( !firstItemFound && drawItem == aLastItem )
657  {
658  firstItemFound = true;
659  }
660  }
661 
662  drawItem = drawItem->Next();
663  }
664 
665  ++it;
666 
667  if( it == end() && aLastItem && aWrap && !hasWrapped )
668  {
669  hasWrapped = true;
670  it = begin();
671  }
672  }
673 
674  return NULL;
675 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
SCH_ITEM * Next() const
Definition: sch_item.h:153
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References SCH_ITEM::Next(), and EDA_ITEM::Type().

Referenced by SCH_EDIT_FRAME::OnFindDrcMarker().

◆ FindPreviousItem()

SCH_ITEM * SCH_SHEET_LIST::FindPreviousItem ( KICAD_T  aType,
SCH_SHEET_PATH **  aSheetFound = NULL,
SCH_ITEM aLastItem = NULL,
bool  aWrap = true 
)

Function FindPreviousItem searches the entire schematic for the previous schematic item.

Parameters
aType- The type of schematic item to find.
aSheetFound- The sheet the item was found in. NULL if the previous item is not found.
aLastItem- Find the previous item before aLastItem if not NULL.
aWrap- Wrap past around the beginning of the list of sheets.
Returns
If found, the previous schematic item. Otherwise, NULL.

Definition at line 678 of file sch_sheet_path.cpp.

680 {
681  bool hasWrapped = false;
682  bool firstItemFound = false;
683  SCH_ITEM* drawItem = NULL;
684  SCH_SHEET_PATHS_RITER it = rbegin();
685 
686  while( it != rend() )
687  {
688  drawItem = (*it).FirstDrawList();
689 
690  while( drawItem )
691  {
692  if( drawItem->Type() == aType )
693  {
694  if( aLastItem == NULL || firstItemFound )
695  {
696  if( aSheetFoundIn )
697  *aSheetFoundIn = &(*it);
698 
699  return drawItem;
700  }
701  else if( !firstItemFound && drawItem == aLastItem )
702  {
703  firstItemFound = true;
704  }
705  }
706 
707  drawItem = drawItem->Back();
708  }
709 
710  ++it;
711 
712  if( it == rend() && aLastItem && aWrap && !hasWrapped )
713  {
714  hasWrapped = true;
715  it = rbegin();
716  }
717  }
718 
719  return NULL;
720 }
SCH_ITEM * Back() const
Definition: sch_item.h:154
SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References SCH_ITEM::Back(), and EDA_ITEM::Type().

◆ FindSheetByName()

SCH_SHEET * SCH_SHEET_LIST::FindSheetByName ( const wxString &  aSheetName)

Function FindSheetByName.

searches the entire SCH_SHEET_LIST for a sheet named aSheetName.

Parameters
aSheetNameis the name of the sheet to find.
Returns
a pointer to the sheet named aSheetName if found or NULL if not found.

Definition at line 788 of file sch_sheet_path.cpp.

789 {
790  for( unsigned i = 0; i < size(); i++ )
791  {
792  SCH_SHEET* sheet = at( i ).FindSheetByName( aSheetName );
793 
794  if( sheet )
795  return sheet;
796  }
797 
798  return NULL;
799 }
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
size_t i
Definition: json11.cpp:597

References i.

Referenced by DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow().

◆ GetComponents()

void SCH_SHEET_LIST::GetComponents ( SCH_REFERENCE_LIST aReferences,
bool  aIncludePowerSymbols = true,
bool  aForceIncludeOrphanComponents = false 
)

Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of sheets.

Parameters
aReferencesList of references to populate.
aIncludePowerSymbolsSet to false to only get normal components.
aForceIncludeOrphanComponents: true to include components having no symbol found in lib. ( orphan components) The normal option is false, and set to true only to build the full list of components.

Definition at line 603 of file sch_sheet_path.cpp.

605 {
606  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
607  (*it).GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents );
608 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::backAnnotateFootprints(), SCH_EDIT_FRAME::CheckAnnotate(), DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL(), DIALOG_EDIT_COMPONENTS_LIBID::initDlg(), mapExistingAnnotation(), and SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile().

◆ GetMultiUnitComponents()

void SCH_SHEET_LIST::GetMultiUnitComponents ( SCH_MULTI_UNIT_REFERENCE_MAP aRefList,
bool  aIncludePowerSymbols = true 
)

Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the list of sheets.

The map key for each element will be the reference designator.

Parameters
aRefListMap of reference designators to reference lists
aIncludePowerSymbolsSet to false to only get normal components.

Definition at line 610 of file sch_sheet_path.cpp.

612 {
613  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
614  {
616  (*it).GetMultiUnitComponents( tempMap );
617 
618  for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
619  {
620  // Merge this list into the main one
621  unsigned n_refs = pair.second.GetCount();
622 
623  for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
624  {
625  aRefList[pair.first].AddItem( pair.second[thisRef] );
626  }
627  }
628  }
629 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
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...

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), and TestMultiunitFootprints().

◆ GetSheetByPath()

SCH_SHEET_PATH * SCH_SHEET_LIST::GetSheetByPath ( const wxString &  aPath,
bool  aHumanReadable = true 
)

Function GetSheetByPath returns a sheet matching the path name in aPath.

Parameters
aPathA wxString object containing path of the sheet to get.
aHumanReadableTrue uses the human readable path for comparison. False uses the timestamp generated path.
Returns
The sheet that matches aPath or NULL if no sheet matching aPath is found.

Definition at line 450 of file sch_sheet_path.cpp.

451 {
452  wxString sheetPath;
453 
454  for( unsigned i = 0; i < size(); i++ )
455  {
456  sheetPath = ( aHumanReadable ) ? at( i ).PathHumanReadable() : at( i ).Path();
457 
458  if( sheetPath == aPath )
459  return &at( i );
460  }
461 
462  return NULL;
463 }
size_t i
Definition: json11.cpp:597

References i, and SCH_SHEET_PATH::PathHumanReadable().

Referenced by SCH_EDIT_FRAME::OnFindReplace(), and SCH_EDIT_FRAME::updateFindReplaceView().

◆ IsComplexHierarchy()

bool SCH_SHEET_LIST::IsComplexHierarchy ( ) const

Function IsComplexHierarchy searches all of the sheets for duplicate files names which indicates a complex hierarchy.

Returns
true if the SCH_SHEET_LIST is a complex hierarchy.

Definition at line 735 of file sch_sheet_path.cpp.

736 {
737  wxString fileName;
738 
739  for( unsigned i = 0; i < size(); i++ )
740  {
741  fileName = at( i ).Last()->GetFileName();
742 
743  for( unsigned j = 0; j < size(); j++ )
744  {
745  if( i == j )
746  continue;
747 
748  if( fileName == at( j ).Last()->GetFileName() )
749  return true;
750  }
751  }
752 
753  return false;
754 }
size_t i
Definition: json11.cpp:597

References i.

◆ IsModified()

bool SCH_SHEET_LIST::IsModified ( )

Function IsModified checks the entire hierarchy for any modifications.

Returns
True if the hierarchy is modified otherwise false.

Definition at line 503 of file sch_sheet_path.cpp.

504 {
505  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
506  {
507  if( (*it).LastScreen() && (*it).LastScreen()->IsModify() )
508  return true;
509  }
510 
511  return false;
512 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER

Referenced by SCH_EDIT_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OnUpdateSave(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ SetComponentFootprint()

bool SCH_SHEET_LIST::SetComponentFootprint ( const wxString &  aReference,
const wxString &  aFootPrint,
bool  aSetVisible 
)

Function SetFootprintField searches all the sheets for a component with aReference and set the footprint field to aFootPrint if found.

Parameters
aReferenceThe reference designator of the component.
aFootPrintThe value to set the footprint field.
aSetVisibleThe value to set the field visibility flag.
Returns
True if aReference was found otherwise false.

Definition at line 723 of file sch_sheet_path.cpp.

725 {
726  bool found = false;
727 
728  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
729  found = (*it).SetComponentFootprint( aReference, aFootPrint, aSetVisible );
730 
731  return found;
732 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER

◆ TestForRecursion()

bool SCH_SHEET_LIST::TestForRecursion ( const SCH_SHEET_LIST aSrcSheetHierarchy,
const wxString &  aDestFileName 
) const

Function TestForRecursion.

test every SCH_SHEET_PATH in the SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHierarchy to the sheet stored in aDestFileName will cause recursion.

Parameters
aSrcSheetHierarchyis the SCH_SHEET_LIST of the source sheet add to aDestFileName.
aDestFileNameis the file name of the destination sheet for aSrcFileName.
Returns
true if aFileName will cause recursion in the sheet path. Otherwise false.

Definition at line 757 of file sch_sheet_path.cpp.

759 {
760  wxFileName rootFn = g_RootSheet->GetFileName();
761  wxFileName destFn = aDestFileName;
762 
763  if( destFn.IsRelative() )
764  destFn.MakeAbsolute( rootFn.GetPath() );
765 
766  // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
767  for( unsigned i = 0; i < size(); i++ )
768  {
769  // Test each SCH_SHEET_PATH in the source sheet.
770  for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
771  {
772  const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
773 
774  for( unsigned k = 0; k < sheetPath->size(); k++ )
775  {
776  if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
777  aDestFileName ) )
778  return true;
779  }
780  }
781  }
782 
783  // The source sheet file can safely be added to the destination sheet file.
784  return false;
785 }
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
size_t size() const
Forwarded method from std::vector.
Class SCH_SHEET_PATH.
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:627
const SCH_SHEET * GetSheet(unsigned aIndex) const
size_t i
Definition: json11.cpp:597

References g_RootSheet, SCH_SHEET::GetFileName(), SCH_SHEET_PATH::GetSheet(), i, and SCH_SHEET_PATH::size().

Referenced by SCH_EDIT_FRAME::AppendSchematic(), SCH_EDIT_FRAME::EditSheet(), and SCH_EDITOR_CONTROL::Paste().

Member Data Documentation

◆ m_currentSheetPath

SCH_SHEET_PATH SCH_SHEET_LIST::m_currentSheetPath
private

Definition at line 379 of file sch_sheet_path.h.

Referenced by BuildSheetList().

◆ m_isRootSheet

bool SCH_SHEET_LIST::m_isRootSheet
private

Definition at line 378 of file sch_sheet_path.h.

Referenced by BuildSheetList(), and SCH_SHEET_LIST().


The documentation for this class was generated from the following files: