The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit ecf594d5 authored by Artur Grunau's avatar Artur Grunau
Browse files

FloatPropertyWidget: configurable decimal places

FloatPropertyWidget and VecPropertyWidget configure their adjusters to
display as many decimals as their properties have significant decimal
places. Moreover, they connect to the s_decimalsChanged signal in order
to reconfigure their adjusters when the number of significant decimal
places of their properties changes.
parent f318af5c
......@@ -34,12 +34,10 @@ namespace campvis {
: AbstractPropertyWidget(property, false, parent)
, _adjuster(0)
{
const float stepValue = 0.01f;
_adjuster = new DoubleAdjusterWidget();
_adjuster->setMinimum(property->getMinValue());
_adjuster->setMaximum(property->getMaxValue());
_adjuster->setDecimals(3);
_adjuster->setDecimals(property->getDecimals());
_adjuster->setSingleStep(property->getStepValue());
_adjuster->setValue(property->getValue());
......@@ -48,11 +46,15 @@ namespace campvis {
connect(_adjuster, SIGNAL(valueChanged(double)), this, SLOT(onAdjusterValueChanged(double)));
property->s_minMaxChanged.connect(this, &FloatPropertyWidget::onPropertyMinMaxChanged);
property->s_stepChanged.connect(this, &FloatPropertyWidget::onPropertyStepChanged);
property->s_decimalsChanged.connect(this, &FloatPropertyWidget::onPropertyDecimalsChanged);
}
FloatPropertyWidget::~FloatPropertyWidget() {
static_cast<FloatProperty*>(_property)->s_minMaxChanged.disconnect(this);
static_cast<FloatProperty*>(_property)->s_stepChanged.disconnect(this);
FloatProperty* property = static_cast<FloatProperty*>(_property);
property->s_minMaxChanged.disconnect(this);
property->s_stepChanged.disconnect(this);
property->s_decimalsChanged.disconnect(this);
}
void FloatPropertyWidget::updateWidgetFromProperty() {
......@@ -83,4 +85,11 @@ namespace campvis {
_adjuster->setSingleStep(prop->getStepValue());
}
}
void FloatPropertyWidget::onPropertyDecimalsChanged(const AbstractProperty* property) {
if (_ignorePropertyUpdates == 0) {
const FloatProperty* prop = static_cast<const FloatProperty*>(property);
_adjuster->setDecimals(prop->getDecimals());
}
}
}
......@@ -71,6 +71,12 @@ namespace campvis {
/// Slot getting called when the property's step value has changed, so that the widget can be updated.
virtual void onPropertyStepChanged(const AbstractProperty* property);
/**
* Slot getting called when the number of significant decimal places of the property has
* changed, so that the widget can be updated.
*/
virtual void onPropertyDecimalsChanged(const AbstractProperty* property);
DoubleAdjusterWidget* _adjuster; ///< Widget allowing the user to change the property's value
};
......@@ -139,6 +145,12 @@ namespace campvis {
/// Slot getting called when the property's step value has changed, so that the widget can be updated.
virtual void onPropertyStepChanged(const AbstractProperty* property);
/**
* Slot getting called when the number of significant decimal places of the property has
* changed, so that the widget can be updated.
*/
virtual void onPropertyDecimalsChanged(const AbstractProperty* property);
DoubleAdjusterWidget* _adjusters[size];
};
......@@ -152,7 +164,7 @@ namespace campvis {
_adjusters[i] = new DoubleAdjusterWidget();
_adjusters[i]->setMinimum(property->getMinValue()[i]);
_adjusters[i]->setMaximum(property->getMaxValue()[i]);
_adjusters[i]->setDecimals(3);
_adjusters[i]->setDecimals(property->getDecimals()[i]);
_adjusters[i]->setSingleStep(property->getStepValue()[i]);
_adjusters[i]->setValue(property->getValue()[i]);
addWidget(_adjusters[i]);
......@@ -160,12 +172,16 @@ namespace campvis {
property->s_minMaxChanged.connect(this, &VecPropertyWidget::onPropertyMinMaxChanged);
property->s_stepChanged.connect(this, &VecPropertyWidget::onPropertyStepChanged);
property->s_decimalsChanged.connect(this, &VecPropertyWidget::onPropertyDecimalsChanged);
}
template<size_t SIZE>
campvis::VecPropertyWidget<SIZE>::~VecPropertyWidget() {
static_cast<PropertyType*>(_property)->s_minMaxChanged.disconnect(this);
static_cast<PropertyType*>(_property)->s_stepChanged.disconnect(this);
PropertyType* property = static_cast<PropertyType*>(_property);
property->s_minMaxChanged.disconnect(this);
property->s_stepChanged.disconnect(this);
property->s_decimalsChanged.disconnect(this);
}
template<size_t SIZE>
......@@ -210,6 +226,16 @@ namespace campvis {
}
}
template<size_t SIZE>
void campvis::VecPropertyWidget<SIZE>::onPropertyDecimalsChanged(const AbstractProperty* property) {
if (_ignorePropertyUpdates == 0) {
PropertyType* prop = static_cast<PropertyType*>(_property);
for (size_t i = 0; i < size; ++i) {
_adjusters[i]->setDecimals(prop->getDecimals()[i]);
}
}
}
// ================================================================================================
class Vec2PropertyWidget : public VecPropertyWidget<2> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment