2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-01 07:19:31 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2017-11-12 00:31:38 +00:00
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
2019-04-12 12:17:55 +00:00
|
|
|
* Copyright (C) 1992-2019 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
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <macros.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_design_settings.h>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
#include <panel_hotkeys_editor.h>
|
2020-06-17 20:45:03 +00:00
|
|
|
#include <panel_edit_options.h>
|
2020-04-24 01:55:20 +00:00
|
|
|
#include <panel_pcbnew_color_settings.h>
|
2020-06-17 20:45:03 +00:00
|
|
|
#include <panel_display_options.h>
|
2018-08-15 09:26:32 +00:00
|
|
|
#include <panel_pcbnew_action_plugins.h>
|
2020-07-07 01:53:12 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/selection_tool.h>
|
2012-10-15 22:30:01 +00:00
|
|
|
#include <fp_lib_table.h>
|
2019-05-25 11:05:39 +00:00
|
|
|
#include <ws_data_model.h>
|
2013-05-20 14:49:20 +00:00
|
|
|
#include <class_board.h>
|
2014-07-21 10:54:58 +00:00
|
|
|
#include <class_module.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.h>
|
2020-07-08 02:21:45 +00:00
|
|
|
#include <pcb_painter.h>
|
2018-01-31 12:37:36 +00:00
|
|
|
#include <footprint_viewer_frame.h>
|
2013-10-13 21:33:58 +00:00
|
|
|
#include <invoke_pcb_dialog.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-07-11 17:42:00 +00:00
|
|
|
#include <widgets/appearance_controls.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <widgets/paged_dialog.h>
|
2020-07-07 01:53:12 +00:00
|
|
|
#include <widgets/panel_selection_filter.h>
|
2020-07-08 02:21:45 +00:00
|
|
|
#include <project/net_settings.h>
|
2020-05-31 21:42:04 +00:00
|
|
|
#include <project/project_file.h>
|
2020-07-07 01:53:12 +00:00
|
|
|
#include <project/project_local_settings.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
void PCB_EDIT_FRAME::On3DShapeLibWizard( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2015-08-20 07:14:44 +00:00
|
|
|
#ifdef BUILD_GITHUB_PLUGIN
|
2019-06-09 21:57:23 +00:00
|
|
|
Invoke3DShapeLibsDownloaderWizard( this );
|
2015-08-20 07:14:44 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
|
|
|
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2020-07-20 13:45:46 +00:00
|
|
|
PAGED_TREEBOOK* book = aParent->GetTreebook();
|
2018-07-15 23:15:48 +00:00
|
|
|
|
2020-07-20 13:45:46 +00:00
|
|
|
book->AddGroupEntry( _( "Pcbnew" ) );
|
2020-06-17 20:45:03 +00:00
|
|
|
book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
|
|
|
|
book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) );
|
2020-08-11 02:01:04 +00:00
|
|
|
book->AddSubPage( new PANEL_PCBNEW_COLOR_SETTINGS( this, book ), _( "Colors" ) );
|
2018-08-15 09:26:32 +00:00
|
|
|
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
|
|
|
|
book->AddSubPage( new PANEL_PCBNEW_ACTION_PLUGINS( this, aParent ), _( "Action Plugins" ) );
|
|
|
|
#endif
|
2019-11-08 08:42:33 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
aHotkeysPanel->AddHotKeys( GetToolManager() );
|
2018-05-14 17:34:18 +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 PCB_EDIT_FRAME::LoadProjectSettings()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-10-02 09:55:06 +00:00
|
|
|
wxLogDebug( wxT( "Loading project '%s' settings." ), GetChars( Prj().GetProjectFullName() ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
PROJECT_FILE& project = Prj().GetProjectFile();
|
|
|
|
PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
|
2020-05-31 21:42:04 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
BASE_SCREEN::m_PageLayoutDescrFileName = project.m_BoardPageLayoutDescrFile;
|
2013-10-13 16:29:20 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Load the page layout decr file, from the filename stored in
|
|
|
|
// BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
|
2014-12-31 12:31:19 +00:00
|
|
|
// If empty, or not existing, the default descr is loaded
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
wxString filename = WS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName,
|
|
|
|
Prj().GetProjectPath() );
|
2014-12-23 13:01:59 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
pglayout.SetPageLayout( filename );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Load render settings that aren't stored in PCB_DISPLAY_OPTIONS
|
|
|
|
|
|
|
|
NET_SETTINGS& netSettings = project.NetSettings();
|
|
|
|
NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
|
|
|
|
2020-07-08 02:21:45 +00:00
|
|
|
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
|
|
|
|
GetCanvas()->GetView()->GetPainter()->GetSettings() );
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
std::set<int>& hiddenNets = rs->GetHiddenNets();
|
|
|
|
hiddenNets.clear();
|
2020-07-08 02:21:45 +00:00
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
for( const wxString& hidden : localSettings.m_HiddenNets )
|
|
|
|
{
|
|
|
|
if( NETINFO_ITEM* net = nets.GetNetItem( hidden ) )
|
|
|
|
hiddenNets.insert( net->GetNet() );
|
|
|
|
}
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
std::map<int, KIGFX::COLOR4D>& netColors = rs->GetNetColorMap();
|
|
|
|
netColors.clear();
|
|
|
|
|
|
|
|
for( const auto& pair : netSettings.m_PcbNetColors )
|
|
|
|
{
|
2020-08-15 22:49:56 +00:00
|
|
|
if( pair.second == COLOR4D::UNSPECIFIED )
|
|
|
|
continue;
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
if( NETINFO_ITEM* net = nets.GetNetItem( pair.first ) )
|
|
|
|
netColors[net->GetNet()] = pair.second;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
|
|
|
|
netclassColors.clear();
|
|
|
|
|
|
|
|
for( const auto& pair : netSettings.m_NetClasses )
|
|
|
|
{
|
|
|
|
if( pair.second->GetPcbColor() != COLOR4D::UNSPECIFIED )
|
|
|
|
netclassColors[pair.first] = pair.second->GetPcbColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_appearancePanel->SetUserLayerPresets( project.m_LayerPresets );
|
|
|
|
m_appearancePanel->ApplyLayerPreset( localSettings.m_ActiveLayerPreset );
|
2020-07-07 01:53:12 +00:00
|
|
|
|
|
|
|
SELECTION_FILTER_OPTIONS& filterOpts = GetToolManager()->GetTool<SELECTION_TOOL>()->GetFilter();
|
|
|
|
|
|
|
|
filterOpts = localSettings.m_SelectionFilter;
|
|
|
|
m_selectionFilterPanel->SetCheckboxesFromFilter( filterOpts );
|
|
|
|
|
2020-07-11 17:40:23 +00:00
|
|
|
PCB_DISPLAY_OPTIONS opts = GetDisplayOptions();
|
|
|
|
opts.m_ContrastModeDisplay = localSettings.m_ContrastModeDisplay;
|
2020-07-11 17:42:00 +00:00
|
|
|
opts.m_NetColorMode = localSettings.m_NetColorMode;
|
|
|
|
opts.m_TrackOpacity = localSettings.m_TrackOpacity;
|
|
|
|
opts.m_ViaOpacity = localSettings.m_ViaOpacity;
|
|
|
|
opts.m_PadOpacity = localSettings.m_PadOpacity;
|
|
|
|
opts.m_ZoneOpacity = localSettings.m_ZoneOpacity;
|
2020-07-11 17:40:23 +00:00
|
|
|
SetDisplayOptions( opts );
|
|
|
|
|
|
|
|
SetActiveLayer( localSettings.m_ActiveLayer );
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
void PCB_EDIT_FRAME::SaveProjectSettings()
|
2007-06-05 12:10: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
|
|
|
wxFileName fn = Prj().GetProjectFullName();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-03-04 17:40:28 +00:00
|
|
|
// Check for the filename before checking IsWritable as this
|
|
|
|
// will throw errors on bad names. Here, we just want to not
|
|
|
|
// save the Settings if we don't have a name
|
|
|
|
if( !fn.IsOk() )
|
|
|
|
return;
|
|
|
|
|
2020-07-17 02:56:02 +00:00
|
|
|
if( !fn.IsDirWritable() )
|
2020-02-28 00:05:40 +00:00
|
|
|
return;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
PROJECT_FILE& project = Prj().GetProjectFile();
|
|
|
|
PROJECT_LOCAL_SETTINGS& localSettings = Prj().GetLocalSettings();
|
2010-04-23 14:46:00 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
// TODO: Can this be pulled out of BASE_SCREEN?
|
2020-06-08 02:19:46 +00:00
|
|
|
project.m_BoardPageLayoutDescrFile = BASE_SCREEN::m_PageLayoutDescrFileName;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
project.m_LayerPresets = m_appearancePanel->GetUserLayerPresets();
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
RecordDRCExclusions();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Save appearance control settings
|
2020-07-11 17:40:23 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
localSettings.m_ActiveLayer = GetActiveLayer();
|
|
|
|
localSettings.m_ActiveLayerPreset = m_appearancePanel->GetActiveLayerPreset();
|
|
|
|
|
|
|
|
const PCB_DISPLAY_OPTIONS& displayOpts = GetDisplayOptions();
|
|
|
|
|
|
|
|
localSettings.m_ContrastModeDisplay = displayOpts.m_ContrastModeDisplay;
|
|
|
|
localSettings.m_NetColorMode = displayOpts.m_NetColorMode;
|
|
|
|
localSettings.m_TrackOpacity = displayOpts.m_TrackOpacity;
|
|
|
|
localSettings.m_ViaOpacity = displayOpts.m_ViaOpacity;
|
|
|
|
localSettings.m_PadOpacity = displayOpts.m_PadOpacity;
|
|
|
|
localSettings.m_ZoneOpacity = displayOpts.m_ZoneOpacity;
|
|
|
|
localSettings.m_ZoneDisplayMode = displayOpts.m_ZoneDisplayMode;
|
|
|
|
|
|
|
|
// Save render settings that aren't stored in PCB_DISPLAY_OPTIONS
|
2020-07-11 17:40:23 +00:00
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
KIGFX::PCB_RENDER_SETTINGS* rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
|
|
|
|
GetCanvas()->GetView()->GetPainter()->GetSettings() );
|
2020-07-07 01:53:12 +00:00
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
NETINFO_LIST& nets = GetBoard()->GetNetInfo();
|
|
|
|
|
|
|
|
localSettings.m_HiddenNets.clear();
|
2020-07-07 01:53:12 +00:00
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
for( int netcode : rs->GetHiddenNets() )
|
|
|
|
{
|
|
|
|
if( NETINFO_ITEM* net = nets.GetNetItem( netcode ) )
|
|
|
|
localSettings.m_HiddenNets.emplace_back( net->GetNetname() );
|
|
|
|
}
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
NET_SETTINGS& netSettings = project.NetSettings();
|
|
|
|
|
|
|
|
netSettings.m_PcbNetColors.clear();
|
|
|
|
|
|
|
|
for( const auto& pair : rs->GetNetColorMap() )
|
|
|
|
{
|
2020-08-15 22:49:56 +00:00
|
|
|
if( pair.second == COLOR4D::UNSPECIFIED )
|
|
|
|
continue;
|
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
if( NETINFO_ITEM* net = nets.GetNetItem( pair.first ) )
|
|
|
|
netSettings.m_PcbNetColors[net->GetNetname()] = pair.second;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<wxString, KIGFX::COLOR4D>& netclassColors = rs->GetNetclassColorMap();
|
|
|
|
|
|
|
|
// NOTE: this assumes netclasses will have already been updated, which I think is the case
|
|
|
|
for( const auto& pair : netSettings.m_NetClasses )
|
|
|
|
{
|
2020-08-15 22:49:56 +00:00
|
|
|
if( netclassColors.count( pair.first )
|
|
|
|
&& netclassColors.at( pair.first ) != COLOR4D::UNSPECIFIED )
|
2020-07-11 17:42:00 +00:00
|
|
|
pair.second->SetPcbColor( netclassColors.at( pair.first ) );
|
|
|
|
}
|
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
SELECTION_FILTER_OPTIONS& filterOpts = GetToolManager()->GetTool<SELECTION_TOOL>()->GetFilter();
|
|
|
|
localSettings.m_SelectionFilter = filterOpts;
|
2020-07-07 01:53:12 +00:00
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
GetSettingsManager()->SaveProject();
|
2010-04-23 14:46:00 +00:00
|
|
|
}
|