App: add convenience methods to get minimum, maximum and step size of property constraints

This commit is contained in:
wmayer
2021-03-03 08:12:03 +01:00
parent 20024707a9
commit 30e9ba9609
4 changed files with 77 additions and 0 deletions

View File

@@ -623,6 +623,29 @@ const PropertyIntegerConstraint::Constraints* PropertyIntegerConstraint::getCon
return _ConstStruct;
}
long PropertyIntegerConstraint::getMinimum() const
{
if (_ConstStruct)
return _ConstStruct->LowerBound;
// return the min of int, not long
return std::numeric_limits<int>::min();
}
long PropertyIntegerConstraint::getMaximum() const
{
if (_ConstStruct)
return _ConstStruct->UpperBound;
// return the max of int, not long
return std::numeric_limits<int>::max();
}
long PropertyIntegerConstraint::getStepSize() const
{
if (_ConstStruct)
return _ConstStruct->StepSize;
return 1;
}
void PropertyIntegerConstraint::setPyObject(PyObject *value)
{
#if PY_MAJOR_VERSION < 3
@@ -1102,6 +1125,27 @@ const PropertyFloatConstraint::Constraints* PropertyFloatConstraint::getConstra
return _ConstStruct;
}
double PropertyFloatConstraint::getMinimum() const
{
if (_ConstStruct)
return _ConstStruct->LowerBound;
return std::numeric_limits<double>::min();
}
double PropertyFloatConstraint::getMaximum() const
{
if (_ConstStruct)
return _ConstStruct->UpperBound;
return std::numeric_limits<double>::max();
}
double PropertyFloatConstraint::getStepSize() const
{
if (_ConstStruct)
return _ConstStruct->StepSize;
return 1.0;
}
void PropertyFloatConstraint::setPyObject(PyObject *value)
{
if (PyFloat_Check(value)) {