Commit 2dea1366 authored by schultezub's avatar schultezub
Browse files

* added IxpvDemo pipeline stub

* implemented automatic connection of AbstractProcessor::s_invalidated signal

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@382 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent fbaee4f4
......@@ -132,6 +132,9 @@ namespace campvis {
if (_dcInspectorWidget != 0)
onBtnShowDataContainerInspectorClicked();
}
else if (AbstractProcessor* processor = dynamic_cast<AbstractProcessor*>(ptr)) {
_selectedProcessor = processor;
}
}
else {
emit updatePropCollectionWidget(0);
......@@ -146,6 +149,7 @@ namespace campvis {
if (_selectedProcessor != 0 && _selectedPipeline != 0) {
// this is not as trivial as it seems:
// We need the pipeline, probably an OpenGL context...
_selectedProcessor->applyInvalidationLevel(InvalidationLevel::INVALID_RESULT);
}
else if (_selectedPipeline != 0) {
......
......@@ -53,6 +53,7 @@ namespace campvis {
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
try {
(*it)->init();
(*it)->s_invalidated.connect(this, &AbstractPipeline::onProcessorInvalidated);
}
catch (tgt::Exception& e) {
LERROR("Caught Exception during initialization of processor: " << e.what());
......@@ -66,6 +67,7 @@ namespace campvis {
// deinitialize all processors:
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
try {
(*it)->s_invalidated.disconnect(this);
(*it)->deinit();
}
catch (tgt::Exception& e) {
......
......@@ -95,7 +95,10 @@ namespace campvis {
DataContainer& getDataContainer();
/**
* Adds the processors \a processor to this pipeline's processor list.
* Adds the processor \a processor to this pipeline's processor list.
* \note The s_invalidated signal of each processor on this list will be automatically
* connected to onProcessorInvalidated() during initialization and disconnected
* during deinitialization.
* \param processor The processor to add.
*/
void addProcessor(AbstractProcessor* processor);
......
......@@ -91,12 +91,6 @@ namespace campvis {
_eepGenerator.p_entryImageID.connect(&_clRaycaster._entryImageID);
_eepGenerator.p_exitImageID.connect(&_clRaycaster._exitImageID);
_imageReader.s_invalidated.connect<OpenCLPipeline>(this, &OpenCLPipeline::onProcessorInvalidated);
_pgGenerator.s_invalidated.connect<OpenCLPipeline>(this, &OpenCLPipeline::onProcessorInvalidated);
_eepGenerator.s_invalidated.connect<OpenCLPipeline>(this, &OpenCLPipeline::onProcessorInvalidated);
_clRaycaster.s_invalidated.connect<OpenCLPipeline>(this, &OpenCLPipeline::onProcessorInvalidated);
_trackballEH->setViewportSize(_effectiveRenderTargetSize.getValue());
_effectiveRenderTargetSize.s_changed.connect<OpenCLPipeline>(this, &OpenCLPipeline::onRenderTargetSizeChanged);
}
......
......@@ -39,7 +39,6 @@ uniform vec2 _viewportSizeRCP;
uniform bool _integrateGeometry; ///< flag whether to integrate geometry into the EEP
uniform bool _isEntrypoint; ///< true if current run is for entrypoints, false if current run is for exitpoints
uniform Texture2D _entryColorTexture; ///< depth texture of the entrypoints (only used in exitpoints run)
uniform Texture2D _entryDepthTexture; ///< depth texture of the entrypoints (only used in exitpoints run)
uniform Texture2D _geometryDepthTexture; ///< depth texture of rendered geometry
......
......@@ -140,17 +140,6 @@ namespace campvis {
_dvrNormal.p_targetImageID.connect(&_depthDarkening.p_inputImage);
_depthDarkening.p_outputImage.connect(&_combine.p_normalImageID);
_imageReader.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_vmgGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_vmRenderer.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_pgGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_eepGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_vmEepGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_dvrNormal.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_dvrVM.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_depthDarkening.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_combine.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_trackballEH->setViewportSize(_effectiveRenderTargetSize.getValue());
_effectiveRenderTargetSize.s_changed.connect<DVRVis>(this, &DVRVis::onRenderTargetSizeChanged);
}
......
// ================================================================================================
//
// 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 "ixpvdemo.h"
#include "tgt/event/keyevent.h"
#include "core/datastructures/imagedataconverter.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
namespace campvis {
IxpvDemo::IxpvDemo()
: VisualizationPipeline()
, _xrayReader()
, _ctReader()
, _usReader()
, _usSliceExtractor(_effectiveRenderTargetSize)
, _wheelHandler(&_usSliceExtractor.p_sliceNumber)
, _tfWindowingHandler(&_usSliceExtractor.p_transferFunction)
{
addProcessor(&_xrayReader);
addProcessor(&_ctReader);
addProcessor(&_usReader);
addProcessor(&_usSliceExtractor);
addEventHandler(&_wheelHandler);
addEventHandler(&_tfWindowingHandler);
}
IxpvDemo::~IxpvDemo() {
}
void IxpvDemo::init() {
VisualizationPipeline::init();
_xrayReader.p_url.setValue("D:\\Medical Data\\Dentalscan\\dental.mhd");
_xrayReader.p_targetImageID.setValue("xray");
_usSliceExtractor.p_sliceNumber.setValue(0);
// TODO: replace this hardcoded domain by automatically determined from image min/max values
Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(128, tgt::vec2(0.f, .08f));
tf->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 0), tgt::col4(255, 255, 255, 255)));
_usSliceExtractor.p_transferFunction.replaceTF(tf);
_renderTargetID.setValue("renderTarget");
_renderTargetID.addSharedProperty(&(_usSliceExtractor.p_targetImageID));
}
void IxpvDemo::execute() {
{
tbb::spin_mutex::scoped_lock lock(_localMutex);
_invalidationLevel.setValid();
// TODO: think whether we want to lock all processors already here.
}
if (! _xrayReader.getInvalidationLevel().isValid()) {
executeProcessor(&_xrayReader);
// convert data
DataContainer::ScopedTypedData<ImageData> img(_data, "reader.output");
ImageDataLocal* local = ImageDataConverter::tryConvert<ImageDataLocal>(img);
if (local != 0) {
DataHandle dh = _data.addData("se.input", local);
_usSliceExtractor.p_transferFunction.getTF()->setImageHandle(dh);
}
}
if (! _usSliceExtractor.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(&_usSliceExtractor);
}
}
void IxpvDemo::keyEvent(tgt::KeyEvent* e) {
if (e->pressed()) {
}
}
const std::string IxpvDemo::getName() const {
return "IXPV Demo";
}
}
\ 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 IXPVDEMO_H__
#define IXPVDEMO_H__
#include "core/datastructures/imagedatalocal.h"
#include "core/eventhandlers/mwheeltonumericpropertyeventhandler.h"
#include "core/eventhandlers/transfuncwindowingeventhandler.h"
#include "core/pipeline/visualizationpipeline.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/vis/processors/sliceextractor.h"
namespace campvis {
class IxpvDemo : public VisualizationPipeline {
public:
/**
* Creates a VisualizationPipeline.
*/
IxpvDemo();
/**
* Virtual Destructor
**/
virtual ~IxpvDemo();
/// \see VisualizationPipeline::init()
virtual void init();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const;
/**
* Execute this pipeline.
**/
virtual void execute();
virtual void keyEvent(tgt::KeyEvent* e);
protected:
MhdImageReader _xrayReader;
MhdImageReader _ctReader;
MhdImageReader _usReader;
SliceExtractor _usSliceExtractor;
MWheelToNumericPropertyEventHandler _wheelHandler;
TransFuncWindowingEventHandler _tfWindowingHandler;
};
}
#endif // IXPVDEMO_H__
......@@ -77,10 +77,6 @@ namespace campvis {
_renderTargetID.setValue("renderTarget");
_renderTargetID.addSharedProperty(&(_sliceExtractor.p_targetImageID));
_imageReader.s_invalidated.connect<SliceVis>(this, &SliceVis::onProcessorInvalidated);
_gvg.s_invalidated.connect<SliceVis>(this, &SliceVis::onProcessorInvalidated);
_sliceExtractor.s_invalidated.connect<SliceVis>(this, &SliceVis::onProcessorInvalidated);
}
void SliceVis::execute() {
......
......@@ -138,13 +138,14 @@ namespace campvis {
decorateRenderProlog(data, _shader);
const tgt::Camera& cam = p_camera.getValue();
tgt::TextureUnit geometryDepthUnit, entryDepthUnit;
_shader->setIgnoreUniformLocationError(true);
_shader->setUniform("_viewportSizeRCP", 1.f / tgt::vec2(_renderTargetSize.getValue()));
_shader->setUniform("_modelMatrix", mirrorMatrix);
const tgt::Camera& cam = p_camera.getValue();
_shader->setUniform("_projectionMatrix", cam.getProjectionMatrix());
_shader->setUniform("_viewMatrix", cam.getViewMatrix());
tgt::TextureUnit geometryDepthUnit;
if (geometryImage != 0) {
geometryImage->bind(_shader, 0, &geometryDepthUnit, "", "_geometryDepthTexture");
......@@ -191,8 +192,7 @@ namespace campvis {
_shader->setUniform("_isEntrypoint", false);
if (geometryImage != 0) {
tgt::TextureUnit entryColorUnit, entryDepthUnit;
entrypoints->bind(_shader, &entryColorUnit, &entryDepthUnit, "_entryColorTexture", "_entryDepthTexture");
entrypoints->bind(_shader, 0, &entryDepthUnit, "", "_entryDepthTexture");
}
glDepthFunc(GL_GREATER);
......
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