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 27b69655 authored by schultezub's avatar schultezub
Browse files

some work on DataContainerInspectorWidget

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@310 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent d3e77032
......@@ -55,18 +55,19 @@ namespace TUMVis {
void DataContainerInspectorWidget::setDataContainer(DataContainer* dataContainer) {
if (_dataContainer != 0) {
_dataContainer->s_changed.disconnect(this);
_dataContainer->s_dataAdded.disconnect(this);
}
_dataContainer = dataContainer;
_dctWidget->update(dataContainer);
if (_dataContainer != 0) {
_dataContainer->s_changed.connect(this, &DataContainerInspectorWidget::onDataContainerChanged);
_dataContainer->s_dataAdded.connect(this, &DataContainerInspectorWidget::onDataContainerDataAdded);
}
}
void DataContainerInspectorWidget::onDataContainerChanged() {
void DataContainerInspectorWidget::onDataContainerDataAdded(const std::string& key, const DataHandle* dh) {
emit dataContainerChanged(QString::fromStdString(key), dh);
}
QSize DataContainerInspectorWidget::sizeHint() const {
......@@ -126,6 +127,9 @@ namespace TUMVis {
connect(
_dctWidget, SIGNAL(clicked(const QModelIndex&)),
this, SLOT(onDCTWidgetItemClicked(const QModelIndex&)));
connect(
this, SIGNAL(dataContainerChanged(const QString&, const DataHandle*)),
_dctWidget->getTreeModel(), SLOT(onDataContainerChanged(const QString&, const DataHandle*)));
}
void DataContainerInspectorWidget::updateInfoWidget() {
......
......@@ -76,9 +76,9 @@ namespace TUMVis {
void setDataContainer(DataContainer* dataContainer);
/**
* Slot called when _dataContainer has changed and emitted the s_changed signal.
* Slot called when _dataContainer has changed and emitted the s_dataAdded signal.
*/
void onDataContainerChanged();
void onDataContainerDataAdded(const std::string&, const DataHandle*);
/**
* Size hint for the default window size
......@@ -86,6 +86,9 @@ namespace TUMVis {
*/
QSize sizeHint() const;
signals:
void dataContainerChanged(const QString&, const DataHandle*);
private slots:
/**
* Slot to be called by the DataContainerTreeWidget when the selected item changes.
......
......@@ -52,6 +52,7 @@ namespace TUMVis {
, _name(name)
{
tgtAssert(_dataHandle != 0, "DataHandle must not be 0.");
tgtAssert(_dataHandle->getData() != 0, "WTF - DataHandle with empty data?");
}
QVariant DataHandleTreeItem::getData(int column, int role) const {
......@@ -89,6 +90,11 @@ namespace TUMVis {
delete _dataHandle;
}
void DataHandleTreeItem::setDataHandle(const DataHandle* dataHandle) {
delete _dataHandle;
_dataHandle = dataHandle;
}
// = DataContainerTreeModel ============================================================================
DataContainerTreeModel::DataContainerTreeModel(QObject *parent /*= 0*/)
......@@ -187,12 +193,29 @@ namespace TUMVis {
}
void DataContainerTreeModel::setData(const DataContainer* dataContainer) {
_itemMap.clear();
delete _rootItem;
_rootItem = new DataContainerTreeRootItem();
std::vector< std::pair< std::string, const DataHandle*> > handlesCopy = dataContainer->getDataHandlesCopy();
for (std::vector< std::pair< std::string, const DataHandle*> >::iterator it = handlesCopy.begin(); it != handlesCopy.end(); ++it) {
DataHandleTreeItem* dhti = new DataHandleTreeItem(it->second, it->first, _rootItem);
_itemMap.insert(std::make_pair(QString::fromStdString(it->first), dhti));
}
}
void DataContainerTreeModel::onDataContainerChanged(const QString& key, const DataHandle* dh) {
tgtAssert(dh->getData() != 0, "WTF - DataHandle with empty data?");
std::map<QString, DataHandleTreeItem*>::const_iterator it = _itemMap.lower_bound(key);
if (it == _itemMap.end() || it->first != key) {
DataHandleTreeItem* dhti = new DataHandleTreeItem(new DataHandle(*dh), key.toStdString(), _rootItem);
_itemMap.insert(std::make_pair(key, dhti));
//emit reset();//dataChanged(createIndex(dhti->getRow(), 0, dhti), createIndex(dhti->getRow(), columnCount(), dhti));
}
else {
it->second->setDataHandle(dh);
//emit reset();//dataChanged(createIndex(it->second->getRow(), 0, it->second), createIndex(it->second->getRow(), columnCount(), it->second));
}
}
......@@ -226,6 +249,11 @@ namespace TUMVis {
tgtAssert(_treeModel != 0, "Failed creating TreeViewWidget model.");
setModel(_treeModel);
}
}
DataContainerTreeModel* DataContainerTreeWidget::getTreeModel() {
return _treeModel;
}
}
\ No newline at end of file
......@@ -33,6 +33,7 @@
#include <QTreeWidget>
#include <QList>
#include <QVariant>
#include <map>
#include "application/tools/treeitem.h"
......@@ -75,6 +76,13 @@ namespace TUMVis {
/// \see TreeItem::getData()
virtual QVariant getData(int column, int role) const;
/**
* Sets the DataHandle for this tree item.
* \note DataHandleTreeItem takes ownership of this pointer.
* \param dataHandle The DataHandle to wrap around, DataHandleTreeItem takes ownership of this pointer!
*/
void setDataHandle(const DataHandle* dataHandle);
private:
const DataHandle* _dataHandle; ///< Base DataHandle
std::string _name; ///< Name of that DataHandle
......@@ -112,8 +120,17 @@ namespace TUMVis {
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
public slots:
/**
* Slot being called when a DataHandle has been added to the DataContainer.
* \param key Name of the DataHandle
* \param dh The added DataHandle
*/
void onDataContainerChanged(const QString& key, const DataHandle* dh);
private:
TreeItem* _rootItem;
std::map<QString, DataHandleTreeItem*> _itemMap; ///< Mapping the DataHandle Keys to the TreeItems
};
// = Widget =======================================================================================
......@@ -136,6 +153,12 @@ namespace TUMVis {
*/
virtual ~DataContainerTreeWidget();
/**
* Returns the data model for the TreeView.
* \return _treeModel
*/
DataContainerTreeModel* getTreeModel();
public slots:
/**
......@@ -145,13 +168,14 @@ namespace TUMVis {
void update(const DataContainer* dataContainer);
private:
/**
* Sets up the widget.
*/
void setupWidget();
DataContainerTreeModel* _treeModel; ///< Data model for the TreeView.
DataContainerTreeModel* _treeModel; ///< Data model for the TreeView.
};
......
......@@ -47,6 +47,7 @@ namespace TUMVis {
}
const DataHandle* DataContainer::addData(const std::string& name, AbstractData* data) {
tgtAssert(data != 0, "The Data must not be 0.");
DataHandle* dh = new DataHandle(data);
addDataHandle(name, dh);
return dh;
......
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