Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 154f74c4 authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

MERGED: transfer function geometries works. though it crashes on any action at editor after loading

transferfunc try v2
parent d75c2a27
......@@ -218,7 +218,7 @@ namespace campvis {
PropertyCollectionLua *_pcLua = new PropertyCollectionLua();
_pcLua->updatePropCollection(_canvas, _dataContainer);
std::cout << _pcLua->getLuaScript("");
std::cout << _pcLua->getLuaScript("", "proc:");
_infoWidgetLayout->addWidget(_pipelinePropertiesScrollArea, 6, 0, 1, 2);
......
......@@ -337,7 +337,7 @@ namespace campvis {
AbstractProcessor *proc = _selectedPipeline->getProcessor(i);
_pcLua->updatePropCollection(proc, &_selectedPipeline->getDataContainer());
std::string res = _pcLua->getLuaScript("");
std::string res = _pcLua->getLuaScript("", "proc:");
pipeScript += res;
std::cout << "\n\n" + pipeScript + "\n\n";
}
......
......@@ -16,7 +16,10 @@
#include "core/pipeline/autoevaluationpipeline.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/classification/tfgeometry1d.h"
#include "core/classification/tfgeometry2d.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/simpletransferfunction.h"
#include "core/classification/geometry2dtransferfunction.h"
%}
......@@ -181,6 +184,7 @@ namespace campvis {
%template(Vec4NumericProperty) NumericProperty< cgt::Vector4<float> >;
%template(Vec4Property) FloatingPointProperty< cgt::Vector4<float> >;
typedef FloatingPointProperty< cgt::Vector4<float> > Vec4Property;
/* TFGeometry1D */
%nodefaultctor TFGeometry1D;
......@@ -188,7 +192,17 @@ namespace campvis {
class TFGeometry1D {
public:
virtual ~TFGeometry1D();
static TFGeometry1D* createQuad(const cgt::vec2& interval, const cgt::col4& leftColor, const cgt::vec4& rightColor);
static TFGeometry1D* createQuad(const cgt::vec2& interval, const cgt::col4& leftColor, const cgt::col4& rightColor);
};
/* TFGeometry2D */
%nodefaultctor TFGeometry2D;
class TFGeometry2D {
public:
virtual ~TFGeometry2D();
static TFGeometry2D* createQuad(const cgt::vec2& ll, const cgt::vec2& ur, const cgt::col4& color);
};
/* AbstractTransferFunction */
......@@ -201,6 +215,15 @@ namespace campvis {
virtual AbstractTransferFunction* clone() const = 0;
};
/* SimpleTransferFunction */
class SimpleTransferFunction : public AbstractTransferFunction {
public:
SimpleTransferFunction(size_t size, const cgt::vec2& intensityDomain = cgt::vec2(0.f, 1.f));
virtual ~SimpleTransferFunction();
virtual SimpleTransferFunction* clone() const;
};
/* GenericGeometryTransferFunction */
template<class T>
......@@ -211,7 +234,7 @@ namespace campvis {
void addGeometry(T* geometry);
};
/* Geometry1DTransferFunction */
%template(GenericGeometryTransferFunction_TFGeometry1D) GenericGeometryTransferFunction<TFGeometry1D>;
......@@ -224,6 +247,18 @@ namespace campvis {
virtual Geometry1DTransferFunction* clone() const;
};
/* Geometry2DTransferFunction */
%template(GenericGeometryTransferFunction_TFGeometry2D) GenericGeometryTransferFunction<TFGeometry2D>;
class Geometry2DTransferFunction : public GenericGeometryTransferFunction<TFGeometry2D> {
public:
Geometry2DTransferFunction(const cgt::svec2& size, const cgt::vec2& intensityDomain = cgt::vec2(0.f, 1.f));
virtual ~Geometry2DTransferFunction();
virtual Geometry2DTransferFunction* clone() const;
};
/* TransferFunctionProperty */
class TransferFunctionProperty : public AbstractProperty {
......
......@@ -116,5 +116,7 @@ namespace campvis {
}
return _texture;
}
cgt::svec3 AbstractTransferFunction::getSize() {
return _size;
}
}
\ No newline at end of file
......@@ -124,6 +124,7 @@ namespace campvis {
/// Signal emitted when the intensity domain has changed
sigslot::signal0 s_intensityDomainChanged;
cgt::svec3 getSize();
protected:
/**
* Computes the intensity histogram;
......
......@@ -80,3 +80,4 @@ namespace campvis {
}
#endif // SIMPLETRANSFERFUNCTION_H__
......@@ -45,11 +45,11 @@ local initCallback = function()
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))
cgt.col4(255, 0, 0, 128))
local geometry2 = campvis.TFGeometry1D_createQuad(cgt.vec2(.19, .28), cgt.col4(89, 89, 89, 155),
cgt.vec4(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.vec4(192, 192, 128, 64))
cgt.col4(192, 192, 128, 64))
local dvrTF = campvis.Geometry1DTransferFunction(128, cgt.vec2(0, 0.05))
dvrTF:addGeometry(geometry1)
......
......@@ -26,11 +26,10 @@
#include "core/properties/abstractproperty.h"
namespace campvis {
AbstractPropertyLua::AbstractPropertyLua(AbstractProperty* property, bool displayBoxed, DataContainer* dataContainer)
AbstractPropertyLua::AbstractPropertyLua(AbstractProperty* property, DataContainer* dataContainer)
: _property(property)
, _dataContainer(dataContainer)
{
//_ignorePropertyUpdates = 0;
}
AbstractPropertyLua::~AbstractPropertyLua() {
......
......@@ -35,36 +35,30 @@ namespace campvis {
class DataContainer;
/**
* Abstract base class for property widgets.
* Abstract base class for property luas.
*/
class AbstractPropertyLua : public sigslot::has_slots {
public:
/**
* Creates a new PropertyWidget for the property \a property.
*
* If displayBoxed is true, the widget is displayed vertically in a QGroupBox.
* If displayBoxed is true, the lua is displayed vertically in a QGroupBox.
*
* \param property The property the widget shall handle.
* \param displayBoxed Should the widget be displayed in a group box?
* \param property The property the lua shall handle.
* \param dataContainer DataContainer to use (optional), defaults to nullptr. However, some derived classed might need a valid pointer here!
* \param parent Parent Qt widget, defaults to nullptr.
*/
AbstractPropertyLua(AbstractProperty* property, bool displayBoxed = false, DataContainer* dataContainer = nullptr);
AbstractPropertyLua(AbstractProperty* property, DataContainer* dataContainer = nullptr);
/**
* Destructor
*/
virtual ~AbstractPropertyLua();
public:
virtual std::string getLuaScript(std::string prefix = "") = 0;
virtual std::string getLuaScript(std::string propNamePrefix, std::string luaProc) = 0;
protected:
AbstractProperty* _property; ///< The property this widget handles
AbstractProperty* _property; ///< The property this lua handles
DataContainer* _dataContainer; ///< DataContainer to use (e.g. to populate GUI), may be 0!
/// Semaphore acts as flag whether the widget shall ignore incoming signals from properties being updated.
//tbb::atomic<int> _ignorePropertyUpdates;
};
}
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.Lua
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "abstracttransferfunctionlua.h"
#include "core/classification/abstracttransferfunction.h"
#include "core/properties/transferfunctionproperty.h"
namespace campvis {
AbstractTransferFunctionLua::AbstractTransferFunctionLua(TransferFunctionProperty* prop, AbstractTransferFunction* tf)
: _tfProperty(prop)
, _transferFunction(tf)
{
}
AbstractTransferFunctionLua::~AbstractTransferFunctionLua() {
}
const TransferFunctionProperty::IntensityHistogramType* AbstractTransferFunctionLua::getIntensityHistogram() const {
return _tfProperty->getIntensityHistogram();
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef ABSTRACTTRANSFERFUNCTIONLUA_H__
#define ABSTRACTTRANSFERFUNCTIONLUA_H__
#include "core/properties/transferfunctionproperty.h"
namespace campvis {
class AbstractProperty;
class AbstractTransferFunction;
/**
* Abstract base class for transfer function lua generators.
*/
class AbstractTransferFunctionLua {
public:
/**
* Creates a new transfer function lua for the for the AbstractTransferFunction \a tf.
* \param prop TransferFunctionProperty to generate the lua script for.
* \param tf The transfer function the lua script shall handle.
*/
AbstractTransferFunctionLua(TransferFunctionProperty* prop, AbstractTransferFunction* tf);
/**
* Destructor
*/
virtual ~AbstractTransferFunctionLua();
virtual std::string getLuaScript(std::string propNamePrefix, std::string luaProc) = 0;
protected:
const TransferFunctionProperty::IntensityHistogramType* getIntensityHistogram() const;
TransferFunctionProperty* _tfProperty; ///< The parent TransferFunctionProperty of this editor
AbstractTransferFunction* _transferFunction; ///< The transfer function this lua handles
private:
};
}
#endif // ABSTRACTTRANSFERFUNCTIONLUA_H__
......@@ -27,16 +27,17 @@
namespace campvis {
BoolPropertyLua::BoolPropertyLua(BoolProperty* property, DataContainer* dataContainer)
: AbstractPropertyLua(property, false, dataContainer)
: AbstractPropertyLua(property, dataContainer)
{
}
BoolPropertyLua::~BoolPropertyLua() {
}
std::string BoolPropertyLua::getLuaScript(std::string prefix) {
std::string BoolPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
std::string ret = "";
ret += "getNestedProperty(\"" + prefix +_property->getName() + "\"):setValue("
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix +_property->getName() + "\"):setValue("
+ (static_cast<BoolProperty*>(_property)->getValue() == 1? "true" : "false") + ")";
return ret;
}
......
......@@ -31,14 +31,13 @@
namespace campvis {
/**
* Widget for a IntProperty
* Lua generator for a BoolProperty
*/
class BoolPropertyLua : public AbstractPropertyLua {
public:
/**
* Creates a new BoolPropertyLua for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*/
BoolPropertyLua(BoolProperty* property, DataContainer* dataContainer = nullptr);
......@@ -47,7 +46,7 @@ namespace campvis {
*/
virtual ~BoolPropertyLua();
std::string getLuaScript(std::string prefix);
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......
......@@ -28,14 +28,14 @@
namespace campvis {
ButtonPropertyLua::ButtonPropertyLua(ButtonProperty* property, DataContainer* dataContainer)
: AbstractPropertyLua(property, false, dataContainer)
: AbstractPropertyLua(property, dataContainer)
{
}
ButtonPropertyLua::~ButtonPropertyLua() {
}
std::string ButtonPropertyLua::getLuaScript(std::string prefix) {
std::string ButtonPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
return "-- Not necessary ButtonProperty";
}
}
\ No newline at end of file
......@@ -29,11 +29,9 @@
#include "propertyluafactory.h"
#include "core/properties/buttonproperty.h"
class QPushButton;
namespace campvis {
/**
* Lua for a Camera.
* Lua generator for a ButtonProperty.
* For now just offering read-access.
*/
class ButtonPropertyLua : public AbstractPropertyLua {
......@@ -41,7 +39,6 @@ namespace campvis {
/**
* Creates a new ButtonPropertyLua for the property \a property.
* \param property The property the lua shall handle
* \param parent Parent Qt lua
*/
ButtonPropertyLua(ButtonProperty* property, DataContainer* dataContainer = nullptr);
......@@ -50,7 +47,7 @@ namespace campvis {
*/
virtual ~ButtonPropertyLua();
std::string getLuaScript(std::string prefix);
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......
......@@ -28,7 +28,7 @@
namespace campvis {
//CameraPropertyLua::CameraPropertyLua(CameraProperty* property, DataContainer* dataContainer)
// : AbstractPropertyLua(property, true, dataContainer)
// : AbstractPropertyLua(property, dataContainer)
//{
//}
......@@ -43,7 +43,7 @@ namespace campvis {
// _lblUpVector->setText("Up Vector: " + QString::fromStdString(StringUtils::toString(prop->getValue().getUpVector())));
//}
std::string CameraPropertyLua::getLuaScript(std::string prefix) {
std::string CameraPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
std::string ret = "";
// cgt::Camera cam = static_cast<CameraProperty*>(_property)->getValue();
// cgt::vec3 pos = cam.getPosition();
......@@ -55,7 +55,7 @@ namespace campvis {
// float distf = cam.getFarDist();
// int pm = cam.getProjectionMode();
// ret += "getNestedProperty(\"" + prefix+ _property->getName() + "\"):setValue(cgt.Camera("
// ret += "getNestedProperty(\"" + propNamePrefix+ _property->getName() + "\"):setValue(cgt.Camera("
// + "cgt.vec3(" + StringUtils::toString(pos.x) + "," + StringUtils::toString(pos.y) + "," + StringUtils::toString(pos.z) + ")"
// + "," + "cgt.vec3(" + StringUtils::toString(focus.x) + "," + StringUtils::toString(focus.y) + "," + StringUtils::toString(focus.z) + ")"
// + "," + "cgt.vec3(" + StringUtils::toString(up.x) + "," + StringUtils::toString(up.y) + "," + StringUtils::toString(up.z) + ")"
......
......@@ -27,11 +27,10 @@
#include "abstractpropertylua.h"
#include "propertyluafactory.h"
//#include "core/properties/cameraproperty.h"
namespace campvis {
/**
* Lua for a Camera.
* Lua generator for a Camera.
* For now just offering read-access.
*/
class CameraPropertyLua : public AbstractPropertyLua {
......@@ -40,7 +39,6 @@ namespace campvis {
* Creates a new CameraPropertyLua for the property \a property.
* \param property The property the lua shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
* \param parent Parent Qt lua
*/
//CameraPropertyLua(CameraProperty* property, DataContainer* dataContainer);
......@@ -49,7 +47,7 @@ namespace campvis {
*/
virtual ~CameraPropertyLua();
std::string getLuaScript(std::string prefix);
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
};
......
......@@ -28,17 +28,18 @@
namespace campvis {
ColorPropertyLua::ColorPropertyLua(ColorProperty* property, DataContainer* dataContainer)
: AbstractPropertyLua(property, false, dataContainer)
: AbstractPropertyLua(property, dataContainer)
{
}
ColorPropertyLua::~ColorPropertyLua() {
}
std::string ColorPropertyLua::getLuaScript(std::string prefix) {
std::string ColorPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
cgt::vec4 value = static_cast<ColorProperty*>(_property)->getValue();
std::string ret = "";
ret += "getNestedProperty(\"" + prefix + _property->getName() + "\"):setValue(cgt.vec4("
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix + _property->getName() + "\"):setValue(cgt.vec4("
+ StringUtils::toString(value.x) +", " + StringUtils::toString(value.y) +", "
+ StringUtils::toString(value.z) +", " + StringUtils::toString(value.w) + "))";
return ret;
......
......@@ -33,7 +33,7 @@
namespace campvis {
/**
* Lua for a ColorProperty
* Lua generator for a ColorProperty
*/
class ColorPropertyLua : public AbstractPropertyLua {
public:
......@@ -41,7 +41,6 @@ namespace campvis {
* Creates a new FloatPropertyLua for the property \a property.
* \param property The property the lua shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
* \param parent Parent Qt lua
*/
ColorPropertyLua(ColorProperty* property, DataContainer* dataContainer);
......@@ -50,7 +49,7 @@ namespace campvis {
*/
virtual ~ColorPropertyLua();
std::string getLuaScript(std::string prefix);
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
};
// ================================================================================================
......
......@@ -29,16 +29,17 @@
namespace campvis {
DataNamePropertyLua::DataNamePropertyLua(DataNameProperty* property, DataContainer* dc)
: AbstractPropertyLua(property, false, dc)
: AbstractPropertyLua(property, dc)
{
}
DataNamePropertyLua::~DataNamePropertyLua() {
}
std::string DataNamePropertyLua::getLuaScript(std::string prefix) {
std::string DataNamePropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
const std::string value = static_cast<DataNameProperty*>(_property)->getValue();
std::string ret = "";
ret += "getNestedProperty(\"" + prefix + _property->getName() + "\"):setValue(\"" + value + "\")";
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix + _property->getName() + "\"):setValue(\"" + value + "\")";
return ret;
}
}
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