Commit 06ba6dde authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

Everything looks good for loading in DataContainerInspectorWidget. Cleaned up the code.

parent 75ec440c
...@@ -72,6 +72,7 @@ namespace campvis { ...@@ -72,6 +72,7 @@ namespace campvis {
, _mainLayout(0) , _mainLayout(0)
, _infoWidget(0) , _infoWidget(0)
, _infoWidgetLayout(0) , _infoWidgetLayout(0)
, _propEditorWid(0)
{ {
setupGUI(); setupGUI();
} }
...@@ -96,6 +97,10 @@ namespace campvis { ...@@ -96,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));
...@@ -165,8 +170,6 @@ namespace campvis { ...@@ -165,8 +170,6 @@ namespace campvis {
_btnSaveToFile = new QPushButton(tr("Save to File"), _infoWidget); _btnSaveToFile = new QPushButton(tr("Save to File"), _infoWidget);
_infoWidgetLayout->addWidget(_btnSaveToFile); _infoWidgetLayout->addWidget(_btnSaveToFile);
// Added by Hossain Mahmud <mahmud@in.tum.de>
// Date: January 02, 2014
_btnLoadFile = new QPushButton(tr("Load File"), _infoWidget); _btnLoadFile = new QPushButton(tr("Load File"), _infoWidget);
_infoWidgetLayout->addWidget(_btnLoadFile); _infoWidgetLayout->addWidget(_btnLoadFile);
...@@ -352,6 +355,9 @@ namespace campvis { ...@@ -352,6 +355,9 @@ 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) {
...@@ -453,43 +459,14 @@ namespace campvis { ...@@ -453,43 +459,14 @@ namespace campvis {
} }
void DataContainerInspectorWidget::onBtnLoadFileClicked() { void DataContainerInspectorWidget::onBtnLoadFileClicked() {
QString dialogCaption = QString::fromStdString("Select the file"); // delete previous PropertyEditor, then create a new one
QString directory; // the final one will be deleted with deinit()
std::string fileTobeRead; if(nullptr != _propEditorWid)
delete _propEditorWid;
directory = tr("");
const QString fileFilter = tr("All files (*)");
QString filename;
filename = QFileDialog::getOpenFileName(QWidget::parentWidget(), dialogCaption, directory, fileFilter);
if (! filename.isEmpty()) {
fileTobeRead = filename.toStdString();
//emit modified();
}
GenericImageReader *imgReader = new GenericImageReader();
imgReader->setURL(fileTobeRead);
PropertyEditorWidget *propEditorWid = new PropertyEditorWidget(this, nullptr); //_dctWidget->getTreeModel()
propEditorWid->setDataContainer(_dataContainer);
propEditorWid->setImageReader(imgReader);
propEditorWid->updatePropCollection();
//propEditorWid->_propCollectionWidget->updatePropCollection(imgReader, _dataContainer);
propEditorWid->setParentx(this);
//imgReader->setVisibibility(".mhd", true);
propEditorWid->setVisible(true);
//imgReader->process(*_dataContainer);
_dctWidget->update(_dataContainer); //use this here. or next statement
//this->setDataContainer(_dataContainer);
_propEditorWid = new PropertyEditorWidget(this, nullptr);
_propEditorWid->setVisible(true);
} }
void DataContainerInspectorWidget::onDataContainerUpdated(const QString&, QtDataHandle) {
this->_dctWidget->update(_dataContainer);
}
} }
\ 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 PropertyEditorWidget;
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.
*/ */
...@@ -139,8 +145,6 @@ namespace campvis { ...@@ -139,8 +145,6 @@ namespace campvis {
*/ */
void onBtnLoadFileClicked(); void onBtnLoadFileClicked();
void onDataContainerUpdated(const QString&, QtDataHandle);
protected: protected:
/** /**
* Setup the GUI stuff * Setup the GUI stuff
...@@ -194,9 +198,11 @@ namespace campvis { ...@@ -194,9 +198,11 @@ namespace campvis {
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> // Added by Hossain Mahmud <mahmud@in.tum.de>
// Date: January 02, 2014 // Date: January 02, 2014
QPushButton* _btnLoadFile; QPushButton* _btnLoadFile;
PropertyEditorWidget* _propEditorWid;
static const std::string loggerCat_; static const std::string loggerCat_;
}; };
......
...@@ -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.
......
...@@ -62,21 +62,20 @@ namespace campvis { ...@@ -62,21 +62,20 @@ namespace campvis {
const std::string PropertyEditorWidget::loggerCat_ = "CAMPVis.application.PropertyEditorWidget"; const std::string PropertyEditorWidget::loggerCat_ = "CAMPVis.application.PropertyEditorWidget";
PropertyEditorWidget::PropertyEditorWidget(DataContainerInspectorWidget* treeModel, QWidget* parent) PropertyEditorWidget::PropertyEditorWidget(DataContainerInspectorWidget* parentDataInspector, QWidget* parent)
: QWidget(parent) : QWidget(parent)
, _inited(false) , _inited(false)
, _dataContainer(0) , _dataContainer(0)
//, _dctWidget(0)
, _canvas(0) , _canvas(0)
//, _pcWidget(0)
, _mainLayout(0) , _mainLayout(0)
//, _infoWidget(0)
, _pipelinePropertiesScrollArea(0) , _pipelinePropertiesScrollArea(0)
, _propCollectionWidget(0) , _propCollectionWidget(0)
//, _infoWidgetLayout(0)
, _fileName("fileName", "Image URL", "") , _fileName("fileName", "Image URL", "")
{ {
_parent = treeModel; _parent = parentDataInspector;
_dataContainer = _parent->getDataContainer();
_imgReader = new GenericImageReader();
_imgReader->setVisibibility(".mhd", true);
setupGUI(); setupGUI();
} }
...@@ -88,35 +87,14 @@ namespace campvis { ...@@ -88,35 +87,14 @@ namespace campvis {
void PropertyEditorWidget::setDataContainer(DataContainer* dataContainer) { void PropertyEditorWidget::setDataContainer(DataContainer* dataContainer) {
if (_dataContainer != 0) { if (_dataContainer != 0) {
//_dataContainer->s_dataAdded.disconnect(this);
} }
_dataContainer = dataContainer; _dataContainer = dataContainer;
//_dctWidget->update(dataContainer);
//updateInfoWidget();
if (_dataContainer != 0) { if (_dataContainer != 0) {
//_dataContainer->s_dataAdded.connect(this, &PropertyEditorWidget::onDataContainerDataAdded);
} }
} }
void PropertyEditorWidget::setParentx(DataContainerInspectorWidget* parent) {
this->_parent = parent;
}
void PropertyEditorWidget::setImageReader (GenericImageReader* imgReader) {
this->_imgReader = imgReader;
}
void PropertyEditorWidget::updatePropCollection () {
this->_propCollectionWidget->updatePropCollection(this->_imgReader, this->_dataContainer);
}
void PropertyEditorWidget::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:
emit dataContainerChanged();
}
QSize PropertyEditorWidget::sizeHint() const { QSize PropertyEditorWidget::sizeHint() const {
return QSize(200, 300); return QSize(200, 300);
} }
...@@ -136,20 +114,15 @@ namespace campvis { ...@@ -136,20 +114,15 @@ namespace campvis {
this->installEventFilter(this); this->installEventFilter(this);
// _btnBrowse = new StringPropertyWidget(&_fileName, this);
// _mainLayout->addWidget(_btnBrowse);
_propCollectionWidget = new PropertyCollectionWidget(_pipelinePropertiesScrollArea); _propCollectionWidget = new PropertyCollectionWidget(_pipelinePropertiesScrollArea);
_mainLayout->addWidget(_propCollectionWidget); _mainLayout->addWidget(_propCollectionWidget);
//_mainLayout->addStretch(); this->_propCollectionWidget->updatePropCollection(this->_imgReader, this->_dataContainer);
_btnLoadFile = new QPushButton(tr("Load File"), this); _btnLoadFile = new QPushButton(tr("Load File"), this);
_mainLayout->addWidget(_btnLoadFile); _mainLayout->addWidget(_btnLoadFile);
_btnCancel = new QPushButton(tr("Cancel"), this); _btnCancel = new QPushButton(tr("Cancel"), this);
_mainLayout->addWidget(_btnCancel); _mainLayout->addWidget(_btnCancel);
qRegisterMetaType<QtDataHandle>("QtDataHandle"); qRegisterMetaType<QtDataHandle>("QtDataHandle");
connect( connect(
_btnCancel, SIGNAL(clicked()), _btnCancel, SIGNAL(clicked()),
...@@ -157,16 +130,6 @@ namespace campvis { ...@@ -157,16 +130,6 @@ namespace campvis {
connect( connect(
_btnLoadFile, SIGNAL(clicked()), _btnLoadFile, SIGNAL(clicked()),
this, SLOT(onBtnLoadFileClicked())); this, SLOT(onBtnLoadFileClicked()));
connect(
this, SIGNAL(dataContainerChanged()),
this->_parent, SLOT(onDataContainerChanged(const QString&, QtDataHandle)));
/*
if (_dataContainer != 0) {
_dataContainer->s_dataAdded.connect(this, &PropertyEditorWidget::updateDataInspector);
}*/
//_fileName.addSharedProperty(&_imgReader->p_url);
} }
void PropertyEditorWidget::updateColor(){ void PropertyEditorWidget::updateColor(){
...@@ -178,57 +141,24 @@ namespace campvis { ...@@ -178,57 +141,24 @@ namespace campvis {
float depth = _canvas->getCapturedDepth(); float depth = _canvas->getCapturedDepth();
} }
//QString PropertyEditorWidget::humanizeBytes(size_t numBytes) const {
// QString units[5] = { tr(" Bytes"), tr(" KB"), tr(" MB"), tr(" GB"), tr(" TB") };
// size_t index = 0;
// size_t remainder = 0;
// while (numBytes > 1024 && index < 4) {
// remainder = numBytes % 1024;
// numBytes /= 1024;
// ++index;
// }
// if (remainder != 0)
// return QString::number(numBytes) + "." + QString::number(remainder) + units[index];
// else
// return QString::number(numBytes) + units[index];
//}
void PropertyEditorWidget::init() { void PropertyEditorWidget::init() {
//if (_canvas != 0)
//_canvas->init(this);
_inited = true; _inited = true;
} }
void PropertyEditorWidget::deinit() { void PropertyEditorWidget::deinit() {
_inited = false; _inited = false;
//if (_canvas != 0) if(nullptr != _imgReader)
//_canvas->deinit(); delete _imgReader;
//_pcWidget->updatePropCollection(0, 0);
if (_dataContainer != 0) {
//_dataContainer->s_dataAdded.disconnect(this);
}
//_dataContainer = 0;
//_dctWidget->update(0);
} }
void PropertyEditorWidget::onBtnCancelClicked() { void PropertyEditorWidget::onBtnCancelClicked() {
if(nullptr != _imgReader)
delete _imgReader;
this->close(); this->close();
}
void PropertyEditorWidget::updateDataInspector(const std::string& key, const DataHandle&dh) {
//emit dataContainerChanged(QString::fromStdString(key), QtDataHandle(dh));
} }
void PropertyEditorWidget::onBtnLoadFileClicked() { void PropertyEditorWidget::onBtnLoadFileClicked() {
_imgReader->process(*_dataContainer); _imgReader->process(*_dataContainer);
//emit dataContainerChanged();
this->_parent->setDataContainer(_dataContainer); this->_parent->setDataContainer(_dataContainer);
this->close(); this->close();
} }
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "application/gui/properties/stringpropertywidget.h" #include "application/gui/properties/stringpropertywidget.h"
#include "core/tools/opengljobprocessor.h" #include "core/tools/opengljobprocessor.h"
#include "modules/io/processors/genericimagereader.h" #include "modules/io/processors/genericimagereader.h"
//#include "application/gui/datacontainertreewidget.h"
#include "application/gui/datacontainerinspectorwidget.h" #include "application/gui/datacontainerinspectorwidget.h"
#include <QLabel> #include <QLabel>
...@@ -59,11 +58,6 @@ namespace tgt { ...@@ -59,11 +58,6 @@ namespace tgt {
} }
namespace campvis { namespace campvis {
class AbstractPipeline;
//class DataContainerInspectorWidget;
//class DataContainer;
//class DataContainerTreeWidget;
//class FaceGeometry;
class PropertyEditorWidget : public QWidget, public sigslot::has_slots<> { class PropertyEditorWidget : public QWidget, public sigslot::has_slots<> {
Q_OBJECT; Q_OBJECT;
...@@ -85,21 +79,6 @@ namespace campvis { ...@@ -85,21 +79,6 @@ namespace campvis {
* \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);
void setParentx(DataContainerInspectorWidget* parent);
void setImageReader (GenericImageReader* imgReader);
void updatePropCollection ();
/**
* Slot called when _dataContainer has changed and emitted the s_dataAdded signal.
*/
void onDataContainerDataAdded(const std::string&, const DataHandle&);
void updateDataInspector(const std::string&, const DataHandle&);
//void mousePressEvent(QMouseEvent*) {
// updateInfoWidget();
//}
/** /**
* Size hint for the default window size * Size hint for the default window size
...@@ -130,7 +109,6 @@ namespace campvis { ...@@ -130,7 +109,6 @@ namespace campvis {
void updateDepth(); void updateDepth();
signals: signals:
void dataContainerChanged();
private slots: private slots:
/** /**
...@@ -150,42 +128,27 @@ namespace campvis { ...@@ -150,42 +128,27 @@ namespace campvis {
void setupGUI(); void setupGUI();
protected: protected:
/**
* Returns a string with \a numBytes humanized (i.e. "numBytes/1024^n [KMG]Byte")
* \param numBytes Number of bytes to be converted.
* \return "numBytes/1024^n [KMG]Bytes
*/
//QString humanizeBytes(size_t numBytes) const;
bool _inited; bool _inited;
DataContainer* _dataContainer; ///< The DataContainer this widget is inspecting DataContainer* _dataContainer; ///< The DataContainer this widget is inspecting
//DataContainerTreeWidget* _dctWidget; ///< The TreeWidget showing the DataHandles in _dataContainer
DataContainerInspectorCanvas* _canvas; ///< The OpenGL canvas for rendering the DataContainer's contents DataContainerInspectorCanvas* _canvas; ///< The OpenGL canvas for rendering the DataContainer's contents
//PropertyCollectionWidget* _pcWidget;
QVBoxLayout* _mainLayout; ///< Layout for this widget QVBoxLayout* _mainLayout; ///< Layout for this widget
//QWidget* _infoWidget; ///< Widget showing the information about the selected QtDataHandle QVBoxLayout* rightLayout; ///< Layout for the _infoWidget
QVBoxLayout* rightLayout; ///< Layout for the _infoWidget QScrollArea* _pipelinePropertiesScrollArea; ///< Scroll area for _pipelinePropertiesWidget
//QWidget* _pipelinePropertiesWidget; ///< Widget showing the selected pipeline's properties protected:
QScrollArea* _pipelinePropertiesScrollArea; ///< Scroll area for _pipelinePropertiesWidget
public:
protected:
//QPushButton* _btnBrowse;
StringPropertyWidget* _btnBrowse;
QPushButton* _btnCancel; QPushButton* _btnCancel;
QPushButton* _btnLoadFile; QPushButton* _btnLoadFile;
StringProperty _fileName; StringProperty _fileName;
PropertyCollectionWidget* _propCollectionWidget; ///< Widget for browsing the PropertyCollection of the selected pipeline/processor
GenericImageReader *_imgReader; GenericImageReader *_imgReader;
PropertyCollectionWidget* _propCollectionWidget; ///< Widget for browsing the PropertyCollection of the selected pipeline/processor
DataContainerInspectorWidget* _parent; DataContainerInspectorWidget* _parent;
static const std::string loggerCat_; static const std::string loggerCat_;
private:
}; };
} }
......
...@@ -45,15 +45,15 @@ namespace campvis { ...@@ -45,15 +45,15 @@ 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());
addProperty(&p_url);
p_url.s_changed.connect(this, &GenericImageReader::onUrlPropertyChanged);
this->_ext = ""; this->_ext = "";
this->_currentlyVisible = nullptr; this->_currentlyVisible = nullptr;
......
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