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

Introducing workflowdemo module showing a demo implementation on how to use...

Introducing workflowdemo module showing a demo implementation on how to use the CAMPVis workflow interface.

refs #13
parent 67dc1fff
// ================================================================================================
//
// 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.
//
// ================================================================================================
#include "imagefiltering.h"
#include "cgt/shadermanager.h"
namespace campvis {
namespace workflowdemo {
ImageFiltering::ImageFiltering(DataContainer* dc)
: AutoEvaluationPipeline(dc)
, _lsp()
, _glCrop(&_canvasSize)
, _ve(&_canvasSize)
{
addProcessor(&_lsp);
addProcessor(&_glCrop);
addProcessor(&_ve);
addEventListenerToBack(&_ve);
}
ImageFiltering::~ImageFiltering() {
}
void ImageFiltering::init() {
AutoEvaluationPipeline::init();
_glCrop.p_inputImage.setValue("image.original");
_glCrop.p_outputImage.setValue("image.cropped");
_ve.p_inputVolume.setValue("image.cropped");
_ve.p_outputImage.setValue("image.cropped.rendered");
_renderTargetID.setValue("image.cropped.rendered");
}
}
}
// ================================================================================================
//
// 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 IMAGEFILTERING_H__
#define IMAGEFILTERING_H__
#include "core/pipeline/autoevaluationpipeline.h"
#include "modules/base/processors/lightsourceprovider.h"
#include "modules/preprocessing/processors/glimagecrop.h"
#include "modules/vis/processors/volumeexplorer.h"
namespace campvis {
namespace workflowdemo {
class ImageFiltering : public AutoEvaluationPipeline {
public:
/**
* Creates a AutoEvaluationPipeline.
*/
ImageFiltering(DataContainer* dc);
/**
* Virtual Destructor
**/
virtual ~ImageFiltering();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "WorkflowDemo::ImageFiltering"; };
LightSourceProvider _lsp;
GlImageCrop _glCrop;
VolumeExplorer _ve;
};
}
}
#endif // IMAGEFILTERING_H__
// ================================================================================================
//
// 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.
//
// ================================================================================================
#include "imageloading.h"
#include "cgt/shadermanager.h"
#include "modules/workflowdemo/workflows/demoworkflow.h"
namespace campvis {
namespace workflowdemo {
ImageLoading::ImageLoading(DataContainer* dc)
: AutoEvaluationPipeline(dc)
, _imageReader()
{
addProcessor(&_imageReader);
}
ImageLoading::~ImageLoading() {
}
void ImageLoading::init() {
AutoEvaluationPipeline::init();
_imageReader.p_targetImageID.setValue("image.original");
}
}
}
// ================================================================================================
//
// 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 IMAGELOADING_H__
#define IMAGELOADING_H__
#include "core/pipeline/autoevaluationpipeline.h"
#include "modules/io/processors/genericimagereader.h"
namespace campvis {
namespace workflowdemo {
class ImageLoading : public AutoEvaluationPipeline {
public:
/**
* Creates a AutoEvaluationPipeline.
*/
ImageLoading(DataContainer* dc);
/**
* Virtual Destructor
**/
virtual ~ImageLoading();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "WorkflowDemo::ImageLoading"; };
campvis::GenericImageReader _imageReader;
};
}
}
#endif // IMAGELOADING_H__
// ================================================================================================
//
// 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.
//
// ================================================================================================
#include "imagevis.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
#include "modules/vis/processors/contextpreservingraycaster.h"
namespace campvis {
namespace workflowdemo {
ImageVis::ImageVis(DataContainer* dc)
: AutoEvaluationPipeline(dc)
, _ve(&_canvasSize, new SliceExtractor(nullptr), new ContextPreservingRaycaster(nullptr))
{
addProcessor(&_ve);
addEventListenerToBack(&_ve);
}
ImageVis::~ImageVis() {
}
void ImageVis::init() {
AutoEvaluationPipeline::init();
_ve.p_inputVolume.setValue("image.cropped");
_ve.p_outputImage.setValue("image.cropped.context");
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .05f));
dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.12f, .15f), cgt::col4(85, 0, 0, 128), cgt::col4(255, 0, 0, 128)));
dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.19f, .28f), cgt::col4(89, 89, 89, 155), cgt::col4(89, 89, 89, 155)));
dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.41f, .51f), cgt::col4(170, 170, 128, 64), cgt::col4(192, 192, 128, 64)));
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::SamplingRate"))->setValue(4.f);
_renderTargetID.setValue("image.cropped.context");
}
}
}
// ================================================================================================
//
// 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 IMAGEVIS_H__
#define IMAGEVIS_H__
#include "core/pipeline/autoevaluationpipeline.h"
#include "modules/vis/processors/volumeexplorer.h"
namespace campvis {
namespace workflowdemo {
class ImageVis : public AutoEvaluationPipeline {
public:
/**
* Creates a AutoEvaluationPipeline.
*/
ImageVis(DataContainer* dc);
/**
* Virtual Destructor
**/
virtual ~ImageVis();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "WorkflowDemo::ImageVis"; };
VolumeExplorer _ve;
};
}
}
#endif // IMAGEVIS_H__
# CMake file for workflowdemo module
IF(${ModuleEnabled})
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/workflowdemo/pipelines/*.cpp
modules/workflowdemo/workflows/*.cpp
)
# Header files (including GLSL files so that they'll appear in VS projects)
FILE(GLOB ThisModHeaders RELATIVE ${ModulesDir}
modules/workflowdemo/pipelines/*.h
modules/workflowdemo/workflows/*.h
)
SET(ThisModDependencies base io preprocessing vis)
ENDIF(${ModuleEnabled})
SET(ThisModStatus TESTING)
SET(ThisModExternalDependencies FALSE)
// ================================================================================================
//
// 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.
//
// ================================================================================================
#include "demoworkflow.h"
namespace campvis {
namespace workflowdemo {
DemoWorkflow::DemoWorkflow()
: AbstractWorkflow("DemoWorkflow")
{
_loaderPipeline = new ImageLoading(_dataContainer);
_filterPipeline = new ImageFiltering(_dataContainer);
_visPipeline = new ImageVis(_dataContainer);
typedef std::vector< std::pair<AbstractPipeline*, bool> > VisVec;
typedef std::vector<AbstractProperty*> PropVec;
VisVec vvl;
vvl.push_back(std::make_pair(_loaderPipeline, false));
vvl.push_back(std::make_pair(_filterPipeline, false));
vvl.push_back(std::make_pair(_visPipeline, false));
PropVec pvl;
pvl.push_back(&_loaderPipeline->_imageReader.p_url);
addStage(LOADING_STAGE, "Load Image", vvl, pvl);
VisVec vvf;
vvf.push_back(std::make_pair(_loaderPipeline, false));
vvf.push_back(std::make_pair(_filterPipeline, true));
vvf.push_back(std::make_pair(_visPipeline, false));
PropVec pvf;
pvf.push_back(&_filterPipeline->_glCrop.p_llf);
pvf.push_back(&_filterPipeline->_glCrop.p_urb);
addStage(FILTERING_STAGE, "Filter Image", vvf, pvf);
VisVec vvv;
vvv.push_back(std::make_pair(_loaderPipeline, false));
vvv.push_back(std::make_pair(_filterPipeline, false));
vvv.push_back(std::make_pair(_visPipeline, true));
PropVec pvv;
pvv.push_back(_visPipeline->_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::KappaS"));
pvv.push_back(_visPipeline->_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::KappaT"));
addStage(VIS_STAGE, "Context-preserving Visualization", vvv, pvv);
addStageTransition(LOADING_STAGE, FILTERING_STAGE);
addStageTransition(FILTERING_STAGE, VIS_STAGE);
}
DemoWorkflow::~DemoWorkflow() {
}
std::vector<AbstractPipeline*> DemoWorkflow::getPipelines() {
std::vector<AbstractPipeline*> toReturn;
toReturn.push_back(_loaderPipeline);
toReturn.push_back(_filterPipeline);
toReturn.push_back(_visPipeline);
return toReturn;
}
void DemoWorkflow::init() {
_dataContainer->s_dataAdded.connect(this, &DemoWorkflow::onDataContainerDataAdded);
this->s_stageChanged.connect(this, &DemoWorkflow::onStageChanged);
// nothing special to do here apart from calling base method
AbstractWorkflow::init();
}
void DemoWorkflow::deinit() {
_dataContainer->s_dataAdded.disconnect(this);
this->s_stageChanged.disconnect(this);
}
bool DemoWorkflow::isStageAvailable(int stage) const {
switch (stage) {
case LOADING_STAGE:
return true;
case FILTERING_STAGE:
return _dataContainer->hasData("image.original");
case VIS_STAGE:
return _dataContainer->hasData("image.cropped");
default:
return false;
}
}
void DemoWorkflow::onDataContainerDataAdded(std::string key, DataHandle) {
if (key == "image.original" || key == "image.cropped")
s_stageAvailabilityChanged.emitSignal();
}
void DemoWorkflow::onStageChanged(int from, int to) {
switch (to) {
case LOADING_STAGE:
_loaderPipeline->setEnabled(true);
_filterPipeline->setEnabled(false);
_visPipeline->setEnabled(false);
break;
case FILTERING_STAGE:
_loaderPipeline->setEnabled(false);
_filterPipeline->setEnabled(true);
_visPipeline->setEnabled(false);
break;
case VIS_STAGE:
_loaderPipeline->setEnabled(false);
_filterPipeline->setEnabled(false);
_visPipeline->setEnabled(true);
break;
}
}
}
}
// ================================================================================================
//
// 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 DEMOWORKFLOW_H__
#define DEMOWORKFLOW_H__
#include "core/pipeline/abstractworkflow.h"
#include "modules/workflowdemo/pipelines/imageloading.h"
#include "modules/workflowdemo/pipelines/imagefiltering.h"
#include "modules/workflowdemo/pipelines/imagevis.h"
#include "modules/pipelinefactory.h"
namespace campvis {
namespace workflowdemo {
class DemoWorkflow : public AbstractWorkflow {
public:
enum Stages {
LOADING_STAGE,
FILTERING_STAGE,
VIS_STAGE
};
/**
* Constructor
*/
DemoWorkflow();
/**
* Virtual Destructor
**/
virtual ~DemoWorkflow();
/// \see AbstractWorkflow::getPipelines()
virtual std::vector<AbstractPipeline*> getPipelines();
/// \see AbstractWorkflow::init()
virtual void init();
/// \see AbstractWorkflow::deinit()
virtual void deinit();
/// \see AbstractWorkflow::isStageAvailable()
virtual bool isStageAvailable(int stage) const;
/// \see AbstractWorkflow::getName()
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "DemoWorkflow"; };
protected:
void onDataContainerDataAdded(std::string key, DataHandle dh);
void onStageChanged(int from, int to);
ImageLoading* _loaderPipeline;
ImageFiltering* _filterPipeline;
ImageVis* _visPipeline;
};
}
template class WorkflowRegistrar<workflowdemo::DemoWorkflow>;
}
#endif // DEMOWORKFLOW_H__