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 {
virtual void addProcessor(AbstractProcessor* processor);
virtual void executePipeline() = 0;
AbstractProcessor* getProcessor(const std::string& name) const;
sigslot::signal0 s_init;
sigslot::signal0 s_deinit;
};
/* AutoEvaluationPipeline */
......
......@@ -64,7 +64,6 @@ namespace campvis {
}
void AbstractPipeline::init() {
initAllProperties();
// initialize all processors:
......@@ -76,9 +75,15 @@ namespace campvis {
LERROR("Caught Exception during initialization of processor: " << e.what());
}
}
// use trigger signal to enforce blocking call
s_init.triggerSignal();
}
void AbstractPipeline::deinit() {
// use trigger signal to enforce blocking call
s_deinit.triggerSignal();
deinitAllProperties();
// deinitialize all processors:
......
......@@ -191,8 +191,10 @@ namespace campvis {
*/
const std::string& getRenderTargetID() const;
/// Signal emitted when the pipeline's render target has changed
sigslot::signal0 s_renderTargetChanged;
/// Signal emitted at the end of AbstractPipeline::init()
sigslot::signal0 s_init;
/// Signal emitted at the beginning of AbstractPipeline::deinit()
sigslot::signal0 s_deinit;
protected:
/**
......
......@@ -81,7 +81,8 @@ namespace sigslot {
}
else {
// 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()
self.vr = vis.VolumeRenderer(canvas_size)
self.addProcessor(instance, self.vr)
-- alternative 1 to automatically adjust the camera to the data
self.tcp:addLqModeProcessor(self.vr)
self.addEventListenerToBack(instance, self.tcp)
end
function pipeline:init()
self.vr.p_outputImage:setValue("combine")
self.getProperty(instance, "renderTargetID"):setValue("combine")
local initCallback = function()
pipeline.vr.p_outputImage:setValue("combine")
pipeline.getProperty(instance, "renderTargetID"):setValue("combine")
self.image_reader.p_url:setValue(campvis.SOURCE_DIR .. "/modules/vis/sampledata/smallHeart.mhd")
self.image_reader.p_targetImageID:setValue("reader.output")
self.image_reader.p_targetImageID:addSharedProperty(self.vr.p_inputVolume)
self.image_reader.p_targetImageID:addSharedProperty(self.tcp.p_image)
pipeline.image_reader.p_url:setValue(campvis.SOURCE_DIR .. "/modules/vis/sampledata/smallHeart.mhd")
pipeline.image_reader.p_targetImageID:setValue("reader.output")
pipeline.image_reader.p_targetImageID:addSharedProperty(pipeline.vr.p_inputVolume)
-- 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
local callback = function(arg)
local data_container = self.getDataContainer(instance)
local img_data = data_container:getData(self.image_reader.p_targetImageID:getValue()):getData()
self.tcp:reinitializeCamera(img_data:getWorldBounds())
local data_container = pipeline.getDataContainer(instance)
local img_data = data_container:getData(pipeline.image_reader.p_targetImageID:getValue()):getData()
pipeline.tcp:reinitializeCamera(img_data:getWorldBounds())
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),
cgt.vec4(255, 0, 0, 128))
......@@ -56,9 +56,9 @@ function pipeline:init()
dvrTF:addGeometry(geometry2)
dvrTF:addGeometry(geometry3)
self.vr:getNestedProperty("RaycasterProps::TransferFunction"):replaceTF(dvrTF)
self.vr:getNestedProperty("RaycasterProps::SamplingRate"):setValue(4.0)
pipeline.vr:getNestedProperty("RaycasterProps::TransferFunction"):replaceTF(dvrTF)
pipeline.vr:getNestedProperty("RaycasterProps::SamplingRate"):setValue(4.0)
end
function pipeline:deinit()
end
pipeline.s_init:connect(initCallback)
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