|
| | Unit (Type type) |
| |
| | Unit (Type first, Type second) |
| |
| | Unit (Type type, uint8_t prec, bool isDecimal=true, bool suffixes=true) |
| |
| | Unit (Type first, Type second, uint8_t prec, bool isDecimal=true) |
| |
| | Unit (Type first, Type second, Type third, uint8_t prec, bool isDecimal=true) |
| |
| bool | isDecimal () const |
| |
| double | divisor () const |
| |
| double | eps () const |
| |
| bool | isMetric (Type type) const |
| |
| double | simpleRatio (double value, double factor, bool reversed) const |
| |
| double | conversion (Type type, double value, bool reversed=false) const |
| |
| utility::String | suffix (Type type) const |
| |
| std::optional< Type > | fromTag (const utility::String &text) const |
| |
| utility::String | toTag (Type type) const |
| |
| std::optional< std::pair< Type, utility::String::size_type > > | findSuffix (const utility::String &text, utility::String::size_type startPos=0) const |
| |
|
|
Type | primary |
| | The primary unit to display.
|
| |
|
std::optional< Type > | secondary |
| | An optional secondary unit, e.g. for foot/inch combos (nullopt = none)
|
| |
|
std::optional< Type > | tertiary |
| | An optional teriary unit, e.g. for degrees/minutes/seconds combos (nullopt = none, ignored if no secondary unit)
|
| |
|
uint8_t | precision = 4 |
| | The display precision (decimal places for metric or 2^-n for fractional units.
|
| |
|
double | base = 10.0 |
| | The numeric base for fractional quantities (10.0 = floating point to specified decimal places, other values create a fraction)
|
| |
|
bool | isUnitSuffix = true |
| | True if values should be displayed with a unit suffix, e.g. "100.0mm" rather than "100.0" (always true when multiple units)
|
| |
|
bool | isLeadingZero = false |
| | True if a value is displayed with multiple units and zero values (apart from the last unit) should be included, e.g. 0' 10" vs 10".
|
| |
template<typename T, typename Type>
struct active::measure::Unit< T, Type >
Template for all classes governing the formatting of measured values when converted to a string
Formatting options include:
- Primary unit, e.g. millimetre.
- Secondary unit. Optional and generally only relevant to imperial units, e.g. a length might be expressed in feet and inches.
- Tertiary unit. Optional, but used by some units, e.g. degrees/minutes/seconds for angle measurements
- Precision:
- For floating point formats, the maximum number of decimal places.
- For fractions, the maximum divisor (2^-n) e.g. 1 = x/2, 2 = x/4 etc.
- Fractions. When true, 0.5 inches will be formatted as 1/2". If a second unit is selected, only the second part will be converted to
a fraction, e.g. 3 feet 2.5 inches will be formatted as 3' 2 1/2"
- Suffixes. When true, measurements are displayed with the appropriate unit suffix, e.g. 100mm (vs just 100). This option is ignored when a second unit is picked (suffixes are always added) because it is otherwise very hard to read the value (and this code could not convert the text back to the original value either)