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 
82 };
83 
84 
95 {
96 public:
97  wxString m_Ident;
99  wxString m_Group;
100  bool m_Setup;
101 
102 public:
103  PARAM_CFG_BASE( const wxString& ident, const paramcfg_id type,
104  const wxChar* group = NULL );
105  virtual ~PARAM_CFG_BASE() {}
106 
112  virtual void ReadParam( wxConfigBase* aConfig ) const {};
113 
119  virtual void SaveParam( wxConfigBase* aConfig ) const {};
120 };
121 
122 
128 {
129 public:
130  int* m_Pt_param;
131  int m_Min, m_Max;
132  int m_Default;
133 
134 public:
135  PARAM_CFG_INT( const wxString& ident, int* ptparam,
136  int default_val = 0,
139  const wxChar* group = NULL );
140  PARAM_CFG_INT( bool Insetup, const wxString& ident, int* ptparam,
141  int default_val = 0,
144  const wxChar* group = NULL );
145 
146  virtual void ReadParam( wxConfigBase* aConfig ) const override;
147  virtual void SaveParam( wxConfigBase* aConfig ) const override;
148 };
149 
158 {
159 public:
161 
162 public:
163  PARAM_CFG_INT_WITH_SCALE( const wxString& ident, int* ptparam,
164  int default_val = 0,
167  const wxChar* group = NULL,
168  double aBiu2cfgunit = 1.0);
169  PARAM_CFG_INT_WITH_SCALE( bool Insetup, const wxString& ident, int* ptparam,
170  int default_val = 0,
173  const wxChar* group = NULL,
174  double aBiu2cfgunit = 1.0 );
175 
176  virtual void ReadParam( wxConfigBase* aConfig ) const override;
177  virtual void SaveParam( wxConfigBase* aConfig ) const override;
178 };
179 
180 
186 {
187 public:
190 
191 public:
192  PARAM_CFG_SETCOLOR( const wxString& ident, COLOR4D* ptparam,
193  COLOR4D default_val, const wxChar* group = NULL );
194  PARAM_CFG_SETCOLOR( bool Insetup, const wxString& ident, COLOR4D* ptparam,
195  COLOR4D default_val, const wxChar* group = NULL );
196 
197  virtual void ReadParam( wxConfigBase* aConfig ) const override;
198  virtual void SaveParam( wxConfigBase* aConfig ) const override;
199 };
200 
201 
207 {
208 public:
209  double* m_Pt_param;
210  double m_Default;
211  double m_Min, m_Max;
212 
213 public:
214  PARAM_CFG_DOUBLE( const wxString& ident, double* ptparam,
215  double default_val = 0.0, double min = 0.0, double max = 10000.0,
216  const wxChar* group = NULL );
217  PARAM_CFG_DOUBLE( bool Insetup, const wxString& ident, double* ptparam,
218  double default_val = 0.0, double min = 0.0, double max = 10000.0,
219  const wxChar* group = NULL );
220 
221  virtual void ReadParam( wxConfigBase* aConfig ) const override;
222  virtual void SaveParam( wxConfigBase* aConfig ) const override;
223 };
224 
225 
231 {
232 public:
233  bool* m_Pt_param;
234  int m_Default;
235 
236 public:
237  PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
238  int default_val = false, const wxChar* group = NULL );
239  PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
240  int default_val = false, const wxChar* group = NULL );
241 
242  virtual void ReadParam( wxConfigBase* aConfig ) const override;
243  virtual void SaveParam( wxConfigBase* aConfig ) const override;
244 };
245 
246 
252 {
253 public:
254  wxString* m_Pt_param;
255  wxString m_default;
256 
257 public:
258  PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam, const wxChar* group = NULL );
259 
260  PARAM_CFG_WXSTRING( bool Insetup,
261  const wxString& ident,
262  wxString* ptparam,
263  const wxString& default_val = wxEmptyString,
264  const wxChar* group = NULL );
265 
266  virtual void ReadParam( wxConfigBase* aConfig ) const override;
267  virtual void SaveParam( wxConfigBase* aConfig ) const override;
268 };
269 
270 
278 {
279 public:
280  wxString* m_Pt_param;
281 
282 public:
283  PARAM_CFG_FILENAME( const wxString& ident, wxString* ptparam,
284  const wxChar* group = NULL );
285  virtual void ReadParam( wxConfigBase* aConfig ) const override;
286  virtual void SaveParam( wxConfigBase* aConfig ) const override;
287 };
288 
289 
291 {
292 public:
293  wxArrayString* m_Pt_param;
294 
295 public:
296  PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
297  wxArrayString* ptparam,
298  const wxChar* group = NULL );
299 
300  virtual void ReadParam( wxConfigBase* aConfig ) const override;
301  virtual void SaveParam( wxConfigBase* aConfig ) const override;
302 };
303 
304 
306 //typedef boost::ptr_vector<PARAM_CFG_BASE> PARAM_CFG_ARRAY;
307 class PARAM_CFG_ARRAY : public boost::ptr_vector<PARAM_CFG_BASE>
308 {
309 };
310 
311 
322 void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList );
323 
337 void wxConfigSaveParams( wxConfigBase* aCfg,
338  const PARAM_CFG_ARRAY& aList, const wxString& aGroup );
339 
349 void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList );
350 
365 void wxConfigLoadParams( wxConfigBase* aCfg,
366  const PARAM_CFG_ARRAY& aList, const wxString& aGroup );
367 
368 
369 #endif // CONFIG_PARAMS_H_
virtual void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
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 ...
virtual void ReadParam(wxConfigBase *aConfig) const override
Function ReadParam reads the value of the parameter stored in aConfig.
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 override
Function ReadParam reads the value of the parameter stored in aConfig.
virtual void ReadParam(wxConfigBase *aConfig) const
Function ReadParam reads the value of the parameter stored in aConfig.
virtual void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
Configuration parameter - Double Precision Class.
int m_Default
The default value of the parameter.
PARAM_CFG_BOOL(const wxString &ident, bool *ptparam, int default_val=false, const wxChar *group=NULL)
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
PARAM_CFG_LIBNAME_LIST(const wxChar *ident, wxArrayString *ptparam, const wxChar *group=NULL)
PARAM_CFG_INT(const wxString &ident, int *ptparam, int default_val=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), const wxChar *group=NULL)
wxArrayString * m_Pt_param
Pointer to the parameter value.
Configuration parameter - SetColor Class.
virtual void ReadParam(wxConfigBase *aConfig) const override
Function ReadParam reads the value of the parameter stored in aConfig.
virtual void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
PARAM_CFG_INT_WITH_SCALE(const wxString &ident, int *ptparam, int default_val=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), const wxChar *group=NULL, double aBiu2cfgunit=1.0)
Configuration parameter - Integer Class.
int m_Max
Minimum and maximum values of the param type.
Configuration parameter - Boolean Class.
virtual void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
double m_Max
Minimum and maximum values of the param type.
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
paramcfg_id
Type of parameter in the configuration file.
Definition: config_params.h:71
virtual void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
Configuration parameter - wxString Class.
double m_Default
The default value of the parameter.
PARAM_CFG_WXSTRING(const wxString &ident, wxString *ptparam, const wxChar *group=NULL)
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 void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
virtual void ReadParam(wxConfigBase *aConfig) const override
Function ReadParam reads the value of the parameter stored in aConfig.
virtual ~PARAM_CFG_BASE()
COLOR4D m_Default
The default value of the parameter.
virtual void ReadParam(wxConfigBase *aConfig) const override
Function ReadParam reads the value of the parameter stored in aConfig.
#define max(a, b)
Definition: auxiliary.h:86
virtual void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
wxString * m_Pt_param
Pointer to the parameter value.
PARAM_CFG_SETCOLOR(const wxString &ident, COLOR4D *ptparam, COLOR4D default_val, const wxChar *group=NULL)
virtual void ReadParam(wxConfigBase *aConfig) const override
Function ReadParam reads the value of the parameter stored in aConfig.
PARAM_CFG_DOUBLE(const wxString &ident, double *ptparam, double default_val=0.0, double min=0.0, double max=10000.0, const wxChar *group=NULL)
PARAM_CFG_BASE(const wxString &ident, const paramcfg_id type, const wxChar *group=NULL)
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 ...
virtual void ReadParam(wxConfigBase *aConfig) const override
Function ReadParam reads the value of the parameter stored in aConfig.
virtual void ReadParam(wxConfigBase *aConfig) const override
Function ReadParam reads the value of the parameter stored in aConfig.
PARAM_CFG_FILENAME(const wxString &ident, wxString *ptparam, const wxChar *group=NULL)
virtual void SaveParam(wxConfigBase *aConfig) const override
Function SaveParam saves the value of the parameter stored in aConfig.
wxString m_Group
Group name (this is like a path in the config data)
Definition: config_params.h:99
paramcfg_id m_Type
Type of parameter.
Definition: config_params.h:98
wxString m_Ident
Keyword in config data.
Definition: config_params.h:97
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