KiCad PCB EDA Suite
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) 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_PATHFindSheetForScreen (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_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)
 
void MigrateSimModelNameFields ()
 Migrate V6 simulator models to V7. More...
 

Private Member Functions

void migrateSimModel (SCH_SYMBOL &aSymbol, unsigned aSheetIndex)
 Migrate a single V6 simulator model to V7. 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 456 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 679 of file sch_sheet_path.cpp.

680{
681 if( aSheet != nullptr )
682 {
683 BuildSheetList( aSheet, aCheckIntegrity );
684
685 if( aSheet->IsRootSheet() )
687 }
688}
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
bool IsRootSheet() const
Definition: sch_sheet.cpp:194

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

◆ ~SCH_SHEET_LIST()

SCH_SHEET_LIST::~SCH_SHEET_LIST ( )
inline

Definition at line 466 of file sch_sheet_path.h.

466{}

Member Function Documentation

◆ AddNewSheetInstances()

void SCH_SHEET_LIST::AddNewSheetInstances ( const SCH_SHEET_PATH aPrefixSheetPath,
int  aLastVirtualPageNumber 
)

Definition at line 1232 of file sch_sheet_path.cpp.

1234{
1235 int nextVirtualPageNumber = aLastVirtualPageNumber + 1;
1236
1237 for( SCH_SHEET_PATH& sheetPath : *this )
1238 nextVirtualPageNumber = sheetPath.AddNewSheetInstances( aPrefixSheetPath,
1239 nextVirtualPageNumber );
1240}
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
int AddNewSheetInstances(const SCH_SHEET_PATH &aPrefixSheetPath, int aNextVirtualPageNumber)

References SCH_SHEET_PATH::AddNewSheetInstances().

Referenced by SCH_EDIT_FRAME::LoadSheetFromFile().

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

1219{
1220 for( SCH_SHEET_PATH& sheetPath : *this )
1221 sheetPath.AddNewSymbolInstances( aPrefixSheetPath );
1222}
void AddNewSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
Attempt to add new symbol instances for all symbols in this sheet path prefixed with aPrefixSheetPath...

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

1190{
1191 for( const SCH_SHEET_PATH& instance : *this )
1192 {
1193 if( !instance.GetPageNumber().IsEmpty() )
1194 return false;
1195 }
1196
1197 return true;
1198}
wxString GetPageNumber() const

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

872{
873 // List of reference for power symbols
874 SCH_REFERENCE_LIST references;
875 SCH_REFERENCE_LIST additionalreferences; // Todo: add as a parameter to this function
876
877 // Map of locked symbols (not used, but needed by Annotate()
878 SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
879
880 // Build the list of power symbols:
881 for( SCH_SHEET_PATH& sheet : *this )
882 {
883 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
884 {
885 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
886 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
887
888 if( libSymbol && libSymbol->IsPower() )
889 {
890 SCH_REFERENCE schReference( symbol, libSymbol, sheet );
891 references.AddItem( schReference );
892 }
893 }
894 }
895
896 // Find duplicate, and silently clear annotation of duplicate
897 std::map<wxString, int> ref_list; // stores the existing references
898
899 for( unsigned ii = 0; ii< references.GetCount(); ++ii )
900 {
901 wxString curr_ref = references[ii].GetRef();
902
903 if( ref_list.find( curr_ref ) == ref_list.end() )
904 {
905 ref_list[curr_ref] = ii;
906 continue;
907 }
908
909 // Possible duplicate, if the ref ends by a number:
910 if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
911 continue; // not annotated
912
913 // Duplicate: clear annotation by removing the number ending the ref
914 while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
915 curr_ref.RemoveLast();
916
917 references[ii].SetRef( curr_ref );
918 }
919
920 // Break full symbol reference into name (prefix) and number:
921 // example: IC1 become IC, and 1
922 references.SplitReferences();
923
924 // Ensure all power symbols have the reference starting by '#'
925 // (Not sure this is really useful)
926 for( unsigned ii = 0; ii< references.GetCount(); ++ii )
927 {
928 if( references[ii].GetRef()[0] != '#' )
929 {
930 wxString new_ref = "#" + references[ii].GetRef();
931 references[ii].SetRef( new_ref );
932 }
933 }
934
935 // Recalculate and update reference numbers in schematic
936 references.Annotate( false, 0, 100, lockedSymbols, additionalreferences );
937 references.UpdateAnnotation();
938}
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
Define a library symbol object.
Definition: lib_symbol.h:98
bool IsPower() const
Definition: lib_symbol.cpp:552
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent=false)
Set the reference designators in the list that have not been annotated.
size_t GetCount() const
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void AddItem(const SCH_REFERENCE &aItem)
void UpdateAnnotation()
Update the symbol references for the schematic project (or the current sheet).
A helper to define a symbol's reference designator in a schematic.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
SCH_SCREEN * LastScreen()
Schematic symbol object.
Definition: sch_symbol.h:80
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:191
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
@ SCH_SYMBOL_T
Definition: typeinfo.h:156

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(), DIALOG_ERC::testErc(), 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 691 of file sch_sheet_path.cpp.

