Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit cf0b42bf authored by schultezub's avatar schultezub
Browse files

introducing FloatPropertyWidget

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@222 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 47d3a104
......@@ -23,6 +23,7 @@ SET(TUMVIS_APPLICATION_TO_BE_MOCCED
gui/properties/abstractpropertywidget.h
gui/properties/abstracttransferfunctioneditor.h
gui/properties/intpropertywidget.h
gui/properties/floatpropertywidget.h
gui/properties/propertycollectionwidget.h
gui/properties/simpletransferfunctioneditor.h
gui/properties/stringpropertywidget.h
......
#include "floatpropertywidget.h"
namespace TUMVis {
FloatPropertyWidget::FloatPropertyWidget(FloatProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
, _spinBox(0)
{
_spinBox = new QDoubleSpinBox(this);
_spinBox->setMinimum(property->getMinValue());
_spinBox->setMaximum(property->getMaxValue());
_spinBox->setValue(property->getValue());
addWidget(_spinBox);
connect(_spinBox, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged(double)));
property->s_minMaxChanged.connect(this, &FloatPropertyWidget::onPropertyMinMaxChanged);
}
FloatPropertyWidget::~FloatPropertyWidget() {
static_cast<FloatProperty*>(_property)->s_minMaxChanged.disconnect(this);
}
void FloatPropertyWidget::updateWidgetFromProperty() {
FloatProperty* prop = static_cast<FloatProperty*>(_property);
_spinBox->blockSignals(true);
_spinBox->setValue(prop->getValue());
_spinBox->blockSignals(false);
}
void FloatPropertyWidget::onValueChanged(double value) {
_ignorePropertyUpdates = true;
FloatProperty* prop = static_cast<FloatProperty*>(_property);
prop->setValue(value);
_ignorePropertyUpdates = false;
}
void FloatPropertyWidget::onPropertyMinMaxChanged(const AbstractProperty* property) {
if (!_ignorePropertyUpdates) {
FloatProperty* prop = static_cast<FloatProperty*>(_property);
_spinBox->setMinimum(prop->getMinValue());
_spinBox->setMaximum(prop->getMaxValue());
}
}
}
\ No newline at end of file
#ifndef FLOATPROPERTYWIDGET_H__
#define FLOATPROPERTYWIDGET_H__
#include "application/gui/properties/abstractpropertywidget.h"
#include "core/properties/numericproperty.h"
#include <QDoubleSpinBox>
namespace TUMVis {
/**
* Widget for a IntProperty
*/
class FloatPropertyWidget : public AbstractPropertyWidget {
Q_OBJECT;
public:
/**
* Creates a new FloatPropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*/
FloatPropertyWidget(FloatProperty* property, QWidget* parent = 0);
/**
* Destructor
*/
virtual ~FloatPropertyWidget();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual void updateWidgetFromProperty();
private slots:
void onValueChanged(double value);
private:
/// Slot getting called when the property's min or max value has changed, so that the widget can be updated.
virtual void onPropertyMinMaxChanged(const AbstractProperty* property);
QDoubleSpinBox* _spinBox;
};
}
#endif // FLOATPROPERTYWIDGET_H__
......@@ -2,6 +2,7 @@
#include "application/gui/properties/abstractpropertywidget.h"
#include "application/gui/properties/intpropertywidget.h"
#include "application/gui/properties/floatpropertywidget.h"
#include "application/gui/properties/stringpropertywidget.h"
#include "application/gui/properties/transferfunctionpropertywidget.h"
......@@ -19,6 +20,10 @@ namespace TUMVis {
return new IntPropertyWidget(tester);
}
if (FloatProperty* tester = dynamic_cast<FloatProperty*>(property)) {
return new FloatPropertyWidget(tester);
}
if (StringProperty* tester = dynamic_cast<StringProperty*>(property)) {
return new StringPropertyWidget(tester);
}
......
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