KiCad PCB EDA Suite
PARAM_CFG_INT_WITH_SCALE Class Reference

Configuration parameter - Integer Class with unit conversion. More...

#include <config_params.h>

Inheritance diagram for PARAM_CFG_INT_WITH_SCALE:
PARAM_CFG_INT PARAM_CFG_BASE

Public Member Functions

 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, const wxString &legacy_ident=wxEmptyString)
 
 PARAM_CFG_INT_WITH_SCALE (bool insetup, 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, const wxString &legacy_ident=wxEmptyString)
 
virtual void ReadParam (wxConfigBase *aConfig) const override
 Function ReadParam reads the value of the parameter stored in aConfig. More...
 
virtual void SaveParam (wxConfigBase *aConfig) const override
 Function SaveParam saves the value of the parameter stored in aConfig. More...
 

Public Attributes

double m_BIU_to_cfgunit
 the factor to convert the saved value in internal value More...
 
int * m_Pt_param
 Pointer to the parameter value. More...
 
int m_Min
 
int m_Max
 Minimum and maximum values of the param type. More...
 
int m_Default
 The default value of the parameter. More...
 
wxString m_Ident
 Keyword in config data. More...
 
paramcfg_id m_Type
 Type of parameter. More...
 
wxString m_Group
 Group name (this is like a path in the config data) More...
 
bool m_Setup
 Install or Project based parameter, true == install. More...
 
wxString m_Ident_legacy
 

Detailed Description

Configuration parameter - Integer Class with unit conversion.

Mainly used to store an integer value in millimeters (or inches) and retrieve it in internal units the stored value is a floating number

Definition at line 166 of file config_params.h.

Constructor & Destructor Documentation

PARAM_CFG_INT_WITH_SCALE::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,
const wxString &  legacy_ident = wxEmptyString 
)

Definition at line 198 of file config_params.cpp.

References m_BIU_to_cfgunit, PARAM_CFG_BASE::m_Type, and PARAM_INT_WITH_SCALE.

201  :
202  PARAM_CFG_INT( ident, ptparam, default_val, min, max, group, legacy_ident )
203 {
205  m_BIU_to_cfgunit = aBiu2cfgunit;
206 }
double m_BIU_to_cfgunit
the factor to convert the saved value in internal value
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=nullptr, const wxString &legacy_ident=wxEmptyString)
#define max(a, b)
Definition: auxiliary.h:86
paramcfg_id m_Type
Type of parameter.
#define min(a, b)
Definition: auxiliary.h:85
PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE ( bool  insetup,
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,
const wxString &  legacy_ident = wxEmptyString 
)

Definition at line 209 of file config_params.cpp.

References m_BIU_to_cfgunit, PARAM_CFG_BASE::m_Type, and PARAM_INT_WITH_SCALE.

212  :
213  PARAM_CFG_INT( setup, ident, ptparam, default_val, min, max, group, legacy_ident )
214 {
216  m_BIU_to_cfgunit = aBiu2cfgunit;
217 }
double m_BIU_to_cfgunit
the factor to convert the saved value in internal value
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=nullptr, const wxString &legacy_ident=wxEmptyString)
#define max(a, b)
Definition: auxiliary.h:86
paramcfg_id m_Type
Type of parameter.
#define min(a, b)
Definition: auxiliary.h:85

Member Function Documentation

void PARAM_CFG_INT_WITH_SCALE::ReadParam ( wxConfigBase *  aConfig) const
overridevirtual

Function ReadParam reads the value of the parameter stored in aConfig.

Parameters
aConfig= the wxConfigBase that holds the parameter

Reimplemented from PARAM_CFG_INT.

Definition at line 220 of file config_params.cpp.

References KiROUND(), m_BIU_to_cfgunit, PARAM_CFG_INT::m_Default, PARAM_CFG_BASE::m_Ident, PARAM_CFG_BASE::m_Ident_legacy, PARAM_CFG_INT::m_Max, PARAM_CFG_INT::m_Min, and PARAM_CFG_INT::m_Pt_param.

