KiCad PCB EDA Suite
Loading...
Searching...
No Matches
EDA_UNIT_UTILS::UI Namespace Reference

Functions

double ToUserUnit (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
 Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit. More...
 
wxString StringFromValue (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Returns the string from aValue according to aUnits (inch, mm ...) for display. More...
 
wxString MessageTextFromValue (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units. More...
 
wxString MessageTextFromValue (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, int aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Convert a value to a string using double notation. More...
 
wxString MessageTextFromValue (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, long long int aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 
wxString MessageTextFromValue (EDA_ANGLE aValue, bool aAddUnitLabel=true)
 
double FromUserUnit (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
 Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg". More...
 
double DoubleValueFromString (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Function DoubleValueFromString converts aTextValue to a double. More...
 
double DoubleValueFromString (const wxString &aTextValue)
 
long long int ValueFromString (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Function ValueFromString converts aTextValue in aUnits to internal units used by the application. More...
 
long long int ValueFromString (const wxString &aTextValue)
 

Function Documentation

◆ DoubleValueFromString() [1/2]

double EDA_UNIT_UTILS::UI::DoubleValueFromString ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnits,
const wxString &  aTextValue,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

Function DoubleValueFromString converts aTextValue to a double.

Warning
This utilizes the current locale and will break if decimal formats differ
Parameters
aIuScaleThe internal units scale for the current frame/app.
aUnitsThe units of aTextValue.
aTextValueA reference to a wxString object containing the string to convert.
Returns
A double representing that value in internal units

Definition at line 445 of file eda_units.cpp.

References AREA, DEGREES, DISTANCE, FromUserUnit(), INCHES, KI_FALLTHROUGH, MILLIMETRES, MILS, and VOLUME.

Referenced by UNITS_PROVIDER::AngleValueFromString(), GRID_MENU::BuildChoiceList(), PCB_UNIT_RESOLVER::Convert(), PROPERTIES_FRAME::CopyPrmsFromPanelToItem(), PANEL_PREVIEW_3D_MODEL::doIncrementOffset(), PANEL_PREVIEW_3D_MODEL::doIncrementRotation(), PANEL_PREVIEW_3D_MODEL::doIncrementScale(), LIBEVAL::COMPILER::generateUCode(), UNIT_BINDER::GetDoubleValue(), DIALOG_BOARD_REANNOTATE::GetParameters(), DIALOG_EXPORT_STEP::GetXOrg(), DIALOG_EXPORT_IDF3::GetXRef(), DIALOG_EXPORT_3DFILE::GetXRef(), DIALOG_EXPORT_STEP::GetYOrg(), DIALOG_EXPORT_IDF3::GetYRef(), DIALOG_EXPORT_3DFILE::GetYRef(), FOOTPRINT_PREVIEW_PANEL::New(), PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset(), PANEL_PREVIEW_3D_MODEL::onMouseWheelRot(), PANEL_PREVIEW_3D_MODEL::onMouseWheelScale(), PANEL_PREVIEW_3D_MODEL::onUnitsChanged(), COMMON_TOOLS::Reset(), rotationFromString(), PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow(), DIALOG_CREATE_ARRAY::TransferDataFromWindow(), DIALOG_IMPORT_GFX::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_TRANSFORM::Transform(), PANEL_PREVIEW_3D_MODEL::updateOrientation(), ValueFromString(), UNITS_PROVIDER::ValueFromString(), and DIALOG_IMPORT_GFX::~DIALOG_IMPORT_GFX().

◆ DoubleValueFromString() [2/2]

double EDA_UNIT_UTILS::UI::DoubleValueFromString ( const wxString &  aTextValue)

Definition at line 408 of file eda_units.cpp.

◆ FromUserUnit()

double EDA_UNIT_UTILS::UI::FromUserUnit ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnit,
double  aValue 
)

◆ MessageTextFromValue() [1/4]

wxString EDA_UNIT_UTILS::UI::MessageTextFromValue ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnits,
double  aValue,
bool  aAddUnitsText = true,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.

Should be used only to display a coordinate in status, but not in dialogs, files, etc., because the mantissa of the number displayed has 4 digits max for readability. The actual internal value could need up to 8 digits to preserve precision.

Parameters
aUnitsUnits (INCHES, MILLIMETRE ..)
aValueThe double value to convert.
aAddUnitsTextIf true, adds the unit label to the end of the string
aTypeDISTANCE, AREA, or VOLUME
Returns
The converted string for display in user interface elements.

Definition at line 315 of file eda_units.cpp.

References AREA, DEGREES, DISTANCE, EDA_UNIT_UTILS::GetText(), INCHES, KI_FALLTHROUGH, MILLIMETRES, MILS, text, ToUserUnit(), UNSCALED, and VOLUME.

Referenced by GRID_MENU::BuildChoiceList(), DIALOG_PAD_PROPERTIES::displayPrimitivesList(), EDIT_TOOL::DragArcTrack(), DRC_ENGINE::EvalRules(), formatCoord(), DS_DRAW_ITEM_BASE::GetMsgPanelInfo(), MessageTextFromValue(), UNITS_PROVIDER::MessageTextFromValue(), EDA_SHAPE::ShapeGetMsgPanelInfo(), PNS::DP_MEANDER_PLACER::TuningInfo(), PNS::MEANDER_PLACER::TuningInfo(), and PNS::MEANDER_SKEW_PLACER::TuningInfo().

◆ MessageTextFromValue() [2/4]

wxString EDA_UNIT_UTILS::UI::MessageTextFromValue ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnits,
int  aValue,
bool  aAddUnitLabel = true,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

Convert a value to a string using double notation.

For readability, the mantissa has 0, 1, 3 or 4 digits, depending on units for unit = inch the mantissa has 3 digits (Eeschema) or 4 digits for unit = mil the mantissa has 0 digits (Eeschema) or 1 digits for unit = mm the mantissa has 3 digits (Eeschema) or 4 digits Should be used only to display info in status, but not in dialogs, because 4 digits only could truncate the actual value

Definition at line 286 of file eda_units.cpp.

References MessageTextFromValue().

◆ MessageTextFromValue() [3/4]

wxString EDA_UNIT_UTILS::UI::MessageTextFromValue ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnits,
long long int  aValue,
bool  aAddUnitLabel = true,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

Definition at line 296 of file eda_units.cpp.

References MessageTextFromValue().

◆ MessageTextFromValue() [4/4]

wxString EDA_UNIT_UTILS::UI::MessageTextFromValue ( EDA_ANGLE  aValue,
bool  aAddUnitLabel = true 
)

Definition at line 305 of file eda_units.cpp.

References EDA_ANGLE::AsDegrees().

◆ StringFromValue()

wxString EDA_UNIT_UTILS::UI::StringFromValue ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnits,
double  aValue,
bool  aAddUnitsText = false,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

Returns the string from aValue according to aUnits (inch, mm ...) for display.

Convert a value to a string using double notation.

For readability, if the mantissa has 3 or more digits then any trailing 0's are removed. This function should be used to display values in dialogs because a value entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa to preserve precision.

Parameters
aUnitsUnits (INCHES, MILLIMETRE ..)
aValueValue in internal units
aAddUnitsTextAdd units text with appropriate separators
aTypeDISTANCE, AREA, or VOLUME
Returns
A wxString object containing value and optionally the symbol unit (like 2.000 mm)

For readability, the mantissa has 3 or more digits, the trailing 0 are removed if the mantissa has more than 3 digits and some trailing 0 This function should be used to display values in dialogs because a value entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa if displayed in inch to avoid truncation or rounding made just by the printf function. otherwise the actual value is rounded when read from dialog and converted in internal units, and therefore modified.

Definition at line 225 of file eda_units.cpp.

References AREA, DISTANCE, EDA_UNIT_UTILS::GetText(), KI_FALLTHROUGH, ToUserUnit(), and VOLUME.

Referenced by BuildStackupReport(), UNIT_BINDER::ChangeDoubleValue(), UNIT_BINDER::ChangeValue(), DRAWING_TOOL::DrawBoardCharacteristics(), DRAWING_TOOL::DrawSpecificationStackup(), PANEL_SETUP_FORMATTING::ImportSettingsFrom(), DIALOG_PLOT::init_Dialog(), EAGLE_PLUGIN::loadClasses(), PANEL_3D_RAYTRACING_OPTIONS::loadSettings(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), PCBNEW_SETTINGS::MigrateFromLegacy(), UNIT_BINDER::SetDoubleValue(), UNIT_BINDER::SetValue(), UNITS_PROVIDER::StringFromValue(), and UNIT_BINDER::Validate().

◆ ToUserUnit()

double EDA_UNIT_UTILS::UI::ToUserUnit ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnit,
double  aValue 
)

Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit.

Returns
The converted value, in double
Parameters
aUnitThe units to convert aValue to.
aValueThe value in internal units to convert.

Definition at line 190 of file eda_units.cpp.

References DEGREES, INCHES, IU_TO_IN, IU_TO_MILS, IU_TO_MM, MILLIMETRES, and MILS.

Referenced by ComboBoxUnits(), PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral(), PROPERTIES_FRAME::CopyPrmsFromPanelToItem(), KIGFX::PREVIEW::DimensionLabel(), PL_EDITOR_FRAME::DisplayGridMsg(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetValueText(), MessageTextFromValue(), UNIT_BINDER::setPrecision(), StringFromValue(), and PL_EDITOR_FRAME::UpdateStatusBar().

◆ ValueFromString() [1/2]

long long int EDA_UNIT_UTILS::UI::ValueFromString ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnits,
const wxString &  aTextValue,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

Function ValueFromString converts aTextValue in aUnits to internal units used by the application.

Warning
This utilizes the current locale and will break if decimal formats differ
Parameters
aIuScaleThe internal units scale for the current frame/app.
aUnitsThe units of aTextValue.
aTextValueA reference to a wxString object containing the string to convert.
Returns
A long long int representing that value in internal units

Definition at line 525 of file eda_units.cpp.

References DoubleValueFromString().

Referenced by DIALOG_ANNOTATE::GetStartNumber(), UNIT_BINDER::GetValue(), and PANEL_EESCHEMA_ANNOTATION_OPTIONS::TransferDataFromWindow().

◆ ValueFromString() [2/2]

long long int EDA_UNIT_UTILS::UI::ValueFromString ( const wxString &  aTextValue)

Definition at line 534 of file eda_units.cpp.

References DoubleValueFromString().