2012-02-16 20:03:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-03-03 13:18:07 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-01-18 10:42:23 +00:00
|
|
|
* Copyright (C) 2013 CERN (www.cern.ch)
|
2020-03-16 13:04:50 +00:00
|
|
|
* Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors.
|
2012-02-16 20:03:33 +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
|
|
|
|
*/
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2019-06-25 04:44:34 +00:00
|
|
|
#include "kicad_id.h"
|
|
|
|
#include "pgm_kicad.h"
|
2020-12-02 12:35:19 +00:00
|
|
|
#include "project_tree_pane.h"
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <build_version.h>
|
2020-10-13 03:29:08 +00:00
|
|
|
#include <eda_base_frame.h>
|
2019-11-23 16:54:48 +00:00
|
|
|
#include <filehistory.h>
|
2020-07-21 00:33:35 +00:00
|
|
|
#include <kiplatform/app.h>
|
2014-04-19 18:47:20 +00:00
|
|
|
#include <kiway.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <kiway_express.h>
|
2014-04-18 02:05:40 +00:00
|
|
|
#include <kiway_player.h>
|
2020-02-21 01:10:49 +00:00
|
|
|
#include <launch_ext.h>
|
2019-06-12 12:43:24 +00:00
|
|
|
#include <panel_hotkeys_editor.h>
|
2020-07-03 13:40:31 +00:00
|
|
|
#include <reporter.h>
|
2020-08-24 02:01:14 +00:00
|
|
|
#include <project/project_local_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/common_settings.h>
|
2020-05-25 20:41:24 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-07-27 22:42:23 +00:00
|
|
|
#include <tool/action_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
|
|
|
#include <tool/common_control.h>
|
2020-07-11 20:18:54 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tools/kicad_manager_actions.h>
|
2019-06-09 13:12:44 +00:00
|
|
|
#include <tools/kicad_manager_control.h>
|
2019-06-25 04:44:34 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-08-24 02:01:14 +00:00
|
|
|
#include <widgets/app_progress_dialog.h>
|
2020-12-12 18:11:51 +00:00
|
|
|
#include <wx/ffile.h>
|
|
|
|
|
2016-02-24 21:36:52 +00:00
|
|
|
|
2018-11-13 17:11:20 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
#include <MacTypes.h>
|
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
|
|
|
#endif
|
|
|
|
|
2019-06-09 10:10:19 +00:00
|
|
|
#include "kicad_manager_frame.h"
|
2020-01-13 01:44:19 +00:00
|
|
|
#include "kicad_settings.h"
|
2015-09-25 19:38:09 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2019-06-10 14:30:42 +00:00
|
|
|
#define SEP() wxFileName::GetPathSeparator()
|
|
|
|
|
|
|
|
|
2019-06-10 14:23:37 +00:00
|
|
|
// Menubar and toolbar event table
|
|
|
|
BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
|
|
|
|
// Window events
|
|
|
|
EVT_SIZE( KICAD_MANAGER_FRAME::OnSize )
|
2020-08-24 02:01:14 +00:00
|
|
|
EVT_IDLE( KICAD_MANAGER_FRAME::OnIdle )
|
2019-06-10 14:23:37 +00:00
|
|
|
|
|
|
|
// Menu events
|
|
|
|
EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit )
|
|
|
|
EVT_MENU( ID_EDIT_LOCAL_FILE_IN_TEXT_EDITOR, KICAD_MANAGER_FRAME::OnOpenFileInTextEditor )
|
|
|
|
EVT_MENU( ID_BROWSE_IN_FILE_EXPLORER, KICAD_MANAGER_FRAME::OnBrowseInFileExplorer )
|
|
|
|
EVT_MENU( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles )
|
|
|
|
EVT_MENU( ID_READ_ZIP_ARCHIVE, KICAD_MANAGER_FRAME::OnUnarchiveFiles )
|
2020-09-27 17:12:32 +00:00
|
|
|
EVT_MENU( ID_IMPORT_CADSTAR_ARCHIVE_PROJECT, KICAD_MANAGER_FRAME::OnImportCadstarArchiveFiles )
|
2019-06-10 14:23:37 +00:00
|
|
|
EVT_MENU( ID_IMPORT_EAGLE_PROJECT, KICAD_MANAGER_FRAME::OnImportEagleFiles )
|
|
|
|
|
|
|
|
// Range menu events
|
|
|
|
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
|
|
|
|
KICAD_MANAGER_FRAME::language_change )
|
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, KICAD_MANAGER_FRAME::OnFileHistory )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_FILE_LIST_CLEAR, KICAD_MANAGER_FRAME::OnClearFileHistory )
|
2019-06-10 14:23:37 +00:00
|
|
|
|
|
|
|
// Special functions
|
|
|
|
EVT_MENU( ID_INIT_WATCHED_PATHS, KICAD_MANAGER_FRAME::OnChangeWatchedPaths )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2019-06-18 16:07:50 +00:00
|
|
|
KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
|
2019-06-09 10:10:19 +00:00
|
|
|
const wxPoint& pos, const wxSize& size ) :
|
|
|
|
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size,
|
2019-06-10 14:23:37 +00:00
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME, &::Kiway ),
|
|
|
|
m_leftWin( nullptr ),
|
|
|
|
m_launcher( nullptr ),
|
|
|
|
m_messagesBox( nullptr ),
|
|
|
|
m_mainToolBar( nullptr )
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2015-08-03 20:56:37 +00:00
|
|
|
m_active_project = false;
|
2019-06-18 16:07:50 +00:00
|
|
|
m_leftWinWidth = 250; // Default value
|
2020-11-16 11:16:44 +00:00
|
|
|
m_aboutTitle = "KiCad";
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2017-03-02 13:46:18 +00:00
|
|
|
// Create the status line (bottom of the frame)
|
2009-08-07 04:44:42 +00:00
|
|
|
static const int dims[3] = { -1, -1, 100 };
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
CreateStatusBar( 3 );
|
|
|
|
SetStatusWidths( 3, dims );
|
|
|
|
|
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
wxIcon icon;
|
2020-12-22 19:41:32 +00:00
|
|
|
wxIconBundle icon_bundle;
|
|
|
|
|
2011-09-09 19:30:59 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_kicad_xpm ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_kicad_32_xpm ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_kicad_16_xpm ) );
|
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
|
|
|
|
SetIcons( icon_bundle );
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// Load the settings
|
* 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
|
|
|
LoadSettings( config() );
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
// Left window: is the box which display tree project
|
2020-12-02 12:35:19 +00:00
|
|
|
m_leftWin = new PROJECT_TREE_PANE( this );
|
* 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-01 18:27:18 +00:00
|
|
|
// Add the wxTextCtrl showing all messages from KiCad:
|
2019-06-10 14:23:37 +00:00
|
|
|
m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
|
2014-02-01 18:27:18 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2018-08-11 16:04:46 +00:00
|
|
|
wxTE_MULTILINE | wxTE_READONLY | wxBORDER_NONE );
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
setupTools();
|
|
|
|
setupUIConditions();
|
2019-06-09 13:12:44 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
RecreateBaseHToolbar();
|
2019-06-10 14:23:37 +00:00
|
|
|
RecreateLauncher();
|
2013-01-01 14:06:49 +00:00
|
|
|
ReCreateMenuBar();
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2009-11-18 20:12:11 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
2011-09-15 18:25:44 +00:00
|
|
|
|
2019-06-18 16:07:50 +00:00
|
|
|
// BestSize() does not always set the actual pane size of m_leftWin to the required value.
|
|
|
|
// It happens when m_leftWin is too large (roughly > 1/3 of the kicad manager frame width.
|
|
|
|
// (Well, BestSize() sets the best size... not the window size)
|
|
|
|
// A trick is to use MinSize() to set the required pane width,
|
|
|
|
// and after give a reasonable MinSize value
|
2019-06-10 14:23:37 +00:00
|
|
|
m_auimgr.AddPane( m_leftWin, EDA_PANE().Palette().Name( "ProjectTree" ).Left().Layer(3)
|
2018-08-11 16:04:46 +00:00
|
|
|
.CaptionVisible( false ).PaneBorder( false )
|
2019-06-18 16:07:50 +00:00
|
|
|
.MinSize( m_leftWinWidth, -1 ).BestSize( m_leftWinWidth, -1 ) );
|
2010-01-13 21:15:54 +00:00
|
|
|
|
2019-06-10 14:23:37 +00:00
|
|
|
m_auimgr.AddPane( m_launcher, EDA_PANE().HToolbar().Name( "Launcher" ).Top().Layer(1) );
|
2014-02-01 18:27:18 +00:00
|
|
|
|
2019-06-10 14:23:37 +00:00
|
|
|
m_auimgr.AddPane( m_messagesBox, EDA_PANE().Messages().Name( "MsgPanel" ).Center() );
|
2011-10-27 05:43:44 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2017-08-31 15:15:20 +00:00
|
|
|
|
2019-06-18 16:07:50 +00:00
|
|
|
// Now the actual m_leftWin size is set, give it a reasonable min width
|
|
|
|
m_auimgr.GetPane( m_leftWin ).MinSize( 200, -1 );
|
|
|
|
|
2017-08-31 15:15:20 +00:00
|
|
|
SetTitle( wxString( "KiCad " ) + GetBuildVersion() );
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2020-07-11 20:18:54 +00:00
|
|
|
// Do not let the messages window have initial focus
|
|
|
|
m_leftWin->SetFocus();
|
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
// Ensure the window is on top
|
|
|
|
Raise();
|
2007-10-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME()
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2020-02-03 14:00:48 +00:00
|
|
|
// Shutdown all running tools
|
2019-08-11 20:30:33 +00:00
|
|
|
if( m_toolManager )
|
2020-02-03 14:00:48 +00:00
|
|
|
m_toolManager->ShutdownAllTools();
|
2019-08-11 20:30:33 +00:00
|
|
|
|
|
|
|
delete m_actions;
|
|
|
|
delete m_toolManager;
|
2020-07-20 00:32:32 +00:00
|
|
|
delete m_toolDispatcher;
|
2019-08-11 20:30:33 +00:00
|
|
|
|
2009-11-18 20:12:11 +00:00
|
|
|
m_auimgr.UnInit();
|
2007-10-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-27 22:42:23 +00:00
|
|
|
void KICAD_MANAGER_FRAME::setupTools()
|
|
|
|
{
|
|
|
|
// Create the manager
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
|
|
|
|
m_actions = new KICAD_MANAGER_ACTIONS();
|
|
|
|
|
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
|
|
|
|
|
|
|
// Attach the events to the tool dispatcher
|
|
|
|
Bind( wxEVT_TOOL, &TOOL_DISPATCHER::DispatchWxCommand, m_toolDispatcher );
|
|
|
|
Bind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
|
|
|
Bind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher );
|
|
|
|
|
|
|
|
// Register tools
|
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
|
|
|
m_toolManager->RegisterTool( new KICAD_MANAGER_CONTROL );
|
|
|
|
m_toolManager->InitTools();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KICAD_MANAGER_FRAME::setupUIConditions()
|
|
|
|
{
|
|
|
|
EDA_BASE_FRAME::setupUIConditions();
|
|
|
|
|
|
|
|
ACTION_MANAGER* manager = m_toolManager->GetActionManager();
|
|
|
|
|
|
|
|
wxASSERT( manager );
|
|
|
|
|
|
|
|
auto activeProject =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return m_active_project;
|
|
|
|
};
|
|
|
|
|
|
|
|
ACTION_CONDITIONS activeProjectCond;
|
2020-08-05 22:00:26 +00:00
|
|
|
activeProjectCond.Enable( activeProject );
|
2020-07-27 22:42:23 +00:00
|
|
|
|
|
|
|
manager->SetConditions( KICAD_MANAGER_ACTIONS::editSchematic, activeProjectCond );
|
|
|
|
manager->SetConditions( KICAD_MANAGER_ACTIONS::editPCB, activeProjectCond );
|
|
|
|
manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
|
|
|
|
manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
|
|
|
|
|
|
|
|
// TODO: Switch this to an action
|
|
|
|
RegisterUIUpdateHandler( ID_SAVE_AND_ZIP_FILES, activeProjectCond );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-24 01:01:23 +00:00
|
|
|
wxWindow* KICAD_MANAGER_FRAME::GetToolCanvas() const
|
|
|
|
{
|
|
|
|
return m_leftWin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
APP_SETTINGS_BASE* KICAD_MANAGER_FRAME::config() const
|
* 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-01-13 01:44:19 +00:00
|
|
|
APP_SETTINGS_BASE* ret = PgmTop().PgmSettings();
|
* 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
|
|
|
wxASSERT( ret );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-07-09 00:52:46 +00:00
|
|
|
|
2020-08-08 20:00:29 +00:00
|
|
|
KICAD_SETTINGS* KICAD_MANAGER_FRAME::kicadSettings() const
|
|
|
|
{
|
|
|
|
KICAD_SETTINGS* ret = dynamic_cast<KICAD_SETTINGS*>( config() );
|
|
|
|
wxASSERT( ret );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-16 23:08:01 +00:00
|
|
|
const wxString KICAD_MANAGER_FRAME::GetProjectFileName() const
|
2014-07-07 19:49:14 +00:00
|
|
|
{
|
2020-08-15 16:43:54 +00:00
|
|
|
return Pgm().GetSettingsManager().IsProjectOpen() ? Prj().GetProjectFullName() : wxString( wxEmptyString );
|
2014-07-07 19:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString KICAD_MANAGER_FRAME::SchFileName()
|
|
|
|
{
|
2014-07-09 00:52:46 +00:00
|
|
|
wxFileName fn( GetProjectFileName() );
|
|
|
|
|
2020-04-16 16:43:50 +00:00
|
|
|
fn.SetExt( KiCadSchematicFileExtension );
|
|
|
|
return fn.GetFullPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString KICAD_MANAGER_FRAME::SchLegacyFileName()
|
|
|
|
{
|
|
|
|
wxFileName fn( GetProjectFileName() );
|
|
|
|
|
2020-03-16 13:04:50 +00:00
|
|
|
fn.SetExt( LegacySchematicFileExtension );
|
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
|
|
|
return fn.GetFullPath();
|
2014-07-07 19:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString KICAD_MANAGER_FRAME::PcbFileName()
|
|
|
|
{
|
2014-07-09 00:52:46 +00:00
|
|
|
wxFileName fn( GetProjectFileName() );
|
|
|
|
|
|
|
|
fn.SetExt( PcbFileExtension );
|
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
|
|
|
return fn.GetFullPath();
|
2014-07-09 00:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName()
|
|
|
|
{
|
|
|
|
wxFileName fn( GetProjectFileName() );
|
|
|
|
|
|
|
|
fn.SetExt( LegacyPcbFileExtension );
|
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
|
|
|
return fn.GetFullPath();
|
2014-07-07 19:49:14 +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
|
|
|
|
2014-07-09 00:52:46 +00:00
|
|
|
void KICAD_MANAGER_FRAME::ReCreateTreePrj()
|
|
|
|
{
|
2019-06-10 14:23:37 +00:00
|
|
|
m_leftWin->ReCreateTreePrj();
|
2014-07-09 00:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-14 18:49:52 +00:00
|
|
|
const SEARCH_STACK& KICAD_MANAGER_FRAME::sys_search()
|
|
|
|
{
|
2016-05-28 16:57:29 +00:00
|
|
|
return PgmTop().SysSearch();
|
2014-04-14 18:49:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString KICAD_MANAGER_FRAME::help_name()
|
|
|
|
{
|
2016-05-28 16:57:29 +00:00
|
|
|
return PgmTop().GetHelpFileName();
|
2014-04-14 18:49:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-19 15:08:41 +00:00
|
|
|
void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText )
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2019-06-10 14:23:37 +00:00
|
|
|
m_messagesBox->AppendText( aText );
|
2007-10-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2009-11-18 20:12:11 +00:00
|
|
|
if( m_auimgr.GetManagedWindow() )
|
|
|
|
m_auimgr.Update();
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2008-07-21 13:44:01 +00:00
|
|
|
event.Skip();
|
2007-10-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-30 23:47:16 +00:00
|
|
|
bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
KICAD_SETTINGS* settings = kicadSettings();
|
|
|
|
settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects();
|
|
|
|
|
|
|
|
// CloseProject will recursively ask all the open editors if they need to save changes.
|
|
|
|
// If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
|
|
|
|
if( CloseProject( true ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( aEvent.CanVeto() )
|
|
|
|
aEvent.Veto();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void KICAD_MANAGER_FRAME::doCloseWindow()
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2020-03-24 19:40:49 +00:00
|
|
|
#ifdef _WINDOWS_
|
|
|
|
// For some obscure reason, on Windows, when killing Kicad from the Windows task manager
|
|
|
|
// if a editor frame (schematic, library, board editor or fp editor) is open and has
|
|
|
|
// some edition to save, OnCloseWindow is run twice *at the same time*, creating race
|
|
|
|
// conditions between OnCloseWindow() code.
|
|
|
|
// Therefore I added (JPC) a ugly hack to discard the second call (unwanted) during
|
|
|
|
// execution of the first call (only one call is right).
|
|
|
|
// Note also if there is no change made in editors, this behavior does not happen.
|
|
|
|
static std::atomic<unsigned int> lock_close_event( 0 );
|
|
|
|
|
|
|
|
if( ++lock_close_event > 1 ) // Skip extra calls
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-08-30 23:47:16 +00:00
|
|
|
m_leftWin->Show( false );
|
2020-08-08 22:40:50 +00:00
|
|
|
|
2020-08-30 23:47:16 +00:00
|
|
|
Destroy();
|
2020-03-24 19:40:49 +00:00
|
|
|
|
|
|
|
#ifdef _WINDOWS_
|
|
|
|
lock_close_event = 0; // Reenable event management
|
|
|
|
#endif
|
2007-10-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Close( true );
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2011-08-19 15:08:41 +00:00
|
|
|
|
2020-08-08 18:52:14 +00:00
|
|
|
bool KICAD_MANAGER_FRAME::CloseProject( bool aSave )
|
2019-06-10 14:30:42 +00:00
|
|
|
{
|
|
|
|
if( !Kiway().PlayersClose( false ) )
|
2020-08-08 18:52:14 +00:00
|
|
|
return false;
|
2019-06-10 14:30:42 +00:00
|
|
|
|
|
|
|
// Save the project file for the currently loaded project.
|
|
|
|
if( m_active_project )
|
2020-06-20 14:36:16 +00:00
|
|
|
{
|
2020-07-03 13:40:31 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
|
|
|
|
mgr.TriggerBackupIfNeeded( NULL_REPORTER::GetInstance() );
|
2020-08-08 18:52:14 +00:00
|
|
|
|
|
|
|
if( aSave )
|
|
|
|
{
|
|
|
|
mgr.SaveProject();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_active_project = false;
|
2020-07-03 13:40:31 +00:00
|
|
|
mgr.UnloadProject( &Prj() );
|
2020-06-20 14:36:16 +00:00
|
|
|
}
|
2019-06-10 14:30:42 +00:00
|
|
|
|
|
|
|
ClearMsg();
|
2020-05-25 20:41:24 +00:00
|
|
|
|
2020-08-08 18:52:14 +00:00
|
|
|
m_leftWin->EmptyTreePrj();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
|
|
|
|
{
|
|
|
|
// The project file should be valid by the time we get here or something has gone wrong.
|
|
|
|
if( !aProjectFileName.Exists() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Any open KIFACE's must be closed if they are not part of the new project.
|
|
|
|
// (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
|
|
|
|
// User is prompted here to close those KIWAY_PLAYERs:
|
|
|
|
CloseProject( true );
|
|
|
|
|
|
|
|
m_active_project = true;
|
|
|
|
|
2020-05-25 20:41:24 +00:00
|
|
|
Pgm().GetSettingsManager().LoadProject( aProjectFileName.GetFullPath() );
|
2019-06-10 14:30:42 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
LoadWindowState( aProjectFileName.GetFullName() );
|
|
|
|
|
2019-06-10 14:30:42 +00:00
|
|
|
if( aProjectFileName.IsDirWritable() )
|
|
|
|
SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?
|
|
|
|
|
2020-07-03 02:31:59 +00:00
|
|
|
UpdateFileHistory( Prj().GetProjectFullName() );
|
2019-06-10 14:30:42 +00:00
|
|
|
|
|
|
|
m_leftWin->ReCreateTreePrj();
|
|
|
|
|
|
|
|
// Rebuild the list of watched paths.
|
|
|
|
// however this is possible only when the main loop event handler is running,
|
|
|
|
// so we use it to run the rebuild function.
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );
|
|
|
|
|
|
|
|
wxPostEvent( this, cmd );
|
|
|
|
|
|
|
|
PrintPrjInfo();
|
2020-07-21 00:33:35 +00:00
|
|
|
|
|
|
|
KIPLATFORM::APP::RegisterApplicationRestart( aProjectFileName.GetFullPath() );
|
2020-08-24 02:01:14 +00:00
|
|
|
m_openSavedWindows = true;
|
2019-06-10 14:30:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName, bool aCreateStubFiles )
|
2019-06-10 14:30:42 +00:00
|
|
|
{
|
|
|
|
wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
|
|
|
|
"Project folder must exist and be writable to create a new project." );
|
|
|
|
|
2020-06-19 03:23:03 +00:00
|
|
|
// If the project is legacy, convert it
|
2019-06-10 14:30:42 +00:00
|
|
|
if( !aProjectFileName.FileExists() )
|
|
|
|
{
|
2020-06-19 03:23:03 +00:00
|
|
|
wxFileName legacyPro( aProjectFileName );
|
|
|
|
legacyPro.SetExt( LegacyProjectFileExtension );
|
2019-06-10 14:30:42 +00:00
|
|
|
|
2020-06-19 03:23:03 +00:00
|
|
|
if( legacyPro.FileExists() )
|
|
|
|
{
|
|
|
|
GetSettingsManager()->LoadProject( legacyPro.GetFullPath() );
|
|
|
|
GetSettingsManager()->SaveProject();
|
2020-05-25 20:41:24 +00:00
|
|
|
|
2020-06-19 03:23:03 +00:00
|
|
|
wxRemoveFile( legacyPro.GetFullPath() );
|
|
|
|
}
|
|
|
|
else
|
2019-06-10 14:30:42 +00:00
|
|
|
{
|
2020-06-19 03:23:03 +00:00
|
|
|
// Copy template project file from template folder.
|
|
|
|
wxString srcFileName = sys_search().FindValidPath( "kicad.kicad_pro" );
|
|
|
|
|
|
|
|
wxFileName destFileName( aProjectFileName );
|
|
|
|
destFileName.SetExt( ProjectFileExtension );
|
|
|
|
|
|
|
|
// Create a minimal project file if the template project file could not be copied
|
|
|
|
if( !wxFileName::FileExists( srcFileName )
|
|
|
|
|| !wxCopyFile( srcFileName, destFileName.GetFullPath() ) )
|
|
|
|
{
|
2020-12-12 18:11:51 +00:00
|
|
|
wxFFile file( destFileName.GetFullPath(), "wb" );
|
2020-07-16 09:31:39 +00:00
|
|
|
|
|
|
|
if( file.IsOpened() )
|
|
|
|
file.Write( wxT( "{\n}\n") );
|
2020-12-12 18:11:51 +00:00
|
|
|
// wxFFile dtor will close the file
|
2020-06-19 03:23:03 +00:00
|
|
|
}
|
2019-06-10 14:30:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
// Create a "stub" for a schematic root sheet and a board if requested.
|
2019-06-10 14:30:42 +00:00
|
|
|
// It will avoid messages from the schematic editor or the board editor to create a new file
|
|
|
|
// And forces the user to create main files under the right name for the project manager
|
2020-08-15 16:43:54 +00:00
|
|
|
if( aCreateStubFiles )
|
2019-06-10 14:30:42 +00:00
|
|
|
{
|
2020-08-15 16:43:54 +00:00
|
|
|
wxFileName fn( aProjectFileName.GetFullPath() );
|
|
|
|
fn.SetExt( KiCadSchematicFileExtension );
|
2019-06-10 14:30:42 +00:00
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
// If a <project>.kicad_sch file does not exist, create a "stub" file ( minimal schematic file )
|
|
|
|
if( !fn.FileExists() )
|
|
|
|
{
|
2020-12-12 18:11:51 +00:00
|
|
|
wxFFile file( fn.GetFullPath(), "wb" );
|
2020-05-09 11:02:16 +00:00
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
if( file.IsOpened() )
|
|
|
|
file.Write( wxT( "(kicad_sch (version 20200310) (host eeschema \"unknown\")\n"
|
|
|
|
"( page \"A4\")\n (lib_symbols)\n"
|
|
|
|
" (symbol_instances)\n)\n" ) );
|
2019-06-10 14:30:42 +00:00
|
|
|
|
|
|
|
|
2020-12-12 18:11:51 +00:00
|
|
|
// wxFFile dtor will close the file
|
2020-08-15 16:43:54 +00:00
|
|
|
}
|
2019-06-10 14:30:42 +00:00
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
// If a <project>.kicad_pcb or <project>.brd file does not exist,
|
|
|
|
// create a .kicad_pcb "stub" file
|
|
|
|
fn.SetExt( KiCadPcbFileExtension );
|
|
|
|
wxFileName leg_fn( fn );
|
|
|
|
leg_fn.SetExt( LegacyPcbFileExtension );
|
2019-06-10 14:30:42 +00:00
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
if( !fn.FileExists() && !leg_fn.FileExists() )
|
|
|
|
{
|
2020-12-12 18:11:51 +00:00
|
|
|
wxFFile file( fn.GetFullPath(), "wb" );
|
2020-08-15 16:43:54 +00:00
|
|
|
|
|
|
|
if( file.IsOpened() )
|
|
|
|
file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) );
|
2019-06-10 14:30:42 +00:00
|
|
|
|
2020-12-12 18:11:51 +00:00
|
|
|
// wxFFile dtor will close the file
|
2020-08-15 16:43:54 +00:00
|
|
|
}
|
2019-06-10 14:30:42 +00:00
|
|
|
}
|
2020-05-16 21:47:01 +00:00
|
|
|
|
|
|
|
UpdateFileHistory( aProjectFileName.GetFullPath() );
|
2020-08-24 02:01:14 +00:00
|
|
|
|
|
|
|
m_openSavedWindows = true;
|
2019-06-10 14:30:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2017-11-22 08:43:29 +00:00
|
|
|
// show all files in file dialog (in Kicad all files are editable texts):
|
2019-01-08 11:57:39 +00:00
|
|
|
wxString wildcard = AllFilesWildcard();
|
2009-11-18 20:12:11 +00:00
|
|
|
|
2014-11-02 16:25:04 +00:00
|
|
|
wxString default_dir = Prj().GetProjectPath();
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2012-12-31 08:12:29 +00:00
|
|
|
wxFileDialog dlg( this, _( "Load File to Edit" ), default_dir,
|
2017-11-12 00:31:38 +00:00
|
|
|
wxEmptyString, wildcard, wxFD_OPEN );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-09 09:00:23 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2011-08-19 15:08:41 +00:00
|
|
|
wxString filename = wxT( "\"" );
|
|
|
|
filename += dlg.GetPath() + wxT( "\"" );
|
|
|
|
|
* 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
|
|
|
if( !dlg.GetPath().IsEmpty() && !Pgm().GetEditorName().IsEmpty() )
|
2019-06-10 14:23:37 +00:00
|
|
|
m_toolManager->RunAction( KICAD_MANAGER_ACTIONS::openTextEditor, true, &filename );
|
2007-10-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
|
2019-06-10 14:30:42 +00:00
|
|
|
|
2018-06-11 10:10:00 +00:00
|
|
|
void KICAD_MANAGER_FRAME::OnBrowseInFileExplorer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// open project directory in host OS's file explorer
|
2020-02-21 01:10:49 +00:00
|
|
|
LaunchExternal( Prj().GetProjectPath() );
|
2018-06-11 10:10:00 +00:00
|
|
|
}
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2019-06-09 13:12:44 +00:00
|
|
|
void KICAD_MANAGER_FRAME::RefreshProjectTree()
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2019-06-10 14:23:37 +00:00
|
|
|
m_leftWin->ReCreateTreePrj();
|
2007-10-31 17:47:44 +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
|
|
|
void KICAD_MANAGER_FRAME::language_change( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
2018-05-14 17:34:18 +00:00
|
|
|
Kiway().SetLanguage( id );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-17 00:29:55 +00:00
|
|
|
void KICAD_MANAGER_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
// call my base class
|
|
|
|
EDA_BASE_FRAME::ShowChangedLanguage();
|
|
|
|
|
|
|
|
// tooltips in toolbars
|
|
|
|
RecreateBaseHToolbar();
|
2019-06-10 14:23:37 +00:00
|
|
|
RecreateLauncher();
|
2019-05-17 00:29:55 +00:00
|
|
|
|
|
|
|
PrintPrjInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void KICAD_MANAGER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2018-08-20 13:46:38 +00:00
|
|
|
{
|
2020-07-27 22:42:23 +00:00
|
|
|
EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2018-08-20 13:46:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
void KICAD_MANAGER_FRAME::ProjectChanged()
|
|
|
|
{
|
2020-04-13 20:02:35 +00:00
|
|
|
wxString app = wxS( "KiCad " ) + GetMajorMinorVersion();
|
2020-08-15 16:43:54 +00:00
|
|
|
wxString file = GetProjectFileName();
|
2020-04-13 20:02:35 +00:00
|
|
|
wxString title;
|
2020-08-15 16:43:54 +00:00
|
|
|
|
|
|
|
if( !file.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxFileName fn( file );
|
|
|
|
|
2020-04-13 20:02:35 +00:00
|
|
|
title += fn.GetName();
|
2020-08-15 16:43:54 +00:00
|
|
|
|
|
|
|
if( !fn.IsDirWritable() )
|
2020-10-20 19:05:04 +00:00
|
|
|
title += wxS( " " ) + _( "[Read Only]" );
|
2020-04-13 20:02:35 +00:00
|
|
|
|
|
|
|
title += wxS(" \u2014 ");
|
2020-08-15 16:43:54 +00:00
|
|
|
}
|
|
|
|
|
2020-04-13 20:02:35 +00:00
|
|
|
title += app;
|
|
|
|
|
2020-08-15 16:43:54 +00:00
|
|
|
SetTitle( title );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-17 13:54:17 +00:00
|
|
|
void KICAD_MANAGER_FRAME::ClearMsg()
|
2007-10-31 17:47:44 +00:00
|
|
|
{
|
2019-06-10 14:23:37 +00:00
|
|
|
m_messagesBox->Clear();
|
2007-10-31 17:47:44 +00:00
|
|
|
}
|
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void KICAD_MANAGER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2009-04-05 20:49:15 +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
|
|
|
EDA_BASE_FRAME::LoadSettings( aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
|
2020-03-29 16:42:24 +00:00
|
|
|
|
|
|
|
wxCHECK( settings, /*void*/);
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_leftWinWidth = settings->m_LeftWinWidth;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void KICAD_MANAGER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2009-04-05 20:49:15 +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
|
|
|
EDA_BASE_FRAME::SaveSettings( aCfg );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
auto settings = dynamic_cast<KICAD_SETTINGS*>( aCfg );
|
2020-03-29 16:42:24 +00:00
|
|
|
|
|
|
|
wxCHECK( settings, /*void*/);
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
settings->m_LeftWinWidth = m_leftWin->GetSize().x;
|
2014-02-01 18:27:18 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +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
|
|
|
|
2019-06-12 12:43:24 +00:00
|
|
|
void KICAD_MANAGER_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
|
|
|
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
|
|
|
|
{
|
|
|
|
aHotkeysPanel->AddHotKeys( GetToolManager() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-01 18:27:18 +00:00
|
|
|
void KICAD_MANAGER_FRAME::PrintPrjInfo()
|
|
|
|
{
|
2020-10-16 00:39:55 +00:00
|
|
|
wxString msg = wxString::Format( _( "Project name:\n%s\n" ), GetProjectFileName() );
|
2014-02-01 18:27:18 +00:00
|
|
|
PrintMsg( msg );
|
2009-04-05 20:49:15 +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
|
|
|
|
2020-08-24 02:10:05 +00:00
|
|
|
|
2020-08-08 18:52:14 +00:00
|
|
|
bool KICAD_MANAGER_FRAME::IsProjectActive()
|
|
|
|
{
|
|
|
|
return m_active_project;
|
|
|
|
}
|
2020-08-24 02:01:14 +00:00
|
|
|
|
2020-08-24 02:10:05 +00:00
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
|
|
|
|
{
|
|
|
|
/**
|
2020-08-24 02:10:05 +00:00
|
|
|
* We start loading the saved previously open windows on idle to avoid locking up the GUI
|
|
|
|
* earlier in project loading. This gives us the visual effect of a opened KiCad project but
|
|
|
|
* with a "busy" progress reporter
|
2020-08-24 02:01:14 +00:00
|
|
|
*/
|
2020-08-24 02:10:05 +00:00
|
|
|
if( !m_openSavedWindows )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_openSavedWindows = false;
|
|
|
|
|
|
|
|
if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
|
2020-08-24 02:01:14 +00:00
|
|
|
{
|
2020-08-24 02:10:05 +00:00
|
|
|
int previousOpenCount =
|
|
|
|
std::count_if( Prj().GetLocalSettings().m_files.begin(),
|
|
|
|
Prj().GetLocalSettings().m_files.end(),
|
|
|
|
[&]( const PROJECT_FILE_STATE& f )
|
|
|
|
{
|
|
|
|
return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
|
|
|
|
} );
|
|
|
|
|
|
|
|
if( previousOpenCount > 0 )
|
2020-08-24 02:01:14 +00:00
|
|
|
{
|
2020-08-24 02:10:05 +00:00
|
|
|
APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
|
|
|
|
previousOpenCount, this );
|
|
|
|
|
|
|
|
int i = 0;
|
2020-08-24 02:01:14 +00:00
|
|
|
|
2020-08-24 02:10:05 +00:00
|
|
|
for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
|
|
|
|
{
|
|
|
|
if( file.open )
|
2020-08-24 02:01:14 +00:00
|
|
|
{
|
2020-08-24 02:10:05 +00:00
|
|
|
progressReporter.Update( i++,
|
|
|
|
wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) );
|
|
|
|
|
|
|
|
wxFileName fn( file.fileName );
|
|
|
|
|
|
|
|
if( fn.GetExt() == LegacySchematicFileExtension
|
|
|
|
|| fn.GetExt() == KiCadSchematicFileExtension )
|
2020-08-24 02:01:14 +00:00
|
|
|
{
|
2020-08-24 02:10:05 +00:00
|
|
|
GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editSchematic, true );
|
|
|
|
}
|
|
|
|
else if( fn.GetExt() == LegacyPcbFileExtension
|
|
|
|
|| fn.GetExt() == KiCadPcbFileExtension )
|
|
|
|
{
|
|
|
|
GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editPCB, true );
|
2020-08-24 02:01:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-24 02:10:05 +00:00
|
|
|
|
|
|
|
wxYield();
|
2020-08-24 02:01:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-24 02:10:05 +00:00
|
|
|
|
|
|
|
// clear file states regardless if we opened windows or not due to setting
|
|
|
|
Prj().GetLocalSettings().ClearFileState();
|
|
|
|
}
|