stlab.adobe.com Adobe Systems Incorporated

Number Unit Descriptor Utilities
[Widget Library]

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_valueis the value to be converted to the base value
unitis 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.

Todo:
the min and max values should come from the unit_t instead of parameters.
Parameters:
scaled_valueis the value to be converted to the base value
unitis the unit by which the scaled value is to be transformed
minis the minimum value allowed for the result
maxis 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_valueis the value to be converted to the scaled value
unitis 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:
dictis the dictionary holding relevant unit information within.
default_unitcontains 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 is y = a(x) + b, so the default settings are simply y = 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.

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google