KiCad PCB EDA Suite
config_params.h File Reference

The common library. More...

#include <wx/confbase.h>
#include <wx/fileconf.h>
#include <boost/ptr_container/ptr_vector.hpp>
#include <gal/color4d.h>
#include <limits>

Go to the source code of this file.

Classes

class  PARAM_CFG_BASE
 Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SaveParam, which are implemented by a number of derived classes, and these function's doxygen comments are inherited also. More...
 
class  PARAM_CFG_INT
 Configuration parameter - Integer Class. More...
 
class  PARAM_CFG_INT_WITH_SCALE
 Configuration parameter - Integer Class with unit conversion. More...
 
class  PARAM_CFG_SETCOLOR
 Configuration parameter - SetColor Class. More...
 
class  PARAM_CFG_DOUBLE
 Configuration parameter - Double Precision Class. More...
 
class  PARAM_CFG_BOOL
 Configuration parameter - Boolean Class. More...
 
class  PARAM_CFG_WXSTRING
 Configuration parameter - wxString Class. More...
 
class  PARAM_CFG_FILENAME
 Configuration parameter - PARAM_CFG_FILENAME Class Same as PARAM_CFG_WXSTRING, but stores "\" as "/". More...
 
class  PARAM_CFG_LIBNAME_LIST
 
class  PARAM_CFG_ARRAY
 A list of parameters type. More...
 

Macros

#define GROUP_PCB   wxT( "/pcbnew" )
 Names of sub sections where to store project info in *.pro project config files. More...
 
#define GROUP_SCH   wxT( "/eeschema" )
 
#define GROUP_SCH_EDITOR   wxT( "/schematic_editor" )
 
#define GROUP_PCB_LIBS   wxT( "/pcbnew/libraries" )
 (and few for component editor). More...
 
#define GROUP_SCH_LIBS   wxT( "/eeschema/libraries" )
 (Now in fp lib tables) More...
 
#define GROUP_CVP   wxT("/cvpcb")
 
#define GROUP_CVP_EQU   wxT("/cvpcb/equfiles")
 
#define CONFIG_VERSION   1
 

Enumerations

enum  paramcfg_id {
  PARAM_INT, PARAM_INT_WITH_SCALE, PARAM_SETCOLOR, PARAM_DOUBLE,
  PARAM_BOOL, PARAM_LIBNAME_LIST, PARAM_WXSTRING, PARAM_FILENAME,
  PARAM_COMMAND_ERASE, PARAM_FIELDNAME_LIST
}
 Type of parameter in the configuration file. More...
 

Functions

void ConfigBaseWriteDouble (wxConfigBase *aConfig, const wxString &aKey, double aValue)
 Function ConfigBaseWriteDouble This is a helper function to write doubles in config We cannot use wxConfigBase->Write for a double, because this function uses a format with very few digits in mantissa, and truncation issues are frequent. More...
 
