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

Namespaces

namespace  UI
 

Functions

KICOMMON_API bool IsImperialUnit (EDA_UNITS aUnit)
 
KICOMMON_API bool IsMetricUnit (EDA_UNITS aUnit)
 
KICOMMON_API int Mm2mils (double aVal)
 Convert mm to mils.
 
KICOMMON_API int Mils2mm (double aVal)
 Convert mils to mm.
 
KICOMMON_API bool FetchUnitsFromString (const wxString &aTextValue, EDA_UNITS &aUnits)
 Writes any unit info found in the string to aUnits.
 
KICOMMON_API wxString GetText (EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Get the units string for a given units type.
 
KICOMMON_API wxString GetLabel (EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Get the units string for a given units type.
 
KICOMMON_API std::string FormatAngle (const EDA_ANGLE &aAngle)
 Converts aAngle from board units to a string appropriate for writing to file.
 
KICOMMON_API std::string FormatInternalUnits (const EDA_IU_SCALE &aIuScale, int aValue)
 Converts aValue from internal units to a string appropriate for writing to file.
 
KICOMMON_API std::string FormatInternalUnits (const EDA_IU_SCALE &aIuScale, const VECTOR2I &aPoint)
 
constexpr int Mils2IU (const EDA_IU_SCALE &aIuScale, int mils)
 

Function Documentation

◆ FetchUnitsFromString()

bool EDA_UNIT_UTILS::FetchUnitsFromString ( const wxString &  aTextValue,
EDA_UNITS aUnits 
)

Writes any unit info found in the string to aUnits.

Returns
true - when unit was found, false - when unit could not be determined

Definition at line 88 of file eda_units.cpp.

References CENTIMETRES, DEGREES, INCHES, MICROMETRES, MILLIMETRES, and MILS.

Referenced by PCB_IO_KICAD_SEXPR_PARSER::parseDIMENSION().

◆ FormatAngle()

std::string EDA_UNIT_UTILS::FormatAngle ( const EDA_ANGLE aAngle)

Converts aAngle from board units to a string appropriate for writing to file.

This should only be used for writing to files as it ignores locale

Note
Internal angles for board items can be either degrees or tenths of degree on how KiCad is built.
Parameters
aAngleA angle value to convert.
Returns
std::string object containing the converted angle.

Definition at line 161 of file eda_units.cpp.

References EDA_ANGLE::AsDegrees().

Referenced by PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::formatRenderCache(), SCH_IO_KICAD_SEXPR::saveField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin(), SCH_IO_KICAD_SEXPR::saveSheet(), SCH_IO_KICAD_SEXPR::saveSymbol(), SCH_IO_KICAD_SEXPR::saveText(), SCH_IO_KICAD_SEXPR::saveTextBox(), and SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox().

◆ FormatInternalUnits() [1/2]

std::string EDA_UNIT_UTILS::FormatInternalUnits ( const EDA_IU_SCALE aIuScale,
const VECTOR2I aPoint 
)

Definition at line 202 of file eda_units.cpp.

References FormatInternalUnits(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ FormatInternalUnits() [2/2]

std::string EDA_UNIT_UTILS::FormatInternalUnits ( const EDA_IU_SCALE aIuScale,
int  aValue 
)

◆ GetLabel()

wxString EDA_UNIT_UTILS::GetLabel ( EDA_UNITS  aUnits,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

Get the units string for a given units type.

This version is for setting a wxStaticText label.

Parameters
aUnitsThe units requested.
aTypeDISTANCE, AREA, or VOLUME
Returns
The human readable units string.

Definition at line 155 of file eda_units.cpp.

References GetText().

Referenced by UNIT_BINDER::ChangeValue(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PCB_NET_INSPECTOR_PANEL::generateReport(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), UNIT_BINDER::onKillFocus(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), UNIT_BINDER::SetDataType(), UNIT_BINDER::SetUnits(), UNIT_BINDER::SetValue(), UNIT_BINDER::UNIT_BINDER(), ERC_REPORT::WriteJsonReport(), and DRC_REPORT::WriteJsonReport().

◆ GetText()

wxString EDA_UNIT_UTILS::GetText ( EDA_UNITS  aUnits,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)

Get the units string for a given units type.

This version is for appending to a value string.

Parameters
aUnitsThe units requested.
aTypeDISTANCE, AREA, or VOLUME
Returns
The human readable units string with appropriate separators.

Definition at line 126 of file eda_units.cpp.

References AREA, CENTIMETRES, DEGREES, DISTANCE, INCHES, MICROMETRES, MILLIMETRES, MILS, PERCENT, UNIMPLEMENTED_FOR, UNSCALED, and VOLUME.

Referenced by ComboBoxUnits(), KIGFX::PREVIEW::DimensionLabel(), PANEL_PREVIEW_3D_MODEL::formatOffsetValue(), PANEL_PREVIEW_3D_MODEL::formatRotationValue(), GetLabel(), EDA_UNIT_UTILS::UI::MessageTextFromValue(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), PCB_FIELDS_GRID_TABLE::PCB_FIELDS_GRID_TABLE(), EDA_UNIT_UTILS::UI::StringFromValue(), and PCB_DIMENSION_BASE::updateText().

◆ IsImperialUnit()

◆ IsMetricUnit()

bool EDA_UNIT_UTILS::IsMetricUnit ( EDA_UNITS  aUnit)

Definition at line 61 of file eda_units.cpp.

References CENTIMETRES, MICROMETRES, and MILLIMETRES.

Referenced by COMMON_TOOLS::SetLastUnits(), and COMMON_TOOLS::SwitchUnits().

◆ Mils2IU()

◆ Mils2mm()

int EDA_UNIT_UTILS::Mils2mm ( double  aVal)

◆ Mm2mils()

int EDA_UNIT_UTILS::Mm2mils ( double  aVal)

Convert mm to mils.

Definition at line 76 of file eda_units.cpp.

References KiROUND().