Commit 65217c3a authored by schultezub's avatar schultezub
Browse files

* introducing IntPropertyWidget

* added DataHandle::removeData
* include/forward declaration clean-up

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@208 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent ab68042a
......@@ -26,6 +26,7 @@ SET(TUMVIS_APPLICATION_TO_BE_MOCCED
gui/mainwindow.h
gui/pipelinetreewidget.h
gui/properties/abstractpropertywidget.h
gui/properties/intpropertywidget.h
gui/properties/propertycollectionwidget.h
gui/properties/propertywidgetfactory.h
gui/properties/stringpropertywidget.h
......
......@@ -41,8 +41,10 @@ namespace TUMVis {
*/
virtual void updateWidgetFromProperty() = 0;
AbstractProperty* _property; ///< The property this widget handles
bool _ignorePropertyUpdates; ///< Flag whether the widget shall ignore incoming signals from properties being updated.
AbstractProperty* _property; ///< The property this widget handles
// TODO: This flag is not thread-safe, it probably should be...
bool _ignorePropertyUpdates; ///< Flag whether the widget shall ignore incoming signals from properties being updated.
private:
/// Slot getting called when the property has changed, so that the widget can be updated.
......
#include "intpropertywidget.h"
namespace TUMVis {
IntPropertyWidget::IntPropertyWidget(IntProperty* property, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, parent)
, _spinBox(0)
{
_spinBox = new QSpinBox(this);
_spinBox->setMinimum(property->getMinValue());
_spinBox->setMaximum(property->getMaxValue());
_spinBox->setValue(property->getValue());
addWidget(_spinBox);
connect(_spinBox, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
property->s_minMaxChanged.connect(this, &IntPropertyWidget::onPropertyMinMaxChanged);
}
IntPropertyWidget::~IntPropertyWidget() {
}
void IntPropertyWidget::updateWidgetFromProperty() {
IntProperty* prop = static_cast<IntProperty*>(_property);
_spinBox->blockSignals(true);
_spinBox->setValue(prop->getValue());
_spinBox->blockSignals(false);
}
void IntPropertyWidget::onValueChanged(int value) {
_ignorePropertyUpdates = true;
IntProperty* prop = static_cast<IntProperty*>(_property);
prop->setValue(value);
_ignorePropertyUpdates = false;
}
void IntPropertyWidget::onPropertyMinMaxChanged(const AbstractProperty* property) {
if (!_ignorePropertyUpdates) {
IntProperty* prop = static_cast<IntProperty*>(_property);
_spinBox->setMinimum(prop->getMinValue());
_spinBox->setMaximum(prop->getMaxValue());
}
}
}
\ No newline at end of file
#ifndef INTPROPERTYWIDGET_H__
#define INTPROPERTYWIDGET_H__
#include "application/gui/properties/abstractpropertywidget.h"
#include "core/properties/numericproperty.h"
#include <QSpinBox>
namespace TUMVis {
/**
* Widget for a IntProperty
*/
class IntPropertyWidget : public AbstractPropertyWidget {
Q_OBJECT;
public:
/**
* Creates a new IntPropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*/
IntPropertyWidget(IntProperty* property, QWidget* parent = 0);
/**
* Destructor
*/
virtual ~IntPropertyWidget();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual void updateWidgetFromProperty();
private slots:
void onValueChanged(int 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);
QSpinBox* _spinBox;
};
}
#endif // INTPROPERTYWIDGET_H__
#include "propertywidgetfactory.h"
#include "application/gui/properties/abstractpropertywidget.h"
#include "application/gui/properties/intpropertywidget.h"
#include "application/gui/properties/stringpropertywidget.h"
#include "core/properties/abstractproperty.h"
......@@ -17,6 +18,10 @@ namespace TUMVis {
return new StringPropertyWidget(tester);
}
if (IntProperty* tester = dynamic_cast<IntProperty*>(property)) {
return new IntPropertyWidget(tester);
}
return 0;
}
......
......@@ -5,11 +5,12 @@ namespace TUMVis {
: AbstractPropertyWidget(property, parent)
, _lineEdit(0)
{
_lineEdit = new QLineEdit(QString::fromStdString(property->getValue()));
_lineEdit = new QLineEdit(this);
_lineEdit->setText(QString::fromStdString(property->getValue()));
addWidget(_lineEdit);
connect(_lineEdit, SIGNAL(textChanged(const QString&)), this, SIGNAL(onTextChanged(const QString&)));
connect(_lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&)));
}
StringPropertyWidget::~StringPropertyWidget() {
......@@ -28,6 +29,8 @@ namespace TUMVis {
void StringPropertyWidget::onTextChanged(const QString& text) {
StringProperty* prop = static_cast<StringProperty*>(_property);
_ignorePropertyUpdates = true;
prop->setValue(text.toStdString());
_ignorePropertyUpdates = false;
}
}
\ No newline at end of file
......@@ -4,9 +4,6 @@
#include "core/tools/referencecounted.h"
namespace TUMVis {
class DataHandle;
/**
* Abstract base class for data handled by a DataHandle and stored in a DataContainer.
*
......
#include "datacontainer.h"
#include "tgt/assert.h"
#include "core/datastructures/abstractdata.h"
namespace TUMVis {
const std::string DataContainer::loggerCat_ = "TUMVis.core.datastructures.DataContainer";
......@@ -51,4 +53,13 @@ namespace TUMVis {
else
return new DataHandle(*it->second);
}
void DataContainer::removeData(const std::string& name) {
tbb::spin_mutex::scoped_lock lock(_localMutex);
std::map<std::string, const DataHandle*>::const_iterator it = _handles.find(name);
if (it != _handles.end()) {
delete it->second;
_handles.erase(it);
}
}
}
\ No newline at end of file
......@@ -3,14 +3,14 @@
#include "sigslot/sigslot.h"
#include "tbb/include/tbb/spin_mutex.h"
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/datahandle.h"
#include "core/tools/observer.h"
#include <string>
#include <map>
namespace TUMVis {
class AbstractData;
/**
* A DataContainer manages instances of AbstractData and offers access to them via string identifiers (names/keys).
* Therefore, it stores them in DataHandles which take ownership of the AbstractData instance. Hence,
......@@ -136,6 +136,12 @@ namespace TUMVis {
*/
const DataHandle* getData(const std::string& name) const;
/**
* Removes the DataHandle with the given name from this container.
* If no such DataHandle exists, nothing happens.
* \param name Key of the DataHandle to remove.
*/
void removeData(const std::string& name);
sigslot::signal2<const std::string&, const DataHandle*> s_dataAdded;
......
#include "datahandle.h"
#include "tgt/assert.h"
#include "tgt/logmanager.h"
#include "core/datastructures/abstractdata.h"
namespace TUMVis {
const std::string DataHandle::loggerCat_ = "TUMVis.core.datastructures.DataHandle";
DataHandle::DataHandle(AbstractData* data)
: _data(data)
{
......
#ifndef datahandle_h__
#define datahandle_h__
#include <string>
namespace TUMVis {
class AbstractData;
......@@ -70,8 +68,6 @@ namespace TUMVis {
void init();
AbstractData* _data; ///< managed data
static const std::string loggerCat_;
};
}
......
......@@ -35,6 +35,9 @@ namespace TUMVis {
template<class TO>
TO* TUMVis::ImageDataConverter::tryConvert(const ImageData* source) {
if (source == 0)
return 0;
// test source image type via dynamic cast
if (const ImageDataDisk* tester = dynamic_cast<const ImageDataDisk*>(source)) {
return convert<ImageDataDisk, TO>(tester);
......
......@@ -2,7 +2,7 @@
#define ABSTRACTEVENTHANDLER_H__
#include "tgt/logmanager.h"
#include "tgt/event/eventlistener.h"
#include "tgt/event/event.h"
namespace TUMVis {
......
#include "mwheeltonumericpropertyeventhandler.h"
#include "tgt/assert.h"
#include "tgt/event/mouseevent.h"
#include "core/properties/numericproperty.h"
namespace TUMVis {
const std::string MWheelToNumericPropertyEventHandler::loggerCat_ = "TUMVis.core.eventhandler.MWheelToNumericPropertyEventHandler";
......
......@@ -3,9 +3,9 @@
#include "tgt/logmanager.h"
#include "core/eventhandlers/abstracteventhandler.h"
#include "core/properties/numericproperty.h"
namespace TUMVis {
class INumericProperty;
/**
* Event handler that maps mouse wheel events to a numeric property.
......
......@@ -6,16 +6,16 @@
#include "tbb/include/tbb/spin_mutex.h"
#include "tbb/include/tbb/mutex.h"
#include "tbb/include/tbb/compat/condition_variable"
#include "core/tools/observer.h"
#include "core/tools/invalidationlevel.h"
#include "core/datastructures/datacontainer.h"
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/propertycollection.h"
#include <vector>
namespace TUMVis {
class AbstractProcessor;
class PipelineEvaluator;
/**
* Abstract base class for TUMVis Pipelines.
*
......
......@@ -3,15 +3,16 @@
#include "sigslot/sigslot.h"
#include "tgt/logmanager.h"
#include "core/tools/invalidationlevel.h"
#include "core/datastructures/datacontainer.h"
#include "core/properties/abstractproperty.h"
#include "core/tools/invalidationlevel.h"
#include "core/properties/propertycollection.h"
#include <string>
#include <vector>
namespace TUMVis {
class AbstractProperty;
/**
* Abstract base class for TUMVis Processors.
* A processor implements a specific task, which it performs on the DataCollection passed
......
#include "pipelineevaluator.h"
#include "tgt/qt/qtcontextmanager.h"
#include "core/pipeline/abstractpipeline.h"
namespace TUMVis {
PipelineEvaluator::PipelineEvaluator(AbstractPipeline* pipeline)
......
......@@ -2,18 +2,19 @@
#define PIPELINEEVALUATOR_H__
#include "sigslot/sigslot.h"
#include "core/pipeline/abstractpipeline.h"
#include "core/tools/runnable.h"
#include "tbb/include/tbb/compat/condition_variable"
namespace TUMVis {
class AbstractPipeline;
/**
* The PipelineEvaluator evaluates its pipeline in its own thread.
* Evaluation is implemented using condidional wait - hence the pipeline is only evaluated when
* \a pipeline emits the s_PipelineInvalidated signal.
*
* \sa Runnable
* \todo Let one PipelineEvaluator evaluate multiple pipelines.
* \sa Runnable
*/
class PipelineEvaluator : public Runnable, public sigslot::has_slots<> {
public:
......
#include "visualizationpipeline.h"
#include "tgt/camera.h"
#include "tgt/quadrenderer.h"
#include "tgt/quadric.h"
#include "tgt/glcanvas.h"
#include "tgt/glcontext.h"
#include "core/datastructures/imagedatarendertarget.h"
......
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