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!" ) );
224 wxLogDebug( wxS(
"Refreshing schematic heirarchy." ) );
233 [&](
const wxString& aVar )
236 aVars->push_back( aVar );
241 add( wxT(
"SHEETPATH" ) );
242 add( wxT(
"SHEETNAME" ) );
243 add( wxT(
"FILENAME" ) );
244 add( wxT(
"FILEPATH" ) );
245 add( wxT(
"PROJECTNAME" ) );
258 wxCHECK( aSheetPath,
false );
260 if( token->IsSameAs( wxT(
"#" ) ) )
265 else if( token->IsSameAs( wxT(
"##" ) ) )
267 *token = wxString::Format(
"%i",
Root().CountSheets() );
270 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
275 else if( token->IsSameAs( wxT(
"SHEETNAME" ) ) )
280 else if( token->IsSameAs( wxT(
"FILENAME" ) ) )
283 *token = fn.GetFullName();
286 else if( token->IsSameAs( wxT(
"FILEPATH" ) ) )
289 *token = fn.GetFullPath();
292 else if( token->IsSameAs( wxT(
"PROJECTNAME" ) ) )
301 if(
Prj().TextVarResolver( token ) )
338 std::set<wxString> migratedExclusions;
352 const wxString settingsKey = testMarker->
GetRCItem()->GetSettingsKey();
354 if( settingsKey != wxT(
"pin_to_pin" )
355 && settingsKey != wxT(
"hier_label_mismatch" )
356 && settingsKey != wxT(
"different_unit_net" ) )
371 settings.
m_ErcExclusions.insert( migratedExclusions.begin(), migratedExclusions.end() );
381 std::set<wxString>::iterator it = settings.
m_ErcExclusions.find( serialized );
391 std::vector<SCH_MARKER*> newMarkers;
400 newMarkers.push_back( marker );
414 for(
const std::shared_ptr<BUS_ALIAS>& alias : sheet.LastScreen()->GetBusAliases() )
416 if( alias->GetName() == aLabel )
427 std::set<wxString> names;
436 names.insert( key.Name );
447 wxString ref = token->BeforeFirst(
':', &remainder );
455 if( refSymbol->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
458 *token = refSymbol->
GetRef( &sheetPath,
true ) + wxS(
":" ) + remainder;
468 if( refSheet->
ResolveTextVar( &sheetPath, &remainder, aDepth + 1 ) )
480 std::map<int, wxString> namesMap;
484 if( sheet.size() == 1 )
485 namesMap[sheet.GetVirtualPageNumber()] =
_(
"<root sheet>" );
487 namesMap[sheet.GetVirtualPageNumber()] = sheet.Last()->GetName();
496 std::map<int, wxString> pagesMap;
499 pagesMap[sheet.GetVirtualPageNumber()] = sheet.GetPageNumber();
508 size_t sourceLen = aSource.length();
510 for(
size_t i = 0; i < sourceLen; ++i )
512 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
515 bool isCrossRef =
false;
518 for( i = i + 2; i < sourceLen; ++i )
520 if( aSource[i] ==
'{'
521 && ( aSource[i-1] ==
'_' || aSource[i-1] ==
'^' || aSource[i-1] ==
'~' ) )
526 if( aSource[i] ==
'}' )
534 if( aSource[i] ==
':' )
537 token.append( aSource[i] );
543 wxString ref = token.BeforeFirst(
':', &remainder );
548 for(
size_t jj = 0; jj < references.
GetCount(); jj++ )
550 SCH_SYMBOL* refSymbol = references[ jj ].GetSymbol();
552 if( ref == refSymbol->
GetRef( &references[ jj ].GetSheetPath(),
true ) )
560 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
564 newbuf.append( aSource[i] );
575 size_t sourceLen = aSource.length();
577 for(
size_t i = 0; i < sourceLen; ++i )
579 if( aSource[i] ==
'$' && i + 1 < sourceLen && aSource[i+1] ==
'{' )
582 bool isCrossRef =
false;
584 for( i = i + 2; i < sourceLen; ++i )
586 if( aSource[i] ==
'}' )
589 if( aSource[i] ==
':' )
592 token.append( aSource[i] );
598 wxString ref = token.BeforeFirst(
':', &remainder );
606 token = refSymbol->
GetRef( &refSheetPath,
true ) + wxS(
":" ) + remainder;
610 newbuf.append( wxS(
"${" ) + token + wxS(
"}" ) );
614 newbuf.append( aSource[i] );
637 wxString filename = rootFn.GetName();
653 int sheet_number = 1;
660 if( sheet.Path() == current_sheetpath )
666 for( screen = s_list.
GetFirst(); screen !=
nullptr; screen = s_list.
GetNext() )
677 std::map<wxString, std::set<int>>& pageRefsMap =
GetPageRefsMap();
686 wxString resolvedLabel = global->
GetShownText( &sheet,
false );
688 pageRefsMap[ resolvedLabel ].insert( sheet.GetVirtualPageNumber() );
697 std::vector<SCH_GLOBALLABEL*> currentSheetGlobalLabels;
700 currentSheetGlobalLabels.push_back(
static_cast<SCH_GLOBALLABEL*
>( item ) );
704 std::vector<SCH_FIELD>& fields = globalLabel->GetFields();
706 fields[0].SetVisible( show );
710 if( fields.size() == 1 && fields[0].GetTextPos() == globalLabel->GetPosition() )
711 globalLabel->AutoplaceFields(
CurrentSheet().LastScreen(),
false );
714 aItemCallback( globalLabel );
721 const wxString& aRange )
723 wxString spiceNetName( aNetName.Lower() );
726 if( spiceNetName == wxS(
"gnd" ) || spiceNetName == wxS(
"0" ) )
727 return wxEmptyString;
746 std::deque<EDA_ITEM*> allItems;
748 for(
auto item : screen->Items() )
749 allItems.push_back( item );
752 for(
const VECTOR2I& point : screen->GetNeededJunctions( allItems ) )
755 screen->Append( junction );
758 for(
SCH_LINE* wire : screen->GetBusesAndWires( point,
true ) )
761 screen->Append( newSegment );
826 for(
unsigned i = 0; i < sheetList.size(); i++ )
874 std::set<KIFONT::OUTLINE_FONT*>
fonts;
880 for(
SCH_ITEM* item : sheet.LastScreen()->Items() )
892 if( outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::EDITABLE
893 || outline->GetEmbeddingPermission() == EMBEDDING_PERMISSION::INSTALLABLE )
895 fonts.insert( outline );
907 wxLogTrace(
"EMBED",
"Failed to add font file: %s", font->GetFileName() );
918 std::set<const SCH_SCREEN*> retv;
931 const std::vector<SCH_SYMBOL_INSTANCE> symbolInstances = symbol->
GetInstances();
935 if( !hierarchy.
HasPath( instance.m_Path ) )
937 retv.insert( screen );
942 if( retv.count( screen ) )
959 wxCHECK2( screen,
continue );
961 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) 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".