![]() |
NDEVR
API Documentation
|
Defines a unit of measurement for converting and displaying data values. More...
Public Member Functions | |
| Unit (StringView name, TranslatedString translated_id) | |
| Constructs a Unit with the given internal name and translated display name. | |
| virtual | ~Unit ()=default |
| Virtual destructor. | |
| virtual const TranslatedString & | abbreviation (uint01 direction=X) const =0 |
| Returns the abbreviated name for this unit along the given axis direction. | |
| virtual Unit * | clone () const |
| Creates a deep copy of this unit. | |
| virtual Unit * | clone (const StringView &new_name, const TranslatedString &new_display_name) const =0 |
| Creates a deep copy of this unit with a new name and display name. | |
| template<class t_angle_type> | |
| Angle< t_angle_type > | convertAngleFromUnit (const fltp08 &unit_space, uint01 direction=X) const |
| Converts a scalar value in this unit's space back to an Angle in program space. | |
| virtual fltp08 | convertFromString (const StringView &unit_string, uint01 direction=X) const |
| Parses a string in this unit's format and converts the result to internal program space. | |
| virtual fltp08 | convertFromUnit (const fltp08 &unit_space, const uint01 direction=X) const =0 |
| Converts a value from this unit's representation back to internal program space. | |
| virtual Ray< 3, fltp08 > | convertFromUnit (const Ray< 3, fltp08 > &unit_space) const =0 |
| Converts a 3D ray from this unit's representation back to internal program space. | |
| virtual Vertex< 3, fltp08 > | convertFromUnit (const Vertex< 3, fltp08 > &unit_space) const =0 |
| Converts a 3D vertex from this unit's representation back to internal program space. | |
| template<class t_angle_type> | |
| String | convertToString (const Angle< t_angle_type > &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const |
| Converts an angle value from program space to a formatted string in this unit. | |
| virtual String | convertToString (const fltp08 &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const |
| Converts a scalar value from program space to a formatted string in this unit. | |
| template<class t_angle_type> | |
| fltp08 | convertToUnit (const Angle< t_angle_type > &program_space, uint01 direction=X) const |
| Converts an angle value from program space to this unit's scalar representation. | |
| virtual fltp08 | convertToUnit (const fltp08 &program_space, const uint01 direction=X) const =0 |
| Converts a value from internal program space to this unit's representation. | |
| virtual Ray< 3, fltp08 > | convertToUnit (const Ray< 3, fltp08 > &program_space) const =0 |
| Converts a 3D ray from internal program space to this unit's representation. | |
| virtual Vertex< 3, fltp08 > | convertToUnit (const Vertex< 3, fltp08 > &program_space) const =0 |
| Converts a 3D vertex from internal program space to this unit's representation. | |
| virtual fltp08 | epsilon (fltp08 value, uint01 direction=X) const |
| Returns a small epsilon value appropriate for comparisons in this unit at the given magnitude. | |
| virtual fltp08 | fromString (const StringView &unit_string, uint01 direction=X) const |
| Parses a string into a scalar value in this unit's space without converting to program space. | |
| virtual StringView | getNextPreferredSeparator (const StringView ¤t_string, uint01 direction=X) const |
| Returns the next preferred separator character sequence based on the current input string. | |
| virtual Matrix< fltp08 > | matrix () const =0 |
| Returns the transformation matrix representing this unit's conversion. | |
| bool | operator== (const Unit &other) const |
| Checks equality between two units by comparing their matrices and names. | |
| virtual const Unit * | subUnit (uint01 direction) const =0 |
| Returns the sub-unit for a specific axis direction, if this unit is compound. | |
| virtual void | toFormula (StringAllocatingView &unit_string, uint01 direction=X) const |
| Writes the unit conversion as a formula into the given string. | |
| String | toString (const fltp08 &unit_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const |
| Formats a value already in this unit's space into a display string. | |
| virtual void | toString (String &string, const fltp08 &unit_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const |
| Appends a formatted unit value to an existing string. | |
| virtual TranslatedString | translatedAxisName (uint04 index) const |
| Returns the translated axis name for a given axis index. | |
| TranslatedString | translatedName () const |
| Returns the translated display name of this unit. | |
Public Attributes | |
| TranslatedString | axis_abbreviations [4] |
| Translated axis abbreviations for up to four axes. | |
| TranslatedString | axis_name_ids [4] |
| Translated axis names for up to four axes. | |
| const String | name |
| Internal identifier name for this unit. | |
| const TranslatedString | translated_id |
| Translated display name for this unit. | |
Static Protected Member Functions | |
| static Buffer< StringView > | OperatorSplit (const StringView &string) |
| Splits a string by operator characters for formula parsing. | |
Defines a unit of measurement for converting and displaying data values.
| Unit::Unit | ( | StringView | name, |
| TranslatedString | translated_id ) |
Constructs a Unit with the given internal name and translated display name.
| [in] | name | The internal identifier for this unit. |
| [in] | translated_id | The translated display name for this unit. |
References name, and translated_id.
Referenced by LocationElevationUnit::LocationElevationUnit(), ScaledOffsetUnit::ScaledOffsetUnit(), ScaledUnit::ScaledUnit(), LocationElevationUnit::clone(), ScaledOffsetUnit::clone(), ScaledUnit::clone(), clone(), clone(), operator==(), LocationElevationUnit::subUnit(), ScaledOffsetUnit::subUnit(), ScaledUnit::subUnit(), and subUnit().
|
nodiscardpure virtual |
Returns the abbreviated name for this unit along the given axis direction.
| [in] | direction | The axis direction index (default X). |
Implemented in LocationElevationUnit, ScaledOffsetUnit, and ScaledUnit.
Referenced by toString().
|
nodiscardvirtual |
|
nodiscardpure virtual |
Creates a deep copy of this unit with a new name and display name.
| [in] | new_name | The new internal identifier. |
| [in] | new_display_name | The new translated display name. |
Implemented in AngleUnit, DDMMSSAngleUnit, LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, ScaledUnit, ThreePartAngleUnit, TwoPartAngleUnit, and TwoPartUnit.
References Unit().
|
inlinenodiscard |
Converts a scalar value in this unit's space back to an Angle in program space.
| [in] | unit_space | The scalar value in this unit's space. |
| [in] | direction | The axis direction index (default X). |
Definition at line 144 of file Unit.h.
References convertFromUnit(), and INTERNAL_ANGLE.
|
inlinenodiscardvirtual |
Parses a string in this unit's format and converts the result to internal program space.
| [in] | unit_string | The string to parse. |
| [in] | direction | The axis direction index (default X). |
Reimplemented in LocationElevationUnit, and ScaledUnit.
Definition at line 209 of file Unit.h.
References convertFromUnit(), and fromString().
|
nodiscardpure virtual |
Converts a value from this unit's representation back to internal program space.
| [in] | unit_space | The value in this unit's space. |
| [in] | direction | The axis direction index (default X). |
Implemented in AngleUnit, LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
Referenced by convertAngleFromUnit(), and convertFromString().
|
nodiscardpure virtual |
Converts a 3D ray from this unit's representation back to internal program space.
| [in] | unit_space | The ray in this unit's space. |
Implemented in AngleUnit, LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
|
nodiscardpure virtual |
Converts a 3D vertex from this unit's representation back to internal program space.
| [in] | unit_space | The vertex in this unit's space. |
Implemented in AngleUnit, LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
|
inlinenodiscard |
Converts an angle value from program space to a formatted string in this unit.
| [in] | program_space | The angle in internal program space. |
| [in] | add_comma | Whether to include comma separators for large numbers. |
| [in] | min_decimals | Minimum number of decimal places to display. |
| [in] | max_decimals | Maximum number of decimal places to display. |
| [in] | min_digits | Minimum number of digits to display. |
| [in] | include_abv | Whether to append the unit abbreviation. |
| [in] | direction | The axis direction index (default X). |
Definition at line 120 of file Unit.h.
References convertToString().
Referenced by convertToString().
|
inlinenodiscardvirtual |
Converts a scalar value from program space to a formatted string in this unit.
| [in] | program_space | The value in internal program space. |
| [in] | add_comma | Whether to include comma separators for large numbers. |
| [in] | min_decimals | Minimum number of decimal places to display. |
| [in] | max_decimals | Maximum number of decimal places to display. |
| [in] | min_digits | Minimum number of digits to display. |
| [in] | include_abv | Whether to append the unit abbreviation. |
| [in] | direction | The axis direction index (default X). |
Reimplemented in LocationElevationUnit, and ScaledUnit.
Definition at line 160 of file Unit.h.
References convertToUnit(), and toString().
|
inlinenodiscard |
Converts an angle value from program space to this unit's scalar representation.
| [in] | program_space | The angle in internal program space. |
| [in] | direction | The axis direction index (default X). |
Definition at line 132 of file Unit.h.
References convertToUnit().
|
nodiscardpure virtual |
Converts a value from internal program space to this unit's representation.
| [in] | program_space | The value in internal program space. |
| [in] | direction | The axis direction index (default X). |
Implemented in AngleUnit, LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
Referenced by convertToString(), and convertToUnit().
|
nodiscardpure virtual |
Converts a 3D ray from internal program space to this unit's representation.
| [in] | program_space | The ray in internal program space. |
Implemented in AngleUnit, LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
|
nodiscardpure virtual |
Converts a 3D vertex from internal program space to this unit's representation.
| [in] | program_space | The vertex in internal program space. |
Implemented in AngleUnit, LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
Returns a small epsilon value appropriate for comparisons in this unit at the given magnitude.
| [in] | value | The reference magnitude. |
| [in] | direction | The axis direction index (default X). |
Reimplemented in AngleUnit, DDMMSSAngleUnit, LocationElevationUnit, MatrixUnit, ThreePartAngleUnit, TwoPartAngleUnit, and TwoPartUnit.
|
inlinenodiscardvirtual |
Parses a string into a scalar value in this unit's space without converting to program space.
| [in] | unit_string | The string to parse. |
| [in] | direction | The axis direction index (default X). |
Reimplemented in DDMMSSAngleUnit, LocationElevationUnit, ScaledUnit, ThreePartAngleUnit, TwoPartAngleUnit, and TwoPartUnit.
Definition at line 220 of file Unit.h.
References StringView::getAs().
Referenced by convertFromString().
|
nodiscardvirtual |
Returns the next preferred separator character sequence based on the current input string.
| [in] | current_string | The current string being composed. |
| [in] | direction | The axis direction index (default X). |
Reimplemented in DDMMSSAngleUnit, LocationElevationUnit, ThreePartAngleUnit, TwoPartAngleUnit, and TwoPartUnit.
Returns the transformation matrix representing this unit's conversion.
Implemented in LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
Referenced by operator==().
|
inline |
|
staticprotected |
Splits a string by operator characters for formula parsing.
| [in] | string | The string to split. |
Returns the sub-unit for a specific axis direction, if this unit is compound.
| [in] | direction | The axis direction index. |
Implemented in LocationElevationUnit, MatrixUnit, ScaledOffsetUnit, and ScaledUnit.
References Unit().
|
virtual |
Writes the unit conversion as a formula into the given string.
| [in,out] | unit_string | The string to write the formula into. |
| [in] | direction | The axis direction index (default X). |
Reimplemented in LocationElevationUnit.
|
inlinenodiscard |
Formats a value already in this unit's space into a display string.
| [in] | unit_space | The value already converted to this unit's space. |
| [in] | add_comma | Whether to include comma separators for large numbers. |
| [in] | min_decimals | Minimum number of decimal places to display. |
| [in] | max_decimals | Maximum number of decimal places to display. |
| [in] | min_digits | Minimum number of digits to display. |
| [in] | include_abv | Whether to append the unit abbreviation. |
| [in] | direction | The axis direction index (default X). |
Definition at line 176 of file Unit.h.
References toString().
Referenced by ScaledUnit::convertToString(), convertToString(), and toString().
|
inlinevirtual |
Appends a formatted unit value to an existing string.
| [in,out] | string | The string to append the formatted value to. |
| [in] | unit_space | The value already converted to this unit's space. |
| [in] | add_comma | Whether to include comma separators for large numbers. |
| [in] | min_decimals | Minimum number of decimal places to display. |
| [in] | max_decimals | Maximum number of decimal places to display. |
| [in] | min_digits | Minimum number of digits to display. |
| [in] | include_abv | Whether to append the unit abbreviation. |
| [in] | direction | The axis direction index (default X). |
Reimplemented in DDMMSSAngleUnit, LocationElevationUnit, ThreePartAngleUnit, TwoPartAngleUnit, and TwoPartUnit.
Definition at line 194 of file Unit.h.
References abbreviation().
|
nodiscardvirtual |
Returns the translated axis name for a given axis index.
| [in] | index | The axis index. |
Reimplemented in LocationElevationUnit.
|
nodiscard |
Returns the translated display name of this unit.