Commit b7817eb2 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Refactoring SliceExtractor processor:

To better support sharing the functionality of slice rendering, the SliceExtractor processor was refactored: Similar to the RaycastingProcessor, the main functionality was moved to an abstract base class, the SliceRenderProcessor. This takes care of computing all the necessary transformation matrices, optionally rendering crosshair and integrating geometry, as well as handling user input to support scribbling. The actual SliceExtractor processor now only implements the rendering of the slice itself, i.e. applying the transfer function.

In this regard, VolumeExplorer was updated to use the generic SliceRenderProcessor, and TransFuncWindowingEventListener supports changing of its assigned property.
parent 523ca698
......@@ -35,11 +35,10 @@ namespace campvis {
TransFuncWindowingEventListener::TransFuncWindowingEventListener(TransferFunctionProperty* property)
: tgt::EventListener()
, _prop(property)
, _mousePressed(false)
, _mouseDownPosition(0, 0)
, _originalIntensityDomain(0.f, 1.f)
, _mousePressed(false)
, _mouseDownPosition(0, 0)
, _originalIntensityDomain(0.f, 1.f)
{
tgtAssert(_prop != 0, "Assigned property must not be 0.");
}
TransFuncWindowingEventListener::~TransFuncWindowingEventListener() {
......@@ -47,6 +46,8 @@ namespace campvis {
}
void TransFuncWindowingEventListener::onEvent(tgt::Event* e) {
if (_prop == nullptr)
return;
if (typeid(*e) != typeid(tgt::MouseEvent))
return;
......@@ -89,4 +90,8 @@ namespace campvis {
}
}
void TransFuncWindowingEventListener::setTransferFunctionProperty(TransferFunctionProperty* prop) {
_prop = prop;
}
}
......@@ -42,6 +42,7 @@ namespace campvis {
public:
/**
* Creates a TransFuncWindowingEventListener.
* \param property The target transfer function property, may be 0.
*/
explicit TransFuncWindowingEventListener(TransferFunctionProperty* property);
......@@ -53,8 +54,14 @@ namespace campvis {
/// \see tgt::EventListener::onEvent()
virtual void onEvent(tgt::Event* e);
/**
* Sets the target transfer function property.
* \param prop The new target transfer function property, may be 0.
*/
void setTransferFunctionProperty(TransferFunctionProperty* prop);
protected:
TransferFunctionProperty* _prop;
TransferFunctionProperty* _prop; ///< The target transfer function property, may be 0
bool _mousePressed; ///< Flag whether the mouse is currently pressed
tgt::ivec2 _mouseDownPosition; ///< Viewport coordinates where mouse button has been pressed
......
This diff is collapsed.
// ================================================================================================
//
// 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 SLICERENDERPROCESSOR_H__
#define SLICERENDERPROCESSOR_H__
#include <string>
#include "tgt/event/eventlistener.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/allproperties.h"
namespace tgt {
class Shader;
}
namespace campvis {
class FaceGeometry;
class ImageData;
/**
* Base class for rendering an axis-aligned slice of a 3D image into a 2D viewport.
* Provides necessary properties, coordinate transforms, interaction handlers, as well as a
* callback for a scribbling feature.
*
* The single thing to be implemented by subclasses is the way the actual image is rendered.
*/
class CAMPVIS_CORE_API SliceRenderProcessor : public VisualizationProcessor, public tgt::EventListener {
public:
/// Slice Orientation to render
enum SliceOrientation {
XY_PLANE = 0,
XZ_PLANE = 1,
YZ_PLANE = 2
};
/**
* Constructs a new SliceRenderProcessor Processor
*
* \param viewportSizeProp Pointer to the parent pipeline's render target size property.
* \param fragmentShaderFileName Filename for the fragment shader being automatically loaded.
* \param customGlslVersion Custom GLSL version to pass to shader (Optional).
**/
SliceRenderProcessor(IVec2Property* viewportSizeProp, const std::string& fragmentShaderFileName, const std::string& customGlslVersion = "");
/**
* Destructor
**/
virtual ~SliceRenderProcessor();
/// \see AbstractProcessor::init
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/// \see tgt::EventListener::onEvent()
virtual void onEvent(tgt::Event* e);
/// Signal emitted when a scribble was painted, parameter gives the position in image coordinates.
sigslot::signal1<tgt::vec3> s_scribblePainted;
DataNameProperty p_sourceImageID; ///< image ID for input image
DataNameProperty p_geometryID; ///< ID for input geometry
DataNameProperty p_targetImageID; ///< image ID for output image
/// orientation of the slice to extract
GenericOptionProperty<SliceOrientation> p_sliceOrientation;
IntProperty p_xSliceNumber; ///< number of the slice in X direction
Vec4Property p_xSliceColor; ///< color for x marker
IntProperty p_ySliceNumber; ///< number of the slice in Y direction
Vec4Property p_ySliceColor; ///< color for y marker
IntProperty p_zSliceNumber; ///< number of the slice in Z direction
Vec4Property p_zSliceColor; ///< color for z marker
BoolProperty p_renderCrosshair; ///< Flag whether to render the crosshair or not
BoolProperty p_fitToWindow; ///< Flag whether fit image to window or use scaling and offset
FloatProperty p_scalingFactor; ///< Image scaling factor
IVec2Property p_offset; ///< Image offset
GenericOptionProperty<GLenum> p_geometryRenderMode; ///< Render mode for the geometry
FloatProperty p_geometryRenderSize; ///< Size of rendered elements
protected:
/**
* Pure virtual method to be implemented by subclasses.
* This method is supposed to implement the actual rendering of the slice, e.g. setup
* and apply transfer function. You may want to call renderCrosshair() or renderGeometry()
* yourself, if needed.
* \param dataContainer DataContainer of calling pipeline
* \param img Image to render (to avoid multiple redundant DataContainer queries), is guarantueed to not be 0)
*/
virtual void renderImageImpl(DataContainer& dataContainer, const ImageRepresentationGL::ScopedRepresentation& img) = 0;
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
/// \see AbstractProcessor::updateProperties
virtual void updateProperties(DataContainer& dataContainer);
/// \see AbstractProcessor::updateShader
virtual void updateShader();
/**
* Renders the crosshair indicating the slice positions into the current OpenGl context.
* \param img Image to render (to avoid multiple redundant DataContainer queries), is guarantueed to not be 0)
*/
virtual void renderCrosshair(const ImageRepresentationGL::ScopedRepresentation& img);
/**
* Renders integrated geometry into the current OpenGL context.
* \param dataContainer DataContainer of calling pipeline
* \param img Image to render (to avoid multiple redundant DataContainer queries), is guarantueed to not be 0)
*/
virtual void renderGeometry(DataContainer& dataContainer, const ImageRepresentationGL::ScopedRepresentation& img);
/**
* Setup all the transformation matrices (local members) needed for rendering.
* Gets called automatically from default updateResult() implementation prior to calling renderImageImpl().
* \param img Image to render (to avoid multiple redundant DataContainer queries), is guarantueed to not be 0)
*/
virtual void setupMatrices(const ImageRepresentationGL::ScopedRepresentation& img);
virtual std::string getGlslHeader();
tgt::Shader* _shader; ///< Shader for slice rendering
DataHandle _currentImage; ///< cached DataHandle to shown image (needed for scribbles)
bool _inScribbleMode; ///< Flag whether processor is in scribble mode (i.e. mouse is pressed)
const std::string _fragmentShaderFilename; ///< Filename for the fragment shader being automatically loaded.
const std::string _customGlslVersion; ///< Custom GLSL version to pass to shader
tgt::mat4 _texCoordMatrix; ///< Transformation matrix applied to texture coordinates
tgt::mat4 _geometryModelMatrix; ///< Transformation to apply to geometry to transform into slice space
tgt::mat4 _geometryProjectionMatrix; ///< Projection matrix to apply to geometry rendering
tgt::mat4 _viewMatrix; ///< View matrix applied to rendering (aspect ratio, zoom, shift)
static const std::string loggerCat_;
};
}
#endif // SLICERENDERPROCESSOR_H__
......@@ -43,7 +43,7 @@ namespace campvis {
const std::string PredicateVolumeExplorer::loggerCat_ = "CAMPVis.modules.vis.PredicateVolumeExplorer";
PredicateVolumeExplorer::PredicateVolumeExplorer(IVec2Property* viewportSizeProp)
: VolumeExplorer(viewportSizeProp, new PointPredicateRaycaster(0))
: VolumeExplorer(viewportSizeProp, new SliceExtractor(0), new PointPredicateRaycaster(0))
, p_inputLabels("InputLabels", "Input Label Image", "", DataNameProperty::READ)
, p_inputSnr("InputSnr", "Input SNR", "", DataNameProperty::READ)
, p_inputVesselness("InputVesselness", "Input Vesselness", "", DataNameProperty::READ)
......
This diff is collapsed.
......@@ -25,41 +25,14 @@
#ifndef SLICEEXTRACTOR_H__
#define SLICEEXTRACTOR_H__
#include <string>
#include "tgt/buffer.h"
#include "tgt/vertexarrayobject.h"
#include "tgt/event/eventlistener.h"
#include "core/pipeline/abstractprocessordecorator.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/floatingpointproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/optionproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/transferfunctionproperty.h"
namespace tgt {
class Shader;
}
#include "core/pipeline/slicerenderprocessor.h"
namespace campvis {
class FaceGeometry;
class ImageData;
/**
* Extracts a slice from a 3D image and renders it into a rendertarget.
*/
class SliceExtractor : public VisualizationProcessor, public tgt::EventListener {
class SliceExtractor : public SliceRenderProcessor {
public:
/// Slice Orientation to render
enum SliceOrientation {
XY_PLANE = 0,
XZ_PLANE = 1,
YZ_PLANE = 2
};
/**
* Constructs a new SliceExtractor Processor
**/
......@@ -70,12 +43,6 @@ namespace campvis {
**/
virtual ~SliceExtractor();
/// \see AbstractProcessor::init
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "SliceExtractor"; };
/// \see AbstractProcessor::getDescription()
......@@ -85,50 +52,15 @@ namespace campvis {
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::TESTING; };
/// \see tgt::EventListener::onEvent()
virtual void onEvent(tgt::Event* e);
/// Signal emitted when a scribble was painted, parameter gives the position in image coordinates.
sigslot::signal1<tgt::vec3> s_scribblePainted;
DataNameProperty p_sourceImageID; ///< image ID for input image
DataNameProperty p_geometryID; ///< ID for input geometry
DataNameProperty p_targetImageID; ///< image ID for output image
/// orientation of the slice to extract
GenericOptionProperty<SliceOrientation> p_sliceOrientation;
IntProperty p_xSliceNumber; ///< number of the slice in X direction
Vec4Property p_xSliceColor; ///< color for x marker
IntProperty p_ySliceNumber; ///< number of the slice in Y direction
Vec4Property p_ySliceColor; ///< color for y marker
IntProperty p_zSliceNumber; ///< number of the slice in Z direction
Vec4Property p_zSliceColor; ///< color for z marker
BoolProperty p_fitToWindow; ///< Flag whether fit image to window or use scaling and offset
FloatProperty p_scalingFactor; ///< Image scaling factor
IVec2Property p_offset; ///< Image offset
TransferFunctionProperty p_transferFunction; ///< Transfer function
GenericOptionProperty<GLenum> p_geometryRenderMode; ///< Render mode for the geometry
FloatProperty p_geometryRenderSize; ///< Size of rendered elements
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
/// \see AbstractProcessor::updateProperties
virtual void updateProperties(DataContainer& dataContainer);
tgt::Shader* _shader; ///< Shader for slice rendering
DataHandle _currentImage; ///< cached DataHandle to shown image (needed for scribbles)
bool _inScribbleMode; ///< Flag whether processor is in scribble mode (i.e. mouse is pressed)
/// \see SliceRenderProcessor::renderImageImpl
virtual void renderImageImpl(DataContainer& dataContainer, const ImageRepresentationGL::ScopedRepresentation& img);
static const std::string loggerCat_;
private:
clock_t _sourceImageTimestamp;
};
}
......
......@@ -38,7 +38,7 @@
namespace campvis {
const std::string VolumeExplorer::loggerCat_ = "CAMPVis.modules.vis.VolumeExplorer";
VolumeExplorer::VolumeExplorer(IVec2Property* viewportSizeProp, RaycastingProcessor* raycaster)
VolumeExplorer::VolumeExplorer(IVec2Property* viewportSizeProp, SliceRenderProcessor* sliceRenderer, RaycastingProcessor* raycaster)
: VisualizationProcessor(viewportSizeProp)
, p_inputVolume("InputVolume", "Input Volume", "", DataNameProperty::READ)
, p_outputImage("OutputImage", "Output Image", "ve.output", DataNameProperty::WRITE)
......@@ -46,17 +46,20 @@ namespace campvis {
, p_seProperties("SliceExtractorProperties", "Slice Extractor Properties")
, p_vrProperties("VolumeRendererProperties", "Volume Renderer Properties")
, _raycaster(viewportSizeProp, raycaster)
, _sliceExtractor(viewportSizeProp)
, _sliceRenderer(sliceRenderer)
, p_sliceRenderSize("SliceRenderSize", "Slice Render Size", tgt::ivec2(32), tgt::ivec2(0), tgt::ivec2(10000), tgt::ivec2(1))
, p_volumeRenderSize("VolumeRenderSize", "Volume Render Size", tgt::ivec2(32), tgt::ivec2(0), tgt::ivec2(10000), tgt::ivec2(1))
, _xSliceHandler(&_sliceExtractor.p_xSliceNumber)
, _ySliceHandler(&_sliceExtractor.p_ySliceNumber)
, _zSliceHandler(&_sliceExtractor.p_zSliceNumber)
, _windowingHandler(&_sliceExtractor.p_transferFunction)
, _xSliceHandler(&_sliceRenderer->p_xSliceNumber)
, _ySliceHandler(&_sliceRenderer->p_ySliceNumber)
, _zSliceHandler(&_sliceRenderer->p_zSliceNumber)
, _windowingHandler(nullptr)
, _trackballEH(0)
, _mousePressedInRaycaster(false)
, _scribblePointer(nullptr)
{
tgtAssert(raycaster != nullptr, "Raycasting Processor must not be 0.");
tgtAssert(_sliceRenderer != nullptr, "Slice Rendering Processor must not be 0.");
addProperty(p_inputVolume, INVALID_PROPERTIES);
addProperty(p_outputImage);
addProperty(p_enableScribbling, VALID);
......@@ -64,14 +67,14 @@ namespace campvis {
addDecorator(new ProcessorDecoratorBackground());
decoratePropertyCollection(this);
p_seProperties.addPropertyCollection(_sliceExtractor);
_sliceExtractor.p_lqMode.setVisible(false);
_sliceExtractor.p_sourceImageID.setVisible(false);
_sliceExtractor.p_targetImageID.setVisible(false);
_sliceExtractor.p_sliceOrientation.setVisible(false);
_sliceExtractor.p_xSliceColor.setVisible(false);
_sliceExtractor.p_ySliceColor.setVisible(false);
_sliceExtractor.p_zSliceColor.setVisible(false);
p_seProperties.addPropertyCollection(*_sliceRenderer);
_sliceRenderer->p_lqMode.setVisible(false);
_sliceRenderer->p_sourceImageID.setVisible(false);
_sliceRenderer->p_targetImageID.setVisible(false);
_sliceRenderer->p_sliceOrientation.setVisible(false);
_sliceRenderer->p_xSliceColor.setVisible(false);
_sliceRenderer->p_ySliceColor.setVisible(false);
_sliceRenderer->p_zSliceColor.setVisible(false);
addProperty(p_seProperties, VALID);
p_vrProperties.addPropertyCollection(_raycaster);
......@@ -81,9 +84,9 @@ namespace campvis {
addProperty(p_vrProperties, VALID);
p_inputVolume.addSharedProperty(&_raycaster.p_inputVolume);
p_inputVolume.addSharedProperty(&_sliceExtractor.p_sourceImageID);
p_inputVolume.addSharedProperty(&_sliceRenderer->p_sourceImageID);
_sliceExtractor.setViewportSizeProperty(&p_sliceRenderSize);
_sliceRenderer->setViewportSizeProperty(&p_sliceRenderSize);
_raycaster.setViewportSizeProperty(&p_volumeRenderSize);
addProperty(p_sliceRenderSize, VALID);
......@@ -92,6 +95,10 @@ namespace campvis {
// Event-Handlers
_trackballEH = new TrackballNavigationEventListener(&_raycaster.p_camera, &p_volumeRenderSize);
_trackballEH->addLqModeProcessor(&_raycaster);
if (TransferFunctionProperty* tester = dynamic_cast<TransferFunctionProperty*>(_sliceRenderer->getProperty("TransferFunction"))) {
_windowingHandler.setTransferFunctionProperty(tester);
}
}
VolumeExplorer::~VolumeExplorer() {
......@@ -101,13 +108,13 @@ namespace campvis {
void VolumeExplorer::init() {
VisualizationProcessor::init();
_raycaster.init();
_sliceExtractor.init();
_sliceRenderer->init();
_shader = ShdrMgr.load("core/glsl/passthrough.vert", "modules/vis/glsl/volumeexplorer.frag", "");
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
_sliceExtractor.s_invalidated.connect(this, &VolumeExplorer::onProcessorInvalidated);
_sliceRenderer->s_invalidated.connect(this, &VolumeExplorer::onProcessorInvalidated);
_raycaster.s_invalidated.connect(this, &VolumeExplorer::onProcessorInvalidated);
_quad = GeometryDataFactory::createQuad(tgt::vec3(0.f), tgt::vec3(1.f), tgt::vec3(0.f), tgt::vec3(1.f));
......@@ -118,7 +125,7 @@ namespace campvis {
void VolumeExplorer::deinit() {
_raycaster.deinit();
_sliceExtractor.deinit();
_sliceRenderer->deinit();
VisualizationProcessor::deinit();
ShdrMgr.dispose(_shader);
delete _quad;
......@@ -151,17 +158,17 @@ namespace campvis {
_raycaster.process(data);
}
if (getInvalidationLevel() & SLICES_INVALID) {
_sliceExtractor.p_sliceOrientation.selectById("x");
_sliceExtractor.p_targetImageID.setValue(p_outputImage.getValue() + ".xSlice");
_sliceExtractor.process(data);
_sliceRenderer->p_sliceOrientation.selectById("x");
_sliceRenderer->p_targetImageID.setValue(p_outputImage.getValue() + ".xSlice");
_sliceRenderer->process(data);
_sliceExtractor.p_sliceOrientation.selectById("y");
_sliceExtractor.p_targetImageID.setValue(p_outputImage.getValue() + ".ySlice");
_sliceExtractor.process(data);
_sliceRenderer->p_sliceOrientation.selectById("y");
_sliceRenderer->p_targetImageID.setValue(p_outputImage.getValue() + ".ySlice");
_sliceRenderer->process(data);
_sliceExtractor.p_sliceOrientation.selectById("z");
_sliceExtractor.p_targetImageID.setValue(p_outputImage.getValue() + ".zSlice");
_sliceExtractor.process(data);
_sliceRenderer->p_sliceOrientation.selectById("z");
_sliceRenderer->p_targetImageID.setValue(p_outputImage.getValue() + ".zSlice");
_sliceRenderer->process(data);
}
// compose rendering
......@@ -177,19 +184,19 @@ namespace campvis {
}
if (prop == &p_outputImage) {
_raycaster.p_outputImage.setValue(p_outputImage.getValue() + ".raycaster");
_sliceExtractor.p_geometryID.setValue(p_outputImage.getValue() + ".scribbles");
_sliceRenderer->p_geometryID.setValue(p_outputImage.getValue() + ".scribbles");
}
if (prop == &p_inputVolume) {
invalidate(VR_INVALID | SLICES_INVALID);
}
if (prop == &p_enableScribbling) {
if (p_enableScribbling.getValue() == true) {
_sliceExtractor.s_scribblePainted.connect(this, &VolumeExplorer::onSliceExtractorScribblePainted);
_sliceExtractor.p_geometryID.setValue(p_outputImage.getValue() + ".scribbles");
_sliceRenderer->s_scribblePainted.connect(this, &VolumeExplorer::onSliceExtractorScribblePainted);
_sliceRenderer->p_geometryID.setValue(p_outputImage.getValue() + ".scribbles");
}
else {
_sliceExtractor.s_scribblePainted.disconnect(this);
_sliceExtractor.p_geometryID.setValue("");
_sliceRenderer->s_scribblePainted.disconnect(this);
_sliceRenderer->p_geometryID.setValue("");
}
}
......@@ -264,7 +271,7 @@ namespace campvis {
if (processor == &_raycaster) {
invalidate(VR_INVALID);
}
if (processor == &_sliceExtractor) {
if (processor == _sliceRenderer) {
invalidate(SLICES_INVALID);
}
......@@ -274,22 +281,21 @@ namespace campvis {
void VolumeExplorer::updateProperties(DataContainer& dc) {
ScopedTypedData<ImageData> img(dc, p_inputVolume.getValue());
_sliceExtractor.p_transferFunction.setImageHandle(img.getDataHandle());
static_cast<TransferFunctionProperty*>(_raycaster.getNestedProperty("RaycasterProps::TransferFunction"))->setImageHandle(img.getDataHandle());
if (img != 0) {
const tgt::svec3& imgSize = img->getSize();
if (_sliceExtractor.p_xSliceNumber.getMaxValue() != static_cast<int>(imgSize.x) - 1){
_sliceExtractor.p_xSliceNumber.setMaxValue(static_cast<int>(imgSize.x) - 1);
_sliceExtractor.p_xSliceNumber.setValue(static_cast<int>(imgSize.x) / 2);
if (_sliceRenderer->p_xSliceNumber.getMaxValue() != static_cast<int>(imgSize.x) - 1){
_sliceRenderer->p_xSliceNumber.setMaxValue(static_cast<int>(imgSize.x) - 1);
_sliceRenderer->p_xSliceNumber.setValue(static_cast<int>(imgSize.x) / 2);
}
if (_sliceExtractor.p_ySliceNumber.getMaxValue() != static_cast<int>(imgSize.y) - 1){
_sliceExtractor.p_ySliceNumber.setMaxValue(static_cast<int>(imgSize.y) - 1);
_sliceExtractor.p_ySliceNumber.setValue(static_cast<int>(imgSize.y) / 2);
if (_sliceRenderer->p_ySliceNumber.getMaxValue() != static_cast<int>(imgSize.y) - 1){
_sliceRenderer->p_ySliceNumber.setMaxValue(static_cast<int>(imgSize.y) - 1);
_sliceRenderer->p_ySliceNumber.setValue(static_cast<int>(imgSize.y) / 2);
}
if (_sliceExtractor.p_zSliceNumber.getMaxValue() != static_cast<int>(imgSize.z) - 1){
_sliceExtractor.p_zSliceNumber.setMaxValue(static_cast<int>(imgSize.z) - 1);
_sliceExtractor.p_zSliceNumber.setValue(static_cast<int>(imgSize.z) / 2);
if (_sliceRenderer->p_zSliceNumber.getMaxValue() != static_cast<int>(imgSize.z) - 1){
_sliceRenderer->p_zSliceNumber.setMaxValue(static_cast<int>(imgSize.z) - 1);
_sliceRenderer->p_zSliceNumber.setValue(static_cast<int>(imgSize.z) / 2);
}
_trackballEH->reinitializeCamera(img);
......@@ -328,31 +334,31 @@ namespace campvis {
AbstractProcessor::ScopedLock lock(this);
if (me->y() <= p_sliceRenderSize.getValue().y) {
_sliceExtractor.p_sliceOrientation.selectByOption(SliceExtractor::XY_PLANE);
_sliceRenderer->p_sliceOrientation.selectByOption(SliceExtractor::XY_PLANE);
tgt::MouseEvent adjustedMe(
me->x(), me->y(),
me->action(), me->modifiers(), me->button(),
p_sliceRenderSize.getValue()
);
_sliceExtractor.onEvent(&adjustedMe);
_sliceRenderer->onEvent(&adjustedMe);
}
else if (me->y() <= 2*p_sliceRenderSize.getValue().y) {
_sliceExtractor.p_sliceOrientation.selectByOption(SliceExtractor::XZ_PLANE);
_sliceRenderer->p_sliceOrientation.selectByOption(SliceExtractor::XZ_PLANE);
tgt::MouseEvent adjustedMe(
me->x(), me->y() - p_sliceRenderSize.getValue().y,
me->action(), me->modifiers(), me->button(),
p_sliceRenderSize.getValue()
);
_sliceExtractor.onEvent(&adjustedMe);
_sliceRenderer->onEvent(&adjustedMe);
}
else {
_sliceExtractor.p_sliceOrientation.selectByOption(SliceExtractor::YZ_PLANE);
_sliceRenderer->p_sliceOrientation.selectByOption(SliceExtractor::YZ_PLANE);
tgt::MouseEvent adjustedMe(
me->x(), me->y() - (2 * p_sliceRenderSize.getValue().y),
me->action(), me->modifiers(), me->button(),
p_sliceRenderSize.getValue()
);
_sliceExtractor.onEvent(&adjustedMe);
_sliceRenderer->onEvent(&adjustedMe);
}
}
......
......@@ -58,7 +58,7 @@ namespace campvis {
* \param viewportSizeProp Pointer to the property defining the viewport size, must not be 0.
* \param raycaster Raycaster to use for rendering, must not be 0, VolumeRenderer will take ownership.
**/
VolumeExplorer(IVec2Property* viewportSizeProp, RaycastingProcessor* raycaster = new SimpleRaycaster(0));
VolumeExplorer(IVec2Property* viewportSizeProp, SliceRenderProcessor* sliceRenderer = new SliceExtractor(0), RaycastingProcessor* raycaster = new SimpleRaycaster(0));
/**
* Destructor
......@@ -131,7 +131,7 @@ namespace campvis {
FaceGeometry* _quad;
VolumeRenderer _raycaster;
SliceExtractor _sliceExtractor;