#include <UnitsApi.h>
Public Member Functions | |
| UnitsApi (const std::string &filter) | |
| UnitsApi (const char *filter) | |
| Constructs a UnitsApi object. | |
| virtual | ~UnitsApi () |
Static Public Member Functions | |
| static void | setSchema (UnitSystem s) |
| set Schema set the UnitsSchema of the Application this a represented by a class of type UnitSchema which defines a set of standard units for that schema and rules for representative strings. | |
| static double | translateUnit (const QString &) |
| static double | translateUnit (const char *) |
| raw parser interface to calculat units (only from and to internal) | |
query and set the user preferences | |
| static const double | getPrefFactorOf (QuantityType t) |
| get the translation factor for the default unit of a quantity | |
| static const QString & | getPrefUnitOf (QuantityType t) |
| get the default unit of a quantity (e.g. m/s) | |
| static const QString | getQuantityName (QuantityType t) |
| get the name of a quantity (e.g. lenth) | |
| static void | setDefaults (void) |
| set the application defaults | |
| static void | setPrefOf (QuantityType t, const char *Str) |
| set the default unit of a quantity type (e.g. m/s) | |
Translation to internal regarding user prefs | |
| static double | toDblWithUserPrefs (QuantityType t, PyObject *ArgObj) |
| generate a value for a quantity with default user prefered system | |
| static double | toDblWithUserPrefs (QuantityType t, double UserVal) |
| generate a value for a quantity with default user prefered system | |
| static double | toDblWithUserPrefs (QuantityType t, const char *Str) |
| generate a value for a quantity with default user prefered system | |
| static double | toDblWithUserPrefs (QuantityType t, const QString &Str) |
| generate a value for a quantity with default user prefered system | |
Translation from internal to user prefs | |
| static PyObject * | toPyWithUserPrefs (QuantityType t, double Value) |
| generate a python for a quantity in user prefered system | |
| static void | toStrWithUserPrefs (QuantityType t, double Value, QString &outValue, QString &outUnit) |
| generate a string for the value and the unit seperately for a quantity in user prefered system | |
| static QString | toStrWithUserPrefs (QuantityType t, double Value) |
| generate a string (UTF-8) for a quantity in user prefered system | |
Public Attributes | |
| double | Result |
Static Public Attributes | |
| static PyMethodDef | Methods [] |
Static Protected Member Functions | |
| static double | parse (const char *, bool &UsedUnit) |
| static PyObject * | sGetWithPrefs (PyObject *self, PyObject *args, PyObject *kwd) |
| static PyObject * | sTranslateUnit (PyObject *self, PyObject *args, PyObject *kwd) |
Static Protected Attributes | |
| static double | UserPrefFactor [50] |
| cached factor to translate | |
| static UnitsSchema * | UserPrefSystem = new UnitsSchemaInternal() |
| static QString | UserPrefUnit [50] |
| name of the unit the user wants to use as quantities | |
The UnitsApi.
Definition at line 46 of file UnitsApi.h.
| UnitsApi::UnitsApi | ( | const char * | filter | ) |
Constructs a UnitsApi object.
Definition at line 89 of file UnitsApi.cpp.
| UnitsApi::UnitsApi | ( | const std::string & | filter | ) |
Definition at line 95 of file UnitsApi.cpp.
| UnitsApi::~UnitsApi | ( | ) | [virtual] |
Definition at line 101 of file UnitsApi.cpp.
| const double UnitsApi::getPrefFactorOf | ( | QuantityType | t | ) | [static] |
get the translation factor for the default unit of a quantity
Definition at line 194 of file UnitsApi.cpp.
References UserPrefFactor.
Referenced by Base::UnitsSchemaMKS::toStrWithUserPrefs(), Base::UnitsSchemaInternal::toStrWithUserPrefs(), and Base::UnitsSchemaImperial1::toStrWithUserPrefs().
| const QString & UnitsApi::getPrefUnitOf | ( | QuantityType | t | ) | [static] |
get the default unit of a quantity (e.g. m/s)
Definition at line 189 of file UnitsApi.cpp.
References UserPrefUnit.
Referenced by Gui::PropertyEditor::PropertyFloatItem::toString(), Base::UnitsSchemaMKS::toStrWithUserPrefs(), Base::UnitsSchemaInternal::toStrWithUserPrefs(), and Base::UnitsSchemaImperial1::toStrWithUserPrefs().
| const QString UnitsApi::getQuantityName | ( | QuantityType | t | ) | [static] |
get the name of a quantity (e.g. lenth)
Definition at line 75 of file UnitsApi.cpp.
References QuantityNames.
| double UnitsApi::parse | ( | const char * | buffer, | |
| bool & | UsedUnit | |||
| ) | [static, protected] |
Definition at line 249 of file UnitsApi.cpp.
References DOUBLE_MIN, ScanResult, and UU.
Referenced by toDblWithUserPrefs(), translateUnit(), and UnitsApi().
| void UnitsApi::setDefaults | ( | void | ) | [static] |
set the application defaults
Definition at line 199 of file UnitsApi.cpp.
References Base::Acceleration, Base::Angle, Base::Area, Base::Length, Base::Mass, setPrefOf(), Base::Temperature, Base::TimeSpan, Base::Velocity, and Base::Volume.
| void UnitsApi::setPrefOf | ( | QuantityType | t, | |
| const char * | Str | |||
| ) | [static] |
set the default unit of a quantity type (e.g. m/s)
Definition at line 182 of file UnitsApi.cpp.
References translateUnit(), UserPrefFactor, and UserPrefUnit.
Referenced by setDefaults(), Base::UnitsSchemaMKS::setSchemaUnits(), Base::UnitsSchemaInternal::setSchemaUnits(), and Base::UnitsSchemaImperial1::setSchemaUnits().
| void UnitsApi::setSchema | ( | UnitSystem | s | ) | [static] |
set Schema set the UnitsSchema of the Application this a represented by a class of type UnitSchema which defines a set of standard units for that schema and rules for representative strings.
Definition at line 105 of file UnitsApi.cpp.
References Base::Imperial1, Base::UnitsSchema::setSchemaUnits(), Base::SI1, Base::SI2, and UserPrefSystem.
| PyObject * UnitsApi::sGetWithPrefs | ( | PyObject * | self, | |
| PyObject * | args, | |||
| PyObject * | kwd | |||
| ) | [static, protected] |
Definition at line 91 of file UnitsApiPy.cpp.
References Base::Length, Py::new_reference_to(), result, RobotExample::t, toDblWithUserPrefs(), and Py::type().
| PyObject * UnitsApi::sTranslateUnit | ( | PyObject * | self, | |
| PyObject * | args, | |||
| PyObject * | kwd | |||
| ) | [static, protected] |
Definition at line 73 of file UnitsApiPy.cpp.
References Py::new_reference_to(), translateUnit(), and Base::Exception::what().
| double UnitsApi::toDblWithUserPrefs | ( | QuantityType | t, | |
| PyObject * | ArgObj | |||
| ) | [static] |
generate a value for a quantity with default user prefered system
Definition at line 170 of file UnitsApi.cpp.
References toDblWithUserPrefs().
| double UnitsApi::toDblWithUserPrefs | ( | QuantityType | t, | |
| double | UserVal | |||
| ) | [static] |
generate a value for a quantity with default user prefered system
Definition at line 165 of file UnitsApi.cpp.
References UserPrefFactor.
| double UnitsApi::toDblWithUserPrefs | ( | QuantityType | t, | |
| const char * | Str | |||
| ) | [static] |
generate a value for a quantity with default user prefered system
Definition at line 154 of file UnitsApi.cpp.
References parse(), and toDblWithUserPrefs().
| double UnitsApi::toDblWithUserPrefs | ( | QuantityType | t, | |
| const QString & | Str | |||
| ) | [static] |
generate a value for a quantity with default user prefered system
Definition at line 149 of file UnitsApi.cpp.
Referenced by Robot::WaypointPy::PyInit(), sGetWithPrefs(), toDblWithUserPrefs(), RobotGui::TaskRobot6Axis::viewTcp(), RobotGui::TaskTrajectory::viewTool(), and RobotGui::TaskRobot6Axis::viewTool().
| PyObject * UnitsApi::toPyWithUserPrefs | ( | QuantityType | t, | |
| double | Value | |||
| ) | [static] |
generate a python for a quantity in user prefered system
Definition at line 144 of file UnitsApi.cpp.
References UserPrefFactor.
| void UnitsApi::toStrWithUserPrefs | ( | QuantityType | t, | |
| double | Value, | |||
| QString & | outValue, | |||
| QString & | outUnit | |||
| ) | [static] |
generate a string for the value and the unit seperately for a quantity in user prefered system
Definition at line 139 of file UnitsApi.cpp.
References Base::UnitsSchema::toStrWithUserPrefs(), and UserPrefSystem.
| QString UnitsApi::toStrWithUserPrefs | ( | QuantityType | t, | |
| double | Value | |||
| ) | [static] |
generate a string (UTF-8) for a quantity in user prefered system
Definition at line 132 of file UnitsApi.cpp.
References Base::UnitsSchema::toStrWithUserPrefs(), and UserPrefSystem.
Referenced by Gui::PropertyEditor::PropertyUnitItem::value().
| double UnitsApi::translateUnit | ( | const QString & | str | ) | [static] |
Definition at line 123 of file UnitsApi.cpp.
References parse().
| double UnitsApi::translateUnit | ( | const char * | str | ) | [static] |
raw parser interface to calculat units (only from and to internal)
Definition at line 117 of file UnitsApi.cpp.
References parse().
Referenced by SketcherGui::TaskSketcherGeneral::setGridSize(), setPrefOf(), and sTranslateUnit().
PyMethodDef UnitsApi::Methods [static] |
{
{"translateUnit", (PyCFunction) UnitsApi::sTranslateUnit ,1,
"translateUnit(string) -> double\n\n"
"calculate a mathematical expression with units to a number. \n"
"can be used for simple unit translation like: \n"
" translateUnit('10m')\n"
" or for more complex espressions:\n"
" translateUnit('sin(pi)/50.0 m/s^2')\n"
},
{"getWithPrefs", (PyCFunction) UnitsApi::sGetWithPrefs ,1,
"getWithPrefs(type,[string|float|int]) -> double\n\n"
"Translation to internal regarding user prefs \n"
" That means if no unit is issued the user prefs are in \n"
" charge. If one unit is used the user prefs get ignored\n"
" type can be: \n"
" Length \n"
" Area \n"
" Volume \n"
" Angle \n"
" TimeSpan \n"
" Velocity \n"
" Acceleration \n"
" Mass \n"
" Temperature \n"
},
{NULL, NULL, 0, NULL}
}
Definition at line 111 of file UnitsApi.h.
| double Base::UnitsApi::Result |
Definition at line 108 of file UnitsApi.h.
Referenced by UnitsApi().
double UnitsApi::UserPrefFactor [static, protected] |
cached factor to translate
Definition at line 119 of file UnitsApi.h.
Referenced by getPrefFactorOf(), setPrefOf(), toDblWithUserPrefs(), and toPyWithUserPrefs().
UnitsSchema * UnitsApi::UserPrefSystem = new UnitsSchemaInternal() [static, protected] |
Definition at line 116 of file UnitsApi.h.
Referenced by setSchema(), and toStrWithUserPrefs().
QString UnitsApi::UserPrefUnit [static, protected] |
name of the unit the user wants to use as quantities
Definition at line 121 of file UnitsApi.h.
Referenced by getPrefUnitOf(), and setPrefOf().
1.6.1