Commit 818c79cc authored by Artur Grunau's avatar Artur Grunau
Browse files

Finalise the implementation of the first Lua pipeline

Now that TGT and campvis-core can be built as shared libraries, the few
remaining issues with the first Lua pipeline could be tracked and fixed.
As a result, the pipeline can be executed without any issues, and its
functionality exactly corresponds to that of ResamplingDemo. To achieve
this, several additional classes, methods and constants had to be
wrapped.

References #1
parent 1d99f396
......@@ -103,14 +103,23 @@ namespace campvis {
const std::string getName() const = 0;
};
/* AutoEvaluationPipeline */
/* AbstractPipeline */
class AbstractPipeline {
public:
AbstractPipeline(DataContainer* dc);
virtual ~AbstractPipeline();
virtual const std::string getName() const = 0;
};
%nodefaultctor AutoEvaluationPipeline;
/* AutoEvaluationPipeline */
class AutoEvaluationPipeline {
class AutoEvaluationPipeline : public AbstractPipeline {
public:
virtual void addProcessor(AbstractProcessor* processor);
virtual ~AutoEvaluationPipeline();
void addEventListenerToBack(tgt::EventListener* e);
};
/* TFGeometry1D */
......@@ -183,6 +192,29 @@ namespace campvis {
};
}
%inline {
static const char* const SOURCE_DIR = CAMPVIS_SOURCE_DIR;
namespace campvis {
/*
* Lua pipelines need to access certain protected properties of AbstractPipeline but can't
* reference them directly as they don't actually inherit from any class. This subclass exposes
* public getters for the properties in question. LuaPipeline instances can then be cast to
* ExtendedAutoEvaluationPipeline to give Lua code access to these new methods.
*/
class ExtendedAutoEvaluationPipeline : public AutoEvaluationPipeline {
public:
const IVec2Property& ExtendedAutoEvaluationPipeline::getCanvasSizeProperty() const {
return _canvasSize;
}
const DataNameProperty& ExtendedAutoEvaluationPipeline::getRenderTargetIDProperty() const {
return _renderTargetID;
}
};
}
}
%luacode {
function campvis.newPipeline (o)
o = o or {} -- create object if user does not provide one
......
......@@ -2,6 +2,7 @@
%include "stdint.i"
%{
#include "ext/tgt/vector.h"
#include "ext/tgt/event/eventlistener.h"
%}
......@@ -41,4 +42,12 @@ namespace tgt {
%template(col4) Vector4<uint8_t>;
typedef Vector4<uint8_t> col4;
/* EventListener */
class EventListener {
public:
EventListener();
virtual ~EventListener();
};
}
......@@ -7,7 +7,7 @@
namespace campvis {
class VolumeExplorer : public VisualizationProcessor {
class VolumeExplorer : public VisualizationProcessor, public tgt::EventListener {
public:
VolumeExplorer(campvis::IVec2Property* viewportSizeProp);
~VolumeExplorer();
......
......@@ -25,7 +25,7 @@ namespace campvis {
if (!_luaVmState->execString("require(\"campvis\")"))
return;
if (!_luaVmState->injectObjectPointer(this, "campvis::AutoEvaluationPipeline *", "instance"))
if (!_luaVmState->injectObjectPointer(this, "campvis::ExtendedAutoEvaluationPipeline *", "instance"))
return;
// Try executing the pipeline's Lua script
......
......@@ -10,22 +10,22 @@ function pipeline:ctor()
self.image_reader = cvio.MhdImageReader()
self.addProcessor(instance, self.image_reader)
local iv = tgt.ivec2(50, 10)
local ivp = campvis.IVec2Property("a", "b", iv, tgt.ivec2_zero, tgt.ivec2(100, 30))
self.ve = vis.VolumeExplorer(ivp)
self.resampler = preprocessing.GlImageResampler(ivp)
self.ve = vis.VolumeExplorer(self.getCanvasSizeProperty(instance))
self.resampler = preprocessing.GlImageResampler(self.getCanvasSizeProperty(instance))
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.getRenderTargetIDProperty(instance):setValue("result")
self.image_reader.p_url:setValue("CAMPVIS_SOURCE_DIR/modules/vis/sampledata/smallHeart.mhd")
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)
......@@ -47,8 +47,3 @@ end
function pipeline:deinit()
print("I'm being deinited!")
end
local nt = campvis.StringProperty("a", "b", "c", campvis.AbstractProcessor_INVALID_RESULT)
print(nt:getValue())
nt:setValue("d")
print(nt:getValue())
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