40 m_rootSheet( nullptr )
64 delete project.m_SchematicSettings;
66 project.m_ErcSettings =
nullptr;
67 project.m_SchematicSettings =
nullptr;
88 delete project.m_SchematicSettings;
90 project.m_ErcSettings =
nullptr;
91 project.m_SchematicSettings =
nullptr;
102 project.m_SchematicSettings->LoadFromFile();
103 project.m_SchematicSettings->m_NgspiceSimulatorSettings->LoadFromFile();
104 project.m_ErcSettings->LoadFromFile();
111 wxCHECK_RET( aRootSheet, wxS(
"Call to SetRoot with null SCH_SHEET!" ) );
131 [&](
const wxString& aVar )
134 aVars->push_back( aVar );
139 add( wxT(
"SHEETPATH" ) );
140 add( wxT(
"SHEETNAME" ) );
141 add( wxT(
"FILENAME" ) );
142 add( wxT(
"PROJECTNAME" ) );
147 for( std::pair<wxString, wxString> entry :
Prj().GetTextVars() )
156 if( token->IsSameAs( wxT(
"#" ) ) )
161 else if( token->IsSameAs( wxT(
"##" ) ) )
163 *token = wxString::Format(
"%i",
Root().CountSheets() );
166 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
171 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
176 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
179 *token = fn.GetFullName();
182 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) )
192 if(
Prj().TextVarResolver( token ) )
229 std::set<wxString> migratedExclusions;
236 const wxString settingsKey = testMarker->
GetRCItem()->GetSettingsKey();
238 if( settingsKey != wxT(
"pin_to_pin" ) && settingsKey != wxT(
"hier_label_mismatch" )
239 && settingsKey != wxT(
"different_unit_net" ) )
241 migratedExclusions.insert( testMarker->
Serialize() );
253 settings.
m_ErcExclusions.insert( migratedExclusions.begin(), migratedExclusions.end() );
272 std::vector<SCH_MARKER*> newMarkers;
281 newMarkers.push_back( marker );
295 for(
const std::shared_ptr<BUS_ALIAS>& alias : sheet.LastScreen()->GetBusAliases() )
297 if( alias->GetName() == aLabel )
308 std::set<wxString> names;
317 names.insert( key.Name );
329 wxString ref = token->BeforeFirst(
':', &remainder );
337 if( refSymbol->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
340 *token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
360 std::map<int, wxString> namesMap;
364 if( sheet.size() == 1 )
365 namesMap[sheet.GetVirtualPageNumber()] =
_(
"<root sheet>" );
367 namesMap[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName();
376 std::map<int, wxString> pagesMap;
379 pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
388 size_t sourceLen = aSource.length();
390 for(
size_t i = 0; i < sourceLen; ++i )
392 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
395 bool isCrossRef =
false;
398 for( i = i + 2; i < sourceLen; ++i )
400 if( aSource[i] ==
'{'
401 && ( aSource[i-1] ==
'_' || aSource[i-1] ==
'^' || aSource[i-1] ==
'~' ) )
406 if( aSource[i] ==
'}' )
414 if( aSource[i] ==
':' )
417 token.append( aSource[i] );
424 wxString ref = token.BeforeFirst(
':', &remainder );
429 for(
size_t jj = 0; jj < references.
GetCount(); jj++ )
431 SCH_SYMBOL* refSymbol = references[ jj ].GetSymbol();
433 if( ref == refSymbol->
GetRef( &references[ jj ].GetSheetPath(),
true ) )
441 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
445 newbuf.append( aSource[i] );
456 size_t sourceLen = aSource.length();
458 for(
size_t i = 0; i < sourceLen; ++i )
460 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
463 bool isCrossRef =
false;
465 for( i = i + 2; i < sourceLen; ++i )
467 if( aSource[i] ==
'}' )
470 if( aSource[i] ==
':' )
473 token.append( aSource[i] );
480 wxString ref = token.BeforeFirst(
':', &remainder );
488 token = refSymbol->
GetRef( &refSheetPath,
true ) + wxS(
":" ) + remainder;
492 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
496 newbuf.append( aSource[i] );
530 wxString filename = rootFn.GetName();
546 int sheet_number = 1;
553 if( sheet.Path() == current_sheetpath )
559 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
570 std::map<wxString, std::set<int>>& pageRefsMap =
GetPageRefsMap();
575 std::vector<int> virtualPageNumbers;
580 virtualPageNumbers.clear();
585 if( sheet.LastScreen() == screen )
586 virtualPageNumbers.push_back( sheet.GetVirtualPageNumber() );
589 for(
SCH_ITEM* item : screen->Items() )
594 std::set<int>& virtualpageList = pageRefsMap[globalLabel->
GetText()];
596 for(
const int& pageNo : virtualPageNumbers )
597 virtualpageList.insert( pageNo );
607 std::vector<SCH_GLOBALLABEL*> currentSheetGlobalLabels;
610 currentSheetGlobalLabels.push_back(
static_cast<SCH_GLOBALLABEL*
>( item ) );
614 std::vector<SCH_FIELD>& fields = globalLabel->GetFields();
616 fields[0].SetVisible( show );
620 if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() )
621 globalLabel->AutoplaceFields(
CurrentSheet().LastScreen(),
false );
624 aItemCallback( globalLabel );
631 const wxString& aRange )
633 std::string spiceNetName( aNetName.Lower().ToStdString() );
636 if( spiceNetName ==
"gnd" || spiceNetName ==
"0" )
637 return wxEmptyString;
656 std::deque<EDA_ITEM*> allItems;
658 for(
auto item : screen->
Items() )
659 allItems.push_back( item );
665 screen->
Append( junction );
671 screen->
Append( newSegment );
void SetPageCount(int aPageCount)
void SetPageNumber(const wxString &aPageNumber)
void SetVirtualPageNumber(int aPageNumber)
Calculates 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.
virtual const wxString & GetText() const
Return the string associated with the text object.
Container for ERC settings.
std::set< wxString > m_ErcExclusions
wxString AsString() const
std::shared_ptr< RC_ITEM > GetRCItem() const
void SetExcluded(bool aExcluded)
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
virtual void OnSchItemsRemoved(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
virtual void OnSchItemsChanged(SCHEMATIC &aSch, std::vector< SCH_ITEM * > &aSchItem)
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 RemoveListener(SCHEMATIC_LISTENER *aListener)
Remove the specified listener.
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)
bool ResolveTextVar(wxString *token, int aDepth) const
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
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.
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)
Base class for any item which can be embedded within the SCHEMATIC container class,...
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.
wxString Serialize() const
bool IsLegacyMarker() const
Determines if this marker is legacy (i.e.
static SCH_MARKER * Deserialize(SCHEMATIC *schematic, const wxString &data)
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.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
Helper class to recognize Spice formatted values.
wxString ToString() const
Return string value as when converting double to string (e.g.
static void GetContextualTextVars(wxArrayString *aVars)
static bool empty(const wxTextEntryBase *aCtrl)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.