Commit 7ea361ff authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Merge remote-tracking branch 'remotes/origin/dev-mahmud' into development

parents 2ef42d4e d7513b42
...@@ -31,6 +31,7 @@ SET(CampvisApplicationToBeMocced ...@@ -31,6 +31,7 @@ SET(CampvisApplicationToBeMocced
gui/mainwindow.h gui/mainwindow.h
gui/datacontainerinspectorcanvas.h gui/datacontainerinspectorcanvas.h
gui/datacontainerinspectorwidget.h gui/datacontainerinspectorwidget.h
gui/datacontainerfileloaderwidget.h
gui/datacontainertreewidget.h gui/datacontainertreewidget.h
gui/pipelinetreewidget.h gui/pipelinetreewidget.h
gui/qtcolortools.h gui/qtcolortools.h
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "datacontainerfileloaderwidget.h"
namespace campvis {
const std::string DataContainerFileLoaderWidget::loggerCat_ = "CAMPVis.application.DataContainerFileLoaderWidget";
DataContainerFileLoaderWidget::DataContainerFileLoaderWidget(DataContainerInspectorWidget* parentDataInspector, QWidget* parent)
: QWidget(parent)
, _dataContainer(0)
, _layout(0)
, _pipelinePropertiesScrollArea(0)
, _propCollectionWidget(0)
, _fileName("fileName", "Image URL", "")
{
this->_parent = parentDataInspector;
this->_dataContainer = this->_parent->getDataContainer();
this->_imgReader = new GenericImageReader();
this->_imgReader->setVisibibility(".mhd", true);
setupGUI();
}
DataContainerFileLoaderWidget::~DataContainerFileLoaderWidget() {
if (this->_dataContainer != 0) {
this->_dataContainer->s_dataAdded.disconnect(this);
}
}
void DataContainerFileLoaderWidget::setDataContainer(DataContainer* dataContainer) {
this->_dataContainer = dataContainer;
}
QSize DataContainerFileLoaderWidget::sizeHint() const {
return QSize(300, 350);
}
void DataContainerFileLoaderWidget::setupGUI() {
setWindowTitle(tr("Browse File"));
this->_layout = new QGridLayout();
this->_layout->setSpacing(2);
setLayout(_layout);
this->_pipelinePropertiesScrollArea = new QScrollArea(this);
this->_pipelinePropertiesScrollArea->setWidgetResizable(true);
this->_pipelinePropertiesScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->_pipelinePropertiesScrollArea->setFrameStyle(QScrollArea::NoFrame);
this->installEventFilter(this);
this->_propCollectionWidget = new PropertyCollectionWidget(this->_pipelinePropertiesScrollArea);
this->_layout->addWidget(this->_propCollectionWidget, 0, 0, 1, 2);
this->_propCollectionWidget->updatePropCollection(this->_imgReader, this->_dataContainer);
this->_btnLoadFile = new QPushButton(tr("Load"), this);
this->_layout->addWidget(this->_btnLoadFile, 1, 0, 1, 1);
this->_btnCancel = new QPushButton(tr("Cancel"), this);
this->_layout->addWidget(this->_btnCancel, 1, 1, 1, 1);
qRegisterMetaType<QtDataHandle>("QtDataHandle");
connect(
this->_btnCancel, SIGNAL(clicked()),
this, SLOT(onBtnCancelClicked()));
connect(
this->_btnLoadFile, SIGNAL(clicked()),
this, SLOT(onBtnLoadFileClicked()));
}
void DataContainerFileLoaderWidget::init() {
}
void DataContainerFileLoaderWidget::deinit() {
delete _imgReader;
this->_imgReader = nullptr;
}
void DataContainerFileLoaderWidget::onBtnCancelClicked() {
delete _imgReader;
this->_imgReader = nullptr;
this->close();
}
void DataContainerFileLoaderWidget::onBtnLoadFileClicked() {
this->_imgReader->process(*_dataContainer);
this->_parent->setDataContainer(_dataContainer);
this->close();
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef DATACONTAINERFILELOADERWIDGET_H
#define DATACONTAINERFILELOADERWIDGET_H
#include "sigslot/sigslot.h"
#include "application/gui/properties/propertycollectionwidget.h"
#include "modules/io/processors/genericimagereader.h"
#include "application/gui/datacontainerinspectorwidget.h"
#include <QScrollArea>
#include <QGridLayout>
#include <QPushButton>
namespace campvis {
class DataContainerFileLoaderWidget : public QWidget, public sigslot::has_slots<> {
Q_OBJECT;
public:
/**
* Creates a new DataContainerFileLoaderWidget.
* \param treeModel Parent DataContainerInspectorWidget. Method Overridden to keep the widget floating.
* \param parent Parent Qt widget, may be 0 (default)
*/
explicit DataContainerFileLoaderWidget(DataContainerInspectorWidget* treeModel, QWidget* parent = nullptr);
/**
* Destructor.
*/
~DataContainerFileLoaderWidget();
/**
* Set the DataContainer this widget is inspecting.
* \param dataContainer The DataContainer this widget shall inspect, may be 0.
*/
void setDataContainer(DataContainer* dataContainer);
/**
* Size hint for the default window size
* \return QSize(300, 350)
*/
QSize sizeHint() const;
/**
* Initializes the OpenGL stuff (e.g. shaders).
* Must be called with a valid and locked OpenGL context.
*/
virtual void init();
/**
* Deinitializes the OpenGL stuff (e.g. shaders).
* Must be called with a valid and locked OpenGL context.
*/
void deinit();
private slots:
/**
* Slot being called when the user clicks on the "Cancel" button.
*/
void onBtnCancelClicked();
/**
* Slot being called when the user clicks on the "Load File" button.
*/
void onBtnLoadFileClicked();
protected:
/**
* Setup the GUI stuff
*/
void setupGUI();
protected:
DataContainer* _dataContainer; ///< The DataContainer this widget is inspecting
QGridLayout* _layout; ///< Layout for the _infoWidget
QScrollArea* _pipelinePropertiesScrollArea; ///< Scroll area for _pipelinePropertiesWidget
protected:
QPushButton* _btnCancel;
QPushButton* _btnLoadFile;
StringProperty _fileName;
PropertyCollectionWidget* _propCollectionWidget; ///< Widget for browsing the PropertyCollection of the selected pipeline/processor
GenericImageReader *_imgReader;
DataContainerInspectorWidget* _parent;
static const std::string loggerCat_;
private:
};
}
#endif // DATACONTAINERFILELOADERWIDGET_H
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
#include "application/gui/datacontainertreewidget.h" #include "application/gui/datacontainertreewidget.h"
#include "application/gui/qtdatahandle.h" #include "application/gui/qtdatahandle.h"
#include "application//gui/datacontainerfileloaderwidget.h"
#include "modules/io/processors/genericimagereader.h"
#include <QFileDialog> #include <QFileDialog>
...@@ -70,6 +72,7 @@ namespace campvis { ...@@ -70,6 +72,7 @@ namespace campvis {
, _mainLayout(0) , _mainLayout(0)
, _infoWidget(0) , _infoWidget(0)
, _infoWidgetLayout(0) , _infoWidgetLayout(0)
, _propEditorWid(0)
{ {
setupGUI(); setupGUI();
} }
...@@ -94,6 +97,10 @@ namespace campvis { ...@@ -94,6 +97,10 @@ namespace campvis {
} }
} }
DataContainer* DataContainerInspectorWidget::getDataContainer() {
return _dataContainer;
}
void DataContainerInspectorWidget::onDataContainerDataAdded(const std::string& key, const DataHandle& dh) { void DataContainerInspectorWidget::onDataContainerDataAdded(const std::string& key, const DataHandle& dh) {
// copy QtDataHandle because signal will be handled by a different thread an indefinite amount of time later: // copy QtDataHandle because signal will be handled by a different thread an indefinite amount of time later:
emit dataContainerChanged(QString::fromStdString(key), QtDataHandle(dh)); emit dataContainerChanged(QString::fromStdString(key), QtDataHandle(dh));
...@@ -160,8 +167,25 @@ namespace campvis { ...@@ -160,8 +167,25 @@ namespace campvis {
_lblBounds = new QLabel(tr("World Bounds:"), _infoWidget); _lblBounds = new QLabel(tr("World Bounds:"), _infoWidget);
_infoWidgetLayout->addWidget(_lblBounds); _infoWidgetLayout->addWidget(_lblBounds);
QWidget* btnWidget = new QWidget(this);
QGridLayout* gridLayout = new QGridLayout();
btnWidget->setLayout(gridLayout);
#ifdef CAMPVIS_HAS_MODULE_DEVIL
_btnSaveToFile = new QPushButton(tr("Save to File"), _infoWidget); _btnSaveToFile = new QPushButton(tr("Save to File"), _infoWidget);
_infoWidgetLayout->addWidget(_btnSaveToFile); gridLayout->addWidget(_btnSaveToFile, 0, 0);
connect(
_btnSaveToFile, SIGNAL(clicked()),
this, SLOT(onBtnSaveToFileClicked()));
_btnSaveToFile->setDisabled(true);
#endif
_btnLoadFile = new QPushButton(tr("Load File"), _infoWidget);
gridLayout->addWidget(_btnLoadFile, 0, 1);
_infoWidgetLayout->addWidget(btnWidget);
_canvas = new DataContainerInspectorCanvas(_infoWidget); _canvas = new DataContainerInspectorCanvas(_infoWidget);
_canvas->setMinimumSize(QSize(100, 100)); _canvas->setMinimumSize(QSize(100, 100));
...@@ -184,8 +208,8 @@ namespace campvis { ...@@ -184,8 +208,8 @@ namespace campvis {
this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)), this, SIGNAL(dataContainerChanged(const QString&, QtDataHandle)),
_dctWidget->getTreeModel(), SLOT(onDataContainerChanged(const QString&, QtDataHandle))); _dctWidget->getTreeModel(), SLOT(onDataContainerChanged(const QString&, QtDataHandle)));
connect( connect(
_btnSaveToFile, SIGNAL(clicked()), _btnLoadFile, SIGNAL(clicked()),
this, SLOT(onBtnSaveToFileClicked())); this, SLOT(onBtnLoadFileClicked()));
} }
void DataContainerInspectorWidget::updateColor(){ void DataContainerInspectorWidget::updateColor(){
...@@ -342,10 +366,25 @@ namespace campvis { ...@@ -342,10 +366,25 @@ namespace campvis {
_dataContainer = 0; _dataContainer = 0;
_dctWidget->update(0); _dctWidget->update(0);
if(_propEditorWid != nullptr)
_propEditorWid->deinit();
} }
void DataContainerInspectorWidget::onDCTWidgetSelectionModelSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { void DataContainerInspectorWidget::onDCTWidgetSelectionModelSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) {
updateInfoWidget(); updateInfoWidget();
// get the selection from the tree widget
const QModelIndexList& indices = _dctWidget->selectionModel()->selectedRows();
// iterate through the indices of the selection
for (QModelIndexList::const_iterator index = indices.begin(); index != indices.end(); ++index) {
if (index->isValid()) {
_btnSaveToFile->setDisabled(false);
return;
}
}
_btnSaveToFile->setDisabled(true);
} }
void DataContainerInspectorWidget::onBtnSaveToFileClicked() { void DataContainerInspectorWidget::onBtnSaveToFileClicked() {
...@@ -442,4 +481,15 @@ namespace campvis { ...@@ -442,4 +481,15 @@ namespace campvis {
} }
void DataContainerInspectorWidget::onBtnLoadFileClicked() {
// delete previous PropertyEditor, then create a new one
// the final one will be deleted with deinit()
if(nullptr != _propEditorWid)
_propEditorWid->deinit();
_propEditorWid = new DataContainerFileLoaderWidget(this, nullptr);
_propEditorWid->setVisible(true);
}
} }
\ No newline at end of file
...@@ -57,6 +57,7 @@ namespace campvis { ...@@ -57,6 +57,7 @@ namespace campvis {
class DataContainer; class DataContainer;
class DataContainerTreeWidget; class DataContainerTreeWidget;
class FaceGeometry; class FaceGeometry;
class DataContainerFileLoaderWidget;
class DataContainerInspectorWidget : public QWidget, public sigslot::has_slots<> { class DataContainerInspectorWidget : public QWidget, public sigslot::has_slots<> {
Q_OBJECT; Q_OBJECT;
...@@ -72,13 +73,18 @@ namespace campvis { ...@@ -72,13 +73,18 @@ namespace campvis {
* Destructor. * Destructor.
*/ */
~DataContainerInspectorWidget(); ~DataContainerInspectorWidget();
/** /**
* Set the DataContainer this widget is inspecting. * Set the DataContainer this widget is inspecting.
* \param dataContainer The DataContainer this widget shall inspect, may be 0. * \param dataContainer The DataContainer this widget shall inspect, may be 0.
*/ */
void setDataContainer(DataContainer* dataContainer); void setDataContainer(DataContainer* dataContainer);
/**
* Get the DataContainer this widget is inspecting.
*/
DataContainer* getDataContainer();
/** /**
* Slot called when _dataContainer has changed and emitted the s_dataAdded signal. * Slot called when _dataContainer has changed and emitted the s_dataAdded signal.
*/ */
...@@ -111,7 +117,7 @@ namespace campvis { ...@@ -111,7 +117,7 @@ namespace campvis {
*/ */
void updateColor(); void updateColor();
/** /**
* Updates depth of the info widget * Updates depth of the info widget
*/ */
void updateDepth(); void updateDepth();
...@@ -133,6 +139,12 @@ namespace campvis { ...@@ -133,6 +139,12 @@ namespace campvis {
*/ */
void onBtnSaveToFileClicked(); void onBtnSaveToFileClicked();
/**
* Slot being called when the user clicks on the "Load File" button.
*/
void onBtnLoadFileClicked();
protected: protected:
/** /**
* Setup the GUI stuff * Setup the GUI stuff
...@@ -147,7 +159,7 @@ namespace campvis { ...@@ -147,7 +159,7 @@ namespace campvis {
*/ */
protected: protected:
static void saveToFile(DataHandle handle, std::string filename); static void saveToFile(DataHandle handle, std::string filename);
/** /**
...@@ -173,19 +185,24 @@ namespace campvis { ...@@ -173,19 +185,24 @@ namespace campvis {
QHBoxLayout* _mainLayout; ///< Layout for this widget QHBoxLayout* _mainLayout; ///< Layout for this widget
QWidget* _infoWidget; ///< Widget showing the information about the selected QtDataHandle QWidget* _infoWidget; ///< Widget showing the information about the selected QtDataHandle
QVBoxLayout* _infoWidgetLayout; ///< Layout for the _infoWidget QVBoxLayout* _infoWidgetLayout; ///< Layout for the _infoWidget
QLabel* _lblName; QLabel* _lblName;
QLabel* _lblLocalMemoryFootprint; QLabel* _lblLocalMemoryFootprint;
QLabel* _lblVideoMemoryFootprint; QLabel* _lblVideoMemoryFootprint;
QLabel* _lblTimestamp; QLabel* _lblTimestamp;
QLabel* _lblSize; QLabel* _lblSize;
QLabel* _lblBounds; QLabel* _lblBounds;
QWidget* _colorWidget; ///< The widget use to show the color value and the color in a single window QWidget* _colorWidget; ///< The widget use to show the color value and the color in a single window
QHBoxLayout* _colorWidgetLayout; ///< Layout for the following widget QHBoxLayout* _colorWidgetLayout; ///< Layout for the following widget
QLabel* _lblColorVal; ///< Color Label Value in text QLabel* _lblColorVal; ///< Color Label Value in text
QWidget* _colorValWidget; ///< Widget that shows the color value in color QWidget* _colorValWidget; ///< Widget that shows the color value in color
QPalette* _ColorValWidgetPalette; ///< Palette which will be used to colorize the color widget QPalette* _ColorValWidgetPalette; ///< Palette which will be used to colorize the color widget
QPushButton* _btnSaveToFile; QPushButton* _btnSaveToFile;
// Added by Hossain Mahmud <mahmud@in.tum.de>
// Date: January 02, 2014
QPushButton* _btnLoadFile;
DataContainerFileLoaderWidget* _propEditorWid;
static const std::string loggerCat_; static const std::string loggerCat_;
}; };
......
...@@ -41,7 +41,7 @@ namespace campvis { ...@@ -41,7 +41,7 @@ namespace campvis {
addWidget(_lineEdit); addWidget(_lineEdit);
if (! dynamic_cast<DataNameProperty*>(property)) { if (! dynamic_cast<DataNameProperty*>(property)) {
_btnLoadFile = new QPushButton(tr("Load File"), this); _btnLoadFile = new QPushButton(tr("Browse"), this);
addWidget(_btnLoadFile); addWidget(_btnLoadFile);
connect(_btnLoadFile, SIGNAL(clicked(bool)), this, SLOT(onBtnLoadFileClicked(bool))); connect(_btnLoadFile, SIGNAL(clicked(bool)), this, SLOT(onBtnLoadFileClicked(bool)));
} }
...@@ -52,6 +52,9 @@ namespace campvis { ...@@ -52,6 +52,9 @@ namespace campvis {
StringPropertyWidget::~StringPropertyWidget() { StringPropertyWidget::~StringPropertyWidget() {
} }
void StringPropertyWidget::setButtonLabel(const std::string& btnLabel) {
this->_btnLoadFile->setText(QString(btnLabel.c_str()));
}
void StringPropertyWidget::updateWidgetFromProperty() { void StringPropertyWidget::updateWidgetFromProperty() {
StringProperty* prop = static_cast<StringProperty*>(_property); StringProperty* prop = static_cast<StringProperty*>(_property);
......
...@@ -51,6 +51,8 @@ namespace campvis { ...@@ -51,6 +51,8 @@ namespace campvis {
*/ */
virtual ~StringPropertyWidget(); virtual ~StringPropertyWidget();
void setButtonLabel(const std::string& btnLabel);
protected: protected:
/** /**
* Gets called when the property has changed, so that widget can update its state. * Gets called when the property has changed, so that widget can update its state.
......
...@@ -73,7 +73,7 @@ namespace campvis { ...@@ -73,7 +73,7 @@ namespace campvis {
virtual void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty); virtual void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
public: public:
StringProperty p_url; ///< URL for file to read StringProperty p_url; ///< URL for file to read
DataNameProperty p_targetImageID; ///< image ID for read image DataNameProperty p_targetImageID; ///< image ID for read image
protected: protected:
......
<
...@@ -45,12 +45,16 @@ namespace campvis { ...@@ -45,12 +45,16 @@ namespace campvis {
: AbstractProcessor() : AbstractProcessor()
, p_url("url", "Image URL", "") , p_url("url", "Image URL", "")
{ {
addProperty(&p_url);
p_url.s_changed.connect(this, &GenericImageReader::onUrlPropertyChanged);
this->addReader(new CsvdImageReader()); this->addReader(new CsvdImageReader());
this->addReader(new LtfImageReader()); this->addReader(new LtfImageReader());
this->addReader(new MhdImageReader()); this->addReader(new MhdImageReader());
this->addReader(new RawImageReader()); this->addReader(new RawImageReader());
this->addReader(new VtkImageReader()); this->addReader(new VtkImageReader());
this->_ext = ""; this->_ext = "";
this->_currentlyVisible = nullptr; this->_currentlyVisible = nullptr;
} }
...@@ -70,13 +74,28 @@ namespace campvis { ...@@ -70,13 +74,28 @@ namespace campvis {
} }
void GenericImageReader::updateResult(DataContainer& data) { void GenericImageReader::updateResult(DataContainer& data) {
std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(this->_ext)); std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(this->_ext));
if(it != this->_readers.end()) {
if (this->_currentlyVisible != it->second) {