48 m_rootSheet( nullptr )
69 if( !symbol || aProperty->
Name() !=
_HKI(
"Text" ) )
75 wxString newValue = aItem->
Get<wxString>( aProperty );
77 wxString ref = symbol->
GetRef( &sheetPath );
83 std::vector<SCH_SYMBOL*> otherUnits;
89 switch( field->
GetId() )
94 aCommit->
Modify( otherUnit, sheet.LastScreen() );
96 otherUnit->SetValueFieldText( newValue );
103 aCommit->
Modify( otherUnit, sheet.LastScreen() );
105 otherUnit->SetFootprintFieldText( newValue );
112 aCommit->
Modify( otherUnit, sheet.LastScreen() );
146 project.m_ErcSettings =
nullptr;
149 delete project.m_SchematicSettings;
150 project.m_SchematicSettings =
nullptr;
172 project.m_ErcSettings =
nullptr;
175 delete project.m_SchematicSettings;
176 project.m_SchematicSettings =
nullptr;
187 project.m_SchematicSettings->LoadFromFile();
188 project.m_SchematicSettings->m_NgspiceSettings->LoadFromFile();
189 project.m_ErcSettings->LoadFromFile();
196 wxCHECK_RET( aRootSheet, wxS(
"Call to SetRoot with null SCH_SHEET!" ) );
231 [&](
const wxString& aVar )
234 aVars->push_back( aVar );
239 add( wxT(
"SHEETPATH" ) );
240 add( wxT(
"SHEETNAME" ) );
241 add( wxT(
"FILENAME" ) );
242 add( wxT(
"FILEPATH" ) );
243 add( wxT(
"PROJECTNAME" ) );
256 wxCHECK( aSheetPath,
false );
258 if( token->IsSameAs( wxT(
"#" ) ) )
263 else if( token->IsSameAs( wxT(
"##" ) ) )
265 *token = wxString::Format(
"%i",
Root().CountSheets() );
268 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
273 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
278 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
281 *token = fn.GetFullName();
284 else if( token->IsSameAs( wxT(
"FILEPATH" ) ) )
287 *token = fn.GetFullPath();
290 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) )
299 if(
Prj().TextVarResolver( token ) )
336 std::set<wxString> migratedExclusions;
350 const wxString settingsKey = testMarker->
GetRCItem()->GetSettingsKey();
352 if( settingsKey != wxT(
"pin_to_pin" )
353 && settingsKey != wxT(
"hier_label_mismatch" )
354 && settingsKey != wxT(
"different_unit_net" ) )
369 settings.
m_ErcExclusions.insert( migratedExclusions.begin(), migratedExclusions.end() );
379 std::set<wxString>::iterator it = settings.
m_ErcExclusions.find( serialized );
389 std::vector<SCH_MARKER*> newMarkers;
398 newMarkers.push_back( marker );
412 for(
const std::shared_ptr<BUS_ALIAS>& alias : sheet.LastScreen()->GetBusAliases() )
414 if( alias->GetName() == aLabel )
425 std::set<wxString> names;
434 names.insert( key.Name );
445 wxString ref = token->BeforeFirst(
':', &remainder );
453 if( refSymbol->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
456 *token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
466 if( refSheet->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
478 std::map<int, wxString> namesMap;
482 if( sheet.size() == 1 )
483 namesMap[sheet.GetVirtualPageNumber()] =
_(
"<root sheet>" );
485 namesMap[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName();
494 std::map<int, wxString> pagesMap;
497 pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
506 size_t sourceLen = aSource.length();
508 for(
size_t i = 0; i < sourceLen; ++i )
510 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
513 bool isCrossRef =
false;
516 for( i = i + 2; i < sourceLen; ++i )
518 if( aSource[i] ==
'{'
519 && ( aSource[i-1] ==
'_' || aSource[i-1] ==
'^' || aSource[i-1] ==
'~' ) )
524 if( aSource[i] ==
'}' )
532 if( aSource[i] ==
':' )
535 token.append( aSource[i] );
541 wxString ref = token.BeforeFirst(
':', &remainder );
546 for(
size_t jj = 0; jj < references.
GetCount(); jj++ )
548 SCH_SYMBOL* refSymbol = references[ jj ].GetSymbol();
550 if( ref == refSymbol->
GetRef( &references[ jj ].GetSheetPath(),
true ) )
558 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
562 newbuf.append( aSource[i] );
573 size_t sourceLen = aSource.length();
575 for(
size_t i = 0; i < sourceLen; ++i )
577 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
580 bool isCrossRef =
false;
582 for( i = i + 2; i < sourceLen; ++i )
584 if( aSource[i] ==
'}' )
587 if( aSource[i] ==
':' )
590 token.append( aSource[i] );
596 wxString ref = token.BeforeFirst(
':', &remainder );
604 token = refSymbol->
GetRef( &refSheetPath,
true ) + wxS(
":" ) + remainder;
608 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
612 newbuf.append( aSource[i] );
635 wxString filename = rootFn.GetName();
651 int sheet_number = 1;
658 if( sheet.Path() == current_sheetpath )
664 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
675 std::map<wxString, std::set<int>>& pageRefsMap =
GetPageRefsMap();
684 wxString resolvedLabel = global->
GetShownText( &sheet,
false );
686 pageRefsMap[ resolvedLabel ].insert( sheet.GetVirtualPageNumber() );
695 std::vector<SCH_GLOBALLABEL*> currentSheetGlobalLabels;
698 currentSheetGlobalLabels.push_back(
static_cast<SCH_GLOBALLABEL*
>( item ) );
702 std::vector<SCH_FIELD>& fields = globalLabel->GetFields();
704 fields[0].SetVisible( show );
708 if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() )
709 globalLabel->AutoplaceFields(
CurrentSheet().LastScreen(),
false );
712 aItemCallback( globalLabel );
719 const wxString& aRange )
721 wxString spiceNetName( aNetName.Lower() );
724 if( spiceNetName == wxS(
"gnd" ) || spiceNetName == wxS(
"0" ) )
725 return wxEmptyString;
744 std::deque<EDA_ITEM*> allItems;
746 for(
auto item : screen->Items() )
747 allItems.push_back( item );
750 for(
const VECTOR2I& point : screen->GetNeededJunctions( allItems ) )
753 screen->Append( junction );
756 for(
SCH_LINE* wire : screen->GetBusesAndWires( point,
true ) )
759 screen->Append( newSegment );
824 for(
unsigned i = 0; i < sheetList.size(); i++ )
872 std::set<KIFONT::OUTLINE_FONT*>
fonts;
878 for(
SCH_ITEM* item : sheet.LastScreen()->Items() )
890 if( outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::EDITABLE
891 || outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::INSTALLABLE )
893 fonts.insert( outline );
905 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
916 std::set<const SCH_SCREEN*> retv;
929 const std::vector<SCH_SYMBOL_INSTANCE> symbolInstances = symbol->
GetInstances();
933 if( !hierarchy.
HasPath( instance.m_Path ) )
935 retv.insert( screen );
940 if( retv.count( screen ) )
957 wxCHECK2( screen,
continue );
959 if( screen->GetRefCount() > 1 )
void SetPageCount(int aPageCount)
void SetPageNumber(const wxString &aPageNumber)
void SetVirtualPageNumber(int aPageNumber)
Represent a set of changes (additions, deletions or modifications) of a data model (e....
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Calculate the connectivity of a schematic and generates netlists.
const NET_MAP & GetNetMap() const
A subgraph is a set of items that are electrically connected on a single sheet.
static PRIORITY GetDriverPriority(SCH_ITEM *aDriver)
Return the priority (higher is more important) of a candidate driver.
const SCH_CONNECTION * GetDriverConnection() const
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Loads a file from disk and adds it to the collection.
Container for ERC settings.
std::map< wxString, wxString > m_ErcExclusionComments
std::set< wxString > m_ErcExclusions
Class that other classes need to inherit from, in order to be inspectable.
wxAny Get(PROPERTY_BASE *aProperty) const
FONT is an abstract base class for both outline and stroke fonts.
virtual bool IsStroke() const
Class OUTLINE_FONT implements outline font drawing.
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
std::shared_ptr< RC_ITEM > GetRCItem() const
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
wxString GetComment() const
static void ConvertToSpiceMarkup(wxString *aNetName)
Remove formatting wrappers and replace illegal spice net name characters with underscores.
The backing store for a PROJECT, in JSON format.
ERC_SETTINGS * m_ErcSettings
Eeschema params.
SCHEMATIC_SETTINGS * m_SchematicSettings
Container for project specific data.
virtual const wxString GetProjectName() const
Return the short name of the project.
virtual PROJECT_FILE & GetProjectFile() const
const wxString & Name() const
static PROPERTY_MANAGER & Instance()
void UnregisterListeners(TYPE_ID aType)
void RegisterListener(TYPE_ID aType, PROPERTY_LISTENER aListenerFunc)
Registers a listener for the given type.
virtual void OnSchItemsRemoved(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
virtual void OnSchItemsChanged(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
virtual void OnSchSheetChanged(SCHEMATIC &aSch)
virtual void OnSchItemsAdded(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
These are loaded from Eeschema settings but then overwritten by the project settings.
bool m_IntersheetRefsShow
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
std::set< const SCH_SCREEN * > GetSchematicsSharedByMultipleProjects() const
Return a list of schematic files in the current project that contain instance data for multiple proje...
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
void OnItemsAdded(std::vector< SCH_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
SCH_SHEET_LIST m_hierarchy
Cache of the entire schematic hierarchy sorted by sheet page number.
SCH_SHEET_PATH & CurrentSheet() const override
void ResolveERCExclusionsPostUpdate()
Update markers to match recorded exclusions.
void RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
bool IsComplexHierarchy() const
Test if the schematic is a complex hierarchy.
void OnSchSheetChanged()
Notify the schematic and its listeners that the current sheet has been changed.
SCH_SHEET_PATH * m_currentSheet
The sheet path of the sheet currently being edited or displayed.
wxString GetOperatingPoint(const wxString &aNetName, int aPrecision, const wxString &aRange)
void OnItemsRemoved(std::vector< SCH_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aLabel) const
Return a pointer to a bus alias object for the given label, or null if one doesn't exist.
std::vector< SCH_MARKER * > ResolveERCExclusions()
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
void EmbedFonts() override
Embed fonts in the schematic.
SCHEMATIC_SETTINGS & Settings() const
wxString ConvertKIIDsToRefs(const wxString &aSource) const
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
std::map< wxString, std::set< int > > & GetPageRefsMap()
void FixupJunctions()
Add junctions to this schematic where required.
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
wxString ConvertRefsToKIIDs(const wxString &aSource) const
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
void SetProject(PROJECT *aPrj)
void AddListener(SCHEMATIC_LISTENER *aListener)
Add a listener to the schematic to receive calls whenever something on the schematic has been modifie...
std::map< int, wxString > GetVirtualPageToSheetPagesMap() const
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
std::set< wxString > GetNetClassAssignmentCandidates()
Return the set of netname candidates for netclass assignment.
void RecomputeIntersheetRefs(const std::function< void(SCH_GLOBALLABEL *)> &aItemCallback)
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
void InvokeListeners(Func &&aFunc, Args &&... args)
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
static bool m_IsSchematicExists
True if a SCHEMATIC exists, false if not.
void RemoveAllListeners()
Remove all listeners.
void GetContextualTextVars(wxArrayString *aVars) const
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
SCH_SHEET_LIST BuildSheetListSortedByPageNumbers() const override
wxString GetUniqueFilenameForCurrentSheet()
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
std::vector< SCHEMATIC_LISTENER * > m_listeners
Currently installed listeners.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
std::map< wxString, double > m_operatingPoints
Simulation operating points for text variable substitution.
ERC_SETTINGS & ErcSettings() const
void OnItemsChanged(std::vector< SCH_ITEM * > &aItems)
Notify the schematic and its listeners that an item on the schematic has been modified in some way.
SCH_SHEET * m_rootSheet
The top-level sheet in this schematic hierarchy (or potentially the only one)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
Segment description base class to describe items which have 2 end points (track, wire,...
SCH_LINE * BreakAt(const VECTOR2I &aPoint)
Break this segment into two at the specified point.
static SCH_MARKER * DeserializeFromString(const SCH_SHEET_LIST &aSheetList, const wxString &data)
wxString SerializeToString() const
bool IsLegacyMarker() const
Determines if this marker is legacy (i.e.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void SetLegacySymbolInstanceData()
Update the symbol value and footprint instance data for legacy designs.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
const wxString & GetFileName() const
const TITLE_BLOCK & GetTitleBlock() const
void Update(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Update aItem's bounding box in the tree.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
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.
bool HasPath(const KIID_PATH &aPath) const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void clear()
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
SCH_SCREEN * GetScreen() const
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
const LIB_ID & GetLibId() const override
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Helper class to recognize Spice formatted values.
wxString ToString() const
Return string value as when converting double to string (e.g.
bool TextVarResolver(wxString *aToken, const PROJECT *aProject, int aFlags=0) const
static void GetContextualTextVars(wxArrayString *aVars)
wxString GetTextVars(const wxString &aSource)
Returns any variables unexpanded, e.g.
static bool empty(const wxTextEntryBase *aCtrl)
void CollectOtherUnits(const wxString &aRef, int aUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
void ignore_unused(const T &)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
A simple container for schematic symbol instance information.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".