2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-03-17 07:34:02 +00:00
|
|
|
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-11-12 00:31:38 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-01-17 16:19:53 +00:00
|
|
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56:32 +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
|
|
|
|
*/
|
|
|
|
|
2023-05-25 00:07:46 +00:00
|
|
|
#include <string>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gestfich.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h>
|
2013-10-13 16:29:20 +00:00
|
|
|
#include <fp_lib_table.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2018-04-13 13:58:25 +00:00
|
|
|
#include <trace_helpers.h>
|
2022-12-17 22:56:52 +00:00
|
|
|
#include <lockfile.h>
|
|
|
|
#include <wx/snglinst.h>
|
2019-11-17 12:58:38 +00:00
|
|
|
#include <netlist_reader/pcb_netlist.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <io_mgr.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-05-18 16:11:57 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-07-21 00:33:35 +00:00
|
|
|
#include <kiplatform/app.h>
|
2020-08-19 23:15:03 +00:00
|
|
|
#include <widgets/appearance_controls.h>
|
2022-12-28 22:03:03 +00:00
|
|
|
#include <widgets/wx_infobar.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <widgets/wx_progress_reporters.h>
|
2020-05-25 20:41:24 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2021-01-23 04:17:32 +00:00
|
|
|
#include <paths.h>
|
2023-07-21 22:40:19 +00:00
|
|
|
#include <pgm_base.h>
|
2020-05-31 21:42:04 +00:00
|
|
|
#include <project/project_file.h>
|
2023-09-28 03:15:54 +00:00
|
|
|
#include <project_pcb.h>
|
2020-05-31 21:42:04 +00:00
|
|
|
#include <project/project_local_settings.h>
|
2020-11-18 00:16:21 +00:00
|
|
|
#include <project/net_settings.h>
|
2020-10-01 22:47:38 +00:00
|
|
|
#include <plugins/cadstar/cadstar_pcb_archive_plugin.h>
|
2021-11-25 12:22:40 +00:00
|
|
|
#include <plugins/kicad/pcb_plugin.h>
|
2020-10-01 22:47:38 +00:00
|
|
|
#include <dialogs/dialog_imported_layers.h>
|
2021-05-28 23:43:46 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2020-12-11 01:38:55 +00:00
|
|
|
#include "footprint_info_impl.h"
|
2023-06-05 10:00:12 +00:00
|
|
|
#include <board_commit.h>
|
|
|
|
#include <zone_filler.h>
|
2021-06-07 19:12:30 +00:00
|
|
|
#include <wx_filename.h> // For ::ResolvePossibleSymlinks()
|
2015-09-25 19:38:09 +00:00
|
|
|
|
2023-05-25 00:07:46 +00:00
|
|
|
#include <kiplatform/io.h>
|
|
|
|
|
2023-06-05 10:00:12 +00:00
|
|
|
#include <wx/stdpaths.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/filedlg.h>
|
2023-01-06 02:08:49 +00:00
|
|
|
#include <wx/txtstrm.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
|
2022-06-12 02:10:49 +00:00
|
|
|
#include "widgets/filedlg_hook_save_project.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2016-01-15 01:48:44 +00:00
|
|
|
//#define USE_INSTRUMENTATION 1
|
|
|
|
#define USE_INSTRUMENTATION 0
|
2013-07-01 06:47:36 +00:00
|
|
|
|
2011-12-05 17:22:19 +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
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Show a wxFileDialog asking for a #BOARD filename to open.
|
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
|
|
|
*
|
|
|
|
* @param aParent is a wxFrame passed to wxFileDialog.
|
|
|
|
* @param aCtl is where to put the OpenProjectFiles() control bits.
|
|
|
|
* @param aFileName on entry is a probable choice, on return is the chosen filename.
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aKicadFilesOnly true to list KiCad pcb files plugins only, false to list import plugins.
|
|
|
|
* @return true if chosen, else false if user aborted.
|
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
|
|
|
*/
|
2023-08-13 02:26:06 +00:00
|
|
|
bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, int aCtl = 0 )
|
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
|
|
|
{
|
2023-08-13 02:26:06 +00:00
|
|
|
std::vector<PLUGIN_FILE_DESC> descriptions;
|
2020-04-03 23:22:24 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
for( const auto& plugin : IO_MGR::PLUGIN_REGISTRY::Instance()->AllPlugins() )
|
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
|
|
|
{
|
2023-08-13 02:26:06 +00:00
|
|
|
bool isKiCad = plugin.m_type == IO_MGR::KICAD_SEXP || plugin.m_type == IO_MGR::LEGACY;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
if( ( aCtl & KICTL_KICAD_ONLY ) && !isKiCad )
|
|
|
|
continue;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
if( ( aCtl & KICTL_NONKICAD_ONLY ) && isKiCad )
|
|
|
|
continue;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
// release the PLUGIN even if an exception is thrown.
|
|
|
|
PLUGIN::RELEASER pi( plugin.m_createFunc() );
|
|
|
|
wxCHECK( pi, false );
|
2023-06-16 00:41:56 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
const PLUGIN_FILE_DESC& desc = pi->GetBoardFileDesc();
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
if( desc.m_FileExtensions.empty() )
|
|
|
|
continue;
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
descriptions.emplace_back( desc );
|
|
|
|
}
|
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
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
wxString fileFiltersStr;
|
|
|
|
std::vector<std::string> allExtensions;
|
|
|
|
std::set<wxString> allWildcardsSet;
|
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
|
|
|
|
2023-08-17 11:43:24 +00:00
|
|
|
for( const PLUGIN_FILE_DESC& desc : descriptions )
|
2016-03-04 18:48:08 +00:00
|
|
|
{
|
2023-08-13 02:26:06 +00:00
|
|
|
if( !fileFiltersStr.IsEmpty() )
|
|
|
|
fileFiltersStr += wxChar( '|' );
|
2020-10-02 23:17:28 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
fileFiltersStr += desc.FileFilter();
|
2020-10-02 23:17:28 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
for( const std::string& ext : desc.m_FileExtensions )
|
|
|
|
{
|
|
|
|
allExtensions.emplace_back( ext );
|
|
|
|
allWildcardsSet.insert( wxT( "*." ) + formatWildcardExt( ext ) + wxT( ";" ) );
|
2016-03-04 18:48:08 +00:00
|
|
|
}
|
2023-08-13 02:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString allWildcardsStr;
|
2023-08-17 06:36:47 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
for( const wxString& wildcard : allWildcardsSet )
|
|
|
|
allWildcardsStr << wildcard;
|
2020-10-02 23:17:28 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
if( aCtl & KICTL_KICAD_ONLY )
|
|
|
|
{
|
2023-08-17 06:36:47 +00:00
|
|
|
fileFiltersStr = _( "All KiCad Board Files" ) + AddFileExtListToFilter( allExtensions );
|
2016-03-04 18:48:08 +00:00
|
|
|
}
|
|
|
|
else
|
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
|
|
|
{
|
2023-08-13 02:26:06 +00:00
|
|
|
fileFiltersStr = _( "All supported formats" ) + wxT( "|" ) + allWildcardsStr + wxT( "|" )
|
|
|
|
+ fileFiltersStr;
|
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
|
|
|
}
|
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
wxFileName fileName( *aFileName );
|
|
|
|
wxString path;
|
|
|
|
wxString name;
|
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
|
|
|
|
|
|
|
if( fileName.FileExists() )
|
|
|
|
{
|
|
|
|
path = fileName.GetPath();
|
|
|
|
name = fileName.GetFullName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-28 19:30:16 +00:00
|
|
|
path = aParent->GetMruPath();
|
|
|
|
|
|
|
|
if( path.IsEmpty() )
|
|
|
|
path = PATHS::GetDefaultUserProjectsPath();
|
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
|
|
|
// leave name empty
|
|
|
|
}
|
|
|
|
|
2016-03-04 18:48:08 +00:00
|
|
|
wxFileDialog dlg( aParent,
|
2023-08-13 02:26:06 +00:00
|
|
|
( aCtl & KICTL_KICAD_ONLY ) ? _( "Open Board File" )
|
|
|
|
: _( "Import Non KiCad Board File" ),
|
|
|
|
path, name, fileFiltersStr, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
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
|
|
|
|
2016-03-04 18:48:08 +00:00
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
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
|
|
|
{
|
|
|
|
*aFileName = dlg.GetPath();
|
2021-02-28 19:30:16 +00:00
|
|
|
aParent->SetMruPath( wxFileName( dlg.GetPath() ).GetPath() );
|
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 true;
|
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +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
|
|
|
return false;
|
2021-07-19 23:56:05 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Put up a wxFileDialog asking for a BOARD filename to save.
|
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
|
|
|
*
|
|
|
|
* @param aParent is a wxFrame passed to wxFileDialog.
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aFileName on entry is a probable choice, on return is the chosen full filename
|
|
|
|
* (includes path).
|
|
|
|
* @param aCreateProject will be filled with the state of the Create Project? checkbox if relevant.
|
|
|
|
* @return true if chosen, else false if user aborted.
|
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
|
|
|
*/
|
2020-09-22 00:00:51 +00:00
|
|
|
bool AskSaveBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, bool* aCreateProject )
|
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
|
|
|
{
|
2017-11-12 00:31:38 +00:00
|
|
|
wxString wildcard = PcbFileWildcard();
|
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
|
|
|
wxFileName fn = *aFileName;
|
|
|
|
|
|
|
|
fn.SetExt( KiCadPcbFileExtension );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
wxFileDialog dlg( aParent, _( "Save Board File As" ), fn.GetPath(), fn.GetFullName(), wildcard,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
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
|
|
|
|
2022-12-17 22:56:20 +00:00
|
|
|
// Add a "Create a project" checkbox in standalone mode and one isn't loaded
|
2022-06-12 02:10:49 +00:00
|
|
|
FILEDLG_HOOK_SAVE_PROJECT newProjectHook;
|
|
|
|
|
2022-12-17 22:56:20 +00:00
|
|
|
if( Kiface().IsSingle() && aParent->Prj().IsNullProject() )
|
|
|
|
dlg.SetCustomizeHook( newProjectHook );
|
2020-09-22 00:00:51 +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
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return false;
|
|
|
|
|
2023-03-12 14:49:57 +00:00
|
|
|
*aFileName = dlg.GetPath();
|
|
|
|
*aFileName = EnsureFileExtension( *aFileName, KiCadPcbFileExtension );
|
2020-09-22 21:58:16 +00:00
|
|
|
|
2022-12-17 22:56:20 +00:00
|
|
|
if( newProjectHook.IsAttachedToDialog() )
|
2022-06-12 02:10:49 +00:00
|
|
|
*aCreateProject = newProjectHook.GetCreateNewProject();
|
|
|
|
else if( !aParent->Prj().IsNullProject() )
|
|
|
|
*aCreateProject = true;
|
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 true;
|
|
|
|
}
|
* 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
|
|
|
|
2010-04-28 14:06:14 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::OnFileHistory( wxCommandEvent& event )
|
2009-01-17 20:31:19 +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
|
|
|
wxString fn = GetFileFromHistory( event.GetId(), _( "Printed circuit board" ) );
|
2009-01-17 20:31:19 +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
|
|
|
if( !!fn )
|
2009-01-17 20:31:19 +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
|
|
|
if( !wxFileName::IsFileReadable( fn ) )
|
|
|
|
{
|
2023-08-13 02:26:06 +00:00
|
|
|
if( !AskLoadBoardFileName( this, &fn, KICTL_KICAD_ONLY ) )
|
* 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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
OpenProjectFiles( std::vector<wxString>( 1, fn ), KICTL_KICAD_ONLY );
|
2009-01-17 20:31:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-16 21:47:01 +00:00
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
void PCB_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
ClearFileHistory();
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
int id = event.GetId();
|
2015-03-17 07:34:02 +00:00
|
|
|
Files_io_from_id( id );
|
|
|
|
}
|
|
|
|
|
2018-08-11 20:46:03 +00:00
|
|
|
|
|
|
|
bool PCB_EDIT_FRAME::Files_io_from_id( int id )
|
2015-03-17 07:34:02 +00:00
|
|
|
{
|
2007-08-06 02:02:39 +00:00
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_LOAD_FILE:
|
2021-02-20 14:23:45 +00:00
|
|
|
{
|
2023-08-13 02:26:06 +00:00
|
|
|
int open_ctl = KICTL_KICAD_ONLY;
|
|
|
|
wxString fileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
* 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-08-13 02:26:06 +00:00
|
|
|
return AskLoadBoardFileName( this, &fileName, open_ctl )
|
|
|
|
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
|
2021-02-20 14:23:45 +00:00
|
|
|
}
|
2016-03-04 18:48:08 +00:00
|
|
|
|
|
|
|
case ID_IMPORT_NON_KICAD_BOARD:
|
2021-02-20 14:23:45 +00:00
|
|
|
{
|
2023-08-13 02:26:06 +00:00
|
|
|
int open_ctl = KICTL_NONKICAD_ONLY;
|
|
|
|
wxString fileName; // = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
2016-03-04 18:48:08 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
return AskLoadBoardFileName( this, &fileName, open_ctl )
|
|
|
|
&& OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
|
2021-02-20 14:23:45 +00:00
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2012-12-21 07:58:51 +00:00
|
|
|
case ID_MENU_RECOVER_BOARD_AUTOSAVE:
|
2021-02-20 14:23:45 +00:00
|
|
|
{
|
|
|
|
wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
|
|
|
wxFileName fn = currfn;
|
* 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
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName();
|
|
|
|
fn.SetName( rec_name );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
if( !fn.FileExists() )
|
|
|
|
{
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Recovery file '%s' not found." ), fn.GetFullPath() );
|
2021-02-20 14:23:45 +00:00
|
|
|
DisplayInfoMessage( this, msg );
|
|
|
|
return false;
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "OK to load recovery file '%s'?" ), fn.GetFullPath() );
|
2012-12-21 07:58:51 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
return false;
|
2012-05-29 21:01:17 +00:00
|
|
|
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified( false ); // do not prompt the user for changes
|
* 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
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
if( OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) ) )
|
|
|
|
{
|
|
|
|
// Re-set the name since name or extension was changed
|
|
|
|
GetBoard()->SetFileName( currfn.GetFullPath() );
|
|
|
|
UpdateTitle();
|
|
|
|
return true;
|
2012-05-29 21:01:17 +00:00
|
|
|
}
|
2021-02-20 14:36:15 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2022-04-17 17:14:50 +00:00
|
|
|
case ID_REVERT_BOARD:
|
|
|
|
{
|
|
|
|
wxFileName fn = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
|
|
|
|
|
|
|
msg.Printf( _( "Revert '%s' to last version saved?" ), fn.GetFullPath() );
|
|
|
|
|
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
GetScreen()->SetContentModified( false ); // do not prompt the user for changes
|
|
|
|
|
2022-04-26 21:28:10 +00:00
|
|
|
ReleaseFile();
|
|
|
|
|
2022-04-17 17:14:50 +00:00
|
|
|
return OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
case ID_NEW_BOARD:
|
2015-09-25 19:38:09 +00:00
|
|
|
{
|
2019-12-19 15:34:01 +00:00
|
|
|
if( IsContentModified() )
|
2019-11-24 14:50:34 +00:00
|
|
|
{
|
|
|
|
wxFileName fileName = GetBoard()->GetFileName();
|
2021-02-20 14:23:45 +00:00
|
|
|
wxString saveMsg = _( "Current board will be closed, save changes to '%s' before "
|
|
|
|
"continuing?" );
|
2019-11-24 14:50:34 +00:00
|
|
|
|
|
|
|
if( !HandleUnsavedChanges( this, wxString::Format( saveMsg, fileName.GetFullName() ),
|
2021-02-20 14:23:45 +00:00
|
|
|
[&]()->bool
|
|
|
|
{
|
|
|
|
return Files_io_from_id( ID_SAVE_BOARD );
|
|
|
|
} ) )
|
|
|
|
{
|
2019-11-24 14:50:34 +00:00
|
|
|
return false;
|
2021-02-20 14:23:45 +00:00
|
|
|
}
|
2019-11-24 14:50:34 +00:00
|
|
|
}
|
|
|
|
else if( !GetBoard()->IsEmpty() )
|
|
|
|
{
|
|
|
|
if( !IsOK( this, _( "Current Board will be closed. Continue?" ) ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-03-04 19:25:07 +00:00
|
|
|
SaveProjectLocalSettings();
|
2020-07-07 01:53:28 +00:00
|
|
|
|
|
|
|
GetBoard()->ClearProject();
|
|
|
|
|
2020-06-20 14:36:16 +00:00
|
|
|
SETTINGS_MANAGER* mgr = GetSettingsManager();
|
|
|
|
mgr->UnloadProject( &mgr->Prj() );
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
if( !Clear_Pcb( false ) )
|
|
|
|
return false;
|
|
|
|
|
2020-08-23 21:57:17 +00:00
|
|
|
LoadProjectSettings();
|
|
|
|
|
2021-03-14 15:41:56 +00:00
|
|
|
onBoardLoaded();
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
OnModify();
|
2018-08-11 20:46:03 +00:00
|
|
|
return true;
|
2015-09-25 19:38:09 +00:00
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
|
|
|
case ID_SAVE_BOARD:
|
2018-08-11 20:46:03 +00:00
|
|
|
if( !GetBoard()->GetFileName().IsEmpty() )
|
2022-10-10 13:03:10 +00:00
|
|
|
{
|
|
|
|
if( SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) ) )
|
|
|
|
{
|
|
|
|
m_autoSaveRequired = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-24 23:44:09 +00:00
|
|
|
|
|
|
|
KI_FALLTHROUGH;
|
2018-08-11 20:46:03 +00:00
|
|
|
|
2015-03-17 07:34:02 +00:00
|
|
|
case ID_COPY_BOARD_AS:
|
|
|
|
case ID_SAVE_BOARD_AS:
|
2021-02-20 14:23:45 +00:00
|
|
|
{
|
2021-04-06 11:40:44 +00:00
|
|
|
bool addToHistory = ( id == ID_SAVE_BOARD_AS );
|
2021-02-20 14:23:45 +00:00
|
|
|
wxString orig_name;
|
2021-04-06 11:40:44 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
wxFileName::SplitPath( GetBoard()->GetFileName(), nullptr, nullptr, &orig_name, nullptr );
|
|
|
|
|
|
|
|
if( orig_name.IsEmpty() )
|
2021-05-27 23:39:41 +00:00
|
|
|
orig_name = NAMELESS_PROJECT;
|
2019-12-26 13:42:11 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
wxFileName savePath( Prj().GetProjectFullName() );
|
2019-12-26 13:42:11 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
if( !savePath.IsOk() || !savePath.IsDirWritable() )
|
|
|
|
{
|
|
|
|
savePath = GetMruPath();
|
2020-10-22 00:55:43 +00:00
|
|
|
|
|
|
|
if( !savePath.IsOk() || !savePath.IsDirWritable() )
|
2021-02-20 14:23:45 +00:00
|
|
|
savePath = PATHS::GetDefaultUserProjectsPath();
|
|
|
|
}
|
2020-10-22 00:55:43 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
|
|
|
|
wxString filename = fn.GetFullPath();
|
2021-04-06 11:40:44 +00:00
|
|
|
bool createProject = false;
|
2022-10-10 13:03:10 +00:00
|
|
|
bool success = false;
|
2020-09-22 00:00:51 +00:00
|
|
|
|
2021-02-20 14:23:45 +00:00
|
|
|
if( AskSaveBoardFileName( this, &filename, &createProject ) )
|
|
|
|
{
|
|
|
|
if( id == ID_COPY_BOARD_AS )
|
2022-10-10 13:03:10 +00:00
|
|
|
{
|
|
|
|
success = SavePcbCopy( filename, createProject );
|
|
|
|
}
|
2021-02-20 14:23:45 +00:00
|
|
|
else
|
2022-10-10 13:03:10 +00:00
|
|
|
{
|
|
|
|
success = SavePcbFile( filename, addToHistory, createProject );
|
|
|
|
|
|
|
|
if( success )
|
|
|
|
m_autoSaveRequired = false;
|
|
|
|
}
|
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
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2022-10-10 13:03:10 +00:00
|
|
|
return success;
|
2021-02-20 14:23:45 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 02:02:39 +00:00
|
|
|
default:
|
2018-08-11 20:46:03 +00:00
|
|
|
return false;
|
2007-08-06 02:02:39 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-19 13:25:30 +00:00
|
|
|
int PCB_EDIT_FRAME::inferLegacyEdgeClearance( BOARD* aBoard )
|
|
|
|
{
|
|
|
|
PCB_LAYER_COLLECTOR collector;
|
|
|
|
|
|
|
|
collector.SetLayerId( Edge_Cuts );
|
|
|
|
collector.Collect( aBoard, GENERAL_COLLECTOR::AllBoardItems );
|
|
|
|
|
|
|
|
int edgeWidth = -1;
|
|
|
|
bool mixed = false;
|
|
|
|
|
|
|
|
for( int i = 0; i < collector.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
if( collector[i]->Type() == PCB_SHAPE_T )
|
|
|
|
{
|
|
|
|
int itemWidth = static_cast<PCB_SHAPE*>( collector[i] )->GetWidth();
|
|
|
|
|
|
|
|
if( edgeWidth != -1 && edgeWidth != itemWidth )
|
|
|
|
{
|
|
|
|
mixed = true;
|
|
|
|
edgeWidth = std::max( edgeWidth, itemWidth );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edgeWidth = itemWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mixed )
|
|
|
|
{
|
|
|
|
// If they had different widths then we can't ensure that fills will be the same.
|
2023-01-19 00:53:16 +00:00
|
|
|
DisplayInfoMessage( this, _( "If the zones on this board are refilled the Copper Edge Clearance "
|
2021-01-13 12:07:06 +00:00
|
|
|
"setting will be used (see Board Setup > Design Rules > Constraints).\n"
|
2021-02-18 15:49:35 +00:00
|
|
|
"This may result in different fills from previous KiCad versions which "
|
2021-01-27 22:15:38 +00:00
|
|
|
"used the line thicknesses of the board boundary on the Edge Cuts "
|
2023-01-19 00:53:16 +00:00
|
|
|
"layer." ) );
|
2020-11-19 13:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return std::max( 0, edgeWidth / 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
* 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
|
|
|
bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
|
|
|
|
{
|
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
|
|
|
// This is for python:
|
|
|
|
if( aFileSet.size() != 1 )
|
|
|
|
{
|
2021-06-26 19:17:34 +00:00
|
|
|
UTF8 msg = StrPrintf( "Pcbnew:%s() takes a single filename", __func__ );
|
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
|
|
|
DisplayError( this, msg );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-31 21:38:45 +00:00
|
|
|
wxString fullFileName( aFileSet[0] );
|
|
|
|
wxFileName wx_filename( fullFileName );
|
|
|
|
wxString msg;
|
* 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-07-21 00:33:35 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
KIPLATFORM::APP::RegisterApplicationRestart( fullFileName );
|
|
|
|
|
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
|
|
|
// We insist on caller sending us an absolute path, if it does not, we say it's a bug.
|
2021-08-31 21:38:45 +00:00
|
|
|
wxASSERT_MSG( wx_filename.IsAbsolute(), wxT( "Path is not absolute!" ) );
|
* 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-05-24 20:19:48 +00:00
|
|
|
std::unique_ptr<LOCKFILE> lock = std::make_unique<LOCKFILE>( fullFileName );
|
2018-09-21 23:07:54 +00:00
|
|
|
|
2023-07-21 22:40:19 +00:00
|
|
|
if( !lock->Valid() && lock->IsLockedByMe() )
|
|
|
|
{
|
|
|
|
// If we cannot acquire the lock but we appear to be the one who
|
|
|
|
// locked it, check to see if there is another KiCad instance running.
|
|
|
|
// If there is not, then we can override the lock. This could happen if
|
|
|
|
// KiCad crashed or was interrupted
|
|
|
|
|
|
|
|
if( !Pgm().SingleInstance()->IsAnotherRunning() )
|
|
|
|
lock->OverrideLock();
|
|
|
|
}
|
|
|
|
|
2023-06-01 00:04:32 +00:00
|
|
|
if( !lock->Valid() )
|
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
|
|
|
{
|
2023-05-24 20:19:48 +00:00
|
|
|
msg.Printf( _( "PCB '%s' is already open by '%s' at '%s'." ), wx_filename.GetFullName(),
|
|
|
|
lock->GetUsername(), lock->GetHostname() );
|
2021-08-31 14:03:40 +00:00
|
|
|
|
2023-07-21 22:40:19 +00:00
|
|
|
if( !AskOverrideLock( this, msg ) )
|
2021-08-31 14:03:40 +00:00
|
|
|
return false;
|
2023-05-24 20:19:48 +00:00
|
|
|
|
|
|
|
lock->OverrideLock();
|
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
|
|
|
}
|
* 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-12-19 15:34:01 +00:00
|
|
|
if( IsContentModified() )
|
* 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
|
|
|
{
|
2018-08-11 20:46:03 +00:00
|
|
|
if( !HandleUnsavedChanges( this, _( "The current PCB has been modified. Save changes?" ),
|
2021-10-01 20:49:14 +00:00
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
return SavePcbFile( GetBoard()->GetFileName() );
|
|
|
|
} ) )
|
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
|
|
|
{
|
2018-08-01 23:06:12 +00:00
|
|
|
return false;
|
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
|
|
|
}
|
* 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
|
|
|
}
|
2009-09-22 12:27:57 +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
|
|
|
wxFileName pro = fullFileName;
|
2020-05-31 21:42:04 +00:00
|
|
|
pro.SetExt( ProjectFileExtension );
|
* 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
|
|
|
bool is_new = !wxFileName::IsFileReadable( fullFileName );
|
* 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
|
|
|
// If its a non-existent schematic and caller thinks it exists
|
|
|
|
if( is_new && !( aCtl & KICTL_CREATE ) )
|
* 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
|
|
|
// notify user that fullFileName does not exist, ask if user wants to create it.
|
2021-08-31 14:03:40 +00:00
|
|
|
msg.Printf( _( "PCB '%s' does not exist. Do you wish to create it?" ), fullFileName );
|
|
|
|
|
|
|
|
if( !IsOK( this, msg ) )
|
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 false;
|
* 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
|
|
|
}
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2021-02-04 00:11:02 +00:00
|
|
|
// Get rid of any existing warnings about the old board
|
|
|
|
GetInfoBar()->Dismiss();
|
|
|
|
|
2021-06-26 19:17:34 +00:00
|
|
|
WX_PROGRESS_REPORTER progressReporter( this, is_new ? _( "Creating PCB" )
|
|
|
|
: _( "Loading PCB" ), 1 );
|
2020-12-21 16:44:10 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
// No save prompt (we already prompted above), and only reset to a new blank board if new
|
|
|
|
Clear_Pcb( false, !is_new );
|
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
|
|
|
|
2023-10-02 21:12:07 +00:00
|
|
|
IO_MGR::PCB_FILE_T pluginType = IO_MGR::KICAD_SEXP;
|
|
|
|
|
|
|
|
if( !is_new )
|
|
|
|
pluginType = IO_MGR::FindPluginTypeFromBoardPath( fullFileName, aCtl );
|
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
|
|
|
|
2023-08-26 19:28:53 +00:00
|
|
|
if( pluginType == IO_MGR::FILE_TYPE_NONE )
|
|
|
|
return false;
|
|
|
|
|
2017-10-03 10:23:52 +00:00
|
|
|
bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD_SEXP;
|
2012-05-29 21:01:17 +00:00
|
|
|
|
2020-11-29 03:45:56 +00:00
|
|
|
// Loading a project should only be done under carefully considered circumstances.
|
2008-04-29 03:18:02 +00:00
|
|
|
|
2020-11-29 03:45:56 +00:00
|
|
|
// The calling code should know not to ask me here to change projects unless
|
|
|
|
// it knows what consequences that will have on other KIFACEs running and using
|
|
|
|
// this same PROJECT. It can be very harmful if that calling code is stupid.
|
|
|
|
SETTINGS_MANAGER* mgr = GetSettingsManager();
|
2020-06-20 14:36:16 +00:00
|
|
|
|
2020-11-29 03:45:56 +00:00
|
|
|
if( pro.GetFullPath() != mgr->Prj().GetProjectFullName() )
|
|
|
|
{
|
|
|
|
// calls SaveProject
|
2023-03-04 19:25:07 +00:00
|
|
|
SaveProjectLocalSettings();
|
2020-07-07 01:53:28 +00:00
|
|
|
|
2021-01-12 03:17:13 +00:00
|
|
|
GetBoard()->ClearProject();
|
2020-11-29 03:45:56 +00:00
|
|
|
mgr->UnloadProject( &mgr->Prj() );
|
2020-06-20 14:36:16 +00:00
|
|
|
|
2020-11-29 03:45:56 +00:00
|
|
|
mgr->LoadProject( pro.GetFullPath() );
|
2020-08-30 20:04:39 +00:00
|
|
|
|
2020-11-29 03:45:56 +00:00
|
|
|
// Do not allow saving a project if one doesn't exist. This normally happens if we are
|
|
|
|
// standalone and opening a board that has been moved from its project folder.
|
|
|
|
// For converted projects, we don't want to set the read-only flag because we want a project
|
|
|
|
// to be saved for the new file in case things like netclasses got migrated.
|
2021-03-21 20:21:24 +00:00
|
|
|
Prj().SetReadOnly( !pro.Exists() && !converted );
|
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
|
|
|
}
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2020-12-11 01:38:55 +00:00
|
|
|
// Clear the cache footprint list which may be project specific
|
|
|
|
GFootprintList.Clear();
|
|
|
|
|
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
|
|
|
if( is_new )
|
2011-11-29 03:08:14 +00:00
|
|
|
{
|
2020-10-13 23:16:36 +00:00
|
|
|
// Link the existing blank board to the new project
|
|
|
|
GetBoard()->SetProject( &Prj() );
|
|
|
|
|
|
|
|
GetBoard()->SetFileName( fullFileName );
|
|
|
|
|
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
|
|
|
OnModify();
|
2011-11-29 03:08:14 +00:00
|
|
|
}
|
2011-12-15 02:24:52 +00:00
|
|
|
else
|
|
|
|
{
|
2021-06-30 15:06:07 +00:00
|
|
|
BOARD* loadedBoard = nullptr; // it will be set to non-NULL if loaded OK
|
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
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
|
2011-11-29 03:08:14 +00:00
|
|
|
|
2021-06-24 13:06:25 +00:00
|
|
|
LAYER_REMAPPABLE_PLUGIN* layerRemappablePlugin =
|
2020-10-09 16:58:21 +00:00
|
|
|
dynamic_cast< LAYER_REMAPPABLE_PLUGIN* >( (PLUGIN*) pi );
|
2021-06-24 13:06:25 +00:00
|
|
|
|
|
|
|
if( layerRemappablePlugin )
|
2020-10-01 22:47:38 +00:00
|
|
|
{
|
2021-06-24 13:06:25 +00:00
|
|
|
layerRemappablePlugin->RegisterLayerMappingCallback(
|
|
|
|
std::bind( DIALOG_IMPORTED_LAYERS::GetMapModal, this, std::placeholders::_1 ) );
|
2020-10-01 22:47:38 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 12:22:33 +00:00
|
|
|
// This will rename the file if there is an autosave and the user want to recover
|
|
|
|
CheckForAutoSaveFile( fullFileName );
|
|
|
|
|
2021-05-01 17:11:10 +00:00
|
|
|
bool failedLoad = false;
|
|
|
|
|
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
|
|
|
try
|
|
|
|
{
|
2023-08-18 12:51:33 +00:00
|
|
|
if( pi == nullptr )
|
|
|
|
{
|
2023-08-18 12:07:45 +00:00
|
|
|
// There was no plugin found, e.g. due to invalid file extension, file header,...
|
|
|
|
THROW_IO_ERROR( _( "File format is not supported" ) );
|
|
|
|
}
|
|
|
|
|
2022-11-06 16:51:52 +00:00
|
|
|
STRING_UTF8_MAP props;
|
2012-06-01 07:39:32 +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
|
|
|
// EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
|
2023-04-17 15:39:34 +00:00
|
|
|
props["page_width"] = std::to_string( GetPageSizeIU().x );
|
|
|
|
props["page_height"] = std::to_string( GetPageSizeIU().y );
|
2012-06-01 07:39:32 +00:00
|
|
|
|
2022-02-11 21:38:31 +00:00
|
|
|
pi->SetQueryUserCallback(
|
|
|
|
[&]( wxString aTitle, int aIcon, wxString aMessage, wxString aAction ) -> bool
|
|
|
|
{
|
|
|
|
KIDIALOG dlg( nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
|
|
|
|
|
|
|
|
if( !aAction.IsEmpty() )
|
|
|
|
dlg.SetOKLabel( aAction );
|
|
|
|
|
|
|
|
dlg.DoNotShowCheckbox( aMessage, 0 );
|
|
|
|
|
|
|
|
return dlg.ShowModal() == wxID_OK;
|
|
|
|
} );
|
|
|
|
|
2013-07-01 06:47:36 +00:00
|
|
|
#if USE_INSTRUMENTATION
|
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
|
|
|
// measure the time to load a BOARD.
|
|
|
|
unsigned startTime = GetRunningMicroSecs();
|
2013-07-01 01:05:40 +00:00
|
|
|
#endif
|
|
|
|
|
2023-08-13 02:11:58 +00:00
|
|
|
loadedBoard = pi->LoadBoard( fullFileName, nullptr, &props, &Prj(), &progressReporter );
|
2012-08-29 16:59:50 +00:00
|
|
|
|
2013-07-01 06:47:36 +00:00
|
|
|
#if USE_INSTRUMENTATION
|
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
|
|
|
unsigned stopTime = GetRunningMicroSecs();
|
|
|
|
printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime );
|
2013-07-01 01:05:40 +00:00
|
|
|
#endif
|
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
|
|
|
}
|
2021-06-30 15:06:07 +00:00
|
|
|
catch( const FUTURE_FORMAT_ERROR& ffe )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Error loading PCB '%s'." ), fullFileName );
|
|
|
|
progressReporter.Hide();
|
|
|
|
DisplayErrorMessage( this, msg, ffe.Problem() );
|
|
|
|
|
|
|
|
failedLoad = true;
|
|
|
|
}
|
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
|
|
|
catch( const IO_ERROR& ioe )
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
{
|
2018-12-07 00:24:27 +00:00
|
|
|
if( ioe.Problem() != wxT( "CANCEL" ) )
|
|
|
|
{
|
2021-06-30 15:06:07 +00:00
|
|
|
msg.Printf( _( "Error loading PCB '%s'." ), fullFileName );
|
|
|
|
progressReporter.Hide();
|
|
|
|
DisplayErrorMessage( this, msg, ioe.What() );
|
2018-12-07 00:24:27 +00:00
|
|
|
}
|
|
|
|
|
2021-05-01 17:11:10 +00:00
|
|
|
failedLoad = true;
|
|
|
|
}
|
|
|
|
catch( const std::bad_alloc& )
|
|
|
|
{
|
2021-06-30 15:06:07 +00:00
|
|
|
msg.Printf( _( "Memory exhausted loading PCB '%s'" ), fullFileName );
|
|
|
|
progressReporter.Hide();
|
|
|
|
DisplayErrorMessage( this, msg, wxEmptyString );
|
|
|
|
|
2021-05-01 17:11:10 +00:00
|
|
|
failedLoad = true;
|
|
|
|
}
|
|
|
|
|
2023-10-01 13:38:30 +00:00
|
|
|
if( failedLoad || !loadedBoard )
|
2021-05-01 17:11:10 +00:00
|
|
|
{
|
2020-05-31 21:42:04 +00:00
|
|
|
// We didn't create a new blank board above, so do that now
|
|
|
|
Clear_Pcb( false );
|
|
|
|
|
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 false;
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
}
|
2011-11-29 03:08:14 +00:00
|
|
|
|
2021-09-16 19:27:29 +00:00
|
|
|
// This fixes a focus issue after the progress reporter is done on GTK. It shouldn't
|
|
|
|
// cause any issues on macOS and Windows. If it does, it will have to be conditionally
|
|
|
|
// compiled.
|
|
|
|
Raise();
|
|
|
|
|
2021-11-25 03:04:16 +00:00
|
|
|
// Skip (possibly expensive) connectivity build here; we build it below after load
|
2021-11-25 16:19:03 +00:00
|
|
|
SetBoard( loadedBoard, false, &progressReporter );
|
2020-05-31 21:42:04 +00:00
|
|
|
|
2020-12-11 01:38:55 +00:00
|
|
|
if( GFootprintList.GetCount() == 0 )
|
2022-02-04 22:44:59 +00:00
|
|
|
GFootprintList.ReadCacheFromFile( Prj().GetProjectPath() + wxT( "fp-info-cache" ) );
|
2020-12-11 01:38:55 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
if( loadedBoard->m_LegacyDesignSettingsLoaded )
|
2020-11-18 00:16:21 +00:00
|
|
|
{
|
2021-03-21 20:21:24 +00:00
|
|
|
Prj().SetReadOnly( false );
|
|
|
|
|
2020-11-19 13:25:30 +00:00
|
|
|
// Before we had a copper edge clearance setting, the edge line widths could be used
|
|
|
|
// as a kludge to control them. So if there's no setting then infer it from the
|
|
|
|
// edge widths.
|
|
|
|
if( !loadedBoard->m_LegacyCopperEdgeClearanceLoaded )
|
|
|
|
{
|
|
|
|
int edgeClearance = inferLegacyEdgeClearance( loadedBoard );
|
2021-07-11 15:12:28 +00:00
|
|
|
loadedBoard->GetDesignSettings().m_CopperEdgeClearance = edgeClearance;
|
2020-11-19 13:25:30 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 00:16:21 +00:00
|
|
|
// On save; design settings will be removed from the board
|
2020-05-31 21:42:04 +00:00
|
|
|
loadedBoard->SetModified();
|
2020-11-18 00:16:21 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
// Move legacy view settings to local project settings
|
|
|
|
if( !loadedBoard->m_LegacyVisibleLayers.test( Rescue ) )
|
2019-07-03 21:19:09 +00:00
|
|
|
{
|
2020-05-31 21:42:04 +00:00
|
|
|
Prj().GetLocalSettings().m_VisibleLayers = loadedBoard->m_LegacyVisibleLayers;
|
|
|
|
loadedBoard->SetModified();
|
2019-07-03 21:19:09 +00:00
|
|
|
}
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
if( !loadedBoard->m_LegacyVisibleItems.test( GAL_LAYER_INDEX( GAL_LAYER_ID_BITMASK_END ) ) )
|
|
|
|
{
|
|
|
|
Prj().GetLocalSettings().m_VisibleItems = loadedBoard->m_LegacyVisibleItems;
|
|
|
|
loadedBoard->SetModified();
|
|
|
|
}
|
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
|
|
|
|
2011-12-15 02:24:52 +00:00
|
|
|
// we should not ask PLUGINs to do these items:
|
|
|
|
loadedBoard->BuildListOfNets();
|
2023-04-15 09:54:53 +00:00
|
|
|
ResolveDRCExclusions( true );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->RunAction( PCB_ACTIONS::repairBoard, true);
|
2011-12-15 02:24:52 +00:00
|
|
|
|
2019-04-10 09:19:16 +00:00
|
|
|
if( loadedBoard->IsModified() )
|
|
|
|
OnModify();
|
|
|
|
else
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified( false );
|
2011-01-20 16:34:57 +00:00
|
|
|
|
2021-06-08 21:11:48 +00:00
|
|
|
if( ( pluginType == IO_MGR::LEGACY )
|
|
|
|
|| ( pluginType == IO_MGR::KICAD_SEXP
|
|
|
|
&& loadedBoard->GetFileFormatVersionAtLoad() < SEXPR_BOARD_FILE_VERSION
|
2022-02-04 22:44:59 +00:00
|
|
|
&& loadedBoard->GetGenerator().Lower() != wxT( "gerbview" ) ) )
|
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
|
|
|
{
|
2020-12-28 00:17:58 +00:00
|
|
|
m_infoBar->RemoveAllButtons();
|
|
|
|
m_infoBar->AddCloseButton();
|
|
|
|
m_infoBar->ShowMessage( _( "This file was created by an older version of KiCad. "
|
|
|
|
"It will be converted to the new format when saved." ),
|
2021-02-16 23:42:39 +00:00
|
|
|
wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE );
|
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
|
|
|
}
|
2021-01-31 21:55:51 +00:00
|
|
|
|
|
|
|
// Import footprints into a project-specific library
|
|
|
|
//==================================================
|
|
|
|
// TODO: This should be refactored out of here into somewhere specific to the Project Import
|
|
|
|
// E.g. KICAD_MANAGER_FRAME::ImportNonKiCadProject
|
|
|
|
if( aCtl & KICTL_IMPORT_LIB )
|
|
|
|
{
|
|
|
|
wxFileName loadedBoardFn( fullFileName );
|
|
|
|
wxString libNickName = loadedBoardFn.GetName();
|
|
|
|
|
|
|
|
// Extract a footprint library from the design and add it to the fp-lib-table
|
|
|
|
// The footprints are saved in a new .pretty library.
|
|
|
|
// If this library already exists, all previous footprints will be deleted
|
|
|
|
std::vector<FOOTPRINT*> loadedFootprints = pi->GetImportedCachedLibraryFootprints();
|
2021-06-18 10:38:08 +00:00
|
|
|
wxString newLibPath = CreateNewProjectLibrary( libNickName );
|
2021-01-31 21:55:51 +00:00
|
|
|
|
|
|
|
// Only create the new library if CreateNewLibrary succeeded (note that this fails if
|
|
|
|
// the library already exists and the user aborts after seeing the warning message
|
|
|
|
// which prompts the user to continue with overwrite or abort)
|
|
|
|
if( newLibPath.Length() > 0 )
|
|
|
|
{
|
|
|
|
PLUGIN::RELEASER piSexpr( IO_MGR::PluginFind( IO_MGR::KICAD_SEXP ) );
|
|
|
|
|
|
|
|
for( FOOTPRINT* footprint : loadedFootprints )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if( !footprint->GetFPID().GetLibItemName().empty() ) // Handle old boards.
|
|
|
|
{
|
|
|
|
footprint->SetReference( "REF**" );
|
|
|
|
piSexpr->FootprintSave( newLibPath, footprint );
|
|
|
|
delete footprint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2021-06-26 19:17:34 +00:00
|
|
|
wxLogError( _( "Error saving footprint %s to project specific library." )
|
|
|
|
+ wxS( "\n%s" ),
|
|
|
|
footprint->GetFPID().GetUniStringLibItemName(),
|
|
|
|
ioe.What() );
|
2021-01-31 21:55:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-28 03:15:54 +00:00
|
|
|
FP_LIB_TABLE* prjlibtable = PROJECT_PCB::PcbFootprintLibs( &Prj() );
|
2021-01-31 21:55:51 +00:00
|
|
|
const wxString& project_env = PROJECT_VAR_NAME;
|
|
|
|
wxString rel_path, env_path;
|
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
wxASSERT_MSG( wxGetEnv( project_env, &env_path ),
|
|
|
|
wxT( "There is no project variable?" ) );
|
2021-01-31 21:55:51 +00:00
|
|
|
|
|
|
|
wxString result( newLibPath );
|
2022-02-11 21:38:31 +00:00
|
|
|
|
|
|
|
if( result.Replace( env_path, wxT( "$(" ) + project_env + wxT( ")" ) ) )
|
|
|
|
rel_path = result;
|
2021-01-31 21:55:51 +00:00
|
|
|
|
|
|
|
FP_LIB_TABLE_ROW* row = new FP_LIB_TABLE_ROW( libNickName, rel_path,
|
|
|
|
wxT( "KiCad" ), wxEmptyString );
|
|
|
|
prjlibtable->InsertRow( row );
|
|
|
|
|
|
|
|
wxString tblName = Prj().FootprintLibTblName();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2023-09-28 03:15:54 +00:00
|
|
|
PROJECT_PCB::PcbFootprintLibs( &Prj() )->Save( tblName );
|
2021-01-31 21:55:51 +00:00
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2021-06-26 19:17:34 +00:00
|
|
|
wxLogError( _( "Error saving project specific footprint library table." )
|
|
|
|
+ wxS( "\n%s" ),
|
|
|
|
ioe.What() );
|
2021-01-31 21:55:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update footprint LIB_IDs to point to the just imported library
|
|
|
|
for( FOOTPRINT* footprint : GetBoard()->Footprints() )
|
|
|
|
{
|
|
|
|
LIB_ID libId = footprint->GetFPID();
|
|
|
|
|
|
|
|
if( libId.GetLibItemName().empty() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
libId.SetLibNickname( libNickName );
|
|
|
|
footprint->SetFPID( libId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-06 02:02:39 +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
|
|
|
{
|
|
|
|
wxFileName fn = fullFileName;
|
2012-12-29 09:54:25 +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
|
|
|
if( converted )
|
|
|
|
fn.SetExt( PcbFileExtension );
|
2012-12-29 09:54:25 +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
|
|
|
wxString fname = fn.GetFullPath();
|
2012-12-29 09:54:25 +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
|
|
|
fname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
|
|
|
|
|
|
|
GetBoard()->SetFileName( fname );
|
|
|
|
}
|
2008-07-22 05:29:16 +00:00
|
|
|
|
2019-05-19 09:03:44 +00:00
|
|
|
// Lock the file newly opened:
|
2023-05-24 20:19:48 +00:00
|
|
|
m_file_checker.reset( lock.release() );
|
2019-05-19 09:03:44 +00:00
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
if( !converted )
|
|
|
|
UpdateFileHistory( GetBoard()->GetFileName() );
|
2008-07-22 05:29:16 +00:00
|
|
|
|
2022-02-11 21:38:31 +00:00
|
|
|
std::vector<ZONE*> toFill;
|
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// Rebuild list of nets (full ratsnest rebuild)
|
2021-11-25 16:19:03 +00:00
|
|
|
GetBoard()->BuildConnectivity( &progressReporter );
|
2016-07-05 15:01:41 +00:00
|
|
|
|
2020-07-09 01:59:34 +00:00
|
|
|
// Load project settings after setting up board; some of them depend on the nets list
|
|
|
|
LoadProjectSettings();
|
|
|
|
|
2020-08-24 23:38:34 +00:00
|
|
|
// Syncs the UI (appearance panel, etc) with the loaded board and project
|
|
|
|
onBoardLoaded();
|
|
|
|
|
2010-05-01 13:32:25 +00:00
|
|
|
// Refresh the 3D view, if any
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
|
2019-06-04 15:26:45 +00:00
|
|
|
|
|
|
|
if( draw3DFrame )
|
|
|
|
draw3DFrame->NewDisplay();
|
2008-04-18 13:28:56 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2007-10-31 06:40:15 +00:00
|
|
|
// Output the board object tree to stdout, but please run from command prompt:
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Show( 0, std::cout );
|
2007-08-06 02:02:39 +00:00
|
|
|
#endif
|
2008-04-18 13:28:56 +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
|
|
|
// from EDA_APPL which was first loaded BOARD only:
|
|
|
|
{
|
|
|
|
/* For an obscure reason the focus is lost after loading a board file
|
|
|
|
* when starting up the process.
|
|
|
|
* (seems due to the recreation of the layer manager after loading the file)
|
|
|
|
* Give focus to main window and Drawpanel
|
|
|
|
* must be done for these 2 windows (for an obscure reason ...)
|
|
|
|
* Linux specific
|
|
|
|
* This is more a workaround than a fix.
|
|
|
|
*/
|
|
|
|
SetFocus();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetFocus();
|
* 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
|
|
|
}
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-05 15:02:48 +00:00
|
|
|
bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
|
|
|
|
bool aChangeProject )
|
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
|
|
|
{
|
|
|
|
// please, keep it simple. prompting goes elsewhere.
|
2020-06-19 23:31:26 +00:00
|
|
|
wxFileName pcbFileName = aFileName;
|
2013-10-13 16:29:20 +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
|
|
|
if( pcbFileName.GetExt() == LegacyPcbFileExtension )
|
|
|
|
pcbFileName.SetExt( KiCadPcbFileExtension );
|
2014-07-07 04:12:04 +00:00
|
|
|
|
2021-06-06 12:15:57 +00:00
|
|
|
// Write through symlinks, don't replace them
|
2021-06-07 19:12:30 +00:00
|
|
|
WX_FILENAME::ResolvePossibleSymlinks( pcbFileName );
|
2021-06-06 12:15:57 +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
|
|
|
if( !IsWritable( pcbFileName ) )
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
wxString msg = wxString::Format( _( "Insufficient permissions to write file '%s'." ),
|
2021-04-01 10:04:59 +00:00
|
|
|
pcbFileName.GetFullPath() );
|
2007-08-06 02:02:39 +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
|
|
|
DisplayError( this, msg );
|
|
|
|
return false;
|
2012-12-14 16:54:54 +00:00
|
|
|
}
|
2012-11-19 16:19:38 +00:00
|
|
|
|
2021-04-15 09:23:02 +00:00
|
|
|
// TODO: these will break if we ever go multi-board
|
2020-05-31 21:42:04 +00:00
|
|
|
wxFileName projectFile( pcbFileName );
|
2021-04-15 09:23:02 +00:00
|
|
|
wxFileName rulesFile( pcbFileName );
|
|
|
|
wxString msg;
|
2020-08-19 18:21:24 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
projectFile.SetExt( ProjectFileExtension );
|
2021-04-15 09:23:02 +00:00
|
|
|
rulesFile.SetExt( DesignRulesFileExtension );
|
2020-05-31 21:42:04 +00:00
|
|
|
|
2023-06-26 15:48:56 +00:00
|
|
|
if( projectFile.FileExists() )
|
|
|
|
{
|
|
|
|
GetSettingsManager()->SaveProject();
|
|
|
|
}
|
|
|
|
else if( aChangeProject )
|
2021-04-22 01:27:23 +00:00
|
|
|
{
|
|
|
|
Prj().SetReadOnly( false );
|
2021-04-13 16:41:23 +00:00
|
|
|
GetSettingsManager()->SaveProjectAs( projectFile.GetFullPath() );
|
2021-04-22 01:27:23 +00:00
|
|
|
}
|
2020-08-19 18:21:24 +00:00
|
|
|
|
2021-04-16 00:43:35 +00:00
|
|
|
wxFileName currentRules( GetDesignRulesPath() );
|
|
|
|
|
|
|
|
if( currentRules.FileExists() && !rulesFile.FileExists() && aChangeProject )
|
|
|
|
KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
|
2021-04-15 09:23:02 +00:00
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxString::Format( _( "Error saving custom rules file '%s'." ),
|
|
|
|
rulesFile.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
2021-04-13 16:41:23 +00:00
|
|
|
if( projectFile.FileExists() )
|
|
|
|
{
|
|
|
|
// Save various DRC parameters, such as violation severities (which may have been
|
|
|
|
// edited via the DRC dialog as well as the Board Setup dialog), DRC exclusions, etc.
|
2023-03-04 19:25:07 +00:00
|
|
|
saveProjectSettings();
|
2020-05-31 21:42:04 +00:00
|
|
|
|
2020-08-19 18:21:24 +00:00
|
|
|
GetBoard()->SynchronizeProperties();
|
2022-11-22 14:24:20 +00:00
|
|
|
GetBoard()->SynchronizeNetsAndNetClasses( false );
|
2021-04-13 16:41:23 +00:00
|
|
|
}
|
2020-08-19 18:21:24 +00:00
|
|
|
|
2023-01-22 14:41:33 +00:00
|
|
|
wxString tempFile = wxFileName::CreateTempFileName( wxS( "pcbnew" ) );
|
2021-04-13 16:41:23 +00:00
|
|
|
wxString upperTxt;
|
|
|
|
wxString lowerTxt;
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
try
|
|
|
|
{
|
2017-10-03 10:23:52 +00:00
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::KICAD_SEXP ) );
|
2012-04-07 18:05:56 +00:00
|
|
|
|
2023-08-13 02:11:58 +00:00
|
|
|
pi->SaveBoard( tempFile, GetBoard(), nullptr );
|
2011-12-14 17:25:42 +00:00
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2011-12-14 17:25:42 +00:00
|
|
|
{
|
2021-04-15 09:23:02 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Error saving board file '%s'.\n%s" ),
|
|
|
|
pcbFileName.GetFullPath(),
|
|
|
|
ioe.What() ) );
|
2011-12-14 17:25:42 +00:00
|
|
|
|
2022-03-08 04:08:54 +00:00
|
|
|
lowerTxt.Printf( _( "Failed to create temporary file '%s'." ), tempFile );
|
2020-06-19 23:31:26 +00:00
|
|
|
|
2020-12-08 05:27:34 +00:00
|
|
|
SetMsgPanel( upperTxt, lowerTxt );
|
2020-06-19 23:31:26 +00:00
|
|
|
|
|
|
|
// In case we started a file but didn't fully write it, clean up
|
2022-03-08 04:08:54 +00:00
|
|
|
wxRemoveFile( tempFile );
|
2020-06-19 23:31:26 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-05-25 00:07:46 +00:00
|
|
|
// Preserve the permissions of the current file
|
|
|
|
KIPLATFORM::IO::DuplicatePermissions( pcbFileName.GetFullPath(), tempFile );
|
|
|
|
|
2020-06-19 23:31:26 +00:00
|
|
|
// If save succeeded, replace the original with what we just wrote
|
2022-03-08 04:08:54 +00:00
|
|
|
if( !wxRenameFile( tempFile, pcbFileName.GetFullPath() ) )
|
2020-06-19 23:31:26 +00:00
|
|
|
{
|
2021-06-16 22:35:00 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Error saving board file '%s'.\n"
|
|
|
|
"Failed to rename temporary file '%s." ),
|
2021-04-15 09:23:02 +00:00
|
|
|
pcbFileName.GetFullPath(),
|
2022-03-08 04:08:54 +00:00
|
|
|
tempFile ) );
|
2020-06-19 23:31:26 +00:00
|
|
|
|
2021-06-16 22:35:00 +00:00
|
|
|
lowerTxt.Printf( _( "Failed to rename temporary file '%s'." ),
|
2022-03-08 04:08:54 +00:00
|
|
|
tempFile );
|
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
|
|
|
|
2020-12-08 05:27:34 +00:00
|
|
|
SetMsgPanel( upperTxt, lowerTxt );
|
2012-12-27 16:42:41 +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
|
|
|
return false;
|
2011-12-15 02:24:52 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 15:42:05 +00:00
|
|
|
if( !Kiface().IsSingle() )
|
|
|
|
{
|
|
|
|
WX_STRING_REPORTER backupReporter( &upperTxt );
|
2020-07-03 13:40:31 +00:00
|
|
|
|
2020-07-12 15:42:05 +00:00
|
|
|
if( GetSettingsManager()->TriggerBackupIfNeeded( backupReporter ) )
|
|
|
|
upperTxt.clear();
|
|
|
|
}
|
2020-07-03 13:40:31 +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
|
|
|
GetBoard()->SetFileName( pcbFileName.GetFullPath() );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2021-04-06 11:40:44 +00:00
|
|
|
// Update the lock in case it was a Save As
|
|
|
|
LockFile( pcbFileName.GetFullPath() );
|
|
|
|
|
2020-06-20 01:06:52 +00:00
|
|
|
// Put the saved file in File History if requested
|
|
|
|
if( addToHistory )
|
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
|
|
|
UpdateFileHistory( GetBoard()->GetFileName() );
|
* 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
|
|
|
// Delete auto save file on successful save.
|
|
|
|
wxFileName autoSaveFileName = pcbFileName;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2019-03-18 12:22:33 +00:00
|
|
|
autoSaveFileName.SetName( GetAutoSaveFilePrefix() + pcbFileName.GetName() );
|
2011-10-13 19:56:32 +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
|
|
|
if( autoSaveFileName.FileExists() )
|
|
|
|
wxRemoveFile( autoSaveFileName.GetFullPath() );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2021-04-01 10:04:59 +00:00
|
|
|
lowerTxt.Printf( _( "File '%s' saved." ), pcbFileName.GetFullPath() );
|
2007-08-06 02:02:39 +00:00
|
|
|
|
2020-12-08 05:27:34 +00:00
|
|
|
SetStatusText( lowerTxt, 0 );
|
2008-04-18 13:28:56 +00:00
|
|
|
|
2021-01-13 04:24:05 +00:00
|
|
|
// Get rid of the old version conversion warning, or any other dismissable warning :)
|
2021-08-01 20:51:08 +00:00
|
|
|
if( m_infoBar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE )
|
|
|
|
m_infoBar->Dismiss();
|
2021-02-16 23:42:39 +00:00
|
|
|
|
2021-08-19 21:28:54 +00:00
|
|
|
if( m_infoBar->IsShownOnScreen() && m_infoBar->HasCloseButton() )
|
2021-01-13 04:24:05 +00:00
|
|
|
m_infoBar->Dismiss();
|
|
|
|
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified( false );
|
2021-02-20 14:36:28 +00:00
|
|
|
UpdateTitle();
|
2009-09-22 12:27:57 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2011-10-13 19:56:32 +00:00
|
|
|
|
|
|
|
|
2020-09-22 00:00:51 +00:00
|
|
|
bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject )
|
2015-02-14 12:43:11 +00:00
|
|
|
{
|
2023-03-12 14:49:57 +00:00
|
|
|
wxFileName pcbFileName( EnsureFileExtension( aFileName, KiCadPcbFileExtension ) );
|
2015-02-14 12:43:11 +00:00
|
|
|
|
|
|
|
if( !IsWritable( pcbFileName ) )
|
|
|
|
{
|
2021-06-27 13:24:02 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Insufficient permissions to write file '%s'." ),
|
2021-04-15 09:23:02 +00:00
|
|
|
pcbFileName.GetFullPath() ) );
|
2015-02-14 12:43:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-04-13 16:41:23 +00:00
|
|
|
// Save various DRC parameters, such as violation severities (which may have been
|
|
|
|
// edited via the DRC dialog as well as the Board Setup dialog), DRC exclusions, etc.
|
2023-03-04 19:25:07 +00:00
|
|
|
SaveProjectLocalSettings();
|
2021-04-13 16:41:23 +00:00
|
|
|
|
2022-11-22 14:24:20 +00:00
|
|
|
GetBoard()->SynchronizeNetsAndNetClasses( false );
|
2015-02-14 12:43:11 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2017-10-03 10:23:52 +00:00
|
|
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::KICAD_SEXP ) );
|
2015-02-14 12:43:11 +00:00
|
|
|
|
|
|
|
wxASSERT( pcbFileName.IsAbsolute() );
|
|
|
|
|
2023-08-13 02:11:58 +00:00
|
|
|
pi->SaveBoard( pcbFileName.GetFullPath(), GetBoard(), nullptr );
|
2015-02-14 12:43:11 +00:00
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2021-04-15 09:23:02 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Error saving board file '%s'.\n%s" ),
|
|
|
|
pcbFileName.GetFullPath(),
|
|
|
|
ioe.What() ) );
|
2015-02-14 12:43:11 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-04-13 16:41:23 +00:00
|
|
|
wxFileName projectFile( pcbFileName );
|
2021-04-15 09:23:02 +00:00
|
|
|
wxFileName rulesFile( pcbFileName );
|
|
|
|
wxString msg;
|
2020-09-22 00:00:51 +00:00
|
|
|
|
2021-04-13 16:41:23 +00:00
|
|
|
projectFile.SetExt( ProjectFileExtension );
|
2021-04-15 09:23:02 +00:00
|
|
|
rulesFile.SetExt( DesignRulesFileExtension );
|
2020-09-22 00:00:51 +00:00
|
|
|
|
2021-04-13 16:41:23 +00:00
|
|
|
if( aCreateProject && !projectFile.FileExists() )
|
|
|
|
GetSettingsManager()->SaveProjectCopy( projectFile.GetFullPath() );
|
2020-09-22 00:00:51 +00:00
|
|
|
|
2021-04-16 00:43:35 +00:00
|
|
|
wxFileName currentRules( GetDesignRulesPath() );
|
|
|
|
|
|
|
|
if( aCreateProject && currentRules.FileExists() && !rulesFile.FileExists() )
|
2021-04-16 00:45:32 +00:00
|
|
|
KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
|
2021-04-15 09:23:02 +00:00
|
|
|
|
|
|
|
if( !msg.IsEmpty() )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxString::Format( _( "Error saving custom rules file '%s'." ),
|
|
|
|
rulesFile.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
2021-09-05 19:13:20 +00:00
|
|
|
DisplayInfoMessage( this, wxString::Format( _( "Board copied to:\n%s" ),
|
2020-05-25 10:06:27 +00:00
|
|
|
pcbFileName.GetFullPath() ) );
|
2015-02-14 12:43:11 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
bool PCB_EDIT_FRAME::doAutoSave()
|
|
|
|
{
|
2016-08-11 19:13:47 +00:00
|
|
|
wxFileName tmpFileName;
|
|
|
|
|
2021-05-27 23:07:48 +00:00
|
|
|
// Don't run autosave if content has not been modified
|
|
|
|
if( !IsContentModified() )
|
|
|
|
return true;
|
|
|
|
|
2021-05-19 15:27:56 +00:00
|
|
|
wxString title = GetTitle(); // Save frame title, that can be modified by the save process
|
|
|
|
|
2016-08-11 19:13:47 +00:00
|
|
|
if( GetBoard()->GetFileName().IsEmpty() )
|
|
|
|
{
|
2021-05-27 23:39:41 +00:00
|
|
|
tmpFileName = wxFileName( PATHS::GetDefaultUserProjectsPath(), NAMELESS_PROJECT,
|
2016-08-11 19:13:47 +00:00
|
|
|
KiCadPcbFileExtension );
|
|
|
|
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
|
|
|
}
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2016-08-11 19:13:47 +00:00
|
|
|
wxFileName autoSaveFileName = tmpFileName;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2016-08-11 19:13:47 +00:00
|
|
|
// Auto save file name is the board file name prepended with autosaveFilePrefix string.
|
2019-03-18 12:22:33 +00:00
|
|
|
autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() );
|
2011-10-15 13:25:57 +00:00
|
|
|
|
2016-08-11 19:13:47 +00:00
|
|
|
if( !autoSaveFileName.IsOk() )
|
2015-06-19 13:27:06 +00:00
|
|
|
return false;
|
2016-08-11 19:13:47 +00:00
|
|
|
|
|
|
|
// If the board file path is not writable, try writing to a platform specific temp file
|
2021-01-27 22:15:38 +00:00
|
|
|
// path. If that path isn't writable, give up.
|
2016-08-11 19:13:47 +00:00
|
|
|
if( !autoSaveFileName.IsDirWritable() )
|
|
|
|
{
|
|
|
|
autoSaveFileName.SetPath( wxFileName::GetTempDir() );
|
|
|
|
|
|
|
|
if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
wxLogTrace( traceAutoSave,
|
|
|
|
wxT( "Creating auto save file <" ) + autoSaveFileName.GetFullPath() + wxT( ">" ) );
|
2016-08-11 19:13:47 +00:00
|
|
|
|
2020-07-05 15:02:48 +00:00
|
|
|
if( SavePcbFile( autoSaveFileName.GetFullPath(), false, false ) )
|
2011-10-13 19:56:32 +00:00
|
|
|
{
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified();
|
2012-08-29 16:59:50 +00:00
|
|
|
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
|
2011-10-13 19:56:32 +00:00
|
|
|
UpdateTitle();
|
2022-10-10 13:03:10 +00:00
|
|
|
m_autoSaveRequired = false;
|
2022-10-10 11:04:19 +00:00
|
|
|
m_autoSavePending = false;
|
2020-07-03 13:40:31 +00:00
|
|
|
|
2020-07-12 15:42:05 +00:00
|
|
|
if( !Kiface().IsSingle() &&
|
|
|
|
GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
|
|
|
|
{
|
2020-07-03 13:40:31 +00:00
|
|
|
GetSettingsManager()->TriggerBackupIfNeeded( NULL_REPORTER::GetInstance() );
|
2020-07-12 15:42:05 +00:00
|
|
|
}
|
2020-07-03 13:40:31 +00:00
|
|
|
|
2021-05-19 15:27:56 +00:00
|
|
|
SetTitle( title ); // Restore initial frame title
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-29 16:59:50 +00:00
|
|
|
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2021-05-19 15:27:56 +00:00
|
|
|
SetTitle( title ); // Restore initial frame title
|
|
|
|
|
2011-10-13 19:56:32 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-08-24 15:56:15 +00:00
|
|
|
|
2017-10-03 10:23:52 +00:00
|
|
|
|
2018-02-26 10:34:36 +00:00
|
|
|
bool PCB_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
2017-08-24 15:56:15 +00:00
|
|
|
{
|
2017-10-03 10:23:52 +00:00
|
|
|
switch( (IO_MGR::PCB_FILE_T) aFileType )
|
2017-08-24 15:56:15 +00:00
|
|
|
{
|
2020-09-27 17:12:32 +00:00
|
|
|
case IO_MGR::CADSTAR_PCB_ARCHIVE:
|
2017-10-03 10:23:52 +00:00
|
|
|
case IO_MGR::EAGLE:
|
2023-09-06 11:58:39 +00:00
|
|
|
case IO_MGR::EASYEDA:
|
|
|
|
case IO_MGR::EASYEDAPRO:
|
2021-01-31 21:55:51 +00:00
|
|
|
return OpenProjectFiles( std::vector<wxString>( 1, aFileName ),
|
2023-08-13 02:26:06 +00:00
|
|
|
KICTL_NONKICAD_ONLY | KICTL_IMPORT_LIB );
|
2017-08-26 12:04:56 +00:00
|
|
|
|
2023-08-13 02:26:06 +00:00
|
|
|
default: break;
|
2017-08-24 15:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-19 11:25:48 +00:00
|
|
|
|