33#include <NDEVR/String.h>
35#include <NDEVR/Unit.h>
44 struct NDEVR_BASE_API ReferenceUnit :
public Unit
46 const Unit& reference;
54 ReferenceUnit(StringView name, TranslatedString translated_id,
const Unit& reference)
55 : Unit(
name, translated_id)
56 , reference(reference)
58 axis_abbreviations[0] = reference.axis_abbreviations[0];
59 axis_abbreviations[1] = reference.axis_abbreviations[1];
60 axis_abbreviations[2] = reference.axis_abbreviations[2];
61 axis_abbreviations[3] = reference.axis_abbreviations[3];
70 [[nodiscard]]
virtual fltp08 convertToUnit(
const fltp08& program_space,
const uint01 direction = X)
const override
72 return reference.convertToUnit(program_space, direction);
81 [[nodiscard]]
virtual fltp08 convertFromUnit(
const fltp08& program_space,
const uint01 direction = X)
const override
83 return reference.convertToUnit(program_space, direction);
91 [[nodiscard]]
virtual Vertex<3, fltp08> convertToUnit(
const Vertex<3, fltp08>& program_space)
const override
93 return reference.convertToUnit(program_space);
101 [[nodiscard]]
virtual Vertex<3, fltp08> convertFromUnit(
const Vertex<3, fltp08>& program_space)
const override
103 return reference.convertFromUnit(program_space);
111 [[nodiscard]]
virtual Ray<3, fltp08> convertToUnit(
const Ray<3, fltp08>& program_space)
const override
113 return reference.convertToUnit(program_space);
121 [[nodiscard]]
virtual Ray<3, fltp08> convertFromUnit(
const Ray<3, fltp08>& program_space)
const override
123 return reference.convertFromUnit(program_space);
137 [[nodiscard]]
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
139 return reference.convertToString(program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
153 virtual void toString(String& s,
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
155 reference.toString(s, program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
164 [[nodiscard]]
virtual fltp08 convertFromString(
const StringView& unit_string, uint01 direction = X)
const override
166 return reference.convertFromString(unit_string, direction);
175 [[nodiscard]]
virtual fltp08 fromString(
const StringView& unit_string, uint01 direction = X)
const override
177 return reference.fromString(unit_string, direction);
185 [[nodiscard]]
virtual const TranslatedString& abbreviation(uint01 direction = X)
const override
187 return reference.abbreviation(direction);
196 [[nodiscard]]
virtual StringView getNextPreferredSeparator(
const StringView& current_string, uint01 direction = X)
const override
198 return reference.getNextPreferredSeparator(current_string, direction);
206 virtual void toFormula(StringAllocatingView& unit_string, uint01 direction = X)
const override
208 reference.toFormula(unit_string, direction);
217 [[nodiscard]]
virtual fltp08 epsilon(fltp08 value, uint01 direction = X)
const override
219 return reference.epsilon(value, direction);
227 [[nodiscard]]
virtual const Unit* subUnit(uint01 direction)
const override
229 return reference.subUnit(direction);
236 [[nodiscard]]
virtual Matrix<fltp08> matrix()
const override
238 return reference.matrix();
271 lib_assert(direction < 3,
"Out of bounds direction");
273 return program_space *
scale;
284 lib_assert(direction < 3,
"Out of bounds direction");
286 return program_space /
scale;
314 [[nodiscard]]
virtual Ray<3, fltp08>
convertToUnit(
const Ray<3, fltp08>& program_space)
const override
316 return scale * program_space;
324 [[nodiscard]]
virtual Ray<3, fltp08>
convertFromUnit(
const Ray<3, fltp08>& program_space)
const override
326 return program_space /
scale;
342 return toString(
convertToUnit(program_space, direction), add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
395 return Matrix<fltp08>::ScalerMatrix(
scale);
439 lib_assert(direction < 3,
"Out of bounds direction");
452 lib_assert(direction < 3,
"Out of bounds direction");
482 [[nodiscard]]
virtual Ray<3, fltp08>
convertToUnit(
const Ray<3, fltp08>& program_space)
const override
492 [[nodiscard]]
virtual Ray<3, fltp08>
convertFromUnit(
const Ray<3, fltp08>& program_space)
const override
524 return Matrix<fltp08>::ScalerMatrix(
scale);
598 [[nodiscard]]
virtual Ray<3, fltp08>
convertToUnit(
const Ray<3, fltp08>& program_space)
const override;
605 [[nodiscard]]
virtual Ray<3, fltp08>
convertFromUnit(
const Ray<3, fltp08>& program_space)
const override;
788 [[nodiscard]]
virtual Ray<3, fltp08>
convertToUnit(
const Ray<3, fltp08>& program_space)
const override;
802 [[nodiscard]]
virtual Ray<3, fltp08>
convertFromUnit(
const Ray<3, fltp08>& program_space)
const override;
856 TwoPartAngleUnit(
const StringView&
name,
const TranslatedString& translated_name,
const TranslatedString&
abr_major,
const TranslatedString&
abr_minor,
fltp08 sub_unit,
fltp08 scale,
const Vector<3, bool>&
normalized,
Vector<3, fltp08> upper_limits,
Vector<3, fltp08> reflex_point,
Vector<3, bool> reflexes_up);
870 uint04 min_digits,
bool use_abv =
true,
uint01 direction = X)
const override;
945 ThreePartAngleUnit(
const StringView&
name,
const TranslatedString& translated_name,
const TranslatedString&
abr_major,
const TranslatedString&
abr_minor_a,
const TranslatedString&
abr_minor_b,
fltp08 sub_unit_a,
fltp08 sub_unit_b,
fltp08 scale,
const Vector<3, bool>&
normalized,
Vector<3, fltp08> upper_limits,
Vector<3, fltp08> reflex_point,
Vector<3, bool> reflexes_up);
959 uint04 min_digits,
bool use_abv =
true,
uint01 direction = X)
const override;
1019 DDMMSSAngleUnit(
const StringView&
name,
const TranslatedString& translated_name,
const TranslatedString&
abbreviation,
fltp08 scale,
const Vector<3, bool>&
normalized,
const Vector<3, fltp08>&
upper_limits,
const Vector<3, fltp08>& reflexes,
const Vector<3, bool>&
reflexes_up);
1127 [[nodiscard]]
virtual Ray<3, fltp08>
convertToUnit(
const Ray<3, fltp08>& program_space)
const override;
1134 [[nodiscard]]
virtual Ray<3, fltp08>
convertFromUnit(
const Ray<3, fltp08>& program_space)
const override;
static constexpr sint04 INDEX_PI
Optimized angle constant representing PI; allows integers to store angles to some degree of accuracy.
Contains methods for easily reading and writing to an INI file including efficient casting,...
Templated logic for doing matrix multiplication.
This class is like a string view, but may optionally store the data internally Useful if the return t...
The core String View class for the NDEVR API.
t_type getAs() const
Converts a string into an object.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ name
The display name of the object.
Vector< 3, bool > normalized
Per-axis flags indicating whether angles should be normalized to their range.
virtual fltp08 normalize(fltp08 value, uint01 direction) const
Normalizes an angle value to its canonical range for the given axis.
virtual fltp08 convertFromUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar angle from this unit back to program space.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray of angles from this unit back to program space.
AngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, fltp08 scale, const Vector< 3, bool > &normalized, const Vector< 3, fltp08 > &upper_limits, const Vector< 3, fltp08 > &reflexes, const Vector< 3, bool > &reflexes_up)
Constructs an AngleUnit with full configuration for normalization and reflexes.
virtual fltp08 denormalize(fltp08 value, uint01 direction) const
Reverses normalization on an angle value for the given axis.
virtual fltp08 convertToUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar angle from program space to this unit.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray of angles from program space to this unit.
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex of angles from program space to this unit.
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
Vector< 3, fltp08 > reflex_point
Per-axis reflex points where angle wrapping behavior changes.
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex of angles from this unit back to program space.
fltp08 period
The full period of the angle in internal units (default 2*PI).
Vector< 3, bool > reflexes_up
Per-axis flags indicating the direction of reflex angle wrapping.
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this angle unit with a new name and display name.
Vector< 3, fltp08 > upper_limits
Per-axis upper limits for angle normalization.
AngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, fltp08 scale)
Constructs an AngleUnit with the given scale factor.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
StringView getNextPreferredSeparator(const StringView &string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a compact DDMMSS-formatted string into a numeric value in this unit's space.
DDMMSSAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, const AngleUnit &unit)
Constructs a DDMMSSAngleUnit from an existing AngleUnit configuration.
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool use_abv=true, uint01 direction=X) const override
Writes a compact DDMMSS-formatted angle string into the given string.
DDMMSSAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, fltp08 scale, const Vector< 3, bool > &normalized, const Vector< 3, fltp08 > &upper_limits, const Vector< 3, fltp08 > &reflexes, const Vector< 3, bool > &reflexes_up)
Constructs a DDMMSSAngleUnit with full configuration.
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the seconds portion.
const Unit * location_unit
The unit used for horizontal location axes (X, Y).
virtual fltp08 convertFromString(const StringView &unit_string, uint01 direction=X) const override
Converts a unit-formatted string to a program-space value using the appropriate sub-unit.
virtual TranslatedString translatedAxisName(uint04 index) const override
Returns the translated axis name for the given index.
virtual fltp08 convertToUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar from program space to this unit, selecting location or elevation based on direction...
LocationElevationUnit(StringView name, TranslatedString translated_id, const Unit *location_unit, const Unit *elevation_unit)
Constructs a LocationElevationUnit combining a horizontal location unit and a vertical elevation unit...
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Returns the abbreviation for this unit along the given axis direction.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space, applying location conversion to X/Y and elevation to Z.
virtual StringView getNextPreferredSeparator(const StringView ¤t_string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
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.
void toString(String &string, 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
Writes a formatted display string for a program-space scalar into the given string.
virtual fltp08 convertFromUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar from this unit back to program space, selecting location or elevation based on dire...
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space.
fltp08 epsilon(fltp08 value, uint01 direction) const override
Returns the smallest meaningful difference for a value in this unit.
virtual Matrix< fltp08 > matrix() const override
Returns the transformation matrix for this unit.
virtual const Unit * subUnit(uint01 direction) const override
Returns the sub-unit for the given axis direction (location or elevation).
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space, applying location conversion to X/Y and elevation to Z.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space.
const Unit * elevation_unit
The unit used for the vertical elevation axis (Z).
virtual void toFormula(StringAllocatingView &unit_string, uint01 direction=X) const override
Writes the conversion formula for this unit into the given string.
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 using the appropriate sub-unit.
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from program space to this unit using the matrix transformation.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space to this unit using the matrix transformation.
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from this unit back to program space using the inverse matrix transformation.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space using the inverse matrix transformation.
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space using the inverse matrix transformation.
virtual Matrix< fltp08 > matrix() const override
Returns the combined transformation matrix for this unit.
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
virtual const Unit * subUnit(uint01) const override
Returns the sub-unit for the given axis direction.
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful difference for a value in this unit.
MatrixUnit(StringView name, const TranslatedString &translated_id, const Matrix< fltp08 > &mat, const Unit &base)
Constructs a MatrixUnit with a rotational transformation applied to a base unit.
const Matrix< fltp08 > local_matrix
The combined transformation matrix (rotation * base matrix).
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space to this unit using the matrix transformation.
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from program space to this unit using scale and offset.
ScaledOffsetUnit(StringView name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale, fltp08 offset)
Constructs a ScaledOffsetUnit with the given scale, offset, and abbreviation.
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Returns the translated abbreviation for this unit.
virtual Matrix< fltp08 > matrix() const override
Returns the transformation matrix representing this unit's scale.
const fltp08 offset
The additive offset applied after scaling during conversion.
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from this unit back to program space by reversing scale and offset.
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space to this unit using scale and offset.
const fltp08 scale
The multiplicative scale factor for conversion.
virtual const Unit * subUnit(uint01) const override
Returns the sub-unit for the given axis direction.
const TranslatedString core_abbreviation
The translated abbreviation displayed for this unit.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space to this unit using scale and offset.
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space.
virtual Unit * clone(const StringView &new_name, const TranslatedString &new_display_name) const override
Creates a copy of this unit with a new name and display name.
virtual Matrix< fltp08 > matrix() const override
Returns the transformation matrix representing this unit's scale.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space by dividing by the scale.
ScaledUnit(StringView name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale)
Constructs a ScaledUnit with the given scale factor and abbreviation.
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 const TranslatedString & abbreviation(uint01 direction=X) const override
Returns the translated abbreviation for this unit.
const TranslatedString core_abbreviation
The translated abbreviation displayed for 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 override
Converts a program-space scalar to a formatted display string.
virtual fltp08 convertFromString(const StringView &unit_string, uint01 direction=X) const override
Converts a unit-formatted string to a program-space value.
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 Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space to this unit by multiplying by the scale.
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
virtual const Unit * subUnit(uint01) const override
Returns the sub-unit for the given axis direction.
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space by dividing by the scale.
const fltp08 scale
The multiplicative scale factor used for conversion to this unit.
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 Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space to this unit by multiplying by the scale.
const TranslatedString abr_major
The abbreviation for the major part (e.g., degrees symbol).
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the smallest part.
const fltp08 sub_unit_a
The number of first minor units per major unit (e.g., 60 minutes per degree).
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
const TranslatedString abr_minor_a
The abbreviation for the first minor part (e.g., minutes symbol).
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a three-part angle formatted string into a numeric value in this unit's space.
const fltp08 sub_unit_b
The number of second minor units per first minor unit (e.g., 60 seconds per minute).
ThreePartAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor_a, const TranslatedString &abr_minor_b, fltp08 sub_unit_a, fltp08 sub_unit_b, fltp08 scale, const Vector< 3, bool > &normalized, Vector< 3, fltp08 > upper_limits, Vector< 3, fltp08 > reflex_point, Vector< 3, bool > reflexes_up)
Constructs a ThreePartAngleUnit with full configuration.
StringView getNextPreferredSeparator(const StringView ¤t_string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
const TranslatedString abr_minor_b
The abbreviation for the second minor part (e.g., seconds symbol).
ThreePartAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor_a, const TranslatedString &abr_minor_b, fltp08 sub_unit_a, fltp08 sub_unit_b, const AngleUnit &angle_unit)
Constructs a ThreePartAngleUnit from an existing AngleUnit configuration.
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool use_abv=true, uint01 direction=X) const override
Writes a formatted three-part angle string (e.g., degrees, minutes, seconds) into the given string.
fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a two-part angle formatted string into a numeric value in this unit's space.
const fltp08 sub_unit
The number of minor units per major unit (e.g., 60 minutes per degree).
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
const TranslatedString abr_major
The abbreviation for the major part (e.g., degrees symbol).
StringView getNextPreferredSeparator(const StringView &string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
TwoPartAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 sub_unit, fltp08 scale, const Vector< 3, bool > &normalized, Vector< 3, fltp08 > upper_limits, Vector< 3, fltp08 > reflex_point, Vector< 3, bool > reflexes_up)
Constructs a TwoPartAngleUnit with full configuration.
const TranslatedString abr_minor
The abbreviation for the minor part (e.g., minutes symbol).
TwoPartAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 sub_unit, const AngleUnit &angle_unit)
Constructs a TwoPartAngleUnit from an existing AngleUnit configuration.
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the minor part.
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool use_abv=true, uint01 direction=X) const override
Writes a formatted two-part angle string (e.g., degrees and minutes) into the given string.
const fltp08 sub_unit
The number of minor units per major unit (e.g., 12 inches per foot).
TwoPartUnit(const StringView &name, const TranslatedString &translated_id, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 scale, fltp08 sub_unit)
Constructs a TwoPartUnit with major and minor subdivisions.
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
Writes a formatted two-part display string into the given string.
virtual StringView getNextPreferredSeparator(const StringView &string, uint01 direction) const override
Returns the next preferred separator character for user input parsing.
virtual fltp08 epsilon(fltp08 value, uint01 direction) const override
Returns the smallest meaningful difference for a value in this unit.
const TranslatedString abr_minor
The abbreviation for the minor part (e.g., inches symbol).
const TranslatedString abr_major
The abbreviation for the major part (e.g., feet symbol).
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
virtual fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a two-part formatted string into a numeric value in this unit's space.
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the minor part.
Defines a unit of measurement for converting and displaying data values.
Unit(StringView name, TranslatedString translated_id)
Constructs a Unit with the given internal name and translated display name.
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.
TranslatedString axis_name_ids[4]
Translated axis names for up to four axes.
const String name
Internal identifier name for this unit.
TranslatedString axis_abbreviations[4]
Translated axis abbreviations for up to four axes.
const TranslatedString translated_id
Translated display name for this unit.