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

Functions

KICOMMON_API 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.
 
KICOMMON_API 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.
 
KICOMMON_API 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.
 
KICOMMON_API 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.
 
KICOMMON_API 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)
 
KICOMMON_API wxString MessageTextFromValue (EDA_ANGLE aValue, bool aAddUnitLabel=true)
 
KICOMMON_API wxString MessageTextFromMinOptMax (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const MINOPTMAX< int > &aValue)
 
KICOMMON_API double FromUserUnit (const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
 Return in internal units the value aValue given in a real unit such as "in", "mm", or "deg".
 
KICOMMON_API 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.
 
KICOMMON_API double DoubleValueFromString (const wxString &aTextValue)
 
KICOMMON_API 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.
 
KICOMMON_API 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 572 of file eda_units.cpp.

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

Referenced by UNITS_PROVIDER::AngleValueFromString(), PCBEXPR_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(), GRID::MessageText(), PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset(), PANEL_PREVIEW_3D_MODEL::onMouseWheelRot(), PANEL_PREVIEW_3D_MODEL::onMouseWheelScale(), PANEL_PREVIEW_3D_MODEL::onUnitsChanged(), COMMON_TOOLS::Reset(), rotationFromString(), GRID::ToDouble(), PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow(), DIALOG_IMPORT_GFX_SCH::TransferDataFromWindow(), DIALOG_CREATE_ARRAY::TransferDataFromWindow(), DIALOG_IMPORT_GRAPHICS::TransferDataFromWindow(), PANEL_PREVIEW_3D_MODEL::updateOrientation(), ValueFromString(), UNITS_PROVIDER::ValueFromString(), DIALOG_IMPORT_GFX_SCH::~DIALOG_IMPORT_GFX_SCH(), and DIALOG_IMPORT_GRAPHICS::~DIALOG_IMPORT_GRAPHICS().

◆ DoubleValueFromString() [2/2]

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

Definition at line 535 of file eda_units.cpp.

◆ FromUserUnit()

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

◆ MessageTextFromMinOptMax()

wxString EDA_UNIT_UTILS::UI::MessageTextFromMinOptMax ( const EDA_IU_SCALE aIuScale,
EDA_UNITS  aUnits,
const MINOPTMAX< int > &  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 404 of file eda_units.cpp.

References AREA, CENTIMETRES, DEGREES, DISTANCE, EDA_UNIT_UTILS::GetText(), INCHES, EDA_IU_SCALE::IU_PER_MM, KI_FALLTHROUGH, MICROMETRES, MILLIMETRES, MILS, SCH_IU_PER_MM, text, ToUserUnit(), UNITLESS, UNSCALED, and VOLUME.

Referenced by EDIT_TOOL::DragArcTrack(), DRC_ENGINE::EvalRules(), DS_DRAW_ITEM_BASE::GetMsgPanelInfo(), GRID::MessageText(), MessageTextFromMinOptMax(), MessageTextFromValue(), UNITS_PROVIDER::MessageTextFromValue(), EDA_SHAPE::ShapeGetMsgPanelInfo(), and PCB_TUNING_PATTERN::Update().

◆ 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 375 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 385 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 394 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 300 of file eda_units.cpp.

References AREA, DISTANCE, EDA_UNIT_UTILS::GetText(), INCHES, EDA_IU_SCALE::IU_PER_MM, KI_FALLTHROUGH, MILS, removeTrailingZeros(), SCH_IU_PER_MM, text, ToUserUnit(), UNITLESS, 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(), PCB_IO_EAGLE::loadClasses(), PANEL_3D_RAYTRACING_OPTIONS::loadSettings(), FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy(), PCBNEW_SETTINGS::MigrateFromLegacy(), PANEL_SETUP_BOARD_STACKUP::onUnitsChanged(), UNIT_BINDER::SetDoubleValue(), UNIT_BINDER::SetValue(), UNITS_PROVIDER::StringFromValue(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), 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 259 of file eda_units.cpp.

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

Referenced by ComboBoxUnits(), KIGFX::PREVIEW::DimensionLabel(), PL_EDITOR_FRAME::DisplayGridMsg(), RC_ITEM::GetJsonViolation(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetValueText(), MessageTextFromValue(), UNIT_BINDER::setPrecision(), StringFromValue(), toMM(), 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 667 of file eda_units.cpp.

References DoubleValueFromString().

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

◆ ValueFromString() [2/2]

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

Definition at line 676 of file eda_units.cpp.

References DoubleValueFromString().