void wxConfigSaveSetups (wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
 Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to aCfg. More...
 
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 aCfg. More...
 
void wxConfigLoadSetups (wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
 Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from aCfg. More...
 
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 aCfg. More...
 

Detailed Description

The common library.

Definition in file config_params.h.

Macro Definition Documentation

#define CONFIG_VERSION   1

Definition at line 56 of file config_params.h.

Referenced by PROJECT::ConfigSave().

#define GROUP_CVP   wxT("/cvpcb")
#define GROUP_CVP_EQU   wxT("/cvpcb/equfiles")

Definition at line 53 of file config_params.h.

Referenced by CVPCB_MAINFRAME::GetProjectFileParameters().

#define GROUP_PCB   wxT( "/pcbnew" )

Names of sub sections where to store project info in *.pro project config files.

Definition at line 43 of file config_params.h.

Referenced by PCB_EDIT_FRAME::InstallNetlistFrame(), PCB_EDIT_FRAME::LoadProjectSettings(), PCB_EDIT_FRAME::Process_Config(), and PCB_EDIT_FRAME::SaveProjectSettings().

#define GROUP_PCB_LIBS   wxT( "/pcbnew/libraries" )

(and few for component editor).

Does not store libs list

Definition at line 48 of file config_params.h.

Referenced by CVPCB_MAINFRAME::GetProjectFileParameters().

#define GROUP_SCH   wxT( "/eeschema" )
#define GROUP_SCH_EDITOR   wxT( "/schematic_editor" )
#define GROUP_SCH_LIBS   wxT( "/eeschema/libraries" )

(Now in fp lib tables)

Definition at line 50 of file config_params.h.

Referenced by PART_LIBS::LibNamesAndPaths().

Enumeration Type Documentation

Type of parameter in the configuration file.

Enumerator
PARAM_INT 
PARAM_INT_WITH_SCALE 
PARAM_SETCOLOR 
PARAM_DOUBLE 
PARAM_BOOL 
PARAM_LIBNAME_LIST 
PARAM_WXSTRING 
PARAM_FILENAME 
PARAM_COMMAND_ERASE 
PARAM_FIELDNAME_LIST 

Definition at line 71 of file config_params.h.

Function Documentation

void ConfigBaseWriteDouble ( wxConfigBase *  aConfig,
const wxString &  aKey,
double  aValue 
)

Function ConfigBaseWriteDouble This is a helper function to write doubles in config We cannot use wxConfigBase->Write for a double, because this function uses a format with very few digits in mantissa, and truncation issues are frequent.

We use here a better floating format.

Definition at line 125 of file config_params.cpp.

References Format().

Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), DIALOG_PLOT::applyPlotSettings(), DIALOG_PRINT_USING_PRINTER::OnCloseWindow(), PARAM_CFG_INT_WITH_SCALE::SaveParam(), and PARAM_CFG_DOUBLE::SaveParam().

126 {
127  // Use a single strategy, regardless of wx version.
128  // Want C locale float string.
129 
130  LOCALE_IO toggle;
131  wxString tnumber = wxString::Format( wxT( "%.16g" ), aValue );
132 
133  aConfig->Write( aKey, tnumber );
134 }
Class LOCALE_IO is a class that can be instantiated within a scope in which you are expecting excepti...
Definition: common.h:166
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
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 aCfg.

Only elements whose m_Setup field is false will be loaded.

Parameters
aCfgwhere to load from.
aListholds some configuration parameters, not all of which will necessarily be loaded.
aGroupindicates in which group the value should be saved, unless the PARAM_CFG_ARRAY element provides its own group, in which case it will take precedence. aGroup may be empty.

Definition at line 41 of file config_params.cpp.

Referenced by PROJECT::ConfigLoad().

43 {
44  wxASSERT( aCfg );
45 
46  for( const PARAM_CFG_BASE& param : aList )
47  {
48  if( !!param.m_Group )
49  aCfg->SetPath( param.m_Group );
50  else
51  aCfg->SetPath( aGroup );
52 
53  if( param.m_Setup )
54  continue;
55 
56  param.ReadParam( aCfg );
57  }
58 }
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
void wxConfigLoadSetups ( wxConfigBase *  aCfg,
const PARAM_CFG_ARRAY aList 
)

Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from aCfg.

Only elements whose m_Setup field is true will be loaded.

Parameters
aCfgwhere to load from.
aListholds some configuration parameters, not all of which will necessarily be loaded.

Definition at line 61 of file config_params.cpp.

Referenced by FOOTPRINT_EDIT_FRAME::LoadSettings(), SCH_EDIT_FRAME::LoadSettings(), PCB_EDIT_FRAME::LoadSettings(), GERBVIEW_FRAME::LoadSettings(), and SCH::IFACE::OnKifaceStart().

62 {
63  wxASSERT( aCfg );
64 
65  for( const PARAM_CFG_BASE& param : aList )
66  {
67  if( !param.m_Setup )
68  continue;
69 
70  param.ReadParam( aCfg );
71  }
72 }
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
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 aCfg.

Only elements with m_Setup set false will be saved, hence the function name.

Parameters
aCfgwhere to save
aListholds some configuration parameters, not all of which will necessarily be saved.
aGroupindicates in which group the value should be saved, unless the PARAM_CFG_ARRAY element provides its own group, in which case it will take precedence. aGroup may be empty.

Definition at line 75 of file config_params.cpp.

References PARAM_COMMAND_ERASE.

Referenced by PROJECT::ConfigSave().

77 {
78  wxASSERT( aCfg );
79 
80  for( const PARAM_CFG_BASE& param : aList )
81  {
82  if( !!param.m_Group )
83  aCfg->SetPath( param.m_Group );
84  else
85  aCfg->SetPath( aGroup );
86 
87  if( param.m_Setup )
88  continue;
89 
90  if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
91  {
92  if( !!param.m_Ident )
93  aCfg->DeleteGroup( param.m_Ident );
94  }
95  else
96  {
97  param.SaveParam( aCfg );
98  }
99  }
100 }
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
void wxConfigSaveSetups ( wxConfigBase *  aCfg,
const PARAM_CFG_ARRAY aList 
)

Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to aCfg.

Only elements with m_Setup set true will be saved, hence the function name.

Parameters
aCfgwhere to save
aListholds some configuration parameters, not all of which will necessarily be saved.

Definition at line 103 of file config_params.cpp.

References PARAM_COMMAND_ERASE.

Referenced by PL_EDITOR_FRAME::OnCloseWindow(), SCH::IFACE::OnKifaceEnd(), FOOTPRINT_EDIT_FRAME::SaveSettings(), PL_EDITOR_FRAME::SaveSettings(), SCH_EDIT_FRAME::SaveSettings(), PCB_EDIT_FRAME::SaveSettings(), and GERBVIEW_FRAME::SaveSettings().

104 {
105  wxASSERT( aCfg );
106 
107  for( const PARAM_CFG_BASE& param : aList )
108  {
109  if( !param.m_Setup )
110  continue;
111 
112  if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
113  {
114  if( !!param.m_Ident )
115  aCfg->DeleteGroup( param.m_Ident );
116  }
117  else
118  {
119  param.SaveParam( aCfg );
120  }
121  }
122 }
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94