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...
 
SCH_SHEET_PATHFindSheetForScreen (SCH_SCREEN *aScreen)
 Function FindSheetForScreen. 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 381 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 451 of file sch_sheet_path.cpp.

452 {
453  m_isRootSheet = false;
454 
455  if( aSheet != NULL )
456  BuildSheetList( aSheet );
457 }
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 397 of file sch_sheet_path.h.

397 {}

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

536 {
537  // List of reference for power symbols
538  SCH_REFERENCE_LIST references;
539 
540  // Map of locked components (not used, but needed by Annotate()
541  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
542 
543  // Build the list of power components:
544  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
545  {
546  SCH_SHEET_PATH& spath = *it;
547 
548  for( EDA_ITEM* item = spath.LastDrawList(); item; item = item->Next() )
549  {
550  if( item->Type() != SCH_COMPONENT_T )
551  continue;
552 
553  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
554  LIB_PART* part = component->GetPartRef().lock().get();
555 
556  if( !part || !part->IsPower() )
557  continue;
558 
559  if( part )
560  {
561  SCH_REFERENCE schReference( component, part, spath );
562  references.AddItem( schReference );
563  }
564  }
565  }
566 
567  // Find duplicate, and silently clear annotation of duplicate
568  std::map<wxString, int> ref_list; // stores the existing references
569 
570  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
571  {
572  wxString curr_ref = references[ii].GetRef();
573 
574  if( ref_list.find( curr_ref ) == ref_list.end() )
575  {
576  ref_list[curr_ref] = ii;
577  continue;
578  }
579 
580  // Possible duplicate, if the ref ends by a number:
581  if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
582  continue; // not annotated
583 
584  // Duplicate: clear annotation by removing the number ending the ref
585  while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
586  curr_ref.RemoveLast();
587 
588  references[ii].SetRef( curr_ref );
589  }
590 
591 
592  // Break full components reference in name (prefix) and number:
593  // example: IC1 become IC, and 1
594  references.SplitReferences();
595 
596  // Ensure all power symbols have the reference starting by '#'
597  // (No sure this is really useful)
598  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
599  {
600  if( references[ii].GetRef()[0] != '#' )
601  {
602  wxString new_ref = "#" + references[ii].GetRef();
603  references[ii].SetRef( new_ref );
604  }
605  }
606 
607  // Recalculate and update reference numbers in schematic
608  references.Annotate( false, 0, 100, lockedComponents );
609  references.UpdateAnnotation();
610 }
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:163
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 476 of file sch_sheet_path.cpp.

477 {
478  wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
479 
480  if( aSheet == g_RootSheet )
481  m_isRootSheet = true;
482 
483  m_currentSheetPath.push_back( aSheet );
484 
490  m_currentSheetPath.SetPageNumber( size() + 1 );
491  push_back( m_currentSheetPath );
492 
493  if( aSheet->GetScreen() )
494  {
496 
497  while( item )
498  {
499  if( item->Type() == SCH_SHEET_T )
500  {
501  SCH_SHEET* sheet = (SCH_SHEET*) item;
502  BuildSheetList( sheet );
503  }
504 
505  item = item->Next();
506  }
507  }
508 
510 }
void SetPageNumber(int aPageNumber)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:271
void pop_back()
Forwarded method from std::vector.
EDA_ITEM * Next() const
Definition: base_struct.h:218
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
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:204
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:163
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

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_EDITOR_CONTROL::FindComponentAndItem(), SCH_EDIT_FRAME::FixupJunctions(), and SCH_SHEET_LIST().

◆ ClearModifyStatus()

void SCH_SHEET_LIST::ClearModifyStatus ( )

Definition at line 525 of file sch_sheet_path.cpp.

526 {
527  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
528  {
529  if( (*it).LastScreen() )
530  (*it).LastScreen()->ClrModify();
531  }
532 }
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 642 of file sch_sheet_path.cpp.

644 {
645  bool hasWrapped = false;
646  bool firstItemFound = false;
647 
648  SCH_ITEM* drawItem = NULL;
649  SCH_SHEET_PATHS_ITER it = begin();
650 
651  while( it != end() )
652  {
653  drawItem = (*it).LastDrawList();
654 
655  while( drawItem )
656  {
657  if( drawItem->Type() == aType )
658  {
659  if( aLastItem == NULL || firstItemFound )
660  {
661  if( aSheetFoundIn )
662  *aSheetFoundIn = &(*it);
663 
664  return drawItem;
665  }
666  else if( !firstItemFound && drawItem == aLastItem )
667  {
668  firstItemFound = true;
669  }
670  }
671 
672  drawItem = drawItem->Next();
673  }
674 
675  ++it;
676 
677  if( it == end() && aLastItem && aWrap && !hasWrapped )
678  {
679  hasWrapped = true;
680  it = begin();
681  }
682  }
683 
684  return NULL;
685 }
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:210

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

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

