Expose some standard units and quantities to Python
This commit is contained in:
@@ -663,8 +663,26 @@ void QuantityPy::setFormat(Py::Dict arg)
|
||||
getQuantityPtr()->setFormat(fmt);
|
||||
}
|
||||
|
||||
PyObject *QuantityPy::getCustomAttributes(const char* /*attr*/) const
|
||||
PyObject *QuantityPy::getCustomAttributes(const char* attr) const
|
||||
{
|
||||
if (strcmp(attr, "Torr") == 0) {
|
||||
return new QuantityPy(new Quantity(Quantity::Torr));
|
||||
}
|
||||
else if (strcmp(attr, "mTorr") == 0) {
|
||||
return new QuantityPy(new Quantity(Quantity::mTorr));
|
||||
}
|
||||
else if (strcmp(attr, "yTorr") == 0) {
|
||||
return new QuantityPy(new Quantity(Quantity::yTorr));
|
||||
}
|
||||
else if (strcmp(attr, "PoundForce") == 0) {
|
||||
return new QuantityPy(new Quantity(Quantity::PoundForce));
|
||||
}
|
||||
else if (strcmp(attr, "AngularMinute") == 0) {
|
||||
return new QuantityPy(new Quantity(Quantity::AngMinute));
|
||||
}
|
||||
else if (strcmp(attr, "AngularSecond") == 0) {
|
||||
return new QuantityPy(new Quantity(Quantity::AngSecond));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,5 +34,11 @@
|
||||
</Documentation>
|
||||
<Parameter Name="Type" Type="String" />
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
<Attribute Name="Signature" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>Returns the signature.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Signature" Type="Tuple" />
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -182,6 +182,21 @@ Py::String UnitPy::getType(void) const
|
||||
return Py::String(getUnitPtr()->getTypeString().toUtf8(),"utf-8");
|
||||
}
|
||||
|
||||
Py::Tuple UnitPy::getSignature(void) const
|
||||
{
|
||||
const UnitSignature & Sig = getUnitPtr()->getSignature();
|
||||
Py::Tuple tuple(8);
|
||||
tuple.setItem(0, Py::Long(Sig.Length));
|
||||
tuple.setItem(1, Py::Long(Sig.Mass));
|
||||
tuple.setItem(2, Py::Long(Sig.Time));
|
||||
tuple.setItem(3, Py::Long(Sig.ElectricCurrent));
|
||||
tuple.setItem(4, Py::Long(Sig.ThermodynamicTemperature));
|
||||
tuple.setItem(5, Py::Long(Sig.AmountOfSubstance));
|
||||
tuple.setItem(6, Py::Long(Sig.LuminousIntensity));
|
||||
tuple.setItem(7, Py::Long(Sig.Angle));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyObject *UnitPy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
||||
Reference in New Issue
Block a user