36#include <wx/filename.h>
45 wxCHECK( aSheet,
false );
50 wxFileName schematicFileName( aPath );
51 schematicFileName.MakeAbsolute();
53 if( !schematicFileName.DirExists() && !wxMkdir( schematicFileName.GetPath() ) )
56 if( schematicFileName.FileExists() && !schematicFileName.IsFileWritable() )
59 if( schematicFileName.FileExists() )
64 if( pluginType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
65 pluginType = SCH_IO_MGR::SCH_KICAD;
71 pi->SaveSchematicFile( schematicFileName.GetFullPath(), aSheet, &aSchematic );
76 wxLogTrace( wxS(
"KI_TRACE_API" ), wxS(
"SaveSheetToFile failed: %s" ), ioe.
What() );
89 wxFileName projectFile( rootScreen->
GetFileName() );
92 if( !projectFile.HasName() || !projectFile.IsOk() )
106 if( !topLevelSheets.empty() )
109 projectSheets.clear();
116 info.uuid = sheet->m_Uuid;
117 info.name = sheet->GetName();
121 if( sheet->GetScreen() )
122 filename = sheet->GetScreen()->GetFileName();
124 wxFileName sheetFn( filename );
126 if( sheetFn.IsAbsolute() )
127 sheetFn.MakeRelativeTo( projectPath );
129 info.filename = sheetFn.GetFullPath();
130 projectSheets.push_back( std::move(
info ) );
144 wxCHECK2( sheet,
continue );
147 sheets.emplace_back( std::make_pair( sheet->
m_Uuid, sheet->
GetName() ) );
158 if( !rootScreen || rootScreen->
GetFileName().IsEmpty() )
166 for(
size_t i = 0; i < screens.
GetCount(); i++ )
170 wxCHECK2( screen,
continue );
174 if( !fileName.IsOk() )
179 if( sheets.size() == 1 )
199 wxFileName schematicFileName( aFileName );
200 schematicFileName.MakeAbsolute();
202 if( !schematicFileName.IsOk() || !schematicFileName.IsDirWritable() )
210 if( !
SaveSheetToFile( rootSheet, aSchematic, schematicFileName.GetFullPath() ) )
215 wxFileName projectFile( schematicFileName );
218 if( !projectFile.FileExists() )
BASE_SCREEN class implementation.
void SetVirtualPageNumber(int aPageNumber)
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
void SetContentModified(bool aModified=true)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual SETTINGS_MANAGER & GetSettingsManager() const
std::vector< FILE_INFO_PAIR > & GetSheets()
SCHEMATIC_SETTINGS * m_SchematicSettings
struct IP2581_BOM m_IP2581Bom
Layer pair list for the board.
std::vector< TOP_LEVEL_SHEET_INFO > & GetTopLevelSheets()
Container for project specific data.
virtual const wxString GetProjectPath() const
Return the full path of the project.
virtual PROJECT_FILE & GetProjectFile() const
wxString m_SchDrawingSheetFileName
Holds all the data relating to one schematic.
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
bool HasHierarchy() const
Check if the hierarchy has been built.
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
std::vector< SCH_SHEET * > GetTopLevelSheets() const
Get the list of top-level sheets.
static SCH_FILE_T GuessPluginTypeFromSchPath(const wxString &aSchematicPath, int aCtl=0)
Return a plugin type given a schematic using the file extension of aSchematicPath.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
SCH_SCREEN * GetScreen(unsigned int aIndex) const
void BuildClientSheetPathList()
Build the list of sheet paths sharing a screen for each screen in use.
SCH_SHEET * GetSheet(unsigned int aIndex) const
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
const wxString & GetFileName() const
TITLE_BLOCK & GetTitleBlock()
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.
bool IsVirtualRootSheet() const
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Save a loaded project.
bool SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Save a copy of the current project under the given path.
const wxString & GetRevision() const
static const std::string ProjectFileExtension
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
bool SaveSheetToFile(SCH_SHEET *aSheet, SCHEMATIC &aSchematic, const wxString &aPath)
Write a single sheet to disk via SCH_IO.
bool SaveSchematic(SCHEMATIC &aSchematic, PROJECT &aProject)
Save every screen in the hierarchy to its current path, then update the project file.
void UpdateProjectFile(SCHEMATIC &aSchematic, PROJECT &aProject)
Sync schematic metadata into the project file (.kicad_pro) and save it.
bool SaveSchematicCopy(SCHEMATIC &aSchematic, PROJECT &aProject, const wxString &aFileName, bool aCreateProject)
Save the root schematic to aFileName without changing the open document.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
wxString schRevision
Auto-propagated schematic title block revision.
Information about a top-level schematic sheet.
Definition of file extensions used in Kicad.