Commit 69aa6793 authored by schultezub's avatar schultezub
Browse files

introducing VolumeRendererDemo pipeline

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@487 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent d17c7e6b
......@@ -32,6 +32,7 @@
#include "modules/advancedusvis/pipelines/cmbatchgeneration.h"
#include "modules/vis/pipelines/ixpvdemo.h"
#include "modules/vis/pipelines/dvrvis.h"
#include "modules/vis/pipelines/volumerendererdemo.h"
#include "modules/vis/pipelines/slicevis.h"
#ifdef HAS_KISSCL
#include "modules/opencl/pipelines/openclpipeline.h"
......@@ -57,12 +58,13 @@ int main(int argc, char** argv) {
// app.addVisualizationPipeline("IXPV", new IxpvDemo());
//app.addVisualizationPipeline("SliceVis", new SliceVis());
//app.addVisualizationPipeline("DVRVis", new DVRVis());
app.addVisualizationPipeline("VolumeRendererDemo", new VolumeRendererDemo());
#ifdef HAS_KISSCL
//app.addVisualizationPipeline("DVR with OpenCL", new OpenCLPipeline());
#endif
#ifdef CAMPVIS_HAS_MODULE_SCR_MSK
app.addVisualizationPipeline("US Compounding", new UsCompounding());
//app.addVisualizationPipeline("US Compounding", new UsCompounding());
#endif
......
// ================================================================================================
//
// This file is part of the CAMPVis Software 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
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// 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 "volumerendererdemo.h"
#include "tgt/event/keyevent.h"
#include "tgt/glcontext.h"
#include "tgt/qt/qtcontextmanager.h"
#include "core/datastructures/imagedata.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
namespace campvis {
VolumeRendererDemo::VolumeRendererDemo()
: VisualizationPipeline()
, _camera("camera", "Camera")
, _imageReader()
, _vr(_effectiveRenderTargetSize)
, _trackballEH(0)
{
addProperty(&_camera);
_trackballEH = new TrackballNavigationEventHandler(this, &_camera, _canvasSize.getValue());
_eventHandlers.push_back(_trackballEH);
addProcessor(&_imageReader);
addProcessor(&_vr);
}
VolumeRendererDemo::~VolumeRendererDemo() {
delete _trackballEH;
}
void VolumeRendererDemo::init() {
VisualizationPipeline::init();
_imageReader.s_validated.connect(this, &VolumeRendererDemo::onProcessorValidated);
_camera.addSharedProperty(&_vr.p_camera);
_vr.p_outputImage.setValue("combine");
_renderTargetID.setValue("combine");
_imageReader.p_url.setValue("D:\\Medical Data\\smallHeart.mhd");
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.connect(&_vr.p_inputVolume);
// Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.f, .05f));
// dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.4f, .42f), tgt::col4(255, 0, 0, 255), tgt::col4(255, 0, 0, 255)));
// dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.45f, .5f), tgt::col4(0, 255, 0, 255), tgt::col4(0, 255, 0, 255)));
// _dvrNormal.p_transferFunction.replaceTF(dvrTF);
_trackballEH->setViewportSize(_effectiveRenderTargetSize.getValue());
_effectiveRenderTargetSize.s_changed.connect<VolumeRendererDemo>(this, &VolumeRendererDemo::onRenderTargetSizeChanged);
}
void VolumeRendererDemo::deinit() {
_effectiveRenderTargetSize.s_changed.disconnect(this);
VisualizationPipeline::deinit();
}
const std::string VolumeRendererDemo::getName() const {
return "VolumeRendererDemo";
}
void VolumeRendererDemo::onRenderTargetSizeChanged(const AbstractProperty* prop) {
_trackballEH->setViewportSize(_canvasSize.getValue());
float ratio = static_cast<float>(_effectiveRenderTargetSize.getValue().x) / static_cast<float>(_effectiveRenderTargetSize.getValue().y);
_camera.setWindowRatio(ratio);
}
void VolumeRendererDemo::onProcessorValidated(AbstractProcessor* processor) {
if (processor == &_imageReader) {
// update camera
DataContainer::ScopedTypedData<ImageData> img(_data, _imageReader.p_targetImageID.getValue());
if (img != 0) {
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
_trackballEH->setSceneBounds(volumeExtent);
_trackballEH->setCenter(volumeExtent.center());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _camera.getValue().getUpVector());
}
}
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software 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
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// 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 VOLUMERENDERERDEMO_H__
#define VOLUMERENDERERDEMO_H__
#include "core/eventhandlers/trackballnavigationeventhandler.h"
#include "core/pipeline/visualizationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/vis/processors/volumerenderer.h"
namespace campvis {
class VolumeRendererDemo : public VisualizationPipeline {
public:
/**
* Creates a VisualizationPipeline.
*/
VolumeRendererDemo();
/**
* Virtual Destructor
**/
virtual ~VolumeRendererDemo();
/// \see VisualizationPipeline::init()
virtual void init();
/// \see VisualizationPipeline::deinit()
virtual void deinit();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const;
void onRenderTargetSizeChanged(const AbstractProperty* prop);
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
CameraProperty _camera;
MhdImageReader _imageReader;
VolumeRenderer _vr;
TrackballNavigationEventHandler* _trackballEH;
};
}
#endif // VOLUMERENDERERDEMO_H__
......@@ -46,7 +46,7 @@ namespace campvis {
: VisualizationProcessor(canvasSize)
, p_inputVolume("InputVolume", "Input Volume", "", DataNameProperty::READ, AbstractProcessor::VALID)
, p_camera("Camera", "Camera", tgt::Camera(), AbstractProcessor::VALID)
, p_outputImage("OutputImage", "Output Image", "dd.output", DataNameProperty::WRITE, AbstractProcessor::VALID)
, p_outputImage("OutputImage", "Output Image", "vr.output", DataNameProperty::WRITE, AbstractProcessor::VALID)
, _pgGenerator()
, _eepGenerator(canvasSize)
, _raycaster(canvasSize)
......
......@@ -87,11 +87,14 @@ namespace campvis {
/**
* Slot getting called when one of the observed processors got invalidated.
* The default behaviour is to dispatch a job to execute the invalidated processor and emit the s_invalidated signal.
* Invalidates this meta-processor with the corresponding level.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorInvalidated(AbstractProcessor* processor);
/**
* \see VisualizationProcessor::onPropertyChanged
*/
virtual void onPropertyChanged(const AbstractProperty* prop);
ProxyGeometryGenerator _pgGenerator;
......
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