USe setactive in cli in the LoadSchematic helper too

This commit is contained in:
Marek Roszko 2024-02-16 00:08:10 -05:00
parent b2c6e2de1f
commit 9e08e6e4f1
3 changed files with 15 additions and 13 deletions

View File

@ -78,19 +78,20 @@ PROJECT* EESCHEMA_HELPERS::GetDefaultProject()
} }
SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( wxString& aFileName ) SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( wxString& aFileName, bool aSetActive )
{ {
if( aFileName.EndsWith( FILEEXT::KiCadSchematicFileExtension ) ) if( aFileName.EndsWith( FILEEXT::KiCadSchematicFileExtension ) )
return LoadSchematic( aFileName, SCH_IO_MGR::SCH_KICAD ); return LoadSchematic( aFileName, SCH_IO_MGR::SCH_KICAD, aSetActive );
else if( aFileName.EndsWith( FILEEXT::LegacySchematicFileExtension ) ) else if( aFileName.EndsWith( FILEEXT::LegacySchematicFileExtension ) )
return LoadSchematic( aFileName, SCH_IO_MGR::SCH_LEGACY ); return LoadSchematic( aFileName, SCH_IO_MGR::SCH_LEGACY, aSetActive );
// as fall back for any other kind use the legacy format // as fall back for any other kind use the legacy format
return LoadSchematic( aFileName, SCH_IO_MGR::SCH_LEGACY ); return LoadSchematic( aFileName, SCH_IO_MGR::SCH_LEGACY, aSetActive );
} }
SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( wxString& aFileName, SCH_IO_MGR::SCH_FILE_T aFormat ) SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( wxString& aFileName, SCH_IO_MGR::SCH_FILE_T aFormat,
bool aSetActive )
{ {
wxFileName pro = aFileName; wxFileName pro = aFileName;
pro.SetExt( FILEEXT::ProjectFileExtension ); pro.SetExt( FILEEXT::ProjectFileExtension );
@ -107,7 +108,7 @@ SCHEMATIC* EESCHEMA_HELPERS::LoadSchematic( wxString& aFileName, SCH_IO_MGR::SCH
{ {
if( wxFileExists( projectPath ) ) if( wxFileExists( projectPath ) )
{ {
GetSettingsManager()->LoadProject( projectPath, false ); GetSettingsManager()->LoadProject( projectPath, aSetActive );
project = GetSettingsManager()->GetProject( projectPath ); project = GetSettingsManager()->GetProject( projectPath );
} }
} }

View File

@ -44,8 +44,9 @@ public:
static SETTINGS_MANAGER* GetSettingsManager(); static SETTINGS_MANAGER* GetSettingsManager();
static void SetSchEditFrame( SCH_EDIT_FRAME* aSchEditFrame ); static void SetSchEditFrame( SCH_EDIT_FRAME* aSchEditFrame );
static PROJECT* GetDefaultProject(); static PROJECT* GetDefaultProject();
static SCHEMATIC* LoadSchematic( wxString& aFileName ); static SCHEMATIC* LoadSchematic( wxString& aFileName, bool aSetActive );
static SCHEMATIC* LoadSchematic( wxString& aFileName, SCH_IO_MGR::SCH_FILE_T aFormat ); static SCHEMATIC* LoadSchematic( wxString& aFileName, SCH_IO_MGR::SCH_FILE_T aFormat,
bool aSetActive );
private: private:

View File

@ -139,7 +139,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportPlot( JOB* aJob )
if( !aPlotJob ) if( !aPlotJob )
return CLI::EXIT_CODES::ERR_UNKNOWN; return CLI::EXIT_CODES::ERR_UNKNOWN;
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPlotJob->m_filename, SCH_IO_MGR::SCH_KICAD ); SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPlotJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
if( sch == nullptr ) if( sch == nullptr )
{ {
@ -238,7 +238,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportNetlist( JOB* aJob )
if( !aNetJob ) if( !aNetJob )
return CLI::EXIT_CODES::ERR_UNKNOWN; return CLI::EXIT_CODES::ERR_UNKNOWN;
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD ); SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
if( sch == nullptr ) if( sch == nullptr )
{ {
@ -343,7 +343,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportBom( JOB* aJob )
if( !aBomJob ) if( !aBomJob )
return CLI::EXIT_CODES::ERR_UNKNOWN; return CLI::EXIT_CODES::ERR_UNKNOWN;
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aBomJob->m_filename, SCH_IO_MGR::SCH_KICAD ); SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aBomJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
if( sch == nullptr ) if( sch == nullptr )
{ {
@ -602,7 +602,7 @@ int EESCHEMA_JOBS_HANDLER::JobExportPythonBom( JOB* aJob )
if( !aNetJob ) if( !aNetJob )
return CLI::EXIT_CODES::ERR_UNKNOWN; return CLI::EXIT_CODES::ERR_UNKNOWN;
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD ); SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aNetJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
if( sch == nullptr ) if( sch == nullptr )
{ {
@ -942,7 +942,7 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
if( !ercJob ) if( !ercJob )
return CLI::EXIT_CODES::ERR_UNKNOWN; return CLI::EXIT_CODES::ERR_UNKNOWN;
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( ercJob->m_filename, SCH_IO_MGR::SCH_KICAD ); SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( ercJob->m_filename, SCH_IO_MGR::SCH_KICAD, true );
if( sch == nullptr ) if( sch == nullptr )
{ {