KiCad PCB EDA Suite
config_params.h
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) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef CONFIG_PARAMS_H_
27 #define CONFIG_PARAMS_H_
28 
34 #include <wx/confbase.h>
35 #include <wx/fileconf.h>
36 #include <boost/ptr_container/ptr_vector.hpp>
37 #include <gal/color4d.h>
38 #include <limits>
39 
40 using KIGFX::COLOR4D;
41 
43 #define GROUP_PCB wxT( "/pcbnew" )
44 #define GROUP_SCH wxT( "/eeschema" )
45 #define GROUP_SCH_EDITOR wxT( "/schematic_editor" )
46 #define GROUP_PCB_LIBS wxT( "/pcbnew/libraries" )
49 #define GROUP_SCH_LIBS wxT( "/eeschema/libraries" )
51 
52 #define GROUP_CVP wxT("/cvpcb")
53 #define GROUP_CVP_EQU wxT("/cvpcb/equfiles")
54 
55 
56 #define CONFIG_VERSION 1
57 
58 
67 void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue );
68 
69 
87 };
88 
89 
100 {
101 public:
102  wxString m_Ident;
104  wxString m_Group;
105  bool m_Setup;
106 
107  // If the m_Ident keyword isn't found, fall back and read values from m_Ident_legacy.
108  // Note that values are always written to the current, non-legacy keyword.
109  wxString m_Ident_legacy;
110 
111 public:
112  PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type, const wxChar* group = NULL,
113  const wxString& legacy_ident = wxEmptyString );
114  virtual ~PARAM_CFG_BASE() {}
115 
121  virtual void ReadParam( wxConfigBase* aConfig ) const {};
122 
128  virtual void SaveParam( wxConfigBase* aConfig ) const {};
129 };
130 
131 
137 {
138 public:
139  int* m_Pt_param;
140  int m_Min, m_Max;
141  int m_Default;
142 
143 public:
144  PARAM_CFG_INT( const wxString& ident, int* ptparam, int default_val = 0,
147  const wxChar* group = nullptr,
148  const wxString& legacy_ident = wxEmptyString );
149  PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam, int default_val = 0,
152  const wxChar* group = nullptr,
153  const wxString& legacy_ident = wxEmptyString );
154 
155  virtual void ReadParam( wxConfigBase* aConfig ) const override;
156  virtual void SaveParam( wxConfigBase* aConfig ) const override;
157 };
158 
167 {
168 public:
170 
171 public:
172  PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam, int default_val = 0,
175  const wxChar* group = NULL, double aBiu2cfgunit = 1.0,
176  const wxString& legacy_ident = wxEmptyString );
177  PARAM_CFG_INT_WITH_SCALE( bool insetup, const wxString& ident, int* ptparam,
178  int default_val = 0,
181  const wxChar* group = NULL, double aBiu2cfgunit = 1.0,
182  const wxString& legacy_ident = wxEmptyString );
183 
184  virtual void ReadParam( wxConfigBase* aConfig ) const override;
185  virtual void SaveParam( wxConfigBase* aConfig ) const override;
186 };
187 
188 
194 {
195 public:
198 
199 public:
200  PARAM_CFG_SETCOLOR( const wxString& ident, COLOR4D* ptparam,
201  COLOR4D default_val, const wxChar* group = NULL );
202  PARAM_CFG_SETCOLOR( bool Insetup, const wxString& ident, COLOR4D* ptparam,
203  COLOR4D default_val, const wxChar* group = NULL );
204 
205  virtual void ReadParam( wxConfigBase* aConfig ) const override;
206  virtual void SaveParam( wxConfigBase* aConfig ) const override;
207 };
208 
209 
215 {
216 public:
217  double* m_Pt_param;
218  double m_Default;
219  double m_Min, m_Max;
220 
221 public:
222  PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
223  double default_val = 0.0, double min = 0.0, double max = 10000.0,
224  const wxChar* group = NULL );
225  PARAM_CFG_DOUBLE( bool Insetup, const wxString& ident, double* ptparam,
226  double default_val = 0.0, double min = 0.0, double max = 10000.0,
227  const wxChar* group = NULL );
228 
229  virtual void ReadParam( wxConfigBase* aConfig ) const override;
230  virtual void SaveParam( wxConfigBase* aConfig ) const override;
231 };
232 
233 
239 {
240 public:
241  bool* m_Pt_param;
242  int m_Default;
243 
244 public:
245  PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
246  int default_val = false, const wxChar* group = NULL );
247  PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
248  int default_val = false, const wxChar* group = NULL );
249 
250  virtual void ReadParam( wxConfigBase* aConfig ) const override;
251  virtual void SaveParam( wxConfigBase* aConfig ) const override;
252 };
253 
254 
260 {
261 public:
262  wxString* m_Pt_param;
263  wxString m_default;
264 
265 public:
266  PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group = NULL );
267 
268  PARAM_CFG_WXSTRING( bool Insetup,
269  const wxString& ident,
270  wxString* ptparam,
271  const wxString& default_val = wxEmptyString,
272  const wxChar* group = NULL );
273 
274  virtual void ReadParam( wxConfigBase* aConfig ) const override;
275  virtual void SaveParam( wxConfigBase* aConfig ) const override;
276 };
277 
278 
286 {
287 public:
288  wxString* m_Pt_param;
289 
290 public:
291  PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam,
292  const wxChar* group = NULL );
293  virtual void ReadParam( wxConfigBase* aConfig ) const override;
294  virtual void SaveParam( wxConfigBase* aConfig ) const override;
295 };
296 
297 
299 {
300 public:
301  wxArrayString* m_Pt_param;
302 
303 public:
304  PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
305  wxArrayString* ptparam,
306  const wxChar* group = NULL );
307 
308  virtual void ReadParam( wxConfigBase* aConfig ) const override;
309  virtual void SaveParam( wxConfigBase* aConfig ) const override;
310 };
311 
312 
314 //typedef boost::ptr_vector<PARAM_CFG_BASE> PARAM_CFG_ARRAY;
315 class PARAM_CFG_ARRAY : public boost::ptr_vector<PARAM_CFG_BASE>
316 {
317 };
318 
319 
330 void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList );
331 
345 void wxConfigSaveParams( wxConfigBase* aCfg,
346  const PARAM_CFG_ARRAY& aList, const wxString& aGroup );
347 
357 void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList );
358 
373 void wxConfigLoadParams( wxConfigBase* aCfg,
374  const PARAM_CFG_ARRAY& aList, const wxString& aGroup );
375 
376 
377 #endif // CONFIG_PARAMS_H_
wxString m_Ident_legacy
A list of parameters type.
int m_Default
The default value of the parameter.
wxString * m_Pt_param
Pointer to the parameter value.
void wxConfigLoadSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
COLOR4D * m_Pt_param
Pointer to the parameter value.
virtual void SaveParam(wxConfigBase *aConfig) const
Function SaveParam saves the value of the parameter stored in aConfig.
void ConfigBaseWriteDouble(wxConfigBase *aConfig, const wxString &aKey, double aValue)
Function ConfigBaseWriteDouble This is a helper function to write doubles in config We cannot use wxC...
wxString m_default
The default value of the parameter.
virtual void ReadParam(wxConfigBase *aConfig) const
Function ReadParam reads the value of the parameter stored in aConfig.
Configuration parameter - Double Precision Class.
int m_Default
The default value of the parameter.
PARAM_CFG_BASE(const wxString &ident, const paramcfg_id type, const wxChar *group=NULL, const wxString &legacy_ident=wxEmptyString)
double * m_Pt_param
Pointer to the parameter value.
Configuration parameter - Integer Class with unit conversion.
int * m_Pt_param
Pointer to the parameter value.
bool m_Setup
Install or Project based parameter, true == install.
Configuration parameter - PARAM_CFG_FILENAME Class Same as PARAM_CFG_WXSTRING, but stores "\" as "/"...
double m_BIU_to_cfgunit
the factor to convert the saved value in internal value
wxArrayString * m_Pt_param
Pointer to the parameter value.
Configuration parameter - SetColor Class.
Configuration parameter - Integer Class.
Configuration parameter - Boolean Class.
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:99
paramcfg_id
Type of parameter in the configuration file.
Definition: config_params.h:71
Configuration parameter - wxString Class.
double m_Default
The default value of the parameter.
bool * m_Pt_param
Pointer to the parameter value.
void wxConfigSaveParams(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList, const wxString &aGroup)
Function wxConfigSaveParams writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
virtual ~PARAM_CFG_BASE()
COLOR4D m_Default
The default value of the parameter.
#define max(a, b)
Definition: auxiliary.h:86
wxString * m_Pt_param
Pointer to the parameter value.
void wxConfigLoadParams(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList, const wxString &aGroup)
Function wxConfigLoadParams uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
wxString m_Group
Group name (this is like a path in the config data)
paramcfg_id m_Type
Type of parameter.
wxString m_Ident
Keyword in config data.
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
#define min(a, b)
Definition: auxiliary.h:85
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39