37 m_rootSheet( nullptr )
61 delete project.m_SchematicSettings;
63 project.m_ErcSettings =
nullptr;
64 project.m_SchematicSettings =
nullptr;
85 delete project.m_SchematicSettings;
87 project.m_ErcSettings =
nullptr;
88 project.m_SchematicSettings =
nullptr;
99 project.m_SchematicSettings->LoadFromFile();
100 project.m_SchematicSettings->m_NgspiceSimulatorSettings->LoadFromFile();
101 project.m_ErcSettings->LoadFromFile();
108 wxCHECK_RET( aRootSheet, wxS(
"Call to SetRoot with null SCH_SHEET!" ) );
129 if( token->IsSameAs( wxT(
"#" ) ) )
134 else if( token->IsSameAs( wxT(
"##" ) ) )
139 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
144 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
149 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
152 *token = fn.GetFullName();
155 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) )
165 if(
Prj().TextVarResolver( token ) )
202 std::set<wxString> migratedExclusions;
209 const wxString settingsKey = testMarker->
GetRCItem()->GetSettingsKey();
211 if( settingsKey != wxT(
"pin_to_pin" ) && settingsKey != wxT(
"hier_label_mismatch" )
212 && settingsKey != wxT(
"different_unit_net" ) )
214 migratedExclusions.insert( testMarker->
Serialize() );
226 settings.
m_ErcExclusions.insert( migratedExclusions.begin(), migratedExclusions.end() );
245 std::vector<SCH_MARKER*> newMarkers;
254 newMarkers.push_back( marker );
268 for(
const std::shared_ptr<BUS_ALIAS>& alias : sheet.LastScreen()->GetBusAliases() )
270 if( alias->GetName() == aLabel )
281 std::set<wxString> names;
290 names.insert( key.Name );
302 wxString ref = token->BeforeFirst(
':', &remainder );
313 *token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
333 std::map<int, wxString> namesMap;
337 if( sheet.size() == 1 )
338 namesMap[sheet.GetVirtualPageNumber()] =
_(
"<root sheet>" );
340 namesMap[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName();
349 std::map<int, wxString> pagesMap;
352 pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
361 size_t sourceLen = aSource.length();
363 for(
size_t i = 0; i < sourceLen; ++i )
365 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
368 bool isCrossRef =
false;
371 for( i = i + 2; i < sourceLen; ++i )
373 if( aSource[i] ==
'{'
374 && ( aSource[i-1] ==
'_' || aSource[i-1] ==
'^' || aSource[i-1] ==
'~' ) )
379 if( aSource[i] ==
'}' )
387 if( aSource[i] ==
':' )
390 token.append( aSource[i] );
397 wxString ref = token.BeforeFirst(
':', &remainder );
402 for(
size_t jj = 0; jj < references.
GetCount(); jj++ )
404 SCH_SYMBOL* refSymbol = references[ jj ].GetSymbol();
406 if( ref == refSymbol->
GetRef( &references[ jj ].GetSheetPath(),
true ) )
414 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
418 newbuf.append( aSource[i] );
429 size_t sourceLen = aSource.length();
431 for(
size_t i = 0; i < sourceLen; ++i )
433 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
436 bool isCrossRef =
false;
438 for( i = i + 2; i < sourceLen; ++i )
440 if( aSource[i] ==
'}' )
443 if( aSource[i] ==
':' )
446 token.append( aSource[i] );
453 wxString ref = token.BeforeFirst(
':', &remainder );
461 token = refSymbol->
GetRef( &refSheetPath,
true ) + wxS(
":" ) + remainder;
465 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
469 newbuf.append( aSource[i] );
503 wxString filename = rootFn.GetName();
519 int sheet_number = 1;
526 if( sheet.Path() == current_sheetpath )
532 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
543 std::map<wxString, std::set<int>>& pageRefsMap =
GetPageRefsMap();
548 std::vector<int> virtualPageNumbers;
553 virtualPageNumbers.clear();
558 if( sheet.LastScreen() == screen )
559 virtualPageNumbers.push_back( sheet.GetVirtualPageNumber() );
562 for(
SCH_ITEM* item : screen->Items() )
567 std::set<int>& virtualpageList = pageRefsMap[globalLabel->
GetText()];
569 for(
const int& pageNo : virtualPageNumbers )
570 virtualpageList.insert( pageNo );
580 std::vector<SCH_GLOBALLABEL*> currentSheetGlobalLabels;
583 currentSheetGlobalLabels.push_back(
static_cast<SCH_GLOBALLABEL*
>( item ) );
587 std::vector<SCH_FIELD>& fields = globalLabel->GetFields();
589 fields[0].SetVisible( show );
593 if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() )
594 globalLabel->AutoplaceFields(
CurrentSheet().LastScreen(),
false );
597 aItemCallback( globalLabel );
609 std::deque<EDA_ITEM*> allItems;
611 for(
auto item : screen->
Items() )
612 allItems.push_back( item );
618 screen->
Append( junction );
624 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.
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
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)
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
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.
CONNECTION_GRAPH * m_connectionGraph
Holds and calculates connectivity information of this schematic.
SCH_SHEET_PATH & CurrentSheet() const override
SCH_SHEET_PATH * m_currentSheet
The sheet path of the sheet currently being edited or displayed.
bool ResolveTextVar(wxString *token, int aDepth) const
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)
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 ...
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
std::map< int, wxString > GetVirtualPageToSheetNamesMap() const
wxString GetUniqueFilenameForCurrentSheet()
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
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.
ERC_SETTINGS & ErcSettings() const
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 Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
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
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.
void Append(SCH_ITEM *aItem)
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(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(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
static bool empty(const wxTextEntryBase *aCtrl)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.