Commit 2d967f2e authored by schultezub's avatar schultezub

* added PropertyCollectionWidget stub with dummy implementation

* AbstractPipeline and AbstractProcessor inherit both from HasPropertyCollection

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@206 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent d22a03ba
...@@ -23,6 +23,7 @@ FILE(GLOB TUMVIS_APPLICATION_HEADERS ...@@ -23,6 +23,7 @@ FILE(GLOB TUMVIS_APPLICATION_HEADERS
SET(TUMVIS_APPLICATION_TO_BE_MOCCED SET(TUMVIS_APPLICATION_TO_BE_MOCCED
gui/mainwindow.h gui/mainwindow.h
gui/pipelinetreewidget.h gui/pipelinetreewidget.h
gui/propertycollectionwidget.h
) )
# #
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "tgt/assert.h" #include "tgt/assert.h"
#include "application/tumvisapplication.h" #include "application/tumvisapplication.h"
#include "core/pipeline/abstractpipeline.h"
#include "core/pipeline/abstractprocessor.h"
namespace TUMVis { namespace TUMVis {
...@@ -19,10 +21,27 @@ namespace TUMVis { ...@@ -19,10 +21,27 @@ namespace TUMVis {
} }
void MainWindow::setup() { void MainWindow::setup() {
_pipelineWidget = new PipelineTreeWidget(this); _centralWidget = new QWidget(this);
setCentralWidget(_pipelineWidget); QHBoxLayout* boxLayout = new QHBoxLayout();
connect(this, SIGNAL(updatePipelineWidget(const std::vector<AbstractPipeline*>&)), _pipelineWidget, SLOT(update(const std::vector<AbstractPipeline*>&))); _pipelineWidget = new PipelineTreeWidget(_centralWidget);
boxLayout->addWidget(_pipelineWidget);
_propCollectionWidget = new PropertyCollectionWidget(_centralWidget);
boxLayout->addWidget(_propCollectionWidget);
_centralWidget->setLayout(boxLayout);
setCentralWidget(_centralWidget);
connect(
this, SIGNAL(updatePipelineWidget(const std::vector<AbstractPipeline*>&)),
_pipelineWidget, SLOT(update(const std::vector<AbstractPipeline*>&)));
connect(
_pipelineWidget, SIGNAL(clicked(const QModelIndex&)),
this, SLOT(onPipelineWidgetItemClicked(const QModelIndex&)));
connect(
this, SIGNAL(updatePropCollectionWidget(PropertyCollection*)),
_propCollectionWidget, SLOT(updatePropCollection(PropertyCollection*)));
_application->s_PipelinesChanged.connect(this, &MainWindow::onPipelinesChanged); _application->s_PipelinesChanged.connect(this, &MainWindow::onPipelinesChanged);
} }
...@@ -30,4 +49,21 @@ namespace TUMVis { ...@@ -30,4 +49,21 @@ namespace TUMVis {
emit updatePipelineWidget(_application->_pipelines); emit updatePipelineWidget(_application->_pipelines);
} }
void MainWindow::onPipelineWidgetItemClicked(const QModelIndex& index) {
if (index.isValid()) {
// Yak, this is so ugly - another reason why GUI programming sucks...
QVariant item = index.data(Qt::UserRole);
HasPropertyCollection* ptr = static_cast<HasPropertyCollection*>(item.value<void*>());
if (ptr != 0) {
emit updatePropCollectionWidget(&(ptr->getPropertyCollection()));
}
else {
emit updatePropCollectionWidget(0);
}
}
else {
emit updatePropCollectionWidget(0);
}
}
} }
\ No newline at end of file
...@@ -4,8 +4,11 @@ ...@@ -4,8 +4,11 @@
#include "sigslot/sigslot.h" #include "sigslot/sigslot.h"
#include "application/tumvisapplication.h" #include "application/tumvisapplication.h"
#include "application/gui/pipelinetreewidget.h" #include "application/gui/pipelinetreewidget.h"
#include "application/gui/propertycollectionwidget.h"
#include <QMainWindow> #include <QMainWindow>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <vector> #include <vector>
namespace TUMVis { namespace TUMVis {
...@@ -35,9 +38,17 @@ namespace TUMVis { ...@@ -35,9 +38,17 @@ namespace TUMVis {
void onPipelinesChanged(); void onPipelinesChanged();
signals: signals:
/// Qt signal for updating the PipelineWidget. /// Qt signal for updating the PipelineWidget.
void updatePipelineWidget(const std::vector<AbstractPipeline*>&); void updatePipelineWidget(const std::vector<AbstractPipeline*>&);
/// Qt signal for updating the PropertyCollectionWidget
void updatePropCollectionWidget(PropertyCollection*);
private slots:
/**
* Slot to be called by the PipelineWidget when the selected item changes.
* \param index Index of the selected item
*/
void onPipelineWidgetItemClicked(const QModelIndex& index);
private: private:
/** /**
...@@ -45,10 +56,11 @@ namespace TUMVis { ...@@ -45,10 +56,11 @@ namespace TUMVis {
*/ */
void setup(); void setup();
TumVisApplication* _application; ///< Pointer to the application hosting the whole stuff TumVisApplication* _application; ///< Pointer to the application hosting the whole stuff
PipelineTreeWidget* _pipelineWidget; ///< Widget for browsing the active pipelines
QWidget* _centralWidget; ///< Central widget of the MainWindow
PipelineTreeWidget* _pipelineWidget; ///< Widget for browsing the active pipelines
PropertyCollectionWidget* _propCollectionWidget; ///< Widget for brosing the PropertyCollection of the selected pipeline/processor
}; };
} }
......
...@@ -45,11 +45,16 @@ namespace TUMVis { ...@@ -45,11 +45,16 @@ namespace TUMVis {
tgtAssert(_pipeline != 0, "Pipeline must not be 0."); tgtAssert(_pipeline != 0, "Pipeline must not be 0.");
} }
QVariant PipelineTreeItem::getData(int column) const { QVariant PipelineTreeItem::getData(int column, int role) const {
if (column == 0) switch (role) {
return QVariant(QString::fromStdString(_pipeline->getName())); case Qt::DisplayRole:
if (column == 0)
return QVariant(); return QVariant(QString::fromStdString(_pipeline->getName()));
case Qt::UserRole:
return qVariantFromValue(static_cast<void*>(_pipeline));
default:
return QVariant();
}
} }
PipelineTreeItem::~PipelineTreeItem() { PipelineTreeItem::~PipelineTreeItem() {
...@@ -63,11 +68,16 @@ namespace TUMVis { ...@@ -63,11 +68,16 @@ namespace TUMVis {
tgtAssert(_processor != 0, "Processor must not be 0."); tgtAssert(_processor != 0, "Processor must not be 0.");
} }
QVariant ProcessorTreeItem::getData(int column) const { QVariant ProcessorTreeItem::getData(int column, int role) const {
if (column == 0) switch (role) {
return QVariant(QString::fromStdString(_processor->getName())); case Qt::DisplayRole:
if (column == 0)
return QVariant(); return QVariant(QString::fromStdString(_processor->getName()));
case Qt::UserRole:
return qVariantFromValue(static_cast<void*>(_processor));
default:
return QVariant();
}
} }
ProcessorTreeItem::~ProcessorTreeItem() { ProcessorTreeItem::~ProcessorTreeItem() {
...@@ -77,11 +87,13 @@ namespace TUMVis { ...@@ -77,11 +87,13 @@ namespace TUMVis {
: TreeItem(parent) : TreeItem(parent)
{} {}
QVariant RootTreeItem::getData(int column) const { QVariant RootTreeItem::getData(int column, int role) const {
if (column == 0) if (role == Qt::DisplayRole) {
return QVariant(QString("Pipeline/Processor")); if (column == 0)
else if (column == 1) return QVariant(QString("Pipeline/Processor"));
return QVariant(QString("Description")); else if (column == 1)
return QVariant(QString("Description"));
}
return QVariant(); return QVariant();
} }
...@@ -106,11 +118,8 @@ namespace TUMVis { ...@@ -106,11 +118,8 @@ namespace TUMVis {
if (!index.isValid()) if (!index.isValid())
return QVariant(); return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
TreeItem* item = static_cast<TreeItem*>(index.internalPointer()); TreeItem* item = static_cast<TreeItem*>(index.internalPointer());
return item->getData(index.column()); return item->getData(index.column(), role);
} }
Qt::ItemFlags PipelineTreeModel::flags(const QModelIndex &index) const { Qt::ItemFlags PipelineTreeModel::flags(const QModelIndex &index) const {
...@@ -122,7 +131,7 @@ namespace TUMVis { ...@@ -122,7 +131,7 @@ namespace TUMVis {
QVariant PipelineTreeModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/) const { QVariant PipelineTreeModel::headerData(int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/) const {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
return _rootItem->getData(section); return _rootItem->getData(section, role);
return QVariant(); return QVariant();
} }
......
...@@ -36,7 +36,7 @@ namespace TUMVis { ...@@ -36,7 +36,7 @@ namespace TUMVis {
* \param column Column * \param column Column
* \return The data of this item at \a column. * \return The data of this item at \a column.
*/ */
virtual QVariant getData(int column) const = 0; virtual QVariant getData(int column, int role) const = 0;
/** /**
* Returns the parent TreeItem * Returns the parent TreeItem
...@@ -77,7 +77,7 @@ namespace TUMVis { ...@@ -77,7 +77,7 @@ namespace TUMVis {
virtual ~RootTreeItem(); virtual ~RootTreeItem();
/// \see TreeItem::getData() /// \see TreeItem::getData()
virtual QVariant getData(int column) const; virtual QVariant getData(int column, int role) const;
}; };
/** /**
...@@ -89,7 +89,7 @@ namespace TUMVis { ...@@ -89,7 +89,7 @@ namespace TUMVis {
virtual ~PipelineTreeItem(); virtual ~PipelineTreeItem();
/// \see TreeItem::getData() /// \see TreeItem::getData()
virtual QVariant getData(int column) const; virtual QVariant getData(int column, int role) const;
private: private:
AbstractPipeline* _pipeline; ///< Base pipeline AbstractPipeline* _pipeline; ///< Base pipeline
...@@ -104,7 +104,7 @@ namespace TUMVis { ...@@ -104,7 +104,7 @@ namespace TUMVis {
virtual ~ProcessorTreeItem(); virtual ~ProcessorTreeItem();
/// \see TreeItem::getData() /// \see TreeItem::getData()
virtual QVariant getData(int column) const; virtual QVariant getData(int column, int role) const;
private: private:
AbstractProcessor* _processor; ///< Base processor AbstractProcessor* _processor; ///< Base processor
......
#include "propertycollectionwidget.h"
#include "core/properties/abstractproperty.h"
#include "core/properties/propertycollection.h"
#include <QPushButton>
namespace TUMVis {
PropertyCollectionWidget::PropertyCollectionWidget(QWidget* parent /*= 0*/)
: QWidget(parent)
, _propCollection(0)
, _layout(0)
{
setupWidget();
}
PropertyCollectionWidget::~PropertyCollectionWidget() {
qDeleteAll(_widgetList);
}
void PropertyCollectionWidget::updatePropCollection(PropertyCollection* propertyCollection) {
// just some dummy implementation for property widget listing:
for (QList<QWidget*>::iterator it = _widgetList.begin(); it != _widgetList.end(); ++it) {
_layout->removeWidget(*it);
}
qDeleteAll(_widgetList);
_widgetList.clear();
for (std::vector<AbstractProperty*>::const_iterator it = propertyCollection->getProperties().begin(); it != propertyCollection->getProperties().end(); ++it) {
QPushButton* propWidget = new QPushButton(QString::fromStdString((*it)->getTitle()));
_widgetList.push_back(propWidget);
_layout->addWidget(propWidget);
}
}
void PropertyCollectionWidget::setupWidget() {
_layout = new QVBoxLayout();
setLayout(_layout);
}
}
\ No newline at end of file
#ifndef PROPERTYCOLLECTIONWIDGET_H__
#define PROPERTYCOLLECTIONWIDGET_H__
#include <QList>
#include <QVBoxLayout>
#include <QWidget>
namespace TUMVis {
class PropertyCollection;
/**
* Main Window for the TUMVis application.
* Wraps a nice Qt GUI around the TumVisApplication instance given during creation.
*/
class PropertyCollectionWidget : public QWidget {
Q_OBJECT;
public:
/**
* Creates a new PropertyCollectionWidget.
* \param parent Parent widget, may be 0.
*/
PropertyCollectionWidget(QWidget* parent = 0);
/**
* Destructor.
*/
~PropertyCollectionWidget();
public slots:
/**
* Updates the property collection this widget works on.
* \param propertyCollection New PropertyCollection for this widget, may be 0.
*/
void updatePropCollection(PropertyCollection* propertyCollection);
private:
/**
* Sets up this widget
*/
void setupWidget();
PropertyCollection* _propCollection; ///< The PropertyCollection this widget is currently working on.
QVBoxLayout* _layout;
QList<QWidget*> _widgetList;
};
}
#endif // PROPERTYCOLLECTIONWIDGET_H__
...@@ -7,16 +7,13 @@ namespace TUMVis { ...@@ -7,16 +7,13 @@ namespace TUMVis {
const std::string AbstractPipeline::loggerCat_ = "TUMVis.core.datastructures.AbstractPipeline"; const std::string AbstractPipeline::loggerCat_ = "TUMVis.core.datastructures.AbstractPipeline";
AbstractPipeline::AbstractPipeline() AbstractPipeline::AbstractPipeline()
: HasPropertyCollection()
{ {
} }
AbstractPipeline::~AbstractPipeline() { AbstractPipeline::~AbstractPipeline() {
} }
PropertyCollection& AbstractPipeline::getPropertyCollection() {
return _properties;
}
void AbstractPipeline::init() { void AbstractPipeline::init() {
// initialize all processors: // initialize all processors:
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) { for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
......
...@@ -20,7 +20,7 @@ namespace TUMVis { ...@@ -20,7 +20,7 @@ namespace TUMVis {
* Abstract base class for TUMVis Pipelines. * Abstract base class for TUMVis Pipelines.
* *
*/ */
class AbstractPipeline : public GenericObserver<ProcessorObserverArgs> { class AbstractPipeline : public HasPropertyCollection, public GenericObserver<ProcessorObserverArgs> {
friend class PipelineEvaluator; friend class PipelineEvaluator;
public: public:
...@@ -54,12 +54,6 @@ namespace TUMVis { ...@@ -54,12 +54,6 @@ namespace TUMVis {
**/ **/
virtual void execute() = 0; virtual void execute() = 0;
/**
* Returns the PropertyCollection of this pipeline.
* \return _properties
*/
PropertyCollection& getPropertyCollection();
/** /**
* Returns the DataContainer of this pipeline * Returns the DataContainer of this pipeline
* \return _data * \return _data
...@@ -100,7 +94,6 @@ namespace TUMVis { ...@@ -100,7 +94,6 @@ namespace TUMVis {
DataContainer _data; ///< DataContainer containing local working set of data for this Pipeline DataContainer _data; ///< DataContainer containing local working set of data for this Pipeline
std::vector<AbstractProcessor*> _processors; ///< List of all processors of this pipeline std::vector<AbstractProcessor*> _processors; ///< List of all processors of this pipeline
PropertyCollection _properties; ///< PropertyCollection of this pipeline, put in here all properties you want to be publicly accessible
InvalidationLevel _invalidationLevel; ///< current invalidation level InvalidationLevel _invalidationLevel; ///< current invalidation level
tbb::spin_mutex _localMutex; ///< mutex for altering local members tbb::spin_mutex _localMutex; ///< mutex for altering local members
......
...@@ -5,7 +5,9 @@ namespace TUMVis { ...@@ -5,7 +5,9 @@ namespace TUMVis {
const std::string AbstractProcessor::loggerCat_ = "TUMVis.core.datastructures.Processor"; const std::string AbstractProcessor::loggerCat_ = "TUMVis.core.datastructures.Processor";
AbstractProcessor::AbstractProcessor() { AbstractProcessor::AbstractProcessor()
: HasPropertyCollection()
{
} }
AbstractProcessor::~AbstractProcessor() { AbstractProcessor::~AbstractProcessor() {
...@@ -29,10 +31,6 @@ namespace TUMVis { ...@@ -29,10 +31,6 @@ namespace TUMVis {
applyInvalidationLevel(poa._invalidationLevel); applyInvalidationLevel(poa._invalidationLevel);
} }
PropertyCollection& AbstractProcessor::getPropertyCollection() {
return _properties;
}
void AbstractProcessor::init() { void AbstractProcessor::init() {
} }
......
...@@ -44,7 +44,7 @@ namespace TUMVis { ...@@ -44,7 +44,7 @@ namespace TUMVis {
* *
* \sa AbstractPipeline * \sa AbstractPipeline
*/ */
class AbstractProcessor : public GenericObserver<PropertyObserverArgs>, public GenericObservable<ProcessorObserverArgs> { class AbstractProcessor : public HasPropertyCollection, public GenericObserver<PropertyObserverArgs>, public GenericObservable<ProcessorObserverArgs> {
/** /**
* We have to find a trade-off: * We have to find a trade-off:
...@@ -94,12 +94,6 @@ namespace TUMVis { ...@@ -94,12 +94,6 @@ namespace TUMVis {
*/ */
const InvalidationLevel& getInvalidationLevel() const; const InvalidationLevel& getInvalidationLevel() const;
/**
* Returns the PropertyCollection of this processor.
* \return _properties
*/
PropertyCollection& getPropertyCollection();
/** /**
* Gets the name of this very processor. To be defined by every subclass. * Gets the name of this very processor. To be defined by every subclass.
* \return The name of this processor. * \return The name of this processor.
...@@ -137,7 +131,6 @@ namespace TUMVis { ...@@ -137,7 +131,6 @@ namespace TUMVis {
protected: protected:
InvalidationLevel _invalidationLevel; ///< current invalidation level of this processor InvalidationLevel _invalidationLevel; ///< current invalidation level of this processor
PropertyCollection _properties; ///< PropertyCollection of this processor
static const std::string loggerCat_; static const std::string loggerCat_;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace TUMVis { namespace TUMVis {
/** /**
* Wrapper for a vector of Properties. * Wrapper for a vector of Properties.
* Properties can be registered and then accessed via their names. * Properties can be registered and then accessed via their names.
...@@ -79,6 +78,21 @@ namespace TUMVis { ...@@ -79,6 +78,21 @@ namespace TUMVis {
std::vector<AbstractProperty*> _properties; ///< list of all registered properties std::vector<AbstractProperty*> _properties; ///< list of all registered properties
}; };
class HasPropertyCollection {
public:
HasPropertyCollection() {};
virtual ~HasPropertyCollection() = 0 {};
/**
* Returns the PropertyCollection of this processor.
* \return _properties
*/
PropertyCollection& getPropertyCollection() { return _properties; };
protected:
PropertyCollection _properties; ///< PropertyCollection of this object
};
} }
#endif // PROPERTYCOLLECTION_H__ #endif // PROPERTYCOLLECTION_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