Removed the obsolete Lua pipeline demos in vis and preprocessing modules....

Removed the obsolete Lua pipeline demos in vis and preprocessing modules. Instead, added an updated Lua pipeline demo to application/lua, which adheres to the current scripting API.
parent 7b8a4d36
......@@ -222,6 +222,7 @@ namespace campvis {
return toReturn;
}
void CampVisApplication::addPipeline(const std::string& name, AbstractPipeline* pipeline) {
cgtAssert(pipeline != 0, "Pipeline must not be 0.");
......@@ -244,8 +245,6 @@ namespace campvis {
if (! _luaVmState->injectObjectPointerToTableField(pipeline, "campvis::AutoEvaluationPipeline *", "pipelines", pipeline->getName()))
LERROR("Could not inject the pipeline into the Lua VM.");
_luaVmState->execString("inspect(pipelines)");
#endif
GLCtxtMgr.releaseContext(canvas, false);
......
-- first load all the CAMPVis Lua modules we need
require("cgt")
require("base")
require("cvio")
require("vis")
require("application")
-- All created CAMPVis objects have to be kept alive and must not be garbage-collected by Lua.
-- In order to keep them alive after this LuaDemo has finished, they have to reside in the global
-- Lua table. At the same time however, we do not want to spam that table. Thus, we create a
-- global table for this script, where everything resides in.
LuaDemo = {}
-- create DataContainer and Pipeline
LuaDemo.dc = application:createAndAddDataContainer("This DataContainer was created by Lua.")
LuaDemo.pipeline = campvis.LuaPipeline("A pipeline created by Lua", LuaDemo.dc)
local pipeline = LuaDemo.pipeline;
-- create the processors we need
local canvas_size = pipeline:getProperty("CanvasSize")
LuaDemo.lsp = base.LightSourceProvider()
LuaDemo.tcp = base.TrackballCameraProvider(canvas_size)
LuaDemo.image_reader = cvio.MhdImageReader()
LuaDemo.vr = vis.VolumeRenderer(canvas_size)
-- register the processors with the pipeline
pipeline:addProcessor(LuaDemo.lsp)
pipeline:addProcessor(LuaDemo.tcp)
pipeline:addProcessor(LuaDemo.image_reader)
pipeline:addProcessor(LuaDemo.vr)
-- setup event listener and register it with the pipeline
LuaDemo.tcp:addLqModeProcessor(LuaDemo.vr)
pipeline:addEventListenerToBack(LuaDemo.tcp)
-- create an init callback function, so that the following code gets called when the pipeline gets
-- initialized by CAMPVis.
-- Actually CAMPVis provides the Lua VM with an OpenGL context as well, so this code could also be
-- here directly. However, this way we nicely can demonstrate how to use CAMPVis signals from Lua.
local initCallback = function()
-- set up the processors' properties
LuaDemo.vr.p_outputImage:setValue("combine")
pipeline:getProperty("renderTargetID"):setValue("combine")
LuaDemo.image_reader.p_url:setValue(campvis.SOURCE_DIR .. "/modules/vis/sampledata/smallHeart.mhd")
LuaDemo.image_reader.p_targetImageID:setValue("reader.output")
LuaDemo.image_reader.p_targetImageID:addSharedProperty(LuaDemo.vr.p_inputVolume)
-- alternative 1 to automatically adjust the camera to the data
LuaDemo.image_reader.p_targetImageID:addSharedProperty(LuaDemo.tcp.p_image)
-- alternative 2 to automatically adjust the camera to the data
local callback = function(arg)
local data_container = LuaDemo.getDataContainer(instance)
local img_data = data_container:getData(LuaDemo.image_reader.p_targetImageID:getValue()):getData()
LuaDemo.tcp:reinitializeCamera(img_data:getWorldBounds())
end
LuaDemo.image_reader.s_validated:connect(callback)
-- let us create a fancy transfer function
local geometry1 = campvis.TFGeometry1D_createQuad(cgt.vec2(0.12, 0.15), cgt.col4(85, 0, 0, 128),
cgt.col4(255, 0, 0, 128))
local geometry2 = campvis.TFGeometry1D_createQuad(cgt.vec2(.19, .28), cgt.col4(89, 89, 89, 155),
cgt.col4(89, 89, 89, 155))
local geometry3 = campvis.TFGeometry1D_createQuad(cgt.vec2(.41, .51), cgt.col4(170, 170, 128, 64),
cgt.col4(192, 192, 128, 64))
local dvrTF = campvis.Geometry1DTransferFunction(128, cgt.vec2(0, 0.05))
dvrTF:addGeometry(geometry1)
dvrTF:addGeometry(geometry2)
dvrTF:addGeometry(geometry3)
LuaDemo.vr:getNestedProperty("RaycasterProps::TransferFunction"):replaceTF(dvrTF)
end
-- register the callback with the s_init signal
pipeline.s_init:connect(initCallback)
-- so, we now finished creating our LuaDemo. All that's missing is registering it with the CAMPVis application
application:addPipeline(pipeline:getName(), pipeline)
\ No newline at end of file
require("cgt")
require("base")
require("cvio")
require("vis")
require("preprocessing")
pipeline = campvis.newPipeline("ResamplingDemoLua")
function pipeline:ctor()
print("I'm being constructed!")
self.lsp = base.LightSourceProvider()
self.addProcessor(instance, self.lsp)
self.image_reader = cvio.MhdImageReader()
self.addProcessor(instance, self.image_reader)
local canvas_size = self.getProperty(instance, "CanvasSize")
self.ve = vis.VolumeExplorer(canvas_size)
self.resampler = preprocessing.GlImageResampler(canvas_size)
self.addProcessor(instance, self.resampler)
self.addProcessor(instance, self.ve)
self.addEventListenerToBack(instance, self.ve)
end
function pipeline:init()
print("I'm being inited!")
self.ve.p_outputImage:setValue("result")
self.getProperty(instance, "renderTargetID"):setValue("result")
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.resampler.p_inputImage)
self.resampler.p_outputImage:setValue("resampled")
self.resampler.p_outputImage:addSharedProperty(self.ve.p_inputVolume)
local geometry1 = campvis.TFGeometry1D_createQuad(cgt.vec2(0.1, 0.125), cgt.col4(255, 0, 0, 32),
cgt.vec4(255, 0, 0, 32))
local geometry2 = campvis.TFGeometry1D_createQuad(cgt.vec2(.4, .5), cgt.col4(0, 255, 0, 128),
cgt.vec4(0, 255, 0, 128))
local dvrTF = campvis.Geometry1DTransferFunction(128, cgt.vec2(0, 0.05))
dvrTF:addGeometry(geometry1)
dvrTF:addGeometry(geometry2)
self.ve:getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"):replaceTF(dvrTF)
self.resampler.p_resampleScale:setValue(1.25)
end
function pipeline:deinit()
print("I'm being deinited!")
end
require("cgt")
require("base")
require("cvio")
require("vis")
require("preprocessing")
pipeline = campvis.newPipeline("VolumeRendererDemoLua")
function pipeline:ctor()
local canvas_size = self.getProperty(instance, "CanvasSize")
self.lsp = base.LightSourceProvider()
self.addProcessor(instance, self.lsp)
self.tcp = base.TrackballCameraProvider(canvas_size)
self.addProcessor(instance, self.tcp)
self.image_reader = cvio.MhdImageReader()
self.addProcessor(instance, self.image_reader)
self.vr = vis.VolumeRenderer(canvas_size)
self.addProcessor(instance, self.vr)
self.tcp:addLqModeProcessor(self.vr)
self.addEventListenerToBack(instance, self.tcp)
end
local initCallback = function()
pipeline.vr.p_outputImage:setValue("combine")
pipeline.getProperty(instance, "renderTargetID"):setValue("combine")
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 = pipeline.getDataContainer(instance)
local img_data = data_container:getData(pipeline.image_reader.p_targetImageID:getValue()):getData()
pipeline.tcp:reinitializeCamera(img_data:getWorldBounds())
end
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.col4(255, 0, 0, 128))
local geometry2 = campvis.TFGeometry1D_createQuad(cgt.vec2(.19, .28), cgt.col4(89, 89, 89, 155),
cgt.col4(89, 89, 89, 155))
local geometry3 = campvis.TFGeometry1D_createQuad(cgt.vec2(.41, .51), cgt.col4(170, 170, 128, 64),
cgt.col4(192, 192, 128, 64))
local dvrTF = campvis.Geometry1DTransferFunction(128, cgt.vec2(0, 0.05))
dvrTF:addGeometry(geometry1)
dvrTF:addGeometry(geometry2)
dvrTF:addGeometry(geometry3)
pipeline.vr:getNestedProperty("RaycasterProps::TransferFunction"):replaceTF(dvrTF)
pipeline.vr:getNestedProperty("RaycasterProps::SamplingRate"):setValue(4.0)
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