692{
693 wxCHECK_RET( aSheet != nullptr, wxT( "Cannot build sheet list from undefined sheet." ) );
694
695 std::vector<SCH_SHEET*> badSheets;
696
698 m_currentSheetPath.SetVirtualPageNumber( static_cast<int>( size() ) + 1 );
699 push_back( m_currentSheetPath );
700
702 {
703 wxString parentFileName = aSheet->GetFileName();
704 std::vector<SCH_ITEM*> childSheets;
705 m_currentSheetPath.LastScreen()->GetSheets( &childSheets );
706
707 for( SCH_ITEM* item : childSheets )
708 {
709 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
710
711 if( aCheckIntegrity )
712 {
713 if( !m_currentSheetPath.TestForRecursion( sheet->GetFileName(), parentFileName ) )
714 BuildSheetList( sheet, true );
715 else
716 badSheets.push_back( sheet );
717 }
718 else
719 {
720 BuildSheetList( sheet, false );
721 }
722 }
723 }
724
725 if( aCheckIntegrity )
726 {
727 for( SCH_SHEET* sheet : badSheets )
728 {
731 }
732 }
733
735}
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:268
void GetSheets(std::vector< SCH_ITEM * > *aItems) const
Similar to Items().OfType( SCH_SHEET_T ), but return the sheets in a deterministic order (L-R,...
SCH_SHEET_PATH m_currentSheetPath
bool TestForRecursion(const wxString &aSrcFileName, const wxString &aDestFileName)
Test the SCH_SHEET_PATH file names to check adding the sheet stored in the file aSrcFileName to the s...
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:300

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

Definition at line 801 of file sch_sheet_path.cpp.

802{
803 for( const SCH_SHEET_PATH& sheet : *this )
804 {
805 if( sheet.LastScreen() )
806 sheet.LastScreen()->SetContentModified( false );
807 }
808}

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

Referenced by SCH_EDIT_FRAME::doCloseWindow().

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

852{
853 for( const SCH_SHEET_PATH& sheet : *this )
854 {
855 SCH_SCREEN* screen = sheet.LastScreen();
856
857 for( SCH_ITEM* aItem : screen->Items() )
858 {
859 aMap[ aItem->m_Uuid ] = aItem;
860
861 aItem->RunOnChildren(
862 [&]( SCH_ITEM* aChild )
863 {
864 aMap[ aChild->m_Uuid ] = aChild;
865 } );
866 }
867 }
868}
const KIID m_Uuid
Definition: eda_item.h:494

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

Referenced by SCH_EDITOR_CONTROL::Paste(), and DIALOG_ERC::writeReport().

◆ FindAllSheetsForScreen()

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

1070{
1071 SCH_SHEET_LIST retval;
1072
1073 for( const SCH_SHEET_PATH& sheetpath : *this )
1074 {
1075 if( sheetpath.LastScreen() == aScreen )
1076 retval.push_back( sheetpath );
1077 }
1078
1079 return retval;
1080}
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.

References SCH_SHEET_PATH::LastScreen().

Referenced by SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceSymbol(), and SCH_EDITOR_CONTROL::ReplaceAll().

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

1046{
1047 for( SCH_SHEET_PATH& path : *this )
1048 {
1049 if( path.Path() == aPath->Path() )
1050 return &path;
1051 }
1052
1053 return nullptr;
1054}
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.

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 a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) using a particular screen.