690 {
691  bool hasWrapped = false;
692  bool firstItemFound = false;
693  SCH_ITEM* drawItem = NULL;
694  SCH_SHEET_PATHS_RITER it = rbegin();
695 
696  while( it != rend() )
697  {
698  drawItem = (*it).FirstDrawList();
699 
700  while( drawItem )
701  {
702  if( drawItem->Type() == aType )
703  {
704  if( aLastItem == NULL || firstItemFound )
705  {
706  if( aSheetFoundIn )
707  *aSheetFoundIn = &(*it);
708 
709  return drawItem;
710  }
711  else if( !firstItemFound && drawItem == aLastItem )
712  {
713  firstItemFound = true;
714  }
715  }
716 
717  drawItem = drawItem->Back();
718  }
719 
720  ++it;
721 
722  if( it == rend() && aLastItem && aWrap && !hasWrapped )
723  {
724  hasWrapped = true;
725  it = rbegin();
726  }
727  }
728 
729  return NULL;
730 }
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:210

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

799 {
800  for( unsigned i = 0; i < size(); i++ )
801  {
802  SCH_SHEET* sheet = at( i ).FindSheetByName( aSheetName );
803 
804  if( sheet )
805  return sheet;
806  }
807 
808  return NULL;
809 }
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:204
size_t i
Definition: json11.cpp:597

References i.

Referenced by DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow().

◆ FindSheetForScreen()

SCH_SHEET_PATH * SCH_SHEET_LIST::FindSheetForScreen ( SCH_SCREEN aScreen)

Function FindSheetForScreen.

returns the first sheetPath (not necessarily the only one) using a particular screen

Definition at line 812 of file sch_sheet_path.cpp.

813 {
814  for( SCH_SHEET_PATH& sheetpath : *this )
815  {
816  if( sheetpath.LastScreen() == aScreen )
817  return &sheetpath;
818  }
819 
820  return nullptr;
821 }
Class SCH_SHEET_PATH.
SCH_SCREEN * LastScreen() const
Function LastScreen.

References SCH_SHEET_PATH::LastScreen().

Referenced by SCH_EDITOR_CONTROL::FindNext(), and SCH_EDITOR_CONTROL::ReplaceAll().

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

615 {
616  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
617  (*it).GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents );
618 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDITOR_CONTROL::BackAnnotateFootprints(), SCH_EDIT_FRAME::CheckAnnotate(), DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL(), DIALOG_EDIT_COMPONENTS_LIBID::initDlg(), mapExistingAnnotation(), and SCH_EDITOR_CONTROL::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 620 of file sch_sheet_path.cpp.

622 {
623  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
624  {
626  (*it).GetMultiUnitComponents( tempMap );
627 
628  for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
629  {
630  // Merge this list into the main one
631  unsigned n_refs = pair.second.GetCount();
632 
633  for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
634  {
635  aRefList[pair.first].AddItem( pair.second[thisRef] );
636  }
637  }
638  }
639 }
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 460 of file sch_sheet_path.cpp.

461 {
462  wxString sheetPath;
463 
464  for( unsigned i = 0; i < size(); i++ )
465  {
466  sheetPath = ( aHumanReadable ) ? at( i ).PathHumanReadable() : at( i ).Path();
467 
468  if( sheetPath == aPath )
469  return &at( i );
470  }
471 
472  return NULL;
473 }
size_t i
Definition: json11.cpp:597

References i, and SCH_SHEET_PATH::PathHumanReadable().

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

746 {
747  wxString fileName;
748 
749  for( unsigned i = 0; i < size(); i++ )
750  {
751  fileName = at( i ).Last()->GetFileName();
752 
753  for( unsigned j = 0; j < size(); j++ )
754  {
755  if( i == j )
756  continue;
757 
758  if( fileName == at( j ).Last()->GetFileName() )
759  return true;
760  }
761  }
762 
763  return false;
764 }
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 513 of file sch_sheet_path.cpp.

514 {
515  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
516  {
517  if( (*it).LastScreen() && (*it).LastScreen()->IsModify() )
518  return true;
519  }
520 
521  return false;
522 }
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER

Referenced by SCH_EDIT_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::ReCreateMenuBar(), and SCH_EDIT_FRAME::SyncToolbars().

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

735 {
736  bool found = false;
737 
738  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
739  found = (*it).SetComponentFootprint( aReference, aFootPrint, aSetVisible );
740 
741  return found;
742 }
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 767 of file sch_sheet_path.cpp.

769 {
770  wxFileName rootFn = g_RootSheet->GetFileName();
771  wxFileName destFn = aDestFileName;
772 
773  if( destFn.IsRelative() )
774  destFn.MakeAbsolute( rootFn.GetPath() );
775 
776  // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
777  for( unsigned i = 0; i < size(); i++ )
778  {
779  // Test each SCH_SHEET_PATH in the source sheet.
780  for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
781  {
782  const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
783 
784  for( unsigned k = 0; k < sheetPath->size(); k++ )
785  {
786  if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
787  aDestFileName ) )
788  return true;
789  }
790  }
791  }
792 
793  // The source sheet file can safely be added to the destination sheet file.
794  return false;
795 }
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
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:629
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::checkSheetForRecursion(), and SCH_EDITOR_CONTROL::Paste().

Member Data Documentation

◆ m_currentSheetPath

SCH_SHEET_PATH SCH_SHEET_LIST::m_currentSheetPath
private

Definition at line 385 of file sch_sheet_path.h.

Referenced by BuildSheetList().

◆ m_isRootSheet

bool SCH_SHEET_LIST::m_isRootSheet
private

Definition at line 384 of file sch_sheet_path.h.

Referenced by BuildSheetList(), and SCH_SHEET_LIST().


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