Commit 67dc1fff authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Fixed/Cleaned up GenericImageReader:

* GenericImageReader now has a property for the target image ID
* Removed all the different setters for the URL/target image ID, as you should use the corresponding properties directly.
parent 9b2ad449
......@@ -27,7 +27,7 @@
namespace campvis {
AbstractImageReader::AbstractImageReader()
: AbstractProcessor()
, p_url("url", "Image URL", "", StringProperty::OPEN_FILENAME)
, p_url("Url", "Image URL", "", StringProperty::OPEN_FILENAME)
, p_targetImageID("targetImageName", "Target Image ID", "AbstractImageReader.output", DataNameProperty::WRITE)
{
}
......
......@@ -38,9 +38,11 @@ namespace campvis {
GenericImageReader::GenericImageReader()
: AbstractProcessor()
, p_url("url", "Image URL", "", StringProperty::OPEN_FILENAME)
, p_url("Url", "Image URL", "", StringProperty::OPEN_FILENAME)
, p_targetImageID("TargetImageName", "Target Image ID", "AbstractImageReader.output", DataNameProperty::WRITE)
{
addProperty(p_url);
addProperty(p_targetImageID);
p_url.s_changed.connect(this, &GenericImageReader::onUrlPropertyChanged);
this->addReader(new CsvdImageReader());
......@@ -108,73 +110,16 @@ namespace campvis {
}
}
void GenericImageReader::setURL(std::string p_url) {
this->p_url.setValue(p_url);
std::string url = this->p_url.getValue();
size_t extPos = url.rfind('.');
if (extPos != std::string::npos) {
this->_ext = url.substr(extPos);
}
std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(this->_ext));
if(it != this->_readers.end()) {
(it->first)->p_url.setValue(this->p_url.getValue());
}
return;
}
void GenericImageReader::setURL(StringProperty p_url) {
return this->setURL(p_url.getValue());
}
void GenericImageReader::setURL(const char* p_url) {
return this->setURL(std::string(p_url));
}
void GenericImageReader::setTargetImageId(DataNameProperty& targetImageId) {
std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(this->_ext));
if(it != this->_readers.end()) {
(it->first)->p_targetImageID.setValue(targetImageId.getValue());
std::set<AbstractProperty*> sharedProperties = targetImageId.getSharedProperties();
for(std::set<AbstractProperty*>::iterator jt = sharedProperties.begin(); jt != sharedProperties.end(); ++jt) {
(it->first)->p_targetImageID.addSharedProperty(*jt);
}
}
return;
}
void GenericImageReader::setTargetImageId(const char* imageId) {
return this->setTargetImageId(std::string(imageId));
}
void GenericImageReader::setTargetImageId(std::string imageId) {
std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(this->_ext));
if(it != this->_readers.end()) {
(it->first)->p_targetImageID.setValue(imageId);
}
return;
}
void GenericImageReader::setTargetImageIdSharedProperty(DataNameProperty* sharedProperty) {
std::map<AbstractImageReader*, MetaProperty*>::iterator it = std::find_if(this->_readers.begin(), this->_readers.end(), checkExt(this->_ext));
if(it != this->_readers.end()) {
(it->first)->p_targetImageID.addSharedProperty(sharedProperty);
}
return;
}
int GenericImageReader::addReader(AbstractImageReader* reader) {
MetaProperty* meta = new MetaProperty(reader->getName()+"MetaProp", reader->getName());
MetaProperty* meta = new MetaProperty(reader->getName() + "MetaProp", reader->getName());
meta->addPropertyCollection(*reader);
meta->setVisible(false);
this->addProperty(*meta);
StringProperty* sp = dynamic_cast<StringProperty*>(meta->getProperty("url"));
cgtAssert(sp != 0, "This should not happen.");
if (sp != 0) {
p_url.addSharedProperty(sp);
sp->setVisible(false);
}
p_url.addSharedProperty(&reader->p_url);
reader->p_url.setVisible(false);
p_targetImageID.addSharedProperty(&reader->p_targetImageID);
reader->p_targetImageID.setVisible(false);
this->_readers.insert(std::pair<AbstractImageReader*, MetaProperty*>(reader, meta));
return 0;
......
......@@ -76,19 +76,10 @@ namespace campvis {
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::TESTING; };
/// functions to set the property of the readers
void setURL(std::string p_url);
void setURL(StringProperty p_url);
void setURL(const char* p_url);
void setTargetImageId(DataNameProperty& targetImageId);
void setTargetImageId(std::string imageId);
void setTargetImageId(const char* imageId);
void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
void setVisibibility(const std::string& extention, bool visibility);
StringProperty p_url;
StringProperty p_url; ///< URL for file to read
DataNameProperty p_targetImageID; ///< image ID for read image
protected:
/// \see AbstractProcessor::updateResult
......
......@@ -54,9 +54,9 @@ namespace campvis {
_ve.p_outputImage.setValue("combine");
_renderTargetID.setValue("combine");
_imageReader.setURL(ShdrMgr.completePath("/modules/vis/sampledata/smallHeart.mhd"));
_imageReader.setTargetImageId("reader.output");
_imageReader.setTargetImageIdSharedProperty(&_ve.p_inputVolume);
_imageReader.p_url.setValue(ShdrMgr.completePath("/modules/vis/sampledata/smallHeart.mhd"));
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.addSharedProperty(&_ve.p_inputVolume);
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .05f));
......
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