App: Apply clang format (part 2)
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cfloat>
|
||||
#include <cfloat>
|
||||
#endif
|
||||
|
||||
#include <Base/QuantityPy.h>
|
||||
@@ -37,8 +37,8 @@ using namespace Base;
|
||||
using namespace std;
|
||||
|
||||
|
||||
const PropertyQuantityConstraint::Constraints LengthStandard = {0.0,DBL_MAX,1.0};
|
||||
const PropertyQuantityConstraint::Constraints AngleStandard = {-360,360,1.0};
|
||||
const PropertyQuantityConstraint::Constraints LengthStandard = {0.0, DBL_MAX, 1.0};
|
||||
const PropertyQuantityConstraint::Constraints AngleStandard = {-360, 360, 1.0};
|
||||
|
||||
//**************************************************************************
|
||||
// PropertyQuantity
|
||||
@@ -48,7 +48,7 @@ TYPESYSTEM_SOURCE(App::PropertyQuantity, App::PropertyFloat)
|
||||
|
||||
Base::Quantity PropertyQuantity::getQuantityValue() const
|
||||
{
|
||||
return Quantity(_dValue,_Unit);
|
||||
return Quantity(_dValue, _Unit);
|
||||
}
|
||||
|
||||
const char* PropertyQuantity::getEditorName() const
|
||||
@@ -56,24 +56,26 @@ const char* PropertyQuantity::getEditorName() const
|
||||
return "Gui::PropertyEditor::PropertyUnitItem";
|
||||
}
|
||||
|
||||
PyObject *PropertyQuantity::getPyObject()
|
||||
PyObject* PropertyQuantity::getPyObject()
|
||||
{
|
||||
return new QuantityPy (new Quantity(_dValue,_Unit));
|
||||
return new QuantityPy(new Quantity(_dValue, _Unit));
|
||||
}
|
||||
|
||||
Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject *value)
|
||||
Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject* value)
|
||||
{
|
||||
Base::Quantity quant;
|
||||
|
||||
if (PyUnicode_Check(value)){
|
||||
if (PyUnicode_Check(value)) {
|
||||
quant = Quantity::parse(QString::fromUtf8(PyUnicode_AsUTF8(value)));
|
||||
}
|
||||
else if (PyFloat_Check(value))
|
||||
quant = Quantity(PyFloat_AsDouble(value),_Unit);
|
||||
else if (PyLong_Check(value))
|
||||
quant = Quantity(double(PyLong_AsLong(value)),_Unit);
|
||||
else if (PyFloat_Check(value)) {
|
||||
quant = Quantity(PyFloat_AsDouble(value), _Unit);
|
||||
}
|
||||
else if (PyLong_Check(value)) {
|
||||
quant = Quantity(double(PyLong_AsLong(value)), _Unit);
|
||||
}
|
||||
else if (PyObject_TypeCheck(value, &(QuantityPy::Type))) {
|
||||
Base::QuantityPy *pcObject = static_cast<Base::QuantityPy*>(value);
|
||||
Base::QuantityPy* pcObject = static_cast<Base::QuantityPy*>(value);
|
||||
quant = *(pcObject->getQuantityPtr());
|
||||
}
|
||||
else {
|
||||
@@ -85,45 +87,47 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject *value)
|
||||
return quant;
|
||||
}
|
||||
|
||||
void PropertyQuantity::setPyObject(PyObject *value)
|
||||
void PropertyQuantity::setPyObject(PyObject* value)
|
||||
{
|
||||
// Set the unit if Unit object supplied, else check the unit
|
||||
// and set the value
|
||||
|
||||
if (PyObject_TypeCheck(value, &(UnitPy::Type))) {
|
||||
Base::UnitPy *pcObject = static_cast<Base::UnitPy*>(value);
|
||||
Base::UnitPy* pcObject = static_cast<Base::UnitPy*>(value);
|
||||
Base::Unit unit = *(pcObject->getUnitPtr());
|
||||
aboutToSetValue();
|
||||
_Unit = unit;
|
||||
hasSetValue();
|
||||
}
|
||||
else {
|
||||
Base::Quantity quant= createQuantityFromPy(value);
|
||||
Base::Quantity quant = createQuantityFromPy(value);
|
||||
|
||||
Unit unit = quant.getUnit();
|
||||
if (unit.isEmpty()){
|
||||
if (unit.isEmpty()) {
|
||||
PropertyFloat::setValue(quant.getValue());
|
||||
return;
|
||||
}
|
||||
|
||||
if (unit != _Unit)
|
||||
if (unit != _Unit) {
|
||||
throw Base::UnitsMismatchError("Not matching Unit!");
|
||||
}
|
||||
|
||||
PropertyFloat::setValue(quant.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyQuantity::setPathValue(const ObjectIdentifier & /*path*/, const boost::any &value)
|
||||
void PropertyQuantity::setPathValue(const ObjectIdentifier& /*path*/, const boost::any& value)
|
||||
{
|
||||
auto q = App::anyToQuantity(value);
|
||||
aboutToSetValue();
|
||||
if(!q.getUnit().isEmpty())
|
||||
if (!q.getUnit().isEmpty()) {
|
||||
_Unit = q.getUnit();
|
||||
_dValue=q.getValue();
|
||||
}
|
||||
_dValue = q.getValue();
|
||||
setValue(q.getValue());
|
||||
}
|
||||
|
||||
const boost::any PropertyQuantity::getPathValue(const ObjectIdentifier & /*path*/) const
|
||||
const boost::any PropertyQuantity::getPathValue(const ObjectIdentifier& /*path*/) const
|
||||
{
|
||||
return Quantity(_dValue, _Unit);
|
||||
}
|
||||
@@ -145,55 +149,61 @@ const char* PropertyQuantityConstraint::getEditorName() const
|
||||
return "Gui::PropertyEditor::PropertyUnitConstraintItem";
|
||||
}
|
||||
|
||||
const PropertyQuantityConstraint::Constraints* PropertyQuantityConstraint::getConstraints() const
|
||||
const PropertyQuantityConstraint::Constraints* PropertyQuantityConstraint::getConstraints() const
|
||||
{
|
||||
return _ConstStruct;
|
||||
}
|
||||
|
||||
double PropertyQuantityConstraint::getMinimum() const
|
||||
{
|
||||
if (_ConstStruct)
|
||||
if (_ConstStruct) {
|
||||
return _ConstStruct->LowerBound;
|
||||
}
|
||||
return std::numeric_limits<double>::min();
|
||||
}
|
||||
|
||||
double PropertyQuantityConstraint::getMaximum() const
|
||||
{
|
||||
if (_ConstStruct)
|
||||
if (_ConstStruct) {
|
||||
return _ConstStruct->UpperBound;
|
||||
}
|
||||
return std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
double PropertyQuantityConstraint::getStepSize() const
|
||||
{
|
||||
if (_ConstStruct)
|
||||
if (_ConstStruct) {
|
||||
return _ConstStruct->StepSize;
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
void PropertyQuantityConstraint::setPyObject(PyObject *value)
|
||||
void PropertyQuantityConstraint::setPyObject(PyObject* value)
|
||||
{
|
||||
Base::Quantity quant= createQuantityFromPy(value);
|
||||
Base::Quantity quant = createQuantityFromPy(value);
|
||||
|
||||
Unit unit = quant.getUnit();
|
||||
double temp = quant.getValue();
|
||||
if (_ConstStruct) {
|
||||
if (temp > _ConstStruct->UpperBound)
|
||||
if (temp > _ConstStruct->UpperBound) {
|
||||
temp = _ConstStruct->UpperBound;
|
||||
else if (temp < _ConstStruct->LowerBound)
|
||||
}
|
||||
else if (temp < _ConstStruct->LowerBound) {
|
||||
temp = _ConstStruct->LowerBound;
|
||||
}
|
||||
}
|
||||
quant.setValue(temp);
|
||||
|
||||
if (unit.isEmpty()){
|
||||
PropertyFloat::setValue(quant.getValue()); // clazy:exclude=skipped-base-method
|
||||
if (unit.isEmpty()) {
|
||||
PropertyFloat::setValue(quant.getValue()); // clazy:exclude=skipped-base-method
|
||||
return;
|
||||
}
|
||||
|
||||
if (unit != _Unit)
|
||||
if (unit != _Unit) {
|
||||
throw Base::UnitsMismatchError("Not matching Unit!");
|
||||
}
|
||||
|
||||
PropertyFloat::setValue(quant.getValue()); // clazy:exclude=skipped-base-method
|
||||
PropertyFloat::setValue(quant.getValue()); // clazy:exclude=skipped-base-method
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user