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...
 
bool IsAutoSaveRequired ()
 Function IsAutoSaveRequired checks the entire hierarchy for any modifications that require auto save. More...
 
void ClearModifyStatus ()
 
void AnnotatePowerSymbols (PART_LIBS *aLib)
 Function AnnotatePowerSymbols Silently annotates the not yet annotated power symbols of the entire hierarchy of the sheet path list. More...
 
void GetComponents (PART_LIBS *aLibs, SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true)
 Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of sheets. More...
 
void GetMultiUnitComponents (PART_LIBS *aLibs, 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 321 of file sch_sheet_path.h.

Constructor & Destructor Documentation

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 431 of file sch_sheet_path.cpp.

References BuildSheetList(), and m_isRootSheet.

432 {
433  m_isRootSheet = false;
434 
435  if( aSheet != NULL )
436  BuildSheetList( aSheet );
437 }
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
SCH_SHEET_LIST::~SCH_SHEET_LIST ( )
inline

Definition at line 337 of file sch_sheet_path.h.

337 {}

Member Function Documentation

void SCH_SHEET_LIST::AnnotatePowerSymbols ( PART_LIBS aLib)

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 ).

Parameters
aLibthe library list to use

Definition at line 527 of file sch_sheet_path.cpp.

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::prepareForNetlist(), and DIALOG_ERC::TestErc().

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

References g_RootSheet, SCH_SHEET::GetScreen(), SCH_SHEET_PATH::LastDrawList(), m_currentSheetPath, m_isRootSheet, EDA_ITEM::Next(), 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().

457 {
458  wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
459 
460  if( aSheet == g_RootSheet )
461  m_isRootSheet = true;
462 
463  m_currentSheetPath.push_back( aSheet );
464 
470  m_currentSheetPath.SetPageNumber( size() + 1 );
471  push_back( m_currentSheetPath );
472 
473  if( aSheet->GetScreen() )
474  {
476 
477  while( item )
478  {
479  if( item->Type() == SCH_SHEET_T )
480  {
481  SCH_SHEET* sheet = (SCH_SHEET*) item;
482  BuildSheetList( sheet );
483  }
484 
485  item = item->Next();
486  }
487  }
488 
489  m_currentSheetPath.pop_back();
490 }
SCH_ITEM * LastDrawList() const
Function LastDrawList.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void SetPageNumber(int aPageNumber)
EDA_ITEM * Next() const
Definition: base_struct.h:206
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:286
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:54
SCH_SHEET_PATH m_currentSheetPath
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
void SCH_SHEET_LIST::ClearModifyStatus ( )

Definition at line 517 of file sch_sheet_path.cpp.

Referenced by SCH_EDIT_FRAME::OnCloseWindow().