Definition at line 1057 of file sch_sheet_path.cpp.

1058{
1059 for( SCH_SHEET_PATH& sheetpath : *this )
1060 {
1061 if( sheetpath.LastScreen() == aScreen )
1062 return &sheetpath;
1063 }
1064
1065 return nullptr;
1066}

References SCH_SHEET_PATH::LastScreen().

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

◆ GetItem()

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

812{
813 for( const SCH_SHEET_PATH& sheet : *this )
814 {
815 SCH_SCREEN* screen = sheet.LastScreen();
816
817 for( SCH_ITEM* aItem : screen->Items() )
818 {
819 if( aItem->m_Uuid == aID )
820 {
821 if( aPathOut )
822 *aPathOut = sheet;
823
824 return aItem;
825 }
826
827 SCH_ITEM* childMatch = nullptr;
828
829 aItem->RunOnChildren(
830 [&]( SCH_ITEM* aChild )
831 {
832 if( aChild->m_Uuid == aID )
833 childMatch = aChild;
834 } );
835
836 if( childMatch )
837 {
838 if( aPathOut )
839 *aPathOut = sheet;
840
841 return childMatch;
842 }
843 }
844 }
845
846 // Not found; weak reference has been deleted.
848}
static DELETED_SHEET_ITEM * GetInstance()
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444

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(), TEST_SCH_REFERENCE_LIST_FIXTURE::getSymbolByKIID(), DIALOG_ERC::OnERCItemSelected(), SCHEMATIC::ResolveCrossReference(), SCH_EDIT_FRAME::ResolveERCExclusions(), and SCH_EDIT_FRAME::SaveSymbolToSchematic().

◆ GetLastVirtualPageNumber()

int SCH_SHEET_LIST::GetLastVirtualPageNumber ( ) const

Definition at line 1243 of file sch_sheet_path.cpp.

1244{
1245 int lastVirtualPageNumber = 1;
1246
1247 for( const SCH_SHEET_PATH& sheetPath : *this )
1248 {
1249 if( sheetPath.GetVirtualPageNumber() > lastVirtualPageNumber )
1250 lastVirtualPageNumber = sheetPath.GetVirtualPageNumber();
1251 }
1252
1253 return lastVirtualPageNumber;
1254}
int GetVirtualPageNumber() const

References SCH_SHEET_PATH::GetVirtualPageNumber().

Referenced by SCH_EDIT_FRAME::LoadSheetFromFile().

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

987{
988 for( SCH_SHEET_PATHS::const_iterator it = begin(); it != end(); ++it )
989 {
991 ( *it ).GetMultiUnitSymbols( tempMap, aIncludePowerSymbols );
992
993 for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
994 {
995 // Merge this list into the main one
996 unsigned n_refs = pair.second.GetCount();
997
998 for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
999 aRefList[pair.first].AddItem( pair.second[thisRef] );
1000 }
1001 }
1002}

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

1155{
1156 std::vector<KIID_PATH> paths;
1157
1158 for( const SCH_SHEET_PATH& sheetPath : *this )
1159 paths.emplace_back( sheetPath.Path() );
1160
1161 return paths;
1162}

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

1166{
1167 std::vector<SCH_SHEET_INSTANCE> retval;
1168
1169 for( const SCH_SHEET_PATH& path : *this )
1170 {
1171 const SCH_SHEET* sheet = path.Last();
1172
1173 wxCHECK2( sheet, continue );
1174
1175 SCH_SHEET_INSTANCE instance;
1176 SCH_SHEET_PATH tmpPath = path;
1177
1178 tmpPath.pop_back();
1179 instance.m_Path = tmpPath.Path();
1180 instance.m_PageNumber = path.GetPageNumber();
1181
1182 retval.push_back( instance );
1183 }
1184
1185 return retval;
1186}
A simple container for sheet instance information.

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

