40#include <wx/filename.h>
58 return _(
"(Deleted Item)" );
63 return wxT(
"DELETED_SHEET_ITEM" );
94 void Show(
int , std::ostream& )
const override {}
143 return path.GetCurrentHash();
150 if( aSuffix.IsEmpty() || aRef.length() <= aSuffix.length() || !aRef.EndsWith( aSuffix )
151 || aRef.EndsWith( wxS(
"?" ) ) )
156 aRef.RemoveLast( aSuffix.length() );
184 m_sheets = std::move( aOther.m_sheets );
189 m_path = std::move( aOther.m_path );
203 m_path.swap( aOther.m_path );
214 for(
size_t i = 0; i <
size; i++ )
270 for(
size_t i = 1; i <
m_sheets.size(); i++ )
277 if(
size() > aSheetPathToTest.
size() )
280 if(
size() < aSheetPathToTest.
size() )
284 for(
unsigned i = 0; i <
size(); i++ )
286 if(
at( i )->m_Uuid < aSheetPathToTest.
at( i )->
m_Uuid )
289 if(
at( i )->m_Uuid != aSheetPathToTest.
at( i )->
m_Uuid )
304 if( pageNumComp == 0 )
309 if( virtualPageA > virtualPageB )
311 else if( virtualPageA < virtualPageB )
321 if( aSheetPathToTest.
size() >
size() )
324 for(
size_t i = 0; i < aSheetPathToTest.
size(); ++i )
326 if(
at( i )->m_Uuid != aSheetPathToTest.
at( i )->
m_Uuid )
377 if( sheet->GetExcludedFromSim() )
387 if( aVariantName.IsEmpty() )
392 while( !
copy.empty() )
409 if( sheet->GetExcludedFromBOM() )
419 if( aVariantName.IsEmpty() )
424 while( !
copy.empty() )
441 if( sheet->GetExcludedFromBoard() )
451 if( aVariantName.IsEmpty() )
456 while( !
copy.empty() )
473 if( sheet->GetDNP() )
483 if( aVariantName.IsEmpty() )
488 while( !
copy.empty() )
509 for(
unsigned i = 1; i <
size(); i++ )
529 if( !sheet->IsVirtualRootSheet() )
530 suffix << sheet->GetRefSuffix( parentPath );
540 bool aStripTrailingSeparator,
541 bool aEscapeSheetNames )
const
548 if( !
empty() &&
at( 0 )->IsVirtualRootSheet() )
551 if( aUseShortRootName )
559 if(
size() > startIdx &&
at( startIdx )->GetScreen() )
562 wxFileName fn = fileName;
564 s = fn.GetName() + wxS(
"/" );
571 size_t loopStart = startIdx + 1;
573 if( aUseShortRootName &&
size() > startIdx )
579 loopStart = startIdx;
584 for(
size_t i = 0; i < loopStart && i <
size(); ++i )
587 for(
unsigned i = loopStart; i <
size(); i++ )
592 if( aEscapeSheetNames )
595 s << sheetName << wxS(
"/" );
598 if( aStripTrailingSeparator && s.EndsWith(
"/" ) )
599 s = s.Left( s.length() - 1 );
607 std::vector<SCH_ITEM*> items;
610 std::back_inserter( items ),
627 reference->EDA_TEXT::SetText( symbol->
GetBaseRef(
this ).Strip( wxString::both ) );
663 const wxString ref = aSymbol->
GetRef( &aSheetPath );
664 const bool isPseudoSymbol = aSymbol->
IsPower() || ( !ref.IsEmpty() && ref[0] == wxT(
'#' ) );
671 bool aForceIncludeOrphanSymbols )
const
676 AppendSymbol( aReferences, symbol, aSymbolFilter, aForceIncludeOrphanSymbols );
682 bool aForceIncludeOrphanSymbols )
const
693 aReferences.
AddItem( schReference );
721 wxString reference_str = schReference.
GetRef();
724 if( reference_str[reference_str.Len() - 1] ==
'?' )
741 auto pair = std::make_pair( aSrcFileName, aDestFileName );
748 wxCHECK_MSG( sch,
false,
"No SCHEMATIC found in SCH_SHEET_PATH::TestForRecursion!" );
751 wxFileName srcFn = aSrcFileName;
752 wxFileName destFn = aDestFileName;
754 if( srcFn.IsRelative() )
755 srcFn.MakeAbsolute( rootFn.GetPath() );
757 if( destFn.IsRelative() )
758 destFn.MakeAbsolute( rootFn.GetPath() );
761 if( srcFn == destFn )
776 if( cmpFn.IsRelative() )
777 cmpFn.MakeAbsolute( rootFn.GetPath() );
780 if( cmpFn == destFn )
788 if( i >=
size() || i == 0 )
802 if( cmpFn.IsRelative() )
803 cmpFn.MakeAbsolute( rootFn.GetPath() );
823 wxCHECK( sheet, wxEmptyString );
827 if( !tmpPath.empty() )
830 return wxEmptyString;
840 if( pageStr.ToLong( &page ) )
855 if( !tmpPath.empty() )
861 wxCHECK_MSG(
false, , wxS(
"Sheet paths must have a least one valid sheet." ) );
872 wxCHECK( !aProjectName.IsEmpty(), );
878 newSheetPath = newSheetPath + currentSheetPath;
884 below.erase( below.begin() );
890 wxCHECK2( symbol,
continue );
895 || ( !below.empty() && symbol->
GetInstance( newSymbolInstance, below,
true ) ) )
904 newSymbolInstance.
m_Path = newSheetPath.
Path();
918 newSymbolInstance.
m_Path = newSheetPath.
Path();
927 newSymbolInstance.
m_Path = newSheetPath.
Path();
942 wxCHECK2( symbol,
continue );
948 fullSheetPath = fullSheetPath + currentSheetPath;
960 wxLogTrace(
traceSchSheetPaths,
"CheckForMissingSymbolInstances for path: %s (project: %s)",
969 wxCHECK2( symbol,
continue );
987 wxLogTrace(
traceSchSheetPaths,
" Legacy format: Using reference '%s' from field, unit %d",
996 const std::vector<SCH_SYMBOL_INSTANCE>& instances = symbol->
GetInstances();
998 auto sourceIt = std::find_if( instances.begin(), instances.end(),
1001 return aInstance.m_ProjectName == aProjectName;
1004 if( sourceIt == instances.end() )
1005 sourceIt = instances.begin();
1007 symbolInstance = *sourceIt;
1010 " Using available instance (project '%s'): ref=%s, unit=%d, variants=%zu",
1011 sourceIt->m_ProjectName, symbolInstance.
m_Reference,
1022 " No instance data: Using reference '%s' from field, unit %d",
1031 " Created instance: ref=%s, path=%s",
1037 " Symbol %s already has instance: ref=%s, path=%s",
1053 if( sheetFileName.IsAbsolute() )
1059 wxCHECK( screen && parentScreen, );
1062 wxFileName parentFileName = parentScreen->
GetFileName();
1066 wxCHECK( fileName.IsAbsolute() && parentFileName.IsAbsolute(), );
1068 if( fileName.GetPath() == parentFileName.GetPath() )
1072 else if( fileName.MakeRelativeTo( parentFileName.GetPath() ) )
1082 wxT(
"\n File name: '%s'"
1083 "\n parent file name '%s',"
1084 "\n sheet '%s' file name '%s'." ),
1086 Last()->GetFileName() );
1094 while( !tmp.
empty() )
1110 if( aSheet !=
nullptr )
1121 "BuildSheetList called with sheet '%s' (UUID=%s, isVirtualRoot=%d)",
1129 wxLogTrace(
traceSchSheetPaths,
" Skipping virtual root, processing children only" );
1133 std::vector<SCH_ITEM*> childSheets;
1136 for(
SCH_ITEM* item : childSheets )
1146 std::vector<SCH_SHEET*> badSheets;
1155 std::vector<SCH_ITEM*> childSheets;
1158 for(
SCH_ITEM* item : childSheets )
1162 if( aCheckIntegrity )
1167 badSheets.push_back( sheet );
1174 wxT(
"Recursion prevented in SCH_SHEET_LIST::BuildSheetList" ) );
1181 if( aCheckIntegrity )
1197 path.CachePageNumber();
1199 std::sort( begin(),
end(),
1203 size_t common_len = 0;
1204 size_t min_len = std::min( a.
size(), b.
size() );
1206 while( common_len < min_len && a.
at( common_len )->
m_Uuid == b.
at( common_len )->
m_Uuid )
1211 if( common_len == a.
size() )
1213 if( common_len == b.
size() )
1224 for(
size_t i = 0; i < common_len; i++ )
1225 ancestor.push_back( a.
at( i )->
m_Uuid );
1246 if( aUpdateVirtualPageNums )
1248 int virtualPageNum = 1;
1259 path.CachePageNumber();
1261 std::sort( begin(),
end(),
1269 else if( retval > 0 )
1281 if( aUpdateVirtualPageNums )
1283 int virtualPageNum = 1;
1317 auto it = std::remove_if( begin(),
end(),
1320 return std::find( aPageInclusions.begin(),
1321 aPageInclusions.end(),
1331 wxString pageNumber;
1334 std::set<int> usedPageNumbers;
1338 wxString existingPageNum =
path.GetPageNumber();
1341 if( existingPageNum.ToLong( &pageNum ) && pageNum > 0 )
1342 usedPageNumbers.insert(
static_cast<int>( pageNum ) );
1346 int nextAvailable = 1;
1348 while( usedPageNumbers.count( nextAvailable ) > 0 )
1351 pageNumber.Printf( wxT(
"%d" ), nextAvailable );
1394 if( aAllowNullptrReturn )
1408 if( aItem->m_Uuid == aID )
1416 if( aChild->
m_Uuid == aID )
1417 childMatch = aChild;
1437 aMap[ aItem->m_Uuid ] = aItem;
1439 aItem->RunOnChildren(
1442 aMap[ aChild->
m_Uuid ] = aChild;
1451 bool aForceIncludeOrphanSymbols )
const
1454 sheet.
GetSymbols( aReferences, aSymbolFilter, aForceIncludeOrphanSymbols );
1459 SYMBOL_FILTER aSymbolFilter,
bool aForceIncludeOrphanSymbols )
const
1464 sheet.
GetSymbols( aReferences, aSymbolFilter, aForceIncludeOrphanSymbols );
1475 aSheets.push_back( sheet );
1481 bool aIncludeLastSheet )
const
1487 if( !aIncludeLastSheet )
1488 testPath.pop_back();
1490 if( testPath == aPath )
1494 return std::nullopt;
1500 for(
auto it = begin(); it !=
end(); ++it )
1503 ( *it ).GetMultiUnitSymbols( tempMap, aSymbolFilter );
1505 for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
1508 unsigned n_refs = pair.second.GetCount();
1510 for(
unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
1511 aRefList[pair.first].AddItem( pair.second[thisRef] );
1518 const wxString& aDestFileName )
1523 SCHEMATIC* sch = at( 0 ).LastScreen()->Schematic();
1525 wxCHECK_MSG( sch,
false,
"No SCHEMATIC found in SCH_SHEET_LIST::TestForRecursion!" );
1528 wxFileName destFn = aDestFileName;
1530 if( destFn.IsRelative() )
1531 destFn.MakeAbsolute( rootFn.GetPath() );
1534 for(
unsigned i = 0; i < size(); i++ )
1537 for(
unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
1541 for(
unsigned k = 0; k < sheetPath->
size(); k++ )
1588 retval.push_back( sheetpath );
1596 const std::vector<SCH_SYMBOL_INSTANCE>& aSymbolInstances )
1604 wxCHECK2( symbol,
continue );
1607 sheetPathWithSymbolUuid.push_back( symbol->
m_Uuid );
1609 auto it = std::find_if( aSymbolInstances.begin(), aSymbolInstances.end(),
1612 return sheetPathWithSymbolUuid == r.m_Path;
1615 if( it == aSymbolInstances.end() )
1618 sheetPathWithSymbolUuid.
AsString() );
1627 if( !it->m_Value.IsEmpty() )
1630 if( !it->m_Footprint.IsEmpty() )
1646 wxCHECK2( sheet &&
path.Last(),
continue );
1648 auto it = std::find_if( aSheetInstances.begin(), aSheetInstances.end(),
1651 return path.Path() == r.m_Path;
1654 if( it == aSheetInstances.end() )
1657 path.Path().AsString() );
1662 ( sheet->
GetName().IsEmpty() ) ? wxString( wxT(
"root" ) ) : sheet->
GetName(),
1663 path.Path().AsString(), it->m_PageNumber );
1664 path.SetPageNumber( it->m_PageNumber );
1671 std::vector<KIID_PATH> paths;
1674 paths.emplace_back( sheetPath.
Path() );
1682 std::vector<SCH_SHEET_INSTANCE> retval;
1688 wxCHECK2( sheet,
continue );
1697 retval.push_back( std::move( instance ) );
1729 tmp.Printf(
"%d", pageNumber );
1744 std::set<wxString> reservedPageIds;
1753 if( !pageNumber.IsEmpty() )
1754 reservedPageIds.insert( pageNumber );
1757 std::set<wxString> assignedPageIds;
1758 bool modified =
false;
1769 if( !pageNumber.IsEmpty() && assignedPageIds.insert( pageNumber ).second )
1772 wxString pageStr = wxString::Format( wxT(
"%ld" ), nextPage );
1774 while( reservedPageIds.count( pageStr ) || assignedPageIds.count( pageStr ) )
1777 pageStr = wxString::Format( wxT(
"%ld" ), nextPage );
1781 assignedPageIds.insert( pageStr );
1791 bool aStripRefSuffixes )
1794 sheetPath.
AddNewSymbolInstances( aPrefixSheetPath, aProjectName, aStripRefSuffixes ?
this :
nullptr );
1806 int aLastVirtualPageNumber )
1808 wxString pageNumber;
1809 int lastUsedPageNumber = 1;
1810 int nextVirtualPageNumber = aLastVirtualPageNumber;
1813 std::vector< wxString > usedPageNumbers;
1815 if( aPrefixSheetPath.
size() )
1821 pageNumber =
path.GetPageNumber();
1823 if( !pageNumber.IsEmpty() )
1824 usedPageNumbers.emplace_back( pageNumber );
1834 newSheetPath = newSheetPath + sheetPath;
1841 wxCHECK2( sheet,
continue );
1843 nextVirtualPageNumber += 1;
1860 pageNumber.Printf( wxT(
"%d" ), lastUsedPageNumber );
1861 lastUsedPageNumber += 1;
1862 }
while( std::find( usedPageNumbers.begin(), usedPageNumbers.end(), pageNumber ) !=
1863 usedPageNumbers.end() );
1876using PACKAGE_UNITS = std::map<std::tuple<wxString, wxString, wxString>, std::set<int>>;
1881 const wxString& aStored,
const wxString& aLibId,
int aUnit,
1882 const wxString& aOwnSuffix )
1884 for(
const wxString& suffix : aSuffixes )
1886 if( suffix >= aOwnSuffix )
1889 wxString base = aStored;
1894 auto it = aPackages.find( { base, aLibId, suffix } );
1896 if( it != aPackages.end() && it->second.insert( aUnit ).second )
1900 return std::nullopt;
1913 std::optional<wxString> ownBase;
1916 std::vector<MULTI_UNIT> multiUnits;
1918 std::set<wxString> suffixes;
1922 const wxString suffix =
path.ComposeRefSuffix();
1924 suffixes.insert( suffix );
1938 std::optional<wxString> ownBase;
1946 if( !suffix.IsEmpty() )
1956 else if( !suffix.IsEmpty() && !ref.EndsWith( wxS(
"?" ) ) )
1964 for(
const MULTI_UNIT& entry : multiUnits )
1966 if( std::optional<wxString> base =
claimPackageUnit( packages, suffixes, entry.stored,
1967 entry.symbol->GetLibId().Format(), entry.unit,
1970 entry.symbol->SetRef( entry.path, *base );
1972 else if( entry.ownBase )
1974 entry.symbol->SetRef( entry.path, *entry.ownBase );
1976 else if( !entry.stored.EndsWith( wxS(
"?" ) ) )
1978 entry.symbol->SetRefLacksSuffix( entry.path->Path() );
1995 std::vector<PENDING> pending;
1997 std::set<wxString> suffixes;
2001 const wxString suffix =
path.ComposeRefSuffix();
2003 suffixes.insert( suffix );
2020 if( !suffix.IsEmpty() )
2025 pending.push_back( { symbol, &
path, stored, suffix, instance.
m_Unit } );
2030 for(
const PENDING& entry : pending )
2032 if( std::optional<wxString> base =
claimPackageUnit( packages, suffixes, entry.stored,
2033 entry.symbol->GetLibId().Format(), entry.unit,
2037 entry.symbol->SetRef( entry.path, *base );
2038 entry.symbol->SetRefLacksSuffix( entry.path->Path(),
false );
2046 const wxString base = aSymbol->
GetBaseRef( &aSource );
2068 return wxEmptyString;
2078 if( !below.empty() )
2079 below.erase( below.begin() );
2081 if( ( !
source || below.size() > depth ) && aInstancePath.
EndsWith( below ) )
2084 depth = below.size();
2088 return source ?
source->ComposeRefSuffix() : wxString();
2095 "SCH_SHEET_LIST::CheckForMissingSymbolInstances: Processing %zu sheet paths",
2101 " Processing sheet path: '%s' (size=%zu, KIID_PATH='%s')",
2112 int lastVirtualPageNumber = 1;
2120 return lastVirtualPageNumber;
2128 if(
path.Path() == aPath )
2140 for(
size_t i = 0; i <
path.size(); i++ )
2142 if(
path.at( i ) == aSheet )
2155 return std::nullopt;
2159 if(
path.LastScreen() == aScreen )
2160 return std::optional<SCH_SHEET_PATH>(
path );
2163 return std::nullopt;
bool IsContentModified() const
void SetContentModified(bool aModified=true)
wxString GetClass() const override
Return the class name.
void SetPosition(const VECTOR2I &) override
static DELETED_SHEET_ITEM * GetInstance()
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool operator==(const SCH_ITEM &aOther) const override
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
KICAD_T Type() const
Returns the type of object.
virtual bool IsVisible() const
virtual void SetVisible(bool aVisible)
EE_TYPE OfType(KICAD_T aType) const
bool EndsWith(const KIID_PATH &aPath) const
Test if aPath from the last path towards the first path.
wxString AsString() const
wxString AsString() const
Define a library symbol object.
int GetUnitCount() const override
bool m_IntersheetRefsShow
Holds all the data relating to one schematic.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
std::vector< SCH_SHEET * > GetTopLevelSheets() const
Get the list of top-level sheets.
bool IsInstancePathInProject(const KIID_PATH &aPath) const
Test whether an instance path is rooted in this schematic's top level sheets.
VECTOR2I GetPosition() const override
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
void SetText(const wxString &aText) override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this label.
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
virtual void SetUnit(int aUnit)
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
std::vector< SCH_FIELD > & GetFields()
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void AddItem(const SCH_REFERENCE &aItem)
A helper to define a symbol's reference designator in a schematic.
wxString GetComposedRef() const
Return the reference as shown on this sheet path, with its sheet suffix.
void SetSheetNumber(int aSheetNumber)
void UpdateDisplayBounds(SCH_ITEM *aItem)
Refresh display bounds only; the item's source and membership must be unchanged.
EE_RTREE & Items()
Get the full RTree, usually for iterating.
const wxString & GetFileName() const
SCHEMATIC * Schematic() const
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,...
void UpdateHatching() const override
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Fetch a SCH_ITEM by ID.
std::optional< SCH_SHEET_PATH > GetOrdinalPath(const SCH_SCREEN *aScreen) const
Return the ordinal sheet path of aScreen.
SCH_SHEET_PATH m_currentSheetPath
void TrimToPageNumbers(const std::vector< wxString > &aPageInclusions)
Truncates the list by removing sheet's with page numbers not in the given list.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
bool NameExists(const wxString &aSheetName) const
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
std::vector< SCH_SHEET_INSTANCE > GetSheetInstances() const
Fetch the instance information for all of the sheets in the hierarchy.
void UpdateSheetInstanceData(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
void StripRefSuffixes()
Recover the base references from the composed references a file stores.
void SetInitialPageNumbers()
Set initial sheet page numbers.
void RemoveSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
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.
wxString GetNextPageNumber() const
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
bool IsModified() const
Check the entire hierarchy for any modifications.
SCH_SHEET_LIST(SCH_SHEET *aSheet=nullptr)
Construct a flattened list of SCH_SHEET_PATH objects from aSheet.
int GetLastVirtualPageNumber() const
void UpdateSymbolInstanceData(const std::vector< SCH_SYMBOL_INSTANCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
void GetSheetsWithinPath(std::vector< SCH_SHEET_PATH > &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 aSheetPat...
void FillItemMap(std::unordered_map< KIID, EDA_ITEM * > &aMap) const
Fill an item cache for temporary use when many items need to be fetched.
bool PageNumberExists(const wxString &aPageNumber) const
void SortByHierarchicalPageNumbers(bool aUpdateVirtualPageNums=true)
This works like SortByPageNumbers, but it sorts the sheets first by their hierarchical depth and then...
void AddNewSheetInstances(const SCH_SHEET_PATH &aPrefixSheetPath, int aLastVirtualPageNumber)
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SYMBOL_FILTER aSymbolFilter) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
void RecoverPackageRefs()
Give a unit loaded by StripRefSuffixes() the base of a package in another top level sheet.
bool ContainsSheet(const SCH_SHEET *aSheet) const
void AddNewSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath, const wxString &aProjectName, bool aStripRefSuffixes=false)
Attempt to add new symbol instances for all symbols in this list of sheet paths prefixed with aPrefix...
bool RepairPageNumbers()
Assign valid page numbers to sheet paths whose stored page number is missing or collides with an earl...
std::vector< KIID_PATH > GetPaths() const
int ShareReusedSheetRef(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSource) const
Give every other instance of aSymbol's sheet the base reference and unit it has on aSource.
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
SCH_SHEET_PATH FindSheetForScreen(const SCH_SCREEN *aScreen)
Return the first SCH_SHEET_PATH object (not necessarily the only one) using a particular screen.
void CheckForMissingSymbolInstances(const wxString &aProjectName)
wxString SourceRefSuffix(const SCH_SYMBOL &aSymbol, const KIID_PATH &aInstancePath) const
Return the suffix the source project composed into the instance of aSymbol at aInstancePath,...
bool HasPath(const KIID_PATH &aPath) const
SCH_SHEET_PATH * FindSheetForPath(const SCH_SHEET_PATH *aPath)
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) matching the provi...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
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 aSrcSheetHi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
bool IsSharedPath() const
Determine if this sheet path is shared in a complex hierarchy.
KIID_PATH m_path
The UUID path of m_sheets, kept in step with it by Rehash().
bool GetExcludedFromBOM() const
void Swap(SCH_SHEET_PATH &aOther) noexcept
const SCH_SHEET * GetSheet(unsigned aIndex) const
bool empty() const
Forwarded method from std::vector.
int ComparePageNum(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare sheets by their page number.
size_t GetCurrentHash() const
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SYMBOL_FILTER aSymbolFilter) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sh...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
bool operator==(const SCH_SHEET_PATH &d1) const
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
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 UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
void MakeFilePathRelativeToParentSheet()
Make the sheet file name relative to its parent sheet.
SCH_ITEM * ResolveItem(const KIID &aID) const
Fetch a SCH_ITEM by ID.
std::vector< SCH_SHEET * > m_sheets
SCH_SCREEN * LastScreen()
void AddNewSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath, const wxString &aProjectName, const SCH_SHEET_LIST *aSourceSheets=nullptr)
Attempt to add new symbol instances for all symbols in this sheet path prefixed with aPrefixSheetPath...
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare if this is the same sheet path as aSheetPathToTest.
void initFromOther(const SCH_SHEET_PATH &aOther)
wxString m_cached_page_number
wxString GetPageNumber() const
void RemoveSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
void CheckForMissingSymbolInstances(const wxString &aProjectName)
bool IsContainedWithin(const SCH_SHEET_PATH &aSheetPathToTest) const
Check if this path is contained inside aSheetPathToTest.
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
const wxString & GetCachedPageNumber() const
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
std::map< std::pair< wxString, wxString >, bool > m_recursion_test_cache
bool GetExcludedFromSim() const
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
void AppendMultiUnitSymbol(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SCH_SYMBOL *aSymbol, SYMBOL_FILTER aSymbolFilter) const
Append a SCH_REFERENCE_LIST object to aRefList based on aSymbol, storing same-reference set of multi-...
bool GetExcludedFromBoard() const
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET_PATH & operator=(const SCH_SHEET_PATH &aOther)
int GetPageNumberAsInt() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
SCH_SHEET_PATH operator+(const SCH_SHEET_PATH &aOther)
int m_virtualPageNumber
Page numbers are maintained by the sheet load order.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
wxString ComposeRefSuffix() const
Compose the reference suffixes of every sheet in this path, from the root down.
int GetVirtualPageNumber() const
void pop_back()
Forwarded method from std::vector.
void InitializeAttributes(const SCH_SHEET &aSheet)
bool HasDifferentials(const SCH_SHEET &aSheet) const
Return true if the variant carries any differential against the base sheet values.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetFileName(const wxString &aFilename)
wxString GetFileName() const
Return the filename corresponding to this sheet.
bool getInstance(SCH_SHEET_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
bool addInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
wxString getPageNumber(const KIID_PATH &aParentPath) const
Return the sheet page number for aParentPath.
bool IsTopLevelSheet() const
Check if this sheet is a top-level sheet.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
SCH_SCREEN * GetScreen() const
static int ComparePageNum(const wxString &aPageNumberA, const wxString &aPageNumberB)
Compare page numbers of schematic sheets.
void setPageNumber(const KIID_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
bool IsVirtualRootSheet() const
bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flags.
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
PIN_MAP_INSTANCE_OVERRIDE m_PinMapOverride
Per-instance pin-to-pad map override for this variant (issue #2282).
std::optional< LIB_ID > m_SymbolOverride
Alternate library symbol to substitute for the base symbol in this variant, if any.
void InitializeAttributes(const SCH_SYMBOL &aSymbol)
bool HasDifferentials(const SCH_SYMBOL &aSymbol) const
Return true if the variant carries any differential against the base symbol values,...
void UpdatePrefix()
Set the prefix based on the current reference designator.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
PIN_MAP_INSTANCE_OVERRIDE GetPinMapOverride(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
wxString GetBaseRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
void SetRefLacksSuffix(const KIID_PATH &aPath, bool aLacksSuffix=true)
Flag the reference loaded for aPath as saved without its sheet suffix.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the base reference for the given sheet path for this symbol.
void SetFootprintFieldText(const wxString &aFootprint)
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
const LIB_ID & GetLibId() const override
void SetValueFieldText(const wxString &aValue, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString)
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
int GetUnitCount() const override
Return the number of units per package of the symbol.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
bool IsPower() const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
std::map< wxString, wxString > m_Fields
bool m_ExcludedFromPosFiles
static bool empty(const wxTextEntryBase *aCtrl)
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
static constexpr void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
Collection of utility functions for component reference designators (refdes)
static std::optional< wxString > claimPackageUnit(PACKAGE_UNITS &aPackages, const std::set< wxString > &aSuffixes, const wxString &aStored, const wxString &aLibId, int aUnit, const wxString &aOwnSuffix)
std::map< std::tuple< wxString, wxString, wxString >, std::set< int > > PACKAGE_UNITS
static bool stripRefSuffix(wxString &aRef, const wxString &aSuffix)
static bool matchesSymbolFilter(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheetPath, SYMBOL_FILTER aSymbolFilter)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
std::map< wxString, SCH_SYMBOL_VARIANT > m_Variants
A list of symbol variants.
bool m_RefLacksSuffix
Set at load when the saved reference lacked its sheet suffix, cleared when the reference changes.
size_t operator()(const SCH_SHEET_PATH &path) const
@ INTERSHEET_REFS
Global label cross-reference page numbers.
@ REFERENCE
Field Reference of part, i.e. "IC21".
wxLogTrace helper definitions.
@ NOT_USED
the 3d code uses this value
VECTOR2< int32_t > VECTOR2I