37#include <wx/filename.h>
46 wxCHECK( aSheet,
false );
51 wxFileName schematicFileName( aPath );
52 schematicFileName.MakeAbsolute();
54 if( !schematicFileName.DirExists() && !wxMkdir( schematicFileName.GetPath() ) )
57 if( schematicFileName.FileExists() && !schematicFileName.IsFileWritable() )
60 if( schematicFileName.FileExists() )
65 if( pluginType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
66 pluginType = SCH_IO_MGR::SCH_KICAD;
72 pi->SaveSchematicFile( schematicFileName.GetFullPath(), aSheet, &aSchematic );
77 wxLogTrace( wxS(
"KI_TRACE_API" ), wxS(
"SaveSheetToFile failed: %s" ), ioe.
What() );
90 wxFileName projectFile( rootScreen->
GetFileName() );
93 if( !projectFile.HasName() || !projectFile.IsOk() )
107 if( !topLevelSheets.empty() )
110 projectSheets.clear();
117 info.uuid = sheet->m_Uuid;
118 info.name = sheet->GetName();
122 if( sheet->GetScreen() )
123 filename = sheet->GetScreen()->GetFileName();
125 wxFileName sheetFn( filename );
127 if( sheetFn.IsAbsolute() )
128 sheetFn.MakeRelativeTo( projectPath );
130 info.filename = sheetFn.GetFullPath();
131 projectSheets.push_back( std::move(
info ) );
145 wxCHECK2( sheet,
continue );
148 sheets.emplace_back( std::make_pair( sheet->
m_Uuid, sheet->
GetName() ) );
159 if( !rootScreen || rootScreen->
GetFileName().IsEmpty() )
167 for(
size_t i = 0; i < screens.
GetCount(); i++ )
171 wxCHECK2( screen,
continue );
175 if( !fileName.IsOk() )
180 if( sheets.size() == 1 )
200 wxFileName schematicFileName( aFileName );
201 schematicFileName.MakeAbsolute();
203 if( !schematicFileName.IsOk() || !schematicFileName.IsDirWritable() )
210 if( !rootSheet || !rootScreen )
213 if( schematicFileName.GetFullPath() == rootScreen->
GetFileName() )
216 if( !
SaveSheetToFile( rootSheet, aSchematic, schematicFileName.GetFullPath() ) )
221 wxFileName projectFile( schematicFileName );
224 if( !projectFile.FileExists() )
226 if( !
Pgm().GetSettingsManager().SaveProjectCopy( projectFile.GetFullPath() ) )
238 schematicFileName.MakeAbsolute();
240 if( !schematicFileName.IsOk() || schematicFileName.GetName().IsEmpty() )
243 if( ( !schematicFileName.DirExists() && !schematicFileName.Mkdir() ) || !schematicFileName.IsDirWritable() )
254 wxFileName projectFile( schematicFileName );
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 void SetReadOnly(bool aReadOnly=true)
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_SHEET * GetTopLevelSheet(int aIndex=0) const
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
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
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.
void SetFileName(const wxString &aFilename)
bool IsVirtualRootSheet() const
void SaveProjectAs(const wxString &aFullPath, PROJECT *aProject=nullptr)
Set the currently loaded project path and saves it (pointers remain valid).
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Save a loaded project.
const wxString & GetRevision() const
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
static const std::string ProjectFileExtension
static const std::string KiCadSchematicFileExtension
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.
bool SaveSchematicAs(SCHEMATIC &aSchematic, PROJECT &aProject, const wxString &aFileName)
Save the schematic to aFileName and adopt it: the root sheet and screen are re-homed to the new path,...
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.