Commit e53c9f06 authored by Artur Grunau's avatar Artur Grunau
Browse files

Wrap several TransferFunction-related classes

To make it possible to interact with TransferFunctionProperties from
Lua, several TransferFunction-related classes have been wrapped.

References #1
parent e117d555
%module campvis
%include factory.i
%include std_string.i
%include tgt.i
%{
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/transferfunctionproperty.h"
#include "core/pipeline/abstractprocessor.h"
#include "core/pipeline/autoevaluationpipeline.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/classification/tfgeometry1d.h"
#include "core/classification/geometry1dtransferfunction.h"
%}
namespace campvis {
class AbstractProcessor {
class AbstractProperty {
public:
enum InvalidationLevel {
VALID = 0,
INVALID_RESULT = 1 << 0,
INVALID_SHADER = 1 << 1,
INVALID_PROPERTIES = 1 << 2,
FIRST_FREE_TO_USE_INVALIDATION_LEVEL = 1 << 3
};
AbstractProperty(const std::string& name, const std::string& title,
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
virtual ~AbstractProperty();
const std::string getName() const = 0;
};
virtual void init();
virtual void deinit();
class VisualizationProcessor : public AbstractProcessor {
public:
explicit VisualizationProcessor(IVec2Property* viewportSizeProp);
~VisualizationProcessor();
};
const std::string& getName() const;
const std::string& getTitle() const;
%nodefaultctor AutoEvaluationPipeline;
int getInvalidationLevel() const;
void setInvalidationLevel(int il);
class AutoEvaluationPipeline {
public:
virtual void addProcessor(AbstractProcessor* processor);
virtual ~AutoEvaluationPipeline();
bool isVisible() const;
void setVisible(bool isVisible);
virtual void addSharedProperty(AbstractProperty* prop);
};
class StringProperty {
template<typename T>
class GenericProperty : public AbstractProperty {
public:
StringProperty(const std::string& name, const std::string& title, const std::string& value,
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
~StringProperty();
const std::string& getValue();
void setValue(const std::string& value);
GenericProperty(const std::string& name, const std::string& title, const T& value,
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
virtual ~GenericProperty();
const T& getValue() const;
virtual void setValue(const T& value);
};
%template(StringProperty) GenericProperty<std::string>;
typedef GenericProperty<std::string> StringProperty;
class DataNameProperty : public StringProperty {
public:
enum DataAccessInfo {
......@@ -83,6 +87,100 @@ namespace campvis {
%template(IVec2Property) NumericProperty< tgt::Vector2<int> >;
typedef NumericProperty< tgt::Vector2<int> > IVec2Property;
/* AbstractProcessor */
class AbstractProcessor {
public:
enum InvalidationLevel {
VALID = 0,
INVALID_RESULT = 1 << 0,
INVALID_SHADER = 1 << 1,
INVALID_PROPERTIES = 1 << 2,
FIRST_FREE_TO_USE_INVALIDATION_LEVEL = 1 << 3
};
const std::string getName() const = 0;
};
/* AutoEvaluationPipeline */
%nodefaultctor AutoEvaluationPipeline;
class AutoEvaluationPipeline {
public:
virtual void addProcessor(AbstractProcessor* processor);
virtual ~AutoEvaluationPipeline();
};
/* TFGeometry1D */
%nodefaultctor TFGeometry1D;
class TFGeometry1D {
public:
virtual ~TFGeometry1D();
static TFGeometry1D* createQuad(const tgt::vec2& interval, const tgt::col4& leftColor, const tgt::vec4& rightColor);
};
/* AbstractTransferFunction */
class AbstractTransferFunction {
public:
AbstractTransferFunction(const tgt::svec3& size, const tgt::vec2& intensityDomain = tgt::vec2(0.f, 1.f));
virtual ~AbstractTransferFunction();
virtual AbstractTransferFunction* clone() const = 0;
};
/* GenericGeometryTransferFunction */
template<class T>
class GenericGeometryTransferFunction : public AbstractTransferFunction {
public:
GenericGeometryTransferFunction(const tgt::vec3& size, const tgt::vec2& intensityDomain = tgt::vec2(0.f, 1.f));
virtual ~GenericGeometryTransferFunction();
void addGeometry(T* geometry);
};
/* Geometry1DTransferFunction */
%template(GenericGeometryTransferFunction_TFGeometry1D) GenericGeometryTransferFunction<TFGeometry1D>;
class Geometry1DTransferFunction : public GenericGeometryTransferFunction<TFGeometry1D> {
public:
Geometry1DTransferFunction(size_t size, const tgt::vec2& intensityDomain = tgt::vec2(0.f, 1.f));
virtual ~Geometry1DTransferFunction();
virtual Geometry1DTransferFunction* clone() const;
};
/* TransferFunctionProperty */
class TransferFunctionProperty : public AbstractProperty {
public:
TransferFunctionProperty(const std::string& name, const std::string& title, AbstractTransferFunction* tf,
int invalidationLevel = AbstractProcessor::INVALID_RESULT);
virtual ~TransferFunctionProperty();
AbstractTransferFunction* getTF();
void replaceTF(AbstractTransferFunction* tf);
};
/* Downcast the return value of VisualizationProcessor::getProperty to appropriate subclass */
%factory(AbstractProperty* campvis::VisualizationProcessor::getProperty,
campvis::TransferFunctionProperty, campvis::DataNameProperty, campvis::StringProperty);
/* VisualizationProcessor */
class VisualizationProcessor : public AbstractProcessor {
public:
explicit VisualizationProcessor(IVec2Property* viewportSizeProp);
~VisualizationProcessor();
AbstractProperty* getProperty(const std::string& name) const;
};
}
%luacode {
......
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