diff --git a/CMake/BuildConfigurations/All.cmake b/CMake/BuildConfigurations/All.cmake
index 6a3b24125e..2e65fd8460 100644
--- a/CMake/BuildConfigurations/All.cmake
+++ b/CMake/BuildConfigurations/All.cmake
@@ -1,45 +1,44 @@
set(MITK_CONFIG_PACKAGES )
set(_apple_package_excludes)
set(_package_excludes
${_apple_package_excludes}
OpenCL
OpenMP
SYSTEM_Boost
Boost_LIBRARIES
SYSTEM_PYTHON
SUPERBUILD
POLHEMUS_TRACKER
MICROBIRD_TRACKER
MICROBIRD_TRACKER_INCLUDE_DIR
MICROBIRD_TRACKER_LIB
MICRON_TRACKER
OPTITRACK_TRACKER
SPACENAVIGATOR
TOF_KINECT
TOF_KINECTV2
TOF_MESASR4000
TOF_PMDCAMBOARD
TOF_PMDCAMCUBE
TOF_PMDO3
US_TELEMED_SDK
videoInput
- WIIMOTE
)
get_cmake_property(_cache_vars CACHE_VARIABLES)
foreach(_cache_var ${_cache_vars})
string(REGEX REPLACE "MITK_USE_(.+)" "\\1" _package "${_cache_var}")
if(_package AND NOT _package STREQUAL _cache_var)
list(FIND _package_excludes ${_package} _index)
if(_index EQUAL -1)
list(APPEND MITK_CONFIG_PACKAGES ${_package})
endif()
endif()
endforeach()
set(MITK_BUILD_ALL_APPS ON CACHE BOOL "Build all MITK applications" FORCE)
set(MITK_BUILD_ALL_PLUGINS ON CACHE BOOL "Build all MITK plugins" FORCE)
set(MITK_BUILD_EXAMPLES ON CACHE BOOL "Build the MITK examples" FORCE)
set(BLUEBERRY_BUILD_ALL_PLUGINS ON CACHE BOOL "Build all BlueBerry plugins" FORCE)
diff --git a/CMake/BuildConfigurations/Default.cmake b/CMake/BuildConfigurations/Default.cmake
index 700e7efd48..08e48e4bfd 100644
--- a/CMake/BuildConfigurations/Default.cmake
+++ b/CMake/BuildConfigurations/Default.cmake
@@ -1,24 +1,25 @@
set(MITK_CONFIG_PACKAGES
ACVD
Qt5
BLUEBERRY
)
set(MITK_CONFIG_PLUGINS
org.mitk.gui.qt.mitkworkbench.intro
org.mitk.gui.qt.datamanager
org.mitk.gui.qt.stdmultiwidgeteditor
+ org.mitk.gui.qt.mxnmultiwidgeteditor
org.mitk.gui.qt.dicombrowser
org.mitk.gui.qt.imagenavigator
org.mitk.gui.qt.measurementtoolbox
org.mitk.gui.qt.properties
org.mitk.gui.qt.segmentation
org.mitk.gui.qt.volumevisualization
org.mitk.planarfigure
org.mitk.gui.qt.moviemaker
org.mitk.gui.qt.pointsetinteraction
org.mitk.gui.qt.remeshing
org.mitk.gui.qt.viewnavigator
org.mitk.gui.qt.imagecropper
org.mitk.gui.qt.pixelvalue
)
diff --git a/CMake/Whitelists/FlowBenchSegmentation.cmake b/CMake/Whitelists/FlowBenchSegmentation.cmake
index 60c1587601..c0eedb2dfb 100644
--- a/CMake/Whitelists/FlowBenchSegmentation.cmake
+++ b/CMake/Whitelists/FlowBenchSegmentation.cmake
@@ -1,55 +1,54 @@
set(enabled_modules
Core
CppMicroServices
DICOM
DICOMPM
DataTypesExt
AlgorithmsExt
DICOMQI
Multilabel
SceneSerializationBase
DICOMPMIO
DICOMImageIO
ContourModel
DICOMSegIO
LegacyGL
MapperExt
SceneSerialization
LegacyIO
IOExt
MultilabelIO
AppUtil
QtWidgets
QtWidgetsExt
Segmentation
SegmentationUI
PlanarFigure
Annotation
SurfaceInterpolation
GraphAlgorithms
ImageExtraction
ImageStatistics
)
set(enabled_plugins
org.blueberry.core.commands
org.blueberry.core.expressions
org.blueberry.core.runtime
org.blueberry.ui.qt
org.blueberry.ui.qt.help
org.blueberry.ui.qt.log
-org.mitk.core.ext
org.mitk.core.services
org.mitk.gui.common
org.mitk.gui.qt.application
org.mitk.gui.qt.common
org.mitk.gui.qt.datamanager
org.mitk.gui.qt.ext
org.mitk.gui.qt.flow.segmentation
org.mitk.gui.qt.flowapplication
org.mitk.gui.qt.imagenavigator
org.mitk.gui.qt.properties
org.mitk.gui.qt.segmentation
org.mitk.gui.qt.stdmultiwidgeteditor
org.mitk.planarfigure
)
diff --git a/CMake/manifest.xml.in b/CMake/manifest.xml.in
index 0e42726234..09d3679994 100644
--- a/CMake/manifest.xml.in
+++ b/CMake/manifest.xml.in
@@ -1,9 +1,10 @@
UTF-8
+ PerMonitorV2
diff --git a/CMake/mitkFunctionCreateBlueBerryApplication.cmake b/CMake/mitkFunctionCreateBlueBerryApplication.cmake
index ebbcaaade2..f56c9fc100 100644
--- a/CMake/mitkFunctionCreateBlueBerryApplication.cmake
+++ b/CMake/mitkFunctionCreateBlueBerryApplication.cmake
@@ -1,235 +1,235 @@
#!
#! Create a BlueBerry application.
#!
#! \brief This function will create a BlueBerry application together with all
#! necessary provisioning and configuration data and install support.
#!
#! \param NAME (required) The name of the executable.
#! \param DESCRIPTION (optional) A human-readable description of your application.
#! The usage depends on the CPack generator (on Windows, this is a descriptive
#! text for the created shortcuts).
#! \param SOURCES (optional) A list of source files to compile into your executable. Defaults
#! to .cpp.
#! \param PLUGINS (optional) A list of required plug-ins. Defaults to all known plug-ins.
#! \param EXCLUDE_PLUGINS (optional) A list of plug-ins which should not be used. Mainly
#! useful if PLUGINS was not used.
#! \param LINK_LIBRARIES A list of libraries to be linked with the executable.
#! \param LIBRARY_DIRS A list of directories to pass through to MITK_INSTALL_TARGETS
#! \param NO_PROVISIONING (option) Do not create provisioning files.
#! \param NO_INSTALL (option) Do not install this executable
#!
#! Assuming that there exists a file called MyApp.cpp
, an example call looks like:
#! \code
#! mitkFunctionCreateBlueBerryApplication(
#! NAME MyApp
#! DESCRIPTION "MyApp - New ways to explore medical data"
#! EXCLUDE_PLUGINS org.mitk.gui.qt.extapplication
#! )
#! \endcode
#!
function(mitkFunctionCreateBlueBerryApplication)
cmake_parse_arguments(_APP "NO_PROVISIONING;NO_INSTALL" "NAME;DESCRIPTION" "SOURCES;PLUGINS;EXCLUDE_PLUGINS;LINK_LIBRARIES;LIBRARY_DIRS" ${ARGN})
if(NOT _APP_NAME)
message(FATAL_ERROR "NAME argument cannot be empty.")
endif()
if(NOT _APP_SOURCES)
set(_APP_SOURCES ${_APP_NAME}.cpp)
endif()
if(NOT _APP_PLUGINS)
ctkFunctionGetAllPluginTargets(_APP_PLUGINS)
else()
set(_plugins ${_APP_PLUGINS})
set(_APP_PLUGINS)
foreach(_plugin ${_plugins})
string(REPLACE "." "_" _plugin_target ${_plugin})
list(APPEND _APP_PLUGINS ${_plugin_target})
endforeach()
# get all plug-in dependencies
ctkFunctionGetPluginDependencies(_plugin_deps PLUGINS ${_APP_PLUGINS} ALL)
# add the dependencies to the list of application plug-ins
list(APPEND _APP_PLUGINS ${_plugin_deps})
endif()
# -----------------------------------------------------------------------
# Set up include and link dirs for the executable
# -----------------------------------------------------------------------
include_directories(
${org_blueberry_core_runtime_INCLUDE_DIRS}
)
# -----------------------------------------------------------------------
# Add executable icon (Windows)
# -----------------------------------------------------------------------
set(WINDOWS_ICON_RESOURCE_FILE "")
if(WIN32)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc")
set(WINDOWS_ICON_RESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc")
endif()
endif()
# -----------------------------------------------------------------------
# Create the executable and link libraries
# -----------------------------------------------------------------------
set(_app_compile_flags )
if(WIN32)
set(_app_compile_flags "${_app_compile_flags} -DWIN32_LEAN_AND_MEAN")
endif()
if(MITK_SHOW_CONSOLE_WINDOW)
add_executable(${_APP_NAME} MACOSX_BUNDLE ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
else()
add_executable(${_APP_NAME} MACOSX_BUNDLE WIN32 ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
endif()
if(NOT CMAKE_CURRENT_SOURCE_DIR MATCHES "^${CMAKE_SOURCE_DIR}/.*")
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
if("${CMAKE_CURRENT_SOURCE_DIR}/" MATCHES "^${MITK_EXTENSION_DIR}/.*")
get_filename_component(MITK_EXTENSION_ROOT_FOLDER "${MITK_EXTENSION_DIR}" NAME)
set_property(TARGET ${_APP_NAME} PROPERTY FOLDER "${MITK_EXTENSION_ROOT_FOLDER}/Applications")
break()
endif()
endforeach()
else()
set_property(TARGET ${_APP_NAME} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Applications")
endif()
mitk_use_modules(TARGET ${_APP_NAME} MODULES MitkAppUtil)
set_target_properties(${_APP_NAME} PROPERTIES
COMPILE_FLAGS "${_app_compile_flags}")
target_link_libraries(${_APP_NAME} PRIVATE org_blueberry_core_runtime ${_APP_LINK_LIBRARIES})
if(WIN32)
target_link_libraries(${_APP_NAME} PRIVATE ${QT_QTMAIN_LIBRARY})
endif()
-if(WIN32 AND MITK_UTF8)
+if(WIN32)
mitk_add_manifest(${_APP_NAME})
endif()
# -----------------------------------------------------------------------
# Add executable icon and bundle name (Mac)
# -----------------------------------------------------------------------
if(APPLE)
if( _APP_DESCRIPTION)
set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_DESCRIPTION}")
else()
set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_NAME}")
endif()
set(icon_name "icon.icns")
set(icon_full_path "${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon_name}")
if(EXISTS "${icon_full_path}")
set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE "${icon_name}")
file(COPY ${icon_full_path} DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.app/Contents/Resources/")
INSTALL (FILES ${icon_full_path} DESTINATION "${_APP_NAME}.app/Contents/Resources/")
endif()
endif()
# -----------------------------------------------------------------------
# Set build time dependencies
# -----------------------------------------------------------------------
# This ensures that all enabled plug-ins are up-to-date when the
# executable is build.
if(_APP_PLUGINS)
ctkMacroGetAllProjectTargetLibraries("${_APP_PLUGINS}" _project_plugins)
if(_APP_EXCLUDE_PLUGINS AND _project_plugins)
set(_exclude_targets)
foreach(_exclude_plugin ${_APP_EXCLUDE_PLUGINS})
string(REPLACE "." "_" _exclude_target ${_exclude_plugin})
list(APPEND _exclude_targets ${_exclude_target})
endforeach()
list(REMOVE_ITEM _project_plugins ${_exclude_targets})
endif()
if(_project_plugins)
add_dependencies(${_APP_NAME} ${_project_plugins})
endif()
endif()
# -----------------------------------------------------------------------
# Additional files needed for the executable
# -----------------------------------------------------------------------
if(NOT _APP_NO_PROVISIONING)
# Create a provisioning file, listing all plug-ins
set(_prov_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.provisioning")
mitkFunctionCreateProvisioningFile(FILE ${_prov_file}
PLUGINS ${_APP_PLUGINS}
EXCLUDE_PLUGINS ${_APP_EXCLUDE_PLUGINS}
)
endif()
# Create a .ini file for initial parameters
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_APP_NAME}.ini")
configure_file(${_APP_NAME}.ini
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.ini)
endif()
# Create batch and VS user files for Windows platforms
include(mitkFunctionCreateWindowsBatchScript)
if(WIN32)
set(template_name "start${_APP_NAME}.bat.in")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${template_name}")
foreach(BUILD_TYPE debug release)
mitkFunctionCreateWindowsBatchScript(${template_name}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/start${_APP_NAME}_${BUILD_TYPE}.bat
${BUILD_TYPE})
endforeach()
endif()
mitkFunctionConfigureVisualStudioUserProjectFile(
NAME ${_APP_NAME}
)
endif(WIN32)
# -----------------------------------------------------------------------
# Install support
# -----------------------------------------------------------------------
if(NOT _APP_NO_INSTALL)
# This installs all third-party CTK plug-ins
mitkFunctionInstallThirdPartyCTKPlugins(${_APP_PLUGINS} EXCLUDE ${_APP_EXCLUDE_PLUGINS})
if(COMMAND BlueBerryApplicationInstallHook)
set(_real_app_plugins ${_APP_PLUGINS})
if(_APP_EXCLUDE_PLUGINS)
list(REMOVE_ITEM _real_app_plugins ${_APP_EXCLUDE_PLUGINS})
endif()
BlueBerryApplicationInstallHook(APP_NAME ${_APP_NAME} PLUGINS ${_real_app_plugins})
endif()
# Install the executable
MITK_INSTALL_TARGETS(EXECUTABLES ${_APP_NAME} LIBRARY_DIRS ${_APP_LIBRARY_DIRS} GLOB_PLUGINS )
if(NOT _APP_NO_PROVISIONING)
# Install the provisioning file
mitkFunctionInstallProvisioningFiles(${_prov_file})
endif()
# On Linux, create a shell script to start a relocatable application
if(UNIX AND NOT APPLE)
install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME "${_APP_NAME}.sh")
elseif(WIN32)
install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledWin32App.bat" DESTINATION "." RENAME "${_APP_NAME}.bat")
endif()
# Tell cpack the executables that you want in the start menu as links
set(MITK_CPACK_PACKAGE_EXECUTABLES ${MITK_CPACK_PACKAGE_EXECUTABLES} "${_APP_NAME};${_APP_DESCRIPTION}" CACHE INTERNAL "Collecting windows shortcuts to executables")
endif()
endfunction()
function(FunctionCreateBlueBerryApplication)
message(SEND_ERROR "The function FunctionCreateBlueBerryApplication was renamed to mitkFunctionCreateBlueBerryApplication in MITK 2015.05")
endfunction()
diff --git a/CMake/mitkFunctionCreateModule.cmake b/CMake/mitkFunctionCreateModule.cmake
index b0a777b921..df45e5d1bc 100644
--- a/CMake/mitkFunctionCreateModule.cmake
+++ b/CMake/mitkFunctionCreateModule.cmake
@@ -1,647 +1,647 @@
##################################################################
#
# mitk_create_module
#
#! Creates a module for the automatic module dependency system within MITK.
#!
#! Example:
#!
#! \code
#! mitk_create_module(
#! DEPENDS PUBLIC MitkCore
#! PACKAGE_DEPENDS
#! PRIVATE Qt5|Xml+Networking
#! PUBLIC ITK|Watersheds
#! \endcode
#!
#! The parameter specifies the name of the module which is used
#! to create a logical target name. The parameter is optional in case the
#! MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME variable evaluates to TRUE. The
#! module name will then be derived from the directory name in which this
#! function is called.
#!
#! If set, the following variables will be used to validate the module name:
#!
#! MITK_MODULE_NAME_REGEX_MATCH The module name must match this regular expression.
#! MITK_MODULE_NAME_REGEX_NOT_MATCH The module name must not match this regular expression.
#!
#! If the MITK_MODULE_NAME_PREFIX variable is set, the module name will be prefixed
#! with its contents.
#!
#! A modules source files are specified in a separate CMake file usually
#! called files.cmake, located in the module root directory. The
#! mitk_create_module() macro evaluates the following CMake variables
#! from the files.cmake file:
#!
#! - CPP_FILES A list of .cpp files
#! - H_FILES A list of .h files without a corresponding .cpp file
#! - TXX_FILES A list of .txx files
#! - RESOURCE_FILES A list of files (resources) which are embedded into the module
#! - MOC_H_FILES A list of Qt header files which should be processed by the MOC
#! - UI_FILES A list of .ui Qt UI files
#! - QRC_FILES A list of .qrc Qt resource files
#! - DOX_FILES A list of .dox Doxygen files
#!
#! List of variables available after the function is called:
#! - MODULE_NAME
#! - MODULE_TARGET
#! - MODULE_IS_ENABLED
#!
#! \sa mitk_create_executable
#!
#! Parameters (all optional):
#!
#! \param The module name (also used as target name)
#! \param FILES_CMAKE File name of a CMake file setting source list variables
#! (defaults to files.cmake)
#! \param VERSION Module version number, e.g. "1.2.0"
#! \param AUTOLOAD_WITH A module target name identifying the module which will
#! trigger the automatic loading of this module
#! \param DEPRECATED_SINCE Marks this modules as deprecated since
#! \param DESCRIPTION A description for this module
#!
#! Multi-value Parameters (all optional):
#!
#! \param INCLUDE_DIRS Include directories for this module:
#! \verbatim
#! [[PUBLIC|PRIVATE|INTERFACE] ...]...
#! \endverbatim
#! The default scope for include directories is PUBLIC.
#! \param DEPENDS List of module dependencies:
#! \verbatim
#! [[PUBLIC|PRIVATE|INTERFACE] ...]...
#! \endverbatim
#! The default scope for module dependencies is PUBLIC.
#! \param PACKAGE_DEPENDS List of public packages dependencies (e.g. Qt, VTK, etc.).
#! Package dependencies have the following syntax:
#! \verbatim
#! [PUBLIC|PRIVATE|INTERFACE] PACKAGE[|COMPONENT1[+COMPONENT2]...]
#! \endverbatim
#! The default scope for package dependencies is PRIVATE.
#! \param ADDITIONAL_LIBS List of additional private libraries linked to this module.
#! The folder containing the library will be added to the global list of library search paths.
#! \param CPP_FILES List of source files for this module. If the list is non-empty,
#! the module does not need to provide a files.cmake file or FILES_CMAKE argument.
#! \param H_FILES List of public header files for this module. It is recommended to use
#! a files.cmake file instead.
#!
#! Options (optional)
#!
#! \param FORCE_STATIC Force building this module as a static library
#! \param GCC_DEFAULT_VISIBILITY Do not use gcc visibility flags - all
#! symbols will be exported
#! \param NO_INIT Do not create CppMicroServices initialization code
#! \param NO_FEATURE_INFO Do not create a feature info by calling add_feature_info()
#! \param WARNINGS_NO_ERRORS Do not treat compiler warnings as errors
#
##################################################################
function(mitk_create_module)
set(_macro_params
VERSION # module version number, e.g. "1.2.0"
EXPORT_DEFINE # export macro name for public symbols of this module (DEPRECATED)
AUTOLOAD_WITH # a module target name identifying the module which will trigger the
# automatic loading of this module
FILES_CMAKE # file name of a CMake file setting source list variables
# (defaults to files.cmake)
DEPRECATED_SINCE # marks this modules as deprecated
DESCRIPTION # a description for this module
)
set(_macro_multiparams
SUBPROJECTS # list of CDash labels (deprecated)
INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE]
INTERNAL_INCLUDE_DIRS # include dirs internal to this module (DEPRECATED)
DEPENDS # list of modules this module depends on: [PUBLIC|PRIVATE|INTERFACE]
DEPENDS_INTERNAL # list of modules this module internally depends on (DEPRECATED)
PACKAGE_DEPENDS # list of "packages this module depends on (e.g. Qt, VTK, etc.): [PUBLIC|PRIVATE|INTERFACE]
TARGET_DEPENDS # list of CMake targets this module should depend on: [PUBLIC|PRIVATE|INTERFACE]
ADDITIONAL_LIBS # list of addidtional private libraries linked to this module.
CPP_FILES # list of cpp files
H_FILES # list of header files: [PUBLIC|PRIVATE]
)
set(_macro_options
FORCE_STATIC # force building this module as a static library
HEADERS_ONLY # this module is a headers-only library
GCC_DEFAULT_VISIBILITY # do not use gcc visibility flags - all symbols will be exported
NO_DEFAULT_INCLUDE_DIRS # do not add default include directories like "include" or "."
NO_INIT # do not create CppMicroServices initialization code
NO_FEATURE_INFO # do not create a feature info by calling add_feature_info()
WARNINGS_NO_ERRORS # do not treat compiler warnings as errors
EXECUTABLE # create an executable; do not use directly, use mitk_create_executable() instead
C_MODULE # compile all source files as C sources
CXX_MODULE # compile all source files as C++ sources
)
cmake_parse_arguments(MODULE "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN})
set(MODULE_NAME ${MODULE_UNPARSED_ARGUMENTS})
# -----------------------------------------------------------------
# Sanity checks
if(NOT MODULE_NAME)
if(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME)
get_filename_component(MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
else()
message(SEND_ERROR "The module name must not be empty")
endif()
endif()
set(_deprecated_args INTERNAL_INCLUDE_DIRS DEPENDS_INTERNAL EXPORT_DEFINE HEADERS_ONLY)
foreach(_deprecated_arg ${_deprecated_args})
if(MODULE_${_deprecated_arg})
message(WARNING "The ${_deprecated_arg} argument is deprecated")
endif()
endforeach()
set(_module_type module)
set(_Module_type Module)
if(MODULE_EXECUTABLE)
set(_module_type executable)
set(_Module_type Executable)
endif()
if(MITK_MODULE_NAME_REGEX_MATCH)
if(NOT ${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_MATCH})
message(SEND_ERROR "The ${_module_type} name \"${MODULE_NAME}\" does not match the regular expression \"${MITK_MODULE_NAME_REGEX_MATCH}\".")
endif()
endif()
if(MITK_MODULE_NAME_REGEX_NOT_MATCH)
if(${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_NOT_MATCH})
message(SEND_ERROR "The ${_module_type} name \"${MODULE_NAME}\" must not match the regular expression \"${MITK_MODULE_NAME_REGEX_NOT_MATCH}\".")
endif()
endif()
if(MITK_MODULE_NAME_PREFIX AND NOT MODULE_NAME MATCHES "^${MITK_MODULE_NAME_PREFIX}.*$")
set(MODULE_NAME "${MITK_MODULE_NAME_PREFIX}${MODULE_NAME}")
endif()
if(NOT MODULE_FILES_CMAKE)
set(MODULE_FILES_CMAKE files.cmake)
endif()
if(NOT IS_ABSOLUTE ${MODULE_FILES_CMAKE})
set(MODULE_FILES_CMAKE ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILES_CMAKE})
endif()
# -----------------------------------------------------------------
# Check if module should be build
set(MODULE_TARGET ${MODULE_NAME})
# assume worst case
set(MODULE_IS_ENABLED 0)
# first we check if we have an explicit module build list
if(MITK_MODULES_TO_BUILD)
list(FIND MITK_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX)
if(_MOD_INDEX EQUAL -1)
set(MODULE_IS_EXCLUDED 1)
endif()
endif()
if(NOT MODULE_IS_EXCLUDED)
# first of all we check for the dependencies
_mitk_parse_package_args(${MODULE_PACKAGE_DEPENDS})
mitk_check_module_dependencies(MODULES ${MODULE_DEPENDS}
PACKAGES ${PACKAGE_NAMES}
MISSING_DEPENDENCIES_VAR _MISSING_DEP
PACKAGE_DEPENDENCIES_VAR PACKAGE_NAMES)
if(_MISSING_DEP)
if(MODULE_NO_FEATURE_INFO)
message("${_Module_type} ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}")
endif()
set(MODULE_IS_ENABLED 0)
else()
foreach(dep ${MODULE_DEPENDS})
if(TARGET ${dep})
get_target_property(AUTLOAD_DEP ${dep} MITK_AUTOLOAD_DIRECTORY)
if (AUTLOAD_DEP)
message(SEND_ERROR "Module \"${MODULE_NAME}\" has an invalid dependency on autoload module \"${dep}\". Check MITK_CREATE_MODULE usage for \"${MODULE_NAME}\".")
endif()
endif()
endforeach(dep)
set(MODULE_IS_ENABLED 1)
# now check for every package if it is enabled. This overlaps a bit with
# MITK_CHECK_MODULE ...
foreach(_package ${PACKAGE_NAMES})
if((DEFINED MITK_USE_${_package}) AND NOT (MITK_USE_${_package}))
message("${_Module_type} ${MODULE_NAME} won't be built. Turn on MITK_USE_${_package} if you want to use it.")
set(MODULE_IS_ENABLED 0)
break()
endif()
endforeach()
endif()
endif()
# -----------------------------------------------------------------
# Start creating the module
if(MODULE_IS_ENABLED)
# clear variables defined in files.cmake
set(RESOURCE_FILES )
set(CPP_FILES )
set(H_FILES )
set(TXX_FILES )
set(DOX_FILES )
set(UI_FILES )
set(MOC_H_FILES )
set(QRC_FILES )
# clear other variables
set(Q${KITNAME}_GENERATED_CPP )
set(Q${KITNAME}_GENERATED_MOC_CPP )
set(Q${KITNAME}_GENERATED_QRC_CPP )
set(Q${KITNAME}_GENERATED_UI_CPP )
# check and set-up auto-loading
if(MODULE_AUTOLOAD_WITH)
if(NOT TARGET "${MODULE_AUTOLOAD_WITH}")
message(SEND_ERROR "The module target \"${MODULE_AUTOLOAD_WITH}\" specified as the auto-loading module for \"${MODULE_NAME}\" does not exist")
endif()
endif()
set(_module_autoload_meta_target "${CMAKE_PROJECT_NAME}-autoload")
# create a meta-target if it does not already exist
if(NOT TARGET ${_module_autoload_meta_target})
add_custom_target(${_module_autoload_meta_target})
set_property(TARGET ${_module_autoload_meta_target} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Modules/Autoload")
endif()
if(NOT MODULE_EXPORT_DEFINE)
set(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT)
endif()
if(MITK_GENERATE_MODULE_DOT)
message("MODULEDOTNAME ${MODULE_NAME}")
foreach(dep ${MODULE_DEPENDS})
message("MODULEDOT \"${MODULE_NAME}\" -> \"${dep}\" ; ")
endforeach(dep)
endif(MITK_GENERATE_MODULE_DOT)
if (EXISTS ${MODULE_FILES_CMAKE})
include(${MODULE_FILES_CMAKE})
endif()
if(MODULE_CPP_FILES)
list(APPEND CPP_FILES ${MODULE_CPP_FILES})
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src")
# Preprend the "src" directory to the cpp file list
set(_cpp_files ${CPP_FILES})
set(CPP_FILES )
foreach(_cpp_file ${_cpp_files})
list(APPEND CPP_FILES "src/${_cpp_file}")
endforeach()
endif()
if(CPP_FILES OR RESOURCE_FILES OR UI_FILES OR MOC_H_FILES OR QRC_FILES)
set(MODULE_HEADERS_ONLY 0)
if(MODULE_C_MODULE)
set_source_files_properties(${CPP_FILES} PROPERTIES LANGUAGE C)
elseif(MODULE_CXX_MODULE)
set_source_files_properties(${CPP_FILES} PROPERTIES LANGUAGE CXX)
endif()
else()
set(MODULE_HEADERS_ONLY 1)
if(MODULE_AUTOLOAD_WITH)
message(SEND_ERROR "A headers only module cannot be auto-loaded")
endif()
endif()
set(module_c_flags )
set(module_c_flags_debug )
set(module_c_flags_release )
set(module_cxx_flags )
set(module_cxx_flags_debug )
set(module_cxx_flags_release )
if(MODULE_GCC_DEFAULT_VISIBILITY OR NOT CMAKE_COMPILER_IS_GNUCXX)
# We only support hidden visibility for gcc for now. Clang still has troubles with
# correctly marking template declarations and explicit template instantiations as exported.
set(CMAKE_CXX_VISIBILITY_PRESET default)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
else()
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()
if(NOT MODULE_WARNINGS_NO_ERRORS)
if(MSVC_VERSION)
mitkFunctionCheckCAndCXXCompilerFlags("/WX" module_c_flags module_cxx_flags)
# this would turn on unused parameter warnings, but unfortunately MSVC cannot
# distinguish yet between internal and external headers so this would be triggered
# a lot by external code. There is support for it on the way so this line could be
# reactivated after https://gitlab.kitware.com/cmake/cmake/issues/17904 has been fixed.
# mitkFunctionCheckCAndCXXCompilerFlags("/w34100" module_c_flags module_cxx_flags)
else()
mitkFunctionCheckCAndCXXCompilerFlags(-Werror module_c_flags module_cxx_flags)
# The flag "c++0x-static-nonintegral-init" has been renamed in newer Clang
# versions to "static-member-init"
#
# Also, older Clang and seemingly all gcc versions do not warn if unknown
# "-no-*" flags are used, so CMake will happily append any -Wno-* flag to the
# command line. This may get confusing if unrelated compiler errors happen and
# the error output then additionally contains errors about unknown flags (which
# is not the case if there were no compile errors).
#
# So instead of using -Wno-* we use -Wno-error=*, which will be properly rejected by
# the compiler and if applicable, prints the specific warning as a real warning and
# not as an error (although -Werror was given).
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=c++0x-static-nonintegral-init" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=static-member-init" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=unknown-warning" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=gnu" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=class-memaccess" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=inconsistent-missing-override" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=deprecated-copy" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=cast-function-type" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=deprecated-declarations" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=type-limits" module_c_flags module_cxx_flags)
endif()
endif()
if(MODULE_FORCE_STATIC)
set(_STATIC STATIC)
else()
set(_STATIC )
endif(MODULE_FORCE_STATIC)
if(NOT MODULE_HEADERS_ONLY)
if(NOT MODULE_NO_INIT OR RESOURCE_FILES)
find_package(CppMicroServices QUIET NO_MODULE REQUIRED)
endif()
if(NOT MODULE_NO_INIT)
usFunctionGenerateModuleInit(CPP_FILES)
endif()
set(binary_res_files )
set(source_res_files )
if(RESOURCE_FILES)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/resource")
set(res_dir resource)
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Resources")
set(res_dir Resources)
else()
message(SEND_ERROR "Resources specified but ${CMAKE_CURRENT_SOURCE_DIR}/resource directory not found.")
endif()
foreach(res_file ${RESOURCE_FILES})
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${res_dir}/${res_file})
list(APPEND binary_res_files "${res_file}")
else()
list(APPEND source_res_files "${res_file}")
endif()
endforeach()
# Add a source level dependencies on resource files
usFunctionGetResourceSource(TARGET ${MODULE_TARGET} OUT CPP_FILES)
endif()
endif()
if(MITK_USE_Qt5)
if(UI_FILES)
qt5_wrap_ui(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES})
endif()
if(MOC_H_FILES)
qt5_wrap_cpp(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
endif()
if(QRC_FILES)
qt5_add_resources(Q${KITNAME}_GENERATED_QRC_CPP ${QRC_FILES})
endif()
endif()
set(Q${KITNAME}_GENERATED_CPP ${Q${KITNAME}_GENERATED_CPP} ${Q${KITNAME}_GENERATED_UI_CPP} ${Q${KITNAME}_GENERATED_MOC_CPP} ${Q${KITNAME}_GENERATED_QRC_CPP})
mitkFunctionOrganizeSources(
SOURCE ${CPP_FILES}
HEADER ${H_FILES}
TXX ${TXX_FILES}
DOC ${DOX_FILES}
UI ${UI_FILES}
QRC ${QRC_FILES}
MOC ${Q${KITNAME}_GENERATED_MOC_CPP}
GEN_QRC ${Q${KITNAME}_GENERATED_QRC_CPP}
GEN_UI ${Q${KITNAME}_GENERATED_UI_CPP}
)
set(coverage_sources
${CPP_FILES} ${H_FILES} ${GLOBBED__H_FILES} ${CORRESPONDING__H_FILES} ${TXX_FILES}
${TOOL_CPPS} ${TOOL_GUI_CPPS})
# ---------------------------------------------------------------
# Create the actual module target
if(MODULE_HEADERS_ONLY)
add_library(${MODULE_TARGET} INTERFACE)
# INTERFACE_LIBRARY targets may only have whitelisted properties. The property "FOLDER" is not allowed.
# set_property(TARGET ${MODULE_TARGET} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Modules")
else()
if(MODULE_EXECUTABLE)
if(MITK_SHOW_CONSOLE_WINDOW)
set(_SHOW_CONSOLE_OPTION "")
else()
set(_SHOW_CONSOLE_OPTION WIN32)
endif()
add_executable(${MODULE_TARGET} ${_SHOW_CONSOLE_OPTION}
${MODULE_CPP_FILES} ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP}
${DOX_FILES} ${UI_FILES} ${QRC_FILES} ${WINDOWS_ICON_RESOURCE_FILE})
- if(WIN32 AND MITK_UTF8)
+ if(WIN32)
mitk_add_manifest(${MODULE_TARGET})
endif()
set_property(TARGET ${MODULE_TARGET} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Modules/Executables")
set(_us_module_name main)
else()
add_library(${MODULE_TARGET} ${_STATIC}
${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP}
${DOX_FILES} ${UI_FILES} ${QRC_FILES})
set_property(TARGET ${MODULE_TARGET} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Modules")
set(_us_module_name ${MODULE_TARGET})
endif()
# Apply properties to the module target.
target_compile_definitions(${MODULE_TARGET} PRIVATE US_MODULE_NAME=${_us_module_name})
if(MODULE_C_MODULE)
if(module_c_flags)
string(REPLACE " " ";" module_c_flags "${module_c_flags}")
target_compile_options(${MODULE_TARGET} PRIVATE ${module_c_flags})
endif()
if(module_c_flags_debug)
string(REPLACE " " ";" module_c_flags_debug "${module_c_flags_debug}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_c_flags_debug}>)
endif()
if(module_c_flags_release)
string(REPLACE " " ";" module_c_flags_release "${module_c_flags_release}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_c_flags_release}>)
endif()
else()
if(module_cxx_flags)
string(REPLACE " " ";" module_cxx_flags "${module_cxx_flags}")
target_compile_options(${MODULE_TARGET} PRIVATE ${module_cxx_flags})
endif()
if(module_cxx_flags_debug)
string(REPLACE " " ";" module_cxx_flags_debug "${module_cxx_flags_debug}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_cxx_flags_debug}>)
endif()
if(module_cxx_flags_release)
string(REPLACE " " ";" module_cxx_flags_release "${module_cxx_flags_release}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_cxx_flags_release}>)
endif()
endif()
set_property(TARGET ${MODULE_TARGET} PROPERTY US_MODULE_NAME ${_us_module_name})
# Add additional library search directories to a global property which
# can be evaluated by other CMake macros, e.g. our install scripts.
if(MODULE_ADDITIONAL_LIBS)
target_link_libraries(${MODULE_TARGET} PRIVATE ${MODULE_ADDITIONAL_LIBS})
get_property(_mitk_additional_library_search_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
foreach(_lib_filepath ${MODULE_ADDITIONAL_LIBS})
get_filename_component(_search_path "${_lib_filepath}" PATH)
if(_search_path)
list(APPEND _mitk_additional_library_search_paths "${_search_path}")
endif()
endforeach()
if(_mitk_additional_library_search_paths)
list(REMOVE_DUPLICATES _mitk_additional_library_search_paths)
set_property(GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS ${_mitk_additional_library_search_paths})
endif()
endif()
# add the target name to a global property which is used in the top-level
# CMakeLists.txt file to export the target
set_property(GLOBAL APPEND PROPERTY MITK_MODULE_TARGETS ${MODULE_TARGET})
if(MODULE_AUTOLOAD_WITH)
# for auto-loaded modules, adapt the output directory
add_dependencies(${_module_autoload_meta_target} ${MODULE_TARGET})
if(WIN32)
set(_module_output_prop RUNTIME_OUTPUT_DIRECTORY)
else()
set(_module_output_prop LIBRARY_OUTPUT_DIRECTORY)
endif()
set(_module_output_dir ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH})
get_target_property(_module_is_imported ${MODULE_AUTOLOAD_WITH} IMPORTED)
if(NOT _module_is_imported)
# if the auto-loading module is not imported, get its location
# and put the auto-load module relative to it.
get_target_property(_module_output_dir ${MODULE_AUTOLOAD_WITH} ${_module_output_prop})
set_target_properties(${MODULE_TARGET} PROPERTIES
${_module_output_prop} ${_module_output_dir}/${MODULE_AUTOLOAD_WITH})
else()
set_target_properties(${MODULE_TARGET} PROPERTIES
${_module_output_prop} ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH})
endif()
set_target_properties(${MODULE_TARGET} PROPERTIES
MITK_AUTOLOAD_DIRECTORY ${MODULE_AUTOLOAD_WITH})
# add the auto-load module name as a property
set_property(TARGET ${MODULE_AUTOLOAD_WITH} APPEND PROPERTY MITK_AUTOLOAD_TARGETS ${MODULE_TARGET})
endif()
if(binary_res_files)
usFunctionAddResources(TARGET ${MODULE_TARGET}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${res_dir}
FILES ${binary_res_files})
endif()
if(source_res_files)
usFunctionAddResources(TARGET ${MODULE_TARGET}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${res_dir}
FILES ${source_res_files})
endif()
if(binary_res_files OR source_res_files)
usFunctionEmbedResources(TARGET ${MODULE_TARGET})
endif()
if(MODULE_DEPRECATED_SINCE)
set_property(TARGET ${MODULE_TARGET} PROPERTY MITK_MODULE_DEPRECATED_SINCE ${MODULE_DEPRECATED_SINCE})
endif()
# create export macros
if (NOT MODULE_EXECUTABLE)
set(_export_macro_name )
if(MITK_LEGACY_EXPORT_MACRO_NAME)
set(_export_macro_names
EXPORT_MACRO_NAME ${MODULE_EXPORT_DEFINE}
NO_EXPORT_MACRO_NAME ${MODULE_NAME}_NO_EXPORT
DEPRECATED_MACRO_NAME ${MODULE_NAME}_DEPRECATED
NO_DEPRECATED_MACRO_NAME ${MODULE_NAME}_NO_DEPRECATED
)
endif()
generate_export_header(${MODULE_NAME}
${_export_macro_names}
EXPORT_FILE_NAME ${MODULE_NAME}Exports.h
)
endif()
target_include_directories(${MODULE_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
endif()
# ---------------------------------------------------------------
# Properties for both header-only and compiled modules
if(MODULE_HEADERS_ONLY)
set(_module_property_type INTERFACE)
else()
set(_module_property_type PUBLIC)
endif()
if(MODULE_TARGET_DEPENDS)
target_link_libraries(${MODULE_TARGET} ${MODULE_TARGET_DEPENDS})
endif()
set(DEPENDS "${MODULE_DEPENDS}")
if(NOT MODULE_NO_INIT AND NOT MODULE_HEADERS_ONLY)
# Add a CppMicroServices dependency implicitly, since it is
# needed for the generated "module initialization" code.
set(DEPENDS "CppMicroServices;${DEPENDS}")
endif()
if(DEPENDS OR MODULE_PACKAGE_DEPENDS)
mitk_use_modules(TARGET ${MODULE_TARGET}
MODULES ${DEPENDS}
PACKAGES ${MODULE_PACKAGE_DEPENDS}
)
endif()
# add include directories
if(MODULE_INTERNAL_INCLUDE_DIRS)
target_include_directories(${MODULE_TARGET} PRIVATE ${MODULE_INTERNAL_INCLUDE_DIRS})
endif()
if(NOT MODULE_NO_DEFAULT_INCLUDE_DIRS)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(${MODULE_TARGET} ${_module_property_type} include)
else()
target_include_directories(${MODULE_TARGET} ${_module_property_type} .)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(${MODULE_TARGET} PRIVATE src)
endif()
endif()
target_include_directories(${MODULE_TARGET} ${_module_property_type} ${MODULE_INCLUDE_DIRS})
endif()
# -----------------------------------------------------------------
# Record missing dependency information
if(_MISSING_DEP)
if(MODULE_DESCRIPTION)
set(MODULE_DESCRIPTION "${MODULE_DESCRIPTION} (missing dependencies: ${_MISSING_DEP})")
else()
set(MODULE_DESCRIPTION "(missing dependencies: ${_MISSING_DEP})")
endif()
endif()
if(NOT MODULE_NO_FEATURE_INFO)
add_feature_info(${MODULE_NAME} MODULE_IS_ENABLED "${MODULE_DESCRIPTION}")
endif()
set(MODULE_NAME ${MODULE_NAME} PARENT_SCOPE)
set(MODULE_TARGET ${MODULE_TARGET} PARENT_SCOPE)
set(MODULE_IS_ENABLED ${MODULE_IS_ENABLED} PARENT_SCOPE)
endfunction()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88c833336b..b8b1869148 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,1377 +1,1371 @@
#[[ When increasing the minimum required version, check if Boost_ADDITIONAL_VERSIONS
in CMake/PackageDepends/MITK_Boost_Config.cmake can be removed. See the first
long comment in CMakeExternals/Boost.cmake for details. ]]
set(MITK_CMAKE_MINIMUM_REQUIRED_VERSION 3.18)
cmake_minimum_required(VERSION ${MITK_CMAKE_MINIMUM_REQUIRED_VERSION})
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19 AND CMAKE_VERSION VERSION_LESS 3.19.2)
message(FATAL_ERROR "\
CMake v${CMAKE_VERSION} is defective [1]. \
Please either downgrade to v3.18 or upgrade to at least v3.19.2.\n\
[1] https://gitlab.kitware.com/cmake/cmake/-/issues/21529")
endif()
#-----------------------------------------------------------------------------
# Policies
#-----------------------------------------------------------------------------
#[[ T28060
https://cmake.org/cmake/help/v3.18/policy/CMP0091.html
https://cmake.org/cmake/help/v3.18/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html
We pass CMP0091 to all external projects as command-line argument:
-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=OLD
]]
cmake_policy(SET CMP0091 OLD)
#-----------------------------------------------------------------------------
# Superbuild Option - Enabled by default
#-----------------------------------------------------------------------------
option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON)
if(MITK_USE_SUPERBUILD)
project(MITK-superbuild)
set(MITK_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(MITK_BINARY_DIR ${PROJECT_BINARY_DIR})
else()
project(MITK VERSION 2022.10.99)
include_directories(SYSTEM ${MITK_SUPERBUILD_BINARY_DIR})
endif()
#-----------------------------------------------------------------------------
# MITK Extension Feature
#-----------------------------------------------------------------------------
set(MITK_EXTENSION_DIRS "" CACHE STRING "")
unset(MITK_ABSOLUTE_EXTENSION_DIRS)
foreach(MITK_EXTENSION_DIR ${MITK_EXTENSION_DIRS})
get_filename_component(MITK_ABSOLUTE_EXTENSION_DIR "${MITK_EXTENSION_DIR}" ABSOLUTE)
list(APPEND MITK_ABSOLUTE_EXTENSION_DIRS "${MITK_ABSOLUTE_EXTENSION_DIR}")
endforeach()
set(MITK_DIR_PLUS_EXTENSION_DIRS "${MITK_SOURCE_DIR}" ${MITK_ABSOLUTE_EXTENSION_DIRS})
#-----------------------------------------------------------------------------
# Update CMake module path
#-----------------------------------------------------------------------------
set(MITK_CMAKE_DIR ${MITK_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR})
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
set(MITK_CMAKE_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMake")
if(EXISTS "${MITK_CMAKE_EXTENSION_DIR}")
list(APPEND CMAKE_MODULE_PATH "${MITK_CMAKE_EXTENSION_DIR}")
endif()
endforeach()
#-----------------------------------------------------------------------------
# CMake function(s) and macro(s)
#-----------------------------------------------------------------------------
# Standard CMake macros
include(FeatureSummary)
include(CTest)
include(CMakeParseArguments)
include(FindPackageHandleStandardArgs)
# MITK macros
include(mitkFunctionGetGccVersion)
include(mitkFunctionCheckCompilerFlags)
include(mitkFunctionSuppressWarnings) # includes several functions
include(mitkMacroEmptyExternalProject)
include(mitkFunctionEnableBuildConfiguration)
include(mitkFunctionWhitelists)
include(mitkFunctionAddExternalProject)
include(mitkFunctionAddLibrarySearchPaths)
SUPPRESS_VC_DEPRECATED_WARNINGS()
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
#-----------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
else()
set(GCC_VERSION 0)
endif()
set(MITK_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS 0)
set(CMAKE_CXX_STANDARD ${MITK_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED 1)
# This is necessary to avoid problems with compile feature checks.
# CMAKE_CXX_STANDARD seems to only set the -std=c++ flag for targets.
# However, compile flag checks also need to be done with -std=c++.
# The MITK_CXX_FLAG variable is also used for external projects
# build during the MITK super-build.
mitkFunctionCheckCompilerFlags("-std=c++${MITK_CXX_STANDARD}" MITK_CXX${MITK_CXX_STANDARD}_FLAG)
#-----------------------------------------------------------------------------
# Warn if source or build path is too long
#-----------------------------------------------------------------------------
if(WIN32)
set(_src_dir_length_max 50)
set(_bin_dir_length_max 50)
if(MITK_USE_SUPERBUILD)
set(_src_dir_length_max 34) # _src_dir_length_max - strlen(ep/src/ITK-build)
set(_bin_dir_length_max 40) # _bin_dir_length_max - strlen(MITK-build)
endif()
string(LENGTH "${MITK_SOURCE_DIR}" _src_n)
string(LENGTH "${MITK_BINARY_DIR}" _bin_n)
# The warnings should be converted to errors
if(_src_n GREATER _src_dir_length_max)
message(WARNING "MITK source code directory path length is too long (${_src_n} > ${_src_dir_length_max})."
"Please move the MITK source code directory to a directory with a shorter path." )
endif()
if(_bin_n GREATER _bin_dir_length_max)
message(WARNING "MITK build directory path length is too long (${_bin_n} > ${_bin_dir_length_max})."
"Please move the MITK build directory to a directory with a shorter path." )
endif()
endif()
#-----------------------------------------------------------------------------
# Additional MITK Options (also shown during superbuild)
#-----------------------------------------------------------------------------
# -----------------------------------------
# General build options
option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON)
option(WITH_COVERAGE "Enable/Disable coverage" OFF)
option(BUILD_TESTING "Test the project" ON)
option(MITK_FAST_TESTING "Disable long-running tests like packaging" OFF)
option(MITK_XVFB_TESTING "Execute test drivers through xvfb-run" OFF)
option(MITK_BUILD_ALL_APPS "Build all MITK applications" OFF)
option(MITK_BUILD_EXAMPLES "Build the MITK Examples" OFF)
mark_as_advanced(
MITK_XVFB_TESTING
MITK_FAST_TESTING
MITK_BUILD_ALL_APPS
)
#-----------------------------------------------------------------------------
# Set UI testing flags
#-----------------------------------------------------------------------------
if(MITK_XVFB_TESTING)
set(MITK_XVFB_TESTING_COMMAND "xvfb-run" "--auto-servernum" CACHE STRING "Command and options to test through Xvfb")
mark_as_advanced(MITK_XVFB_TESTING_COMMAND)
endif(MITK_XVFB_TESTING)
# -----------------------------------------
# Other options
set(MITK_CUSTOM_REVISION_DESC "" CACHE STRING "Override MITK revision description")
mark_as_advanced(MITK_CUSTOM_REVISION_DESC)
set_property(GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS "")
include(CMakeExternals/ExternalProjectList.cmake)
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
set(MITK_CMAKE_EXTERNALS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMakeExternals")
if(EXISTS "${MITK_CMAKE_EXTERNALS_EXTENSION_DIR}/ExternalProjectList.cmake")
include("${MITK_CMAKE_EXTERNALS_EXTENSION_DIR}/ExternalProjectList.cmake")
endif()
endforeach()
# -----------------------------------------
# Other MITK_USE_* options not related to
# external projects build via the
# MITK superbuild
option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON)
option(MITK_USE_OpenCL "Use OpenCL GPU-Computing library" OFF)
option(MITK_USE_OpenMP "Use OpenMP" OFF)
option(MITK_USE_Python3 "Use Python 3" OFF)
#-----------------------------------------------------------------------------
# Build configurations
#-----------------------------------------------------------------------------
set(_buildConfigs "Custom")
file(GLOB _buildConfigFiles CMake/BuildConfigurations/*.cmake)
foreach(_buildConfigFile ${_buildConfigFiles})
get_filename_component(_buildConfigFile ${_buildConfigFile} NAME_WE)
list(APPEND _buildConfigs ${_buildConfigFile})
endforeach()
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
file(GLOB _extBuildConfigFiles "${MITK_EXTENSION_DIR}/CMake/BuildConfigurations/*.cmake")
foreach(_extBuildConfigFile ${_extBuildConfigFiles})
get_filename_component(_extBuildConfigFile "${_extBuildConfigFile}" NAME_WE)
list(APPEND _buildConfigs "${_extBuildConfigFile}")
endforeach()
list(REMOVE_DUPLICATES _buildConfigs)
endforeach()
set(MITK_BUILD_CONFIGURATION "Custom" CACHE STRING "Use pre-defined MITK configurations")
set_property(CACHE MITK_BUILD_CONFIGURATION PROPERTY STRINGS ${_buildConfigs})
mitkFunctionEnableBuildConfiguration()
mitkFunctionCreateWhitelistPaths(MITK)
mitkFunctionFindWhitelists(MITK)
# -----------------------------------------
# Qt version related variables
option(MITK_USE_Qt5 "Use Qt 5 library" ON)
if(MITK_USE_Qt5)
if(WIN32)
set(MITK_QT5_MINIMUM_VERSION 5.12.9)
else()
set(MITK_QT5_MINIMUM_VERSION 5.12)
endif()
set(MITK_QT5_COMPONENTS Concurrent OpenGL PrintSupport Script Sql Svg Widgets Xml XmlPatterns WebEngineWidgets UiTools Help LinguistTools)
if(APPLE)
list(APPEND MITK_QT5_COMPONENTS DBus)
elseif(UNIX)
list(APPEND MITK_QT5_COMPONENTS X11Extras)
endif()
# Hint at default install locations of Qt
if(NOT Qt5_DIR)
if(MSVC)
set(_dir_candidates "C:/Qt")
if(CMAKE_GENERATOR MATCHES "^Visual Studio [0-9]+ ([0-9]+)")
set(_compilers "msvc${CMAKE_MATCH_1}")
elseif(CMAKE_GENERATOR MATCHES "Ninja")
include(mitkFunctionGetMSVCVersion)
mitkFunctionGetMSVCVersion()
if(VISUAL_STUDIO_PRODUCT_NAME MATCHES "^Visual Studio ([0-9]+)")
set(_compilers "msvc${CMAKE_MATCH_1}")
endif()
endif()
if(_compilers MATCHES "[0-9]+")
if (CMAKE_MATCH_0 EQUAL 2022)
list(APPEND _compilers "msvc2019" "msvc2017") # Binary compatible
elseif (CMAKE_MATCH_0 EQUAL 2019)
list(APPEND _compilers "msvc2017") # Binary compatible
endif()
endif()
else()
set(_dir_candidates ~/Qt)
if(APPLE)
set(_compilers clang)
else()
list(APPEND _dir_candidates /opt/Qt)
set(_compilers gcc)
endif()
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
foreach(_compiler ${_compilers})
list(APPEND _compilers64 "${_compiler}_64")
endforeach()
set(_compilers ${_compilers64})
endif()
foreach(_dir_candidate ${_dir_candidates})
get_filename_component(_dir_candidate ${_dir_candidate} REALPATH)
foreach(_compiler ${_compilers})
set(_glob_expression "${_dir_candidate}/5.*/${_compiler}")
file(GLOB _hints ${_glob_expression})
list(SORT _hints)
list(APPEND MITK_QT5_HINTS ${_hints})
endforeach()
endforeach()
endif()
find_package(Qt5 ${MITK_QT5_MINIMUM_VERSION} COMPONENTS ${MITK_QT5_COMPONENTS} REQUIRED HINTS ${MITK_QT5_HINTS})
endif()
# -----------------------------------------
# Custom dependency logic
if(WIN32 AND Qt5_DIR)
set(_dir_candidate "${Qt5_DIR}/../../../../../Tools/OpenSSL/Win_x64")
get_filename_component(_dir_candidate ${_dir_candidate} ABSOLUTE)
if(EXISTS "${_dir_candidate}")
set(OPENSSL_ROOT_DIR "${_dir_candidate}")
endif()
endif()
find_package(OpenSSL)
option(MITK_USE_SYSTEM_Boost "Use the system Boost" OFF)
set(MITK_USE_Boost_LIBRARIES "" CACHE STRING "A semi-colon separated list of required Boost libraries")
if(MITK_USE_cpprestsdk)
if(NOT OpenSSL_FOUND)
set(openssl_message "Could not find OpenSSL (dependency of C++ REST SDK).\n")
if(UNIX)
if(APPLE)
set(openssl_message "${openssl_message}Please install it using your favorite package management "
"system (i.e. Homebrew or MacPorts).\n")
else()
set(openssl_message "${openssl_message}Please install the dev package of OpenSSL (i.e. libssl-dev).\n")
endif()
else()
set(openssl_message "${openssl_message}Please either install Win32 OpenSSL:\n"
" https://slproweb.com/products/Win32OpenSSL.html\n"
"Or use the Qt Maintenance tool to install:\n"
" Developer and Designer Tools > OpenSSL Toolkit > OpenSSL 64-bit binaries\n")
endif()
set(openssl_message "${openssl_message}If it still cannot be found, you can hint CMake to find OpenSSL by "
"adding/setting the OPENSSL_ROOT_DIR variable to the root directory of an "
"OpenSSL installation. Make sure to clear variables of partly found "
"versions of OpenSSL before, or they will be mixed up.")
message(FATAL_ERROR ${openssl_message})
endif()
list(APPEND MITK_USE_Boost_LIBRARIES date_time regex system)
if(UNIX)
list(APPEND MITK_USE_Boost_LIBRARIES atomic chrono filesystem random thread)
endif()
list(REMOVE_DUPLICATES MITK_USE_Boost_LIBRARIES)
set(MITK_USE_Boost_LIBRARIES ${MITK_USE_Boost_LIBRARIES} CACHE STRING "A semi-colon separated list of required Boost libraries" FORCE)
endif()
if(MITK_USE_Python3)
set(MITK_USE_ZLIB ON CACHE BOOL "" FORCE)
if(APPLE AND CMAKE_FRAMEWORK_PATH AND CMAKE_FRAMEWORK_PATH MATCHES "python3\\.?([0-9]+)")
find_package(Python3 3.${CMAKE_MATCH_1} EXACT REQUIRED COMPONENTS Interpreter Development NumPy)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development NumPy)
endif()
if(WIN32)
string(REPLACE "\\" "/" Python3_STDARCH "${Python3_STDARCH}")
string(REPLACE "\\" "/" Python3_STDLIB "${Python3_STDLIB}")
string(REPLACE "\\" "/" Python3_SITELIB "${Python3_SITELIB}")
endif()
endif()
if(BUILD_TESTING AND NOT MITK_USE_CppUnit)
message("> Forcing MITK_USE_CppUnit to ON because BUILD_TESTING=ON")
set(MITK_USE_CppUnit ON CACHE BOOL "Use CppUnit for unit tests" FORCE)
endif()
if(MITK_USE_BLUEBERRY)
option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF)
mark_as_advanced(MITK_BUILD_ALL_PLUGINS)
if(NOT MITK_USE_CTK)
message("> Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY")
set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE)
endif()
endif()
#-----------------------------------------------------------------------------
# Pixel type multiplexing
#-----------------------------------------------------------------------------
# Customize the default pixel types for multiplex macros
set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES
"int, unsigned int, short, unsigned short, char, unsigned char"
CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros")
set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES
"double, float"
CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros")
set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES
"itk::RGBPixel, itk::RGBAPixel"
CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros")
set(MITK_ACCESSBYITK_DIMENSIONS
"2,3"
CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros")
mark_as_advanced(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES
MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES
MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES
MITK_ACCESSBYITK_DIMENSIONS
)
# consistency checks
if(NOT MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES)
set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES
"int, unsigned int, short, unsigned short, char, unsigned char"
CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES)
set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES
"double, float"
CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES)
set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES
"itk::RGBPixel, itk::RGBAPixel"
CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES)
string(REPLACE "," ";" _integral_types ${MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES})
string(REPLACE "," ";" _floating_types ${MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES})
foreach(_scalar_type ${_integral_types} ${_floating_types})
set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES
"${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}itk::VariableLengthVector<${_scalar_type}>,")
endforeach()
string(LENGTH "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" _length)
math(EXPR _length "${_length} - 1")
string(SUBSTRING "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" 0 ${_length} MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES)
set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES ${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}
CACHE STRING "List of vector pixel types used in AccessByItk and InstantiateAccessFunction macros for itk::VectorImage types" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_DIMENSIONS)
set(MITK_ACCESSBYITK_DIMENSIONS
"2,3"
CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros")
endif()
find_package(Git REQUIRED)
#-----------------------------------------------------------------------------
# Superbuild script
#-----------------------------------------------------------------------------
if(MITK_USE_SUPERBUILD)
include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
# Print configuration summary
message("\n\n")
feature_summary(
DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------"
WHAT ALL)
return()
endif()
#*****************************************************************************
#**************************** END OF SUPERBUILD ****************************
#*****************************************************************************
#-----------------------------------------------------------------------------
# Organize MITK targets in folders
#-----------------------------------------------------------------------------
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(MITK_ROOT_FOLDER "MITK" CACHE STRING "")
mark_as_advanced(MITK_ROOT_FOLDER)
#-----------------------------------------------------------------------------
# CMake function(s) and macro(s)
#-----------------------------------------------------------------------------
include(WriteBasicConfigVersionFile)
include(CheckCXXSourceCompiles)
include(GenerateExportHeader)
include(mitkFunctionAddManifest)
include(mitkFunctionAddCustomModuleTest)
include(mitkFunctionCheckModuleDependencies)
include(mitkFunctionCompileSnippets)
include(mitkFunctionConfigureVisualStudioUserProjectFile)
include(mitkFunctionCreateBlueBerryApplication)
include(mitkFunctionCreateCommandLineApp)
include(mitkFunctionCreateModule)
include(mitkFunctionCreatePlugin)
include(mitkFunctionCreateProvisioningFile)
include(mitkFunctionGetLibrarySearchPaths)
include(mitkFunctionGetVersion)
include(mitkFunctionGetVersionDescription)
include(mitkFunctionInstallAutoLoadModules)
include(mitkFunctionInstallCTKPlugin)
include(mitkFunctionInstallProvisioningFiles)
include(mitkFunctionInstallThirdPartyCTKPlugins)
include(mitkFunctionOrganizeSources)
include(mitkFunctionUseModules)
if( ${MITK_USE_MatchPoint} )
include(mitkFunctionCreateMatchPointDeployedAlgorithm)
endif()
include(mitkMacroConfigureItkPixelTypes)
include(mitkMacroCreateExecutable)
include(mitkMacroCreateModuleTests)
include(mitkMacroGenerateToolsLibrary)
include(mitkMacroGetLinuxDistribution)
include(mitkMacroGetPMDPlatformString)
include(mitkMacroInstall)
include(mitkMacroInstallHelperApp)
include(mitkMacroInstallTargets)
include(mitkMacroMultiplexPicType)
# Deprecated
include(mitkMacroCreateCTKPlugin)
#-----------------------------------------------------------------------------
# Global CMake variables
#-----------------------------------------------------------------------------
if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
# We can't do this yet because the CTK Plugin Framework
# cannot cope with a postfix yet.
#set(CMAKE_DEBUG_POSTFIX d)
endif()
#-----------------------------------------------------------------------------
# Output directories.
#-----------------------------------------------------------------------------
set(_default_LIBRARY_output_dir lib)
set(_default_RUNTIME_output_dir bin)
set(_default_ARCHIVE_output_dir lib)
foreach(type LIBRARY RUNTIME ARCHIVE)
# Make sure the directory exists
if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY
AND NOT EXISTS ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY})
message("Creating directory MITK_CMAKE_${type}_OUTPUT_DIRECTORY: ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}")
file(MAKE_DIRECTORY "${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}")
endif()
if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY)
set(CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY})
else()
set(CMAKE_${type}_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${_default_${type}_output_dir})
set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY})
endif()
set(CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY} CACHE INTERNAL "Output directory for ${type} files.")
mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY)
endforeach()
#-----------------------------------------------------------------------------
# Set MITK specific options and variables (NOT available during superbuild)
#-----------------------------------------------------------------------------
if(OpenSSL_FOUND AND WIN32)
set(MITK_OPENSSL_SSL_DLL "" CACHE FILEPATH "")
set(MITK_OPENSSL_CRYPTO_DLL "" CACHE FILEPATH "")
if(MITK_OPENSSL_SSL_DLL AND EXISTS "${MITK_OPENSSL_SSL_DLL}" AND MITK_OPENSSL_CRYPTO_DLL AND EXISTS "${MITK_OPENSSL_CRYPTO_DLL}")
foreach(config_type ${CMAKE_CONFIGURATION_TYPES})
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${MITK_BINARY_DIR}/bin/${config_type}")
configure_file("${MITK_OPENSSL_SSL_DLL}" "${MITK_BINARY_DIR}/bin/${config_type}/" COPYONLY)
configure_file("${MITK_OPENSSL_CRYPTO_DLL}" "${MITK_BINARY_DIR}/bin/${config_type}/" COPYONLY)
endforeach()
MITK_INSTALL(FILES
"${MITK_OPENSSL_SSL_DLL}"
"${MITK_OPENSSL_CRYPTO_DLL}"
)
endif()
endif()
# Look for optional Doxygen package
find_package(Doxygen)
option(BLUEBERRY_DEBUG_SMARTPOINTER "Enable code for debugging smart pointers" OFF)
mark_as_advanced(BLUEBERRY_DEBUG_SMARTPOINTER)
# Ask the user to show the console window for applications
option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON)
mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW)
-# As of Windows 10 Version 1903 (May 2019 Update), applications can use the UTF-8 code page
-if(WIN32)
- option(MITK_UTF8 "Use UTF-8 code page in MITK applications on Windows" ON)
- mark_as_advanced(MITK_UTF8)
-endif()
-
if(NOT MITK_FAST_TESTING)
if(MITK_CTEST_SCRIPT_MODE STREQUAL "Continuous" OR MITK_CTEST_SCRIPT_MODE STREQUAL "Experimental")
set(MITK_FAST_TESTING ON)
endif()
endif()
if(NOT UNIX)
set(MITK_WIN32_FORCE_STATIC "STATIC" CACHE INTERNAL "Use this variable to always build static libraries on non-unix platforms")
endif()
if(MITK_BUILD_ALL_PLUGINS)
set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL")
endif()
# Configure pixel types used for ITK image access multiplexing
mitkMacroConfigureItkPixelTypes()
# Configure module naming conventions
set(MITK_MODULE_NAME_REGEX_MATCH "^[A-Z].*$")
set(MITK_MODULE_NAME_REGEX_NOT_MATCH "^[Mm][Ii][Tt][Kk].*$")
set(MITK_DEFAULT_MODULE_NAME_PREFIX "Mitk")
set(MITK_MODULE_NAME_PREFIX ${MITK_DEFAULT_MODULE_NAME_PREFIX})
set(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME 1)
#-----------------------------------------------------------------------------
# Get MITK version info
#-----------------------------------------------------------------------------
mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK)
mitkFunctionGetVersionDescription(${MITK_SOURCE_DIR} MITK)
# MITK_VERSION
set(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}")
if(MITK_VERSION_PATCH STREQUAL "99")
set(MITK_VERSION_STRING "${MITK_VERSION_STRING}-${MITK_REVISION_SHORTID}")
endif()
#-----------------------------------------------------------------------------
# Installation preparation
#
# These should be set before any MITK install macros are used
#-----------------------------------------------------------------------------
# on macOS all BlueBerry plugins get copied into every
# application bundle (.app directory) specified here
if(MITK_USE_BLUEBERRY AND APPLE)
foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS})
set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications")
if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake")
set(MITK_APPS "")
include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake")
foreach(mitk_app ${MITK_APPS})
# extract option_name
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 1 option_name)
list(GET target_info_list 0 app_name)
# check if the application is enabled
if(${option_name} OR MITK_BUILD_ALL_APPS)
set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} Mitk${app_name})
endif()
endforeach()
endif()
endforeach()
endif()
#-----------------------------------------------------------------------------
# Set coverage Flags
#-----------------------------------------------------------------------------
if(WITH_COVERAGE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG")
set(COVERAGE_CXX_FLAGS ${coverage_flags})
set(COVERAGE_C_FLAGS ${coverage_flags})
endif()
endif()
#-----------------------------------------------------------------------------
# MITK C/CXX Flags
#-----------------------------------------------------------------------------
set(MITK_C_FLAGS "${COVERAGE_C_FLAGS}")
set(MITK_C_FLAGS_DEBUG )
set(MITK_C_FLAGS_RELEASE )
set(MITK_CXX_FLAGS "${COVERAGE_CXX_FLAGS} ${MITK_CXX${MITK_CXX_STANDARD}_FLAG}")
set(MITK_CXX_FLAGS_DEBUG )
set(MITK_CXX_FLAGS_RELEASE )
set(MITK_EXE_LINKER_FLAGS )
set(MITK_SHARED_LINKER_FLAGS )
if(WIN32)
set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN -DNOMINMAX")
mitkFunctionCheckCompilerFlags("/wd4005" MITK_CXX_FLAGS) # warning C4005: macro redefinition
mitkFunctionCheckCompilerFlags("/wd4231" MITK_CXX_FLAGS) # warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
# the following line should be removed after fixing bug 17637
mitkFunctionCheckCompilerFlags("/wd4316" MITK_CXX_FLAGS) # warning C4316: object alignment on heap
mitkFunctionCheckCompilerFlags("/wd4180" MITK_CXX_FLAGS) # warning C4180: qualifier applied to function type has no meaning
mitkFunctionCheckCompilerFlags("/wd4251" MITK_CXX_FLAGS) # warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
endif()
if(APPLE)
set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -DGL_SILENCE_DEPRECATION") # Apple deprecated OpenGL in macOS 10.14
endif()
if(NOT MSVC_VERSION)
foreach(_flag
-Wall
-Wextra
-Wpointer-arith
-Winvalid-pch
-Wcast-align
-Wwrite-strings
-Wno-error=gnu
-Wno-error=unknown-pragmas
# The strict-overflow warning is generated by ITK template code
-Wno-error=strict-overflow
-Woverloaded-virtual
-Wstrict-null-sentinel
#-Wold-style-cast
#-Wsign-promo
-Wno-deprecated-copy
-Wno-array-bounds
-Wno-cast-function-type
-Wno-maybe-uninitialized
-Wno-error=stringop-overread
-fdiagnostics-show-option
)
mitkFunctionCheckCAndCXXCompilerFlags(${_flag} MITK_C_FLAGS MITK_CXX_FLAGS)
endforeach()
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS)
mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
mitkFunctionCheckCAndCXXCompilerFlags("-fstack-protector-all" MITK_C_FLAGS MITK_CXX_FLAGS)
set(MITK_CXX_FLAGS_RELEASE "-U_FORTIFY_SOURCES -D_FORTIFY_SOURCE=2 ${MITK_CXX_FLAGS_RELEASE}")
endif()
set(MITK_MODULE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS})
set(MITK_EXE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS})
#-----------------------------------------------------------------------------
# MITK Packages
#-----------------------------------------------------------------------------
set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends)
set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR})
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
set(MITK_PACKAGE_DEPENDS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMake/PackageDepends")
if(EXISTS "${MITK_PACKAGE_DEPENDS_EXTENSION_DIR}")
list(APPEND MODULES_PACKAGE_DEPENDS_DIRS "${MITK_PACKAGE_DEPENDS_EXTENSION_DIR}")
endif()
endforeach()
if(NOT MITK_USE_SYSTEM_Boost)
set(Boost_NO_SYSTEM_PATHS 1)
endif()
set(Boost_USE_MULTITHREADED 1)
set(Boost_USE_STATIC_LIBS 0)
set(Boost_USE_STATIC_RUNTIME 0)
set(Boost_ADDITIONAL_VERSIONS 1.74 1.74.0)
# We need this later for a DCMTK workaround
set(_dcmtk_dir_orig ${DCMTK_DIR})
# This property is populated at the top half of this file
get_property(MITK_EXTERNAL_PROJECTS GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS)
foreach(ep ${MITK_EXTERNAL_PROJECTS})
get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE)
get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS)
if(MITK_USE_${ep} AND _package)
if(_components)
find_package(${_package} COMPONENTS ${_components} REQUIRED CONFIG)
else()
# Prefer config mode first because it finds external
# Config.cmake files pointed at by _DIR variables.
# Otherwise, existing Find.cmake files could fail.
if(DEFINED ${_package}_DIR)
#we store the information because it will be overwritten by find_package
#and would get lost for all EPs that use on Find.cmake instead of config
#files.
set(_temp_EP_${_package}_dir ${${_package}_DIR})
endif(DEFINED ${_package}_DIR)
find_package(${_package} QUIET CONFIG)
string(TOUPPER "${_package}" _package_uc)
if(NOT (${_package}_FOUND OR ${_package_uc}_FOUND))
if(DEFINED _temp_EP_${_package}_dir)
set(${_package}_DIR ${_temp_EP_${_package}_dir} CACHE PATH "externaly set dir of the package ${_package}" FORCE)
endif(DEFINED _temp_EP_${_package}_dir)
find_package(${_package} REQUIRED)
endif()
endif()
endif()
endforeach()
# Ensure that the MITK CMake module path comes first
set(CMAKE_MODULE_PATH
${MITK_CMAKE_DIR}
${CMAKE_MODULE_PATH}
)
if(MITK_USE_DCMTK)
if(${_dcmtk_dir_orig} MATCHES "${MITK_EXTERNAL_PROJECT_PREFIX}.*")
# Help our FindDCMTK.cmake script find our super-build DCMTK
set(DCMTK_DIR ${MITK_EXTERNAL_PROJECT_PREFIX})
else()
# Use the original value
set(DCMTK_DIR ${_dcmtk_dir_orig})
endif()
endif()
if(MITK_USE_DCMQI)
# Due to the preferred CONFIG mode in find_package calls above,
# the DCMQIConfig.cmake file is read, which does not provide useful
# package information. We explictly need MODULE mode to find DCMQI.
# Help our FindDCMQI.cmake script find our super-build DCMQI
set(DCMQI_DIR ${MITK_EXTERNAL_PROJECT_PREFIX})
find_package(DCMQI REQUIRED)
endif()
if(MITK_USE_OpenIGTLink)
link_directories(${OpenIGTLink_LIBRARY_DIRS})
endif()
if(MITK_USE_OpenCL)
find_package(OpenCL REQUIRED)
endif()
if(MITK_USE_OpenMP)
find_package(OpenMP REQUIRED COMPONENTS CXX)
else()
find_package(OpenMP QUIET COMPONENTS CXX)
if(OpenMP_FOUND)
set(MITK_USE_OpenMP ON CACHE BOOL "" FORCE)
elseif(APPLE AND OpenMP_libomp_LIBRARY AND NOT OpenMP_CXX_LIB_NAMES)
set(OpenMP_CXX_LIB_NAMES libomp CACHE STRING "" FORCE)
get_filename_component(openmp_lib_dir "${OpenMP_libomp_LIBRARY}" DIRECTORY)
set(openmp_include_dir "${openmp_lib_dir}/../include")
if(EXISTS "${openmp_include_dir}")
get_filename_component(openmp_include_dir "${openmp_include_dir}" REALPATH)
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${openmp_include_dir}" CACHE STRING "" FORCE)
find_package(OpenMP QUIET COMPONENTS CXX)
if(OpenMP_FOUND)
set(MITK_USE_OpenMP ON CACHE BOOL "" FORCE)
endif()
endif()
endif()
endif()
# Qt support
if(MITK_USE_Qt5)
find_package(Qt5Core ${MITK_QT5_MINIMUM_VERSION} REQUIRED) # at least Core required
get_target_property(_qmake_exec Qt5::qmake LOCATION)
execute_process(COMMAND ${_qmake_exec} -query QT_INSTALL_BINS
RESULT_VARIABLE _result
OUTPUT_VARIABLE QT_BINARY_DIR
ERROR_VARIABLE _error
)
string(STRIP "${QT_BINARY_DIR}" QT_BINARY_DIR)
if(_result OR NOT EXISTS "${QT_BINARY_DIR}")
message(FATAL_ERROR "Could not determine Qt binary directory: ${_result} ${QT_BINARY_DIR} ${_error}")
endif()
find_program(QT_HELPGENERATOR_EXECUTABLE
NAMES qhelpgenerator qhelpgenerator-qt5 qhelpgenerator5
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_COLLECTIONGENERATOR_EXECUTABLE
NAMES qcollectiongenerator qcollectiongenerator-qt5 qcollectiongenerator5
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_ASSISTANT_EXECUTABLE
NAMES assistant assistant-qt5 assistant5
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_XMLPATTERNS_EXECUTABLE
NAMES xmlpatterns
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
mark_as_advanced(QT_HELPGENERATOR_EXECUTABLE
QT_COLLECTIONGENERATOR_EXECUTABLE
QT_ASSISTANT_EXECUTABLE
QT_XMLPATTERNS_EXECUTABLE
)
if(MITK_USE_BLUEBERRY)
option(BLUEBERRY_USE_QT_HELP "Enable support for integrating plugin documentation into Qt Help" ${DOXYGEN_FOUND})
mark_as_advanced(BLUEBERRY_USE_QT_HELP)
# Sanity checks for in-application BlueBerry plug-in help generation
if(BLUEBERRY_USE_QT_HELP)
set(_force_blueberry_use_qt_help_to_off 0)
if(NOT DOXYGEN_FOUND)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen was not found.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_LESS 1.8.7)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen version 1.8.7 or newer not found.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(NOT QT_HELPGENERATOR_EXECUTABLE)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because QT_HELPGENERATOR_EXECUTABLE is empty.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(NOT MITK_USE_Qt5)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because MITK_USE_Qt5 is OFF.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(NOT QT_XMLPATTERNS_EXECUTABLE)
message("You have enabled Qt Help support, but QT_XMLPATTERNS_EXECUTABLE is empty")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(_force_blueberry_use_qt_help_to_off)
set(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating plugin documentation into Qt Help" FORCE)
endif()
endif()
if(BLUEBERRY_QT_HELP_REQUIRED AND NOT BLUEBERRY_USE_QT_HELP)
message(FATAL_ERROR "BLUEBERRY_USE_QT_HELP is required to be set to ON")
endif()
endif()
endif()
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
if(BUILD_TESTING)
# Configuration for the CMake-generated test driver
set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ")
set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
try
{")
set(CMAKE_TESTDRIVER_AFTER_TESTMAIN "
}
catch (const std::exception& e)
{
fprintf(stderr, \"%s\\n\", e.what());
return EXIT_FAILURE;
}
catch (...)
{
printf(\"Exception caught in the test driver\\n\");
return EXIT_FAILURE;
}")
set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output")
if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR})
file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR})
endif()
# Test the package target
include(mitkPackageTest)
endif()
configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h)
#-----------------------------------------------------------------------------
# MITK_SUPERBUILD_BINARY_DIR
#-----------------------------------------------------------------------------
# If MITK_SUPERBUILD_BINARY_DIR isn't defined, it means MITK is *NOT* build using Superbuild.
# In that specific case, MITK_SUPERBUILD_BINARY_DIR should default to MITK_BINARY_DIR
if(NOT DEFINED MITK_SUPERBUILD_BINARY_DIR)
set(MITK_SUPERBUILD_BINARY_DIR ${MITK_BINARY_DIR})
endif()
#-----------------------------------------------------------------------------
# Set C/CXX and linker flags for MITK code
#-----------------------------------------------------------------------------
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MITK_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MITK_CXX_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MITK_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${MITK_C_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MITK_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MITK_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${MITK_MODULE_LINKER_FLAGS}")
#-----------------------------------------------------------------------------
# Add subdirectories
#-----------------------------------------------------------------------------
add_subdirectory(Utilities)
add_subdirectory(Modules)
include("${CMAKE_CURRENT_SOURCE_DIR}/Modules/ModuleList.cmake")
mitkFunctionWhitelistModules(MITK MITK_MODULES)
set(MITK_ROOT_FOLDER_BACKUP "${MITK_ROOT_FOLDER}")
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
get_filename_component(MITK_ROOT_FOLDER "${MITK_EXTENSION_DIR}" NAME)
set(MITK_MODULES_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Modules")
if(EXISTS "${MITK_MODULES_EXTENSION_DIR}/ModuleList.cmake")
set(MITK_MODULES "")
include("${MITK_MODULES_EXTENSION_DIR}/ModuleList.cmake")
foreach(mitk_module ${MITK_MODULES})
add_subdirectory("${MITK_MODULES_EXTENSION_DIR}/${mitk_module}" "Modules/${mitk_module}")
endforeach()
endif()
set(MITK_MODULE_NAME_PREFIX ${MITK_DEFAULT_MODULE_NAME_PREFIX})
endforeach()
set(MITK_ROOT_FOLDER "${MITK_ROOT_FOLDER_BACKUP}")
add_subdirectory(Wrapping)
set(MITK_DOXYGEN_OUTPUT_DIR "${PROJECT_BINARY_DIR}/Documentation/Doxygen" CACHE PATH
"Output directory for doxygen generated documentation.")
if(MITK_USE_BLUEBERRY)
include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake")
mitkFunctionWhitelistPlugins(MITK MITK_PLUGINS)
set(mitk_plugins_fullpath "")
foreach(mitk_plugin ${MITK_PLUGINS})
list(APPEND mitk_plugins_fullpath Plugins/${mitk_plugin})
endforeach()
set(MITK_PLUGIN_REGEX_LIST "")
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
set(MITK_PLUGINS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Plugins")
if(EXISTS "${MITK_PLUGINS_EXTENSION_DIR}/PluginList.cmake")
set(MITK_PLUGINS "")
include("${MITK_PLUGINS_EXTENSION_DIR}/PluginList.cmake")
foreach(mitk_plugin ${MITK_PLUGINS})
list(APPEND mitk_plugins_fullpath "${MITK_PLUGINS_EXTENSION_DIR}/${mitk_plugin}")
endforeach()
endif()
endforeach()
if(EXISTS ${MITK_PRIVATE_MODULES}/PluginList.cmake)
include(${MITK_PRIVATE_MODULES}/PluginList.cmake)
foreach(mitk_plugin ${MITK_PRIVATE_PLUGINS})
list(APPEND mitk_plugins_fullpath ${MITK_PRIVATE_MODULES}/${mitk_plugin})
endforeach()
endif()
if(MITK_BUILD_EXAMPLES)
include("${CMAKE_CURRENT_SOURCE_DIR}/Examples/Plugins/PluginList.cmake")
set(mitk_example_plugins_fullpath )
foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS})
list(APPEND mitk_example_plugins_fullpath Examples/Plugins/${mitk_example_plugin})
list(APPEND mitk_plugins_fullpath Examples/Plugins/${mitk_example_plugin})
endforeach()
endif()
# Specify which plug-ins belong to this project
macro(GetMyTargetLibraries all_target_libraries varname)
set(re_ctkplugin_mitk "^org_mitk_[a-zA-Z0-9_]+$")
set(re_ctkplugin_bb "^org_blueberry_[a-zA-Z0-9_]+$")
set(_tmp_list)
list(APPEND _tmp_list ${all_target_libraries})
ctkMacroListFilter(_tmp_list re_ctkplugin_mitk re_ctkplugin_bb MITK_PLUGIN_REGEX_LIST OUTPUT_VARIABLE ${varname})
endmacro()
# Get infos about application directories and build options
set(mitk_apps_fullpath "")
foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS})
set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications")
if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake")
set(MITK_APPS "")
include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake")
foreach(mitk_app ${MITK_APPS})
# extract option_name
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 0 directory_name)
list(GET target_info_list 1 option_name)
if(${option_name})
list(APPEND mitk_apps_fullpath "${MITK_APPLICATIONS_EXTENSION_DIR}/${directory_name}^^${option_name}")
endif()
endforeach()
endif()
endforeach()
if (mitk_plugins_fullpath)
ctkMacroSetupPlugins(${mitk_plugins_fullpath}
BUILD_OPTION_PREFIX MITK_BUILD_
APPS ${mitk_apps_fullpath}
BUILD_ALL ${MITK_BUILD_ALL_PLUGINS}
COMPACT_OPTIONS)
endif()
set(MITK_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkPluginUseFile.cmake")
if(${PROJECT_NAME}_PLUGIN_LIBRARIES)
ctkFunctionGeneratePluginUseFile(${MITK_PLUGIN_USE_FILE})
else()
file(REMOVE ${MITK_PLUGIN_USE_FILE})
set(MITK_PLUGIN_USE_FILE )
endif()
endif()
#-----------------------------------------------------------------------------
# Documentation
#-----------------------------------------------------------------------------
set(MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS)
set(MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS)
foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS})
set(MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS "${MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS} \"${MITK_EXTENSION_DIR}\"")
set(MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS "${MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS} \"${MITK_EXTENSION_DIR}\"")
endforeach()
if(DOXYGEN_FOUND)
add_subdirectory(Documentation)
endif()
#-----------------------------------------------------------------------------
# Installation
#-----------------------------------------------------------------------------
# set MITK cpack variables
# These are the default variables, which can be overwritten ( see below )
include(mitkSetupCPack)
set(use_default_config ON)
set(ALL_MITK_APPS "")
set(activated_apps_no 0)
foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS})
set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications")
if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake")
set(MITK_APPS "")
include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake")
foreach(mitk_app ${MITK_APPS})
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 0 directory_name)
list(GET target_info_list 1 option_name)
list(GET target_info_list 2 executable_name)
list(APPEND ALL_MITK_APPS "${MITK_EXTENSION_DIR}/Applications/${directory_name}^^${option_name}^^${executable_name}")
if(${option_name} OR MITK_BUILD_ALL_APPS)
MATH(EXPR activated_apps_no "${activated_apps_no} + 1")
endif()
endforeach()
endif()
endforeach()
list(LENGTH ALL_MITK_APPS app_count)
if(app_count EQUAL 1 AND (activated_apps_no EQUAL 1 OR MITK_BUILD_ALL_APPS))
# Corner case if there is only one app in total
set(use_project_cpack ON)
elseif(activated_apps_no EQUAL 1 AND NOT MITK_BUILD_ALL_APPS)
# Only one app is enabled (no "build all" flag set)
set(use_project_cpack ON)
else()
# Less or more then one app is enabled
set(use_project_cpack OFF)
endif()
foreach(mitk_app ${ALL_MITK_APPS})
# extract target_dir and option_name
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 0 target_dir)
list(GET target_info_list 1 option_name)
list(GET target_info_list 2 executable_name)
# check if the application is enabled
if(${option_name} OR MITK_BUILD_ALL_APPS)
# check whether application specific configuration files will be used
if(use_project_cpack)
# use files if they exist
if(EXISTS "${target_dir}/CPackOptions.cmake")
include("${target_dir}/CPackOptions.cmake")
endif()
if(EXISTS "${target_dir}/CPackConfig.cmake.in")
set(CPACK_PROJECT_CONFIG_FILE "${target_dir}/CPackConfig.cmake")
configure_file(${target_dir}/CPackConfig.cmake.in
${CPACK_PROJECT_CONFIG_FILE} @ONLY)
set(use_default_config OFF)
endif()
endif()
# add link to the list
list(APPEND CPACK_CREATE_DESKTOP_LINKS "${executable_name}")
endif()
endforeach()
# if no application specific configuration file was used, use default
if(use_default_config)
configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in
${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY)
set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake")
endif()
# include CPack model once all variables are set
include(CPack)
# Additional installation rules
include(mitkInstallRules)
#-----------------------------------------------------------------------------
# Last configuration steps
#-----------------------------------------------------------------------------
# ---------------- Export targets -----------------
set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake")
file(REMOVE ${MITK_EXPORTS_FILE})
set(targets_to_export)
get_property(module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS)
if(module_targets)
list(APPEND targets_to_export ${module_targets})
endif()
if(MITK_USE_BLUEBERRY)
if(MITK_PLUGIN_LIBRARIES)
list(APPEND targets_to_export ${MITK_PLUGIN_LIBRARIES})
endif()
endif()
export(TARGETS ${targets_to_export} APPEND
FILE ${MITK_EXPORTS_FILE})
set(MITK_EXPORTED_TARGET_PROPERTIES )
foreach(target_to_export ${targets_to_export})
get_target_property(autoload_targets ${target_to_export} MITK_AUTOLOAD_TARGETS)
if(autoload_targets)
set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES}
set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_TARGETS \"${autoload_targets}\")")
endif()
get_target_property(autoload_dir ${target_to_export} MITK_AUTOLOAD_DIRECTORY)
if(autoload_dir)
set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES}
set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_DIRECTORY \"${autoload_dir}\")")
endif()
get_target_property(deprecated_module ${target_to_export} MITK_MODULE_DEPRECATED_SINCE)
if(deprecated_module)
set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES}
set_target_properties(${target_to_export} PROPERTIES MITK_MODULE_DEPRECATED_SINCE \"${deprecated_module}\")")
endif()
endforeach()
# ---------------- External projects -----------------
get_property(MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
set(MITK_CONFIG_EXTERNAL_PROJECTS )
#string(REPLACE "^^" ";" _mitk_external_projects ${MITK_EXTERNAL_PROJECTS})
foreach(ep ${MITK_EXTERNAL_PROJECTS})
get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS)
set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS}
set(MITK_USE_${ep} ${MITK_USE_${ep}})
set(MITK_${ep}_DIR \"${${ep}_DIR}\")
set(MITK_${ep}_COMPONENTS ${_components})
")
endforeach()
foreach(ep ${MITK_EXTERNAL_PROJECTS})
get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE)
get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS)
if(_components)
set(_components_arg COMPONENTS \${_components})
else()
set(_components_arg)
endif()
if(_package)
set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS}
if(MITK_USE_${ep})
set(${ep}_DIR \${MITK_${ep}_DIR})
if(MITK_${ep}_COMPONENTS)
mitkMacroFindDependency(${_package} COMPONENTS \${MITK_${ep}_COMPONENTS})
else()
mitkMacroFindDependency(${_package})
endif()
endif()")
endif()
endforeach()
# ---------------- Tools -----------------
configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in
${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY)
configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in
${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY)
configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in
${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY)
# ---------------- Configure files -----------------
configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h)
configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h)
set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc)
set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities)
configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h)
configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY)
write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${MITK_VERSION_STRING} COMPATIBILITY AnyNewerVersion)
#-----------------------------------------------------------------------------
# MITK Applications
#-----------------------------------------------------------------------------
# This must come after MITKConfig.h was generated, since applications
# might do a find_package(MITK REQUIRED).
add_subdirectory(Applications)
if(MSVC AND TARGET MitkWorkbench)
set_directory_properties(PROPERTIES VS_STARTUP_PROJECT MitkWorkbench)
endif()
foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications")
if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/CMakeLists.txt")
add_subdirectory("${MITK_APPLICATIONS_EXTENSION_DIR}" "Applications")
endif()
endforeach()
#-----------------------------------------------------------------------------
# MITK Examples
#-----------------------------------------------------------------------------
if(MITK_BUILD_EXAMPLES)
# This must come after MITKConfig.h was generated, since applications
# might do a find_package(MITK REQUIRED).
add_subdirectory(Examples)
endif()
#-----------------------------------------------------------------------------
# Print configuration summary
#-----------------------------------------------------------------------------
message("\n\n")
feature_summary(
DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------"
WHAT ALL
)
diff --git a/Documentation/Doxygen/2-UserManual/MITKPluginManualsList.dox b/Documentation/Doxygen/2-UserManual/MITKPluginManualsList.dox
index 83731979d3..d6bd479bdc 100644
--- a/Documentation/Doxygen/2-UserManual/MITKPluginManualsList.dox
+++ b/Documentation/Doxygen/2-UserManual/MITKPluginManualsList.dox
@@ -1,70 +1,76 @@
/**
\page PluginListPage MITK Plugin Manuals
The plugins and bundles provide much of the extended functionality of MITK. Each encapsulates a solution to a problem and associated features. This way one can easily assemble the necessary capabilites for a workflow without adding a lot of bloat, by combining plugins as needed.
- \subpage org_mitk_views_basicimageprocessing
- \subpage org_mitk_views_datamanager
- \subpage org_mitk_editors_dicombrowser
- \subpage org_mitk_views_dicominspector
- \subpage org_mitk_views_imagecropper
- \subpage org_mitk_views_imagenavigator
- \subpage org_mitk_views_pixelvalue
- \subpage org_blueberry_views_logview
- \subpage org_mitk_views_matchpoint_algorithm_browser
- \subpage org_mitk_views_matchpoint_algorithm_control
- \subpage org_mitk_views_matchpoint_evaluator
- \subpage org_mitk_views_matchpoint_framereg
- \subpage org_mitk_views_matchpoint_manipulator
- \subpage org_mitk_views_matchpoint_mapper
- \subpage org_mitk_views_matchpoint_visualizer
- \subpage org_mitk_gui_qt_measurementtoolbox
- \subpage org_mitk_views_measurement
- \subpage org_mitk_views_imagestatistics
- \subpage org_mitk_views_moviemaker
- \subpage org_mitk_views_pointsetinteraction
- \subpage org_mitk_views_python
- \subpage org_mitk_views_remeshing
- \subpage org_mitk_views_screenshotmaker
- - \subpage org_mitk_views_segmentation
+ - Segmentation
+
+ - \subpage org_mitk_views_segmentation
+ - \subpage org_mitk_views_segmentationutilities
+ - \subpage org_mitk_views_segmentationtasklist
+
+
- \subpage org_mitk_editors_stdmultiwidget
- \subpage org_mitk_editors_mxnmultiwidget
- \subpage org_mitk_views_deformableclippingplane
- \subpage org_mitk_views_viewnavigator
- \subpage org_mitk_views_volumevisualization
- \subpage org_mitk_views_properties
- \subpage org_mitk_gui_qt_flowapplication
- \subpage org_mitk_gui_qt_flow_segmentation
- \subpage org_mitk_gui_qt_aicpregistration
- \subpage org_mitk_gui_qt_cest
- \subpage org_mitk_gui_qt_classificationsegmentation
- \subpage org_mitk_views_cmdlinemodules
- \subpage org_mitk_views_pharmacokinetics_concentration_mri
- \subpage org_mitk_views_pharmacokinetics_mri
- \subpage org_mitk_views_pharmacokinetics_pet
- \subpage org_mitk_gui_qt_examples
- \subpage org_mitk_gui_qt_geometrytools
- \subpage org_mitk_gui_qt_igtexample
- \subpage org_mitk_gui_qt_igttracking
- \subpage org_mitk_views_igttrackingsemiautomaticmeasurement
- \subpage org_mitk_views_fit_demo
- \subpage org_mitk_views_fit_genericfitting
- \subpage org_mitk_views_fit_inspector
- \subpage org_mitkexamplesopencv
- \subpage org_mitk_gui_qt_overlaymanager
- \subpage org_mitk_gui_qt_mitkphenotyping
- \subpage org_mitk_gui_qt_preprocessing_resampling
- \subpage org_mitk_views_pharmacokinetics_curvedescriptor
- \subpage org_mitk_views_pharmacokinetics_simulation
- \subpage org_surfacematerialeditor
- \subpage org_toftutorial
- \subpage org_blueberry_ui_qt_objectinspector
- \subpage org_mitk_gui_qt_ultrasound
- \subpage org_mitk_gui_qt_xnat
*/
diff --git a/Documentation/Doxygen/3-DeveloperManual/Application/DevelopmentApplication.dox b/Documentation/Doxygen/3-DeveloperManual/Application/DevelopmentApplication.dox
index baf97ed86f..587d9c2803 100644
--- a/Documentation/Doxygen/3-DeveloperManual/Application/DevelopmentApplication.dox
+++ b/Documentation/Doxygen/3-DeveloperManual/Application/DevelopmentApplication.dox
@@ -1,27 +1,22 @@
/**
\page DevelopmentApplication Developing with the MITK Application Framework
MITK offers a powerful application featuring a plugin system and many
predefined plugins. You can configure this application to offer a set of
functionality to the user and easily create an installer.
Working with the application, you will have to learn about extension
points and the Blueberry framework itself. If you are new to the matter,
please also consult \ref Architecture and \ref FirstSteps.
- \subpage BlueBerryIntro
- \subpage BlueBerryExamples
The BlueBerry framework extension-point reference is available here:
- \subpage BlueBerryExtPointsIndex
-
-The MITK application extension-point reference is available here:
-
- - \subpage mitkExtPointsIndex
-
*/
diff --git a/Documentation/Doxygen/3-DeveloperManual/Application/ExtensionPointReference.dox b/Documentation/Doxygen/3-DeveloperManual/Application/ExtensionPointReference.dox
deleted file mode 100644
index e324ea7885..0000000000
--- a/Documentation/Doxygen/3-DeveloperManual/Application/ExtensionPointReference.dox
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
-
-\page mitkExtPointsIndex MITK Extension-Point Reference
-
-- \subpage mitkExtPointsIndex_InputDevices
-
-\page mitkExtPointsIndex_InputDevices Input Devices
-
-\tableofcontents
-
-\section mitkExtPointsIndex_InputDevices_Identifier Identifier
-
-\c org.mitk.core.ext.inputdevices
-
-\section mitkExtPointsIndex_InputDevices_Description Description
-
-This extension point is used to define additional input devices.
-
-\section mitkExtPointsIndex_InputDevices_ConfigurationMarkup Configuration Markup
-
-\code{.unparsed}
-
-
-\endcode
-
-- point: a fully qualified identifier of the target extension point
-- id: an optional identifier of the extension instance
-- name: an optional name of the extension instance
-
-\code{.unparsed}
-
-
-\endcode
-
-- id: the identifier of the input device
-- name: an optional name of the input device
-- class: a fully qualified name of the class that implements mitk::IInputDevice.
-
-\code{.unparsed}
-
-\endcode
-
-An optional subelement whose body should contain text providing a short description of the input device.
-
-\section mitkExtPointsIndex_InputDevices_Examples Examples
-
-\code{.unparsed}
-
-
- My new 20-dimensional input device
-
-
-\endcode
-
-*/
diff --git a/Documentation/Doxygen/3-DeveloperManual/DeveloperManualPortal.dox b/Documentation/Doxygen/3-DeveloperManual/DeveloperManualPortal.dox
index 678ce379c8..8ab74c6556 100644
--- a/Documentation/Doxygen/3-DeveloperManual/DeveloperManualPortal.dox
+++ b/Documentation/Doxygen/3-DeveloperManual/DeveloperManualPortal.dox
@@ -1,31 +1,28 @@
/**
\developersguidemainpage{DeveloperManualPortal} Developer Manual
Development with MITK can happen under several conditions. Depending on whether you are using the Toolkit or the entire application, different sections may apply to you.
In case you are unsure about what you need, please refer to \link Architecture The Architecture of MITK text\endlink.
An extensive Introduction to MITK is available under \link StartingDevelopment Starting your MITK Development\endlink.
Once you have made yourself familiar with MITK, you should have a look at the \link Concepts Development Concepts\endlink, as MITK implements a lot of high-level functionality.
Knowing about these concepts will prevent you from reimplementing functionality.
Once you start consuming more specific functionality, the \link MITKModuleManualsListPage Module Manual\endlink will be helpful to understand how a specific plugin works and what functionality it provides.
- \subpage StartingDevelopment
- \ref Architecture
- \ref SettingUpMITK
- \ref GettingToKnowMITK
- \ref FirstSteps
- \ref AboutTestingPage
- \subpage Concepts
- \subpage MITKModuleManualsListPage
- \subpage DevelopmentApplication
-
- - \ref mitkExtPointsIndex
-
- \subpage DeploymentPage
*/
diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/CMakeFAQ.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/CMakeFAQ.dox
index eb1e126554..475dd319e3 100644
--- a/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/CMakeFAQ.dox
+++ b/Documentation/Doxygen/3-DeveloperManual/Starting/GettingToKnow/CMakeFAQ.dox
@@ -1,44 +1,44 @@
/**
\page CMAKE_FAQ CMake FAQ
\section CMAKE_FAQ_General A general comment
MITK uses %CMake for configuration. If you want to develop either using MITK as a toolkit or by extending the capabilities of the applications provided by us, we recommend using %CMake for your own project too.
While it might be possible to use MITK in conjunction with other options, such as QMake or setting up your own project manually it will invariably involve a lot of work and probably hacks as well.
As we do have no experience with this, we will not be able to help you.
Be prepared to do a lot of tweaking on by yourself.
This guide does not try to give a general introduction to CMake, instead it tries to answer some basic questions that might arise for those new to %CMake, to help you get started on MITK. For a more comprehensive introduction on %CMake see here.
We will assume in this guide, that the path to your source is /MITK/.
\section CMAKE_FAQ_Question Basic Questions
\subsection CMAKE_FAQ_Question_WhereGetIt Where do I get CMake and what version do I need?
See \ref BuildInstructions_Prerequisites.
\subsection CMAKE_FAQ_Question_NewPluginNothing I coded a new plugin for the Workbench and nothing happened. Why?
Do note that you need to move the source to the Plugins directory and you will have to add the plugin to the config file (most likely Plugins/PluginList.cmake). After that see \ref CMAKE_FAQ_Question_HowDoIActivatePlugin.
\subsection CMAKE_FAQ_Question_HowDoIActivatePlugin I want to use a plugin, how do I activate it?
- Start %CMake in the `MITK-build` directory inside your superbuild folder. E.g.
`cd ~//MITK-build`
`ccmake .` or `cmake-gui .`
- Optional: *Configure* to see all %CMake variables.
- Find the variable `MITK_BUILD_` and activate it. The `` refers to the package name of the plugin.
- E.g. the plugin-id (also, the package name) `org.mitk.core.ext` is the sub-directory of same name in plugins directory (`~/MITK/Plugins/`).
+ E.g. the plugin-id (also, the package name) `org.mitk.gui.qt.application` is the sub-directory of same name in plugins directory (`~/MITK/Plugins/`).
- *Configure*, again
- *Generate*
- Rebuild the `MITK-build` target using your development environment.
\subsection CMAKE_FAQ_Question_HowDoIActivateModule I want to use a module, how do I activate it?
Modules are build automatically if a plugin that requires them is activated. See \ref CMAKE_FAQ_Question_HowDoIActivatePlugin.
\subsection CMAKE_FAQ_Question_HowOwnToolkits MITK always downloads the toolkits, but I want to use my own.
This is covered in \ref HowToNewProjectCustomizingMITKConfigure.
\subsection CMAKE_FAQ_Question_HowOwnProjectMITK I want to use an MITK plugin in my own project but I can not find it.
See \ref HowToNewProjectAddingMITKFunctionality.
*/
diff --git a/Examples/Plugins/org.mitk.example.gui.customviewer/manifest_headers.cmake b/Examples/Plugins/org.mitk.example.gui.customviewer/manifest_headers.cmake
index 058dcf0b91..170a057a2d 100644
--- a/Examples/Plugins/org.mitk.example.gui.customviewer/manifest_headers.cmake
+++ b/Examples/Plugins/org.mitk.example.gui.customviewer/manifest_headers.cmake
@@ -1,9 +1,8 @@
set(Plugin-Name "MITK Example Custom Viewer")
set(Plugin-Version "1.0.0")
set(Plugin-Vendor "German Cancer Research Center (DKFZ)")
set(Plugin-ContactAddress "https://www.mitk.org")
set(Require-Plugin
- org.mitk.core.ext # Registers file reader factories
org.mitk.gui.qt.application # Initializes GlobalInteraction and registers MITK Core factories
)
diff --git a/Modules/AppUtil/src/mitkBaseApplication.cpp b/Modules/AppUtil/src/mitkBaseApplication.cpp
index b3c458b695..736557984b 100644
--- a/Modules/AppUtil/src/mitkBaseApplication.cpp
+++ b/Modules/AppUtil/src/mitkBaseApplication.cpp
@@ -1,898 +1,902 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace
{
void outputQtMessage(QtMsgType type, const QMessageLogContext&, const QString& msg)
{
auto message = msg.toStdString();
switch (type)
{
case QtDebugMsg:
MITK_DEBUG << message;
break;
case QtInfoMsg:
MITK_INFO << message;
break;
case QtWarningMsg:
MITK_WARN << message;
break;
case QtCriticalMsg:
MITK_ERROR << message;
break;
case QtFatalMsg:
MITK_ERROR << message;
abort();
default:
MITK_INFO << message;
break;
}
}
}
namespace mitk
{
const QString BaseApplication::ARG_APPLICATION = "BlueBerry.application";
const QString BaseApplication::ARG_CLEAN = "BlueBerry.clean";
const QString BaseApplication::ARG_CONSOLELOG = "BlueBerry.consoleLog";
const QString BaseApplication::ARG_DEBUG = "BlueBerry.debug";
const QString BaseApplication::ARG_FORCE_PLUGIN_INSTALL = "BlueBerry.forcePlugins";
const QString BaseApplication::ARG_HOME = "BlueBerry.home";
const QString BaseApplication::ARG_NEWINSTANCE = "BlueBerry.newInstance";
const QString BaseApplication::ARG_NO_LAZY_REGISTRY_CACHE_LOADING = "BlueBerry.noLazyRegistryCacheLoading";
const QString BaseApplication::ARG_NO_REGISTRY_CACHE = "BlueBerry.noRegistryCache";
const QString BaseApplication::ARG_PLUGIN_CACHE = "BlueBerry.plugin_cache_dir";
const QString BaseApplication::ARG_PLUGIN_DIRS = "BlueBerry.plugin_dirs";
const QString BaseApplication::ARG_PRELOAD_LIBRARY = "BlueBerry.preloadLibrary";
const QString BaseApplication::ARG_PRODUCT = "BlueBerry.product";
const QString BaseApplication::ARG_PROVISIONING = "BlueBerry.provisioning";
const QString BaseApplication::ARG_REGISTRY_MULTI_LANGUAGE = "BlueBerry.registryMultiLanguage";
const QString BaseApplication::ARG_SPLASH_IMAGE = "BlueBerry.splashscreen";
const QString BaseApplication::ARG_STORAGE_DIR = "BlueBerry.storageDir";
const QString BaseApplication::ARG_XARGS = "xargs";
const QString BaseApplication::ARG_LOG_QT_MESSAGES = "Qt.logMessages";
const QString BaseApplication::ARG_SEGMENTATION_LABELSET_PRESET = "Segmentation.labelSetPreset";
const QString BaseApplication::ARG_SEGMENTATION_LABEL_SUGGESTIONS = "Segmentation.labelSuggestions";
const QString BaseApplication::PROP_APPLICATION = "blueberry.application";
const QString BaseApplication::PROP_FORCE_PLUGIN_INSTALL = BaseApplication::ARG_FORCE_PLUGIN_INSTALL;
const QString BaseApplication::PROP_NEWINSTANCE = BaseApplication::ARG_NEWINSTANCE;
const QString BaseApplication::PROP_NO_LAZY_REGISTRY_CACHE_LOADING = BaseApplication::ARG_NO_LAZY_REGISTRY_CACHE_LOADING;
const QString BaseApplication::PROP_NO_REGISTRY_CACHE = BaseApplication::ARG_NO_REGISTRY_CACHE;
const QString BaseApplication::PROP_PRODUCT = "blueberry.product";
const QString BaseApplication::PROP_REGISTRY_MULTI_LANGUAGE = BaseApplication::ARG_REGISTRY_MULTI_LANGUAGE;
class SplashCloserCallback : public QRunnable
{
public:
SplashCloserCallback(QSplashScreen* splashscreen)
: m_Splashscreen(splashscreen)
{
}
void run() override
{
this->m_Splashscreen->close();
}
private:
QSplashScreen *m_Splashscreen; // Owned by BaseApplication::Impl
};
struct BaseApplication::Impl
{
ctkProperties m_FWProps;
QCoreApplication *m_QApp;
int m_Argc;
char **m_Argv;
#ifdef Q_OS_MAC
std::vector m_Argv_macOS;
#endif
QString m_AppName;
QString m_OrgaName;
QString m_OrgaDomain;
bool m_SingleMode;
bool m_SafeMode;
QSplashScreen *m_Splashscreen;
SplashCloserCallback *m_SplashscreenClosingCallback;
bool m_LogQtMessages;
QStringList m_PreloadLibs;
QString m_ProvFile;
Impl(int argc, char **argv)
: m_Argc(argc),
m_Argv(argv),
#ifdef Q_OS_MAC
m_Argv_macOS(),
#endif
m_SingleMode(false),
m_SafeMode(true),
m_Splashscreen(nullptr),
m_SplashscreenClosingCallback(nullptr),
m_LogQtMessages(false)
{
#ifdef Q_OS_MAC
/* On macOS the process serial number is passed as an command line argument (-psn_)
in certain circumstances. This option causes a Poco exception. We remove it, if present. */
m_Argv_macOS.reserve(argc + 1);
const char psn[] = "-psn";
for (int i = 0; i < argc; ++i)
{
if (0 == strncmp(argv[i], psn, sizeof(psn) - 1))
continue;
m_Argv_macOS.push_back(argv[i]);
}
m_Argv_macOS.push_back(nullptr);
m_Argc = static_cast(m_Argv_macOS.size() - 1);
m_Argv = m_Argv_macOS.data();
#endif
}
~Impl()
{
delete m_SplashscreenClosingCallback;
delete m_Splashscreen;
delete m_QApp;
}
QVariant getProperty(const QString &property) const
{
auto iter = m_FWProps.find(property);
return m_FWProps.end() != iter
? iter.value()
: QVariant();
}
void handleBooleanOption(const std::string &name, const std::string &)
{
if (ARG_LOG_QT_MESSAGES.toStdString() == name)
{
m_LogQtMessages = true;
return;
}
auto fwKey = QString::fromStdString(name);
// Translate some keys to proper framework properties
if (ARG_CONSOLELOG == fwKey)
fwKey = ctkPluginFrameworkLauncher::PROP_CONSOLE_LOG;
// For all other options we use the command line option name as the
// framework property key.
m_FWProps[fwKey] = true;
}
void handlePreloadLibraryOption(const std::string &, const std::string &value)
{
m_PreloadLibs.push_back(QString::fromStdString(value));
}
void handleClean(const std::string &, const std::string &)
{
m_FWProps[ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN] = ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT;
}
void initializeCTKPluginFrameworkProperties(Poco::Util::LayeredConfiguration &configuration)
{
// Add all configuration key/value pairs as framework properties
Poco::Util::LayeredConfiguration::Keys keys;
Poco::Util::LayeredConfiguration::Keys keyStack;
configuration.keys(keyStack);
std::vector keyChain;
while (!keyStack.empty())
{
const auto currSubKey = keyStack.back();
if (!keyChain.empty() && keyChain.back() == currSubKey)
{
keyChain.pop_back();
keyStack.pop_back();
continue;
}
Poco::Util::LayeredConfiguration::Keys subKeys;
configuration.keys(currSubKey, subKeys);
if (subKeys.empty())
{
std::string finalKey;
keyStack.pop_back();
for (const auto& key : keyChain)
finalKey += key + '.';
finalKey += currSubKey;
keys.push_back(finalKey);
}
else
{
keyChain.push_back(currSubKey);
for (const auto& key : subKeys)
keyStack.push_back(key);
}
}
for (const auto& key : keys)
{
if (configuration.hasProperty(key))
{
// .ini and command line options overwrite already inserted keys
auto qKey = QString::fromStdString(key);
m_FWProps[qKey] = QString::fromStdString(configuration.getString(key));
}
}
}
void parseProvisioningFile(const QString &filePath)
{
// Skip parsing if the file path is empty
if (filePath.isEmpty())
return;
auto consoleLog = this->getProperty(ctkPluginFrameworkLauncher::PROP_CONSOLE_LOG).toBool();
// Read initial plugins from a provisioning file
QFileInfo provFile(filePath);
QStringList pluginsToStart;
if (provFile.exists())
{
MITK_INFO(consoleLog) << "Using provisioning file: " << qPrintable(provFile.absoluteFilePath());
ProvisioningInfo provInfo(provFile.absoluteFilePath());
// It can still happen that the encoding is not compatible with the fromUtf8 function (i.e. when
// manipulating the LANG variable). The QStringList in provInfo is empty then.
if (provInfo.getPluginDirs().empty())
{
MITK_ERROR << "Cannot search for provisioning file, the retrieved directory list is empty.\n"
<< "This can happen if there are some special non-ASCII characters in the install path.";
}
else
{
for(const auto& pluginPath : provInfo.getPluginDirs())
ctkPluginFrameworkLauncher::addSearchPath(pluginPath);
auto pluginUrlsToStart = provInfo.getPluginsToStart();
for (const auto& url : qAsConst(pluginUrlsToStart))
pluginsToStart.push_back(url.toString());
}
}
else
{
MITK_INFO(consoleLog) << "Provisionig file does not exist.";
}
if (!pluginsToStart.isEmpty())
{
m_FWProps[ctkPluginFrameworkLauncher::PROP_PLUGINS] = pluginsToStart;
// Use transient start with declared activation policy (this helps when the provisioning file
// changes and some plug-ins should not be installed in the application any more).
ctkPlugin::StartOptions startOptions(ctkPlugin::START_TRANSIENT | ctkPlugin::START_ACTIVATION_POLICY);
m_FWProps[ctkPluginFrameworkLauncher::PROP_PLUGINS_START_OPTIONS] = static_cast(startOptions);
}
}
};
BaseApplication::BaseApplication(int argc, char **argv)
: Application(),
d(new Impl(argc, argv))
{
}
BaseApplication::~BaseApplication()
{
delete d;
}
void BaseApplication::printHelp(const std::string &, const std::string &)
{
Poco::Util::HelpFormatter help(this->options());
help.setAutoIndent();
help.setCommand(this->commandName());
help.format(std::cout);
exit(EXIT_OK);
}
void BaseApplication::setApplicationName(const QString &name)
{
if (nullptr != qApp)
qApp->setApplicationName(name);
d->m_AppName = name;
}
QString BaseApplication::getApplicationName() const
{
return nullptr != qApp
? qApp->applicationName()
: d->m_AppName;
}
void BaseApplication::setOrganizationName(const QString &name)
{
if (nullptr != qApp)
qApp->setOrganizationName(name);
d->m_OrgaName = name;
}
QString BaseApplication::getOrganizationName() const
{
return nullptr != qApp
? qApp->organizationName()
: d->m_OrgaName;
}
void BaseApplication::setOrganizationDomain(const QString &domain)
{
if (nullptr != qApp)
qApp->setOrganizationDomain(domain);
d->m_OrgaDomain = domain;
}
QString BaseApplication::getOrganizationDomain() const
{
return nullptr != qApp
? qApp->organizationDomain()
: d->m_OrgaDomain;
}
void BaseApplication::setSingleMode(bool singleMode)
{
if (nullptr != qApp)
return;
d->m_SingleMode = singleMode;
}
bool BaseApplication::getSingleMode() const
{
return d->m_SingleMode;
}
void BaseApplication::setSafeMode(bool safeMode)
{
if (nullptr != qApp && nullptr == d->m_QApp)
return;
d->m_SafeMode = safeMode;
nullptr == d->m_QApp && getSingleMode()
? static_cast(d->m_QApp)->setSafeMode(safeMode)
: static_cast(d->m_QApp)->setSafeMode(safeMode);
}
bool BaseApplication::getSafeMode() const
{
return d->m_SafeMode;
}
void BaseApplication::setPreloadLibraries(const QStringList &libraryBaseNames)
{
d->m_PreloadLibs = libraryBaseNames;
}
QStringList BaseApplication::getPreloadLibraries() const
{
return d->m_PreloadLibs;
}
void BaseApplication::setProvisioningFilePath(const QString &filePath)
{
d->m_ProvFile = filePath;
}
QString BaseApplication::getProvisioningFilePath() const
{
auto provFilePath = d->m_ProvFile;
// A null QString means look up a default provisioning file
if (provFilePath.isNull() && nullptr != qApp)
{
QFileInfo appFilePath(QCoreApplication::applicationFilePath());
QDir basePath(QCoreApplication::applicationDirPath());
auto provFileName = appFilePath.baseName() + ".provisioning";
QFileInfo provFile(basePath.absoluteFilePath(provFileName));
#ifdef Q_OS_MAC
/*
* On macOS, if started from the build directory, the .provisioning file is located at:
*
* The executable path is:
*
* In this case we have to cdUp threetimes.
*
* During packaging the MitkWorkbench.provisioning file is placed at the same
* level like the executable. Nothing has to be done.
*/
if (!provFile.exists())
{
basePath.cdUp();
basePath.cdUp();
basePath.cdUp();
provFile = basePath.absoluteFilePath(provFileName);
}
#endif
if (provFile.exists())
{
provFilePath = provFile.absoluteFilePath();
}
#ifdef CMAKE_INTDIR
else
{
basePath.cdUp();
provFile.setFile(basePath.absoluteFilePath(provFileName));
if (provFile.exists())
provFilePath = provFile.absoluteFilePath();
}
#endif
}
return provFilePath;
}
void BaseApplication::initializeQt()
{
if (nullptr != qApp)
return;
#ifdef Q_OS_LINUX
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--single-process"); // See T29332
#endif
// If parameters have been set before, we have to store them to hand them
// through to the application
auto appName = this->getApplicationName();
auto orgName = this->getOrganizationName();
auto orgDomain = this->getOrganizationDomain();
// Create a QCoreApplication instance
this->getQApplication();
// Provide parameters to QCoreApplication
this->setApplicationName(appName);
this->setOrganizationName(orgName);
this->setOrganizationDomain(orgDomain);
if (d->m_LogQtMessages)
qInstallMessageHandler(outputQtMessage);
QWebEngineUrlScheme qtHelpScheme("qthelp");
qtHelpScheme.setFlags(QWebEngineUrlScheme::LocalScheme | QWebEngineUrlScheme::LocalAccessAllowed);
QWebEngineUrlScheme::registerScheme(qtHelpScheme);
}
void BaseApplication::initialize(Poco::Util::Application &self)
{
// 1. Call the super-class method
Poco::Util::Application::initialize(self);
// 2. Initialize the Qt framework (by creating a QCoreApplication)
this->initializeQt();
// 3. Seed the random number generator, once at startup.
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
// 4. Load the "default" configuration, which involves parsing
// an optional .ini file and parsing any
// command line arguments
this->loadConfiguration();
// 5. Add configuration data from the command line and the
// optional .ini file as CTK plugin
// framework properties.
d->initializeCTKPluginFrameworkProperties(this->config());
// 6. Initialize splash screen if an image path is provided
// in the .ini file
this->initializeSplashScreen(qApp);
// 7. Set the custom CTK Plugin Framework storage directory
QString storageDir = this->getCTKFrameworkStorageDir();
if (!storageDir.isEmpty())
{
d->m_FWProps[ctkPluginConstants::FRAMEWORK_STORAGE] = storageDir;
// Initialize core service preferences at the exact same location as their predecessor BlueBerry preferences
mitk::CoreServicePointer preferencesService(mitk::CoreServices::GetPreferencesService());
preferencesService->InitializeStorage(storageDir.toStdString() + "/data/3/prefs.xml");
}
// 8. Set the library search paths and the pre-load library property
this->initializeLibraryPaths();
auto preloadLibs = this->getPreloadLibraries();
if (!preloadLibs.isEmpty())
d->m_FWProps[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES] = preloadLibs;
// 9. Initialize the CppMicroServices library.
// The initializeCppMicroServices() method reuses the
// FRAMEWORK_STORAGE property, so we call it after the
// getCTKFrameworkStorageDir method.
this->initializeCppMicroServices();
// 10. Parse the (optional) provisioning file and set the
// correct framework properties.
d->parseProvisioningFile(this->getProvisioningFilePath());
// 11. Set the CTK Plugin Framework properties
ctkPluginFrameworkLauncher::setFrameworkProperties(d->m_FWProps);
}
void BaseApplication::uninitialize()
{
auto pfw = this->getFramework();
if (pfw)
{
pfw->stop();
// Wait for up to 10 seconds for the CTK plugin framework to stop
pfw->waitForStop(10000);
}
Poco::Util::Application::uninitialize();
}
int BaseApplication::getArgc() const
{
return d->m_Argc;
}
char **BaseApplication::getArgv() const
{
return d->m_Argv;
}
QString BaseApplication::getCTKFrameworkStorageDir() const
{
QString storageDir;
if (this->getSingleMode())
{
// This function checks if an instance is already running and either sends a message to
// it containing the command line arguments or checks if a new instance was forced by
// providing the BlueBerry.newInstance command line argument. In the latter case, a path
// to a temporary directory for the new application's storage directory is returned.
storageDir = handleNewAppInstance(static_cast(d->m_QApp),
d->m_Argc, d->m_Argv, ARG_NEWINSTANCE);
}
if (storageDir.isEmpty())
{
// This is a new instance and no other instance is already running. We specify the
// storage directory here (this is the same code as in berryInternalPlatform.cpp)
// so that we can re-use the location for the persistent data location of the
// the CppMicroServices library.
// Append a hash value of the absolute path of the executable to the data location.
// This allows to start the same application from different build or install trees.
storageDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/" +
this->getOrganizationName() + "/" + this->getApplicationName() + '_';
storageDir += QString::number(qHash(QCoreApplication::applicationDirPath())) + "/";
}
return storageDir;
}
void BaseApplication::initializeCppMicroServices()
{
auto storageDir = this->getProperty(ctkPluginConstants::FRAMEWORK_STORAGE).toString();
if (!storageDir.isEmpty())
us::ModuleSettings::SetStoragePath((storageDir + "us" + QDir::separator()).toStdString());
}
QCoreApplication *BaseApplication::getQApplication() const
{
if (nullptr == qApp)
{
vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples(0);
auto defaultFormat = QVTKOpenGLNativeWidget::defaultFormat();
defaultFormat.setSamples(0);
QSurfaceFormat::setDefaultFormat(defaultFormat);
#ifdef Q_OS_OSX
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif
- QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
+#endif
+ QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
+
d->m_QApp = this->getSingleMode()
? static_cast(new QmitkSingleApplication(d->m_Argc, d->m_Argv, this->getSafeMode()))
: static_cast(new QmitkSafeApplication(d->m_Argc, d->m_Argv, this->getSafeMode()));
}
return qApp;
}
void BaseApplication::initializeLibraryPaths()
{
QStringList suffixes;
suffixes << "plugins";
#ifdef Q_OS_WINDOWS
suffixes << "bin/plugins";
#ifdef CMAKE_INTDIR
suffixes << "bin/" CMAKE_INTDIR "/plugins";
#endif
#else
suffixes << "lib/plugins";
#ifdef CMAKE_INTDIR
suffixes << "lib/" CMAKE_INTDIR "/plugins";
#endif
#endif
#ifdef Q_OS_MAC
suffixes << "../../plugins";
#endif
// We add a couple of standard library search paths for plug-ins
QDir appDir(QCoreApplication::applicationDirPath());
// Walk one directory up and add bin and lib sub-dirs; this might be redundant
appDir.cdUp();
for (const auto& suffix : qAsConst(suffixes))
ctkPluginFrameworkLauncher::addSearchPath(appDir.absoluteFilePath(suffix));
}
int BaseApplication::main(const std::vector &args)
{
// Start the plugin framework and all installed plug-ins according to their auto-start setting
QStringList arguments;
for (auto const &arg : args)
arguments.push_back(QString::fromStdString(arg));
if (nullptr != d->m_Splashscreen)
{
// A splash screen is displayed. Create the closing callback.
d->m_SplashscreenClosingCallback = new SplashCloserCallback(d->m_Splashscreen);
}
return ctkPluginFrameworkLauncher::run(d->m_SplashscreenClosingCallback, QVariant::fromValue(arguments)).toInt();
}
void BaseApplication::defineOptions(Poco::Util::OptionSet &options)
{
Poco::Util::Option helpOption("help", "h", "print this help text");
helpOption.callback(Poco::Util::OptionCallback(this, &BaseApplication::printHelp));
options.addOption(helpOption);
Poco::Util::Option newInstanceOption(ARG_NEWINSTANCE.toStdString(), "", "forces a new instance of this application");
newInstanceOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption));
options.addOption(newInstanceOption);
Poco::Util::Option cleanOption(ARG_CLEAN.toStdString(), "", "cleans the plugin cache");
cleanOption.callback(Poco::Util::OptionCallback(d, &Impl::handleClean));
options.addOption(cleanOption);
Poco::Util::Option productOption(ARG_PRODUCT.toStdString(), "", "the id of the product to be launched");
productOption.argument("").binding(PROP_PRODUCT.toStdString());
options.addOption(productOption);
Poco::Util::Option appOption(ARG_APPLICATION.toStdString(), "", "the id of the application extension to be executed");
appOption.argument("").binding(PROP_APPLICATION.toStdString());
options.addOption(appOption);
Poco::Util::Option provOption(ARG_PROVISIONING.toStdString(), "", "the location of a provisioning file");
provOption.argument("").binding(ARG_PROVISIONING.toStdString());
options.addOption(provOption);
Poco::Util::Option storageDirOption(ARG_STORAGE_DIR.toStdString(), "", "the location for storing persistent application data");
storageDirOption.argument("").binding(ctkPluginConstants::FRAMEWORK_STORAGE.toStdString());
options.addOption(storageDirOption);
Poco::Util::Option consoleLogOption(ARG_CONSOLELOG.toStdString(), "", "log messages to the console");
consoleLogOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption));
options.addOption(consoleLogOption);
Poco::Util::Option debugOption(ARG_DEBUG.toStdString(), "", "enable debug mode");
debugOption.argument("", false).binding(ctkPluginFrameworkLauncher::PROP_DEBUG.toStdString());
options.addOption(debugOption);
Poco::Util::Option forcePluginOption(ARG_FORCE_PLUGIN_INSTALL.toStdString(), "", "force installing plug-ins with same symbolic name");
forcePluginOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption));
options.addOption(forcePluginOption);
Poco::Util::Option preloadLibsOption(ARG_PRELOAD_LIBRARY.toStdString(), "", "preload a library");
preloadLibsOption.argument("")
.repeatable(true)
.callback(Poco::Util::OptionCallback(d, &Impl::handlePreloadLibraryOption));
options.addOption(preloadLibsOption);
Poco::Util::Option noRegistryCacheOption(ARG_NO_REGISTRY_CACHE.toStdString(), "", "do not use a cache for the registry");
noRegistryCacheOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption));
options.addOption(noRegistryCacheOption);
Poco::Util::Option noLazyRegistryCacheLoadingOption(ARG_NO_LAZY_REGISTRY_CACHE_LOADING.toStdString(), "", "do not use lazy cache loading for the registry");
noLazyRegistryCacheLoadingOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption));
options.addOption(noLazyRegistryCacheLoadingOption);
Poco::Util::Option registryMultiLanguageOption(ARG_REGISTRY_MULTI_LANGUAGE.toStdString(), "", "enable multi-language support for the registry");
registryMultiLanguageOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption));
options.addOption(registryMultiLanguageOption);
Poco::Util::Option splashScreenOption(ARG_SPLASH_IMAGE.toStdString(), "", "optional picture to use as a splash screen");
splashScreenOption.argument("").binding(ARG_SPLASH_IMAGE.toStdString());
options.addOption(splashScreenOption);
Poco::Util::Option xargsOption(ARG_XARGS.toStdString(), "", "Extended argument list");
xargsOption.argument("").binding(ARG_XARGS.toStdString());
options.addOption(xargsOption);
Poco::Util::Option logQtMessagesOption(ARG_LOG_QT_MESSAGES.toStdString(), "", "log Qt messages");
logQtMessagesOption.callback(Poco::Util::OptionCallback(d, &Impl::handleBooleanOption));
options.addOption(logQtMessagesOption);
Poco::Util::Option labelSetPresetOption(ARG_SEGMENTATION_LABELSET_PRESET.toStdString(), "", "use this label set preset for new segmentations");
labelSetPresetOption.argument("").binding(ARG_SEGMENTATION_LABELSET_PRESET.toStdString());
options.addOption(labelSetPresetOption);
Poco::Util::Option labelSuggestionsOption(ARG_SEGMENTATION_LABEL_SUGGESTIONS.toStdString(), "", "use this list of predefined suggestions for segmentation labels");
labelSuggestionsOption.argument("").binding(ARG_SEGMENTATION_LABEL_SUGGESTIONS.toStdString());
options.addOption(labelSuggestionsOption);
Poco::Util::Application::defineOptions(options);
}
QSharedPointer BaseApplication::getFramework() const
{
return ctkPluginFrameworkLauncher::getPluginFramework();
}
ctkPluginContext *BaseApplication::getFrameworkContext() const
{
auto framework = getFramework();
return framework
? framework->getPluginContext()
: nullptr;
}
void BaseApplication::initializeSplashScreen(QCoreApplication * application) const
{
auto pixmapFileNameProp = d->getProperty(ARG_SPLASH_IMAGE);
if (!pixmapFileNameProp.isNull())
{
auto pixmapFileName = pixmapFileNameProp.toString();
QFileInfo checkFile(pixmapFileName);
if (checkFile.exists() && checkFile.isFile())
{
QPixmap pixmap(checkFile.absoluteFilePath());
d->m_Splashscreen = new QSplashScreen(pixmap, Qt::WindowStaysOnTopHint);
d->m_Splashscreen->show();
application->processEvents();
}
}
}
QHash BaseApplication::getFrameworkProperties() const
{
return d->m_FWProps;
}
int BaseApplication::run()
{
this->init(d->m_Argc, d->m_Argv);
return Application::run();
}
void BaseApplication::setProperty(const QString &property, const QVariant &value)
{
d->m_FWProps[property] = value;
}
QVariant BaseApplication::getProperty(const QString &property) const
{
return d->getProperty(property);
}
void BaseApplication::installTranslator(QTranslator* translator)
{
this->getQApplication()->installTranslator(translator);
}
bool BaseApplication::isRunning()
{
auto app = dynamic_cast(this->getQApplication());
if (nullptr != app)
app->isRunning();
mitkThrow() << "Method not implemented.";
}
void BaseApplication::sendMessage(const QByteArray msg)
{
auto app = dynamic_cast(this->getQApplication());
if (nullptr != app)
app->sendMessage(msg);
mitkThrow() << "Method not implemented.";
}
}
diff --git a/Modules/Classification/CLVigraRandomForest/test/files.cmake b/Modules/Classification/CLVigraRandomForest/test/files.cmake
index 3f04b16d08..9a4351245d 100644
--- a/Modules/Classification/CLVigraRandomForest/test/files.cmake
+++ b/Modules/Classification/CLVigraRandomForest/test/files.cmake
@@ -1,3 +1,5 @@
-set(MODULE_TESTS
- mitkVigraRandomForestTest.cpp
-)
+set(MODULE_TESTS "")
+
+if(NOT APPLE)
+ list(APPEND MODULE_TESTS mitkVigraRandomForestTest.cpp)
+endif()
diff --git a/Modules/Core/include/mitkInteractionConst.h b/Modules/Core/include/mitkInteractionConst.h
index e83f33b429..0df91c3715 100644
--- a/Modules/Core/include/mitkInteractionConst.h
+++ b/Modules/Core/include/mitkInteractionConst.h
@@ -1,776 +1,762 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#ifndef mitkInteractionConst_h
#define mitkInteractionConst_h
//##Documentation
//## @file mitkInteractionConst.h
//## @brief Constants for most interaction classes, due to the generic StateMachines.
//##
//## Changes in Type, ButtonState or Key has to be don in mitkEventMapper.cpp, too.
//## @ingroup Interaction
/*Prefixes for Constants:
E = Enumeration
EID = EventId's
Op = Operations
Ac = Action
Type_ = Type of Event
BS_ = ButtonStates and Buttons
Key_ = Keys like in QT
*/
namespace mitk
{
// Constants for EventIds; use the according constant to through an event in the code
enum EEventIds
{
EIDNULLEVENT = 0,
EIDLEFTMOUSEBTN = 1,
EIDRIGHTMOUSEBTN = 2,
EIDLEFTMOUSEBTNANDSHIFT = 3,
EIDMIDDLEMOUSEBTN = 4,
EIDLEFTMOUSEBTNANDCTRL = 5,
EIDMIDDLEMOUSEBTNANDCTRL = 6,
EIDRIGHTMOUSEBTNANDCTRL = 7,
EIDLEFTMOUSEBTNDOUBLECLICK = 8,
EIDMOUSEWHEEL = 9,
EIDLEFTMOUSERELEASE = 505,
EIDMIDDLEMOUSERELEASE = 506,
EIDRIGHTMOUSERELEASE = 507,
EIDLEFTMOUSERELEASEANDSHIFT = 508,
EIDMOUSEMOVE = 520,
EIDLEFTMOUSEBTNANDMOUSEWHEEL = 521,
EIDRIGHTMOUSEBTNANDMOUSEWHEEL = 522,
EIDMIDDLEMOUSEBTNANDMOUSEWHEEL = 523,
EIDLEFTMOUSEBTNANDMOUSEMOVE = 530,
EIDRIGHTMOUSEBTNANDMOUSEMOVE = 531,
EIDMIDDLEMOUSEBTNANDMOUSEMOVE = 533,
EIDCTRLANDLEFTMOUSEBTNANDMOUSEMOVE = 534,
EIDCTRLANDRIGHTMOUSEBTNANDMOUSEMOVE = 535,
EIDCTRLANDMIDDLEMOUSEBTNANDMOUSEMOVE = 536,
EIDCTRLANDLEFTMOUSEBTNRELEASE = 537,
EIDCTRLANDRIGHTMOUSEBTNRELEASE = 538,
EIDCTRLANDMIDDLEMOUSEBTNRELEASE = 539,
EIDSHIFTANDCTRLANDMIDDLEMOUSEBTN = 540,
EIDSHIFTANDLEFTMOUSEBTNANDMOUSEMOVE = 541,
EIDSHIFTANDCTRLANDMOUSEMOVE = 542,
EIDSHIFTANDCTRLANDMOUSERELEASE = 543,
EIDALTANDLEFTMOUSEBTN = 600,
EIDALTANDLEFTMOUSEBTNANDMOUSEMOVE = 610,
EIDALTANDLEFTMOUSERELEASE = 620,
EIDCTRLANDLEFTMOUSEWHEEL = 630,
EIDALTANDMOUSEWHEEL = 640,
EIDALTANDMIDDLEMOUSEBTN = 641,
EIDALTANDMIDDLEMOUSEBTNANDMOVE = 642,
EIDALTANDMIDDLEMOUSEBTNRELEASE = 643,
EIDALTANDSHIFTANDRIGHTMOUSEBTN = 644,
EIDALTANDSHIFTANDRIGHTMOUSEBTNANDMOUSEMOVE = 645,
EIDALTANDSHIFTANDRIGHTMOUSEBTNRELEASE = 646,
EIDSHIFTANDRIGHTMOUSEPRESS = 2000,
EIDSHIFTANDRIGHTMOUSEMOVE = 2001,
EIDSHIFTANDRIGHTMOUSERELEASE = 2002,
EIDSHIFTANDMIDDLEMOUSEPRESS = 2003,
EIDSHIFTANDMIDDLEMOUSEMOVE = 2004,
EIDSHIFTANDMIDDLEMOUSERELEASE = 2005,
- EIDSPACENAVIGATORINPUT = 4001, // 3d Mouse, SpaceNavigator input
- EIDSPACENAVIGATORKEYDOWN = 4002, // 3d Mouse, KeyDown
- EIDWIIMOTEINPUT = 4003, // WiiMote input
- EIDWIIMOTEBUTTON = 4004, // WiiMote home button
- EIDWIIMOTEBUTTONB = 4005, // WiiMote b button
EIDSTRGANDN = 10,
EIDSTRGANDE = 11,
EIDDELETE = 12,
EIDN = 13,
EIDESCAPE = 14,
EIDP = 15,
EIDR = 16,
EIDT = 17,
EIDS = 18,
EIDE = 19,
EIDSTRGANDALTANDA = 20,
EIDSTRGANDALTANDB = 21,
EIDH = 22,
EIDRETURN = 23,
EIDENTER = 24,
EIDSPACE = 25,
EIDPLUS = 26,
EIDMINUS = 27,
EIDSTRGANDALTANDH = 30,
EIDSTRGANDALTANDI = 31,
EIDSTRGANDALTANDS = 40,
EIDALT = 90,
EIDSTRGANDB = 91,
EIDNEW = 1000,
EIDOLD = 1001,
EIDFINISHED = 1002,
EIDNO = 1003,
EIDYES = 1004,
EIDSAME = 1005,
EIDNOANDLASTOBJECT = 1006,
EIDNOANDNOTLASTOBJECT = 1007,
EIDLAST = 1008,
EIDNOTLAST = 1009,
EIDSTSMALERNMINUS1 = 1010,
EIDSTLARGERNMINUS1 = 1011,
EIDPOSITIONEVENT = 1012,
EIDEDIT = 1013,
EIDSMALLERN = 1014,
EIDEQUALSN = 1015,
EIDLARGERN = 1016,
EIDEMPTY = 1017,
EIDSUBDESELECT = 1020,
EIDSMTOSELECTED = 1030,
EIDSMTODESELECTED = 1031,
EIDTIP = 1050,
EIDHEAD = 1051,
EIDBODY = 1052,
EIDCLEAR = 1100,
EIDACTIVATETOOL = 1300,
EIDPRINT = 3001,
EV_INIT = 5551001,
EV_PREVIOUS = 5551002,
EV_PATH_COLLECTION_SELECTED = 5551003,
EV_NAVIGATION_SELECTED = 5551004,
EV_LESS_THEN_MIN_COUNT = 5551005,
EV_READY = 5551006,
EV_NEXT = 5551007,
EV_DONE = 5551008,
EV_NEW_LANDMARK = 5551009,
EV_REMOVE_LANDMARK = 5551010,
EIDINSIDE = 2500,
EIDA = 4001,
EIDB = 4002,
EIDC = 4003,
EIDD = 4004,
EIDF = 4005,
EIDG = 4006,
EIDI = 4007,
EIDJ = 4008,
EIDK = 4009,
EIDL = 4010,
EIDM = 4011,
EIDO = 4012,
EIDQ = 4013,
EIDU = 4014,
EIDV = 4015,
EIDW = 4016,
EIDX = 4017,
EIDY = 4018,
EIDZ = 4019,
EID1 = 4020,
EID2 = 4021,
EID3 = 4022,
EID4 = 4023,
EID5 = 4024,
EID6 = 4025,
EID7 = 4026,
EID8 = 4027,
EID9 = 4028,
EID0 = 4029,
EIDFIGUREHOVER = 12340,
EIDNOFIGUREHOVER = 12341
};
//##Constants for Operations
- //## xomments are always examples of the usage
+ //## comments are always examples of the usage
enum EOperations
{
OpNOTHING = 0,
OpTEST = 1,
OpNEWCELL = 10, // add a new cell
OpADD = 100, // add a point or a vessel
OpUNDOADD = 101,
OpADDLINE = 1001, // add a line
OpINSERT = 200, // insert a point at position
OpINSERTLINE = 201, // insert a line at position
OpINSERTPOINT = 202,
OpCLOSECELL = 250, // close a cell (to a polygon)
OpOPENCELL = 251, // close a cell (to a polygon)
OpMOVE = 300, // move a point
OpMOVELINE = 301, // move a line
OpMOVECELL = 302, // move a line
OpUNDOMOVE = 303,
OpMOVEPOINTUP = 304,
OpMOVEPOINTDOWN = 305,
OpREMOVE = 400, // remove a point at position
OpREMOVELINE = 401, // remove a line at position
OpREMOVECELL = 402, // remove a cell
OpREMOVEPOINT = 403,
OpDELETE = 500, // delete
OpDELETELINE = 501, // delete the last line in a cell
OpUNDELETE = 502,
OpDELETECELL = 505,
OpSTATECHANGE = 600, // change a state
OpTIMECHANGE = 601, // change a state
OpTERMINATE = 666, // change a state
OpSELECTPOINT = 700,
OpSELECTLINE = 701,
OpSELECTCELL = 702,
OpSELECTSUBOBJECT = 703, // for VesselGraphInteractor
// OpSELECTNEWSUBOBJECT = 704, //for VesselGraphInteractor
OpSELECT = 705,
OpDESELECTPOINT = 800,
OpDESELECTLINE = 801,
OpDESELECTCELL = 802,
OpDESELECTSUBOBJECT = 803, // for VesselGraphInteractor
OpDESELECTALL = 804, // for VesselGraphInteractor
OpDESELECT = 805,
OpNAVIGATE = 900,
OpZOOM = 1000,
OpSCALE = 1100,
OpROTATE = 1200,
OpORIENT = 1201,
OpRESTOREPLANEPOSITION = 1202,
OpAPPLYTRANSFORMMATRIX = 1203,
OpSETPOINTTYPE = 1210,
OpMODECHANGE = 1500,
OpSENDCOORDINATES = 1600,
OpPERIPHERYSEARCH = 2000, // used in VesselGraphInteractor
OpROOTSEARCH = 2001, // used in VesselGraphInteractor
OpTHICKSTVESSELSEARCH = 2002, // used in VesselGraphInteractor
OpSHORTESTPATHSEARCH = 2003, // used in VesselGraphInteractor
OpATTRIBUTATION = 2004, // used in VesselGraphInteractor
OpDEFAULT = 2006, // used in VesselGraphInteractor
OpSURFACECHANGED = 3000, // used for changing polydata in surfaces
};
//##Constants for EventMapping...
//##connects the statemachine.xml-File with the implemented conditions.
//##within one statemachine the choice of the actionconstants is freely
//##
//## ActionId
enum EActions
{
AcDONOTHING = 0,
AcINITNEWOBJECT = 5,
AcINITEDITOBJECT = 6,
AcINITEDITGROUP = 7,
AcINITMOVEMENT = 8,
AcINITMOVE = 9,
AcINITFOREGROUND = 45, // used in SeedsInteractor for setting the foreground seeds
AcINITBACKGROUND = 46, // used in SeedsInteractor for setting the background seeds
AcINITNEUTRAL = 47, // used in SeedsInteractor for setting the neutral seeds (rubber)
AcINITUPDATE = 1235, // For shape model deformation
AcADDPOINT = 10,
AcADDPOINTRMB = 6000, // in mitralPointSetInteractor used to set a different type of point
AcADD = 11,
AcADDLINE = 12,
AcADDANDFINISH = 13,
AcADDSELECTEDTOGROUP = 64,
AcCHECKPOINT = 21,
AcCHECKLINE = 22,
AcCHECKCELL = 23,
AcCHECKELEMENT = 30, // check if there is a element close enough (picking)
AcCHECKOBJECT = 31, // check if an object is hit
AcCHECKNMINUS1 = 32, // check if the number of elements is equal to N-1
AcCHECKEQUALS1 = 33, // check if the number of elements in the data is equal to 1
AcCHECKNUMBEROFPOINTS = 330, // check the number of elements in the data
AcCHECKSELECTED = 34, // check if the given element is selected or not
AcCHECKONESELECTED = 340, // check if there is an element that is selected
AcCHECKHOVERING = 341, // check if there is an element that is selected
AcCHECKGREATERZERO = 35, // check if the current number of elements is greater than 0
AcCHECKGREATERTWO = 36, // check if the current number of elements is greater than two
AcCHECKOPERATION = 37, // check if the operation is of one spectial type
AcCHECKONESUBINTERACTOR = 38,
AcCHECKSUBINTERACTORS = 39,
AcFINISHOBJECT = 40,
AcFINISHGROUP = 41,
AcFINISHMOVEMENT = 42,
AcFINISHMOVE = 43,
AcFINISH = 44,
AcSEARCHOBJECT = 50,
AcSEARCHGROUP = 51,
AcSEARCHANOTHEROBJECT = 52, // one object is selected and another object is to be added to selection
AcSELECTPICKEDOBJECT = 60, // select the picked object and deselect others
AcSELECTANOTHEROBJECT = 61,
AcSELECTGROUP = 62,
AcSELECTALL = 63,
AcSELECT = 65,
AcSELECTPOINT = 66,
AcSELECTLINE = 68,
AcSELECTCELL = 67,
AcSELECTSUBOBJECT = 69, // used in VesselGraphInteractor
AcDESELECTOBJECT = 70, // deselect picked from group
AcDESELECTALL = 72,
AcDESELECT = 75,
AcDESELECTPOINT = 76,
AcDESELECTLINE = 78,
AcDESELECTCELL = 77,
AcNEWPOINT = 80,
AcNEWSUBOBJECT = 81,
AcMOVEPOINT = 90,
AcMOVESELECTED = 91,
AcMOVE = 92,
AcMOVEPOINTUP = 93,
AcMOVEPOINTDOWN = 94,
AcREMOVEPOINT = 100,
AcREMOVE = 101,
AcREMOVELINE = 102,
AcREMOVEALL = 103,
AcREMOVESELECTEDSUBOBJECT = 104, // used in VesselGraphInteractor
AcWHEEL = 105,
AcPLUS = 106,
AcMINUS = 107,
AcDELETEPOINT = 120,
AcCLEAR = 130, // clear all elements from a list
AcINSERTPOINT = 110,
AcINSERTLINE = 111,
AC_SET_NEXT_BUTTON_VISIBLE = 5550001,
AC_SET_NEXT_BUTTON_INVISIBLE = 5550002,
AC_SET_PREVIOUS_BUTTON_VISIBLE = 5550003,
AC_SET_PREVIOUS_BUTTON_INVISIBLE = 5550004,
AC_SET_ASSISTAND_WIDGET_STECK = 5550005,
AC_SETMAX_COUNT_REF_POINTS = 5550006,
AC_SET_NEXT_BUTTON_TEXT = 5550007,
AC_CHECK_LANDMARK_COUNT = 5550008,
AC_SET_DONE_FALSE = 5550009,
AC_INIT = 55500010,
AC_SET_APPLICATION_SELECTED_FALSE = 55500011,
AC_SENSOR_ATTACHED = 55500012,
AC_CLOSE_ASSISTENT = 55500013,
AC_START_APPLICATION_TEXT = 55500014,
AC_START_NAVIGATION = 55500015,
AC_START_PATHCOLLECTION = 55500016,
AC_LOAD_LANDMARKS = 55500017,
AC_CALCULATE_LANDMARK_TRANSFORM = 55500018,
AcTERMINATE_INTERACTION = 666,
AcTRANSLATESTART = 1000,
AcTRANSLATE = 1001,
AcSCALESTART = 1002,
AcSCALE = 1003,
AcROTATESTART = 1004,
AcROTATE = 1005,
AcINITAFFINEINTERACTIONS = 1006,
AcFINISHAFFINEINTERACTIONS = 1007,
AcTRANSLATEEND = 1008,
AcSCALEEND = 1009,
AcROTATEEND = 1010,
AcINITZOOM = 1011,
AcZOOM = 1012,
AcSCROLL = 1013,
AcLEVELWINDOW = 1014,
AcSCROLLMOUSEWHEEL = 1015,
AcSETSTARTPOINT = 1050,
AcMODEDESELECT = 1100, // set interactor in not selected mode
AcMODESELECT = 1101, // set interactor in selected mode
AcMODESUBSELECT = 1102, // set interacor in sub selected mode
AcINFORMLISTENERS = 1200,
AcASKINTERACTORS = 1201,
AcCHECKGREATERONE = 1500,
AcCHECKBOUNDINGBOX = 1510,
AcFORCESUBINTERACTORS = 1550,
AcSENDCOORDINATES = 1600,
AcTRANSMITEVENT = 2000, // to transmit an event to a lower Interactor/Statemachine
AcPERIPHERYSEARCH = 3000, // used in VesselGraphInteractor
AcROOTSEARCH = 3001, // used in VesselGraphInteractor
AcTHICKSTVESSELSEARCH = 3002, // used in VesselGraphInteractor
AcSHORTESTPATHSEARCH = 3003, // used in VesselGraphInteractor
AcSINGLE = 3004, // used in VesselGraphInteractor
AcATTRIBUTATION = 3005, // used in VesselGraphInteractor
AcDEFAULT = 3007, // used in VesselGraphInteractor
AcSETVESSELELEMENT = 3008, // used in VesselGraphInteractor
AcCHECKBARRIERSTATUS = 3010, // used in VesselGraphInteractor
AcUPDATEMESH = 1234, // For Shape Model Interaction
AcINCREASE = 49012,
AcDECREASE = 49013,
AcMODIFY = 49014,
AcUNDOUPDATE = 1236, // For restoring a mesh after an update
AcENTEROBJECT = 48000,
AcLEAVEOBJECT = 48001,
AcSWITCHOBJECT = 48002,
AcUPDATELINE = 48003,
AcINITLINE = 48004,
AcTERMINATELINE = 48005,
AcCREATEBOX = 48006,
AcCREATEOBJECTFROMLINE = 48007,
AcCANCEL = 48008,
AcACTIVATETOOL = 48009,
AcROTATEAROUNDPOINT1 = 49002,
AcROTATEAROUNDPOINT2 = 49003,
AcMOVEPOINT1 = 49004,
AcMOVEPOINT2 = 49005,
AcUPDATEPOINT = 49006,
AcUPDATERADIUSMOUSEWHEEL = 49007,
AcDISPLAYOPTIONS = 49009,
AcCYCLE = 49010,
AcACCEPT = 49011,
- AcONSPACENAVIGATORMOUSEINPUT = 4001, // On input of 3D Mouse
- AcONPACENAVIGATORKEYDOWN = 4002, // On input of 3D Mouse
- AcONWIIMOTEINPUT = 4003, // used for wiimote to signal IR input
- AcRESETVIEW = 4004, // used for wiimote to reset view
- AcONWIIMOTEBUTTONRELEASED = 4005, // stops the surface interaction
AcCHECKPOSITION = 5000,
AcINITIALIZECONTOUR = 5001,
AcCALCULATENEWSEGMENTATION_SP = 5002,
AcINTERACTOR = 5003,
AcCALCULATENEWSEGMENTATION_BB = 5004
};
/*
//!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!
//EventMechanism:
//If you change anything from here on, then change in mitkEventMapper.cpp (Array of constants) as well.
//!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!
*/
// Type of an Event;
enum EEventType
{
Type_None = 0, // invalid event
Type_Timer = 1, // timer event
Type_MouseButtonPress = 2, // mouse button pressed
Type_MouseButtonRelease = 3, // mouse button released
Type_MouseButtonDblClick = 4, // mouse button double click
Type_MouseMove = 5, // mouse move
Type_KeyPress = 6, // key pressed
Type_KeyRelease = 7, // key released
Type_FocusIn = 8, // keyboard focus received
Type_FocusOut = 9, // keyboard focus lost
Type_Enter = 10, // mouse enters widget
Type_Leave = 11, // mouse leaves widget
Type_Paint = 12, // paint widget
Type_Move = 13, // move widget
Type_Resize = 14, // resize widget
Type_Create = 15, // after object creation
Type_Destroy = 16, // during object destruction
Type_Show = 17, // widget is shown
Type_Hide = 18, // widget is hidden
Type_Close = 19, // request to close widget
Type_Quit = 20, // request to quit application
Type_Reparent = 21, // widget has been reparented
Type_ShowMinimized = 22, // widget is shown minimized
Type_ShowNormal = 23, // widget is shown normal
Type_WindowActivate = 24, // window was activated
Type_WindowDeactivate = 25, // window was deactivated
Type_ShowToParent = 26, // widget is shown to parent
Type_HideToParent = 27, // widget is hidden to parent
Type_ShowMaximized = 28, // widget is shown maximized
Type_ShowFullScreen = 29, // widget is shown full-screen
Type_Accel = 30, // accelerator event
Type_Wheel = 31, // wheel event
Type_AccelAvailable = 32, // accelerator available event
Type_CaptionChange = 33, // caption changed
Type_IconChange = 34, // icon changed
Type_ParentFontChange = 35, // parent font changed
Type_ApplicationFontChange = 36, // application font changed
Type_ParentPaletteChange = 37, // parent palette changed
Type_ApplicationPaletteChange = 38, // application palette changed
Type_PaletteChange = 39, // widget palette changed
Type_Clipboard = 40, // internal clipboard event
Type_Speech = 42, // reserved for speech input
Type_SockAct = 50, // socket activation
Type_AccelOverride = 51, // accelerator override event
Type_DeferredDelete = 52, // deferred delete event
Type_DragEnter = 60, // drag moves into widget
Type_DragMove = 61, // drag moves in widget
Type_DragLeave = 62, // drag leaves or is cancelled
Type_Drop = 63, // actual drop
Type_DragResponse = 64, // drag accepted/rejected
Type_ChildInserted = 70, // new child widget
Type_ChildRemoved = 71, // deleted child widget
Type_LayoutHint = 72, // child min/max size changed
Type_ShowWindowRequest = 73, // widget's window should be mapped
Type_ActivateControl = 80, // ActiveX activation
Type_DeactivateControl = 81, // ActiveX deactivation
Type_ContextMenu = 82, // context popup menu
Type_IMStart = 83, // input method composition start
Type_IMCompose = 84, // input method composition
Type_IMEnd = 85, // input method composition end
Type_Accessibility = 86, // accessibility information is requested
Type_TabletMove = 87, // Wacom tablet event
Type_LocaleChange = 88, // the system locale changed
Type_LanguageChange = 89, // the application language changed
Type_LayoutDirectionChange = 90, // the layout direction changed
Type_Style = 91, // internal style event
Type_TabletPress = 92, // tablet press
Type_TabletRelease = 93, // tablet release
Type_User = 1000, // first user event id
- Type_SpaceNavigatorInput = 1094, // 3D mouse input occurred
- Type_SpaceNavigatorKeyDown = 1095, // 3D mouse input occurred
- Type_WiiMoteInput = 1096, // WiiMote input occurred
- Type_WiiMoteButton = 1097, // WiiMote button pressed
Type_MaxUser = 65535
};
//##ButtonState
// mouse/keyboard state values
// QT combinations if MOUSEBUTTONRelease: left MouseButton + ControlButton: 0x201
enum EButtonStates
{
BS_NoButton = 0x0000,
BS_LeftButton = 0x0001,
BS_RightButton = 0x0002,
BS_MidButton = 0x0004,
BS_MouseButtonMask = 0x0007,
BS_ShiftButton = 0x0100,
BS_ControlButton = 0x0200,
BS_AltButton = 0x0400,
BS_MetaButton = 0x0800,
BS_KeyButtonMask = 0x0f00,
BS_Keypad = 0x4000
};
//##Key
enum EKeys
{
Key_Escape = 0x1000, // misc keys
Key_Tab = 0x1001,
Key_Backtab = 0x1002,
Key_BackTab = 0x1002, //= Key_Backtab
Key_Backspace = 0x1003,
Key_BackSpace = 0x1003, //= Key_Backspace
Key_Return = 0x1004,
Key_Enter = 0x1005,
Key_Insert = 0x1006,
Key_Delete = 0x1007,
Key_Pause = 0x1008,
Key_Print = 0x1009,
Key_SysReq = 0x100a,
Key_Home = 0x1010, // cursor movement
Key_End = 0x1011,
Key_Left = 0x1012,
Key_Up = 0x1013,
Key_Right = 0x1014,
Key_Down = 0x1015,
Key_Prior = 0x1016,
Key_PageUp = 0x1016, //=Key_Prior
Key_Next = 0x1017,
Key_PageDown = 0x1017, //=Key_Next
Key_Shift = 0x1020, // modifiers
Key_Control = 0x1021,
Key_Meta = 0x1022,
Key_Alt = 0x1023,
Key_CapsLock = 0x1024,
Key_NumLock = 0x1025,
Key_ScrollLock = 0x1026,
Key_F1 = 0x1030, // function keys
Key_F2 = 0x1031,
Key_F3 = 0x1032,
Key_F4 = 0x1033,
Key_F5 = 0x1034,
Key_F6 = 0x1035,
Key_F7 = 0x1036,
Key_F8 = 0x1037,
Key_F9 = 0x1038,
Key_F10 = 0x1039,
Key_F11 = 0x103a,
Key_F12 = 0x103b,
Key_F13 = 0x103c,
Key_F14 = 0x103d,
Key_F15 = 0x103e,
Key_F16 = 0x103f,
Key_F17 = 0x1040,
Key_F18 = 0x1041,
Key_F19 = 0x1042,
Key_F20 = 0x1043,
Key_F21 = 0x1044,
Key_F22 = 0x1045,
Key_F23 = 0x1046,
Key_F24 = 0x1047,
Key_F25 = 0x1048, // F25 .. F35 only on X11
Key_F26 = 0x1049,
Key_F27 = 0x104a,
Key_F28 = 0x104b,
Key_F29 = 0x104c,
Key_F30 = 0x104d,
Key_F31 = 0x104e,
Key_F32 = 0x104f,
Key_F33 = 0x1050,
Key_F34 = 0x1051,
Key_F35 = 0x1052,
Key_Super_L = 0x1053, // extra keys
Key_Super_R = 0x1054,
Key_Menu = 0x1055,
Key_Hyper_L = 0x1056,
Key_Hyper_R = 0x1057,
Key_Help = 0x1058,
// International input method support (X keycode - = 0xEE00)
// Only interesting if you are writing your own input method
Key_Muhenkan = 0x1122, // Cancel Conversion
Key_Henkan = 0x1123, // Start/Stop Conversion
Key_Hiragana_Katakana = 0x1127, // Hiragana/Katakana toggle
Key_Zenkaku_Hankaku = 0x112A, // Zenkaku/Hankaku toggle
Key_Space = 0x20, // 7 bit printable ASCII
Key_Any = 0x20, //= Key_Space
Key_Exclam = 0x21,
Key_QuoteDbl = 0x22,
Key_NumberSign = 0x23,
Key_Dollar = 0x24,
Key_Percent = 0x25,
Key_Ampersand = 0x26,
Key_Apostrophe = 0x27,
Key_ParenLeft = 0x28,
Key_ParenRight = 0x29,
Key_Asterisk = 0x2a,
Key_Plus = 0x2b,
Key_Comma = 0x2c,
Key_Minus = 0x2d,
Key_Period = 0x2e,
Key_Slash = 0x2f,
Key_0 = 0x30,
Key_1 = 0x31,
Key_2 = 0x32,
Key_3 = 0x33,
Key_4 = 0x34,
Key_5 = 0x35,
Key_6 = 0x36,
Key_7 = 0x37,
Key_8 = 0x38,
Key_9 = 0x39,
Key_Colon = 0x3a,
Key_Semicolon = 0x3b,
Key_Less = 0x3c,
Key_Equal = 0x3d,
Key_Greater = 0x3e,
Key_Question = 0x3f,
Key_At = 0x40,
Key_A = 0x41,
Key_B = 0x42,
Key_C = 0x43,
Key_D = 0x44,
Key_E = 0x45,
Key_F = 0x46,
Key_G = 0x47,
Key_H = 0x48,
Key_I = 0x49,
Key_J = 0x4a,
Key_K = 0x4b,
Key_L = 0x4c,
Key_M = 0x4d,
Key_N = 0x4e,
Key_O = 0x4f,
Key_P = 0x50,
Key_Q = 0x51,
Key_R = 0x52,
Key_S = 0x53,
Key_T = 0x54,
Key_U = 0x55,
Key_V = 0x56,
Key_W = 0x57,
Key_X = 0x58,
Key_Y = 0x59,
Key_Z = 0x5a,
Key_BracketLeft = 0x5b,
Key_Backslash = 0x5c,
Key_BracketRight = 0x5d,
Key_AsciiCircum = 0x5e,
Key_Underscore = 0x5f,
Key_QuoteLeft = 0x60,
Key_BraceLeft = 0x7b,
Key_Bar = 0x7c,
Key_BraceRight = 0x7d,
Key_AsciiTilde = 0x7e,
Key_nobreakspace = 0x0a0,
Key_exclamdown = 0x0a1,
Key_cent = 0x0a2,
Key_sterling = 0x0a3,
Key_currency = 0x0a4,
Key_yen = 0x0a5,
Key_brokenbar = 0x0a6,
Key_section = 0x0a7,
Key_diaeresis = 0x0a8,
Key_copyright = 0x0a9,
Key_ordfeminine = 0x0aa,
Key_guillemotleft = 0x0ab, // left angle quotation mark
Key_notsign = 0x0ac,
Key_hyphen = 0x0ad,
Key_registered = 0x0ae,
Key_macron = 0x0af,
Key_degree = 0x0b0,
Key_plusminus = 0x0b1,
Key_twosuperior = 0x0b2,
Key_threesuperior = 0x0b3,
Key_acute = 0x0b4,
Key_mu = 0x0b5,
Key_paragraph = 0x0b6,
Key_periodcentered = 0x0b7,
Key_cedilla = 0x0b8,
Key_onesuperior = 0x0b9,
Key_masculine = 0x0ba,
Key_guillemotright = 0x0bb, // right angle quotation mark
Key_onequarter = 0x0bc,
Key_onehalf = 0x0bd,
Key_threequarters = 0x0be,
Key_questiondown = 0x0bf,
Key_Agrave = 0x0c0,
Key_Aacute = 0x0c1,
Key_Acircumflex = 0x0c2,
Key_Atilde = 0x0c3,
Key_Adiaeresis = 0x0c4,
Key_Aring = 0x0c5,
Key_AE = 0x0c6,
Key_Ccedilla = 0x0c7,
Key_Egrave = 0x0c8,
Key_Eacute = 0x0c9,
Key_Ecircumflex = 0x0ca,
Key_Ediaeresis = 0x0cb,
Key_Igrave = 0x0cc,
Key_Iacute = 0x0cd,
Key_Icircumflex = 0x0ce,
Key_Idiaeresis = 0x0cf,
Key_ETH = 0x0d0,
Key_Ntilde = 0x0d1,
Key_Ograve = 0x0d2,
Key_Oacute = 0x0d3,
Key_Ocircumflex = 0x0d4,
Key_Otilde = 0x0d5,
Key_Odiaeresis = 0x0d6,
Key_multiply = 0x0d7,
Key_Ooblique = 0x0d8,
Key_Ugrave = 0x0d9,
Key_Uacute = 0x0da,
Key_Ucircumflex = 0x0db,
Key_Udiaeresis = 0x0dc,
Key_Yacute = 0x0dd,
Key_THORN = 0x0de,
Key_ssharp = 0x0df,
Key_agrave = 0x0e0,
Key_aacute = 0x0e1,
Key_acircumflex = 0x0e2,
Key_atilde = 0x0e3,
Key_adiaeresis = 0x0e4,
Key_aring = 0x0e5,
Key_ae = 0x0e6,
Key_ccedilla = 0x0e7,
Key_egrave = 0x0e8,
Key_eacute = 0x0e9,
Key_ecircumflex = 0x0ea,
Key_ediaeresis = 0x0eb,
Key_igrave = 0x0ec,
Key_iacute = 0x0ed,
Key_icircumflex = 0x0ee,
Key_idiaeresis = 0x0ef,
Key_eth = 0x0f0,
Key_ntilde = 0x0f1,
Key_ograve = 0x0f2,
Key_oacute = 0x0f3,
Key_ocircumflex = 0x0f4,
Key_otilde = 0x0f5,
Key_odiaeresis = 0x0f6,
Key_division = 0x0f7,
Key_oslash = 0x0f8,
Key_ugrave = 0x0f9,
Key_uacute = 0x0fa,
Key_ucircumflex = 0x0fb,
Key_udiaeresis = 0x0fc,
Key_yacute = 0x0fd,
Key_thorn = 0x0fe,
Key_ydiaeresis = 0x0ff,
Key_unknown = 0xffff,
Key_none = 0xffff //= Key_unknown
};
} // namespace mitk
#endif
diff --git a/Modules/Core/src/Rendering/mitkPointSetVtkMapper3D.cpp b/Modules/Core/src/Rendering/mitkPointSetVtkMapper3D.cpp
index 8c30df1c50..beafa5cc99 100644
--- a/Modules/Core/src/Rendering/mitkPointSetVtkMapper3D.cpp
+++ b/Modules/Core/src/Rendering/mitkPointSetVtkMapper3D.cpp
@@ -1,614 +1,594 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "mitkPointSetVtkMapper3D.h"
#include "mitkColorProperty.h"
#include "mitkDataNode.h"
#include "mitkPointSet.h"
#include "mitkProperties.h"
#include "mitkVtkPropRenderer.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
const mitk::PointSet *mitk::PointSetVtkMapper3D::GetInput()
{
return static_cast(GetDataNode()->GetData());
}
mitk::PointSetVtkMapper3D::PointSetVtkMapper3D()
: m_vtkSelectedPointList(nullptr),
m_vtkUnselectedPointList(nullptr),
m_VtkSelectedPolyDataMapper(nullptr),
m_VtkUnselectedPolyDataMapper(nullptr),
m_vtkTextList(nullptr),
m_NumberOfSelectedAdded(0),
m_NumberOfUnselectedAdded(0),
m_PointSize(1.0),
m_ContourRadius(0.5)
{
// propassembly
m_PointsAssembly = vtkSmartPointer::New();
// creating actors to be able to set transform
m_SelectedActor = vtkSmartPointer::New();
m_UnselectedActor = vtkSmartPointer::New();
m_ContourActor = vtkSmartPointer::New();
}
mitk::PointSetVtkMapper3D::~PointSetVtkMapper3D()
{
}
void mitk::PointSetVtkMapper3D::ReleaseGraphicsResources(vtkWindow *renWin)
{
m_PointsAssembly->ReleaseGraphicsResources(renWin);
m_SelectedActor->ReleaseGraphicsResources(renWin);
m_UnselectedActor->ReleaseGraphicsResources(renWin);
m_ContourActor->ReleaseGraphicsResources(renWin);
}
void mitk::PointSetVtkMapper3D::ReleaseGraphicsResources(mitk::BaseRenderer *renderer)
{
m_PointsAssembly->ReleaseGraphicsResources(renderer->GetRenderWindow());
m_SelectedActor->ReleaseGraphicsResources(renderer->GetRenderWindow());
m_UnselectedActor->ReleaseGraphicsResources(renderer->GetRenderWindow());
m_ContourActor->ReleaseGraphicsResources(renderer->GetRenderWindow());
}
void mitk::PointSetVtkMapper3D::CreateVTKRenderObjects()
{
m_vtkSelectedPointList = vtkSmartPointer::New();
m_vtkUnselectedPointList = vtkSmartPointer::New();
m_PointsAssembly->VisibilityOn();
if (m_PointsAssembly->GetParts()->IsItemPresent(m_SelectedActor))
m_PointsAssembly->RemovePart(m_SelectedActor);
if (m_PointsAssembly->GetParts()->IsItemPresent(m_UnselectedActor))
m_PointsAssembly->RemovePart(m_UnselectedActor);
if (m_PointsAssembly->GetParts()->IsItemPresent(m_ContourActor))
m_PointsAssembly->RemovePart(m_ContourActor);
- // exceptional displaying for PositionTracker -> MouseOrientationTool
- int mapperID;
- bool isInputDevice = false;
- if (this->GetDataNode()->GetBoolProperty("inputdevice", isInputDevice) && isInputDevice)
- {
- if (this->GetDataNode()->GetIntProperty("BaseRendererMapperID", mapperID) && mapperID == BaseRenderer::Standard3D)
- return; // The event for the PositionTracker came from the 3d widget and not needs to be displayed
- }
-
// get and update the PointSet
mitk::PointSet::Pointer input = const_cast(this->GetInput());
/* only update the input data, if the property tells us to */
bool update = true;
this->GetDataNode()->GetBoolProperty("updateDataOnRender", update);
if (update == true)
input->Update();
int timestep = this->GetTimestep();
mitk::PointSet::DataType::Pointer itkPointSet = input->GetPointSet(timestep);
if (itkPointSet.GetPointer() == nullptr)
{
m_PointsAssembly->VisibilityOff();
return;
}
// now fill selected and unselected pointList
// get size of Points in Property
m_PointSize = 2;
mitk::FloatProperty::Pointer pointSizeProp =
dynamic_cast(this->GetDataNode()->GetProperty("pointsize"));
if (pointSizeProp.IsNotNull())
m_PointSize = pointSizeProp->GetValue();
// get the property for creating a label onto every point only once
bool showLabel = true;
this->GetDataNode()->GetBoolProperty("show label", showLabel);
const char *pointLabel = nullptr;
if (showLabel)
{
if (dynamic_cast(this->GetDataNode()->GetPropertyList()->GetProperty("label")) != nullptr)
pointLabel =
dynamic_cast(this->GetDataNode()->GetPropertyList()->GetProperty("label"))->GetValue();
else
showLabel = false;
}
// whether or not to creat a "contour" - connecting lines between all the points
int nbPoints = itkPointSet->GetPointData()->Size();
bool makeContour = false;
this->GetDataNode()->GetBoolProperty("show contour", makeContour);
bool closeContour = false;
this->GetDataNode()->GetBoolProperty("close contour", closeContour);
int contourPointLimit = 0; // NO contour
if (makeContour)
{
if (closeContour)
contourPointLimit = nbPoints;
else
contourPointLimit = nbPoints - 1;
}
// build list of all positions for later transform in one go
mitk::PointSet::PointsContainer::Iterator pointsIter;
int ptIdx;
m_NumberOfSelectedAdded = 0;
m_NumberOfUnselectedAdded = 0;
vtkSmartPointer localPoints = vtkSmartPointer::New();
m_WorldPositions = vtkSmartPointer::New();
m_PointConnections = vtkSmartPointer::New(); // m_PointConnections between points
for (ptIdx = 0, pointsIter = itkPointSet->GetPoints()->Begin(); pointsIter != itkPointSet->GetPoints()->End();
pointsIter++, ptIdx++)
{
itk::Point currentPoint = pointsIter->Value();
localPoints->InsertPoint(ptIdx, currentPoint[0], currentPoint[1], currentPoint[2]);
if (makeContour && ptIdx < contourPointLimit)
{
vtkIdType cell[2] = {(ptIdx + 1) % nbPoints, ptIdx};
m_PointConnections->InsertNextCell(2, cell);
}
}
vtkSmartPointer vtktransform = this->GetDataNode()->GetVtkTransform(this->GetTimestep());
vtktransform->TransformPoints(localPoints, m_WorldPositions);
// create contour
if (makeContour)
{
this->CreateContour(m_WorldPositions, m_PointConnections);
}
// check if the list for the PointDataContainer is the same size as the PointsContainer. Is not, then the points were
// inserted manually and can not be visualized according to the PointData (selected/unselected)
bool pointDataBroken = (itkPointSet->GetPointData()->Size() != itkPointSet->GetPoints()->Size());
// now add an object for each point in data
mitk::PointSet::PointDataContainer::Iterator pointDataIter = itkPointSet->GetPointData()->Begin();
for (ptIdx = 0; ptIdx < nbPoints; ++ptIdx) // pointDataIter moved at end of loop
{
double currentPoint[3];
m_WorldPositions->GetPoint(ptIdx, currentPoint);
vtkSmartPointer source;
// check for the pointtype in data and decide which geom-object to take and then add to the selected or unselected
// list
int pointType;
if (itkPointSet->GetPointData()->size() == 0 || pointDataBroken)
pointType = mitk::PTUNDEFINED;
else
pointType = pointDataIter.Value().pointSpec;
switch (pointType)
{
case mitk::PTUNDEFINED:
{
vtkSmartPointer sphere = vtkSmartPointer::New();
sphere->SetRadius(m_PointSize / 2.0f);
sphere->SetCenter(currentPoint);
- // sphere->SetCenter(pointsIter.Value()[0],pointsIter.Value()[1],pointsIter.Value()[2]);
-
- // MouseOrientation Tool (PositionTracker)
- if (isInputDevice)
- {
- sphere->SetThetaResolution(10);
- sphere->SetPhiResolution(10);
- }
- else
- {
- sphere->SetThetaResolution(20);
- sphere->SetPhiResolution(20);
- }
+ sphere->SetThetaResolution(20);
+ sphere->SetPhiResolution(20);
source = sphere;
}
break;
case mitk::PTSTART:
{
vtkSmartPointer cube = vtkSmartPointer::New();
cube->SetXLength(m_PointSize / 2);
cube->SetYLength(m_PointSize / 2);
cube->SetZLength(m_PointSize / 2);
cube->SetCenter(currentPoint);
source = cube;
}
break;
case mitk::PTCORNER:
{
vtkSmartPointer cone = vtkSmartPointer::New();
cone->SetRadius(m_PointSize / 2.0f);
cone->SetCenter(currentPoint);
cone->SetResolution(20);
source = cone;
}
break;
case mitk::PTEDGE:
{
vtkSmartPointer cylinder = vtkSmartPointer::New();
cylinder->SetRadius(m_PointSize / 2.0f);
cylinder->SetCenter(currentPoint);
cylinder->SetResolution(20);
source = cylinder;
}
break;
case mitk::PTEND:
{
vtkSmartPointer sphere = vtkSmartPointer::New();
sphere->SetRadius(m_PointSize / 2.0f);
// no SetCenter?? this functionality should be explained!
// otherwise: join with default block!
sphere->SetThetaResolution(20);
sphere->SetPhiResolution(20);
source = sphere;
}
break;
default:
{
vtkSmartPointer sphere = vtkSmartPointer::New();
sphere->SetRadius(m_PointSize / 2.0f);
sphere->SetCenter(currentPoint);
sphere->SetThetaResolution(20);
sphere->SetPhiResolution(20);
source = sphere;
}
break;
}
if (pointDataIter.Value().selected && !pointDataBroken)
{
m_vtkSelectedPointList->AddInputConnection(source->GetOutputPort());
++m_NumberOfSelectedAdded;
}
else
{
m_vtkUnselectedPointList->AddInputConnection(source->GetOutputPort());
++m_NumberOfUnselectedAdded;
}
if (showLabel)
{
char buffer[20];
std::string l = pointLabel;
if (input->GetSize() > 1)
{
sprintf(buffer, "%d", ptIdx + 1);
l.append(buffer);
}
// Define the text for the label
vtkSmartPointer label = vtkSmartPointer::New();
label->SetText(l.c_str());
//# Set up a transform to move the label to a new position.
vtkSmartPointer aLabelTransform = vtkSmartPointer::New();
aLabelTransform->Identity();
aLabelTransform->Translate(currentPoint[0] + 2, currentPoint[1] + 2, currentPoint[2]);
aLabelTransform->Scale(5.7, 5.7, 5.7);
//# Move the label to a new position.
vtkSmartPointer labelTransform = vtkSmartPointer::New();
labelTransform->SetTransform(aLabelTransform);
labelTransform->SetInputConnection(label->GetOutputPort());
// add it to the wright PointList
if (pointType)
{
m_vtkSelectedPointList->AddInputConnection(labelTransform->GetOutputPort());
++m_NumberOfSelectedAdded;
}
else
{
m_vtkUnselectedPointList->AddInputConnection(labelTransform->GetOutputPort());
++m_NumberOfUnselectedAdded;
}
}
if (pointDataIter != itkPointSet->GetPointData()->End())
pointDataIter++;
} // end FOR
// now according to number of elements added to selected or unselected, build up the rendering pipeline
if (m_NumberOfSelectedAdded > 0)
{
m_VtkSelectedPolyDataMapper = vtkSmartPointer::New();
m_VtkSelectedPolyDataMapper->SetInputConnection(m_vtkSelectedPointList->GetOutputPort());
// create a new instance of the actor
m_SelectedActor = vtkSmartPointer::New();
m_SelectedActor->SetMapper(m_VtkSelectedPolyDataMapper);
m_PointsAssembly->AddPart(m_SelectedActor);
}
if (m_NumberOfUnselectedAdded > 0)
{
m_VtkUnselectedPolyDataMapper = vtkSmartPointer::New();
m_VtkUnselectedPolyDataMapper->SetInputConnection(m_vtkUnselectedPointList->GetOutputPort());
// create a new instance of the actor
m_UnselectedActor = vtkSmartPointer::New();
m_UnselectedActor->SetMapper(m_VtkUnselectedPolyDataMapper);
m_PointsAssembly->AddPart(m_UnselectedActor);
}
}
void mitk::PointSetVtkMapper3D::GenerateDataForRenderer(mitk::BaseRenderer *renderer)
{
bool visible = true;
GetDataNode()->GetVisibility(visible, renderer, "visible");
if (!visible)
{
m_UnselectedActor->VisibilityOff();
m_SelectedActor->VisibilityOff();
m_ContourActor->VisibilityOff();
return;
}
// create new vtk render objects (e.g. sphere for a point)
BaseLocalStorage *ls = m_LSH.GetLocalStorage(renderer);
bool needGenerateData = ls->IsGenerateDataRequired(renderer, this, GetDataNode());
if (!needGenerateData)
{
if (this->GetDataNode()->GetPropertyList()->GetMTime() > ls->GetLastGenerateDataTime() ||
this->GetDataNode()->GetPropertyList(renderer)->GetMTime() > ls->GetLastGenerateDataTime())
{
needGenerateData = true;
}
}
if (needGenerateData)
{
this->CreateVTKRenderObjects();
ls->UpdateGenerateDataTime();
}
this->ApplyAllProperties(renderer, m_ContourActor);
bool showPoints = true;
this->GetDataNode()->GetBoolProperty("show points", showPoints);
m_UnselectedActor->SetVisibility(showPoints);
m_SelectedActor->SetVisibility(showPoints);
if (false && dynamic_cast(this->GetDataNode()->GetProperty("opacity")) != nullptr)
{
mitk::FloatProperty::Pointer pointOpacity =
dynamic_cast(this->GetDataNode()->GetProperty("opacity"));
float opacity = pointOpacity->GetValue();
m_ContourActor->GetProperty()->SetOpacity(opacity);
m_UnselectedActor->GetProperty()->SetOpacity(opacity);
m_SelectedActor->GetProperty()->SetOpacity(opacity);
}
bool showContour = false;
this->GetDataNode()->GetBoolProperty("show contour", showContour);
m_ContourActor->SetVisibility(showContour);
}
void mitk::PointSetVtkMapper3D::ResetMapper(BaseRenderer * /*renderer*/)
{
m_PointsAssembly->VisibilityOff();
}
vtkProp *mitk::PointSetVtkMapper3D::GetVtkProp(mitk::BaseRenderer * /*renderer*/)
{
return m_PointsAssembly;
}
void mitk::PointSetVtkMapper3D::UpdateVtkTransform(mitk::BaseRenderer * /*renderer*/)
{
}
void mitk::PointSetVtkMapper3D::ApplyAllProperties(mitk::BaseRenderer *renderer, vtkActor *actor)
{
Superclass::ApplyColorAndOpacityProperties(renderer, actor);
// check for color props and use it for rendering of selected/unselected points and contour
// due to different params in VTK (double/float) we have to convert!
// vars to convert to
double unselectedColor[4] = {1.0f, 1.0f, 0.0f, 1.0f}; // yellow
double selectedColor[4] = {1.0f, 0.0f, 0.0f, 1.0f}; // red
double contourColor[4] = {1.0f, 0.0f, 0.0f, 1.0f}; // red
// different types for color!!!
mitk::Color tmpColor;
double opacity = 1.0;
// check if there is an unselected property
if (dynamic_cast(
this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor")) != nullptr)
{
tmpColor = dynamic_cast(
this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor"))
->GetValue();
unselectedColor[0] = tmpColor[0];
unselectedColor[1] = tmpColor[1];
unselectedColor[2] = tmpColor[2];
unselectedColor[3] = 1.0f; //!!define a new ColorProp to be able to pass alpha value
}
else if (dynamic_cast(
this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("unselectedcolor")) != nullptr)
{
tmpColor =
dynamic_cast(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("unselectedcolor"))
->GetValue();
unselectedColor[0] = tmpColor[0];
unselectedColor[1] = tmpColor[1];
unselectedColor[2] = tmpColor[2];
unselectedColor[3] = 1.0f; //!!define a new ColorProp to be able to pass alpha value
}
else
{
// check if the node has a color
float unselectedColorTMP[4] = {1.0f, 1.0f, 0.0f, 1.0f}; // yellow
m_DataNode->GetColor(unselectedColorTMP, nullptr);
unselectedColor[0] = unselectedColorTMP[0];
unselectedColor[1] = unselectedColorTMP[1];
unselectedColor[2] = unselectedColorTMP[2];
// unselectedColor[3] stays 1.0f
}
// get selected property
if (dynamic_cast(
this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor")) != nullptr)
{
tmpColor =
dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor"))
->GetValue();
selectedColor[0] = tmpColor[0];
selectedColor[1] = tmpColor[1];
selectedColor[2] = tmpColor[2];
selectedColor[3] = 1.0f;
}
else if (dynamic_cast(
this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("selectedcolor")) != nullptr)
{
tmpColor =
dynamic_cast(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("selectedcolor"))
->GetValue();
selectedColor[0] = tmpColor[0];
selectedColor[1] = tmpColor[1];
selectedColor[2] = tmpColor[2];
selectedColor[3] = 1.0f;
}
// get contour property
if (dynamic_cast(
this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor")) != nullptr)
{
tmpColor =
dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor"))
->GetValue();
contourColor[0] = tmpColor[0];
contourColor[1] = tmpColor[1];
contourColor[2] = tmpColor[2];
contourColor[3] = 1.0f;
}
else if (dynamic_cast(
this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("contourcolor")) != nullptr)
{
tmpColor =
dynamic_cast(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("contourcolor"))
->GetValue();
contourColor[0] = tmpColor[0];
contourColor[1] = tmpColor[1];
contourColor[2] = tmpColor[2];
contourColor[3] = 1.0f;
}
if (dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity")) !=
nullptr)
{
mitk::FloatProperty::Pointer pointOpacity =
dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity"));
opacity = pointOpacity->GetValue();
}
else if (dynamic_cast(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("opacity")) !=
nullptr)
{
mitk::FloatProperty::Pointer pointOpacity =
dynamic_cast(this->GetDataNode()->GetPropertyList(nullptr)->GetProperty("opacity"));
opacity = pointOpacity->GetValue();
}
// finished color / opacity fishing!
// check if a contour shall be drawn
bool showContour = false;
this->GetDataNode()->GetBoolProperty("show contour", showContour, renderer);
if (showContour && (m_ContourActor != nullptr))
{
this->CreateContour(m_WorldPositions, m_PointConnections);
m_ContourActor->GetProperty()->SetColor(contourColor);
m_ContourActor->GetProperty()->SetOpacity(opacity);
}
m_SelectedActor->GetProperty()->SetColor(selectedColor);
m_SelectedActor->GetProperty()->SetOpacity(opacity);
m_UnselectedActor->GetProperty()->SetColor(unselectedColor);
m_UnselectedActor->GetProperty()->SetOpacity(opacity);
}
void mitk::PointSetVtkMapper3D::CreateContour(vtkPoints *points, vtkCellArray *m_PointConnections)
{
vtkSmartPointer vtkContourPolyData = vtkSmartPointer::New();
vtkSmartPointer vtkContourPolyDataMapper = vtkSmartPointer::New();
vtkSmartPointer contour = vtkSmartPointer::New();
contour->SetPoints(points);
contour->SetLines(m_PointConnections);
vtkSmartPointer tubeFilter = vtkSmartPointer::New();
tubeFilter->SetNumberOfSides(12);
tubeFilter->SetInputData(contour);
// check for property contoursize.
m_ContourRadius = 0.5;
mitk::FloatProperty::Pointer contourSizeProp =
dynamic_cast(this->GetDataNode()->GetProperty("contoursize"));
if (contourSizeProp.IsNotNull())
m_ContourRadius = contourSizeProp->GetValue();
tubeFilter->SetRadius(m_ContourRadius);
tubeFilter->Update();
// add to pipeline
vtkContourPolyData->AddInputConnection(tubeFilter->GetOutputPort());
vtkContourPolyDataMapper->SetInputConnection(vtkContourPolyData->GetOutputPort());
m_ContourActor->SetMapper(vtkContourPolyDataMapper);
m_PointsAssembly->AddPart(m_ContourActor);
}
void mitk::PointSetVtkMapper3D::SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer, bool overwrite)
{
node->AddProperty("line width", mitk::IntProperty::New(2), renderer, overwrite);
node->AddProperty("pointsize", mitk::FloatProperty::New(1.0), renderer, overwrite);
node->AddProperty("selectedcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite); // red
node->AddProperty("color", mitk::ColorProperty::New(1.0f, 1.0f, 0.0f), renderer, overwrite); // yellow
node->AddProperty("opacity", mitk::FloatProperty::New(1.0f), renderer, overwrite);
node->AddProperty("show contour", mitk::BoolProperty::New(false), renderer, overwrite);
node->AddProperty("close contour", mitk::BoolProperty::New(false), renderer, overwrite);
node->AddProperty("contourcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite);
node->AddProperty("contoursize", mitk::FloatProperty::New(0.5), renderer, overwrite);
node->AddProperty("show points", mitk::BoolProperty::New(true), renderer, overwrite);
node->AddProperty("updateDataOnRender", mitk::BoolProperty::New(true), renderer, overwrite);
Superclass::SetDefaultProperties(node, renderer, overwrite);
}
diff --git a/Modules/Core/src/Rendering/mitkVideoRecorder.cpp b/Modules/Core/src/Rendering/mitkVideoRecorder.cpp
index 117946b90f..064c0efd5a 100644
--- a/Modules/Core/src/Rendering/mitkVideoRecorder.cpp
+++ b/Modules/Core/src/Rendering/mitkVideoRecorder.cpp
@@ -1,391 +1,409 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
std::string mitk::VideoRecorder::GetFileExtension(OutputFormat format)
{
switch (format)
{
case OutputFormat::WebM_VP9:
return ".webm";
case OutputFormat::MP4_H264:
return ".mp4";
default:
break;
}
mitkThrow() << "Unknown output format for video recording.";
}
namespace
{
mitk::IPreferences* GetPreferences()
{
auto* preferencesService = mitk::CoreServices::GetPreferencesService();
return preferencesService->GetSystemPreferences()->Node("org.mitk.views.moviemaker");
}
class RecordingSession
{
public:
RecordingSession(vtkRenderWindow* renderWindow, mitk::VideoRecorder::OutputFormat format)
: m_FrameDir(mitk::IOUtil::CreateTemporaryDirectory("MITK_RecordingSession_XXXXXX")),
m_NumberOfFrames(0)
{
m_WindowToImageFilter->SetInput(renderWindow);
if (mitk::VideoRecorder::OutputFormat::MP4_H264 == format)
{
// H.264 only supports image dimensions that are a multiple of 2. Resize if necessary.
auto* size = renderWindow->GetActualSize();
if (size[0] & 1 || size[1] & 1)
{
m_ImageResize->SetInputConnection(m_WindowToImageFilter->GetOutputPort());
m_ImageResize->SetOutputDimensions(size[0] & ~1, size[1] & ~1, -1);
m_ImageResize->SetInterpolate(0);
m_ImageResize->BorderOn();
m_ImageWriter->SetInputConnection(m_ImageResize->GetOutputPort());
return;
}
}
m_ImageWriter->SetInputConnection(m_WindowToImageFilter->GetOutputPort());
}
~RecordingSession()
{
std::error_code errorCode;
std::filesystem::remove_all(m_FrameDir, errorCode);
}
RecordingSession(const RecordingSession&) = delete;
RecordingSession& operator=(const RecordingSession&) = delete;
std::filesystem::path GetFrameDir() const
{
return m_FrameDir;
}
void RecordFrame()
{
m_WindowToImageFilter->Modified();
std::stringstream frameFilename;
frameFilename << std::setw(6) << std::setfill('0') << m_NumberOfFrames << ".png";
const auto framePath = m_FrameDir / frameFilename.str();
m_ImageWriter->SetFileName(framePath.string().c_str());
m_ImageWriter->Write();
++m_NumberOfFrames;
}
private:
std::filesystem::path m_FrameDir;
unsigned int m_NumberOfFrames;
vtkNew m_WindowToImageFilter;
vtkNew m_ImageResize;
vtkNew m_ImageWriter;
};
}
namespace mitk
{
class VideoRecorder::Impl
{
public:
Impl()
: m_FrameRate(30)
{
}
~Impl() = default;
Impl(const Impl&) = delete;
Impl& operator=(const Impl&) = delete;
std::filesystem::path GetFFmpegPath() const
{
if (m_FFmpegPath)
return m_FFmpegPath.value();
auto* preferences = GetPreferences();
if (nullptr != preferences)
{
auto ffmpegPath = preferences->Get("ffmpeg", "");
if (!ffmpegPath.empty())
return ffmpegPath;
}
return std::filesystem::path();
}
void SetFFmpegPath(const std::filesystem::path& path)
{
m_FFmpegPath = path;
}
std::filesystem::path GetOutputPath() const
{
return m_OutputPath;
}
void SetOutputPath(const std::filesystem::path& path)
{
m_OutputPath = path;
}
mitk::VideoRecorder::OutputFormat GetOutputFormat() const
{
if (m_OutputFormat)
return m_OutputFormat.value();
auto* preferences = GetPreferences();
if (nullptr != preferences)
return static_cast(preferences->GetInt("format", 0));
return OutputFormat::WebM_VP9;
}
void SetOutputFormat(OutputFormat format)
{
m_OutputFormat = format;
}
std::string GetRenderWindowName() const
{
return m_RenderWindowName;
}
void SetRenderWindowName(const std::string& renderWindowName)
{
m_RenderWindowName = renderWindowName;
}
int GetFrameRate() const
{
return m_FrameRate;
}
void SetFrameRate(unsigned int fps)
{
m_FrameRate = fps;
}
bool OnAir() const
{
return nullptr != m_RecordingSession.get();
}
void StartRecording()
{
if (this->OnAir())
mitkThrow() << "Recording session already running.";
auto renderWindowName = this->GetRenderWindowName();
if (renderWindowName.empty())
mitkThrow() << "No render window specified for recording.";
auto* renderWindow = BaseRenderer::GetRenderWindowByName(renderWindowName);
if (nullptr == renderWindow)
mitkThrow() << "\"" << renderWindowName << "\" references unknown render window for recording.";
m_RecordingSession = std::make_unique(renderWindow, this->GetOutputFormat());
}
void RecordFrame()
{
if (!this->OnAir())
mitkThrow() << "Cannot record frame. No recording session running.";
m_RecordingSession->RecordFrame();
}
std::string GetFFmpegCommandLine() const
{
bool vp9 = OutputFormat::WebM_VP9 == this->GetOutputFormat();
std::stringstream stream;
- stream << this->GetFFmpegPath()
+ stream << this->GetFFmpegPath() << ' '
<< "-y" << ' '
<< "-r " << std::to_string(this->GetFrameRate()) << ' '
<< "-i %6d.png" << ' '
<< "-c:v " << (vp9 ? "libvpx-vp9" : "libx264") << ' '
<< "-crf " << (vp9 ? "31" : "23") << ' '
<< "-pix_fmt yuv420p" << ' '
<< "-b:v 0" << ' '
<< this->GetOutputPath();
return stream.str();
}
int ExecuteFFmpeg() const
{
auto commandLine = this->GetFFmpegCommandLine();
auto commandLineCStr = commandLine.c_str();
auto workingDirectory = m_RecordingSession->GetFrameDir().string();
auto* ffmpeg = itksysProcess_New();
itksysProcess_SetOption(ffmpeg, itksysProcess_Option_Verbatim, 1);
itksysProcess_SetCommand(ffmpeg, &commandLineCStr);
itksysProcess_SetWorkingDirectory(ffmpeg, workingDirectory.c_str());
itksysProcess_Execute(ffmpeg);
itksysProcess_WaitForExit(ffmpeg, nullptr);
- if (itksysProcess_State_Exited != itksysProcess_GetState(ffmpeg))
+ auto state = itksysProcess_GetState(ffmpeg);
+
+ if (itksysProcess_State_Exited != state)
{
+ std::stringstream message;
+ message << "FFmpeg process did not exit as expected: ";
+
+ if (itksysProcess_State_Error == state)
+ {
+ message << itksysProcess_GetErrorString(ffmpeg);
+ }
+ else if (itksysProcess_State_Exception == state)
+ {
+ message << itksysProcess_GetExceptionString(ffmpeg);
+ }
+
+ message << "\n Command: " << commandLineCStr;
+ message << "\n Working directory: " << workingDirectory.c_str();
+
itksysProcess_Delete(ffmpeg);
- mitkThrow() << "FFmpeg process did not exit as expected.";
+
+ mitkThrow() << message.str();
}
auto exitCode = itksysProcess_GetExitValue(ffmpeg);
itksysProcess_Delete(ffmpeg);
return exitCode;
}
int StopRecording()
{
if (!this->OnAir())
mitkThrow() << "No recording session running.";
if (this->GetFFmpegPath().empty())
mitkThrow() << "Path to FFmpeg not set.";
if (this->GetOutputPath().empty())
mitkThrow() << "Path to output video file not set.";
auto exitCode = this->ExecuteFFmpeg();
m_RecordingSession = nullptr;
return exitCode;
}
private:
std::optional m_FFmpegPath;
std::filesystem::path m_OutputPath;
std::optional m_OutputFormat;
std::string m_RenderWindowName;
unsigned int m_FrameRate;
std::unique_ptr m_RecordingSession;
};
}
mitk::VideoRecorder::VideoRecorder()
: m_Impl(std::make_unique())
{
}
mitk::VideoRecorder::~VideoRecorder()
{
}
std::filesystem::path mitk::VideoRecorder::GetFFmpegPath() const
{
return m_Impl->GetFFmpegPath();
}
void mitk::VideoRecorder::SetFFmpegPath(const std::filesystem::path& path)
{
m_Impl->SetFFmpegPath(path);
}
std::filesystem::path mitk::VideoRecorder::GetOutputPath() const
{
return m_Impl->GetOutputPath();
}
void mitk::VideoRecorder::SetOutputPath(const std::filesystem::path& path)
{
m_Impl->SetOutputPath(path);
}
mitk::VideoRecorder::OutputFormat mitk::VideoRecorder::GetOutputFormat() const
{
return m_Impl->GetOutputFormat();
}
void mitk::VideoRecorder::SetOutputFormat(OutputFormat format)
{
m_Impl->SetOutputFormat(format);
}
std::string mitk::VideoRecorder::GetRenderWindowName() const
{
return m_Impl->GetRenderWindowName();
}
void mitk::VideoRecorder::SetRenderWindowName(const std::string& renderWindowName)
{
m_Impl->SetRenderWindowName(renderWindowName);
}
int mitk::VideoRecorder::GetFrameRate() const
{
return m_Impl->GetFrameRate();
}
void mitk::VideoRecorder::SetFrameRate(unsigned int fps)
{
m_Impl->SetFrameRate(fps);
}
void mitk::VideoRecorder::StartRecording()
{
m_Impl->StartRecording();
}
void mitk::VideoRecorder::RecordFrame() const
{
m_Impl->RecordFrame();
}
int mitk::VideoRecorder::StopRecording()
{
return m_Impl->StopRecording();
}
diff --git a/Modules/Multilabel/mitkLabelSetImage.cpp b/Modules/Multilabel/mitkLabelSetImage.cpp
index 5dabaf8adb..48cfd421c1 100644
--- a/Modules/Multilabel/mitkLabelSetImage.cpp
+++ b/Modules/Multilabel/mitkLabelSetImage.cpp
@@ -1,1553 +1,1562 @@
/*============================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.
Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.
============================================================================*/
#include "mitkLabelSetImage.h"
#include "mitkImageAccessByItk.h"
#include "mitkImageCast.h"
#include "mitkImagePixelReadAccessor.h"
#include "mitkImagePixelWriteAccessor.h"
#include "mitkInteractionConst.h"
#include "mitkLookupTableProperty.h"
#include "mitkPadImageFilter.h"
#include "mitkRenderingManager.h"
#include "mitkDICOMSegmentationPropertyHelper.h"
#include "mitkDICOMQIPropertyHelper.h"
#include
#include
#include
#include
#include
#include
#include
//#include
#include
#include
template
void SetToZero(itk::Image *source)
{
source->FillBuffer(0);
}
template
void CreateLabelMaskProcessing(mitk::Image *layerImage, mitk::Image *mask, mitk::LabelSet::PixelType index)
{
mitk::ImagePixelReadAccessor readAccessor(layerImage);
mitk::ImagePixelWriteAccessor writeAccessor(mask);
std::size_t numberOfPixels = 1;
for (int dim = 0; dim < static_cast(VImageDimension); ++dim)
numberOfPixels *= static_cast(readAccessor.GetDimension(dim));
auto src = readAccessor.GetData();
auto dest = writeAccessor.GetData();
for (std::size_t i = 0; i < numberOfPixels; ++i)
{
if (index == *(src + i))
*(dest + i) = 1;
}
}
mitk::LabelSetImage::LabelSetImage()
: mitk::Image(), m_UnlabeledLabelLock(false), m_ActiveLayer(0), m_activeLayerInvalid(false)
{
// Add some DICOM Tags as properties to segmentation image
DICOMSegmentationPropertyHelper::DeriveDICOMSegmentationProperties(this);
}
mitk::LabelSetImage::LabelSetImage(const mitk::LabelSetImage &other)
: Image(other),
m_UnlabeledLabelLock(other.m_UnlabeledLabelLock),
m_ActiveLayer(other.GetActiveLayer()),
m_activeLayerInvalid(false)
{
for (unsigned int i = 0; i < other.GetNumberOfLayers(); i++)
{
// Clone LabelSet data
mitk::LabelSet::Pointer lsClone = other.GetLabelSet(i)->Clone();
this->RegisterLabelSet(lsClone);
m_LabelSetContainer.push_back(lsClone);
// clone layer Image data
mitk::Image::Pointer liClone = other.GetLayerImage(i)->Clone();
m_LayerContainer.push_back(liClone);
}
+ this->ReinitMaps();
+
// Add some DICOM Tags as properties to segmentation image
DICOMSegmentationPropertyHelper::DeriveDICOMSegmentationProperties(this);
}
void mitk::LabelSetImage::OnLabelSetModified()
{
Superclass::Modified();
}
void mitk::LabelSetImage::Initialize(const mitk::Image *other)
{
mitk::PixelType pixelType(mitk::MakeScalarPixelType());
if (other->GetDimension() == 2)
{
const unsigned int dimensions[] = {other->GetDimension(0), other->GetDimension(1), 1};
Superclass::Initialize(pixelType, 3, dimensions);
}
else
{
Superclass::Initialize(pixelType, other->GetDimension(), other->GetDimensions());
}
auto originalGeometry = other->GetTimeGeometry()->Clone();
this->SetTimeGeometry(originalGeometry);
// initialize image memory to zero
if (4 == this->GetDimension())
{
AccessFixedDimensionByItk(this, SetToZero, 4);
}
else
{
AccessByItk(this, SetToZero);
}
// Transfer some general DICOM properties from the source image to derived image (e.g. Patient information,...)
DICOMQIPropertyHelper::DeriveDICOMSourceProperties(other, this);
// Add a inital LabelSet ans corresponding image data to the stack
if (this->GetNumberOfLayers() == 0)
{
AddLayer();
}
}
mitk::LabelSetImage::~LabelSetImage()
{
for (auto ls : m_LabelSetContainer)
{
this->ReleaseLabelSet(ls);
}
m_LabelSetContainer.clear();
}
mitk::Image *mitk::LabelSetImage::GetLayerImage(unsigned int layer)
{
return m_LayerContainer[layer];
}
const mitk::Image *mitk::LabelSetImage::GetLayerImage(unsigned int layer) const
{
return m_LayerContainer[layer];
}
unsigned int mitk::LabelSetImage::GetActiveLayer() const
{
return m_ActiveLayer;
}
unsigned int mitk::LabelSetImage::GetNumberOfLayers() const
{
return m_LabelSetContainer.size();
}
void mitk::LabelSetImage::RegisterLabelSet(mitk::LabelSet* ls)
{
// add modified event listener to LabelSet (listen to LabelSet changes)
itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New();
command->SetCallbackFunction(this, &mitk::LabelSetImage::OnLabelSetModified);
ls->AddObserver(itk::ModifiedEvent(), command);
ls->AddLabelEvent.AddListener(mitk::MessageDelegate1(
this, &LabelSetImage::OnLabelAdded));
ls->ModifyLabelEvent.AddListener(mitk::MessageDelegate1(
this, &LabelSetImage::OnLabelModified));
ls->RemoveLabelEvent.AddListener(mitk::MessageDelegate1(
this, &LabelSetImage::OnLabelRemoved));
ls->m_ReservedLabelValuesFunctor = [this]() {return this->GetUsedLabelValues(); };
}
void mitk::LabelSetImage::ReleaseLabelSet(mitk::LabelSet* ls)
{
ls->RemoveAllObservers();
ls->AddLabelEvent.RemoveListener(mitk::MessageDelegate1(
this, &LabelSetImage::OnLabelAdded));
ls->ModifyLabelEvent.RemoveListener(mitk::MessageDelegate1(
this, &LabelSetImage::OnLabelModified));
ls->RemoveLabelEvent.RemoveListener(mitk::MessageDelegate1(
this, &LabelSetImage::OnLabelRemoved));
ls->m_ReservedLabelValuesFunctor = nullptr;
}
void mitk::LabelSetImage::RemoveLayer()
{
int layerToDelete = GetActiveLayer();
// remove all observers from active label set
GetLabelSet(layerToDelete)->RemoveAllObservers();
// set the active layer to one below, if exists.
if (layerToDelete != 0)
{
SetActiveLayer(layerToDelete - 1);
}
else
{
// we are deleting layer zero, it should not be copied back into the vector
m_activeLayerInvalid = true;
}
// remove labelset and image data
m_LabelSetContainer.erase(m_LabelSetContainer.begin() + layerToDelete);
m_LayerContainer.erase(m_LayerContainer.begin() + layerToDelete);
if (layerToDelete == 0)
{
this->SetActiveLayer(layerToDelete);
}
this->OnGroupRemoved(layerToDelete);
this->Modified();
}
void mitk::LabelSetImage::RemoveGroup(GroupIndexType indexToDelete)
{
const auto activeIndex = GetActiveLayer();
// remove all observers from active label set
GetLabelSet(indexToDelete)->RemoveAllObservers();
// set the active layer to one below, if exists.
if (activeIndex>indexToDelete)
{
SetActiveLayer(activeIndex - 1);
}
else if (activeIndex==indexToDelete)
{
// we are deleting layer zero, it should not be copied back into the vector
m_activeLayerInvalid = true;
}
// remove labelset and image data
m_LabelSetContainer.erase(m_LabelSetContainer.begin() + indexToDelete);
m_LayerContainer.erase(m_LayerContainer.begin() + indexToDelete);
if (indexToDelete == activeIndex)
{ //enforces the new active layer to be set and copied
auto newActiveIndex = indexToDelete < GetNumberOfLayers() ? indexToDelete : GetNumberOfLayers() - 1;
this->SetActiveLayer(newActiveIndex);
}
this->OnGroupRemoved(indexToDelete);
this->Modified();
}
mitk::LabelSetImage::LabelValueVectorType mitk::LabelSetImage::GetUsedLabelValues() const
{
LabelValueVectorType result = { UnlabeledValue };
for (auto [value, label] : m_LabelMap)
{
result.emplace_back(value);
}
return result;
}
unsigned int mitk::LabelSetImage::AddLayer(mitk::LabelSet::Pointer labelSet)
{
mitk::Image::Pointer newImage = mitk::Image::New();
newImage->Initialize(this->GetPixelType(),
this->GetDimension(),
this->GetDimensions(),
this->GetImageDescriptor()->GetNumberOfChannels());
newImage->SetTimeGeometry(this->GetTimeGeometry()->Clone());
if (newImage->GetDimension() < 4)
{
AccessByItk(newImage, SetToZero);
}
else
{
AccessFixedDimensionByItk(newImage, SetToZero, 4);
}
return this->AddLayer(newImage, labelSet);
}
unsigned int mitk::LabelSetImage::AddLayer(mitk::Image::Pointer layerImage, mitk::LabelSet::Pointer labelSet)
{
unsigned int newLabelSetId = m_LayerContainer.size();
// Add labelset to layer
mitk::LabelSet::Pointer ls;
if (labelSet.IsNotNull())
{
ls = labelSet;
}
else
{
ls = mitk::LabelSet::New();
ls->SetActiveLabel(UnlabeledValue);
}
ls->SetLayer(newLabelSetId);
// push a new working image for the new layer
m_LayerContainer.push_back(layerImage);
// push a new labelset for the new layer
m_LabelSetContainer.push_back(ls);
RegisterLabelSet(ls);
this->ReinitMaps();
SetActiveLayer(newLabelSetId);
this->Modified();
this->OnGroupAdded(newLabelSetId);
return newLabelSetId;
}
void mitk::LabelSetImage::AddLabelSetToLayer(const unsigned int layerIdx, const mitk::LabelSet* labelSet)
{
if (m_LayerContainer.size() <= layerIdx)
{
mitkThrow() << "Trying to add labelSet to non-existing layer.";
}
auto clonedLabelSet = labelSet->Clone();
this->RegisterLabelSet(clonedLabelSet);
std::vector addedGroups;
if (layerIdx < m_LabelSetContainer.size())
{
if (m_LabelSetContainer[layerIdx].IsNotNull())
{
this->ReleaseLabelSet(m_LabelSetContainer[layerIdx]);
}
m_LabelSetContainer[layerIdx] = clonedLabelSet;
}
else
{
while (layerIdx >= m_LabelSetContainer.size())
{
mitk::LabelSet::Pointer defaultLabelSet = mitk::LabelSet::New();
defaultLabelSet->SetActiveLabel(UnlabeledValue);
defaultLabelSet->SetLayer(m_LabelSetContainer.size());
this->RegisterLabelSet(defaultLabelSet);
this->ReinitMaps();
m_LabelSetContainer.push_back(defaultLabelSet);
addedGroups.emplace_back(m_LabelSetContainer.size() - 1);
}
m_LabelSetContainer.push_back(clonedLabelSet);
addedGroups.emplace_back(m_LabelSetContainer.size() - 1);
}
this->ReinitMaps();
for (auto groupID : addedGroups)
{
this->m_GroupAddedMessage.Send(groupID);
}
}
void mitk::LabelSetImage::SetActiveLayer(unsigned int layer)
{
try
{
if (4 == this->GetDimension())
{
if ((layer != GetActiveLayer() || m_activeLayerInvalid) && (layer < this->GetNumberOfLayers()))
{
BeforeChangeLayerEvent.Send();
if (m_activeLayerInvalid)
{
// We should not write the invalid layer back to the vector
m_activeLayerInvalid = false;
}
else
{
AccessFixedDimensionByItk_n(this, ImageToLayerContainerProcessing, 4, (GetActiveLayer()));
}
m_ActiveLayer = layer; // only at this place m_ActiveLayer should be manipulated!!! Use Getter and Setter
AccessFixedDimensionByItk_n(this, LayerContainerToImageProcessing, 4, (GetActiveLayer()));
AfterChangeLayerEvent.Send();
}
}
else
{
if ((layer != GetActiveLayer() || m_activeLayerInvalid) && (layer < this->GetNumberOfLayers()))
{
BeforeChangeLayerEvent.Send();
if (m_activeLayerInvalid)
{
// We should not write the invalid layer back to the vector
m_activeLayerInvalid = false;
}
else
{
AccessByItk_1(this, ImageToLayerContainerProcessing, GetActiveLayer());
}
m_ActiveLayer = layer; // only at this place m_ActiveLayer should be manipulated!!! Use Getter and Setter
AccessByItk_1(this, LayerContainerToImageProcessing, GetActiveLayer());
AfterChangeLayerEvent.Send();
}
}
}
catch (itk::ExceptionObject &e)
{
mitkThrow() << e.GetDescription();
}
this->Modified();
}
void mitk::LabelSetImage::ClearBuffer()
{
try
{
if (this->GetDimension() == 4)
{ //remark: this extra branch was added, because LabelSetImage instances can be
//dynamic (4D), but AccessByItk by support only supports 2D and 3D.
//The option to change the CMake default dimensions for AccessByItk was
//dropped (for details see discussion in T28756)
AccessFixedDimensionByItk(this, ClearBufferProcessing,4);
}
else
{
AccessByItk(this, ClearBufferProcessing);
}
this->Modified();
}
catch (itk::ExceptionObject &e)
{
mitkThrow() << e.GetDescription();
}
}
bool mitk::LabelSetImage::ExistLabel(PixelType pixelValue) const
{
bool exist = false;
for (unsigned int lidx = 0; lidx < GetNumberOfLayers(); lidx++)
exist |= m_LabelSetContainer[lidx]->ExistLabel(pixelValue);
return exist;
}
bool mitk::LabelSetImage::ExistLabel(PixelType pixelValue, unsigned int layer) const
{
bool exist = m_LabelSetContainer[layer]->ExistLabel(pixelValue);
return exist;
}
bool mitk::LabelSetImage::ExistLabelSet(unsigned int layer) const
{
return layer < m_LabelSetContainer.size();
}
void mitk::LabelSetImage::MergeLabel(PixelType pixelValue, PixelType sourcePixelValue, unsigned int layer)
{
try
{
AccessByItk_2(this, MergeLabelProcessing, pixelValue, sourcePixelValue);
}
catch (itk::ExceptionObject &e)
{
mitkThrow() << e.GetDescription();
}
GetLabelSet(layer)->SetActiveLabel(pixelValue);
this->m_LabelModifiedMessage.Send(sourcePixelValue);
this->m_LabelModifiedMessage.Send(pixelValue);
this->m_LabelsChangedMessage.Send({ sourcePixelValue, pixelValue });
Modified();
}
void mitk::LabelSetImage::MergeLabels(PixelType pixelValue, const std::vector& vectorOfSourcePixelValues, unsigned int layer)
{
try
{
for (unsigned int idx = 0; idx < vectorOfSourcePixelValues.size(); idx++)
{
AccessByItk_2(this, MergeLabelProcessing, pixelValue, vectorOfSourcePixelValues[idx]);
this->m_LabelModifiedMessage.Send(vectorOfSourcePixelValues[idx]);
}
}
catch (itk::ExceptionObject &e)
{
mitkThrow() << e.GetDescription();
}
GetLabelSet(layer)->SetActiveLabel(pixelValue);
this->m_LabelModifiedMessage.Send(pixelValue);
auto modifiedValues = vectorOfSourcePixelValues;
modifiedValues.push_back(pixelValue);
this->m_LabelsChangedMessage.Send(modifiedValues);
Modified();
}
void mitk::LabelSetImage::RemoveLabel(LabelValueType pixelValue)
{
auto groupID = this->GetGroupIndexOfLabel(pixelValue);
//first erase the pixel content (also triggers a LabelModified event)
this->EraseLabel(pixelValue);
//now remove the label entry itself
this->GetLabelSet(groupID)->RemoveLabel(pixelValue);
// in the interim version triggered by label set events: this->m_LabelRemovedMessage.Send(pixelValue);
this->m_LabelsChangedMessage.Send({ pixelValue });
this->m_GroupModifiedMessage.Send(groupID);
}
void mitk::LabelSetImage::RemoveLabels(const std::vector& VectorOfLabelPixelValues)
{
for (unsigned int idx = 0; idx < VectorOfLabelPixelValues.size(); idx++)
{
this->RemoveLabel(VectorOfLabelPixelValues[idx]);
this->m_LabelsChangedMessage.Send({ VectorOfLabelPixelValues[idx] });
}
}
void mitk::LabelSetImage::EraseLabel(PixelType pixelValue)
{
try
{
auto groupID = this->GetGroupIndexOfLabel(pixelValue);
mitk::Image* groupImage = this->GetActiveLayer() != groupID
? this->GetLayerImage(groupID)
: this;
if (4 == this->GetDimension())
{
AccessFixedDimensionByItk_1(groupImage, EraseLabelProcessing, 4, pixelValue);
}
else
{
AccessByItk_1(groupImage, EraseLabelProcessing, pixelValue);
}
}
catch (const itk::ExceptionObject& e)
{
mitkThrow() << e.GetDescription();
}
this->m_LabelModifiedMessage.Send(pixelValue);
this->m_LabelsChangedMessage.Send({ pixelValue });
Modified();
}
void mitk::LabelSetImage::EraseLabels(const std::vector& VectorOfLabelPixelValues)
{
for (unsigned int idx = 0; idx < VectorOfLabelPixelValues.size(); idx++)
{
this->EraseLabel(VectorOfLabelPixelValues[idx]);
}
}
mitk::Label *mitk::LabelSetImage::GetActiveLabel(unsigned int layer)
{
if (m_LabelSetContainer.size() <= layer)
return nullptr;
else
return m_LabelSetContainer[layer]->GetActiveLabel();
}
const mitk::Label* mitk::LabelSetImage::GetActiveLabel(unsigned int layer) const
{
if (m_LabelSetContainer.size() <= layer)
return nullptr;
else
return m_LabelSetContainer[layer]->GetActiveLabel();
}
mitk::Label *mitk::LabelSetImage::GetLabel(PixelType pixelValue, unsigned int layer) const
{
if (m_LabelSetContainer.size() <= layer)
return nullptr;
else
return m_LabelSetContainer[layer]->GetLabel(pixelValue);
}
mitk::LabelSet *mitk::LabelSetImage::GetLabelSet(unsigned int layer)
{
if (m_LabelSetContainer.size() <= layer)
return nullptr;
else
return m_LabelSetContainer[layer].GetPointer();
}
const mitk::LabelSet *mitk::LabelSetImage::GetLabelSet(unsigned int layer) const
{
if (m_LabelSetContainer.size() <= layer)
return nullptr;
else
return m_LabelSetContainer[layer].GetPointer();
}
mitk::LabelSet *mitk::LabelSetImage::GetActiveLabelSet()
{
if (m_LabelSetContainer.size() == 0)
return nullptr;
else
return m_LabelSetContainer[GetActiveLayer()].GetPointer();
}
const mitk::LabelSet* mitk::LabelSetImage::GetActiveLabelSet() const
{
if (m_LabelSetContainer.size() == 0)
return nullptr;
else
return m_LabelSetContainer[GetActiveLayer()].GetPointer();
}
void mitk::LabelSetImage::UpdateCenterOfMass(PixelType pixelValue)
{
this->UpdateCenterOfMass(pixelValue, this->GetGroupIndexOfLabel(pixelValue));
}
void mitk::LabelSetImage::UpdateCenterOfMass(PixelType pixelValue, unsigned int layer)
{
if (4 == this->GetDimension())
{
AccessFixedDimensionByItk_2(this, CalculateCenterOfMassProcessing, 4, pixelValue, layer);
}
else
{
AccessByItk_2(this, CalculateCenterOfMassProcessing, pixelValue, layer);
}
}
unsigned int mitk::LabelSetImage::GetNumberOfLabels(unsigned int layer) const
{
return m_LabelSetContainer[layer]->GetNumberOfLabels();
}
unsigned int mitk::LabelSetImage::GetTotalNumberOfLabels() const
{
unsigned int totalLabels(0);
auto layerIter = m_LabelSetContainer.begin();
for (; layerIter != m_LabelSetContainer.end(); ++layerIter)
totalLabels += (*layerIter)->GetNumberOfLabels();
return totalLabels;
}
void mitk::LabelSetImage::MaskStamp(mitk::Image *mask, bool forceOverwrite)
{
try
{
mitk::PadImageFilter::Pointer padImageFilter = mitk::PadImageFilter::New();
padImageFilter->SetInput(0, mask);
padImageFilter->SetInput(1, this);
padImageFilter->SetPadConstant(0);
padImageFilter->SetBinaryFilter(false);
padImageFilter->SetLowerThreshold(0);
padImageFilter->SetUpperThreshold(1);
padImageFilter->Update();
mitk::Image::Pointer paddedMask = padImageFilter->GetOutput();
if (paddedMask.IsNull())
return;
AccessByItk_2(this, MaskStampProcessing, paddedMask, forceOverwrite);
}
catch (...)
{
mitkThrow() << "Could not stamp the provided mask on the selected label.";
}
}
mitk::Image::Pointer mitk::LabelSetImage::CreateLabelMask(PixelType index, bool useActiveLayer, unsigned int layer)
{
auto previousActiveLayer = this->GetActiveLayer();
auto mask = mitk::Image::New();
try
{
// mask->Initialize(this) does not work here if this label set image has a single slice,
// since the mask would be automatically flattened to a 2-d image, whereas we expect the
// original dimension of this label set image. Hence, initialize the mask more explicitly:
mask->Initialize(this->GetPixelType(), this->GetDimension(), this->GetDimensions());
mask->SetTimeGeometry(this->GetTimeGeometry()->Clone());
auto byteSize = sizeof(LabelSetImage::PixelType);
for (unsigned int dim = 0; dim < mask->GetDimension(); ++dim)
byteSize *= mask->GetDimension(dim);
{
ImageWriteAccessor accessor(mask);
memset(accessor.GetData(), 0, byteSize);
}
if (!useActiveLayer)
this->SetActiveLayer(layer);
if (4 == this->GetDimension())
{
::CreateLabelMaskProcessing<4>(this, mask, index);
}
else if (3 == this->GetDimension())
{
::CreateLabelMaskProcessing(this, mask, index);
}
else
{
mitkThrow();
}
}
catch (...)
{
if (!useActiveLayer)
this->SetActiveLayer(previousActiveLayer);
mitkThrow() << "Could not create a mask out of the selected label.";
}
if (!useActiveLayer)
this->SetActiveLayer(previousActiveLayer);
return mask;
}
void mitk::LabelSetImage::InitializeByLabeledImage(mitk::Image::Pointer image)
{
if (image.IsNull() || image->IsEmpty() || !image->IsInitialized())
mitkThrow() << "Invalid labeled image.";
try
{
this->Initialize(image);
unsigned int byteSize = sizeof(LabelSetImage::PixelType);
for (unsigned int dim = 0; dim < image->GetDimension(); ++dim)
{
byteSize *= image->GetDimension(dim);
}
mitk::ImageWriteAccessor *accessor = new mitk::ImageWriteAccessor(static_cast(this));
memset(accessor->GetData(), 0, byteSize);
delete accessor;
auto geometry = image->GetTimeGeometry()->Clone();
this->SetTimeGeometry(geometry);
if (image->GetDimension() == 3)
{
AccessTwoImagesFixedDimensionByItk(this, image, InitializeByLabeledImageProcessing, 3);
}
else if (image->GetDimension() == 4)
{
AccessTwoImagesFixedDimensionByItk(this, image, InitializeByLabeledImageProcessing, 4);
}
else
{
mitkThrow() << image->GetDimension() << "-dimensional label set images not yet supported";
}
}
catch (...)
{
mitkThrow() << "Could not intialize by provided labeled image.";
}
this->Modified();
}
template
void mitk::LabelSetImage::InitializeByLabeledImageProcessing(LabelSetImageType *labelSetImage, ImageType *image)
{
typedef itk::ImageRegionConstIteratorWithIndex SourceIteratorType;
typedef itk::ImageRegionIterator TargetIteratorType;
TargetIteratorType targetIter(labelSetImage, labelSetImage->GetRequestedRegion());
targetIter.GoToBegin();
SourceIteratorType sourceIter(image, image->GetRequestedRegion());
sourceIter.GoToBegin();
while (!sourceIter.IsAtEnd())
{
auto sourceValue = static_cast(sourceIter.Get());
targetIter.Set(sourceValue);
if (LabelSetImage::UnlabeledValue!=sourceValue && !this->ExistLabel(sourceValue))
{
std::stringstream name;
name << "object-" << sourceValue;
double rgba[4];
m_LabelSetContainer[this->GetActiveLayer()]->GetLookupTable()->GetTableValue(sourceValue, rgba);
mitk::Color color;
color.SetRed(rgba[0]);
color.SetGreen(rgba[1]);
color.SetBlue(rgba[2]);
auto label = mitk::Label::New();
label->SetName(name.str().c_str());
label->SetColor(color);
label->SetOpacity(rgba[3]);
label->SetValue(sourceValue);
this->GetLabelSet()->AddLabel(label);
if (GetActiveLabelSet()->GetNumberOfLabels() >= mitk::Label::MAX_LABEL_VALUE ||
sourceValue >= mitk::Label::MAX_LABEL_VALUE)
this->AddLayer();
}
++sourceIter;
++targetIter;
}
}
template
void mitk::LabelSetImage::MaskStampProcessing(ImageType *itkImage, mitk::Image *mask, bool forceOverwrite)
{
typename ImageType::Pointer itkMask;
mitk::CastToItkImage(mask, itkMask);
typedef itk::ImageRegionConstIterator SourceIteratorType;
typedef itk::ImageRegionIterator TargetIteratorType;
SourceIteratorType sourceIter(itkMask, itkMask->GetLargestPossibleRegion());
sourceIter.GoToBegin();
TargetIteratorType targetIter(itkImage, itkImage->GetLargestPossibleRegion());
targetIter.GoToBegin();
int activeLabel = this->GetActiveLabel(GetActiveLayer())->GetValue();
while (!sourceIter.IsAtEnd())
{
PixelType sourceValue = sourceIter.Get();
PixelType targetValue = targetIter.Get();
if ((sourceValue != UnlabeledValue) &&
(forceOverwrite || !this->IsLabelLocked(targetValue))) // skip unlabeled pixels and locked labels
{
targetIter.Set(activeLabel);
}
++sourceIter;
++targetIter;
}
this->Modified();
}
template
void mitk::LabelSetImage::CalculateCenterOfMassProcessing(ImageType *itkImage, PixelType pixelValue, unsigned int layer)
{
if (ImageType::GetImageDimension() != 3)
{
return;
}
auto labelGeometryFilter = itk::LabelGeometryImageFilter::New();
labelGeometryFilter->SetInput(itkImage);
labelGeometryFilter->Update();
auto centroid = labelGeometryFilter->GetCentroid(pixelValue);
mitk::Point3D pos;
pos[0] = centroid[0];
pos[1] = centroid[1];
pos[2] = centroid[2];
GetLabelSet(layer)->GetLabel(pixelValue)->SetCenterOfMassIndex(pos);
this->GetSlicedGeometry()->IndexToWorld(pos, pos); // TODO: TimeGeometry?
GetLabelSet(layer)->GetLabel(pixelValue)->SetCenterOfMassCoordinates(pos);
}
template
void mitk::LabelSetImage::ClearBufferProcessing(ImageType *itkImage)
{
itkImage->FillBuffer(0);
}
template
void mitk::LabelSetImage::LayerContainerToImageProcessing(itk::Image *target,
unsigned int layer)
{
typedef itk::Image ImageType;
typename ImageType::Pointer itkSource;
// mitk::CastToItkImage(m_LayerContainer[layer], itkSource);
itkSource = ImageToItkImage(m_LayerContainer[layer]);
typedef itk::ImageRegionConstIterator SourceIteratorType;
typedef itk::ImageRegionIterator TargetIteratorType;
SourceIteratorType sourceIter(itkSource, itkSource->GetLargestPossibleRegion());
sourceIter.GoToBegin();
TargetIteratorType targetIter(target, target->GetLargestPossibleRegion());
targetIter.GoToBegin();
while (!sourceIter.IsAtEnd())
{
targetIter.Set(sourceIter.Get());
++sourceIter;
++targetIter;
}
}
template
void mitk::LabelSetImage::ImageToLayerContainerProcessing(itk::Image *source,
unsigned int layer) const
{
typedef itk::Image ImageType;
typename ImageType::Pointer itkTarget;
// mitk::CastToItkImage(m_LayerContainer[layer], itkTarget);
itkTarget = ImageToItkImage(m_LayerContainer[layer]);
typedef itk::ImageRegionConstIterator SourceIteratorType;
typedef itk::ImageRegionIterator TargetIteratorType;
SourceIteratorType sourceIter(source, source->GetLargestPossibleRegion());
sourceIter.GoToBegin();
TargetIteratorType targetIter(itkTarget, itkTarget->GetLargestPossibleRegion());
targetIter.GoToBegin();
while (!sourceIter.IsAtEnd())
{
targetIter.Set(sourceIter.Get());
++sourceIter;
++targetIter;
}
}
template