Referenced by SCH_SEXPR_PLUGIN::Format(), and DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged().

◆ GetSheetPathByKIIDPath()

std::optional< SCH_SHEET_PATH > SCH_SHEET_LIST::GetSheetPathByKIIDPath ( const KIID_PATH aPath) const

Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.

Parameters
aPathThe KIID_PATH to search for.

Definition at line 973 of file sch_sheet_path.cpp.

974{
975 for( const SCH_SHEET_PATH& sheet : *this )
976 {
977 if( sheet.Path() == aPath )
978 return SCH_SHEET_PATH( sheet );
979 }
980
981 return std::nullopt;
982}

References SCH_SHEET_PATH::Path().

Referenced by findItemsFromSyncSelection(), SCH_SEXPR_PLUGIN::saveSheet(), and SCH_SEXPR_PLUGIN::saveSymbol().

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

964{
965 for( const SCH_SHEET_PATH& sheet : *this )
966 {
967 if( sheet.IsContainedWithin( aSheetPath ) )
968 aSheets.push_back( sheet );
969 }
970}
bool IsContainedWithin(const SCH_SHEET_PATH &aSheetPathToTest) const
Check if this path is contained inside aSheetPathToTest.

References SCH_SHEET_PATH::IsContainedWithin().

Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), SCH_EDIT_FRAME::CheckAnnotate(), SCH_EDIT_FRAME::DeleteAnnotation(), and SCH_SEXPR_PLUGIN::Format().

◆ GetSymbols()

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.

Parameters
aReferencesList of references to populate.
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 941 of file sch_sheet_path.cpp.

943{
944 for( const SCH_SHEET_PATH& sheet : *this )
945 sheet.GetSymbols( aReferences, aIncludePowerSymbols, aForceIncludeOrphanSymbols );
946}
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.

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(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), TEST_SCH_REFERENCE_LIST_FIXTURE::getAdditionalRefs(), DIALOG_EDIT_SYMBOLS_LIBID::initDlg(), EESCHEMA_JOBS_HANDLER::JobExportNetlist(), EESCHEMA_JOBS_HANDLER::JobExportPythonBom(), SCH_EDIT_FRAME::mapExistingAnnotation(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), DIALOG_TEXT_PROPERTIES::onScintillaCharAdded(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceSymbol(), and SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile().

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

953{
954 for( const SCH_SHEET_PATH& sheet : *this )
955 {
956 if( sheet.IsContainedWithin( aSheetPath ) )
957 sheet.GetSymbols( aReferences, aIncludePowerSymbols, aForceIncludeOrphanSymbols );
958 }
959}

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

Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), and SCH_SEXPR_PLUGIN::Format().

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

790{
791 for( const SCH_SHEET_PATH& sheet : *this )
792 {
793 if( sheet.LastScreen() && sheet.LastScreen()->IsContentModified() )
794 return true;
795 }
796
797 return false;
798}
bool IsContentModified() const
Definition: base_screen.h:60

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

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

◆ migrateSimModel()

void SCH_SHEET_LIST::migrateSimModel ( SCH_SYMBOL aSymbol,
unsigned  aSheetIndex 
)
private

Migrate a single V6 simulator model to V7.

Must be called only after UpdateSymbolInstances().

Definition at line 1285 of file sch_sheet_path.cpp.

