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 
96 {
97  wxFileName fn = Prj().GetProjectFullName();
98 
99  // Check for the filename before checking IsWritable as this
100  // will throw errors on bad names. Here, we just want to not
101  // save the Settings if we don't have a name
102  if( !fn.IsOk() )
103  return;
104 
105  if( !IsWritable( fn ) )
106  return;
107 
108  wxString pro_name = fn.GetFullPath();
109 
111  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_name );
112 }
113 
114 
116 {
117  m_projectFileParams.clear();
118 
119  // This one cannot be cached because some settings are going to/from the BOARD,
120  // so pointers into that cannot be saved for long.
121 
122  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
124 
125  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ),
127 
128  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastSTEPExportPath" ),
129  &m_lastPath[ LAST_PATH_STEP ] ) );
130 
131  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastIDFExportPath" ),
132  &m_lastPath[ LAST_PATH_IDF ] ) );
133 
134  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastVRMLExportPath" ),
135  &m_lastPath[ LAST_PATH_VRML ] ) );
136 
137  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastSpecctraDSNExportPath" ),
139 
140  m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LastGenCADExportPath" ),
142 
143  m_projectFileParams.push_back( new PARAM_CFG_WXSTRING_SET( wxT( "DRCExclusion" ),
144  &m_drcExclusions ) );
145 
147 
148  return m_projectFileParams;
149 }
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.
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:512
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.
bool IsWritable(const wxFileName &aFileName)
Checks if aFileName can be written.
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
Configuration parameter - PARAM_CFG_FILENAME Class Same as PARAM_CFG_WXSTRING, but stores "\" as "/".
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:385
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
Configuration parameter - std::set<wxString>
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SaveProjectSettings() override
Function SaveProjectSettings saves changes to the project settings to the project (....
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:350
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
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:33
wxString m_lastPath[LAST_PATH_SIZE]
std::set< wxString > m_drcExclusions
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:40
void AppendConfigs(BOARD *aBoard, std::vector< PARAM_CFG * > *aResult)
Function AppendConfigs appends to aResult the configuration setting accessors which will later allow ...