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-2017 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 
31 #include <fctsys.h>
32 #include <kiface_i.h>
33 #include <project.h>
34 #include <class_drawpanel.h>
35 #include <pcb_draw_panel_gal.h>
36 #include <confirm.h>
37 #include <gestfich.h>
38 #include <xnode.h>
39 #include <common.h>
40 #include <macros.h>
41 #include <pcb_edit_frame.h>
42 #include <board_design_settings.h>
43 #include <plotter.h>
44 #include <worksheet.h>
45 #include <panel_hotkeys_editor.h>
46 #include <panel_pcbnew_settings.h>
49 #include <fp_lib_table.h>
51 #include <class_board.h>
52 #include <class_module.h>
53 #include <pcbplot.h>
54 #include <pcbnew_id.h>
55 #include <hotkeys.h>
56 #include <footprint_viewer_frame.h>
57 #include <invoke_pcb_dialog.h>
59 #include <view/view.h>
60 #include <widgets/paged_dialog.h>
61 
62 
63 void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
64 {
65  int id = event.GetId();
66 
67  switch( id )
68  {
70  InvokePcbLibTableEditor( &Kiway(), this );
71  break;
72 
74 #ifdef BUILD_GITHUB_PLUGIN
76 #endif
77  break;
78 
79  case wxID_PREFERENCES:
81  break;
82 
85  break;
86 
87  default:
88  DisplayErrorMessage( this, "Unknown ID in Process Config",
89  wxString::Format( "PCB_EDIT_FRAME::Process_Config received ID %d", id ) );
90  break;
91  }
92 }
93 
94 
96 {
97  wxTreebook* book = aParent->GetTreebook();
98 
99  book->AddPage( new PANEL_PCBNEW_SETTINGS( this, aParent ), _( "Pcbnew" ) );
100  book->AddSubPage( new PANEL_PCBNEW_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
101 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
102  book->AddSubPage( new PANEL_PCBNEW_ACTION_PLUGINS( this, aParent ), _( "Action Plugins" ) );
103 #endif
104 }
105 
106 
108 {
109  wxLogDebug( wxT( "Loading project '%s' settings." ),
110  GetChars( Prj().GetProjectFullName() ) );
111 
112  bool rc = Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters() );
113 
114  // Load the page layout decr file, from the filename stored in
115  // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
116  // If empty, or not existing, the default descr is loaded
118  wxString pg_fullfilename = WORKSHEET_LAYOUT::MakeFullFileName(
120  Prj().GetProjectPath() );
121 
122  pglayout.SetPageLayout( pg_fullfilename );
123 
124  return rc;
125 }
126 
127 
128 void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
129 {
130  wxFileName fn = Prj().GetProjectFullName();
131 
132  if( aAskForSave )
133  {
134  wxFileDialog dlg( this, _( "Save Project File" ),
135  fn.GetPath(), fn.GetFullName(),
136  ProjectFileWildcard(), wxFD_SAVE | wxFD_CHANGE_DIR );
137 
138  if( dlg.ShowModal() == wxID_CANCEL )
139  return;
140 
141  fn = dlg.GetPath();
142  }
143 
144  wxString pro_name = fn.GetFullPath();
145 
146  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_name );
147 }
148 
149 
151 {
152  PARAM_CFG_ARRAY pca;
153 
154  // This one cannot be cached because some settings are going to/from the BOARD,
155  // so pointers into that cannot be saved for long.
156 
157  pca.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
159 
160  pca.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ), &m_lastNetListRead ) );
161 
163 
164  return pca;
165 }
166 
167 
169 {
170  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
171 
172  if( m_configParams.empty() )
173  {
174  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayPolarCoords" ),
175  &displ_opts->m_DisplayPolarCood, false ) );
176  // Display options and modes:
177  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "ShowNetNamesMode" ),
178  &displ_opts->m_DisplayNetNamesMode, 3, 0, 3 ) );
179  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "DisplayTrackFilled" ),
180  &displ_opts->m_DisplayPcbTrackFill, true ) );
181  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "TrackDisplayClearance" ),
182  (int*) &displ_opts->m_ShowTrackClearanceMode,
184  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadFill" ),
185  &displ_opts->m_DisplayPadFill, true ) );
186  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ViaFill" ),
187  &displ_opts->m_DisplayViaFill, true ) );
188  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadAffG" ),
189  &displ_opts->m_DisplayPadIsol, true ) );
190  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PadSNum" ),
191  &displ_opts->m_DisplayPadNum, true ) );
192  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffC" ),
193  &displ_opts->m_DisplayModEdgeFill, FILLED ) );
194  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "ModAffT" ),
195  &displ_opts->m_DisplayModTextFill, FILLED ) );
196  m_configParams.push_back( new PARAM_CFG_BOOL( true, wxT( "PcbAffT" ),
197  &displ_opts->m_DisplayDrawItemsFill, FILLED ) );
198  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ),
199  &displ_opts->m_DisplayZonesMode, 0, 0, 2 ) );
200 
201  // Miscellaneous:
202  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ),
203  &m_rotationAngle, 900, 1, 900 ) );
204  m_configParams.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ),
205  &displ_opts->m_MaxLinksShowed, 3, 0, 15 ) );
206  }
207 
208  return m_configParams;
209 }
A list of parameters type.
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:318
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
PARAM_CFG_ARRAY GetProjectFileParameters()
Function GetProjectFileParameters returns a project file parameter list for Pcbnew.
void Process_Config(wxCommandEvent &event)
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
This file is part of the common library TODO brief description.
This file is part of the common library.
Class BOARD to handle a board.
bool LoadProjectSettings()
Load the current project&#39;s file configuration settings which are pertinent to this PCB_EDIT_FRAME ins...
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
BOARD * GetBoard() const
PARAM_CFG_ARRAY & GetConfigurationSettings()
Function GetConfigurationSettings returns the Pcbnew applications settings list.
void Invoke3DShapeLibsDownloaderWizard(wxWindow *aCaller)
Function Invoke3DShapeLibsDownloaderWizard Runs the downloader wizard for easy 3D shape libraries dow...
struct EDA_HOTKEY_CONFIG g_Pcbnew_Editor_Hotkeys_Descr[]
void SaveProjectSettings(bool aAskForSave) override
Function SaveProjectSettings saves changes to the project settings to the project (...
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
Configuration parameter - PARAM_CFG_FILENAME Class Same as PARAM_CFG_WXSTRING, but stores "\" as "/"...
static WORKSHEET_LAYOUT & GetTheInstance()
static function: returns the instance of WORKSHEET_LAYOUT used in the application ...
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Pcbnew hotkeys.
This file contains miscellaneous commonly used macros and functions.
Board plot function definition file.
void InvokePcbLibTableEditor(KIWAY *aKiway, wxWindow *aCaller)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the glob...
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:180
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void DisplayHotkeyList(EDA_BASE_FRAME *aFrame, struct EDA_HOTKEY_CONFIG *aDescList)
Function DisplayHotkeyList Displays the current hotkey list.
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
Configuration parameter - Integer Class.
The common library.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
struct EDA_HOTKEY_CONFIG g_Board_Editor_Hotkeys_Descr[]
Configuration parameter - Boolean Class.
void AppendConfigs(BOARD *aBoard, PARAM_CFG_ARRAY *aResult)
Function AppendConfigs appends to aResult the configuration setting accessors which will later allow ...
WORKSHEET_LAYOUT handles the graphic items list to draw/plot the title block and other items (page re...
int m_rotationAngle
User defined rotation angle (in tenths of a degree).
wxString ProjectFileWildcard()
wxString m_lastNetListRead
Last net list read with relative path.
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:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static const wxString MakeFullFileName(const wxString &aShortFileName, const wxString &aProjectPath)
Static function.
The common library.
classes and function to generate graphics to plt or draw titles blocks and frame references ...
PARAM_CFG_ARRAY m_configParams
List of Pcbnew configuration settings.
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:353
bool ShowPreferences(EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aHotkeysNickname)
Module description (excepted pads)
void InstallPreferences(PAGED_DIALOG *aParent) override
Allows Pcbnew to install its preferences panel into the preferences dialog.
#define GROUP_PCB
Names of sub sections where to store project info in *.pro project config files.
Definition: config_params.h:43
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...