Commit 35d262db authored by Jakob Weiss's avatar Jakob Weiss

Merge branch 'campvis-nx' into 'campvis-nx'

Campvis nx

See merge request CAMP/campvis-public!7
parents d97de6a8 4826c14b
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Windows-style newlines with a newline ending every file
[*]
end_of_line = crlf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
# Files generated by CMake # Files generated by CMake
CMakeCache.txt CMakeCache.txt
CMakeLists.txt.user
CMakeFiles CMakeFiles
cmake_install.cmake cmake_install.cmake
Makefile Makefile
/core/gen_converterregistration.h /core/gen_converterregistration.h
/modules/gen_pipelineregistration.h /modules/gen_pipelineregistration.h
FailedShader.vert
FailedShader.geom
FailedShader.frag
FailedShader.comp
# Files generated by Qt's moc and uic # Files generated by Qt's moc and uic
moc_*.cxx moc_*.cxx
...@@ -48,3 +53,12 @@ ext/tbb ...@@ -48,3 +53,12 @@ ext/tbb
# SWIG wrapper code # SWIG wrapper code
*LUA_wrap.cxx *LUA_wrap.cxx
# CMake build folders and IDE folders
build*/
.vs/
.vscode/
# Mac specific
.DS_Store
# = CAMPVis - Yet another medical visualization framework ===================== # = CAMPVis - Yet another medical visualization framework =====================
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2 FATAL_ERROR)
cmake_policy(SET CMP0020 NEW)
PROJECT(CAMPVis) PROJECT(CAMPVis)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0 FATAL_ERROR)
SET(CAMPVIS_VERSION 1.0.0) SET(CAMPVIS_VERSION 1.0.0)
# = Global Build Options ====================================================== # = Global Build Options ======================================================
OPTION(BUILD_SHARED_LIBS "Build shared libraries (strongly recommended!)" ON) OPTION(BUILD_SHARED_LIBS "Build shared libraries (strongly recommended!)" ON)
OPTION(CAMPVIS_DEBUG "Activate debug code?" ON) OPTION(CAMPVIS_DEBUG "Activate debug code?" ON)
OPTION(CAMPVIS_BUILD_LIB_CGT "Build CGT Library" ON)
OPTION(CAMPVIS_BUILD_APPLICATION "Build CAMPVis Application" ON) OPTION(CAMPVIS_BUILD_APPLICATION "Build CAMPVis Application" ON)
OPTION(CAMPVIS_BUILD_MODULES "Build CAMPVis Modules" ON) OPTION(CAMPVIS_BUILD_MODULES "Build CAMPVis Modules" ON)
OPTION(CAMPVIS_ENABLE_SCRIPTING "Add support for scripting CAMPVis using Lua" OFF) OPTION(CAMPVIS_ENABLE_SCRIPTING "Add support for scripting CAMPVis using Lua" OFF)
...@@ -27,6 +30,10 @@ ENDIF() ...@@ -27,6 +30,10 @@ ENDIF()
SET(CAMPVIS_DEFAULT_ENABLED_MODULES "STABLE_NO_DEPENDENCIES" CACHE STRING "Default CAMPVis modules to activate") SET(CAMPVIS_DEFAULT_ENABLED_MODULES "STABLE_NO_DEPENDENCIES" CACHE STRING "Default CAMPVis modules to activate")
SET_PROPERTY(CACHE CAMPVIS_DEFAULT_ENABLED_MODULES PROPERTY STRINGS "NONE" "STABLE_NO_DEPENDENCIES" "STABLE_WITH_EXTERNAL_DEPENDENCIES" "TESTING" "ALL") SET_PROPERTY(CACHE CAMPVIS_DEFAULT_ENABLED_MODULES PROPERTY STRINGS "NONE" "STABLE_NO_DEPENDENCIES" "STABLE_WITH_EXTERNAL_DEPENDENCIES" "TESTING" "ALL")
IF(NOT BUILD_SHARED_LIBS)
MESSAGE(WARNING "Building shared libraries is turned off. Thus, CAMPVis will most probably not work as intended!\nPlease turn BUILD_SHARED_LIBS on unless you know what you're doing!")
ENDIF(NOT BUILD_SHARED_LIBS)
# propagate CAMPVIS_ENABLE_SCRIPTING to CAMPVIS_BUILD_LIB_LUA to support deprecated code # propagate CAMPVIS_ENABLE_SCRIPTING to CAMPVIS_BUILD_LIB_LUA to support deprecated code
IF (CAMPVIS_ENABLE_SCRIPTING) IF (CAMPVIS_ENABLE_SCRIPTING)
SET(CAMPVIS_BUILD_LIB_LUA ON) SET(CAMPVIS_BUILD_LIB_LUA ON)
...@@ -68,7 +75,7 @@ ENDIF() ...@@ -68,7 +75,7 @@ ENDIF()
# build campvis-test when enabled # build campvis-test when enabled
IF(CAMPVIS_ENABLE_TESTING) IF(CAMPVIS_ENABLE_TESTING)
ADD_SUBDIRECTORY(ext/gtest-1.7.0) ADD_SUBDIRECTORY(ext/googletest-release-1.8.0)
ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(test)
ENDIF() ENDIF()
...@@ -105,15 +112,9 @@ EXPORT(PACKAGE CAMPVis) ...@@ -105,15 +112,9 @@ EXPORT(PACKAGE CAMPVis)
# = Copy Windows DLLs to binary dir for improved development experience ======= # = Copy Windows DLLs to binary dir for improved development experience =======
IF(WIN32) IF(WIN32)
# gather Qt4 DLLs - TODO: remove redundant naming of required components IF(CAMPVIS_COPY_EXTERNAL_DLLS)
FIND_PACKAGE(Qt4DLLs COMPONENTS QtCore QtGui QtOpenGL QtNetwork QtXmlPatterns)
LIST(APPEND CampvisExternalDllsDebug ${QT_DEBUG_DLLS})
LIST(APPEND CampvisExternalDllsRelease ${QT_RELEASE_DLLS})
LIST(REMOVE_DUPLICATES CampvisExternalDllsDebug) LIST(REMOVE_DUPLICATES CampvisExternalDllsDebug)
LIST(REMOVE_DUPLICATES CampvisExternalDllsRelease) LIST(REMOVE_DUPLICATES CampvisExternalDllsRelease)
IF(CAMPVIS_COPY_EXTERNAL_DLLS)
COPY_EXTERNAL_DLLS(CampvisExternalDllsDebug CampvisExternalDllsRelease false) COPY_EXTERNAL_DLLS(CampvisExternalDllsDebug CampvisExternalDllsRelease false)
ENDIF() ENDIF()
ENDIF() ENDIF()
......
PROJECT(campvis-application) PROJECT(campvis-application)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
INCLUDE(../cmake/commonconf.cmake) INCLUDE(../cmake/commonconf.cmake)
MESSAGE(STATUS "Configuring CAMPVis-Application") MESSAGE(STATUS "Configuring CAMPVis-Application")
...@@ -106,13 +105,7 @@ FOREACH(ModFile ${CampvisModulesApplicationToBeMocced}) ...@@ -106,13 +105,7 @@ FOREACH(ModFile ${CampvisModulesApplicationToBeMocced})
LIST(APPEND CampvisApplicationToBeMocced ${ModFileRelative}) LIST(APPEND CampvisApplicationToBeMocced ${ModFileRelative})
ENDFOREACH() ENDFOREACH()
# QT5_WRAP_UI(CampvisApplicationFormsHeaders ${CampvisApplicationForms})
# Qt related stuff:
#
QT4_WRAP_CPP(CampvisApplicationMoc ${CampvisApplicationToBeMocced})
LIST(APPEND CampvisApplicationSources ${CampvisApplicationMoc})
QT4_WRAP_UI(CampvisApplicationFormsHeaders ${CampvisApplicationForms})
LIST(APPEND CampvisApplicationSources ${CampvisApplicationFormsHeaders}) LIST(APPEND CampvisApplicationSources ${CampvisApplicationFormsHeaders})
LINK_DIRECTORIES(${CampvisGlobalLinkDirectories} ${CampvisModulesLinkDirectories}) LINK_DIRECTORIES(${CampvisGlobalLinkDirectories} ${CampvisModulesLinkDirectories})
...@@ -127,14 +120,15 @@ ADD_LIBRARY(campvis-application-lib ...@@ -127,14 +120,15 @@ ADD_LIBRARY(campvis-application-lib
${CampvisApplicationSources} ${CampvisApplicationHeaders} ${CampvisApplicationSources} ${CampvisApplicationHeaders}
${CampvisApplicationMoc} ${CampvisApplicationMoc}
) )
ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${CampvisApplicationDefinitions} ${QT_DEFINITIONS}) ADD_DEFINITIONS(${CampvisGlobalDefinitions} ${CampvisModulesDefinitions} ${CampvisApplicationDefinitions})
INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs}) INCLUDE_DIRECTORIES(${CampvisGlobalIncludeDirs} ${CampvisModulesIncludeDirs})
TARGET_LINK_LIBRARIES(campvis-application-lib ${CampvisMainLibs} ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs} ${QT_LIBRARIES}) TARGET_LINK_LIBRARIES(campvis-application-lib ${CampvisMainLibs} ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs} Qt5::Widgets Qt5::OpenGL)
# if campvis-core is built as a shared library, CMake will define the following flag to instruct # if campvis-core is built as a shared library, CMake will define the following flag to instruct
# the code to export DLL symbols # the code to export DLL symbols
SET_TARGET_PROPERTIES(campvis-application-lib PROPERTIES DEFINE_SYMBOL "CAMPVIS_APPLICATION_BUILD_DLL") SET_TARGET_PROPERTIES(campvis-application-lib PROPERTIES DEFINE_SYMBOL "CAMPVIS_APPLICATION_BUILD_DLL")
IF(CAMPVIS_GROUP_SOURCE_FILES) IF(CAMPVIS_GROUP_SOURCE_FILES)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisApplicationSources ${CampvisHome} "") DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisApplicationSources ${CampvisHome} "")
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisApplicationHeaders ${CampvisHome} "") DEFINE_SOURCE_GROUPS_FROM_SUBDIR(CampvisApplicationHeaders ${CampvisHome} "")
...@@ -144,9 +138,7 @@ INSTALL(TARGETS campvis-application-lib DESTINATION exports EXPORT campvis-targe ...@@ -144,9 +138,7 @@ INSTALL(TARGETS campvis-application-lib DESTINATION exports EXPORT campvis-targe
ADD_EXECUTABLE(campvis-application "campvis.cpp") ADD_EXECUTABLE(campvis-application "campvis.cpp")
TARGET_LINK_LIBRARIES(campvis-application campvis-application-lib ${CampvisMainLibs} ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs} ${QT_LIBRARIES}) TARGET_LINK_LIBRARIES(campvis-application campvis-application-lib ${CampvisMainLibs} ${CampvisGlobalExternalLibs} ${CampvisModulesExternalLibs} Qt5::Widgets Qt5::OpenGL)
IF(CAMPVIS_DEPLOY_SHADERS) IF(CAMPVIS_DEPLOY_SHADERS)
LIST(APPEND CampvisShaderDirectories "application/data") LIST(APPEND CampvisShaderDirectories "application/data")
......
...@@ -46,12 +46,15 @@ ...@@ -46,12 +46,15 @@
#include "core/pipeline/abstractworkflow.h" #include "core/pipeline/abstractworkflow.h"
#include "core/pipeline/pipelinefactory.h" #include "core/pipeline/pipelinefactory.h"
#include "core/pipeline/pipelinepainter.h" #include "core/pipeline/pipelinepainter.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/datastructures/imagerepresentationconverter.h" #include "core/datastructures/imagerepresentationconverter.h"
#include "core/pipeline/visualizationprocessor.h" #include "core/pipeline/visualizationprocessor.h"
#include "tools/qtjobprocessor.h" #include "tools/qtjobprocessor.h"
#include <QApplication> #include <QApplication>
#include <QThread>
#include <QStyleFactory>
#ifdef CAMPVIS_HAS_SCRIPTING #ifdef CAMPVIS_HAS_SCRIPTING
#include "scripting/glue/luavmstate.h" #include "scripting/glue/luavmstate.h"
...@@ -93,12 +96,11 @@ namespace campvis { ...@@ -93,12 +96,11 @@ namespace campvis {
#endif #endif
} }
_localContext = new QtThreadedCanvas("", cgt::ivec2(16, 16)); _localContext = new cgt::QtThreadedCanvas("", cgt::ivec2(16, 16));
campvis::init(_localContext, searchPaths); campvis::init(_localContext, searchPaths);
_mainWindow = new MainWindow(this); _mainWindow = new MainWindow(this);
cgt::GLContextScopedLock lock(_localContext); GLJobProc.enqueueJobBlocking([&]() {
{
_mainWindow->init(); _mainWindow->init();
// load textureData from file // load textureData from file
...@@ -133,7 +135,7 @@ namespace campvis { ...@@ -133,7 +135,7 @@ namespace campvis {
if (! _luaVmState->injectGlobalObjectPointer(this, "campvis::CampVisApplication *", "application")) if (! _luaVmState->injectGlobalObjectPointer(this, "campvis::CampVisApplication *", "application"))
LERROR("Could not inject the pipeline into the Lua VM."); LERROR("Could not inject the pipeline into the Lua VM.");
#endif #endif
} });
// parse argument list and create pipelines // parse argument list and create pipelines
QStringList pipelinesToAdd = this->arguments(); QStringList pipelinesToAdd = this->arguments();
...@@ -171,6 +173,27 @@ namespace campvis { ...@@ -171,6 +173,27 @@ namespace campvis {
} }
} }
// Set Qt color palette to dark - adapted from https://gist.github.com/QuantumCD/6245215
QApplication::setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ButtonText, Qt::white);
darkPalette.setColor(QPalette::BrightText, Qt::red);
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
setPalette(darkPalette);
setStyleSheet("QMainWindow * {font: 12pt;} QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
_initialized = true; _initialized = true;
} }
...@@ -185,10 +208,7 @@ namespace campvis { ...@@ -185,10 +208,7 @@ namespace campvis {
for (auto it = _workflows.begin(); it != _workflows.end(); ++it) for (auto it = _workflows.begin(); it != _workflows.end(); ++it)
(*it)->deinit(); (*it)->deinit();
{ GLJobProc.enqueueJobBlocking([&]() {
// Deinit everything OpenGL related using the local context.
cgt::GLContextScopedLock lock(_localContext);
delete _errorTexture; delete _errorTexture;
// Deinit pipeline and painter first // Deinit pipeline and painter first
...@@ -197,7 +217,9 @@ namespace campvis { ...@@ -197,7 +217,9 @@ namespace campvis {
} }
_mainWindow->deinit(); _mainWindow->deinit();
} });
delete _mainWindow;
// now delete everything in the right order: // now delete everything in the right order:
for (auto it = _pipelines.begin(); it != _pipelines.end(); ++it) { for (auto it = _pipelines.begin(); it != _pipelines.end(); ++it) {
...@@ -254,8 +276,10 @@ namespace campvis { ...@@ -254,8 +276,10 @@ namespace campvis {
#endif #endif
GLCtxtMgr.releaseContext(canvas, false); GLCtxtMgr.releaseContext(canvas, false);
s_PipelinesChanged.emitSignal(); s_PipelinesChanged.emitSignal();
pipeline->start();
startOpenGlThreadAndMoveQtThreadAffinity(pipeline, canvas);
} }
void CampVisApplication::initGlContextAndPipeline(cgt::GLCanvas* canvas, AbstractPipeline* pipeline) { void CampVisApplication::initGlContextAndPipeline(cgt::GLCanvas* canvas, AbstractPipeline* pipeline) {
...@@ -286,7 +310,7 @@ namespace campvis { ...@@ -286,7 +310,7 @@ namespace campvis {
void CampVisApplication::rebuildAllShadersFromFiles() { void CampVisApplication::rebuildAllShadersFromFiles() {
// rebuilding all shaders has to be done from OpenGL context, use the local one. // rebuilding all shaders has to be done from OpenGL context, use the local one.
GLJobProc.enqueueJob(makeJobOnHeap(this, &CampVisApplication::triggerShaderRebuild)); GLJobProc.enqueueJob(cgt::makeJobOnHeap(this, &CampVisApplication::triggerShaderRebuild));
} }
void CampVisApplication::triggerShaderRebuild() { void CampVisApplication::triggerShaderRebuild() {
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
namespace cgt { namespace cgt {
class GLCanvas; class GLCanvas;
class QtCanvas;
class QtThreadedCanvas; class QtThreadedCanvas;
class Texture; class Texture;
} }
...@@ -170,7 +171,7 @@ namespace campvis { ...@@ -170,7 +171,7 @@ namespace campvis {
void triggerShaderRebuild(); void triggerShaderRebuild();
/// A local OpenGL context used for initialization /// A local OpenGL context used for initialization
cgt::GLCanvas* _localContext; cgt::QtCanvas* _localContext;
/// Main window hosting GUI stuff /// Main window hosting GUI stuff
MainWindow* _mainWindow; MainWindow* _mainWindow;
......
...@@ -101,12 +101,17 @@ void main() { ...@@ -101,12 +101,17 @@ void main() {
if (! _renderRChannel) if (! _renderRChannel)
out_Color.r = 0.0; out_Color.r = 0.0;
if (! _renderGChannel) if (! _renderGChannel)
out_Color.g = 0.0; out_Color.g = 0.0;
if (! _renderBChannel) if (! _renderBChannel)
out_Color.b = 0.0; out_Color.b = 0.0;
if (! _renderAChannel) if (! _renderAChannel)
out_Color.a = 1.0; out_Color.a = 1.0;
else if(! _renderRChannel && ! _renderGChannel && ! _renderBChannel)
out_Color = vec4(vec3((abs(out_Color.a) - vec3(_transferFunctionParams._intensityDomain.x)) / (_transferFunctionParams._intensityDomain.y - _transferFunctionParams._intensityDomain.x)), 1);
// mix with fancy checkerboard pattern: // mix with fancy checkerboard pattern:
if ((mod(ex_TexCoord.x * 10.0, 2.0) > 1.0) ^^ (mod(ex_TexCoord.y * 10.0, 2.0) > 1.0)) if ((mod(ex_TexCoord.x * 10.0, 2.0) > 1.0) ^^ (mod(ex_TexCoord.y * 10.0, 2.0) > 1.0))
......
...@@ -45,6 +45,9 @@ namespace campvis { ...@@ -45,6 +45,9 @@ namespace campvis {
} }
DataContainerFileLoaderWidget::~DataContainerFileLoaderWidget() { DataContainerFileLoaderWidget::~DataContainerFileLoaderWidget() {
delete _imgReader;
_imgReader = nullptr;
if (_dataContainer != 0) { if (_dataContainer != 0) {
_dataContainer->s_dataAdded.disconnect(this); _dataContainer->s_dataAdded.disconnect(this);
} }
...@@ -97,14 +100,6 @@ namespace campvis { ...@@ -97,14 +100,6 @@ namespace campvis {
return false; return false;
} }
void DataContainerFileLoaderWidget::init() {
}
void DataContainerFileLoaderWidget::deinit() {
delete _imgReader;
_imgReader = nullptr;
}
void DataContainerFileLoaderWidget::onBtnCancelClicked() { void DataContainerFileLoaderWidget::onBtnCancelClicked() {
delete _imgReader; delete _imgReader;
_imgReader = nullptr; _imgReader = nullptr;
......
...@@ -67,17 +67,6 @@ namespace campvis { ...@@ -67,17 +67,6 @@ namespace campvis {
*/ */
QSize sizeHint() const; QSize sizeHint() const;
/**
* Initializes the OpenGL stuff (e.g. shaders).
* Must be called with a valid and locked OpenGL context.
*/
virtual void init();
/**
* Deinitializes the OpenGL stuff (e.g. shaders).
* Must be called with a valid and locked OpenGL context.
*/
void deinit();
private slots: private slots:
/** /**
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "ext/cgt/navigation/trackball.h" #include "ext/cgt/navigation/trackball.h"
#include <QWindow>
namespace campvis { namespace campvis {
...@@ -70,7 +71,6 @@ namespace campvis { ...@@ -70,7 +71,6 @@ namespace campvis {
static_cast<Geometry1DTransferFunction*>(p_transferFunction.getTF())->addGeometry(TFGeometry1D::createQuad(cgt::vec2(0.f, 1.f), cgt::col4(0, 0, 0, 255), cgt::col4(255, 255, 255, 255))); static_cast<Geometry1DTransferFunction*>(p_transferFunction.getTF())->addGeometry(TFGeometry1D::createQuad(cgt::vec2(0.f, 1.f), cgt::col4(0, 0, 0, 255), cgt::col4(255, 255, 255, 255)));
GLCtxtMgr.registerContextAndInitGlew(this, "DataContainerInspector"); GLCtxtMgr.registerContextAndInitGlew(this, "DataContainerInspector");
GLCtxtMgr.releaseContext(this, false);
addProperty(p_currentSlice); addProperty(p_currentSlice);
addProperty(p_transferFunction); addProperty(p_transferFunction);
...@@ -103,10 +103,13 @@ namespace campvis { ...@@ -103,10 +103,13 @@ namespace campvis {
p_renderGChannel.setVisible(false); p_renderGChannel.setVisible(false);
p_renderBChannel.setVisible(false); p_renderBChannel.setVisible(false);
p_renderAChannel.setVisible(false); p_renderAChannel.setVisible(false);
connect(this, &DataContainerInspectorCanvas::s_invalidated, this, &DataContainerInspectorCanvas::onInvalidated);
init();
}