1286{
1288 || aSymbol.FindField( SIM_MODEL::TYPE_FIELD )
1289 || aSymbol.FindField( SIM_MODEL::PINS_FIELD )
1290 || aSymbol.FindField( SIM_MODEL::PARAMS_FIELD ) )
1291 {
1292 // Has a V7 model field -- skip.
1293 return;
1294 }
1295
1296 wxString ref = aSymbol.GetRef( &at( aSheetIndex ), true );
1297 wxString value = aSymbol.GetValueFieldText( true );
1298
1299 wxString spiceType;
1300 wxString spiceModel;
1301 wxString spiceLib;
1302 wxString pinMap;
1303
1304 if( aSymbol.FindField( "Spice_Primitive" )
1305 || aSymbol.FindField( "Spice_Node_Sequence" )
1306 || aSymbol.FindField( "Spice_Model" )
1307 || aSymbol.FindField( "Spice_Netlist_Enabled" )
1308 || aSymbol.FindField( "Spice_Lib_File" ) )
1309 {
1310 if( SCH_FIELD* primitiveField = aSymbol.FindField( "Spice_Primitive" ) )
1311 {
1312 spiceType = primitiveField->GetText();
1313 aSymbol.RemoveField( "Spice_Primitive" );
1314 }
1315
1316 if( SCH_FIELD* nodeSequenceField = aSymbol.FindField( "Spice_Node_Sequence" ) )
1317 {
1318 const wxString delimiters( "{:,; }" );
1319 const wxString& nodeSequence = nodeSequenceField->GetText();
1320
1321 if( nodeSequence != "" )
1322 {
1323 wxStringTokenizer tkz( nodeSequence, delimiters );
1324
1325 for( long modelPinNumber = 1; tkz.HasMoreTokens(); ++modelPinNumber )
1326 {
1327 long symbolPinNumber = 1;
1328 tkz.GetNextToken().ToLong( &symbolPinNumber );
1329
1330 if( modelPinNumber != 1 )
1331 pinMap.Append( " " );
1332
1333 pinMap.Append( wxString::Format( "%ld=%ld", symbolPinNumber, modelPinNumber ) );
1334 }
1335 }
1336
1337 aSymbol.RemoveField( "Spice_Node_Sequence" );
1338 }
1339
1340 if( SCH_FIELD* modelField = aSymbol.FindField( "Spice_Model" ) )
1341 {
1342 spiceModel = modelField->GetText();
1343 aSymbol.RemoveField( "Spice_Model" );
1344 }
1345 else
1346 spiceModel = aSymbol.FindField( "Value" )->GetText();
1347
1348 if( SCH_FIELD* netlistEnabledField = aSymbol.FindField( "Spice_Netlist_Enabled" ) )
1349 {
1350 wxString netlistEnabled = netlistEnabledField->GetText().Lower();
1351
1352 if( netlistEnabled.StartsWith( "0" )
1353 || netlistEnabled.StartsWith( "n" )
1354 || netlistEnabled.StartsWith( "f" ) )
1355 {
1356 SCH_FIELD enableField( VECTOR2I( 0, 0 ), aSymbol.GetFieldCount(), &aSymbol,
1358 }
1359 }
1360
1361 if( SCH_FIELD* libFileField = aSymbol.FindField( "Spice_Lib_File" ) )
1362 {
1363 spiceLib = libFileField->GetText();
1364 aSymbol.RemoveField( "Spice_Lib_File" );
1365 }
1366 }
1367 else if( ref.StartsWith( "R" ) || ref.StartsWith( "L" ) || ref.StartsWith( "C" ) )
1368 {
1369 wxRegEx passiveVal(
1370 wxT( "^([0-9\\. ]+)([fFpPnNuUmMkKgGtTμµ𝛍𝜇𝝁 ]|M(e|E)(g|G))?([fFhHΩΩ𝛀𝛺𝝮]|ohm)?([-1-9 ]*)$" ) );
1371
1372 if( !passiveVal.Matches( value ) )
1373 return;
1374
1375 wxString prefix( passiveVal.GetMatch( value, 1 ) );
1376 wxString unit( passiveVal.GetMatch( value, 2 ) );
1377 wxString suffix( passiveVal.GetMatch( value, 6 ) );
1378
1379 if( unit == "M" )
1380 unit = "Meg";
1381
1382 spiceModel = prefix + unit;
1383 }
1384 else if( ref.StartsWith( "V" ) || ref.StartsWith( "I" ) )
1385 spiceModel = value;
1386 else
1387 return;
1388
1389 // Insert a plaintext model as a substitute.
1390
1391 SCH_FIELD deviceTypeField( VECTOR2I( 0, 0 ), aSymbol.GetFieldCount(), &aSymbol,
1393 deviceTypeField.SetText(
1394 SIM_MODEL::DeviceInfo( SIM_MODEL::DEVICE_TYPE_::SPICE ).fieldValue );
1395 aSymbol.AddField( deviceTypeField );
1396
1397 SCH_FIELD paramsField( VECTOR2I( 0, 0 ), aSymbol.GetFieldCount(), &aSymbol,
1399 paramsField.SetText( wxString::Format( "type=\"%s\" model=\"%s\" lib=\"%s\"",
1400 spiceType, spiceModel, spiceLib ) );
1401 aSymbol.AddField( paramsField );
1402
1403 // Legacy models by default get linear pin mapping.
1404 if( pinMap != "" )
1405 {
1406 SCH_FIELD pinsField( VECTOR2I( 0, 0 ), aSymbol.GetFieldCount(), &aSymbol,
1408
1409 pinsField.SetText( pinMap );
1410 aSymbol.AddField( pinsField );
1411 }
1412 else
1413 {
1414 wxString pins;
1415
1416 for( unsigned i = 0; i < aSymbol.GetLibPins().size(); ++i )
1417 {
1418 if( i != 0 )
1419 pins.Append( " " );
1420
1421 pins.Append( wxString::Format( "%u=%u", i + 1, i + 1 ) );
1422 }
1423
1424 SCH_FIELD pinsField( VECTOR2I( 0, 0 ), aSymbol.GetFieldCount(), &aSymbol,
1426 pinsField.SetText( pins );
1427 aSymbol.AddField( pinsField );
1428 }
1429}
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:50
void GetLibPins(std::vector< LIB_PIN * > &aPinsList) const
Populate a vector with all the pins from the library object.
Definition: sch_symbol.cpp:966
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:478
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
Definition: sch_symbol.cpp:861
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:848
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:624
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:758
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:839
static constexpr auto ENABLE_FIELD
Definition: sim_model.h:61
static DEVICE_INFO DeviceInfo(DEVICE_TYPE_ aDeviceType)
Definition: sim_model.cpp:55
static constexpr auto DEVICE_TYPE_FIELD
Definition: sim_model.h:57
static constexpr auto TYPE_FIELD
Definition: sim_model.h:58
static constexpr auto PARAMS_FIELD
Definition: sim_model.h:60
static constexpr auto PINS_FIELD
Definition: sim_model.h:59
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References SCH_SYMBOL::AddField(), SIM_MODEL::DEVICE_TYPE_FIELD, SIM_MODEL::DeviceInfo(), SIM_MODEL::ENABLE_FIELD, SCH_SYMBOL::FindField(), Format(), SCH_SYMBOL::GetFieldCount(), SCH_SYMBOL::GetLibPins(), SCH_SYMBOL::GetRef(), EDA_TEXT::GetText(), SCH_SYMBOL::GetValueFieldText(), SIM_MODEL::PARAMS_FIELD, SIM_MODEL::PINS_FIELD, SCH_SYMBOL::RemoveField(), EDA_TEXT::SetText(), and SIM_MODEL::TYPE_FIELD.

Referenced by MigrateSimModelNameFields().

◆ MigrateSimModelNameFields()

void SCH_SHEET_LIST::MigrateSimModelNameFields ( )

Migrate V6 simulator models to V7.

Must be called only after UpdateSymbolInstances().

Definition at line 1257 of file sch_sheet_path.cpp.

1258{
1259 LOCALE_IO toggle;
1260
1261 for( unsigned sheetIndex = 0; sheetIndex < size(); ++sheetIndex )
1262 {
1263 SCH_SCREEN* screen = at( sheetIndex ).LastScreen();
1264
1265 // V6 schematics may specify model names in Value fields, which we don't do in V7.
1266 // Migrate by adding an equivalent model for these symbols.
1267
1268 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1269 {
1270 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1271
1272 if( !symbol )
1273 {
1274 // Shouldn't happen.
1275 wxFAIL;
1276 continue;
1277 }
1278
1279 migrateSimModel( *symbol, sheetIndex );
1280 }
1281 }
1282}
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
void migrateSimModel(SCH_SYMBOL &aSymbol, unsigned aSheetIndex)
Migrate a single V6 simulator model to V7.

References SCH_SCREEN::Items(), migrateSimModel(), EE_RTREE::OfType(), and SCH_SYMBOL_T.

Referenced by UpdateSymbolInstances().

◆ NameExists()

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

Definition at line 765 of file sch_sheet_path.cpp.

766{
767 for( const SCH_SHEET_PATH& sheet : *this )
768 {
769 if( sheet.Last()->GetName() == aSheetName )
770 return true;
771 }
772
773 return false;
774}
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
wxString GetName() const
Definition: sch_sheet.h:101

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

778{
779 for( const SCH_SHEET_PATH& sheet : *this )
780 {
781 if( sheet.GetPageNumber() == aPageNumber )
782 return true;
783 }
784
785 return false;
786}

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

1226{
1227 for( SCH_SHEET_PATH& sheetPath : *this )
1228 sheetPath.RemoveSymbolInstances( aPrefixSheetPath );
1229}
void RemoveSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)

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

1202{
1203 // Don't accidentally renumber existing sheets.
1204 wxCHECK( AllSheetPageNumbersEmpty(), /* void */ );
1205
1206 wxString tmp;
1207 int pageNumber = 1;
1208
1209 for( SCH_SHEET_PATH& instance : *this )
1210 {
1211 tmp.Printf( "%d", pageNumber );
1212 instance.SetPageNumber( tmp );
1213 pageNumber += 1;
1214 }
1215}
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.

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

739{
740 std::sort( begin(), end(),
741 []( SCH_SHEET_PATH a, SCH_SHEET_PATH b ) -> bool
742 {
743 int retval = a.ComparePageNum( b );
744
745 if( retval < 0 )
746 return true;
747 else if( retval > 0 )
748 return false;
749 else
750 return a.GetCurrentHash() < b.GetCurrentHash();
751 } );
752
753 if( aUpdateVirtualPageNums )
754 {
755 int virtualPageNum = 1;
756
757 for( SCH_SHEET_PATH& sheet : *this )
758 {
759 sheet.SetVirtualPageNumber( virtualPageNum++ );
760 }
761 }
762}
int ComparePageNum(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare sheets by their page number.
size_t GetCurrentHash() const

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_DRAWING_TOOLS::DrawSheet(), SCH_SEXPR_PLUGIN::Format(), 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 1005 of file sch_sheet_path.cpp.

1007{
1008 if( empty() )
1009 return false;
1010
1011 SCHEMATIC* sch = at( 0 ).LastScreen()->Schematic();
1012
1013 wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_LIST::TestForRecursion!" );
1014
1015 wxFileName rootFn = sch->GetFileName();
1016 wxFileName destFn = aDestFileName;
1017
1018 if( destFn.IsRelative() )
1019 destFn.MakeAbsolute( rootFn.GetPath() );
1020
1021 // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
1022 for( unsigned i = 0; i < size(); i++ )
1023 {
1024 // Test each SCH_SHEET_PATH in the source sheet.
1025 for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
1026 {
1027 const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
1028
1029 for( unsigned k = 0; k < sheetPath->size(); k++ )
1030 {
1031 if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
1032 aDestFileName ) )
1033 {
1034 return true;
1035 }
1036 }
1037 }
1038 }
1039
1040 // The source sheet file can safely be added to the destination sheet file.
1041 return false;
1042}
Holds all the data relating to one schematic.
Definition: schematic.h:61
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:166
const SCH_SHEET * GetSheet(unsigned aIndex) const
size_t size() const
Forwarded method from std::vector.
static bool empty(const wxTextEntryBase *aCtrl)

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

◆ UpdateSheetInstances()

void SCH_SHEET_LIST::UpdateSheetInstances ( 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 1124 of file sch_sheet_path.cpp.

1125{
1126
1127 for( SCH_SHEET_PATH& path : *this )
1128 {
1129 SCH_SHEET* sheet = path.Last();
1130
1131 wxCHECK2( sheet && path.Last(), continue );
1132
1133 auto it = std::find_if( aSheetInstances.begin(), aSheetInstances.end(),
1134 [ path ]( const SCH_SHEET_INSTANCE& r ) -> bool
1135 {
1136 return path.Path() == r.m_Path;
1137 } );
1138
1139 if( it == aSheetInstances.end() )
1140 {
1141 wxLogTrace( traceSchSheetPaths, "No sheet instance found for path '%s'",
1142 path.Path().AsString() );
1143 continue;
1144 }
1145
1146 wxLogTrace( traceSchSheetPaths, "Setting sheet '%s' instance '%s' page number '%s'",
1147 ( sheet->GetName().IsEmpty() ) ? wxT( "root" ) : sheet->GetName(),
1148 path.Path().AsString(), it->m_PageNumber );
1149 path.SetPageNumber( it->m_PageNumber );
1150 }
1151}
E_SERIE r
Definition: eserie.cpp:41
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.

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

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

◆ UpdateSymbolInstances()

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.

Parameters
aSymbolInstancesis the symbol path information loaded from the root schematic.

Definition at line 1083 of file sch_sheet_path.cpp.

1085{
1086 for( SCH_SHEET_PATH& sheetPath : *this )
1087 {
1088 for( SCH_ITEM* item : sheetPath.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1089 {
1090 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1091
1092 wxCHECK2( symbol, continue );
1093
1094 KIID_PATH sheetPathWithSymbolUuid = sheetPath.Path();
1095 sheetPathWithSymbolUuid.push_back( symbol->m_Uuid );
1096
1097 auto it = std::find_if( aSymbolInstances.begin(), aSymbolInstances.end(),
1098 [ sheetPathWithSymbolUuid ]( const SYMBOL_INSTANCE_REFERENCE& r ) -> bool
1099 {
1100 return sheetPathWithSymbolUuid == r.m_Path;
1101 } );
1102
1103 if( it == aSymbolInstances.end() )
1104 {
1105 wxLogTrace( traceSchSheetPaths, "No symbol instance found for symbol '%s'",
1106 sheetPathWithSymbolUuid.AsString() );
1107 continue;
1108 }
1109
1110 // Symbol instance paths are stored and looked up in memory with the root path so use
1111 // the full path here.
1112 symbol->AddHierarchicalReference( sheetPath.Path(), it->m_Reference, it->m_Unit );
1113 symbol->GetField( REFERENCE_FIELD )->SetText( it->m_Reference );
1114 symbol->SetValueFieldText( it->m_Value );
1115 symbol->SetFootprintFieldText( it->m_Footprint );
1116 }
1117 }
1118
1119 if( size() >= 1 && at( 0 ).LastScreen()->GetFileFormatVersionAtLoad() < 20220622 )
1121}
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
wxString AsString() const
Definition: kiid.cpp:332
void MigrateSimModelNameFields()
Migrate V6 simulator models to V7.
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:767
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:788
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:782
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:522
A simple container for schematic symbol instance information.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".

References SCH_SYMBOL::AddHierarchicalReference(), KIID_PATH::AsString(), SCH_SYMBOL::GetField(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EDA_ITEM::m_Uuid, MigrateSimModelNameFields(), EE_RTREE::OfType(), SCH_SHEET_PATH::Path(), r, REFERENCE_FIELD, SCH_SYMBOL_T, SCH_SYMBOL::SetFootprintFieldText(), EDA_TEXT::SetText(), SCH_SYMBOL::SetValueFieldText(), and traceSchSheetPaths.

Referenced by KI_TEST::LoadSchematic(), EESCHEMA_HELPERS::LoadSchematic(), SCH_EDIT_FRAME::LoadSheetFromFile(), DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged(), SCH_EDIT_FRAME::OpenProjectFiles(), and SCH::readSchematicFromFile().

Member Data Documentation

◆ m_currentSheetPath

SCH_SHEET_PATH SCH_SHEET_LIST::m_currentSheetPath
private

Definition at line 681 of file sch_sheet_path.h.

Referenced by BuildSheetList().


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