KiCad PCB EDA Suite
config_params.h File Reference
#include <set>
#include <limits>
#include <wx/confbase.h>
#include <wx/fileconf.h>
#include <boost/ptr_container/ptr_vector.hpp>
#include <gal/color4d.h>

Go to the source code of this file.

Classes

class  PARAM_CFG
 PARAM_CFG 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_WXSTRING_SET
 Configuration parameter - std::set<wxString> 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
 

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_EDIT   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 GROUP_SHEET_NAMES   wxT( "/sheetnames" )
 
#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_WXSTRING_SET,
  PARAM_FILENAME, PARAM_COMMAND_ERASE, PARAM_LAYERS, PARAM_TRACKWIDTHS,
  PARAM_VIADIMENSIONS, PARAM_DIFFPAIRDIMENSIONS, PARAM_NETCLASSES, PARAM_SEVERITIES
}
 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 std::vector< PARAM_CFG * > &aList)
 Function wxConfigSaveSetups writes aList of PARAM_CFG to save configuration values to aCfg. More...
 
void wxConfigSaveParams (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
 Function wxConfigSaveParams writes aList of PARAM_CFG to save configuration values to aCfg. More...
 
void wxConfigLoadSetups (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
 Function wxConfigLoadSetups uses aList of PARAM_CFG to load configuration values from aCfg. More...
 
void wxConfigLoadParams (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
 Function wxConfigLoadParams uses aList of PARAM_CFG to load configuration values from aCfg. More...
 

Macro Definition Documentation

◆ CONFIG_VERSION

#define CONFIG_VERSION   1

Definition at line 54 of file config_params.h.

◆ GROUP_CVP

#define GROUP_CVP   wxT( "/cvpcb" )

Definition at line 49 of file config_params.h.

◆ GROUP_CVP_EQU

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

Definition at line 50 of file config_params.h.

◆ GROUP_PCB

#define GROUP_PCB   wxT( "/pcbnew" )

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

Definition at line 40 of file config_params.h.

◆ GROUP_PCB_LIBS

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

(and few for component editor).

Does not store libs list

Definition at line 45 of file config_params.h.

◆ GROUP_SCH

#define GROUP_SCH   wxT( "/eeschema" )

Definition at line 41 of file config_params.h.

◆ GROUP_SCH_EDIT

#define GROUP_SCH_EDIT   wxT( "/schematic_editor" )

Definition at line 42 of file config_params.h.

◆ GROUP_SCH_LIBS

#define GROUP_SCH_LIBS   wxT( "/eeschema/libraries" )

(Now in fp lib tables)

Definition at line 47 of file config_params.h.

◆ GROUP_SHEET_NAMES

#define GROUP_SHEET_NAMES   wxT( "/sheetnames" )

Definition at line 52 of file config_params.h.

Enumeration Type Documentation

◆ paramcfg_id

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_WXSTRING_SET 
PARAM_FILENAME 
PARAM_COMMAND_ERASE 
PARAM_LAYERS 
PARAM_TRACKWIDTHS 
PARAM_VIADIMENSIONS 
PARAM_DIFFPAIRDIMENSIONS 
PARAM_NETCLASSES 
PARAM_SEVERITIES 

Definition at line 69 of file config_params.h.

Function Documentation

◆ ConfigBaseWriteDouble()

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 120 of file config_params.cpp.

121 {
122  // Use a single strategy, regardless of wx version.
123  // Want C locale float string.
124 
125  LOCALE_IO toggle;
126  wxString tnumber = wxString::Format( wxT( "%.16g" ), aValue );
127 
128  aConfig->Write( aKey, tnumber );
129 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:202
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

References Format().

Referenced by PARAM_CFG_INT_WITH_SCALE::SaveParam(), and PARAM_CFG_DOUBLE::SaveParam().

◆ wxConfigLoadParams()

void wxConfigLoadParams ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList,
const wxString &  aGroup 
)

Function wxConfigLoadParams uses aList of PARAM_CFG 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 provides its own group, in which case it will take precedence. aGroup may be empty.

Definition at line 36 of file config_params.cpp.

38 {
39  wxASSERT( aCfg );
40 
41  for( PARAM_CFG* param : aList )
42  {
43  if( !!param->m_Group )
44  aCfg->SetPath( param->m_Group );
45  else
46  aCfg->SetPath( aGroup );
47 
48  if( param->m_Setup )
49  continue;
50 
51  param->ReadParam( aCfg );
52  }
53 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:98

Referenced by PROJECT::ConfigLoad(), DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction(), and DIALOG_BOARD_SETUP::OnAuxiliaryAction().

◆ wxConfigLoadSetups()

void wxConfigLoadSetups ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList 
)

Function wxConfigLoadSetups uses aList of PARAM_CFG 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 56 of file config_params.cpp.

57 {
58  wxASSERT( aCfg );
59 
60  for( PARAM_CFG* param : aList )
61  {
62  if( !param->m_Setup )
63  continue;
64 
65  param->ReadParam( aCfg );
66  }
67 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:98

Referenced by ADVANCED_CFG::loadSettings().

◆ wxConfigSaveParams()

void wxConfigSaveParams ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList,
const wxString &  aGroup 
)

Function wxConfigSaveParams writes aList of PARAM_CFG 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 provides its own group, in which case it will take precedence. aGroup may be empty.

Definition at line 70 of file config_params.cpp.

72 {
73  wxASSERT( aCfg );
74 
75  for( PARAM_CFG* param : aList )
76  {
77  if( !!param->m_Group )
78  aCfg->SetPath( param->m_Group );
79  else
80  aCfg->SetPath( aGroup );
81 
82  if( param->m_Setup )
83  continue;
84 
85  if( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
86  {
87  if( !!param->m_Ident )
88  aCfg->DeleteGroup( param->m_Ident );
89  }
90  else
91  {
92  param->SaveParam( aCfg );
93  }
94  }
95 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:98

References PARAM_COMMAND_ERASE.

Referenced by PROJECT::ConfigSave().

◆ wxConfigSaveSetups()

void wxConfigSaveSetups ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList 
)

Function wxConfigSaveSetups writes aList of PARAM_CFG 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 98 of file config_params.cpp.

99 {
100  wxASSERT( aCfg );
101 
102  for( PARAM_CFG* param : aList )
103  {
104  if( !param->m_Setup )
105  continue;
106 
107  if( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
108  {
109  if( !!param->m_Ident )
110  aCfg->DeleteGroup( param->m_Ident );
111  }
112  else
113  {
114  param->SaveParam( aCfg );
115  }
116  }
117 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:98

References PARAM_COMMAND_ERASE.