Number Unit Descriptor Utilities |
Classes | |
struct | unit_t |
Functions | |
double | to_base_value (double scaled_value, const unit_t &unit) |
double | to_pinned_base_value (double scaled_value, const unit_t &unit, double min, double max) |
double | to_scaled_value (double base_value, const unit_t &unit) |
unit_t | to_unit (const dictionary_t &dict, const unit_t &default_unit=unit_t()) |
Function Documentation
double adobe::to_base_value | ( | double | scaled_value, |
const unit_t & | unit | ||
) |
Performs an inverse-linear transformation on a scaled value given a unit.
- Parameters:
-
scaled_value is the value to be converted to the base value unit is the unit by which the scaled value is to be transformed
- Returns:
- the base value according to the unit_t's linear transformation.
Definition at line 189 of file number_unit.hpp.
double adobe::to_pinned_base_value | ( | double | scaled_value, |
const unit_t & | unit, | ||
double | min, | ||
double | max | ||
) |
Performs an inverse-linear transformation on a scaled value given a unit. It will also pin the value after the transformation has taken place to the unit_t's specified minimum and maximum values.
- Parameters:
-
scaled_value is the value to be converted to the base value unit is the unit by which the scaled value is to be transformed min is the minimum value allowed for the result max is the maximumn value allowed for the result
- Returns:
- the pinned base value according to the unit_t's linear transformation.
Definition at line 208 of file number_unit.hpp.
double adobe::to_scaled_value | ( | double | base_value, |
const unit_t & | unit | ||
) |
Performs a linear transformation on a base value given a unit.
- Parameters:
-
base_value is the value to be converted to the scaled value unit is the unit by which the base value is to be transformed
- Returns:
- the scaled value according to the unit_t's linear transformation.
Definition at line 176 of file number_unit.hpp.
unit_t adobe::to_unit | ( | const dictionary_t & | dict, |
const unit_t & | default_unit = unit_t() |
||
) |
- Parameters:
-
dict is the dictionary holding relevant unit information within. default_unit contains values for the resultant unit should they not be defined in dict
.
- Returns:
- a complete unit_t as a result of the merging of the two parameters.
- Dictionary Values
- The values extracted from the dictionary are the following:
key value type default value description name
string
"" Name of this unit bind
name
empty Name of base unit to which this unit is bound format
string
"#.00"
printf-style format for the widget when this unit is selected increment
double
1
amount by which the property model value should be increemented when this unit is selected scale
array of two doubles
[ 1.0, 0.0 ]
Scale factor for the property model's value to this specified unit. This allows you to represent a given cell (say, @width_inches
) in an arbitrary unit given a linear conversion. The linear formula isy = a(x) + b
, so the default settings are simplyy = x
. As an example, if you cell is saving values in unit inches and you want to display your value in centimeters, the scale would be[ 2.54, 0.0 ]
.min_value
double
N/A Optional. Minimum value allowed for this unit. Note that if you have a value that can be represented as multiple units, you have to specify a minimum value for each unit. max_value
double
N/A Optional. Maximum value allowed for this unit. Note that if you have a value that can be represented as multiple units, you have to specify a maximum value for each unit.