221 {
222  if( !m_Pt_param || !aConfig )
223  return;
224 
225  double dtmp = (double) m_Default * m_BIU_to_cfgunit;
226  if( !aConfig->Read( m_Ident, &dtmp ) && m_Ident_legacy != wxEmptyString )
227  aConfig->Read( m_Ident_legacy, &dtmp );
228 
229  int itmp = KiROUND( dtmp / m_BIU_to_cfgunit );
230 
231  if( (itmp < m_Min) || (itmp > m_Max) )
232  itmp = m_Default;
233 
234  *m_Pt_param = itmp;
235 }
wxString m_Ident_legacy
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
int m_Default
The default value of the parameter.
int * m_Pt_param
Pointer to the parameter value.
double m_BIU_to_cfgunit
the factor to convert the saved value in internal value
int m_Max
Minimum and maximum values of the param type.
wxString m_Ident
Keyword in config data.
void PARAM_CFG_INT_WITH_SCALE::SaveParam ( wxConfigBase *  aConfig) const
overridevirtual

Function SaveParam saves the value of the parameter stored in aConfig.

Parameters
aConfig= the wxConfigBase that can store the parameter

Reimplemented from PARAM_CFG_INT.

Definition at line 238 of file config_params.cpp.

References ConfigBaseWriteDouble(), m_BIU_to_cfgunit, PARAM_CFG_BASE::m_Ident, and PARAM_CFG_INT::m_Pt_param.

239 {
240  if( !m_Pt_param || !aConfig )
241  return;
242 
243  // We cannot use aConfig->Write for a double, because
244  // this function uses a format with very few digits in mantissa,
245  // and truncature issues are frequent.
246  // We uses our function.
248 }
int * m_Pt_param
Pointer to the parameter value.
double m_BIU_to_cfgunit
the factor to convert the saved value in internal value
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_Ident
Keyword in config data.

Member Data Documentation

double PARAM_CFG_INT_WITH_SCALE::m_BIU_to_cfgunit

the factor to convert the saved value in internal value

Definition at line 169 of file config_params.h.

Referenced by PARAM_CFG_INT_WITH_SCALE(), ReadParam(), and SaveParam().

int PARAM_CFG_INT::m_Default
inherited

The default value of the parameter.

Definition at line 141 of file config_params.h.

Referenced by PARAM_CFG_INT::PARAM_CFG_INT(), PARAM_CFG_INT::ReadParam(), and ReadParam().

wxString PARAM_CFG_BASE::m_Group
inherited

Group name (this is like a path in the config data)

Definition at line 104 of file config_params.h.

Referenced by PARAM_CFG_BASE::PARAM_CFG_BASE().

wxString PARAM_CFG_BASE::m_Ident_legacy
inherited
int PARAM_CFG_INT::m_Max
inherited

Minimum and maximum values of the param type.

Definition at line 140 of file config_params.h.

Referenced by PARAM_CFG_INT::PARAM_CFG_INT(), PARAM_CFG_INT::ReadParam(), and ReadParam().

int PARAM_CFG_INT::m_Min
inherited
int* PARAM_CFG_INT::m_Pt_param
inherited

Pointer to the parameter value.

Definition at line 139 of file config_params.h.

Referenced by PARAM_CFG_INT::PARAM_CFG_INT(), PARAM_CFG_INT::ReadParam(), ReadParam(), PARAM_CFG_INT::SaveParam(), and SaveParam().

bool PARAM_CFG_BASE::m_Setup
inherited
paramcfg_id PARAM_CFG_BASE::m_Type
inherited

Type of parameter.

Definition at line 103 of file config_params.h.

Referenced by PARAM_CFG_BASE::PARAM_CFG_BASE(), and PARAM_CFG_INT_WITH_SCALE().


The documentation for this class was generated from the following files: