KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SCH_SHEET_LIST Class Reference

A container for handling SCH_SHEET_PATH objects in a flattened hierarchy. More...

#include <sch_sheet_path.h>

Inheritance diagram for SCH_SHEET_LIST:

Public Member Functions

 SCH_SHEET_LIST (SCH_SHEET *aSheet=nullptr, bool aCheckIntegrity=false)
 Construct a flattened list of SCH_SHEET_PATH objects from aSheet. More...
 
 ~SCH_SHEET_LIST ()
 
bool IsModified () const
 Check the entire hierarchy for any modifications. More...
 
void ClearModifyStatus ()
 
SCH_ITEMGetItem (const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
 Fetch a SCH_ITEM by ID. More...
 
void FillItemMap (std::map< KIID, EDA_ITEM * > &aMap)
 Fill an item cache for temporary use when many items need to be fetched. More...
 
void AnnotatePowerSymbols ()
 Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list. More...
 
void GetSymbols (SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
 Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets. More...
 
void GetSymbolsWithinPath (SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
 Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained within aSheetPath as well as recursively downwards inside aSheetPath. More...
 
void GetSheetsWithinPath (SCH_SHEET_PATHS &aSheets, const SCH_SHEET_PATH &aSheetPath) const
 Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPath as well as recursively downwards inside aSheetPath. More...
 
std::optional< SCH_SHEET_PATHGetSheetPathByKIIDPath (const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
 Finds a SCH_SHEET_PATH that matches the provided KIID_PATH. More...
 
void GetMultiUnitSymbols (SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
 Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the list of sheets. More...
 
bool TestForRecursion (const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
 Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHierarchy to the sheet stored in aDestFileName will cause recursion. More...
 
SCH_SHEET_PATHFindSheetForPath (const SCH_SHEET_PATH *aPath)
 Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) matching the provided path. More...
 
SCH_SHEET_PATH FindSheetForScreen (const SCH_SCREEN *aScreen)
 Return the first SCH_SHEET_PATH object (not necessarily the only one) using a particular screen. More...
 
SCH_SHEET_LIST FindAllSheetsForScreen (const SCH_SCREEN *aScreen) const
 Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen. More...
 
void BuildSheetList (SCH_SHEET *aSheet, bool aCheckIntegrity)
 Build the list of sheets and their sheet path from aSheet. More...
 
void SortByPageNumbers (bool aUpdateVirtualPageNums=true)
 Sort the list of sheets by page number. More...
 
bool NameExists (const wxString &aSheetName) const
 
bool PageNumberExists (const wxString &aPageNumber) const
 
void TrimToPageNumbers (const std::vector< wxString > &aPageInclusions)
 Truncates the list by removing sheet's with page numbers not in the given list. More...
 
void UpdateSymbolInstanceData (const std::vector< SCH_SYMBOL_INSTANCE > &aSymbolInstances)
 Update all of the symbol instance information using aSymbolInstances. More...
 
void UpdateSheetInstanceData (const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
 Update all of the sheet instance information using aSheetInstances. More...
 
std::vector< KIID_PATHGetPaths () const
 
std::vector< SCH_SHEET_INSTANCEGetSheetInstances () const
 Fetch the instance information for all of the sheets in the hiearchy. More...
 
bool AllSheetPageNumbersEmpty () const
 Check all of the sheet instance for empty page numbers. More...
 
void SetInitialPageNumbers ()
 Set initial sheet page numbers. More...
 
void AddNewSymbolInstances (const SCH_SHEET_PATH &aPrefixSheetPath)
 Attempt to add new symbol instances for all symbols in this list of sheet paths prefixed with aPrefixSheetPath. More...
 
void AddNewSheetInstances (const SCH_SHEET_PATH &aPrefixSheetPath, int aLastVirtualPageNumber)
 
int GetLastVirtualPageNumber () const
 
void RemoveSymbolInstances (const SCH_SHEET_PATH &aPrefixSheetPath)
 
bool HasPath (const KIID_PATH &aPath) const
 
bool ContainsSheet (const SCH_SHEET *aSheet) const
 

Public Attributes

SCH_SHEET_PATH elements
 STL member. More...
 

Private Attributes

SCH_SHEET_PATH m_currentSheetPath
 

Detailed Description

A container for handling 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 symbol references are specific to a sheet path. When a sheet is entered, symbol references and sheet page number are updated.

Definition at line 460 of file sch_sheet_path.h.

Constructor & Destructor Documentation

◆ SCH_SHEET_LIST()

SCH_SHEET_LIST::SCH_SHEET_LIST ( SCH_SHEET aSheet = nullptr,
bool  aCheckIntegrity = false 
)

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

References BuildSheetList(), SCH_SHEET::IsRootSheet(), and SortByPageNumbers().

◆ ~SCH_SHEET_LIST()

SCH_SHEET_LIST::~SCH_SHEET_LIST ( )
inline

Definition at line 470 of file sch_sheet_path.h.

Member Function Documentation

◆ AddNewSheetInstances()

◆ AddNewSymbolInstances()

void SCH_SHEET_LIST::AddNewSymbolInstances ( const SCH_SHEET_PATH aPrefixSheetPath)

Attempt to add new symbol instances for all symbols in this list of sheet paths prefixed with aPrefixSheetPath.

Parameters
aPrefixSheetPathis the sheet path to append the new symbol instances to.

Definition at line 1240 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::AddNewSymbolInstances().

Referenced by SCH_EDIT_FRAME::LoadSheetFromFile().

◆ AllSheetPageNumbersEmpty()

bool SCH_SHEET_LIST::AllSheetPageNumbersEmpty ( ) const

Check all of the sheet instance for empty page numbers.

Note
This should only return true when loading a legacy schematic or an s-expression schematic before version 20201005.
Returns
true if all sheet instance page numbers are not defined. Otherwise false.

Definition at line 1211 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::GetPageNumber().

Referenced by BOOST_AUTO_TEST_CASE(), SCH_EDIT_FRAME::OpenProjectFiles(), and SetInitialPageNumbers().

◆ AnnotatePowerSymbols()

void SCH_SHEET_LIST::AnnotatePowerSymbols ( )

Silently annotate 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 884 of file sch_sheet_path.cpp.

References SCH_REFERENCE_LIST::AddItem(), SCH_REFERENCE_LIST::Annotate(), SCH_REFERENCE_LIST::GetCount(), SCH_SYMBOL::GetLibSymbolRef(), LIB_SYMBOL::IsPower(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EE_RTREE::OfType(), SCH_SYMBOL_T, SCH_REFERENCE_LIST::SplitReferences(), and SCH_REFERENCE_LIST::UpdateAnnotation().

Referenced by KI_TEST::LoadSchematic(), EESCHEMA_HELPERS::LoadSchematic(), DIALOG_ERC::OnRunERCClick(), SCH::readSchematicFromFile(), SCH_EDIT_FRAME::ReadyToNetlist(), and SCH_EDIT_FRAME::WriteNetListFile().

◆ BuildSheetList()

void SCH_SHEET_LIST::BuildSheetList ( SCH_SHEET aSheet,
bool  aCheckIntegrity 
)

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

The list will be ordered as per SCH_SCREEN::GetSheets which results in sheets being ordered in the legacy way of using the X and Y positions of the sheets.

See also
SortByPageNumbers to sort by page numbers
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.

Definition at line 681 of file sch_sheet_path.cpp.

References BuildSheetList(), SCH_SHEET::GetFileName(), SCH_SCREEN::GetSheets(), SCH_SHEET_PATH::LastScreen(), m_currentSheetPath, SCH_SHEET_PATH::pop_back(), SCH_SHEET_PATH::push_back(), SCH_SCREEN::Remove(), BASE_SCREEN::SetContentModified(), SCH_SHEET_PATH::SetVirtualPageNumber(), and SCH_SHEET_PATH::TestForRecursion().

Referenced by BuildSheetList(), SCH_PLOTTER::createDXFFiles(), SCH_PLOTTER::createHPGLFiles(), SCH_PLOTTER::createPDFFile(), SCH_PLOTTER::createPSFiles(), SCH_PLOTTER::createSVGFiles(), SCHEMATIC::GetFullHierarchy(), and SCH_SHEET_LIST().

◆ ClearModifyStatus()

void SCH_SHEET_LIST::ClearModifyStatus ( )

◆ ContainsSheet()

bool SCH_SHEET_LIST::ContainsSheet ( const SCH_SHEET aSheet) const

Definition at line 1350 of file sch_sheet_path.cpp.

References path.

Referenced by SCH_EDITOR_CONTROL::updatePastedSheet().

◆ FillItemMap()

void SCH_SHEET_LIST::FillItemMap ( std::map< KIID, EDA_ITEM * > &  aMap)

Fill an item cache for temporary use when many items need to be fetched.

Definition at line 864 of file sch_sheet_path.cpp.

References SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), and EDA_ITEM::m_Uuid.

Referenced by ERC_REPORT::GetTextReport(), SCH_EDITOR_CONTROL::Paste(), and ERC_REPORT::WriteJsonReport().

◆ FindAllSheetsForScreen()

SCH_SHEET_LIST SCH_SHEET_LIST::FindAllSheetsForScreen ( const SCH_SCREEN aScreen) const

◆ FindSheetForPath()

SCH_SHEET_PATH * SCH_SHEET_LIST::FindSheetForPath ( const SCH_SHEET_PATH aPath)

Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) matching the provided path.

Returns nullptr if not found.

Definition at line 1064 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::Path(), and path.

Referenced by SCH_REFERENCE_LIST::ReannotateByOptions().

◆ FindSheetForScreen()

SCH_SHEET_PATH SCH_SHEET_LIST::FindSheetForScreen ( const SCH_SCREEN aScreen)

Return the first SCH_SHEET_PATH object (not necessarily the only one) using a particular screen.

Definition at line 1076 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::LastScreen().

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState(), and SCH_COMMIT::Revert().

◆ GetItem()

◆ GetLastVirtualPageNumber()

int SCH_SHEET_LIST::GetLastVirtualPageNumber ( ) const

◆ GetMultiUnitSymbols()

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

Add 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 symbols.

Definition at line 1004 of file sch_sheet_path.cpp.

Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), BACK_ANNOTATE::BackAnnotateSymbols(), ERC_TESTER::TestMissingUnits(), and ERC_TESTER::TestMultiunitFootprints().

◆ GetPaths()

std::vector< KIID_PATH > SCH_SHEET_LIST::GetPaths ( ) const

Definition at line 1176 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::Path().

◆ GetSheetInstances()

std::vector< SCH_SHEET_INSTANCE > SCH_SHEET_LIST::GetSheetInstances ( ) const

Fetch the instance information for all of the sheets in the hiearchy.

Returns
all of the sheet instance data for the hierarchy.

Definition at line 1187 of file sch_sheet_path.cpp.

References SCH_SHEET_INSTANCE::m_PageNumber, SCH_SHEET_INSTANCE::m_Path, SCH_SHEET_PATH::Path(), path, and SCH_SHEET_PATH::pop_back().

◆ GetSheetPathByKIIDPath()

std::optional< SCH_SHEET_PATH > SCH_SHEET_LIST::GetSheetPathByKIIDPath ( const KIID_PATH aPath,
bool  aIncludeLastSheet = true 
) const

◆ GetSheetsWithinPath()

void SCH_SHEET_LIST::GetSheetsWithinPath ( SCH_SHEET_PATHS aSheets,
const SCH_SHEET_PATH aSheetPath 
) const

Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPath as well as recursively downwards inside aSheetPath.

Parameters
aReferencesList of sheets to populate.
aSheetPathPath to return sheets from

Definition at line 975 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::IsContainedWithin().

Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), SCH_EDIT_FRAME::CheckAnnotate(), SCH_EDIT_FRAME::DeleteAnnotation(), and DIALOG_SYMBOL_FIELDS_TABLE::getSheetSymbolReferences().

◆ GetSymbols()

void SCH_SHEET_LIST::GetSymbols ( SCH_REFERENCE_LIST aReferences,
bool  aIncludePowerSymbols = true,
bool  aForceIncludeOrphanSymbols = false 
) const

◆ GetSymbolsWithinPath()

void SCH_SHEET_LIST::GetSymbolsWithinPath ( SCH_REFERENCE_LIST aReferences,
const SCH_SHEET_PATH aSheetPath,
bool  aIncludePowerSymbols = true,
bool  aForceIncludeOrphanSymbols = false 
) const

Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained within aSheetPath as well as recursively downwards inside aSheetPath.

Parameters
aReferencesList of references to populate.
aSheetPathPath to return symbols from
aIncludePowerSymbolsSet to false to only get normal symbols.
aForceIncludeOrphanSymbolsSet to true to include symbols having no symbol found in lib. The normal option is false, and set to true only to build the full list of symbols.

Definition at line 962 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::GetSymbols(), and SCH_SHEET_PATH::IsContainedWithin().

Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), and DIALOG_SYMBOL_FIELDS_TABLE::getSheetSymbolReferences().

◆ HasPath()

bool SCH_SHEET_LIST::HasPath ( const KIID_PATH aPath) const

Definition at line 1338 of file sch_sheet_path.cpp.

References path.

Referenced by DIALOG_CHANGE_SYMBOLS::getSymbolReferences(), and SCH_EDITOR_CONTROL::Paste().

◆ IsModified()

bool SCH_SHEET_LIST::IsModified ( ) const

Check the entire hierarchy for any modifications.

Returns
True if the hierarchy is modified otherwise false.

Definition at line 798 of file sch_sheet_path.cpp.

References BASE_SCREEN::IsContentModified(), and SCH_SHEET_PATH::LastScreen().

Referenced by SCH_EDIT_FRAME::canCloseWindow(), SCH_EDIT_FRAME::IsContentModified(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ NameExists()

bool SCH_SHEET_LIST::NameExists ( const wxString &  aSheetName) const

Definition at line 760 of file sch_sheet_path.cpp.

References SCH_SHEET::GetName(), and SCH_SHEET_PATH::Last().

Referenced by SCH_EDITOR_CONTROL::Paste().

◆ PageNumberExists()

bool SCH_SHEET_LIST::PageNumberExists ( const wxString &  aPageNumber) const

Definition at line 772 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::GetPageNumber().

Referenced by SCH_EDITOR_CONTROL::Paste().

◆ RemoveSymbolInstances()

void SCH_SHEET_LIST::RemoveSymbolInstances ( const SCH_SHEET_PATH aPrefixSheetPath)

Definition at line 1247 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::RemoveSymbolInstances().

◆ SetInitialPageNumbers()

void SCH_SHEET_LIST::SetInitialPageNumbers ( )

Set initial sheet page numbers.

The number scheme is base on the old pseudo sheet numbering algorithm prior to the implementation of user definable sheet page numbers.

Definition at line 1223 of file sch_sheet_path.cpp.

References AllSheetPageNumbersEmpty(), and SCH_SHEET_PATH::SetPageNumber().

Referenced by BOOST_AUTO_TEST_CASE(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ SortByPageNumbers()

void SCH_SHEET_LIST::SortByPageNumbers ( bool  aUpdateVirtualPageNums = true)

Sort the list of sheets by page number.

This should be called after BuildSheetList

If page numbers happen to be equal, then it compares the sheet names to ensure deterministic ordering.

Parameters
aUpdateVirtualPageNumsIf true, updates the virtual page numbers to match the new ordering

Enforce strict ordering. If the page numbers are the same, use UUIDs

Definition at line 733 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::ComparePageNum(), SCH_SHEET_PATH::GetCurrentHash(), and SCH_SHEET_PATH::SetVirtualPageNumber().

Referenced by SCH_PLOTTER::createDXFFiles(), SCH_PLOTTER::createHPGLFiles(), SCH_PLOTTER::createPDFFile(), SCH_PLOTTER::createPSFiles(), SCH_PLOTTER::createSVGFiles(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceSymbol(), and SCH_SHEET_LIST().

◆ TestForRecursion()

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

Test every SCH_SHEET_PATH in this 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 1024 of file sch_sheet_path.cpp.

References empty(), SCH_SHEET::GetFileName(), SCHEMATIC::GetFileName(), SCH_SHEET_PATH::GetSheet(), and SCH_SHEET_PATH::size().

Referenced by SCH_EDIT_FRAME::CheckSheetForRecursion(), and SCH_EDITOR_CONTROL::Paste().

◆ TrimToPageNumbers()

void SCH_SHEET_LIST::TrimToPageNumbers ( const std::vector< wxString > &  aPageInclusions)

Truncates the list by removing sheet's with page numbers not in the given list.

Parameters
aPageInclusionsList of Page Numbers (non-virtual) to keep

Definition at line 784 of file sch_sheet_path.cpp.

References SCH_SHEET_PATH::GetPageNumber().

Referenced by SCH_PLOTTER::createDXFFiles(), SCH_PLOTTER::createHPGLFiles(), SCH_PLOTTER::createPDFFile(), SCH_PLOTTER::createPSFiles(), and SCH_PLOTTER::createSVGFiles().

◆ UpdateSheetInstanceData()

void SCH_SHEET_LIST::UpdateSheetInstanceData ( const std::vector< SCH_SHEET_INSTANCE > &  aSheetInstances)

Update all of the sheet instance information using aSheetInstances.

Warning
Do not call this on anything other than the full hierarchy.
Parameters
aSymbolInstancesis the symbol path information loaded from the root schematic.

Definition at line 1146 of file sch_sheet_path.cpp.

References SCH_SHEET::GetName(), path, and traceSchSheetPaths.

Referenced by KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic(), KI_TEST::LoadSchematic(), EESCHEMA_HELPERS::LoadSchematic(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ UpdateSymbolInstanceData()

void SCH_SHEET_LIST::UpdateSymbolInstanceData ( const std::vector< SCH_SYMBOL_INSTANCE > &  aSymbolInstances)

Member Data Documentation

◆ elements

SCH_SHEET_PATH std::vector< SCH_SHEET_PATH >::elements
inherited

STL member.

◆ m_currentSheetPath

SCH_SHEET_PATH SCH_SHEET_LIST::m_currentSheetPath
private

Definition at line 687 of file sch_sheet_path.h.

Referenced by BuildSheetList().


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