Commit 054bd1f7 authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

basic functionality of loading works. however, triggering the screen update is yet to be solved

parent 223846ab
......@@ -472,17 +472,24 @@ namespace campvis {
GenericImageReader *imgReader = new GenericImageReader();
imgReader->setURL(fileTobeRead);
PropertyEditorWidget *propEditorWid = new PropertyEditorWidget();
propEditorWid->_propCollectionWidget->updatePropCollection(imgReader, _dataContainer);
PropertyEditorWidget *propEditorWid = new PropertyEditorWidget(_dctWidget->getTreeModel(), nullptr);
propEditorWid->setDataContainer(_dataContainer);
propEditorWid->setImageReader(imgReader);
propEditorWid->updatePropCollection();
//propEditorWid->_propCollectionWidget->updatePropCollection(imgReader, _dataContainer);
//propEditorWid->setParentx(_dctWidget->getTreeModel());
imgReader->setVisibibility(".mhd", true);
propEditorWid->setVisible(true);
imgReader->process(*_dataContainer);
//imgReader->process(*_dataContainer);
this->setDataContainer(_dataContainer);
//this->show();
//this->activateWindow();
_dctWidget->update(_dataContainer); //use this here. or next statement
//this->setDataContainer(_dataContainer);
}
void DataContainerInspectorWidget::onDataContainerUpdated(const QString&, QtDataHandle) {
this->_dctWidget->update(_dataContainer);
}
}
\ No newline at end of file
......@@ -139,6 +139,8 @@ namespace campvis {
*/
void onBtnLoadFileClicked();
void onDataContainerUpdated(const QString&, QtDataHandle);
protected:
/**
* Setup the GUI stuff
......
......@@ -53,6 +53,7 @@
#include "application/gui/datacontainertreewidget.h"
#include "application/gui/qtdatahandle.h"
#include "modules/io/processors/genericimagereader.h"
#include <QFileDialog>
......@@ -60,7 +61,7 @@ namespace campvis {
const std::string PropertyEditorWidget::loggerCat_ = "CAMPVis.application.PropertyEditorWidget";
PropertyEditorWidget::PropertyEditorWidget(QWidget* parent)
PropertyEditorWidget::PropertyEditorWidget(DataContainerTreeModel* treeModel, QWidget* parent)
: QWidget(parent)
, _inited(false)
, _dataContainer(0)
......@@ -72,7 +73,9 @@ namespace campvis {
, _pipelinePropertiesScrollArea(0)
, _propCollectionWidget(0)
//, _infoWidgetLayout(0)
, _fileName("fileName", "Image URL", "")
{
_parent = treeModel;
setupGUI();
}
......@@ -96,9 +99,21 @@ namespace campvis {
}
}
void PropertyEditorWidget::setParentx(DataContainerTreeModel* 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(QString::fromStdString(key), QtDataHandle(dh));
emit dataContainerChanged();
}
QSize PropertyEditorWidget::sizeHint() const {
......@@ -119,6 +134,9 @@ namespace campvis {
_pipelinePropertiesScrollArea->setFrameStyle(QScrollArea::NoFrame);
this->installEventFilter(this);
_btnBrowse = new StringPropertyWidget(&_fileName, this);
_mainLayout->addWidget(_btnBrowse);
_propCollectionWidget = new PropertyCollectionWidget(_pipelinePropertiesScrollArea);
_mainLayout->addWidget(_propCollectionWidget);
......@@ -129,6 +147,8 @@ namespace campvis {
_btnCancel = new QPushButton(tr("Cancel"), this);
_mainLayout->addWidget(_btnCancel);
qRegisterMetaType<QtDataHandle>("QtDataHandle");
connect(
_btnCancel, SIGNAL(clicked()),
......@@ -136,6 +156,14 @@ namespace campvis {
connect(
_btnLoadFile, SIGNAL(clicked()),
this, SLOT(onBtnLoadFileClicked()));
connect(
this, SIGNAL(dataContainerChanged()),
this->_parent, SLOT(onDataContainerChanged(const QString&, QtDataHandle)));
/*
if (_dataContainer != 0) {
_dataContainer->s_dataAdded.connect(this, &PropertyEditorWidget::updateDataInspector);
}*/
}
void PropertyEditorWidget::updateColor(){
......@@ -147,22 +175,22 @@ namespace campvis {
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;
//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;
}
// 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];
}
// if (remainder != 0)
// return QString::number(numBytes) + "." + QString::number(remainder) + units[index];
// else
// return QString::number(numBytes) + units[index];
//}
void PropertyEditorWidget::init() {
//if (_canvas != 0)
......@@ -187,26 +215,19 @@ namespace campvis {
}
void PropertyEditorWidget::onBtnCancelClicked() {
this->close();
}
void PropertyEditorWidget::onBtnLoadFileClicked() {
QString dialogCaption = QString::fromStdString("Select the file");
QString directory;
std::string fileTobeRead;
// use directory of current property value if any, default directory otherwise
directory = tr("");
const QString fileFilter = tr("All files (*)");
void PropertyEditorWidget::updateDataInspector(const std::string& key, const DataHandle&dh) {
//emit dataContainerChanged(QString::fromStdString(key), QtDataHandle(dh));
}
QString filename;
filename = QFileDialog::getOpenFileName(QWidget::parentWidget(), dialogCaption, directory, fileFilter);
void PropertyEditorWidget::onBtnLoadFileClicked() {
_imgReader->process(*_dataContainer);
emit dataContainerChanged();
if (! filename.isEmpty()) {
fileTobeRead = filename.toStdString();
//emit modified();
}
this->close();
}
}
\ No newline at end of file
......@@ -34,7 +34,10 @@
#include "application/gui/qtdatahandle.h"
#include "application/gui/datacontainerinspectorcanvas.h"
#include "application/gui/properties/propertycollectionwidget.h"
#include "application/gui/properties/stringpropertywidget.h"
#include "core/tools/opengljobprocessor.h"
#include "modules/io/processors/genericimagereader.h"
#include "application/gui/datacontainertreewidget.h"
#include <QLabel>
#include <QWidget>
......@@ -56,6 +59,7 @@ namespace tgt {
namespace campvis {
class AbstractPipeline;
//class DataContainerInspectorWidget;
//class DataContainer;
//class DataContainerTreeWidget;
//class FaceGeometry;
......@@ -68,7 +72,7 @@ namespace campvis {
* Creates a new DataContainerInspectorWidget.
* \param parent Parent Qt widget, may be 0 (default)
*/
explicit PropertyEditorWidget(QWidget* parent = nullptr);
explicit PropertyEditorWidget(DataContainerTreeModel* treeModel, QWidget* parent = nullptr);
/**
* Destructor.
......@@ -80,12 +84,18 @@ namespace campvis {
* \param dataContainer The DataContainer this widget shall inspect, may be 0.
*/
void setDataContainer(DataContainer* dataContainer);
void setParentx(DataContainerTreeModel* 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();
//}
......@@ -119,7 +129,7 @@ namespace campvis {
void updateDepth();
signals:
void dataContainerChanged(const QString&, QtDataHandle);
void dataContainerChanged();
private slots:
/**
......@@ -144,7 +154,7 @@ namespace campvis {
* \param numBytes Number of bytes to be converted.
* \return "numBytes/1024^n [KMG]Bytes
*/
QString humanizeBytes(size_t numBytes) const;
//QString humanizeBytes(size_t numBytes) const;
bool _inited;
......@@ -161,11 +171,19 @@ namespace campvis {
//QWidget* _pipelinePropertiesWidget; ///< Widget showing the selected pipeline's properties
QScrollArea* _pipelinePropertiesScrollArea; ///< Scroll area for _pipelinePropertiesWidget
public:
PropertyCollectionWidget* _propCollectionWidget; ///< Widget for browsing the PropertyCollection of the selected pipeline/processor
protected:
protected:
//QPushButton* _btnBrowse;
StringPropertyWidget* _btnBrowse;
QPushButton* _btnCancel;
QPushButton* _btnLoadFile;
StringProperty _fileName;
GenericImageReader *_imgReader;
PropertyCollectionWidget* _propCollectionWidget; ///< Widget for browsing the PropertyCollection of the selected pipeline/processor
DataContainerTreeModel* _parent;
static const std::string loggerCat_;
};
}
......
......@@ -80,6 +80,19 @@ namespace campvis {
}
return;
}
void GenericImageReader::setVisibibility(const char* extention, bool visibility) {
std::string _ext = std::string(extention);
std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(_ext));
if(it != this->_readers.end()) {
if(nullptr != this->_currentlyVisible) {
this->_currentlyVisible->setVisible(!visibility);
}
(it->second)->setVisible(visibility);
this->_currentlyVisible = it->second;
//(it->first)->process(data);
}
return;
}
void GenericImageReader::setURL(std::string p_url) {
this->p_url.setValue(p_url);
......
......@@ -91,6 +91,9 @@ namespace campvis {
void setTargetImageId(const char* imageId);
void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
void setVisibibility(const char* extention, bool visibility);
protected:
static const std::string loggerCat_;
......
Supports Markdown
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