Commit 75ec440c authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Various changes to GenericImageReader and the DataContainerInspectorWidgted to...

Various changes to GenericImageReader and the DataContainerInspectorWidgted to get loading arbitrary images into the DataContainer running.
parent 0e440a30
......@@ -479,7 +479,7 @@ namespace campvis {
//propEditorWid->_propCollectionWidget->updatePropCollection(imgReader, _dataContainer);
propEditorWid->setParentx(this);
imgReader->setVisibibility(".mhd", true);
//imgReader->setVisibibility(".mhd", true);
propEditorWid->setVisible(true);
//imgReader->process(*_dataContainer);
......
......@@ -136,8 +136,8 @@ namespace campvis {
this->installEventFilter(this);
_btnBrowse = new StringPropertyWidget(&_fileName, this);
_mainLayout->addWidget(_btnBrowse);
// _btnBrowse = new StringPropertyWidget(&_fileName, this);
// _mainLayout->addWidget(_btnBrowse);
_propCollectionWidget = new PropertyCollectionWidget(_pipelinePropertiesScrollArea);
_mainLayout->addWidget(_propCollectionWidget);
......@@ -165,6 +165,8 @@ namespace campvis {
if (_dataContainer != 0) {
_dataContainer->s_dataAdded.connect(this, &PropertyEditorWidget::updateDataInspector);
}*/
//_fileName.addSharedProperty(&_imgReader->p_url);
}
void PropertyEditorWidget::updateColor(){
......
......@@ -31,7 +31,7 @@
namespace campvis {
AbstractImageReader::AbstractImageReader()
: p_url("url", "Image URL", "")
: p_url("url", "Image URL", "", DataNameProperty::READ)
, p_targetImageID("targetImageName", "Target Image ID", "AbstractImageReader.output", DataNameProperty::WRITE)
{
}
......
......@@ -73,7 +73,7 @@ namespace campvis {
virtual void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
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
protected:
......
......@@ -51,6 +51,10 @@ namespace campvis {
this->addReader(new RawImageReader());
this->addReader(new VtkImageReader());
addProperty(&p_url);
p_url.s_changed.connect(this, &GenericImageReader::onUrlPropertyChanged);
this->_ext = "";
this->_currentlyVisible = nullptr;
}
......@@ -71,17 +75,19 @@ namespace campvis {
void GenericImageReader::process(DataContainer& data) {
std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(this->_ext));
if(it != this->_readers.end()) {
if(nullptr != this->_currentlyVisible) {
this->_currentlyVisible->setVisible(false);
if (this->_currentlyVisible != it->second) {
if(nullptr != this->_currentlyVisible) {
this->_currentlyVisible->setVisible(false);
}
(it->second)->setVisible(true);
this->_currentlyVisible = it->second;
}
(it->second)->setVisible(true);
this->_currentlyVisible = it->second;
(it->first)->process(data);
}
return;
}
void GenericImageReader::setVisibibility(const char* extention, bool visibility) {
std::string _ext = std::string(extention);
void GenericImageReader::setVisibibility(const std::string& extention, bool visibility) {
std::string _ext = 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) {
......@@ -152,9 +158,38 @@ namespace campvis {
MetaProperty* meta = new MetaProperty(reader->getName()+"MetaProp", reader->getName());
meta->addPropertyCollection(*reader);
meta->setVisible(false);
StringProperty* sp = dynamic_cast<StringProperty*>(meta->getProperty("url"));
tgtAssert(sp != 0, "This should not happen.");
if (sp != 0) {
p_url.addSharedProperty(sp);
sp->setVisible(false);
}
this->addProperty(meta);
this->_readers.insert(std::pair<AbstractImageReader*, MetaProperty*>(reader, meta));
return 0;
}
void GenericImageReader::onUrlPropertyChanged(const AbstractProperty*) {
// first set visibility of old extension to false
setVisibibility(_ext, false);
// now update extension
const std::string& url = this->p_url.getValue();
size_t extPos = url.rfind('.');
if (extPos != std::string::npos) {
this->_ext = url.substr(extPos);
}
// set visibility of new extension's properties to true
setVisibibility(_ext, true);
}
void GenericImageReader::adjustToNewExtension() {
}
}
\ No newline at end of file
......@@ -92,14 +92,19 @@ namespace campvis {
void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
void setVisibibility(const char* extention, bool visibility);
void setVisibibility(const std::string& extention, bool visibility);
StringProperty p_url;
protected:
static const std::string loggerCat_;
private:
void onUrlPropertyChanged(const AbstractProperty*);
void adjustToNewExtension();
std::map<AbstractImageReader*, MetaProperty*> _readers;
StringProperty p_url;
std::string _ext;
MetaProperty* _currentlyVisible;
......
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