43 m_rootSheet( nullptr )
63 if( !symbol || aProperty->
Name() !=
_HKI(
"Text" ) )
69 wxString newValue = aItem->
Get<wxString>( aProperty );
71 wxString ref = symbol->
GetRef( &sheetPath );
77 std::vector<SCH_SYMBOL*> otherUnits;
83 switch( field->
GetId() )
88 aCommit->
Modify( otherUnit, sheet.LastScreen() );
90 otherUnit->SetValueFieldText( newValue );
97 aCommit->
Modify( otherUnit, sheet.LastScreen() );
99 otherUnit->SetFootprintFieldText( newValue );
106 aCommit->
Modify( otherUnit, sheet.LastScreen() );
136 project.m_ErcSettings =
nullptr;
139 delete project.m_SchematicSettings;
140 project.m_SchematicSettings =
nullptr;
162 project.m_ErcSettings =
nullptr;
165 delete project.m_SchematicSettings;
166 project.m_SchematicSettings =
nullptr;
177 project.m_SchematicSettings->LoadFromFile();
178 project.m_SchematicSettings->m_NgspiceSettings->LoadFromFile();
179 project.m_ErcSettings->LoadFromFile();
186 wxCHECK_RET( aRootSheet, wxS(
"Call to SetRoot with null SCH_SHEET!" ) );
206 [&](
const wxString& aVar )
209 aVars->push_back( aVar );
214 add( wxT(
"SHEETPATH" ) );
215 add( wxT(
"SHEETNAME" ) );
216 add( wxT(
"FILENAME" ) );
217 add( wxT(
"FILEPATH" ) );
218 add( wxT(
"PROJECTNAME" ) );
231 wxCHECK( aSheetPath,
false );
233 if( token->IsSameAs( wxT(
"#" ) ) )
238 else if( token->IsSameAs( wxT(
"##" ) ) )
240 *token = wxString::Format(
"%i",
Root().CountSheets() );
243 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
248 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
253 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
256 *token = fn.GetFullName();
259 else if( token->IsSameAs( wxT(
"FILEPATH" ) ) )
262 *token = fn.GetFullPath();
265 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) )
274 if(
Prj().TextVarResolver( token ) )
311 std::set<wxString> migratedExclusions;
319 const wxString settingsKey = testMarker->
GetRCItem()->GetSettingsKey();
321 if( settingsKey != wxT(
"pin_to_pin" )
322 && settingsKey != wxT(
"hier_label_mismatch" )
323 && settingsKey != wxT(
"different_unit_net" ) )
338 settings.
m_ErcExclusions.insert( migratedExclusions.begin(), migratedExclusions.end() );
348 std::set<wxString>::iterator it = settings.
m_ErcExclusions.find( serialized );
358 std::vector<SCH_MARKER*> newMarkers;
367 newMarkers.push_back( marker );
381 for(
const std::shared_ptr<BUS_ALIAS>& alias : sheet.LastScreen()->GetBusAliases() )
383 if( alias->GetName() == aLabel )
394 std::set<wxString> names;
403 names.insert( key.Name );
415 wxString ref = token->BeforeFirst(
':', &remainder );
423 if( refSymbol->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
426 *token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
436 if( refSheet->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
448 std::map<int, wxString> namesMap;
452 if( sheet.size() == 1 )
453 namesMap[sheet.GetVirtualPageNumber()] =
_(
"<root sheet>" );
455 namesMap[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName();
464 std::map<int, wxString> pagesMap;
467 pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
476 size_t sourceLen = aSource.length();
478 for(
size_t i = 0; i < sourceLen; ++i )
480 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
483 bool isCrossRef =
false;
486 for( i = i + 2; i < sourceLen; ++i )
488 if( aSource[i] ==
'{'
489 && ( aSource[i-1] ==
'_' || aSource[i-1] ==
'^' || aSource[i-1] ==
'~' ) )
494 if( aSource[i] ==
'}' )
502 if( aSource[i] ==
':' )
505 token.append( aSource[i] );
512 wxString ref = token.BeforeFirst(
':', &remainder );
517 for(
size_t jj = 0; jj < references.
GetCount(); jj++ )
519 SCH_SYMBOL* refSymbol = references[ jj ].GetSymbol();
521 if( ref == refSymbol->
GetRef( &references[ jj ].GetSheetPath(),
true ) )
529 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
533 newbuf.append( aSource[i] );
544 size_t sourceLen = aSource.length();
546 for(
size_t i = 0; i < sourceLen; ++i )
548 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
551 bool isCrossRef =
false;
553 for( i = i + 2; i < sourceLen; ++i )
555 if( aSource[i] ==
'}' )
558 if( aSource[i] ==
':' )
561 token.append( aSource[i] );
568 wxString ref = token.BeforeFirst(
':', &remainder );
576 token = refSymbol->
GetRef( &refSheetPath,
true ) + wxS(
":" ) + remainder;
580 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
584 newbuf.append( aSource[i] );
618 wxString filename = rootFn.GetName();
634 int sheet_number = 1;
641 if( sheet.Path() == current_sheetpath )
647 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
658 std::map<wxString, std::set<int>>& pageRefsMap =
GetPageRefsMap();
667 wxString resolvedLabel = global->
GetShownText( &sheet,
false );
669 pageRefsMap[ resolvedLabel ].insert( sheet.GetVirtualPageNumber() );
678 std::vector<SCH_GLOBALLABEL*> currentSheetGlobalLabels;
681 currentSheetGlobalLabels.push_back(
static_cast<SCH_GLOBALLABEL*
>( item ) );
685 std::vector<SCH_FIELD>& fields = globalLabel->GetFields();
687 fields[0].SetVisible( show );
691 if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() )
692 globalLabel->AutoplaceFields(
CurrentSheet().LastScreen(),
false );
695 aItemCallback( globalLabel );
702 const wxString& aRange )
704 std::string spiceNetName( aNetName.Lower().ToStdString() );
707 if( spiceNetName ==
"gnd" || spiceNetName ==
"0" )
708 return wxEmptyString;
727 std::deque<EDA_ITEM*> allItems;
729 for(
auto item : screen->
Items() )
730 allItems.push_back( item );
736 screen->
Append( junction );
742 screen->
Append( newSegment );
806 for(
unsigned i = 0; i < sheetList.size(); i++ )
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
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
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(std::string &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 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 settings were stored in SCH_BASE_FRAME previously.
bool m_IntersheetRefsShow
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
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_PATH & CurrentSheet() const override
void ResolveERCExclusionsPostUpdate()
Update markers to match recorded exclusions.
void RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
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.
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()
SCH_SHEET_LIST & GetFullHierarchy() const
Return the full schematic flattened hierarchical sheet list.
void FixupJunctions()
Add junctions to this schematic where required.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
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
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.
void RemoveAllListeners()
Remove all listeners.
void GetContextualTextVars(wxArrayString *aVars) const
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
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(SCHEMATIC *schematic, 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)
std::vector< SCH_LINE * > GetBusesAndWires(const VECTOR2I &aPosition, bool aIgnoreEndpoints=false) const
Return buses and wires passing through aPosition.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
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.
std::vector< VECTOR2I > GetNeededJunctions(const std::deque< EDA_ITEM * > &aItems) const
Return the unique set of points belonging to aItems where a junction is needed.
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.
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
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.
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) 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.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".