Commit 383898a8 authored by schultezub's avatar schultezub

Introducing Decorator pattern for processors for easy adding of generic...

Introducing Decorator pattern for processors for easy adding of generic features (properties, shader stuff):
 * Introducing AbstractProcessorDecorator and HasProcessorDecorators interfaces
 * Added ProcessorDecoratorBackground and ProcessorDecoratorMasking
 * test usage of the processor decorators in EEPGenerator (masking) and VirtualMirrorCombine (background)

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@292 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 6eeb3b4f
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
uniform vec4 _backgroundColor1;
uniform vec4 _backgroundColor2;
void renderBackground(in vec2 texCoords, out vec4 outColor) {
outColor = mix(_backgroundColor1, _backgroundColor2, texCoords.x * texCoords.y);
gl_FragDepth = 1.0;
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifdef APPLY_MASK
#include "tools/texture2d.frag"
uniform Texture2D _maskImage; ///< mask image \
uniform vec4 _maskColor; ///< mask color
#define MASKING_PROLOG(COORDS) \
vec4 maskValue = getElement2DNormalized(_maskImage, (COORDS) ); \
if (distance(maskValue, _maskColor) > 0.01) {
#define MASKING_EPILOG \
} \
else { \
discard; \
}
#else
#define MASKING_PROLOG
#define MASKING_EPILOG
#endif
......@@ -163,7 +163,6 @@ namespace TUMVis {
InvalidationLevel _invalidationLevel; ///< current invalidation level of this processor
bool _enabled; ///< flag whether this processor is currently enabled
static const std::string loggerCat_;
};
......
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "abstractprocessordecorator.h"
#include "tgt/assert.h"
#include "tgt/shadermanager.h"
namespace TUMVis {
void AbstractProcessorDecorator::addProperties(HasPropertyCollection* propCollection) {
}
void AbstractProcessorDecorator::renderProlog(const DataContainer& dataContainer, tgt::Shader* shader) {
}
void AbstractProcessorDecorator::renderEpilog(tgt::Shader* shader) {
}
std::string AbstractProcessorDecorator::generateHeader() const {
return "";
}
// ================================================================================================
HasProcessorDecorators::~HasProcessorDecorators() {
for (std::vector<AbstractProcessorDecorator*>::iterator it = _decorators.begin(); it != _decorators.end(); ++it)
delete *it;
}
void HasProcessorDecorators::addDecorator(AbstractProcessorDecorator* decorator) {
tgtAssert(decorator != 0, "Decorator must not be 0.");
_decorators.push_back(decorator);
}
void HasProcessorDecorators::decoratePropertyCollection(HasPropertyCollection* propCollection) const {
for (std::vector<AbstractProcessorDecorator*>::const_iterator it = _decorators.begin(); it != _decorators.end(); ++it)
(*it)->addProperties(propCollection);
}
void HasProcessorDecorators::decorateRenderProlog(const DataContainer& dataContainer, tgt::Shader* shader) const {
for (std::vector<AbstractProcessorDecorator*>::const_iterator it = _decorators.begin(); it != _decorators.end(); ++it)
(*it)->renderProlog(dataContainer, shader);
}
void HasProcessorDecorators::decorateRenderEpilog(tgt::Shader* shader) const {
for (std::vector<AbstractProcessorDecorator*>::const_iterator it = _decorators.begin(); it != _decorators.end(); ++it)
(*it)->renderEpilog(shader);
}
std::string HasProcessorDecorators::getDecoratedHeader() const {
std::string toReturn;
for (std::vector<AbstractProcessorDecorator*>::const_iterator it = _decorators.begin(); it != _decorators.end(); ++it)
toReturn.append((*it)->generateHeader());
return toReturn;
}
}
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef ABSTRACTPROCESSORDECORATOR_H__
#define ABSTRACTPROCESSORDECORATOR_H__
#include <vector>
#include <string>
namespace tgt {
class Shader;
}
namespace TUMVis {
class DataContainer;
class HasPropertyCollection;
/**
* Abstract base class for processor decorators.
* ProcessorDecorators are created and assigned to a processor during its construction. The
* virtual methods are then calles at an appropriate time.
*/
class AbstractProcessorDecorator {
public:
/**
* Pure virtual Destructor
*/
virtual ~AbstractProcessorDecorator() = 0 {};
/**
* Gets called by the processor during initialization to let the decorator
* add its properties to the processor.
* \param propCollection PropertyCollection defining where to add the properties (usually the owning processor).
*/
virtual void addProperties(HasPropertyCollection* propCollection);
/**
* Gets called by the processor with an active OpenGL context having \a shader activated before the
* actual rendering takes place.
* Here is the place to setup additional shader arguments (i.e. uniforms) or bind additional textures.
* \param dataContainer The current processor's DataContainer
* \param shader Shader object used during rendering.
*/
virtual void renderProlog(const DataContainer& dataContainer, tgt::Shader* shader);
/**
* Gets called by the processor after the actual rendering took place.
* Here is the place to clean up and deinit created resources.
* \param shader Shader object used during rendering.
*/
virtual void renderEpilog(tgt::Shader* shader);
/**
* Returns an additional header that will be linked into the fragment shader.
* Gets calles when building the shader. Overwrite this method to add a decorator-specific header to
* your fragment shader.
* \return The default implementation returns an empty string.
*/
virtual std::string generateHeader() const;
};
// ================================================================================================
/**
* Pure virtual base class for processors using decorators.
*/
class HasProcessorDecorators {
public:
/**
* Virtual Destructor, deletes all Decorators
*/
virtual ~HasProcessorDecorators();
protected:
void addDecorator(AbstractProcessorDecorator* decorator);
void decoratePropertyCollection(HasPropertyCollection* propCollection) const;
void decorateRenderProlog(const DataContainer& dataContainer, tgt::Shader* shader) const;
void decorateRenderEpilog(tgt::Shader* shader) const;
std::string getDecoratedHeader() const;
std::vector<AbstractProcessorDecorator*> _decorators; ///< List of all processor decorators
};
}
#endif // ABSTRACTPROCESSORDECORATOR_H__
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "processordecoratorbackground.h"
#include "tgt/shadermanager.h"
#include "core/properties/propertycollection.h"
namespace TUMVis {
ProcessorDecoratorBackground::ProcessorDecoratorBackground()
: AbstractProcessorDecorator()
, _backgroundColor1("backgroundColor1", "Background Color 1", tgt::vec4(.9f, .9f, .9f, 1), tgt::vec4(0.f), tgt::vec4(1.f))
, _backgroundColor2("backgroundColor2", "Background Color 2", tgt::vec4(.7f, .7f, .7f, 1), tgt::vec4(0.f), tgt::vec4(1.f))
{
}
ProcessorDecoratorBackground::~ProcessorDecoratorBackground() {
}
void ProcessorDecoratorBackground::addProperties(HasPropertyCollection* propCollection) {
propCollection->addProperty(&_backgroundColor1);
propCollection->addProperty(&_backgroundColor2);
}
void ProcessorDecoratorBackground::renderProlog(const DataContainer& dataContainer, tgt::Shader* shader) {
shader->setUniform("_backgroundColor1", _backgroundColor1.getValue());
shader->setUniform("_backgroundColor2", _backgroundColor2.getValue());
}
}
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef PROCESSORDECORATORBACKGROUND_H__
#define PROCESSORDECORATORBACKGROUND_H__
#include "core/pipeline/abstractprocessordecorator.h"
#include "core/properties/numericproperty.h"
namespace TUMVis {
class ProcessorDecoratorBackground : public AbstractProcessorDecorator {
public:
ProcessorDecoratorBackground();
virtual ~ProcessorDecoratorBackground();
protected:
void addProperties(HasPropertyCollection* propCollection);
virtual void renderProlog(const DataContainer& dataContainer, tgt::Shader* shader);
Vec4Property _backgroundColor1;
Vec4Property _backgroundColor2;
};
}
#endif // PROCESSORDECORATORBACKGROUND_H__
\ No newline at end of file
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "processordecoratormasking.h"
#include "tgt/shadermanager.h"
#include "core/properties/propertycollection.h"
namespace TUMVis {
ProcessorDecoratorMasking::ProcessorDecoratorMasking()
: AbstractProcessorDecorator()
, _applyMask("applyMask", "Apply Mask to image", false, InvalidationLevel::INVALID_SHADER)
, _maskID("maskID", "Mask Image ID", "mask", DataNameProperty::READ)
, _maskColor("maskColor", "Mask Color", tgt::vec4(0.f), tgt::vec4(0.f), tgt::vec4(1.f))
, _texUnit(0)
, _maskImage(0)
{
}
ProcessorDecoratorMasking::~ProcessorDecoratorMasking() {
delete _texUnit;
delete _maskImage;
}
void ProcessorDecoratorMasking::addProperties(HasPropertyCollection* propCollection) {
propCollection->addProperty(&_applyMask);
propCollection->addProperty(&_maskID);
propCollection->addProperty(&_maskColor);
}
void ProcessorDecoratorMasking::renderProlog(const DataContainer& dataContainer, tgt::Shader* shader) {
_texUnit = new tgt::TextureUnit();
if (_applyMask.getValue()) {
shader->setUniform("_maskColor", _maskColor.getValue());
_maskImage = new DataContainer::ScopedTypedData<ImageDataRenderTarget>(dataContainer, _maskID.getValue());
if (*_maskImage != 0) {
(*_maskImage)->bind(shader, _texUnit, 0, "_maskImage");
}
else {
LERRORC("TUMVis.core.ProcessorDecoratorMasking", "No valid mask image found!");
}
}
}
void ProcessorDecoratorMasking::renderEpilog(tgt::Shader* shader) {
delete _texUnit;
_texUnit = 0;
delete _maskImage;
_maskImage = 0;
}
std::string ProcessorDecoratorMasking::generateHeader() const {
if (_applyMask.getValue())
return "#define APPLY_MASK 1\n";
else
return "";
}
}
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef PROCESSORDECORATORMASKING_H__
#define PROCESSORDECORATORMASKING_H__
#include "tgt/textureunit.h"
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/imagedatarendertarget.h"
#include "core/pipeline/abstractprocessordecorator.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
namespace TUMVis {
class ProcessorDecoratorMasking : public AbstractProcessorDecorator {
public:
ProcessorDecoratorMasking();
virtual ~ProcessorDecoratorMasking();
protected:
void addProperties(HasPropertyCollection* propCollection);
void renderProlog(const DataContainer& dataContainer, tgt::Shader* shader);
void renderEpilog(tgt::Shader* shader);
std::string generateHeader() const;
BoolProperty _applyMask; ///< Flag whether to apply mask
DataNameProperty _maskID; ///< ID for mask image (optional)
Vec4Property _maskColor; ///< Mask color
tgt::TextureUnit* _texUnit;
DataContainer::ScopedTypedData<ImageDataRenderTarget>* _maskImage;
};
}
#endif // PROCESSORDECORATORMASKING_H__
......@@ -98,12 +98,16 @@ namespace TUMVis {
_vmEepGenerator._sourceImageID.setValue("eep.input");
_pgGenerator._sourceImageID.setValue("eep.input");
_vmRenderer._renderTargetID.connect(&_vmEepGenerator._maskID);
_vmRenderer._renderTargetID.connect(&_combine._mirrorRenderID);
_vmEepGenerator._entryImageID.setValue("vm.eep.entry");
_vmEepGenerator._exitImageID.setValue("vm.eep.exit");
_vmEepGenerator._applyMask.setValue(true);
_vmEepGenerator._enableMirror.setValue(true);
// not the most beautiful way... *g*
// this will all get better with scripting support.
static_cast<BoolProperty*>(_vmEepGenerator.getProperty("applyMask"))->setValue(true);
_vmRenderer._renderTargetID.connect(static_cast<DataNameProperty*>(_vmEepGenerator.getProperty("maskID")));
_renderTargetID.setValue("combine");
_pgGenerator._geometryID.connect(&_vmEepGenerator._geometryID);
......
......@@ -36,6 +36,7 @@
#include "core/datastructures/imagedatagl.h"
#include "core/datastructures/imagedatarendertarget.h"
#include "core/datastructures/meshgeometry.h"
#include "core/pipeline/processordecoratormasking.h"
namespace TUMVis {
const std::string EEPGenerator::loggerCat_ = "TUMVis.modules.vis.EEPGenerator";
......@@ -49,11 +50,10 @@ namespace TUMVis {
, _exitImageID("exitImageID", "Output Exit Points Image", "eep.exit", DataNameProperty::WRITE)
, _camera("camera", "Camera")
, _enableMirror("enableMirror", "Enable Virtual Mirror Feature", false)