Commit 20e53e2d authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

* Moved ResamplingDemo pipeline to preprocessing module

* Fixed VolumeExplorer not always correctly invalidating sub-processors
* Updated ProxyGeometryGenerator to new Processor design (using INVALID_PROPERTIES invalidation level)
parent 9d2e100a
......@@ -129,6 +129,7 @@ namespace campvis {
void AbstractProcessor::process(DataContainer& data, bool unlockInExtraThread) {
// use a scoped lock for exception safety
AbstractProcessor::ScopedLock lock(this, unlockInExtraThread);
tgtAssert(_locked == true, "Processor not locked, this should not happen!");
if (hasInvalidShader())
updateShader();
......
......@@ -135,7 +135,7 @@ namespace campvis {
tbb::spin_rw_mutex::scoped_lock lock(_pmMutex, false);
PortMapType::const_iterator it = _portMap.find(name);
while(it != _portMap.end() && it->first == name) {
it->second->s_changed(it->second);
it->second->setValue(it->second->getValue());
++it;
}
}
......
......@@ -26,9 +26,12 @@
#include "tgt/event/keyevent.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/renderdata.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
#include "core/tools/glreduction.h"
namespace campvis {
......@@ -50,8 +53,6 @@ namespace campvis {
void ResamplingDemo::init() {
AutoEvaluationPipeline::init();
_imageReader.s_validated.connect(this, &ResamplingDemo::onProcessorValidated);
_ve.p_outputImage.setValue("result");
_renderTargetID.setValue("result");
......@@ -62,13 +63,11 @@ namespace campvis {
_resampler.p_outputImage.setValue("resampled");
_resampler.p_outputImage.addSharedProperty(&_ve.p_inputVolume);
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.f, .05f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.1f, .125f), tgt::col4(255, 0, 0, 32), tgt::col4(255, 0, 0, 32)));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.4f, .5f), tgt::col4(0, 255, 0, 128), tgt::col4(0, 255, 0, 128)));
static_cast<TransferFunctionProperty*>(_ve.getProperty("TransferFunction"))->replaceTF(dvrTF);
_canvasSize.s_changed.connect<ResamplingDemo>(this, &ResamplingDemo::onRenderTargetSizeChanged);
}
void ResamplingDemo::deinit() {
......@@ -76,11 +75,5 @@ namespace campvis {
AutoEvaluationPipeline::deinit();
}
void ResamplingDemo::onRenderTargetSizeChanged(const AbstractProperty* prop) {
}
void ResamplingDemo::onProcessorValidated(AbstractProcessor* processor) {
}
}
\ No newline at end of file
......@@ -30,6 +30,7 @@
#include "modules/io/processors/mhdimagereader.h"
#include "modules/preprocessing/processors/glimageresampler.h"
#include "modules/vis/processors/volumeexplorer.h"
#include "core/tools/glreduction.h"
namespace campvis {
class ResamplingDemo : public AutoEvaluationPipeline {
......@@ -54,16 +55,7 @@ namespace campvis {
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "ResamplingDemo"; };
void onRenderTargetSizeChanged(const AbstractProperty* prop);
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
MhdImageReader _imageReader;
GlImageResampler _resampler;
VolumeExplorer _ve;
......
......@@ -39,12 +39,11 @@ namespace campvis {
ProxyGeometryGenerator::ProxyGeometryGenerator()
: AbstractProcessor()
, p_sourceImageID("sourceImageID", "Input Image", "", DataNameProperty::READ)
, p_sourceImageID("sourceImageID", "Input Image", "", DataNameProperty::READ, INVALID_RESULT | INVALID_PROPERTIES)
, p_geometryID("geometryID", "Output Geometry ID", "proxygeometry", DataNameProperty::WRITE)
, p_clipX("clipX", "X Axis Clip Coordinates", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(0))
, p_clipY("clipY", "Y Axis Clip Coordinates", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(0))
, p_clipZ("clipZ", "Z Axis Clip Coordinates", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(0))
, _sourceTimestamp(0)
{
addProperty(&p_sourceImageID);
addProperty(&p_geometryID);
......@@ -58,20 +57,11 @@ namespace campvis {
}
void ProxyGeometryGenerator::updateResult(DataContainer& data) {
tgtAssert(_locked == true, "Processor not locked, this should not happen!");
ScopedTypedData<ImageData> img(data, p_sourceImageID.getValue());
if (img != 0) {
if (img->getDimensionality() == 3) {
if (img.getDataHandle().getTimestamp() != _sourceTimestamp) {
p_clipX.setMaxValue(tgt::ivec2(static_cast<int>(img->getSize().x), static_cast<int>(img->getSize().x)));
p_clipY.setMaxValue(tgt::ivec2(static_cast<int>(img->getSize().y), static_cast<int>(img->getSize().y)));
p_clipZ.setMaxValue(tgt::ivec2(static_cast<int>(img->getSize().z), static_cast<int>(img->getSize().z)));
p_clipX.setValue(tgt::ivec2(0, static_cast<int>(img->getSize().x)));
p_clipY.setValue(tgt::ivec2(0, static_cast<int>(img->getSize().y)));
p_clipZ.setValue(tgt::ivec2(0, static_cast<int>(img->getSize().z)));
_sourceTimestamp = img.getDataHandle().getTimestamp();
}
tgt::Bounds volumeExtent = img->getWorldBounds(tgt::svec3(p_clipX.getValue().x, p_clipY.getValue().x, p_clipZ.getValue().x), tgt::svec3(p_clipX.getValue().y, p_clipY.getValue().y, p_clipZ.getValue().y));
tgt::vec3 numSlices = tgt::vec3(img->getSize());
......@@ -95,4 +85,21 @@ namespace campvis {
validate(INVALID_RESULT);
}
void ProxyGeometryGenerator::updateProperties(DataContainer& dataContainer) {
tgtAssert(_locked == true, "Processor not locked, this should not happen!");
ScopedTypedData<ImageData> img(dataContainer, p_sourceImageID.getValue());
if (img != 0) {
p_clipX.setMaxValue(tgt::ivec2(static_cast<int>(img->getSize().x), static_cast<int>(img->getSize().x)));
p_clipY.setMaxValue(tgt::ivec2(static_cast<int>(img->getSize().y), static_cast<int>(img->getSize().y)));
p_clipZ.setMaxValue(tgt::ivec2(static_cast<int>(img->getSize().z), static_cast<int>(img->getSize().z)));
p_clipX.setValue(tgt::ivec2(0, static_cast<int>(img->getSize().x)));
p_clipY.setValue(tgt::ivec2(0, static_cast<int>(img->getSize().y)));
p_clipZ.setValue(tgt::ivec2(0, static_cast<int>(img->getSize().z)));
}
validate(INVALID_PROPERTIES);
}
}
......@@ -68,10 +68,8 @@ namespace campvis {
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
void updateClipProperties();
clock_t _sourceTimestamp;
/// \see AbstractProcessor::updateProperties
virtual void updateProperties(DataContainer& dc);
static const std::string loggerCat_;
};
......
......@@ -152,7 +152,6 @@ namespace campvis {
_raycaster.p_outputImage.setValue(p_outputImage.getValue() + ".raycaster");
}
if (prop == &p_inputVolume) {
_raycaster.invalidate(VolumeRenderer::PG_INVALID);
invalidate(VR_INVALID | SLICES_INVALID);
}
VisualizationProcessor::onPropertyChanged(prop);
......
......@@ -155,9 +155,6 @@ namespace campvis {
_eepGenerator.p_exitImageID.setValue(p_outputImage.getValue() + ".exitpoints");
_raycaster.p_exitImageID.setValue(p_outputImage.getValue() + ".exitpoints");
}
else if (prop == &p_inputVolume) {
invalidate(AbstractProcessor::INVALID_RESULT | PG_INVALID);
}
VisualizationProcessor::onPropertyChanged(prop);
}
......@@ -168,5 +165,9 @@ namespace campvis {
VisualizationProcessor::setViewportSizeProperty(viewportSizeProp);
}
void VolumeRenderer::updateProperties(DataContainer& dataContainer) {
// nothing to do here
}
}
......@@ -48,9 +48,9 @@ namespace campvis {
/// Additional invalidation levels for this processor.
/// Not the most beautiful design though.
enum ProcessorInvalidationLevel {
PG_INVALID = 1 << 4,
EEP_INVALID = 1 << 5,
RAYCASTER_INVALID = 1 << 6
PG_INVALID = AbstractProcessor::FIRST_FREE_TO_USE_INVALIDATION_LEVEL << 1,
EEP_INVALID = AbstractProcessor::FIRST_FREE_TO_USE_INVALIDATION_LEVEL << 2,
RAYCASTER_INVALID = AbstractProcessor::FIRST_FREE_TO_USE_INVALIDATION_LEVEL << 3
};
/**
......@@ -92,6 +92,8 @@ namespace campvis {
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
/// \see AbstractProcessor::updateProperties
virtual void updateProperties(DataContainer& dataContainer);
/**
* Slot getting called when one of the observed processors got invalidated.
......
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