KiCad PCB EDA Suite
pcbnew_config.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include <fctsys.h>
28 #include <kiface_i.h>
29 #include <project.h>
30 #include <confirm.h>
31 #include <gestfich.h>
32 #include <macros.h>
33 #include <pcb_edit_frame.h>
34 #include <board_design_settings.h>
35 #include <plotter.h>
36 #include <ws_painter.h>
37 #include <panel_hotkeys_editor.h>
38 #include <panel_pcbnew_settings.h>
41 #include <fp_lib_table.h>
42 #include <ws_data_model.h>
43 #include <class_board.h>
44 #include <class_module.h>
45 #include <pcbplot.h>
46 #include <footprint_viewer_frame.h>
47 #include <invoke_pcb_dialog.h>
49 #include <widgets/paged_dialog.h>
50 
51 
52 void PCB_EDIT_FRAME::On3DShapeLibWizard( wxCommandEvent& event )
53 {
54 #ifdef BUILD_GITHUB_PLUGIN
56 #endif
57 }
58 
59 
61  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
62 {
63  wxTreebook* book = aParent->GetTreebook();
64 
65  book->AddPage( new wxPanel( book ), _( "Pcbnew" ) );
66  book->AddSubPage( new PANEL_PCBNEW_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
67  book->AddSubPage( new PANEL_PCBNEW_SETTINGS( this, aParent ), _( "Editing Options" ) );
68 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
69  book->AddSubPage( new PANEL_PCBNEW_ACTION_PLUGINS( this, aParent ), _( "Action Plugins" ) );
70 #endif
71 
72  aHotkeysPanel->AddHotKeys( GetToolManager() );
73 }
74 
75 
77 {
78  wxLogDebug( wxT( "Loading project '%s' settings." ), GetChars( Prj().GetProjectFullName() ) );
79 
80  bool rc = Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters() );
81 
82  // Load the page layout decr file, from the filename stored in
83  // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
84  // If empty, or not existing, the default descr is loaded
87  Prj().GetProjectPath() );
88 
89  pglayout.SetPageLayout( filename );
90 
91  return rc;
92 }
93 
94 
95 void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
96 {
97  wxFileName fn = Prj().GetProjectFullName();
98 
99  if( aAskForSave )
100  {
101  wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),
102  ProjectFileWildcard(), wxFD_SAVE | wxFD_CHANGE_DIR );
103 
104  if( dlg.ShowModal() == wxID_CANCEL )
105  return;
106 
107  fn = dlg.GetPath();
108  }
109 
110  wxString pro_name = fn.GetFullPath();
111 
112  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_name );
113 }
114 
115 
117 {
118  m_projectFileParams.clear();
119 
120  // This one cannot be cached because some settings are going to/from the BOARD,
121  // so pointers into that cannot be saved for long.
122 
123  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
125 
126  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ),
128 
129  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastSTEPExportPath" ),
130  &m_lastPath[ LAST_PATH_STEP ] ) );
131 
132  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastIDFExportPath" ),
133  &m_lastPath[ LAST_PATH_IDF ] ) );
134 
135  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastVRMLExportPath" ),
136  &m_lastPath[ LAST_PATH_VRML ] ) );
137 
138  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastSpecctraDSNExportPath" ),
140 
141  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastGenCADExportPath" ),
143 
145 
146  return m_projectFileParams;
147 }
148 
149 
151 {
153 
154  if( m_configParams.empty() )
155  {
156  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayPolarCoords" ),
157  &m_PolarCoords, false ) );
158  // Display options and modes:
159  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "ShowNetNamesMode" ),
160  &displ_opts.m_DisplayNetNamesMode, 3, 0, 3 ) );
161  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayTrackFilled" ),
162  &displ_opts.m_DisplayPcbTrackFill, true ) );
163  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "TrackDisplayClearance" ),
164  (int*) &displ_opts.m_ShowTrackClearanceMode,
166  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadFill" ),
167  &displ_opts.m_DisplayPadFill, true ) );
168  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ViaFill" ),
169  &displ_opts.m_DisplayViaFill, true ) );
170  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadAffG" ),
171  &displ_opts.m_DisplayPadIsol, true ) );
172  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadSNum" ),
173  &displ_opts.m_DisplayPadNum, true ) );
174  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffC" ),
175  &displ_opts.m_DisplayModEdgeFill, FILLED ) );
176  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffT" ),
177  &displ_opts.m_DisplayModTextFill, FILLED ) );
178  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PcbAffT" ),
179  &displ_opts.m_DisplayDrawItemsFill, FILLED ) );
180  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ),
181  &displ_opts.m_DisplayZonesMode, 0, 0, 2 ) );
182  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "CurvedRatsnestLines" ),
183  &displ_opts.m_DisplayRatsnestLinesCurved, false ) );
184  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestLines" ),
185  &displ_opts.m_ShowGlobalRatsnest, true) );
186  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ShowRatsnestModuleLines" ),
187  &displ_opts.m_ShowModuleRatsnest, true) );
188 
189  // Miscellaneous:
190  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ),
191  &m_rotationAngle, 900, 1, 900 ) );
192  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ),
193  &displ_opts.m_MaxLinksShowed, 3, 0, 15 ) );
194  }
195 
196  return m_configParams;
197 }
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
This file is part of the common library TODO brief description.
This file is part of the common library.
std::vector< PARAM_CFG * > & GetConfigurationSettings()
Function GetConfigurationSettings returns the Pcbnew applications settings list.
bool LoadProjectSettings()
Load the current project's file configuration settings which are pertinent to this PCB_EDIT_FRAME ins...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
void Invoke3DShapeLibsDownloaderWizard(wxWindow *aCaller)
Function Invoke3DShapeLibsDownloaderWizard Runs the downloader wizard for easy 3D shape libraries dow...
void AddHotKeys(TOOL_MANAGER *aToolMgr)
void SetPageLayout(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout, or the default layout, if no custom layout available.
void SaveProjectSettings(bool aAskForSave) override
Function SaveProjectSettings saves changes to the project settings to the project (....
Configuration parameter - PARAM_CFG_FILENAME Class Same as PARAM_CFG_WXSTRING, but stores "\" as "/".
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
This file contains miscellaneous commonly used macros and functions.
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
std::vector< PARAM_CFG * > m_projectFileParams
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const std::vector< PARAM_CFG * > &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:358
Board plot function definition file.
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:109
std::vector< PARAM_CFG * > & GetProjectFileParameters()
Function GetProjectFileParameters returns a project file parameter list for Pcbnew.
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Configuration parameter - Integer Class.
Definition of file extensions used in Kicad.
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const std::vector< PARAM_CFG * > &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative.
Definition: project.cpp:323
Configuration parameter - Boolean Class.
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
PCB_DISPLAY_OPTIONS m_DisplayOptions
int m_rotationAngle
User defined rotation angle (in tenths of a degree).
wxString ProjectFileWildcard()
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
static const wxString MakeFullFileName(const wxString &aShortFileName, const wxString &aProjectPath)
Static function.
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allows Pcbnew to install its preferences panel into the preferences dialog.
#define _(s)
Definition: 3d_actions.cpp:31
wxString m_lastPath[LAST_PATH_SIZE]
void On3DShapeLibWizard(wxCommandEvent &event)
Module description (excepted pads)
BOARD * GetBoard() const
#define GROUP_PCB
Names of sub sections where to store project info in *.pro project config files.
Definition: config_params.h:43
void AppendConfigs(BOARD *aBoard, std::vector< PARAM_CFG * > *aResult)
Function AppendConfigs appends to aResult the configuration setting accessors which will later allow ...
std::vector< PARAM_CFG * > m_configParams