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

Merge branch 'development' of /mnt/bigone/git/repositories/berge/campvis

parents 3aa094f7 5bb124e2
# Files generated by CMake
CMakeCache.txt
CMakeFiles
cmake_install.cmake
Makefile
# Files generated by Qt's moc and uic
moc_*.cxx
moc_*.cxx_parameters
application/ui_mainwindow.h
# Project files of common IDEs
*.cbp
# Documentation generated by Doxygen
doc/html
doc/Doxyfile
......@@ -18,8 +18,10 @@ OPTION(CAMPVIS_BUILD_CORE "Build CAMPVis Core"
OPTION(CAMPVIS_BUILD_MODULES "Build CAMPVis Modules" ON)
OPTION(CAMPVIS_BUILD_LIB_TGT "Build TGT Library" ON)
OPTION(CAMPVIS_BUILD_LIB_KISSCL "Build KissCL Library" OFF)
OPTION(CAMPVIS_BUILD_DOXYGEN "Build Doxygen Documentation" ON)
OPTION(CAMPVIS_DEPLOY_SHADERS "Deploy Shader files to binary directory" OFF)
OPTION(CAMPVIS_GROUP_SOURCE_FILES "Group source files by directory" OFF)
IF(WIN32)
OPTION(CAMPVIS_COPY_EXTERNAL_DLLS "Copy external DLLs to bin directory?" ON)
......@@ -33,8 +35,6 @@ ENDIF()
include(cmake/commonconf.cmake)
include(cmake/parseModulesDir.cmake)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
MESSAGE(STATUS "--------------------------------------------------------------------------------")
IF(CAMPVIS_BUILD_LIB_TGT)
......@@ -59,6 +59,10 @@ IF(CAMPVIS_BUILD_APPLICATION)
ADD_SUBDIRECTORY(application)
ENDIF()
IF(CAMPVIS_BUILD_DOXYGEN)
ADD_SUBDIRECTORY(doc EXCLUDE_FROM_ALL)
ENDIF()
#
# Copy External DLLs
......
......@@ -8,6 +8,7 @@ FILE(GLOB CampvisApplicationSources
*.cpp
gui/*.cpp
gui/properties/*.cpp
gui/adjusterwidgets/*.cpp
tools/*.cpp
)
......@@ -17,6 +18,7 @@ FILE(GLOB CampvisApplicationHeaders
glsl/*.vert
gui/*.h
gui/properties/*.h
gui/adjusterwidgets/*.h
tools/*.h
)
......@@ -34,6 +36,11 @@ SET(CampvisApplicationToBeMocced
gui/qtdatahandle.h
gui/logviewerwidget.h
gui/loghighlighter.h
gui/pipelinemdisubwindow.h
gui/visualizationpipelinewidget.h
gui/visualizationpipelinewrapper.h
gui/adjusterwidgets/doubleadjusterwidget.h
gui/adjusterwidgets/intadjusterwidget.h
gui/properties/abstractpropertywidget.h
gui/properties/abstracttransferfunctioneditor.h
gui/properties/boolpropertywidget.h
......@@ -75,6 +82,13 @@ ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${Campv
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs})
TARGET_LINK_LIBRARIES(campvis-application campvis-core campvis-modules tgt ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs} ${QT_LIBRARIES})
IF(CAMPVIS_GROUP_SOURCE_FILES)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisApplicationSources ${CampvisHome} "")
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisApplicationHeaders ${CampvisHome} "")
ENDIF()
IF(CAMPVIS_DEPLOY_SHADERS)
LIST(APPEND CampvisShaderDirectories "application/glsl")
LIST(APPEND CampvisShaderDirectories "core/glsl")
......
......@@ -33,6 +33,7 @@
#include "modules/vis/pipelines/ixpvdemo.h"
#include "modules/vis/pipelines/dvrvis.h"
#include "modules/vis/pipelines/volumerendererdemo.h"
#include "modules/vis/pipelines/volumeexplorerdemo.h"
#include "modules/vis/pipelines/slicevis.h"
#ifdef HAS_KISSCL
#include "modules/opencl/pipelines/openclpipeline.h"
......@@ -46,6 +47,10 @@
#include "modules/columbia/pipelines/columbia1.h"
#endif
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#endif
using namespace campvis;
/**
......@@ -56,13 +61,18 @@ using namespace campvis;
* \return 0 if program exited successfully
**/
int main(int argc, char** argv) {
#ifdef Q_WS_X11
XInitThreads();
#endif
CampVisApplication app(argc, argv);
//app.addVisualizationPipeline("Advanced Ultrasound Visualization", new AdvancedUsVis());
//app.addVisualizationPipeline("Confidence Map Generation", new CmBatchGeneration());
// app.addVisualizationPipeline("IXPV", new IxpvDemo());
//app.addVisualizationPipeline("SliceVis", new SliceVis());
//app.addVisualizationPipeline("DVRVis", new DVRVis());
app.addVisualizationPipeline("DVRVis", new DVRVis());
//app.addVisualizationPipeline("VolumeRendererDemo", new VolumeRendererDemo());
app.addVisualizationPipeline("VolumeExplorerDemo", new VolumeExplorerDemo());
#ifdef HAS_KISSCL
//app.addVisualizationPipeline("DVR with OpenCL", new OpenCLPipeline());
#endif
......@@ -72,7 +82,7 @@ int main(int argc, char** argv) {
#endif
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
app.addVisualizationPipeline("Columbia", new Columbia1());
//app.addVisualizationPipeline("Columbia", new Columbia1());
#endif
......
......@@ -55,7 +55,7 @@ namespace campvis {
const std::string CampVisApplication::loggerCat_ = "CAMPVis.application.CampVisApplication";
CampVisApplication::CampVisApplication(int argc, char** argv, bool useOpenCL)
CampVisApplication::CampVisApplication(int& argc, char** argv, bool useOpenCL)
: QApplication(argc, argv)
, _localContext(0)
, _mainWindow(0)
......@@ -106,10 +106,13 @@ namespace campvis {
// ensure matching OpenGL specs
if (GpuCaps.getGlVersion() < tgt::GpuCapabilities::GlVersion::TGT_GL_VERSION_3_3) {
LERROR("Your system does not support OpenGL 3.3, which is mandatory. CAMPVis will probably not work as intendet.");
LERROR("Your system does not support OpenGL 3.3, which is mandatory. CAMPVis will probably not work as intended.");
}
if (GpuCaps.getShaderVersion() < tgt::GpuCapabilities::GlVersion::SHADER_VERSION_330) {
LERROR("Your system does not support GLSL Shader Version 3.30, which is mandatory. CAMPVis will probably not work as intendet.");
LERROR("Your system does not support GLSL Shader Version 3.30, which is mandatory. CAMPVis will probably not work as intended.");
}
if (!GpuCaps.isNpotSupported() && !GpuCaps.areTextureRectanglesSupported()) {
LERROR("Neither non-power-of-two textures nor texture rectangles seem to be supported. CAMPVis will probably not work as intended.");
}
QuadRenderer::init();
......@@ -144,6 +147,15 @@ namespace campvis {
CLRtm.addPath(basePath);
CLRtm.addPath(basePath + "/core/cl");
}
#ifdef CAMPVIS_SOURCE_DIR
{
std::string sourcePath = CAMPVIS_SOURCE_DIR;
CLRtm.addPath(sourcePath);
CLRtm.addPath(sourcePath + "/core/glsl");
}
#endif
#endif
}
......
......@@ -60,7 +60,7 @@ namespace campvis {
* 5. call deinit()
* 6. You can now safely destroy your CampVisApplication
*/
class CampVisApplication : QApplication {
class CampVisApplication : public QApplication {
friend class MainWindow;
public:
......@@ -70,7 +70,7 @@ namespace campvis {
* \param argv vector of arguments
* \param useOpenCL Flag, whether to use OpenCL (inits and deinits KissCL lib at the appropriate time).
*/
CampVisApplication(int argc, char** argv, bool useOpenCL = true);
CampVisApplication(int& argc, char** argv, bool useOpenCL = true);
/**
* Destructor, make sure to call deinit() first.
......
......@@ -31,14 +31,16 @@
#include "tgt/assert.h"
#include "tgt/camera.h"
#include "tgt/quadric.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "tgt/qt/qtthreadedcanvas.h"
#include "tgt/qt/qtglcontext.h"
#include "tgt/qt/qtcontextmanager.h"
#include "tgt/quadric.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/datastructures/renderdata.h"
#include "core/pipeline/visualizationpipeline.h"
#include "core/tools/job.h"
#include "core/tools/opengljobprocessor.h"
......@@ -95,9 +97,9 @@ namespace campvis {
glViewport(0, 0, size.x, size.y);
// try get Data
ImageRepresentationRenderTarget::ScopedRepresentation image(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
DataContainer::ScopedTypedData<RenderData> rd(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (image != 0) {
if (rd != 0) {
// activate shader
_copyShader->activate();
_copyShader->setIgnoreUniformLocationError(true);
......@@ -107,7 +109,7 @@ namespace campvis {
// bind input textures
tgt::TextureUnit colorUnit, depthUnit;
image->bind(_copyShader, colorUnit, depthUnit);
rd->bind(_copyShader, colorUnit, depthUnit);
LGL_ERROR;
// execute the shader
......@@ -168,7 +170,7 @@ namespace campvis {
if (_pipeline != 0) {
_pipeline->s_renderTargetChanged.disconnect(this);
if (getCanvas()->getEventHandler() != 0)
getCanvas()->getEventHandler()->removeListener(_pipeline);
getCanvas()->getEventHandler()->removeEventListener(_pipeline);
_pipeline = 0;
}
}
......@@ -178,22 +180,26 @@ namespace campvis {
if (_pipeline != 0) {
_pipeline->s_renderTargetChanged.disconnect(this);
if (getCanvas()->getEventHandler() != 0)
getCanvas()->getEventHandler()->removeListener(_pipeline);
getCanvas()->getEventHandler()->removeEventListener(_pipeline);
}
_pipeline = pipeline;
_pipeline->s_renderTargetChanged.connect(this, &TumVisPainter::onRenderTargetChanged);
_pipeline->setRenderTargetSize(getCanvas()->getSize());
if (getCanvas()->getEventHandler() != 0)
getCanvas()->getEventHandler()->addListenerToFront(_pipeline);
getCanvas()->getEventHandler()->addEventListenerToFront(_pipeline);
}
void TumVisPainter::onRenderTargetChanged() {
void TumVisPainter::repaint() {
GLJobProc.enqueueJob(getCanvas(), makeJobOnHeap(this, &TumVisPainter::paint), OpenGLJobProcessor::PaintJob);
}
void TumVisPainter::onRenderTargetChanged() {
repaint();
}
void TumVisPainter::setCanvas(tgt::GLCanvas* canvas) {
tgtAssert(dynamic_cast<tgt::QtThreadedCanvas*>(canvas) != 0, "Canvas must be of type QtThreadedCanvas!");
Painter::setCanvas(canvas);
}
}
\ No newline at end of file
}
......@@ -79,9 +79,9 @@ namespace campvis {
void run();
/**
* Performs the actual rendering of the pipeline's render target
* Schedule a repaint job for the pipeline's render target
*/
virtual void paint();
virtual void repaint();
/// \see tgt::Painter::sizeChanged
virtual void sizeChanged(const tgt::ivec2& size);
......@@ -114,6 +114,11 @@ namespace campvis {
void onRenderTargetChanged();
private:
/**
* Performs the actual rendering of the pipeline's render target
*/
virtual void paint();
static const std::string loggerCat_;
VisualizationPipeline* _pipeline; ///< Pipeline to render
......
// ================================================================================================
//
// 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.
//
// ================================================================================================
#ifndef ABSTRACTADJUSTERWIDGET_H__
#define ABSTRACTADJUSTERWIDGET_H__
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QSlider>
#include <QSpinBox>
namespace campvis {
namespace {
template<typename T>
struct AdjusterWidgetTraits {};
template<>
struct AdjusterWidgetTraits<double> {
typedef QDoubleSpinBox SpinBoxType;
};
template<>
struct AdjusterWidgetTraits<int> {
typedef QSpinBox SpinBoxType;
};
}
// ================================================================================================
/**
* Base class for widgets providing two ways of adjusting numeric values.
*
* AbstractAdjusterWidget consists of a slider, which can be used to quickly change numeric values, and a spin box,
* which is better suited for precise adjustments.
*/
template<typename T>
class AbstractAdjusterWidget : public QWidget {
public:
/**
* Creates a new AbstractAdjusterWidget.
* \param parent parent Qt widget
*/
AbstractAdjusterWidget(QWidget* parent = 0);
/**
* Return the adjuster's current value.
*/
T value() const;
/**
* Return the adjuster's minimum value.
*/
T minimum() const;
/**
* Change the adjuster's minimum value.
* \param minimum new minimum value for the adjuster
*/
void setMinimum(T minimum);
/**
* Return the adjuster's maximum value.
*/
T maximum() const;
/**
* Change the adjuster's maximum value.
* \param maximum new maximum value for the adjuster
*/
void setMaximum(T maximum);
/**
* Return the adjuster's single step value.
*/
T singleStep() const;
/**
* Change the adjuster's single step value.
* \param value new single step value for the adjuster
*/
void setSingleStep(T value);
protected:
/**
* Change the adjuster's current value.
* \param value new value for the adjuster
*/
void setValueImpl(T value);
/// Slot getting called when the spin box's value changes
void onSpinBoxValueChangedImpl(T value);
/// Slot getting called when the slider's value changes
void onSliderValueChangedImpl(T value);
/**
* Set the slider's value.
*
* The slider's value will be set to \p value.
*
* \param value the slider's new value
*/
virtual void setSliderValue(T value);
/**
* Set the slider's properties.
*
* The slider's step, minimum, and maximum value will be updated with the provided arguments.
*
* \param stepValue the slider's new step value
* \param minValue the slider's new minimum value
* \param maxValue the slider's new maximum value
*/
virtual void setSliderProperties(T stepValue, T minValue, T maxValue);
QSlider* _slider; ///< Slider allowing the user to quickly change the value
typename AdjusterWidgetTraits<T>::SpinBoxType* _spinBox; ///< Spin box displaying the current value
};
// ================================================================================================
template<typename T>
AbstractAdjusterWidget<T>::AbstractAdjusterWidget(QWidget* parent /*= 0*/)
: QWidget(parent)
, _slider(0)
, _spinBox(0)
{
_spinBox = new typename AdjusterWidgetTraits<T>::SpinBoxType;
_spinBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
_slider = new QSlider(Qt::Horizontal);
QHBoxLayout* layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(_slider);
layout->addWidget(_spinBox);
setLayout(layout);
}
template<typename T>
T AbstractAdjusterWidget<T>::value() const
{
return _spinBox->value();
}
template<typename T>
void AbstractAdjusterWidget<T>::setValueImpl(T value)
{
_spinBox->setValue(value);
setSliderValue(value);
}
template<typename T>
T AbstractAdjusterWidget<T>::minimum() const
{
return _spinBox->minimum();
}
template<typename T>
void AbstractAdjusterWidget<T>::setMinimum(T minimum)
{
_spinBox->setMinimum(minimum);
setSliderProperties(_spinBox->singleStep(), minimum, _spinBox->maximum());
}
template<typename T>
T AbstractAdjusterWidget<T>::maximum() const
{
return _spinBox->maximum();
}
template<typename T>
void AbstractAdjusterWidget<T>::setMaximum(T maximum)
{
_spinBox->setMaximum(maximum);
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), maximum);
}
template<typename T>
T AbstractAdjusterWidget<T>::singleStep() const
{
return _spinBox->singleStep();
}
template<typename T>
void AbstractAdjusterWidget<T>::setSingleStep(T value)
{
_spinBox->setSingleStep(value);
setSliderProperties(value, _spinBox->minimum(), _spinBox->maximum());
}
template<typename T>
void AbstractAdjusterWidget<T>::onSpinBoxValueChangedImpl(T value) {
setSliderValue(value);
}
template<typename T>
void AbstractAdjusterWidget<T>::onSliderValueChangedImpl(T value) {
_spinBox->blockSignals(true);
_spinBox->setValue(value);
_spinBox->blockSignals(false);
}
template<typename T>
void AbstractAdjusterWidget<T>::setSliderValue(T value) {
_slider->blockSignals(true);
_slider->setValue(value);
_slider->blockSignals(false);
}
template<typename T>
void AbstractAdjusterWidget<T>::setSliderProperties(T stepValue, T minValue, T maxValue) {
_slider->blockSignals(true);
_slider->setMinimum(minValue);
_slider->setMaximum(maxValue);
_slider->setSingleStep(stepValue);
_slider->blockSignals(false);
}
}
#endif // ABSTRACTADJUSTERWIDGET_H__
// ================================================================================================
//
// 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 "doubleadjusterwidget.h"
#include <cmath>
namespace campvis {
DoubleAdjusterWidget::DoubleAdjusterWidget(QWidget* parent /*= 0*/)
: AbstractAdjusterWidget<double>(parent)
{
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), _spinBox->maximum());
connect(_spinBox, SIGNAL(valueChanged(double)), this, SLOT(onSpinBoxValueChanged(double)));
connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
}
void DoubleAdjusterWidget::setValue(double value)
{
setValueImpl(value);
}
void DoubleAdjusterWidget::setDecimals(int prec)
{
_spinBox->setDecimals(prec);
setSliderProperties(_spinBox->singleStep(), _spinBox->minimum(), _spinBox->maximum());
}
void DoubleAdjusterWidget::onSpinBoxValueChanged(double value) {
onSpinBoxValueChangedImpl(value);
emit valueChanged(value);
}
void DoubleAdjusterWidget::onSliderValueChanged(int value) {
const double newValue = _spinBox->minimum() + value * _spinBox->singleStep();
onSliderValueChangedImpl(newValue);
emit valueChanged(newValue);