kicad/pcbnew/pcbnew_config.cpp

198 lines
8.9 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
#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>
#include <project.h>
#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>
#include <plotter.h>
#include <ws_painter.h>
#include <panel_hotkeys_editor.h>
#include <panel_pcbnew_settings.h>
#include <panel_pcbnew_display_options.h>
#include <panel_pcbnew_action_plugins.h>
2012-10-15 22:30:01 +00:00
#include <fp_lib_table.h>
#include <ws_data_model.h>
#include <class_board.h>
#include <class_module.h>
#include <pcbplot.h>
#include <footprint_viewer_frame.h>
#include <invoke_pcb_dialog.h>
#include <wildcards_and_files_ext.h>
#include <widgets/paged_dialog.h>
2019-06-09 21:57:23 +00:00
void PCB_EDIT_FRAME::On3DShapeLibWizard( wxCommandEvent& event )
{
#ifdef BUILD_GITHUB_PLUGIN
2019-06-09 21:57:23 +00:00
Invoke3DShapeLibsDownloaderWizard( this );
#endif
}
2019-06-09 21:57:23 +00:00
void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
{
wxTreebook* book = aParent->GetTreebook();
book->AddPage( new wxPanel( book ), _( "Pcbnew" ) );
book->AddSubPage( new PANEL_PCBNEW_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
book->AddSubPage( new PANEL_PCBNEW_SETTINGS( this, aParent ), _( "Editing Options" ) );
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
book->AddSubPage( new PANEL_PCBNEW_ACTION_PLUGINS( this, aParent ), _( "Action Plugins" ) );
#endif
2019-06-09 21:57:23 +00:00
aHotkeysPanel->AddHotKeys( GetToolManager() );
}
bool PCB_EDIT_FRAME::LoadProjectSettings()
{
wxLogDebug( wxT( "Loading project '%s' settings." ), GetChars( Prj().GetProjectFullName() ) );
bool rc = Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters() );
// Load the page layout decr file, from the filename stored in
// BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
// If empty, or not existing, the default descr is loaded
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
wxString filename = WS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName,
Prj().GetProjectPath() );
pglayout.SetPageLayout( filename );
return rc;
}
2008-02-19 00:35:45 +00:00
void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
{
wxFileName fn = Prj().GetProjectFullName();
if( aAskForSave )
{
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),
ProjectFileWildcard(), wxFD_SAVE | wxFD_CHANGE_DIR );
if( dlg.ShowModal() == wxID_CANCEL )
return;
2008-02-19 00:35:45 +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
fn = dlg.GetPath();
}
wxString pro_name = fn.GetFullPath();
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_name );
}
PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters()
{
m_projectFileParams.clear();
// This one cannot be cached because some settings are going to/from the BOARD,
// so pointers into that cannot be saved for long.
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
&BASE_SCREEN::m_PageLayoutDescrFileName ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ),
&m_lastPath[ LAST_PATH_NETLIST ] ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastSTEPExportPath" ),
&m_lastPath[ LAST_PATH_STEP ] ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastIDFExportPath" ),
&m_lastPath[ LAST_PATH_IDF ] ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastVRMLExportPath" ),
&m_lastPath[ LAST_PATH_VRML ] ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastSpecctraDSNExportPath" ),
&m_lastPath[ LAST_PATH_SPECCTRADSN ] ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastGenCADExportPath" ),
&m_lastPath[ LAST_PATH_GENCAD ] ) );
2012-02-19 04:02:19 +00:00
GetBoard()->GetDesignSettings().AppendConfigs( GetBoard(), &m_projectFileParams);
2012-02-19 04:02:19 +00:00
return m_projectFileParams;
}
PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
{
PCB_DISPLAY_OPTIONS& displ_opts = m_DisplayOptions;
if( m_configParams.empty() )
{
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayPolarCoords" ),
&m_PolarCoords, false ) );
// Display options and modes:
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "ShowNetNamesMode" ),
&displ_opts.m_DisplayNetNamesMode, 3, 0, 3 ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayTrackFilled" ),
&displ_opts.m_DisplayPcbTrackFill, true ) );
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "TrackDisplayClearance" ),
(int*) &displ_opts.m_ShowTrackClearanceMode,
PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadFill" ),
&displ_opts.m_DisplayPadFill, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ViaFill" ),
&displ_opts.m_DisplayViaFill, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadAffG" ),
&displ_opts.m_DisplayPadIsol, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadSNum" ),
&displ_opts.m_DisplayPadNum, true ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffC" ),
&displ_opts.m_DisplayModEdgeFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffT" ),
&displ_opts.m_DisplayModTextFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PcbAffT" ),
&displ_opts.m_DisplayDrawItemsFill, FILLED ) );
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ),
&displ_opts.m_DisplayZonesMode, 0, 0, 2 ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "CurvedRatsnestLines" ),
&displ_opts.m_DisplayRatsnestLinesCurved, false ) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestLines" ),
&displ_opts.m_ShowGlobalRatsnest, true) );
m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestModuleLines" ),
&displ_opts.m_ShowModuleRatsnest, true) );
// Miscellaneous:
2018-07-19 20:46:16 +00:00
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ),
&m_rotationAngle, 900, 1, 900 ) );
m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ),
&displ_opts.m_MaxLinksShowed, 3, 0, 15 ) );
}
return m_configParams;
}