| 90 | } |
| 91 | |
| 92 | void PropertyQuantity::setPyObject(PyObject* value) |
| 93 | { |
| 94 | // Set the unit if Unit object supplied, else check the unit |
| 95 | // and set the value |
| 96 | |
| 97 | if (PyObject_TypeCheck(value, &(UnitPy::Type))) { |
| 98 | Base::UnitPy* pcObject = static_cast<Base::UnitPy*>(value); |
| 99 | Base::Unit unit = *(pcObject->getUnitPtr()); |
| 100 | aboutToSetValue(); |
| 101 | _Unit = unit; |
| 102 | hasSetValue(); |
| 103 | } |
| 104 | else { |
| 105 | Base::Quantity quant = createQuantityFromPy(value); |
| 106 | |
| 107 | if (quant.isDimensionless()) { |
| 108 | PropertyFloat::setValue(quant.getValue()); |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | if (_Unit != quant.getUnit()) { |
| 113 | throw Base::UnitsMismatchError("Not matching Unit!"); |
| 114 | } |
| 115 | |
| 116 | PropertyFloat::setValue(quant.getValue()); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | void PropertyQuantity::setPathValue(const ObjectIdentifier& /*path*/, const boost::any& value) |
| 121 | { |
nothing calls this directly
no test coverage detected