2011-10-28 13:43:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2020-06-03 20:13:01 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-03-19 11:30:53 +00:00
|
|
|
* Copyright (C) 2004-2023 KiCad Developers, see change_log.txt for contributors.
|
2011-10-28 13:43:37 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2023-08-14 00:31:19 +00:00
|
|
|
#include <cli_progress_reporter.h>
|
2016-11-24 17:57:53 +00:00
|
|
|
#include <confirm.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gestfich.h>
|
|
|
|
#include <eda_dde.h>
|
2022-10-26 21:59:33 +00:00
|
|
|
#include "eeschema_jobs_handler.h"
|
|
|
|
#include "eeschema_helpers.h"
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <eeschema_settings.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_edit_frame.h>
|
2020-12-25 23:37:01 +00:00
|
|
|
#include <symbol_viewer_frame.h>
|
2023-09-28 13:09:45 +00:00
|
|
|
#include <symbol_chooser_frame.h>
|
2016-11-24 17:57:53 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2018-08-06 18:33:28 +00:00
|
|
|
#include <dialogs/dialog_global_sym_lib_table_config.h>
|
2023-08-26 12:29:24 +00:00
|
|
|
#include <dialogs/panel_grid_settings.h>
|
2018-08-06 18:33:28 +00:00
|
|
|
#include <dialogs/panel_sym_lib_table.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiway.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <symbol_editor_settings.h>
|
2019-11-10 14:51:06 +00:00
|
|
|
#include <sexpr/sexpr.h>
|
|
|
|
#include <sexpr/sexpr_parser.h>
|
2020-09-18 14:19:47 +00:00
|
|
|
#include <kiface_ids.h>
|
|
|
|
#include <netlist_exporters/netlist_exporter_kicad.h>
|
2020-12-12 18:11:51 +00:00
|
|
|
#include <wx/ffile.h>
|
2021-03-03 01:06:25 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-09-18 14:19:47 +00:00
|
|
|
|
|
|
|
#include <schematic.h>
|
|
|
|
#include <connection_graph.h>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <panel_template_fieldnames.h>
|
|
|
|
#include <panel_eeschema_color_settings.h>
|
|
|
|
#include <panel_sym_color_settings.h>
|
|
|
|
#include <panel_eeschema_editing_options.h>
|
2022-03-30 17:41:40 +00:00
|
|
|
#include <panel_eeschema_annotation_options.h>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <panel_sym_editing_options.h>
|
|
|
|
#include <dialogs/panel_gal_display_options.h>
|
2021-09-15 20:03:07 +00:00
|
|
|
#include <panel_eeschema_display_options.h>
|
2021-11-01 11:20:13 +00:00
|
|
|
#include <panel_sym_display_options.h>
|
2023-03-03 22:36:07 +00:00
|
|
|
#include <sim/simulator_frame.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2022-12-08 04:55:47 +00:00
|
|
|
#include <wx/crt.h>
|
|
|
|
|
2015-04-22 11:39:00 +00:00
|
|
|
// The main sheet of the project
|
2021-07-16 20:13:26 +00:00
|
|
|
SCH_SHEET* g_RootSheet = nullptr;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
namespace SCH {
|
|
|
|
|
2020-09-18 14:19:47 +00:00
|
|
|
|
|
|
|
static std::unique_ptr<SCHEMATIC> readSchematicFromFile( const std::string& aFilename )
|
|
|
|
{
|
|
|
|
auto pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
|
2020-10-26 23:49:11 +00:00
|
|
|
std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
|
2020-09-18 14:19:47 +00:00
|
|
|
|
|
|
|
auto &manager = Pgm().GetSettingsManager();
|
|
|
|
|
|
|
|
manager.LoadProject( "" );
|
|
|
|
schematic->Reset();
|
|
|
|
schematic->SetProject( &manager.Prj() );
|
2023-08-26 19:28:53 +00:00
|
|
|
schematic->SetRoot( pi->LoadSchematicFile( aFilename, schematic.get() ) );
|
2020-09-18 14:19:47 +00:00
|
|
|
schematic->CurrentSheet().push_back( &schematic->Root() );
|
|
|
|
|
|
|
|
SCH_SCREENS screens( schematic->Root() );
|
|
|
|
|
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
|
|
|
screen->UpdateLocalLibSymbolLinks();
|
|
|
|
|
|
|
|
SCH_SHEET_LIST sheets = schematic->GetSheets();
|
|
|
|
|
|
|
|
// Restore all of the loaded symbol instances from the root sheet screen.
|
2022-12-06 14:00:11 +00:00
|
|
|
sheets.UpdateSymbolInstanceData( schematic->RootScreen()->GetSymbolInstances() );
|
2020-09-18 14:19:47 +00:00
|
|
|
|
2023-02-20 17:55:02 +00:00
|
|
|
if( schematic->RootScreen()->GetFileFormatVersionAtLoad() < 20230221 )
|
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
|
|
|
screen->FixLegacyPowerSymbolMismatches();
|
|
|
|
|
2022-12-07 23:40:05 +00:00
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
|
|
|
screen->MigrateSimModels();
|
2022-12-07 01:34:10 +00:00
|
|
|
|
2020-09-18 14:19:47 +00:00
|
|
|
sheets.AnnotatePowerSymbols();
|
|
|
|
|
|
|
|
// NOTE: This is required for multi-unit symbols to be correct
|
|
|
|
for( SCH_SHEET_PATH& sheet : sheets )
|
|
|
|
sheet.UpdateAllScreenReferences();
|
|
|
|
|
|
|
|
// NOTE: SchematicCleanUp is not called; QA schematics must already be clean or else
|
|
|
|
// SchematicCleanUp must be freed from its UI dependencies.
|
|
|
|
|
|
|
|
schematic->ConnectionGraph()->Recalculate( sheets, true );
|
|
|
|
|
|
|
|
return schematic;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-02 23:04:56 +00:00
|
|
|
bool generateSchematicNetlist( const wxString& aFilename, std::string& aNetlist )
|
2020-09-18 14:19:47 +00:00
|
|
|
{
|
2020-10-26 23:49:11 +00:00
|
|
|
std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
|
2020-09-18 14:19:47 +00:00
|
|
|
NETLIST_EXPORTER_KICAD exporter( schematic.get() );
|
|
|
|
STRING_FORMATTER formatter;
|
|
|
|
|
|
|
|
exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
|
|
|
|
aNetlist = formatter.GetString();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
static struct IFACE : public KIFACE_BASE, public UNITS_PROVIDER
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// Of course all are virtual overloads, implementations of the KIFACE.
|
|
|
|
|
|
|
|
IFACE( const char* aName, KIWAY::FACE_T aType ) :
|
2022-12-03 19:31:41 +00:00
|
|
|
KIFACE_BASE( aName, aType ),
|
|
|
|
UNITS_PROVIDER( schIUScale, EDA_UNITS::MILLIMETRES )
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
{}
|
|
|
|
|
2024-02-02 23:04:56 +00:00
|
|
|
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2023-01-19 00:14:31 +00:00
|
|
|
void Reset() override;
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnKifaceEnd() override;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2022-11-08 09:14:40 +00:00
|
|
|
wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
|
2023-04-03 16:10:15 +00:00
|
|
|
int aCtlBits = 0 ) override
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
|
|
|
switch( aClassId )
|
|
|
|
{
|
2014-04-19 18:47:20 +00:00
|
|
|
case FRAME_SCH:
|
2019-06-02 23:17:27 +00:00
|
|
|
{
|
|
|
|
SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
|
|
|
|
|
2022-10-26 21:59:33 +00:00
|
|
|
EESCHEMA_HELPERS::SetSchEditFrame( frame );
|
|
|
|
|
2019-06-02 23:17:27 +00:00
|
|
|
if( Kiface().IsSingle() )
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
{
|
2019-06-02 23:17:27 +00:00
|
|
|
// only run this under single_top, not under a project manager.
|
|
|
|
frame->CreateServer( KICAD_SCH_PORT_SERVICE_NUMBER );
|
2014-04-18 02:05:40 +00:00
|
|
|
}
|
2019-06-02 23:17:27 +00:00
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2020-10-31 01:27:16 +00:00
|
|
|
case FRAME_SCH_SYMBOL_EDITOR:
|
2019-06-02 23:17:27 +00:00
|
|
|
{
|
2020-10-31 01:27:16 +00:00
|
|
|
SYMBOL_EDIT_FRAME* frame = new SYMBOL_EDIT_FRAME( aKiway, aParent );
|
2019-06-02 23:17:27 +00:00
|
|
|
return frame;
|
|
|
|
}
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
2016-08-11 12:41:01 +00:00
|
|
|
case FRAME_SIMULATOR:
|
2019-06-02 23:17:27 +00:00
|
|
|
{
|
2023-03-03 22:36:07 +00:00
|
|
|
SIMULATOR_FRAME* frame = new SIMULATOR_FRAME( aKiway, aParent );
|
2019-06-02 23:17:27 +00:00
|
|
|
return frame;
|
|
|
|
}
|
2023-03-20 15:02:45 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case FRAME_SCH_VIEWER:
|
2019-06-02 23:17:27 +00:00
|
|
|
{
|
2023-09-28 13:09:45 +00:00
|
|
|
SYMBOL_VIEWER_FRAME* frame = new SYMBOL_VIEWER_FRAME( aKiway, aParent );
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FRAME_SYMBOL_CHOOSER:
|
|
|
|
{
|
|
|
|
SYMBOL_CHOOSER_FRAME* frame = new SYMBOL_CHOOSER_FRAME( aKiway, aParent );
|
2019-06-02 23:17:27 +00:00
|
|
|
return frame;
|
|
|
|
}
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
2018-08-06 18:33:28 +00:00
|
|
|
case DIALOG_SCH_LIBRARY_TABLE:
|
|
|
|
InvokeSchEditSymbolLibTable( aKiway, aParent );
|
|
|
|
// Dialog has completed; nothing to return.
|
|
|
|
return nullptr;
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
case PANEL_SYM_DISP_OPTIONS:
|
2021-08-29 23:33:08 +00:00
|
|
|
{
|
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
APP_SETTINGS_BASE* cfg = mgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
return new PANEL_SYM_DISPLAY_OPTIONS( aParent, cfg );
|
2021-08-29 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
2023-08-26 12:29:24 +00:00
|
|
|
case PANEL_SYM_EDIT_GRIDS:
|
|
|
|
{
|
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
APP_SETTINGS_BASE* cfg = mgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
|
|
|
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
|
|
|
|
|
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH_VIEWER, false );
|
|
|
|
|
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH, false );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
SetUserUnits( frame->GetUserUnits() );
|
|
|
|
|
|
|
|
return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH_SYMBOL_EDITOR );
|
|
|
|
}
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
case PANEL_SYM_EDIT_OPTIONS:
|
|
|
|
{
|
2022-12-03 19:31:41 +00:00
|
|
|
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH_VIEWER, false );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH, false );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
if( frame )
|
2023-04-03 16:10:15 +00:00
|
|
|
SetUserUnits( frame->GetUserUnits() );
|
|
|
|
|
|
|
|
return new PANEL_SYM_EDITING_OPTIONS( aParent, this, frame );
|
2021-08-29 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case PANEL_SYM_COLORS:
|
|
|
|
return new PANEL_SYM_COLOR_SETTINGS( aParent );
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
case PANEL_SCH_DISP_OPTIONS:
|
2021-08-29 23:33:08 +00:00
|
|
|
{
|
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
APP_SETTINGS_BASE* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
|
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
return new PANEL_EESCHEMA_DISPLAY_OPTIONS( aParent, cfg );
|
2021-08-29 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
2023-08-26 12:29:24 +00:00
|
|
|
case PANEL_SCH_GRIDS:
|
|
|
|
{
|
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
APP_SETTINGS_BASE* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
|
|
|
|
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
|
|
|
|
|
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
|
|
|
|
|
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH_VIEWER, false );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
SetUserUnits( frame->GetUserUnits() );
|
|
|
|
|
|
|
|
return new PANEL_GRID_SETTINGS( aParent, this, frame, cfg, FRAME_SCH );
|
|
|
|
}
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
case PANEL_SCH_EDIT_OPTIONS:
|
|
|
|
{
|
2022-12-03 19:31:41 +00:00
|
|
|
EDA_BASE_FRAME* frame = aKiway->Player( FRAME_SCH, false );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
if( !frame )
|
|
|
|
frame = aKiway->Player( FRAME_SCH_VIEWER, false );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
if( frame )
|
2023-04-03 16:10:15 +00:00
|
|
|
SetUserUnits( frame->GetUserUnits() );
|
|
|
|
|
|
|
|
return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, this, frame );
|
2021-08-29 23:33:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-30 17:41:40 +00:00
|
|
|
case PANEL_SCH_ANNO_OPTIONS:
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME* schSettingsProvider = aKiway->Player( FRAME_SCH, false );
|
|
|
|
|
|
|
|
return new PANEL_EESCHEMA_ANNOTATION_OPTIONS( aParent, schSettingsProvider );
|
|
|
|
}
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
case PANEL_SCH_COLORS:
|
|
|
|
return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent );
|
|
|
|
|
|
|
|
case PANEL_SCH_FIELD_NAME_TEMPLATES:
|
|
|
|
return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr );
|
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
default:
|
2021-07-16 20:13:26 +00:00
|
|
|
return nullptr;
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-16 20:13:26 +00:00
|
|
|
* Return a pointer to the requested object.
|
|
|
|
*
|
|
|
|
* The safest way to use this is to retrieve a pointer to a static instance of an interface,
|
|
|
|
* similar to how the KIFACE interface is exported. But if you know what you are doing use
|
|
|
|
* it to retrieve anything you want.
|
|
|
|
*
|
2014-02-03 15:10:37 +00:00
|
|
|
* @param aDataId identifies which object you want the address of.
|
2021-07-16 20:13:26 +00:00
|
|
|
* @return the object requested and must be cast into the know type.
|
2014-02-03 15:10:37 +00:00
|
|
|
*/
|
2016-09-25 17:06:49 +00:00
|
|
|
void* IfaceOrAddress( int aDataId ) override
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2020-09-18 14:19:47 +00:00
|
|
|
switch( aDataId )
|
|
|
|
{
|
|
|
|
case KIFACE_NETLIST_SCHEMATIC:
|
|
|
|
return (void*) generateSchematicNetlist;
|
|
|
|
}
|
2021-07-16 20:13:26 +00:00
|
|
|
|
|
|
|
return nullptr;
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
2019-11-09 19:39:08 +00:00
|
|
|
/**
|
|
|
|
* Saving a file under a different name is delegated to the various KIFACEs because
|
|
|
|
* the project doesn't know the internal format of the various files (which may have
|
|
|
|
* paths in them that need updating).
|
|
|
|
*/
|
2019-11-10 08:37:39 +00:00
|
|
|
void SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
|
|
|
|
const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
|
|
|
|
const wxString& aSrcFilePath, wxString& aErrors ) override;
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2022-10-04 01:53:37 +00:00
|
|
|
|
|
|
|
int HandleJob( JOB* aJob ) override;
|
|
|
|
|
2022-10-26 21:59:33 +00:00
|
|
|
private:
|
2023-01-19 00:14:31 +00:00
|
|
|
bool loadGlobalLibTable();
|
|
|
|
|
2022-10-26 21:59:33 +00:00
|
|
|
std::unique_ptr<EESCHEMA_JOBS_HANDLER> m_jobHandler;
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
} kiface( "eeschema", KIWAY::FACE_SCH );
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
using namespace SCH;
|
|
|
|
|
|
|
|
static PGM_BASE* process;
|
|
|
|
|
|
|
|
|
2021-09-14 22:45:14 +00:00
|
|
|
KIFACE_BASE& Kiface() { return kiface; }
|
2014-02-03 15:10:37 +00:00
|
|
|
|
|
|
|
|
2014-02-03 19:26:18 +00:00
|
|
|
// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
|
|
|
|
// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
|
2023-09-09 00:44:08 +00:00
|
|
|
KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2015-11-03 19:44:05 +00:00
|
|
|
process = aProgram;
|
2014-02-03 15:10:37 +00:00
|
|
|
return &kiface;
|
|
|
|
}
|
|
|
|
|
2014-02-03 19:26:18 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
PGM_BASE& Pgm()
|
2014-02-03 15:10:37 +00:00
|
|
|
{
|
2014-02-03 19:26:18 +00:00
|
|
|
wxASSERT( process ); // KIFACE_GETTER has already been called.
|
|
|
|
return *process;
|
2014-02-03 15:10:37 +00:00
|
|
|
}
|
|
|
|
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2020-04-14 16:12:15 +00:00
|
|
|
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
|
|
|
|
// a python script or something else.
|
|
|
|
PGM_BASE* PgmOrNull()
|
|
|
|
{
|
|
|
|
return process;
|
|
|
|
}
|
|
|
|
|
2010-01-16 19:42:58 +00:00
|
|
|
|
2024-02-02 23:04:56 +00:00
|
|
|
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-11-10 14:51:06 +00:00
|
|
|
// This is process-level-initialization, not project-level-initialization of the DSO.
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// Do nothing in here pertinent to a project!
|
2020-01-13 01:44:19 +00:00
|
|
|
InitSettings( new EESCHEMA_SETTINGS );
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2023-04-18 20:40:25 +00:00
|
|
|
// Register the symbol editor settings as well because they share a KiFACE and need to be
|
|
|
|
// loaded prior to use to avoid threading deadlocks
|
2024-02-12 02:04:09 +00:00
|
|
|
SYMBOL_EDITOR_SETTINGS* symSettings = new SYMBOL_EDITOR_SETTINGS();
|
|
|
|
aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership
|
2023-04-18 20:40:25 +00:00
|
|
|
|
2023-09-05 03:22:39 +00:00
|
|
|
// We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS
|
|
|
|
// In legacy configs, many settings were in a single editor config nd the migration routine
|
|
|
|
// for the main editor file will try and call into the now separate settings stores
|
|
|
|
// to move the settings into them
|
|
|
|
aProgram->GetSettingsManager().RegisterSettings( KifaceSettings() );
|
|
|
|
|
2014-04-18 02:05:40 +00:00
|
|
|
start_common( aCtlBits );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2023-01-19 00:14:31 +00:00
|
|
|
if( !loadGlobalLibTable() )
|
2024-02-12 02:04:09 +00:00
|
|
|
{
|
|
|
|
// we didnt get anywhere deregister the settings
|
|
|
|
aProgram->GetSettingsManager().FlushAndRelease( symSettings, false );
|
|
|
|
aProgram->GetSettingsManager().FlushAndRelease( KifaceSettings(), false );
|
2023-01-19 00:14:31 +00:00
|
|
|
return false;
|
2024-02-12 02:04:09 +00:00
|
|
|
}
|
2023-01-19 00:14:31 +00:00
|
|
|
|
2024-02-02 23:04:56 +00:00
|
|
|
m_jobHandler = std::make_unique<EESCHEMA_JOBS_HANDLER>( aKiway );
|
2023-01-19 00:14:31 +00:00
|
|
|
|
2023-03-24 10:31:08 +00:00
|
|
|
if( m_start_flags & KFCTL_CLI )
|
2023-08-14 00:31:19 +00:00
|
|
|
{
|
2023-03-24 10:31:08 +00:00
|
|
|
m_jobHandler->SetReporter( &CLI_REPORTER::GetInstance() );
|
2023-08-14 00:31:19 +00:00
|
|
|
m_jobHandler->SetProgressReporter( &CLI_PROGRESS_REPORTER::GetInstance() );
|
|
|
|
}
|
2023-03-24 10:31:08 +00:00
|
|
|
|
2023-01-19 00:14:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IFACE::Reset()
|
|
|
|
{
|
|
|
|
loadGlobalLibTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IFACE::loadGlobalLibTable()
|
|
|
|
{
|
2017-08-04 18:46:28 +00:00
|
|
|
wxFileName fn = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
|
|
|
|
|
|
|
|
if( !fn.FileExists() )
|
2016-11-24 17:57:53 +00:00
|
|
|
{
|
2023-01-19 00:14:31 +00:00
|
|
|
if( !( m_start_flags & KFCTL_CLI ) )
|
2022-12-08 04:55:47 +00:00
|
|
|
{
|
2023-06-24 16:09:43 +00:00
|
|
|
// Ensure the splash screen does not hide the dialog:
|
|
|
|
Pgm().HideSplash();
|
|
|
|
|
2023-03-19 11:30:53 +00:00
|
|
|
DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG symDialog( nullptr );
|
2017-08-04 18:46:28 +00:00
|
|
|
|
2023-03-19 11:30:53 +00:00
|
|
|
if( symDialog.ShowModal() != wxID_OK )
|
|
|
|
return false;
|
2022-12-08 04:55:47 +00:00
|
|
|
}
|
2016-11-24 17:57:53 +00:00
|
|
|
}
|
2017-08-04 18:46:28 +00:00
|
|
|
else
|
2016-11-24 17:57:53 +00:00
|
|
|
{
|
2017-08-04 18:46:28 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// The global table is not related to a specific project. All projects
|
|
|
|
// will use the same global table. So the KIFACE::OnKifaceStart() contract
|
|
|
|
// of avoiding anything project specific is not violated here.
|
|
|
|
if( !SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE::GetGlobalLibTable() ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
// if we are here, a incorrect global symbol library table was found.
|
|
|
|
// Incorrect global symbol library table is not a fatal error:
|
|
|
|
// the user just has to edit the (partially) loaded table.
|
2022-12-08 04:55:47 +00:00
|
|
|
wxString msg =
|
|
|
|
_( "An error occurred attempting to load the global symbol library table.\n"
|
|
|
|
"Please edit this global symbol library table in Preferences menu." );
|
2017-08-04 18:46:28 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
DisplayErrorMessage( nullptr, msg, ioe.What() );
|
2017-08-04 18:46:28 +00:00
|
|
|
}
|
2016-11-24 17:57:53 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 18:44:24 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2014-09-26 10:35:11 +00:00
|
|
|
void IFACE::OnKifaceEnd()
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
{
|
|
|
|
end_common();
|
|
|
|
}
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2019-11-09 19:39:08 +00:00
|
|
|
static void traverseSEXPR( SEXPR::SEXPR* aNode,
|
|
|
|
const std::function<void( SEXPR::SEXPR* )>& aVisitor )
|
|
|
|
{
|
|
|
|
aVisitor( aNode );
|
|
|
|
|
|
|
|
if( aNode->IsList() )
|
|
|
|
{
|
2019-11-10 08:37:39 +00:00
|
|
|
for( unsigned i = 0; i < aNode->GetNumberOfChildren(); i++ )
|
2019-11-09 19:39:08 +00:00
|
|
|
traverseSEXPR( aNode->GetChild( i ), aVisitor );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-10 08:37:39 +00:00
|
|
|
void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProjectName,
|
|
|
|
const wxString& aNewProjectBasePath, const wxString& aNewProjectName,
|
|
|
|
const wxString& aSrcFilePath, wxString& aErrors )
|
2019-11-09 19:39:08 +00:00
|
|
|
{
|
|
|
|
wxFileName destFile( aSrcFilePath );
|
2020-02-02 23:00:54 +00:00
|
|
|
wxString destPath = destFile.GetPathWithSep();
|
|
|
|
wxUniChar pathSep = wxFileName::GetPathSeparator();
|
2019-11-09 19:39:08 +00:00
|
|
|
wxString ext = destFile.GetExt();
|
|
|
|
|
2020-02-02 23:00:54 +00:00
|
|
|
if( destPath.StartsWith( aProjectBasePath + pathSep ) )
|
2019-11-09 19:39:08 +00:00
|
|
|
destPath.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
2020-02-02 23:00:54 +00:00
|
|
|
|
|
|
|
destFile.SetPath( destPath );
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2023-12-28 02:10:01 +00:00
|
|
|
if( ext == FILEEXT::LegacySchematicFileExtension
|
|
|
|
|| ext == FILEEXT::LegacySchematicFileExtension + FILEEXT::BackupFileSuffix
|
|
|
|
|| ext == FILEEXT::KiCadSchematicFileExtension
|
|
|
|
|| ext == FILEEXT::KiCadSchematicFileExtension + FILEEXT::BackupFileSuffix )
|
2019-11-09 19:39:08 +00:00
|
|
|
{
|
|
|
|
if( destFile.GetName() == aProjectName )
|
2022-09-08 22:17:41 +00:00
|
|
|
{
|
2019-11-09 19:39:08 +00:00
|
|
|
destFile.SetName( aNewProjectName );
|
2022-09-08 22:17:41 +00:00
|
|
|
}
|
|
|
|
else if( destFile.GetName() == aNewProjectName )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( !aErrors.empty() )
|
2023-01-17 04:14:38 +00:00
|
|
|
aErrors += wxS( "\n" );
|
2022-09-08 22:17:41 +00:00
|
|
|
|
|
|
|
msg.Printf( _( "Cannot copy file '%s' as it will be overwritten by the new root "
|
|
|
|
"sheet file." ), destFile.GetFullPath() );
|
|
|
|
aErrors += msg;
|
|
|
|
return;
|
|
|
|
}
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2019-11-10 14:51:06 +00:00
|
|
|
// Sheet paths when auto-generated are relative to the root, so those will stay
|
|
|
|
// pointing to whatever they were pointing at.
|
|
|
|
// The author can create their own absolute and relative sheet paths. Absolute
|
|
|
|
// sheet paths aren't an issue, and relative ones will continue to work as long
|
|
|
|
// as the author didn't include any '..'s. If they did, it's still not clear
|
|
|
|
// whether they should be adjusted or not (as the author may be duplicating an
|
|
|
|
// entire tree with several projects within it), so we leave this as an exercise
|
|
|
|
// to the author.
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2020-10-02 18:36:06 +00:00
|
|
|
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
2019-11-09 19:39:08 +00:00
|
|
|
}
|
2023-12-28 02:10:01 +00:00
|
|
|
else if( ext == FILEEXT::SchematicSymbolFileExtension )
|
2019-11-09 19:39:08 +00:00
|
|
|
{
|
|
|
|
// Symbols are not project-specific. Keep their source names.
|
2020-10-02 18:36:06 +00:00
|
|
|
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
2019-11-09 19:39:08 +00:00
|
|
|
}
|
2023-12-28 02:10:01 +00:00
|
|
|
else if( ext == FILEEXT::LegacySymbolLibFileExtension
|
|
|
|
|| ext == FILEEXT::LegacySymbolDocumentFileExtension
|
|
|
|
|| ext == FILEEXT::KiCadSymbolLibFileExtension )
|
2019-11-09 19:39:08 +00:00
|
|
|
{
|
2023-01-17 04:14:38 +00:00
|
|
|
if( destFile.GetName() == aProjectName + wxS( "-cache" ) )
|
|
|
|
destFile.SetName( aNewProjectName + wxS( "-cache" ) );
|
2022-11-05 12:11:58 +00:00
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
if( destFile.GetName() == aProjectName + wxS( "-rescue" ) )
|
|
|
|
destFile.SetName( aNewProjectName + wxS( "-rescue" ) );
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2020-10-02 18:36:06 +00:00
|
|
|
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
2019-11-09 19:39:08 +00:00
|
|
|
}
|
2023-12-28 02:10:01 +00:00
|
|
|
else if( ext == FILEEXT::NetlistFileExtension )
|
2019-11-09 19:39:08 +00:00
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
|
|
|
|
if( destFile.GetName() == aProjectName )
|
|
|
|
destFile.SetName( aNewProjectName );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
SEXPR::PARSER parser;
|
2019-11-10 08:37:39 +00:00
|
|
|
std::unique_ptr<SEXPR::SEXPR> sexpr( parser.ParseFromFile( TO_UTF8( aSrcFilePath ) ) );
|
2019-11-09 19:39:08 +00:00
|
|
|
|
|
|
|
traverseSEXPR( sexpr.get(), [&]( SEXPR::SEXPR* node )
|
|
|
|
{
|
|
|
|
if( node->IsList() && node->GetNumberOfChildren() > 1
|
|
|
|
&& node->GetChild( 0 )->IsSymbol()
|
|
|
|
&& node->GetChild( 0 )->GetSymbol() == "source" )
|
|
|
|
{
|
|
|
|
auto pathNode = dynamic_cast<SEXPR::SEXPR_STRING*>( node->GetChild( 1 ) );
|
2019-11-11 20:34:42 +00:00
|
|
|
auto symNode = dynamic_cast<SEXPR::SEXPR_SYMBOL*>( node->GetChild( 1 ) );
|
|
|
|
wxString path;
|
|
|
|
|
|
|
|
if( pathNode )
|
|
|
|
path = pathNode->m_value;
|
|
|
|
else if( symNode )
|
|
|
|
path = symNode->m_value;
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
if( path == aProjectName + wxS( ".sch" ) )
|
|
|
|
path = aNewProjectName + wxS( ".sch" );
|
|
|
|
else if( path == aProjectBasePath + "/" + aProjectName + wxS( ".sch" ) )
|
|
|
|
path = aNewProjectBasePath + "/" + aNewProjectName + wxS( ".sch" );
|
2019-11-09 19:39:08 +00:00
|
|
|
else if( path.StartsWith( aProjectBasePath ) )
|
|
|
|
path.Replace( aProjectBasePath, aNewProjectBasePath, false );
|
|
|
|
|
2019-11-11 20:34:42 +00:00
|
|
|
if( pathNode )
|
|
|
|
pathNode->m_value = path;
|
|
|
|
else if( symNode )
|
|
|
|
symNode->m_value = path;
|
2019-11-09 19:39:08 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2020-12-12 18:11:51 +00:00
|
|
|
wxFFile destNetList( destFile.GetFullPath(), "wb" );
|
2019-11-09 19:39:08 +00:00
|
|
|
|
|
|
|
if( destNetList.IsOpened() )
|
|
|
|
success = destNetList.Write( sexpr->AsString( 0 ) );
|
|
|
|
|
2020-12-12 18:11:51 +00:00
|
|
|
// wxFFile dtor will close the file
|
2019-11-09 19:39:08 +00:00
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !success )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( !aErrors.empty() )
|
2023-01-17 04:14:38 +00:00
|
|
|
aErrors += wxS( "\n" );
|
2019-11-09 19:39:08 +00:00
|
|
|
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
|
2019-11-09 19:39:08 +00:00
|
|
|
aErrors += msg;
|
|
|
|
}
|
|
|
|
}
|
2023-01-17 04:14:38 +00:00
|
|
|
else if( destFile.GetName() == wxS( "sym-lib-table" ) )
|
2019-11-09 19:39:08 +00:00
|
|
|
{
|
|
|
|
SYMBOL_LIB_TABLE symbolLibTable;
|
|
|
|
symbolLibTable.Load( aSrcFilePath );
|
|
|
|
|
2019-11-10 08:37:39 +00:00
|
|
|
for( unsigned i = 0; i < symbolLibTable.GetCount(); i++ )
|
2019-11-09 19:39:08 +00:00
|
|
|
{
|
|
|
|
LIB_TABLE_ROW& row = symbolLibTable.At( i );
|
|
|
|
wxString uri = row.GetFullURI();
|
|
|
|
|
2023-01-17 04:14:38 +00:00
|
|
|
uri.Replace( wxS( "/" ) + aProjectName + wxS( "-cache.lib" ),
|
|
|
|
wxS( "/" ) + aNewProjectName + wxS( "-cache.lib" ) );
|
|
|
|
uri.Replace( wxS( "/" ) + aProjectName + wxS( "-rescue.lib" ),
|
|
|
|
wxS( "/" ) + aNewProjectName + wxS( "-rescue.lib" ) );
|
|
|
|
uri.Replace( wxS( "/" ) + aProjectName + wxS( ".lib" ),
|
|
|
|
wxS( "/" ) + aNewProjectName + wxS( ".lib" ) );
|
2019-11-09 19:39:08 +00:00
|
|
|
|
|
|
|
row.SetFullURI( uri );
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
symbolLibTable.Save( destFile.GetFullPath() );
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( !aErrors.empty() )
|
|
|
|
aErrors += "\n";
|
|
|
|
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Cannot copy file '%s'." ), destFile.GetFullPath() );
|
2019-11-09 19:39:08 +00:00
|
|
|
aErrors += msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-17 04:14:38 +00:00
|
|
|
wxFAIL_MSG( wxS( "Unexpected filetype for Eeschema::SaveFileAs()" ) );
|
2019-11-09 19:39:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 13:36:28 +00:00
|
|
|
|
2022-10-04 01:53:37 +00:00
|
|
|
int IFACE::HandleJob( JOB* aJob )
|
|
|
|
{
|
2022-10-26 21:59:33 +00:00
|
|
|
return m_jobHandler->RunJob( aJob );
|
2023-02-20 17:55:02 +00:00
|
|
|
}
|