24#include <unordered_set>
53 auto schematic = std::make_unique<SCHEMATIC>(
project );
55 SCH_SHEET* defaultSheet = schematic->GetTopLevelSheet( 0 );
59 schematic->AddTopLevelSheet( rootSheet );
60 schematic->RemoveTopLevelSheet( defaultSheet );
64 throw std::runtime_error( io.
GetError().ToStdString( wxConvUTF8 ) );
71 std::unique_ptr<SCHEMATIC> schematic(
new SCHEMATIC(
nullptr ) );
72 schematic->SetProject( aProject );
77 schematic->SetTopLevelSheets( { rootSheet } );
87 SCH_SHEET_LIST sheets = schematic->BuildSheetListSortedByPageNumbers();
92 sheet.UpdateAllScreenReferences();
96 if( schematic->ConnectionGraph() )
99 schematic->ConnectionGraph()->SetNetChainColorOverrides( parser.
GetNetChainColors() );
101 std::map<wxString, CONNECTION_GRAPH::CHAIN_TERMINAL_REFS> termRefs;
105 termRefs[
name] = { { terms.first.ref, terms.first.pin },
106 { terms.second.ref, terms.second.pin } };
109 schematic->ConnectionGraph()->SetNetChainTerminalRefOverrides( termRefs );
118 std::unique_ptr<SCHEMATIC>& aSchematic )
122 PROJECT* prj = &aSchematic->Project();
124 aSchematic->SetProject(
nullptr );
130 wxFileName projectFile( absPath +
".kicad_pro" );
131 wxFileName legacyProject( absPath +
".pro" );
132 std::string schematicPath = absPath +
".kicad_sch";
134 if( projectFile.Exists() )
135 aSettingsManager.
LoadProject( projectFile.GetFullPath() );
136 else if( legacyProject.Exists() )
137 aSettingsManager.
LoadProject( legacyProject.GetFullPath() );
148 screen->UpdateLocalLibSymbolLinks();
150 SCH_SHEET_LIST sheets = aSchematic->BuildSheetListSortedByPageNumbers();
156 if( aSchematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
159 if( aSchematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
162 screen->MigrateSimModels();
171 sheet.UpdateAllScreenReferences();
176 std::unordered_set<SCH_SCREEN*> allScreens;
179 allScreens.insert(
path.LastScreen() );
182 aSchematic->ConnectionGraph()->Recalculate( sheets,
true );
virtual void SetParent(EDA_ITEM *aParent)
Container for project specific data.
virtual void SetElem(PROJECT::ELEM aIndex, _ELEM *aElem)
Holds all the data relating to one schematic.
Object to parser s-expression symbol library and schematic file formats.
const std::map< wxString, wxString > & GetNetChainNetClasses() const
const std::map< wxString, COLOR4D > & GetNetChainColors() const
void ParseSchematic(SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
Parse the internal LINE_READER object into aSheet.
const std::map< wxString, CHAIN_TERMINALS > & GetNetChainTerminalRefs() const
const std::map< wxString, std::set< wxString > > & GetNetChainMemberNets() const
A SCH_IO derivation for loading schematic files using the new s-expression file format.
const wxString & GetError() const override
Return an error string to the caller.
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Update all rule area connectvity / caches in the given sheet paths.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void FixLegacyPowerSymbolMismatches()
Fix legacy power symbols that have mismatched value text fields and invisible power pin names.
void UpdateLocalLibSymbolLinks()
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in this schematic with the local projec...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void UpdateSheetInstanceData(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
void UpdateSymbolInstanceData(const std::vector< SCH_SYMBOL_INSTANCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
SCH_SCREEN * GetScreen() const
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister the given PROJECT.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
LINE_READER that wraps a given std::istream instance.
void SetStream(std::istream &aStream)
Set the stream for this line reader.
std::unique_ptr< SCHEMATIC > ReadSchematicFromStream(std::istream &aStream, PROJECT *aProject)
std::unique_ptr< SCHEMATIC > LoadHierarchyFromRoot(const std::string &rootFilename, PROJECT *project)
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
void DumpSchematicToFile(SCHEMATIC &aSchematic, SCH_SHEET &aSheet, const std::string &aFilename)