38 #include <boost/functional/hash.hpp> 39 #include <wx/filename.h> 56 return _(
"(Deleted Item)" );
61 return wxT(
"DELETED_SHEET_ITEM" );
77 void Move(
const wxPoint& aMoveVector )
override {}
80 void Rotate( wxPoint aCenter )
override {}
83 void Show(
int , std::ostream& )
const override {}
92 return path.GetCurrentHash();
139 if(
size() > aSheetPathToTest.
size() )
142 if(
size() < aSheetPathToTest.
size() )
146 for(
unsigned i = 0; i <
size(); i++ )
198 for(
unsigned i = 1; i <
size(); i++ )
210 path.push_back( sheet->m_Uuid );
220 for(
size_t i = 1; i <
size(); i++ )
221 path.push_back(
at( i )->m_Uuid );
232 if( !
empty() &&
at( 0 )->GetScreen() )
235 wxFileName fn = fileName;
237 if( aUseShortRootName )
240 s = fn.GetName() + wxT(
"/" );
243 for(
unsigned i = 1; i <
size(); i++ )
265 bool aForceIncludeOrphanSymbols )
const 273 if( aIncludePowerSymbols || symbol->
GetRef(
this )[0] != wxT(
'#' ) )
277 if( part || aForceIncludeOrphanSymbols )
282 aReferences.
AddItem( schReference );
290 bool aIncludePowerSymbols )
const 298 if( !aIncludePowerSymbols && symbol->
GetRef(
this )[0] == wxT(
'#' ) )
307 wxString reference_str = schReference.
GetRef();
310 if( reference_str[reference_str.Len() - 1] ==
'?' )
313 aRefList[reference_str].AddItem( schReference );
327 auto pair = std::make_pair( aSrcFileName, aDestFileName );
334 wxCHECK_MSG( sch,
false,
"No SCHEMATIC found in SCH_SHEET_PATH::TestForRecursion!" );
337 wxFileName srcFn = aSrcFileName;
338 wxFileName destFn = aDestFileName;
340 if( srcFn.IsRelative() )
341 srcFn.MakeAbsolute( rootFn.GetPath() );
343 if( destFn.IsRelative() )
344 destFn.MakeAbsolute( rootFn.GetPath() );
348 if( srcFn == destFn )
363 if( cmpFn.IsRelative() )
364 cmpFn.MakeAbsolute( rootFn.GetPath() );
367 if( cmpFn == destFn )
375 if( i >=
size() || i == 0 )
389 if( cmpFn.IsRelative() )
390 cmpFn.MakeAbsolute( rootFn.GetPath() );
410 wxCHECK( sheet, wxEmptyString );
438 wxCHECK_RET( aSheet !=
NULL, wxT(
"Cannot build sheet list from undefined sheet." ) );
440 std::vector<SCH_SHEET*> badSheets;
449 std::vector<SCH_ITEM*> childSheets;
454 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
456 if( aCheckIntegrity )
461 badSheets.push_back( sheet );
470 if( aCheckIntegrity )
485 std::sort( begin(), end(),
494 if( aUpdateVirtualPageNums )
496 int virtualPageNum = 1;
560 if( aItem->m_Uuid == aID )
573 if( aChild->
m_Uuid == aID )
600 aMap[ aItem->m_Uuid ] = aItem;
602 aItem->RunOnChildren(
605 aMap[ aChild->
m_Uuid ] = aChild;
631 references.
AddItem( schReference );
637 std::map<wxString, int> ref_list;
639 for(
unsigned ii = 0; ii< references.
GetCount(); ++ii )
641 wxString curr_ref = references[ii].GetRef();
643 if( ref_list.find( curr_ref ) == ref_list.end() )
645 ref_list[curr_ref] = ii;
650 if( curr_ref.Last() <
'0' && curr_ref.Last() >
'9' )
654 while( curr_ref.Last() >=
'0' && curr_ref.Last() <=
'9' )
655 curr_ref.RemoveLast();
657 references[ii].SetRef( curr_ref );
667 for(
unsigned ii = 0; ii< references.
GetCount(); ++ii )
669 if( references[ii].GetRef()[0] !=
'#' )
671 wxString new_ref =
"#" + references[ii].GetRef();
672 references[ii].SetRef( new_ref );
677 references.
Annotate(
false, 0, 100, lockedSymbols );
683 bool aForceIncludeOrphanSymbols )
const 686 sheet.
GetSymbols( aReferences, aIncludePowerSymbols, aForceIncludeOrphanSymbols );
691 bool aIncludePowerSymbols )
const 693 for( SCH_SHEET_PATHS::const_iterator it = begin(); it != end(); ++it )
696 ( *it ).GetMultiUnitSymbols( tempMap );
698 for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
701 unsigned n_refs = pair.second.GetCount();
703 for(
unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
704 aRefList[pair.first].AddItem( pair.second[thisRef] );
711 const wxString& aDestFileName )
716 SCHEMATIC* sch = at( 0 ).LastScreen()->Schematic();
718 wxCHECK_MSG( sch,
false,
"No SCHEMATIC found in SCH_SHEET_LIST::TestForRecursion!" );
721 wxFileName destFn = aDestFileName;
723 if( destFn.IsRelative() )
724 destFn.MakeAbsolute( rootFn.GetPath() );
727 for(
unsigned i = 0; i < size(); i++ )
730 for(
unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
734 for(
unsigned k = 0; k < sheetPath->
size(); k++ )
763 const std::vector<SYMBOL_INSTANCE_REFERENCE>& aSymbolInstances )
769 std::map<KIID_PATH, wxString> pathNameCache;
773 auto getName = [&pathNameCache](
const KIID_PATH& aPath ) ->
const wxString&
775 if( pathNameCache.count( aPath ) )
776 return pathNameCache.at( aPath );
778 pathNameCache[aPath] = aPath.AsString();
779 return pathNameCache[aPath];
782 for(
size_t i = 0; i < symbolInstances.
GetCount(); i++ )
786 wxString
path = symbolInstances[i].GetPath();
788 auto it = std::find_if( aSymbolInstances.begin(), aSymbolInstances.end(),
791 return path == getName( r.m_Path );
794 if( it == aSymbolInstances.end() )
802 wxCHECK2( symbol,
continue );
807 it->m_Reference, it->m_Unit, it->m_Value,
819 auto it = std::find_if( aSheetInstances.begin(), aSheetInstances.end(),
825 if( it == aSheetInstances.end() )
834 wxCHECK2( sheet,
continue );
844 std::vector<KIID_PATH> paths;
847 paths.emplace_back( sheetPath.
Path() );
859 wxCHECK2( sheet,
continue );
881 wxCHECK2( sheet,
continue );
884 tmp.Printf(
"%d", pageNumber );
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Field Reference of part, i.e. "IC21".
void SetSheetNumber(int aSheetNumber)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
EE_TYPE OfType(KICAD_T aType) const
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 sh...
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
const wxString & GetFileName() const
void initFromOther(const SCH_SHEET_PATH &aOther)
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
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...
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
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 li...
Holds all the data relating to one schematic.
void Rotate(wxPoint aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
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.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
bool IsModified() const
Check the entire hierarchy for any modifications.
bool operator==(const SCH_SHEET_PATH &d1) 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,...
bool PageNumberExists(const wxString &aPageNumber) const
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
the 3d code uses this value
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
wxString AsString() const
std::map< std::pair< wxString, wxString >, bool > m_recursion_test_cache
Page numbers are maintained by the sheet load order.
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
A singleton item of this class is returned for a weak reference that no longer exists.
void AddItem(const SCH_REFERENCE &aItem)
static int ComparePageNum(const wxString &aPageNumberA, const wxString aPageNumberB)
Compares page numbers of schematic sheets.
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
SCH_SCREEN * GetScreen() const
wxString GetClass() const override
Return the class name.
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
void UpdateSheetInstances(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
static void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
void pop_back()
Forwarded method from std::vector.
const wxString GetFootprint(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific footprint assignment for the given sheet path.
std::vector< SCH_FIELD > & GetFields()
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
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...
void UpdateAnnotation()
Update the symbol references for the schematic project (or the current sheet).
SCH_SHEET_PATH & operator=(const SCH_SHEET_PATH &aOther)
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific value for the given sheet path.
int GetUnitCount() const override
For items with units, return the number of units.
size_t size() const
Forwarded method from std::vector.
SCH_SHEET_PATH m_currentSheetPath
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
std::vector< SCH_SHEET * > m_sheets
wxString GetPageNumber() const
size_t operator()(const SCH_SHEET_PATH &path) const
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
Define a library symbol object.
bool NameExists(const wxString &aSheetName) const
A simple container for schematic symbol instance information.
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap)
Set the reference designators in the list that have not been annotated.
wxLogTrace helper definitions.
void SetPosition(const wxPoint &) override
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::unique_ptr< LIB_PART > & GetPartRef()
wxString GetFileName() const
Return the filename corresponding to this sheet.
void UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
KIID_PATH PathWithoutRootUuid() const
Get the sheet path as an KIID_PATH without the root sheet UUID prefix.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
unsigned GetCount() const
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
A simple container for sheet instance information.
const SCH_SHEET * GetSheet(unsigned aIndex) const
SCH_SCREEN * LastScreen()
static DELETED_SHEET_ITEM * GetInstance()
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
SCHEMATIC * Schematic() const
SCH_SHEET_LIST(SCH_SHEET *aSheet=nullptr, bool aCheckIntegrity=false)
Construct a flattened list of SCH_SHEET_PATH objects from aSheet.
wxString AsString() const
size_t GetCurrentHash() const
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
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.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
std::vector< KIID_PATH > GetPaths() const
static bool empty(const wxTextEntryBase *aCtrl)
bool empty() const
Forwarded method from std::vector.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit, const wxString &aValue=wxEmptyString, const wxString &aFootprint=wxEmptyString)
Add a full hierarchical reference to this symbol.
Definition for part library class.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Base class for any item which can be embedded within the SCHEMATIC container class,...
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...
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare if this is the same sheet path as aSheetPathToTest.
void SetInitialPageNumbers()
Set initial sheet page numbers.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
wxString GetPageNumber(const SCH_SHEET_PATH &aInstance) const
Return the sheet page number for aInstance.
A helper to define a symbol's reference designator in a schematic.
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Field Name Module PCB, i.e. "16DIP300".