518 {
519  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
520  {
521  if( (*it).LastScreen() )
522  (*it).LastScreen()->ClrModify();
523  }
524 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
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 635 of file sch_sheet_path.cpp.

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

Referenced by SCH_EDIT_FRAME::OnFindDrcMarker().

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

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

683 {
684  bool hasWrapped = false;
685  bool firstItemFound = false;
686  SCH_ITEM* drawItem = NULL;
687  SCH_SHEET_PATHS_RITER it = rbegin();
688 
689  while( it != rend() )
690  {
691  drawItem = (*it).FirstDrawList();
692 
693  while( drawItem )
694  {
695  if( drawItem->Type() == aType )
696  {
697  if( aLastItem == NULL || firstItemFound )
698  {
699  if( aSheetFoundIn )
700  *aSheetFoundIn = &(*it);
701 
702  return drawItem;
703  }
704  else if( !firstItemFound && drawItem == aLastItem )
705  {
706  firstItemFound = true;
707  }
708  }
709 
710  drawItem = drawItem->Back();
711  }
712 
713  ++it;
714 
715  if( it == rend() && aLastItem && aWrap && !hasWrapped )
716  {
717  hasWrapped = true;
718  it = rbegin();
719  }
720  }
721 
722  return NULL;
723 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_ITEM * Back() const
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...
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 791 of file sch_sheet_path.cpp.

Referenced by SCH_EDIT_FRAME::EditSheet().

792 {
793  for( unsigned i = 0; i < size(); i++ )
794  {
795  SCH_SHEET* sheet = at( i ).FindSheetByName( aSheetName );
796 
797  if( sheet )
798  return sheet;
799  }
800 
801  return NULL;
802 }
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
void SCH_SHEET_LIST::GetComponents ( PART_LIBS aLibs,
SCH_REFERENCE_LIST aReferences,
bool  aIncludePowerSymbols = true 
)

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

Parameters
aLibsthe library list to use
aReferencesList of references to populate.
aIncludePowerSymbolsSet to false to only get normal components.

Definition at line 605 of file sch_sheet_path.cpp.

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::backAnnotateFootprints(), SCH_EDIT_FRAME::CheckAnnotate(), DIALOG_BOM_EDITOR::LoadComponents(), and SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile().

607 {
608  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
609  (*it).GetComponents( aLibs, aReferences, aIncludePowerSymbols );
610 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
void SCH_SHEET_LIST::GetMultiUnitComponents ( PART_LIBS aLibs,
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
aLibsthe library list to use
aRefListMap of reference designators to reference lists
aIncludePowerSymbolsSet to false to only get normal components.

Definition at line 612 of file sch_sheet_path.cpp.

Referenced by SCH_EDIT_FRAME::AnnotateComponents().

615 {
616  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
617  {
619  (*it).GetMultiUnitComponents( aLibs, tempMap );
620 
621  for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
622  {
623  // Merge this list into the main one
624  unsigned n_refs = pair.second.GetCount();
625 
626  for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
627  {
628  aRefList[pair.first].AddItem( pair.second[thisRef] );
629  }
630  }
631  }
632 }
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...
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 440 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::PathHumanReadable().

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

441 {
442  wxString sheetPath;
443 
444  for( unsigned i = 0; i < size(); i++ )
445  {
446  sheetPath = ( aHumanReadable ) ? at( i ).PathHumanReadable() : at( i ).Path();
447 
448  if( sheetPath == aPath )
449  return &at( i );
450  }
451 
452  return NULL;
453 }
bool SCH_SHEET_LIST::IsAutoSaveRequired ( )

Function IsAutoSaveRequired checks the entire hierarchy for any modifications that require auto save.

Returns
True if the hierarchy is modified otherwise false.

Definition at line 505 of file sch_sheet_path.cpp.

Referenced by SCH_EDIT_FRAME::isAutoSaveRequired().

506 {
507  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
508  {
509  if( (*it).LastScreen() && (*it).LastScreen()->IsSave() )
510  return true;
511  }
512 
513  return false;
514 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
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 738 of file sch_sheet_path.cpp.

739 {
740  wxString fileName;
741 
742  for( unsigned i = 0; i < size(); i++ )
743  {
744  fileName = at( i ).Last()->GetFileName();
745 
746  for( unsigned j = 0; j < size(); j++ )
747  {
748  if( i == j )
749  continue;
750 
751  if( fileName == at( j ).Last()->GetFileName() )
752  return true;
753  }
754  }
755 
756  return false;
757 }
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 493 of file sch_sheet_path.cpp.

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

494 {
495  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
496  {
497  if( (*it).LastScreen() && (*it).LastScreen()->IsModify() )
498  return true;
499  }
500 
501  return false;
502 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
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 726 of file sch_sheet_path.cpp.

728 {
729  bool found = false;
730 
731  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
732  found = (*it).SetComponentFootprint( aReference, aFootPrint, aSetVisible );
733 
734  return found;
735 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
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 760 of file sch_sheet_path.cpp.

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

Referenced by SCH_EDIT_FRAME::EditSheet(), and SCH_EDIT_FRAME::PasteListOfItems().

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

Member Data Documentation

SCH_SHEET_PATH SCH_SHEET_LIST::m_currentSheetPath
private

Definition at line 325 of file sch_sheet_path.h.

Referenced by BuildSheetList().

bool SCH_SHEET_LIST::m_isRootSheet
private

Definition at line 324 of file sch_sheet_path.h.

Referenced by BuildSheetList(), and SCH_SHEET_LIST().


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