Commit 2393c045 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Introducing AbstractPipeline::s_init and AbstractPipeline::s_deinit signals...

Introducing AbstractPipeline::s_init and AbstractPipeline::s_deinit signals (including Lua bindings) as first step to simplify writing entire pipelines as Lua scripts. The signals are emitted as blocking calls (via triggerSignal()) and can be used by Lua scripts to run (de)initialization code in callback functions.
This was tested with the volumerendererdemo.lua pipeline.
parent d40d5c25
...@@ -366,6 +366,9 @@ namespace campvis { ...@@ -366,6 +366,9 @@ namespace campvis {
virtual void addProcessor(AbstractProcessor* processor); virtual void addProcessor(AbstractProcessor* processor);
virtual void executePipeline() = 0; virtual void executePipeline() = 0;
AbstractProcessor* getProcessor(const std::string& name) const; AbstractProcessor* getProcessor(const std::string& name) const;
sigslot::signal0 s_init;
sigslot::signal0 s_deinit;
}; };
/* AutoEvaluationPipeline */ /* AutoEvaluationPipeline */
......
...@@ -64,7 +64,6 @@ namespace campvis { ...@@ -64,7 +64,6 @@ namespace campvis {
} }
void AbstractPipeline::init() { void AbstractPipeline::init() {
initAllProperties(); initAllProperties();
// initialize all processors: // initialize all processors:
...@@ -76,9 +75,15 @@ namespace campvis { ...@@ -76,9 +75,15 @@ namespace campvis {
LERROR("Caught Exception during initialization of processor: " << e.what()); LERROR("Caught Exception during initialization of processor: " << e.what());
} }
} }
// use trigger signal to enforce blocking call
s_init.triggerSignal();
} }
void AbstractPipeline::deinit() { void AbstractPipeline::deinit() {
// use trigger signal to enforce blocking call
s_deinit.triggerSignal();
deinitAllProperties(); deinitAllProperties();
// deinitialize all processors: // deinitialize all processors:
......
...@@ -191,8 +191,10 @@ namespace campvis { ...@@ -191,8 +191,10 @@ namespace campvis {
*/ */
const std::string& getRenderTargetID() const; const std::string& getRenderTargetID() const;
/// Signal emitted when the pipeline's render target has changed /// Signal emitted at the end of AbstractPipeline::init()
sigslot::signal0 s_renderTargetChanged; sigslot::signal0 s_init;
/// Signal emitted at the beginning of AbstractPipeline::deinit()
sigslot::signal0 s_deinit;
protected: protected:
/** /**
......
...@@ -81,7 +81,8 @@ namespace sigslot { ...@@ -81,7 +81,8 @@ namespace sigslot {
} }
else { else {
// there currently is no event in this queue -> go sleep // there currently is no event in this queue -> go sleep
_evaluationCondition.wait(lock); if (! _stopExecution)
_evaluationCondition.wait(lock);
} }
} }
} }
......
...@@ -21,28 +21,28 @@ function pipeline:ctor() ...@@ -21,28 +21,28 @@ function pipeline:ctor()
self.vr = vis.VolumeRenderer(canvas_size) self.vr = vis.VolumeRenderer(canvas_size)
self.addProcessor(instance, self.vr) self.addProcessor(instance, self.vr)
-- alternative 1 to automatically adjust the camera to the data
self.tcp:addLqModeProcessor(self.vr) self.tcp:addLqModeProcessor(self.vr)
self.addEventListenerToBack(instance, self.tcp) self.addEventListenerToBack(instance, self.tcp)
end end
function pipeline:init() local initCallback = function()
self.vr.p_outputImage:setValue("combine") pipeline.vr.p_outputImage:setValue("combine")
self.getProperty(instance, "renderTargetID"):setValue("combine") pipeline.getProperty(instance, "renderTargetID"):setValue("combine")
self.image_reader.p_url:setValue(campvis.SOURCE_DIR .. "/modules/vis/sampledata/smallHeart.mhd") pipeline.image_reader.p_url:setValue(campvis.SOURCE_DIR .. "/modules/vis/sampledata/smallHeart.mhd")
self.image_reader.p_targetImageID:setValue("reader.output") pipeline.image_reader.p_targetImageID:setValue("reader.output")
self.image_reader.p_targetImageID:addSharedProperty(self.vr.p_inputVolume) pipeline.image_reader.p_targetImageID:addSharedProperty(pipeline.vr.p_inputVolume)
self.image_reader.p_targetImageID:addSharedProperty(self.tcp.p_image)
-- alternative 1 to automatically adjust the camera to the data
pipeline.image_reader.p_targetImageID:addSharedProperty(pipeline.tcp.p_image)
-- alternative 2 to automatically adjust the camera to the data -- alternative 2 to automatically adjust the camera to the data
local callback = function(arg) local callback = function(arg)
local data_container = self.getDataContainer(instance) local data_container = pipeline.getDataContainer(instance)
local img_data = data_container:getData(self.image_reader.p_targetImageID:getValue()):getData() local img_data = data_container:getData(pipeline.image_reader.p_targetImageID:getValue()):getData()
self.tcp:reinitializeCamera(img_data:getWorldBounds()) pipeline.tcp:reinitializeCamera(img_data:getWorldBounds())
end end
self.image_reader.s_validated:connect(callback) pipeline.image_reader.s_validated:connect(callback)
local geometry1 = campvis.TFGeometry1D_createQuad(cgt.vec2(0.12, 0.15), cgt.col4(85, 0, 0, 128), local geometry1 = campvis.TFGeometry1D_createQuad(cgt.vec2(0.12, 0.15), cgt.col4(85, 0, 0, 128),
cgt.vec4(255, 0, 0, 128)) cgt.vec4(255, 0, 0, 128))
...@@ -56,9 +56,9 @@ function pipeline:init() ...@@ -56,9 +56,9 @@ function pipeline:init()
dvrTF:addGeometry(geometry2) dvrTF:addGeometry(geometry2)
dvrTF:addGeometry(geometry3) dvrTF:addGeometry(geometry3)
self.vr:getNestedProperty("RaycasterProps::TransferFunction"):replaceTF(dvrTF) pipeline.vr:getNestedProperty("RaycasterProps::TransferFunction"):replaceTF(dvrTF)
self.vr:getNestedProperty("RaycasterProps::SamplingRate"):setValue(4.0) pipeline.vr:getNestedProperty("RaycasterProps::SamplingRate"):setValue(4.0)
end end
function pipeline:deinit() pipeline.s_init:connect(initCallback)
end
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