40#ifndef QA_EESCHEMA_DATA_LOCATION
41 #define QA_EESCHEMA_DATA_LOCATION "???"
46 const char* env = std::getenv(
"KICAD_TEST_EESCHEMA_DATA_DIR" );
70 io.
Save( aFilename, &aSheet, &aSchematic );
75 std::ifstream fileStream;
76 fileStream.open( fileName );
77 wxASSERT( fileStream.is_open() );
85 std::unordered_map<std::string, SCH_SCREEN*>& parsedScreens )
92 const wxFileName fileName( sheetFilename );
93 const std::string filePath( fileName.GetPath( wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR ) );
94 const std::string fileBareName( fileName.GetFullName() );
97 auto screenFound = parsedScreens.find( fileBareName );
98 if( screenFound != parsedScreens.end() )
99 screen = screenFound->second;
112 parsedScreens.insert( { fileBareName, screen } );
122 wxFileName childSheetFilename = childSheet->
GetFileName();
123 if( !childSheetFilename.IsAbsolute() )
124 childSheetFilename.MakeAbsolute( filePath );
125 std::string childSheetFullFilename( childSheetFilename.GetFullPath() );
126 LoadHierarchy( schematic, childSheet, childSheetFullFilename, parsedScreens );
134 std::unique_ptr<SCHEMATIC> schematic(
new SCHEMATIC(
nullptr ) );
135 std::unordered_map<std::string, SCH_SCREEN*> parsedScreens;
137 schematic->SetProject(
project );
139 schematic->SetRoot( rootSheet );
140 LoadHierarchy( schematic.get(), rootSheet, rootFilename, parsedScreens );
147 std::unique_ptr<SCHEMATIC>& aSchematic )
151 PROJECT* prj = &aSchematic->Prj();
153 aSchematic->SetProject(
nullptr );
159 wxFileName projectFile( absPath +
".kicad_pro" );
160 wxFileName legacyProject( absPath +
".pro" );
161 std::string schematicPath = absPath +
".kicad_sch";
163 if( projectFile.Exists() )
164 aSettingsManager.
LoadProject( projectFile.GetFullPath() );
165 else if( legacyProject.Exists() )
166 aSettingsManager.
LoadProject( legacyProject.GetFullPath() );
174 aSchematic->CurrentSheet().push_back( &aSchematic->Root() );
179 screen->UpdateLocalLibSymbolLinks();
187 if( aSchematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
190 if( aSchematic->RootScreen()->GetFileFormatVersionAtLoad() < 20221206 )
193 screen->MigrateSimModels();
201 sheet.UpdateAllScreenReferences();
206 aSchematic->ConnectionGraph()->Recalculate( sheets,
true );
virtual void SetParent(EDA_ITEM *aParent)
EE_TYPE OfType(KICAD_T aType) const
Container for project specific data.
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Holds all the data relating to one schematic.
Base class for any item which can be embedded within the SCHEMATIC container class,...
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.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Object to parser s-expression symbol library and schematic file formats.
void ParseSchematic(SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
Parse the internal LINE_READER object into aSheet.
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.
void Save(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about,...
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.
wxString GetFileName() const
Return the filename corresponding to this sheet.
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)
Loads a project or sets up a new project with a specified path.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters 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 > LoadHierarchyFromRoot(const std::string &rootFilename, PROJECT *project)
void LoadSheetSchematicContents(const std::string &fileName, SCH_SHEET *sheet)
void LoadHierarchy(SCHEMATIC *schematic, SCH_SHEET *sheet, const std::string &sheetFilename, std::unordered_map< std::string, SCH_SCREEN * > &parsedScreens)
void LoadSchematic(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< SCHEMATIC > &aSchematic)
void DumpSchematicToFile(SCHEMATIC &aSchematic, SCH_SHEET &aSheet, const std::string &aFilename)
std::string getEeschemaTestDataDir()
Schematic and symbol library s-expression file format parser definitions.
#define QA_EESCHEMA_DATA_LOCATION