KiCad PCB EDA Suite
PARAM_CFG_INT_WITH_SCALE Class Reference

Configuration for integers with unit conversion. More...

#include <config_params.h>

Inheritance diagram for PARAM_CFG_INT_WITH_SCALE:
PARAM_CFG_INT PARAM_CFG

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=nullptr, 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=nullptr, double aBiu2cfgunit=1.0, const wxString &legacy_ident=wxEmptyString)
 
virtual void ReadParam (wxConfigBase *aConfig) const override
 Read the value of the parameter stored in aConfig. More...
 
virtual void SaveParam (wxConfigBase *aConfig) const override
 Save 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 for integers 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 144 of file config_params.h.

Constructor & Destructor Documentation

◆ PARAM_CFG_INT_WITH_SCALE() [1/2]

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 = nullptr,
double  aBiu2cfgunit = 1.0,
const wxString &  legacy_ident = wxEmptyString 
)

Definition at line 191 of file config_params.cpp.

194 :
195 PARAM_CFG_INT( ident, ptparam, default_val, min, max, group, legacy_ident )
196{
198 m_BIU_to_cfgunit = aBiu2cfgunit;
199}
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)
paramcfg_id m_Type
Type of parameter.
@ PARAM_INT_WITH_SCALE
Definition: config_params.h:56

References group, m_BIU_to_cfgunit, PARAM_CFG::m_Type, and PARAM_INT_WITH_SCALE.

◆ PARAM_CFG_INT_WITH_SCALE() [2/2]

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 = nullptr,
double  aBiu2cfgunit = 1.0,
const wxString &  legacy_ident = wxEmptyString 
)

Definition at line 202 of file config_params.cpp.

205 :
206 PARAM_CFG_INT( setup, ident, ptparam, default_val, min, max, group, legacy_ident )
207{
209 m_BIU_to_cfgunit = aBiu2cfgunit;
210}

References group, m_BIU_to_cfgunit, PARAM_CFG::m_Type, and PARAM_INT_WITH_SCALE.

Member Function Documentation

◆ ReadParam()

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

Read the value of the parameter stored in aConfig.

Parameters
aConfigthe wxConfigBase that holds the parameter.

Reimplemented from PARAM_CFG_INT.

Definition at line 213 of file config_params.cpp.

214{
215 if( !m_Pt_param || !aConfig )
216 return;
217
218 double dtmp = (double) m_Default * m_BIU_to_cfgunit;
219 if( !aConfig->Read( m_Ident, &dtmp ) && m_Ident_legacy != wxEmptyString )
220 aConfig->Read( m_Ident_legacy, &dtmp );
221
222 int itmp = KiROUND( dtmp / m_BIU_to_cfgunit );
223
224 if( (itmp < m_Min) || (itmp > m_Max) )
225 itmp = m_Default;
226
227 *m_Pt_param = itmp;
228}
int m_Max
Minimum and maximum values of the param type.
int m_Default
The default value of the parameter.
int * m_Pt_param
Pointer to the parameter value.
wxString m_Ident_legacy
wxString m_Ident
Keyword in config data.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

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

◆ SaveParam()

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

Save the value of the parameter stored in aConfig.

Parameters
aConfigthe wxConfigBase that can store the parameter.

Reimplemented from PARAM_CFG_INT.

Definition at line 231 of file config_params.cpp.

232{
233 if( !m_Pt_param || !aConfig )
234 return;
235
236 // We cannot use aConfig->Write for a double, because
237 // this function uses a format with very few digits in mantissa,
238 // and truncature issues are frequent.
239 // We uses our function.
241}
void ConfigBaseWriteDouble(wxConfigBase *aConfig, const wxString &aKey, double aValue)
A helper function to write doubles in configuration file.

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

Member Data Documentation

◆ m_BIU_to_cfgunit

double PARAM_CFG_INT_WITH_SCALE::m_BIU_to_cfgunit

the factor to convert the saved value in internal value

Definition at line 163 of file config_params.h.

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

◆ m_Default

int PARAM_CFG_INT::m_Default
inherited

The default value of the parameter.

Definition at line 135 of file config_params.h.

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

◆ m_Group

wxString PARAM_CFG::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::PARAM_CFG().

◆ m_Ident

◆ m_Ident_legacy

wxString PARAM_CFG::m_Ident_legacy
inherited

◆ m_Max

int PARAM_CFG_INT::m_Max
inherited

Minimum and maximum values of the param type.

Definition at line 134 of file config_params.h.

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

◆ m_Min

int PARAM_CFG_INT::m_Min
inherited

◆ m_Pt_param

int* PARAM_CFG_INT::m_Pt_param
inherited

Pointer to the parameter value.

Definition at line 133 of file config_params.h.

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

◆ m_Setup

◆ m_Type

paramcfg_id PARAM_CFG::m_Type
inherited

Type of parameter.

Definition at line 103 of file config_params.h.

Referenced by dumpParamCfg(), PARAM_CFG::PARAM_CFG(), and PARAM_CFG_INT_WITH_SCALE().


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