NDEVR
API Documentation

A unit that describes a simple scale (think meters vs feet). More...

Inheritance diagram for ScaledUnit:
[legend]
Collaboration diagram for ScaledUnit:
[legend]

Public Member Functions

 ScaledUnit (StringView name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale)
 Constructs a ScaledUnit with the given scale factor and abbreviation.
virtual const TranslatedStringabbreviation (uint01 direction=X) const override
 Returns the translated abbreviation for this unit.
virtual Unitclone (const StringView &name, const TranslatedString &translated_id) const override
 Creates a copy of this unit with a new name and display name.
virtual fltp08 convertFromString (const StringView &unit_string, uint01 direction=X) const override
 Converts a unit-formatted string to a program-space value.
virtual fltp08 convertFromUnit (const fltp08 &program_space, const uint01 direction=X) const override
 Converts a scalar from this unit back to program space by dividing by the scale.
virtual Ray< 3, fltp08convertFromUnit (const Ray< 3, fltp08 > &program_space) const override
 Converts a 3D ray from this unit back to program space by dividing by the scale.
virtual Vertex< 3, fltp08convertFromUnit (const Vertex< 3, fltp08 > &program_space) const override
 Converts a 3D vertex from this unit back to program space by dividing by the scale.
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 override
 Converts a program-space scalar to a formatted display string.
virtual fltp08 convertToUnit (const fltp08 &program_space, const uint01 direction=X) const override
 Converts a scalar from program space to this unit by multiplying by the scale.
virtual Ray< 3, fltp08convertToUnit (const Ray< 3, fltp08 > &program_space) const override
 Converts a 3D ray from program space to this unit by multiplying by the scale.
virtual Vertex< 3, fltp08convertToUnit (const Vertex< 3, fltp08 > &program_space) const override
 Converts a 3D vertex from program space to this unit by multiplying by the scale.
virtual fltp08 fromString (const StringView &unit_string, uint01 direction=X) const override
 Parses a string directly into a numeric value in this unit's space.
virtual Matrix< fltp08matrix () const override
 Returns the transformation matrix representing this unit's scale.
virtual const UnitsubUnit (uint01) const override
 Returns the sub-unit for the given axis direction.
Public Member Functions inherited from Unit
 Unit (StringView name, TranslatedString translated_id)
 Constructs a Unit with the given internal name and translated display name.
virtual ~Unit ()=default
 Virtual destructor.
virtual Unitclone () const
 Creates a deep copy of this unit.
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.
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.
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 epsilon (fltp08 value, uint01 direction=X) const
 Returns a small epsilon value appropriate for comparisons in this unit at the given magnitude.
virtual StringView getNextPreferredSeparator (const StringView &current_string, uint01 direction=X) const
 Returns the next preferred separator character sequence based on the current input string.
bool operator== (const Unit &other) const
 Checks equality between two units by comparing their matrices and names.
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

const TranslatedString core_abbreviation
 The translated abbreviation displayed for this unit.
const fltp08 scale
 The multiplicative scale factor used for conversion to this unit.
Public Attributes inherited from Unit
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.

Additional Inherited Members

Static Protected Member Functions inherited from Unit
static Buffer< StringViewOperatorSplit (const StringView &string)
 Splits a string by operator characters for formula parsing.

Detailed Description

A unit that describes a simple scale (think meters vs feet).


Definition at line 245 of file UnitTypes.h.

Constructor & Destructor Documentation

◆ ScaledUnit()

ScaledUnit::ScaledUnit ( StringView name,
TranslatedString translated_id,
TranslatedString abbreviation,
fltp08 scale )
inline

Constructs a ScaledUnit with the given scale factor and abbreviation.

Parameters
[in]nameThe internal identifier for this unit.
[in]translated_idThe translated display name for this unit.
[in]abbreviationThe translated abbreviation for this unit.
[in]scaleThe multiplicative scale factor for converting to this unit.

Definition at line 257 of file UnitTypes.h.

References Unit::Unit(), abbreviation(), core_abbreviation, Unit::name, scale, and Unit::translated_id.

Member Function Documentation

◆ abbreviation()

virtual const TranslatedString & ScaledUnit::abbreviation ( uint01 direction = X) const
inlinenodiscardoverridevirtual

Returns the translated abbreviation for this unit.

Parameters
[in]directionThe axis direction.
Returns
The translated abbreviation string.

Implements Unit.

Definition at line 373 of file UnitTypes.h.

References core_abbreviation.

Referenced by AngleUnit::AngleUnit(), AngleUnit::AngleUnit(), DDMMSSAngleUnit::DDMMSSAngleUnit(), DDMMSSAngleUnit::DDMMSSAngleUnit(), and ScaledUnit().

◆ clone()

virtual Unit * ScaledUnit::clone ( const StringView & name,
const TranslatedString & translated_id ) const
nodiscardoverridevirtual

Creates a copy of this unit with a new name and display name.

Parameters
[in]nameThe internal identifier for the cloned unit.
[in]translated_idThe translated display name for the cloned unit.
Returns
A newly allocated clone of this unit.

Implements Unit.

Reimplemented in AngleUnit, DDMMSSAngleUnit, ThreePartAngleUnit, TwoPartAngleUnit, and TwoPartUnit.

References Unit::Unit(), Unit::name, and Unit::translated_id.

◆ convertFromString()

