Base::UnitsApi Class Reference

The UnitsApi. More...

#include <UnitsApi.h>

List of all members.

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

That means if no unit is issued the user prefs are in charge.

If one unit is used the user prefs get ignored



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 PyObjecttoPyWithUserPrefs (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 PyObjectsGetWithPrefs (PyObject *self, PyObject *args, PyObject *kwd)
static PyObjectsTranslateUnit (PyObject *self, PyObject *args, PyObject *kwd)

Static Protected Attributes

static double UserPrefFactor [50]
 cached factor to translate
static UnitsSchemaUserPrefSystem = new UnitsSchemaInternal()
static QString UserPrefUnit [50]
 name of the unit the user wants to use as quantities

Detailed Description

The UnitsApi.

Definition at line 46 of file UnitsApi.h.


Constructor & Destructor Documentation

UnitsApi::UnitsApi ( const char *  filter  ) 

Constructs a UnitsApi object.

Definition at line 89 of file UnitsApi.cpp.

References parse(), and Result.

UnitsApi::UnitsApi ( const std::string &  filter  ) 

Definition at line 95 of file UnitsApi.cpp.

References parse(), and Result.

UnitsApi::~UnitsApi (  )  [virtual]

Definition at line 101 of file UnitsApi.cpp.


Member Function Documentation

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]
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]
void UnitsApi::setPrefOf ( QuantityType  t,
const char *  Str 
) [static]
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]
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().


Member Data Documentation

PyMethodDef UnitsApi::Methods [static]
Initial value:
 {
    {"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.

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().

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().


The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:01:48 2011 for FreeCAD by  doxygen 1.6.1