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>
|
2020-08-18 14:17:16 +00:00
|
|
|
* Copyright (C) 1992-2020 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>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.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:33:03 +00:00
|
|
|
#include <panel_pcbnew_display_origin.h>
|
2020-07-07 01:53:12 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/selection_tool.h>
|
2019-05-25 11:05:39 +00:00
|
|
|
#include <ws_data_model.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.h>
|
2020-07-08 02:21:45 +00:00
|
|
|
#include <pcb_painter.h>
|
2013-10-13 21:33:58 +00:00
|
|
|
#include <invoke_pcb_dialog.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-08-29 19:52:39 +00:00
|
|
|
wxTreebook* book = aParent->GetTreebook();
|
2018-07-15 23:15:48 +00:00
|
|
|
|
2020-08-29 19:52:39 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "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
|
2020-07-07 01:33:03 +00:00
|
|
|
book->AddSubPage( new PANEL_PCBNEW_DISPLAY_ORIGIN( this, aParent ), _( "Origins & Axes" ) );
|
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
|
|
|
{
|
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 )
|
2020-09-03 17:54:14 +00:00
|
|
|
netclassColors[pair.first] = pair.second->GetPcbColor();
|
2020-07-11 17:42:00 +00:00
|
|
|
|
|
|
|
m_appearancePanel->SetUserLayerPresets( project.m_LayerPresets );
|
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 );
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
wxFileName fn( GetCurrentFileName() );
|
|
|
|
fn.MakeRelativeTo( Prj().GetProjectPath() );
|
|
|
|
LoadWindowState( fn.GetFullPath() );
|
|
|
|
|
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();
|
|
|
|
|
2020-09-03 17:54:14 +00:00
|
|
|
for( const std::pair<const int, KIGFX::COLOR4D>& pair : rs->GetNetColorMap() )
|
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
|
2020-09-03 17:54:14 +00:00
|
|
|
for( const std::pair<const wxString, NETCLASSPTR>& pair : netSettings.m_NetClasses )
|
2020-07-11 17:42:00 +00:00
|
|
|
{
|
2020-09-03 17:54:14 +00:00
|
|
|
if( netclassColors.count( pair.first ) )
|
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-08-25 02:17:21 +00:00
|
|
|
if( !Prj().IsNullProject() )
|
|
|
|
GetSettingsManager()->SaveProject();
|
2010-04-23 14:46:00 +00:00
|
|
|
}
|