Wait to save non-KiCad imported drawing sheet until user requests a save
This commit is contained in:
parent
d063eb431b
commit
ff717fec3f
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <mutex>
|
||||
#include <wx/ffile.h>
|
||||
|
||||
#include <symbol_library.h>
|
||||
#include <confirm.h>
|
||||
|
@ -64,6 +65,8 @@ bool SCH_EDIT_FRAME::LoadProjectSettings()
|
|||
LIB_SYMBOL::SetSubpartIdNotation( LIB_SYMBOL::GetSubpartIdSeparator(),
|
||||
LIB_SYMBOL::GetSubpartFirstId() );
|
||||
|
||||
BASE_SCREEN::m_DrawingSheetFileName = settings.m_SchDrawingSheetFileName;
|
||||
|
||||
// Load the drawing sheet from the filename stored in BASE_SCREEN::m_DrawingSheetFileName.
|
||||
// If empty, or not existing, the default drawing sheet is loaded.
|
||||
wxString filename = DS_DATA_MODEL::ResolvePath( BASE_SCREEN::m_DrawingSheetFileName,
|
||||
|
@ -127,6 +130,22 @@ void SCH_EDIT_FRAME::SaveProjectSettings()
|
|||
|
||||
RecordERCExclusions();
|
||||
|
||||
// TODO: We need to remove dependence on BASE_SCREEN
|
||||
Prj().GetProjectFile().m_SchematicSettings->m_SchDrawingSheetFileName = BASE_SCREEN::m_DrawingSheetFileName;
|
||||
|
||||
if( !BASE_SCREEN::m_DrawingSheetFileName.IsEmpty() )
|
||||
{
|
||||
// Save the page layout file if doesn't exist yet (e.g. if we opened a non-kicad schematic)
|
||||
|
||||
wxFileName layoutfn( BASE_SCREEN::m_DrawingSheetFileName );
|
||||
|
||||
if( !layoutfn.IsAbsolute() )
|
||||
layoutfn = wxFileName( Prj().GetProjectPath(), BASE_SCREEN::m_DrawingSheetFileName );
|
||||
|
||||
if( !layoutfn.FileExists() )
|
||||
DS_DATA_MODEL::GetTheInstance().Save( layoutfn.GetAbsolutePath() );
|
||||
}
|
||||
|
||||
GetSettingsManager()->SaveProject( fn.GetFullPath() );
|
||||
}
|
||||
|
||||
|
|
|
@ -1237,16 +1237,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
|||
// to KiCad), so set it to an empty one
|
||||
DS_DATA_MODEL& drawingSheet = DS_DATA_MODEL::GetTheInstance();
|
||||
drawingSheet.SetEmptyLayout();
|
||||
|
||||
BASE_SCREEN::m_DrawingSheetFileName = "empty.kicad_wks";
|
||||
wxFileName layoutfn( Prj().GetProjectPath(), BASE_SCREEN::m_DrawingSheetFileName );
|
||||
wxFFile layoutfile;
|
||||
|
||||
if( layoutfile.Open( layoutfn.GetFullPath(), "wb" ) )
|
||||
{
|
||||
layoutfile.Write( DS_DATA_MODEL::EmptyLayout() );
|
||||
layoutfile.Close();
|
||||
}
|
||||
|
||||
newfilename.SetPath( Prj().GetProjectPath() );
|
||||
newfilename.SetName( Prj().GetProjectName() );
|
||||
|
|
|
@ -23,11 +23,12 @@
|
|||
#include <lib_symbol.h>
|
||||
#include <default_values.h>
|
||||
#include <eeschema_settings.h>
|
||||
#include <kiface_base.h>
|
||||
#include <macros.h>
|
||||
#include <pgm_base.h>
|
||||
#include <schematic_settings.h>
|
||||
#include <settings/json_settings_internals.h>
|
||||
#include <settings/parameters.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <sim/spice_settings.h>
|
||||
|
||||
|
||||
|
@ -58,7 +59,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
|
|||
m_SpiceModelCurSheetAsRoot( true ),
|
||||
m_NgspiceSimulatorSettings( nullptr )
|
||||
{
|
||||
EESCHEMA_SETTINGS* appSettings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
EESCHEMA_SETTINGS* appSettings = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||
|
||||
int defaultLineThickness =
|
||||
appSettings ? appSettings->m_Drawing.default_line_thickness : DEFAULT_LINE_WIDTH_MILS;
|
||||
|
@ -163,7 +164,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
|
|||
}
|
||||
}
|
||||
|
||||
auto* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
auto* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||
|
||||
if( cfg )
|
||||
{
|
||||
|
@ -172,7 +173,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
|
|||
|
||||
if( !templateFieldNames.IsEmpty() )
|
||||
{
|
||||
TEMPLATE_FIELDNAMES_LEXER field_lexer( TO_UTF8( templateFieldNames ) );
|
||||
TEMPLATE_FIELDNAMES_LEXER field_lexer( TO_UTF8( templateFieldNames ) );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -185,9 +186,8 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
|
|||
}
|
||||
}, {} ) );
|
||||
|
||||
// TODO(JE) get rid of this static
|
||||
m_params.emplace_back( new PARAM<wxString>( "page_layout_descr_file",
|
||||
&BASE_SCREEN::m_DrawingSheetFileName, "" ) );
|
||||
&m_SchDrawingSheetFileName, "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<wxString>( "plot_directory",
|
||||
&m_PlotDirectoryName, "" ) );
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
double m_DashedLineDashRatio; // Dash length as ratio of the lineWidth
|
||||
double m_DashedLineGapRatio; // Gap length as ratio of the lineWidth
|
||||
|
||||
wxString m_SchDrawingSheetFileName;
|
||||
wxString m_PlotDirectoryName;
|
||||
|
||||
wxString m_NetFormatName;
|
||||
|
|
Loading…
Reference in New Issue