Base::UnitsApi Class Reference

The UnitsApi. More...

#include <UnitsApi.h>

Static Public Member Functions

static UnitsSchemaPtr createSchema (UnitSystem s)
 return an instance of the given enum value More...
 
static int getDecimals ()
 
static const char * getDescription (UnitSystem)
 Returns a brief description of a schema. More...
 
static UnitSystem getSchema ()
 return the active schema More...
 
static QString schemaTranslate (const Base::Quantity &quant)
 
static QString schemaTranslate (const Base::Quantity &quant, double &factor, QString &unitString)
 
static void setDecimals (int)
 
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. More...
 
static double toDouble (PyObject *args, const Base::Unit &u=Base::Unit())
 generate a value for a quantity with default user preferred system More...
 
static QString toNumber (const Base::Quantity &q, const QuantityFormat &f=QuantityFormat(QuantityFormat::Default))
 Get a number as string for a quantity of a given format. More...
 
static QString toNumber (double d, const QuantityFormat &f=QuantityFormat(QuantityFormat::Default))
 Get a number as string for a double of a given format. More...
 
static Quantity toQuantity (PyObject *args, const Base::Unit &u=Base::Unit())
 generate a value for a quantity with default user preferred system More...
 
static QString toString (const Base::Quantity &q, const QuantityFormat &f=QuantityFormat(QuantityFormat::Default))
 Get a number as string for a quantity of a given format. More...
 

Static Public Attributes

static PyMethodDef Methods []
 

Static Protected Member Functions

static PyObjectsGetSchema (PyObject *self, PyObject *args)
 
static PyObjectsListSchemas (PyObject *self, PyObject *args)
 
static PyObjectsParseQuantity (PyObject *self, PyObject *args)
 
static PyObjectsSchemaTranslate (PyObject *self, PyObject *args)
 
static PyObjectsSetSchema (PyObject *self, PyObject *args)
 
static PyObjectsToNumber (PyObject *self, PyObject *args)
 

Static Protected Attributes

static UnitSystem currentSystem = UnitSystem::SI1
 
static int UserPrefDecimals = 2
 number of decimals for floats More...
 
static UnitsSchemaPtr UserPrefSystem
 

Detailed Description

The UnitsApi.

Member Function Documentation

◆ createSchema()

◆ getDecimals()

◆ getDescription()

◆ getSchema()

static UnitSystem Base::UnitsApi::getSchema ( )
static

◆ schemaTranslate() [1/2]

static QString Base::UnitsApi::schemaTranslate ( const Base::Quantity quant)
static

References schemaTranslate().

◆ schemaTranslate() [2/2]

QString UnitsApi::schemaTranslate ( const Base::Quantity quant,
double &  factor,
QString &  unitString 
)
static

◆ setDecimals()

void UnitsApi::setDecimals ( int  prec)
static

◆ setSchema()

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.

References createSchema(), currentSystem, Base::SI1, and UserPrefSystem.

Referenced by sSetSchema().

◆ sGetSchema()

PyObject * UnitsApi::sGetSchema ( PyObject self,
PyObject args 
)
staticprotected

References currentSystem.

◆ sListSchemas()

PyObject * UnitsApi::sListSchemas ( PyObject self,
PyObject args 
)
staticprotected

◆ sParseQuantity()

PyObject * UnitsApi::sParseQuantity ( PyObject self,
PyObject args 
)
staticprotected

◆ sSchemaTranslate()

PyObject * UnitsApi::sSchemaTranslate ( PyObject self,
PyObject args 
)
staticprotected

References createSchema().

◆ sSetSchema()

PyObject * UnitsApi::sSetSchema ( PyObject self,
PyObject args 
)
staticprotected

◆ sToNumber()

PyObject * UnitsApi::sToNumber ( PyObject self,
PyObject args 
)
staticprotected

◆ toDouble()

double UnitsApi::toDouble ( PyObject args,
const Base::Unit u = Base::Unit() 
)
static

generate a value for a quantity with default user preferred system

References Base::Quantity::parse().

◆ toNumber() [1/2]

QString UnitsApi::toNumber ( const Base::Quantity q,
const QuantityFormat f = QuantityFormat(QuantityFormat::Default) 
)
static

Get a number as string for a quantity of a given format.

The string is a number in C locale (i.e. the decimal separator is always a dot) and if needed represented in scientific notation. The string doesn't include the unit of the quantity.

References toNumber().

Referenced by MeshGui::DlgRegularSolidImp::on_createSolidButton_clicked(), PartDesignGui::TaskBoxPrimitives::setPrimitive(), Gui::PropertyEditor::PropertyVectorDistanceItem::setValue(), Gui::PropertyEditor::PropertyRotationItem::setValue(), Gui::PropertyEditor::PropertyPlacementItem::setValue(), sToNumber(), and toNumber().

◆ toNumber() [2/2]

QString UnitsApi::toNumber ( double  d,
const QuantityFormat f = QuantityFormat(QuantityFormat::Default) 
)
static

Get a number as string for a double of a given format.

The string is a number in C locale (i.e. the decimal separator is always a dot) and if needed represented in scientific notation. The string doesn't include the unit of the quantity.

◆ toQuantity()

Quantity UnitsApi::toQuantity ( PyObject args,
const Base::Unit u = Base::Unit() 
)
static

generate a value for a quantity with default user preferred system

References Base::Quantity::parse().

◆ toString()

QString UnitsApi::toString ( const Base::Quantity q,
const QuantityFormat f = QuantityFormat(QuantityFormat::Default) 
)
static

Get a number as string for a quantity of a given format.

The string is a number in C locale (i.e. the decimal separator is always a dot) and if needed represented in scientific notation. The string also includes the unit of the quantity.

Referenced by Gui::PropertyEditor::PropertyUnitItem::setValue().

Member Data Documentation

◆ currentSystem

UnitSystem UnitsApi::currentSystem = UnitSystem::SI1
staticprotected

Referenced by setSchema(), and sGetSchema().

◆ Methods

PyMethodDef UnitsApi::Methods
static

◆ UserPrefDecimals

int UnitsApi::UserPrefDecimals = 2
staticprotected

number of decimals for floats

Referenced by getDecimals(), and setDecimals().

◆ UserPrefSystem

UnitsSchemaPtr UnitsApi::UserPrefSystem
staticprotected

Referenced by schemaTranslate(), and setSchema().


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