![]() |
KiCad PCB EDA Suite
|
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy. More...
#include <sch_sheet_path.h>
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_ITEM * | GetItem (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... | |
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_PATH * | FindSheetForScreen (const SCH_SCREEN *aScreen) |
Return a pointer to 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 | UpdateSymbolInstances (const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances) |
Update all of the symbol instance information using aSymbolInstances. More... | |
void | UpdateSheetInstances (const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances) |
Update all of the sheet instance information using aSheetInstances. More... | |
std::vector< KIID_PATH > | GetPaths () const |
std::vector< SCH_SHEET_INSTANCE > | GetSheetInstances () 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... | |
Private Attributes | |
SCH_SHEET_PATH | m_currentSheetPath |
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 409 of file sch_sheet_path.h.
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 528 of file sch_sheet_path.cpp.
References BuildSheetList(), SCH_SHEET::IsRootSheet(), and SortByPageNumbers().
|
inline |
Definition at line 419 of file sch_sheet_path.h.
bool SCH_SHEET_LIST::AllSheetPageNumbersEmpty | ( | ) | const |
Check all of the sheet instance for empty page numbers.
Definition at line 1016 of file sch_sheet_path.cpp.
References SCH_SHEET::GetPageNumber(), and SCH_SHEET_PATH::Last().
Referenced by BOOST_AUTO_TEST_CASE(), SCH_EDIT_FRAME::OpenProjectFiles(), and SetInitialPageNumbers().
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 713 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 TEST_SCH_SHEET_LIST_FIXTURE::loadSchematic(), TEST_NETLISTS_FIXTURE::loadSchematic(), DIALOG_ERC::OnRunERCClick(), SCH::readSchematicFromFile(), ReadSchematicFromFile(), SCH_EDIT_FRAME::ReadyToNetlist(), DIALOG_ERC::testErc(), and SCH_EDIT_FRAME::WriteNetListFile().
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.
aSheet | is the starting sheet from which the list is built, or NULL indicating that g_RootSheet should be used. |
std::bad_alloc | if the memory for the sheet path list could not be allocated. |
Definition at line 540 of file sch_sheet_path.cpp.
References 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 DIALOG_PLOT_SCHEMATIC::createDXFFiles(), DIALOG_PLOT_SCHEMATIC::createHPGLFiles(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::createPSFiles(), DIALOG_PLOT_SCHEMATIC::createSVGFiles(), SCHEMATIC::GetFullHierarchy(), and SCH_SHEET_LIST().
void SCH_SHEET_LIST::ClearModifyStatus | ( | ) |
Definition at line 643 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::LastScreen(), and BASE_SCREEN::SetContentModified().
Referenced by SCH_EDIT_FRAME::doCloseWindow().
Fill an item cache for temporary use when many items need to be fetched.
Definition at line 693 of file sch_sheet_path.cpp.
References SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), and EDA_ITEM::m_Uuid.
Referenced by DIALOG_ERC::writeReport().
SCH_SHEET_LIST 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.
Definition at line 887 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::LastScreen().
Referenced by SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDITOR_CONTROL::Paste(), and SCH_EDITOR_CONTROL::ReplaceAll().
SCH_SHEET_PATH * SCH_SHEET_LIST::FindSheetForScreen | ( | const SCH_SCREEN * | aScreen | ) |
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) using a particular screen.
Definition at line 875 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::LastScreen().
Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().
SCH_ITEM * SCH_SHEET_LIST::GetItem | ( | const KIID & | aID, |
SCH_SHEET_PATH * | aPathOut = nullptr |
||
) | const |
Fetch a SCH_ITEM by ID.
Also returns the sheet the item was found on in aPathOut.
Definition at line 653 of file sch_sheet_path.cpp.
References DELETED_SHEET_ITEM::GetInstance(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EDA_ITEM::m_Uuid, and SCH_ITEM::RunOnChildren().
Referenced by SCHEMATIC::ConvertKIIDsToRefs(), SCH_EDIT_FRAME::FocusOnItem(), SCH_EDIT_FRAME::GetItem(), DIALOG_ERC::OnERCItemSelected(), SCHEMATIC::ResolveCrossReference(), SCH_EDIT_FRAME::ResolveERCExclusions(), and SCH_EDIT_FRAME::SaveSymbolToSchematic().
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.
aRefList | Map of reference designators to reference lists |
aIncludePowerSymbols | Set to false to only get normal symbols. |
Definition at line 815 of file sch_sheet_path.cpp.
Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), BACK_ANNOTATE::BackAnnotateSymbols(), and ERC_TESTER::TestMultiunitFootprints().
std::vector< KIID_PATH > SCH_SHEET_LIST::GetPaths | ( | ) | const |
Definition at line 984 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::Path().
std::vector< SCH_SHEET_INSTANCE > SCH_SHEET_LIST::GetSheetInstances | ( | ) | const |
Fetch the instance information for all of the sheets in the hiearchy.
Definition at line 995 of file sch_sheet_path.cpp.
References SCH_SHEET::GetPageNumber(), SCH_SHEET_INSTANCE::m_PageNumber, SCH_SHEET_INSTANCE::m_Path, and path.
Referenced by SCH_SEXPR_PLUGIN::Format(), and DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged().
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.
aReferences | List of sheets to populate. |
aSheetPath | Path to return sheets from |
Definition at line 804 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::IsContainedWithin().
Referenced by SCH_SEXPR_PLUGIN::Format().
void SCH_SHEET_LIST::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.
aReferences | List of references to populate. |
aIncludePowerSymbols | Set to false to only get normal symbols. |
aForceIncludeOrphanSymbols | Set 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 783 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::GetSymbols().
Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), SCH_EDITOR_CONTROL::AssignFootprints(), BACK_ANNOTATE::BackAnnotateSymbols(), SCH_EDIT_FRAME::CheckAnnotate(), SCHEMATIC::ConvertRefsToKIIDs(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_EDIT_SYMBOLS_LIBID::initDlg(), SCH_EDIT_FRAME::mapExistingAnnotation(), DIALOG_TEXT_AND_LABEL_PROPERTIES::onScintillaCharAdded(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), and UpdateSymbolInstances().
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.
aReferences | List of references to populate. |
aSheetPath | Path to return symbols from |
aIncludePowerSymbols | Set to false to only get normal symbols. |
aForceIncludeOrphanSymbols | Set 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 791 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::GetSymbols(), and SCH_SHEET_PATH::IsContainedWithin().
Referenced by SCH_SEXPR_PLUGIN::Format().
bool SCH_SHEET_LIST::IsModified | ( | ) | const |
Check the entire hierarchy for any modifications.
Definition at line 631 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().
bool SCH_SHEET_LIST::NameExists | ( | const wxString & | aSheetName | ) | const |
Definition at line 607 of file sch_sheet_path.cpp.
References SCH_SHEET::GetName(), and SCH_SHEET_PATH::Last().
bool SCH_SHEET_LIST::PageNumberExists | ( | const wxString & | aPageNumber | ) | const |
Definition at line 619 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::GetPageNumber().
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 1032 of file sch_sheet_path.cpp.
References SCH_SHEET::AddInstance(), AllSheetPageNumbersEmpty(), SCH_SHEET_PATH::Last(), and SCH_SHEET::SetPageNumber().
Referenced by BOOST_AUTO_TEST_CASE(), and SCH_EDIT_FRAME::OpenProjectFiles().
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.
aUpdateVirtualPageNums | If true, updates the virtual page numbers to match the new ordering |
Definition at line 587 of file sch_sheet_path.cpp.
References SCH_SHEET_PATH::ComparePageNum(), and SCH_SHEET_PATH::SetVirtualPageNumber().
Referenced by DIALOG_PLOT_SCHEMATIC::createDXFFiles(), DIALOG_PLOT_SCHEMATIC::createHPGLFiles(), DIALOG_PLOT_SCHEMATIC::createPDFFile(), DIALOG_PLOT_SCHEMATIC::createPSFiles(), DIALOG_PLOT_SCHEMATIC::createSVGFiles(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_SEXPR_PLUGIN::Format(), SCH_EDITOR_CONTROL::Paste(), and SCH_SHEET_LIST().
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.
aSrcSheetHierarchy | is the SCH_SHEET_LIST of the source sheet add to aDestFileName. |
aDestFileName | is the file name of the destination sheet for aSrcFileName. |
Definition at line 835 of file sch_sheet_path.cpp.
References empty(), SCHEMATIC::GetFileName(), SCH_SHEET::GetFileName(), SCH_SHEET_PATH::GetSheet(), and SCH_SHEET_PATH::size().
Referenced by SCH_EDIT_FRAME::CheckSheetForRecursion().
void SCH_SHEET_LIST::UpdateSheetInstances | ( | const std::vector< SCH_SHEET_INSTANCE > & | aSheetInstances | ) |
Update all of the sheet instance information using aSheetInstances.
aSymbolInstances | is the symbol path information loaded from the root schematic. |
Definition at line 953 of file sch_sheet_path.cpp.
References SCH_SHEET::AddInstance(), SCH_SHEET::GetName(), path, r, SCH_SHEET::SetPageNumber(), and traceSchSheetPaths.
Referenced by TEST_SCH_SHEET_LIST_FIXTURE::loadSchematic(), DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged(), and SCH_EDIT_FRAME::OpenProjectFiles().
void SCH_SHEET_LIST::UpdateSymbolInstances | ( | const std::vector< SYMBOL_INSTANCE_REFERENCE > & | aSymbolInstances | ) |
Update all of the symbol instance information using aSymbolInstances.
WARNING: Do not call this on anything other than the full hierarchy.
aSymbolInstances | is the symbol path information loaded from the root schematic. |
Definition at line 901 of file sch_sheet_path.cpp.
References SCH_SYMBOL::AddHierarchicalReference(), SCH_REFERENCE_LIST::GetCount(), SCH_SYMBOL::GetField(), GetSymbols(), path, r, REFERENCE_FIELD, EDA_TEXT::SetText(), and traceSchSheetPaths.
Referenced by TEST_SCH_SHEET_LIST_FIXTURE::loadSchematic(), TEST_NETLISTS_FIXTURE::loadSchematic(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH::readSchematicFromFile(), and ReadSchematicFromFile().
|
private |
Definition at line 594 of file sch_sheet_path.h.
Referenced by BuildSheetList().