virtual fltp08 ScaledUnit::convertFromString ( const StringView & unit_string,
uint01 direction = X ) const
inlinenodiscardoverridevirtual

Converts a unit-formatted string to a program-space value.

Parameters
[in]unit_stringThe string representation of a value in this unit.
[in]directionThe axis direction for the conversion.
Returns
The parsed value converted into program space.

Reimplemented from Unit.

Definition at line 351 of file UnitTypes.h.

References convertFromUnit(), and fromString().

◆ convertFromUnit() [1/3]

virtual fltp08 ScaledUnit::convertFromUnit ( const fltp08 & program_space,
const uint01 direction = X ) const
inlinenodiscardoverridevirtual

Converts a scalar from this unit back to program space by dividing by the scale.

Parameters
[in]program_spaceThe value in this unit's space.
[in]directionThe axis direction for the conversion.
Returns
The value converted back to program space.

Implements Unit.

Reimplemented in AngleUnit.

Definition at line 282 of file UnitTypes.h.

References scale.

Referenced by convertFromString().

◆ convertFromUnit() [2/3]

virtual Ray< 3, fltp08 > ScaledUnit::convertFromUnit ( const Ray< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D ray from this unit back to program space by dividing by the scale.

Parameters
[in]program_spaceThe ray in this unit's space.
Returns
The ray converted back to program space.

Implements Unit.

Reimplemented in AngleUnit.

Definition at line 324 of file UnitTypes.h.

References scale.

◆ convertFromUnit() [3/3]

virtual Vertex< 3, fltp08 > ScaledUnit::convertFromUnit ( const Vertex< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D vertex from this unit back to program space by dividing by the scale.

Parameters
[in]program_spaceThe vertex in this unit's space.
Returns
The vertex converted back to program space.

Implements Unit.

Reimplemented in AngleUnit.

Definition at line 304 of file UnitTypes.h.

References scale.

◆ convertToString()

virtual String ScaledUnit::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
inlinenodiscardoverridevirtual

Converts a program-space scalar to a formatted display string.

Parameters
[in]program_spaceThe value in program space.
[in]add_commaWhether to insert comma separators for large numbers.
[in]min_decimalsThe minimum number of decimal places to display.
[in]max_decimalsThe maximum number of decimal places to display.
[in]min_digitsThe minimum number of integer digits to display.
[in]include_abvWhether to append the unit abbreviation.
[in]directionThe axis direction for the conversion.
Returns
A formatted string representation of the value in this unit.

Reimplemented from Unit.

Definition at line 340 of file UnitTypes.h.

References convertToUnit(), and Unit::toString().

◆ convertToUnit() [1/3]

virtual fltp08 ScaledUnit::convertToUnit ( const fltp08 & program_space,
const uint01 direction = X ) const
inlinenodiscardoverridevirtual

Converts a scalar from program space to this unit by multiplying by the scale.

Parameters
[in]program_spaceThe value in program space.
[in]directionThe axis direction for the conversion.
Returns
The scaled value in this unit's space.

Implements Unit.

Reimplemented in AngleUnit.

Definition at line 269 of file UnitTypes.h.

References scale.

Referenced by convertToString().

◆ convertToUnit() [2/3]

virtual Ray< 3, fltp08 > ScaledUnit::convertToUnit ( const Ray< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D ray from program space to this unit by multiplying by the scale.

Parameters
[in]program_spaceThe ray in program space.
Returns
The scaled ray in this unit's space.

Implements Unit.

Reimplemented in AngleUnit.

Definition at line 314 of file UnitTypes.h.

References scale.

◆ convertToUnit() [3/3]

virtual Vertex< 3, fltp08 > ScaledUnit::convertToUnit ( const Vertex< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D vertex from program space to this unit by multiplying by the scale.

Parameters
[in]program_spaceThe vertex in program space.
Returns
The scaled vertex in this unit's space.

Implements Unit.

Reimplemented in AngleUnit.

Definition at line 294 of file UnitTypes.h.

References scale.

◆ fromString()

virtual fltp08 ScaledUnit::fromString ( const StringView & unit_string,
uint01 direction = X ) const
inlinenodiscardoverridevirtual

Parses a string directly into a numeric value in this unit's space.

Parameters
[in]unit_stringThe string to parse.
[in]directionThe axis direction for the conversion.
Returns
The parsed numeric value.

Reimplemented from Unit.

Reimplemented in DDMMSSAngleUnit, ThreePartAngleUnit, TwoPartAngleUnit, and TwoPartUnit.

Definition at line 362 of file UnitTypes.h.

References StringView::getAs().

Referenced by convertFromString().

◆ matrix()

virtual Matrix< fltp08 > ScaledUnit::matrix ( ) const
inlinenodiscardoverridevirtual

Returns the transformation matrix representing this unit's scale.

Returns
A diagonal scale matrix with this unit's scale factor.

Implements Unit.

Definition at line 393 of file UnitTypes.h.

References scale.

◆ subUnit()

virtual const Unit * ScaledUnit::subUnit ( uint01 ) const
inlinenodiscardoverridevirtual

Returns the sub-unit for the given axis direction.

Parameters
[in]directionThe axis direction.
Returns
A pointer to this unit, since a simple scaled unit has no distinct sub-units.

Implements Unit.

Definition at line 384 of file UnitTypes.h.

References Unit::Unit().


The documentation for this struct was generated from the following file: