Commit 0c21a2ad authored by schultezub's avatar schultezub
Browse files

introducing BoolPropertyWidget

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@223 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent cf0b42bf
......@@ -22,6 +22,7 @@ SET(TUMVIS_APPLICATION_TO_BE_MOCCED
gui/qtcolortools.h
gui/properties/abstractpropertywidget.h
gui/properties/abstracttransferfunctioneditor.h
gui/properties/boolpropertywidget.h
gui/properties/intpropertywidget.h
gui/properties/floatpropertywidget.h
gui/properties/propertycollectionwidget.h
......
#include "boolpropertywidget.h"
#include <QCheckBox>
namespace TUMVis {
BoolPropertyWidget::BoolPropertyWidget(BoolProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
, _spinBox(0)
{
_spinBox = new QCheckBox(this);
_spinBox->setChecked(property->getValue());
addWidget(_spinBox);
connect(_spinBox, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
}
BoolPropertyWidget::~BoolPropertyWidget() {
}
void BoolPropertyWidget::updateWidgetFromProperty() {
BoolProperty* prop = static_cast<BoolProperty*>(_property);
_spinBox->blockSignals(true);
_spinBox->setChecked(prop->getValue());
_spinBox->blockSignals(false);
}
void BoolPropertyWidget::onStateChanged(int value) {
_ignorePropertyUpdates = true;
BoolProperty* prop = static_cast<BoolProperty*>(_property);
prop->setValue(_spinBox->isChecked());
_ignorePropertyUpdates = false;
}
}
\ No newline at end of file
#ifndef BOOLPROPERTYWIDGET_H__
#define BOOLPROPERTYWIDGET_H__
#include "application/gui/properties/abstractpropertywidget.h"
#include "core/properties/genericproperty.h"
class QCheckBox;
namespace TUMVis {
/**
* Widget for a IntProperty
*/
class BoolPropertyWidget : public AbstractPropertyWidget {
Q_OBJECT;
public:
/**
* Creates a new BoolPropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*/
BoolPropertyWidget(BoolProperty* property, QWidget* parent = 0);
/**
* Destructor
*/
virtual ~BoolPropertyWidget();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual void updateWidgetFromProperty();
private slots:
void onStateChanged(int value);
private:
QCheckBox* _spinBox;
};
}
#endif // BOOLPROPERTYWIDGET_H__
#include "propertywidgetfactory.h"
#include "application/gui/properties/abstractpropertywidget.h"
#include "application/gui/properties/boolpropertywidget.h"
#include "application/gui/properties/intpropertywidget.h"
#include "application/gui/properties/floatpropertywidget.h"
#include "application/gui/properties/stringpropertywidget.h"
......@@ -16,6 +17,10 @@ namespace TUMVis {
AbstractPropertyWidget* PropertyWidgetFactory::createWidget(AbstractProperty* property) {
tgtAssert(property != 0, "Property must not be 0.");
if (BoolProperty* tester = dynamic_cast<BoolProperty*>(property)) {
return new BoolPropertyWidget(tester);
}
if (IntProperty* tester = dynamic_cast<IntProperty*>(property)) {
return new IntPropertyWidget(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