diff --git a/Applications/mitkDiffusion/CMakeLists.txt b/Applications/mitkDiffusion/CMakeLists.txt index 71a6e71547..030f5022b2 100644 --- a/Applications/mitkDiffusion/CMakeLists.txt +++ b/Applications/mitkDiffusion/CMakeLists.txt @@ -1,84 +1,81 @@ project(mitkDiffusion) set(DIFFUSIONAPP_NAME mitkDiffusion) set(_app_options) if(MITK_SHOW_CONSOLE_WINDOW) list(APPEND _app_options SHOW_CONSOLE) endif() -MITK_USE_MODULE(qtsingleapplication) -include_directories(${ALL_INCLUDE_DIRECTORIES}) - # Create a cache entry for the provisioning file which is used to export # the file name in the MITKConfig.cmake file. This will keep external projects # which rely on this file happy. set(DIFFUSIONIMAGINGAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DIFFUSIONAPP_NAME}.provisioning" CACHE INTERNAL "${DIFFUSIONAPP_NAME} provisioning file" FORCE) set(_plugins org.commontk.configadmin org.commontk.eventadmin org.blueberry.osgi org.blueberry.compat org.blueberry.core.runtime org.blueberry.core.expressions org.blueberry.solstice.common org.blueberry.core.commands org.blueberry.ui org.blueberry.ui.qt org.blueberry.ui.qt.log org.blueberry.ui.qt.help org.mitk.core.services org.mitk.gui.common org.mitk.planarfigure org.mitk.core.ext org.mitk.diffusionimaging org.mitk.gui.qt.application org.mitk.gui.qt.ext org.mitk.gui.qt.diffusionimagingapp org.mitk.gui.qt.common org.mitk.gui.qt.stdmultiwidgeteditor org.mitk.gui.qt.common.legacy org.mitk.gui.qt.datamanager org.mitk.gui.qt.measurementtoolbox org.mitk.gui.qt.segmentation org.mitk.gui.qt.volumevisualization org.mitk.gui.qt.diffusionimaging org.mitk.gui.qt.imagenavigator org.mitk.gui.qt.moviemaker org.mitk.gui.qt.basicimageprocessing org.mitk.gui.qt.registration org.mitk.gui.qt.properties ) # Plug-ins listed below will not be # - added as a build-time dependency to the executable # - listed in the provisioning file for the executable # - installed if they are external plug-ins set(_exclude_plugins org.blueberry.test org.blueberry.uitest org.mitk.gui.qt.coreapplication org.mitk.gui.qt.extapplication ) FunctionCreateBlueBerryApplication( NAME ${DIFFUSIONAPP_NAME} DESCRIPTION "MITK Diffusion" PLUGINS ${_plugins} EXCLUDE_PLUGINS ${_exclude_plugins} LINK_LIBRARIES ${ALL_LIBRARIES} ${_app_options} ) +mitk_use_modules(TARGET ${DIFFUSIONAPP_NAME} MODULES qtsingleapplication) # Add meta dependencies (e.g. on auto-load modules from depending modules) if(ALL_META_DEPENDENCIES) add_dependencies(${DIFFUSIONAPP_NAME} ${ALL_META_DEPENDENCIES}) endif() - # Add a build time dependency to legacy BlueBerry bundles. if(MITK_MODULES_ENABLED_PLUGINS) add_dependencies(${DIFFUSIONAPP_NAME} ${MITK_MODULES_ENABLED_PLUGINS}) endif() diff --git a/Applications/mitkWorkbench/CMakeLists.txt b/Applications/mitkWorkbench/CMakeLists.txt index fb3825aa9d..602e4b7d62 100644 --- a/Applications/mitkWorkbench/CMakeLists.txt +++ b/Applications/mitkWorkbench/CMakeLists.txt @@ -1,52 +1,50 @@ project(mitkWorkbench) set(_app_options) if(MITK_SHOW_CONSOLE_WINDOW) list(APPEND _app_options SHOW_CONSOLE) endif() -MITK_USE_MODULE(qtsingleapplication Mitk) -include_directories(${ALL_INCLUDE_DIRECTORIES}) - # Create a cache entry for the provisioning file which is used to export # the file name in the MITKConfig.cmake file. This will keep external projects # which rely on this file happy. set(MITK_EXTAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mitkWorkbench.provisioning" CACHE INTERNAL "mitkWorkbench provisioning file" FORCE) # Plug-ins listed below will not be # - added as a build-time dependency to the executable # - listed in the provisioning file for the executable # - installed if they are external plug-ins set(_exclude_plugins org.blueberry.test org.blueberry.uitest org.mitk.gui.qt.coreapplication org.mitk.gui.qt.diffusionimagingapp ) FunctionCreateBlueBerryApplication( NAME mitkWorkbench DESCRIPTION "MITK Workbench" EXCLUDE_PLUGINS ${_exclude_plugins} LINK_LIBRARIES ${ALL_LIBRARIES} ${_app_options} ) +mitk_use_modules(TARGET mitkWorkbench MODULES qtsingleapplication Mitk) # Add meta dependencies (e.g. on auto-load modules from depending modules) if(ALL_META_DEPENDENCIES) add_dependencies(mitkWorkbench ${ALL_META_DEPENDENCIES}) endif() #Setting application icon for mac os x systems set_target_properties(mitkWorkbench PROPERTIES MACOSX_BUNDLE_ICON_FILE "icon.icns") if(APPLE) install(FILES "icons/icon.icns" DESTINATION "mitkWorkbench.app/Contents/Resources") endif(APPLE) # Add a build time dependency to legacy BlueBerry bundles. if(MITK_MODULES_ENABLED_PLUGINS) add_dependencies(mitkWorkbench ${MITK_MODULES_ENABLED_PLUGINS}) endif() diff --git a/CMake/PackageDepends/MITK_ACVD_Config.cmake b/CMake/PackageDepends/MITK_ACVD_Config.cmake index 7e4ceb960f..961c105e88 100644 --- a/CMake/PackageDepends/MITK_ACVD_Config.cmake +++ b/CMake/PackageDepends/MITK_ACVD_Config.cmake @@ -1,4 +1,4 @@ find_package(ACVD REQUIRED CONFIG) list(APPEND ALL_INCLUDE_DIRECTORIES ${ACVD_INCLUDE_DIRS}) list(APPEND ALL_LIBRARIES ${ACVD_LIBRARIES}) -link_directories(${ACVD_LIBRARY_DIRS}) +list(APPEND ALL_LIBRARY_DIRS ${ACVD_LIBRARY_DIRS}) diff --git a/CMake/PackageDepends/MITK_ITK_Config.cmake b/CMake/PackageDepends/MITK_ITK_Config.cmake index e1f8ad0b4d..2509e4bef4 100644 --- a/CMake/PackageDepends/MITK_ITK_Config.cmake +++ b/CMake/PackageDepends/MITK_ITK_Config.cmake @@ -1,21 +1,25 @@ +if(TARGET itksys) + set(ITK_TARGETS_IMPORTED 1) +endif() + find_package(ITK REQUIRED) # # for some reason this does not work on windows, probably an ITK bug # ITK_BUILD_SHARED is OFF even in shared library builds # #if(ITK_FOUND AND NOT ITK_BUILD_SHARED) # message(FATAL_ERROR "MITK only supports a ITK which was built with shared libraries. Turn on BUILD_SHARED_LIBS in your ITK config.") #endif(ITK_FOUND AND NOT ITK_BUILD_SHARED) if(NOT DEFINED ITK_NO_IO_FACTORY_REGISTER_MANAGER) set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) endif() include(${ITK_USE_FILE}) list(APPEND ALL_LIBRARIES ${ITK_LIBRARIES}) list(APPEND ALL_INCLUDE_DIRECTORIES ${ITK_INCLUDE_DIRS}) find_package(GDCM PATHS ${ITK_GDCM_DIR} REQUIRED) list(APPEND ALL_INCLUDE_DIRECTORIES ${GDCM_INCLUDE_DIRS}) list(APPEND ALL_LIBRARIES ${GDCM_LIBRARIES}) -include(${GDCM_USE_FILE}) +list(APPEND ALL_LIBRARY_DIRS ${GDCM_LIBRARY_DIRS}) diff --git a/CMake/PackageDepends/MITK_QT_Config.cmake b/CMake/PackageDepends/MITK_QT_Config.cmake index 6d1d9f6397..593cde093f 100644 --- a/CMake/PackageDepends/MITK_QT_Config.cmake +++ b/CMake/PackageDepends/MITK_QT_Config.cmake @@ -1,6 +1 @@ - -find_package(Qt4 REQUIRED) -include(${QT_USE_FILE}) -list(APPEND ALL_INCLUDE_DIRECTORIES ${QT_INCLUDE_DIRS}) -list(APPEND ALL_LIBRARIES ${QT_LIBRARIES}) - +message(WARNING "You used a deprecated keyword PACKAGE_DEPENDS QT.\nPlease switch to QT4 or QT5 or investigate more to support both versions.") diff --git a/CMake/PackageDepends/MITK_VTK_Config.cmake b/CMake/PackageDepends/MITK_VTK_Config.cmake index 1e5fbfac47..ffc59643d8 100644 --- a/CMake/PackageDepends/MITK_VTK_Config.cmake +++ b/CMake/PackageDepends/MITK_VTK_Config.cmake @@ -1,138 +1,133 @@ -if(NOT MITK_VTK_Config_INCLUDED) - set(MITK_VTK_Config_INCLUDED 1) - find_package(VTK REQUIRED) - if(VTK_FOUND AND NOT VTK_BUILD_SHARED_LIBS) - message(FATAL_ERROR "MITK only supports a VTK which was built with shared libraries. Turn on BUILD_SHARED_LIBS in your VTK config.") - endif() +find_package(VTK REQUIRED) +if(VTK_FOUND AND NOT VTK_BUILD_SHARED_LIBS) + message(FATAL_ERROR "MITK only supports a VTK which was built with shared libraries. Turn on BUILD_SHARED_LIBS in your VTK config.") +endif() - include(${VTK_USE_FILE}) - list(APPEND ALL_INCLUDE_DIRECTORIES ${VTK_INCLUDE_DIRS}) - list(APPEND ALL_LIBRARY_DIRS ${VTK_LIBRARY_DIRS}) - if(VTK_FOR_MITK_LIBRARIES) - list(APPEND ALL_LIBRARIES ${VTK_FOR_MITK_LIBRARIES}) - else() - # Libraries in mitk/Utilities may depend on VTK but - # the VTK_FOR_MITK_LIBRARIES variable is not yet set. - # Supply the VTK libraries manually - ## VTK6_TODO Remove unneeded Libraries - list(APPEND ALL_LIBRARIES +include(${VTK_USE_FILE}) +list(APPEND ALL_INCLUDE_DIRECTORIES ${VTK_INCLUDE_DIRS}) +if(VTK_FOR_MITK_LIBRARIES) + list(APPEND ALL_LIBRARIES ${VTK_FOR_MITK_LIBRARIES}) +else() + # Libraries in mitk/Utilities may depend on VTK but + # the VTK_FOR_MITK_LIBRARIES variable is not yet set. + # Supply the VTK libraries manually + ## VTK6_TODO Remove unneeded Libraries + list(APPEND ALL_LIBRARIES vtkalglib vtkChartsCore vtkCommonColor vtkCommonComputationalGeometry vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkDICOMParser vtkDomainsChemistry vtkexoIIc vtkexpat vtkFiltersAMR vtkFiltersCore vtkFiltersExtraction vtkFiltersFlowPaths vtkFiltersGeneral vtkFiltersGeneric vtkFiltersGeometry vtkFiltersHybrid vtkFiltersHyperTree vtkFiltersImaging vtkFiltersModeling vtkFiltersParallel vtkFiltersParallelImaging vtkFiltersProgrammable vtkFiltersSelection vtkFiltersSources vtkFiltersStatistics vtkFiltersTexture vtkFiltersVerdict vtkfreetype vtkftgl vtkGeovisCore vtkgl2ps vtkhdf5 vtkhdf5_hl vtkImagingColor vtkImagingCore vtkImagingFourier vtkImagingGeneral vtkImagingHybrid vtkImagingMath vtkImagingMorphological vtkImagingSources vtkImagingStatistics vtkImagingStencil vtkInfovisCore vtkInfovisLayout vtkInteractionImage vtkInteractionStyle vtkInteractionWidgets vtkIOAMR vtkIOCore vtkIOEnSight vtkIOExodus vtkIOExport vtkIOGeometry vtkIOImage vtkIOImport vtkIOInfovis vtkIOLegacy vtkIOLSDyna vtkIOMINC vtkIOMovie vtkIONetCDF vtkIOParallel vtkIOPLY vtkIOSQL vtkIOVideo vtkIOXML vtkIOXMLParser vtkjpeg vtkjsoncpp vtklibxml2 vtkmetaio vtkNetCDF vtkNetCDF_cxx vtkoggtheora vtkParallelCore vtkpng vtkproj4 vtkRenderingAnnotation vtkRenderingContext2D vtkRenderingCore vtkRenderingFreeType vtkRenderingFreeTypeOpenGL vtkRenderingGL2PS vtkRenderingHybridOpenGL vtkRenderingImage vtkRenderingLabel vtkRenderingLOD vtkRenderingOpenGL vtkRenderingVolume vtkRenderingVolumeAMR vtkRenderingVolumeOpenGL vtkGUISupportQtOpenGL vtksqlite vtksys vtkTestingRendering vtktiff vtkViewsContext2D vtkViewsCore vtkViewsGeovis vtkViewsInfovis vtkzlib vtkGUISupportQt vtkGUISupportQtWebkit - ${VTK_JPEG_LIBRARIES} - ${VTK_PNG_LIBRARIES} - ${VTK_ZLIB_LIBRARIES} - ${VTK_EXPAT_LIBRARIES} - ${VTK_FREETYPE_LIBRARIES} + ${VTK_JPEG_LIBRARIES} + ${VTK_PNG_LIBRARIES} + ${VTK_ZLIB_LIBRARIES} + ${VTK_EXPAT_LIBRARIES} + ${VTK_FREETYPE_LIBRARIES} ) - endif() - -endif(NOT MITK_VTK_Config_INCLUDED) +endif() diff --git a/CMake/PackageDepends/Qt/MITK_Qt4_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt4_Config.cmake new file mode 100644 index 0000000000..c017c48303 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt4_Config.cmake @@ -0,0 +1,5 @@ +set(QT_DONT_USE_QTCORE 0) +set(QT_DONT_USE_QTGUI 0) +find_package(Qt4 QUIET REQUIRED QtCore ${MODULE_QT4_MODULES}) # TODO we could need QUIET! +include(${QT_USE_FILE}) +list(APPEND ALL_LIBRARIES ${QT_LIBRARIES}) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5CLucene_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5CLucene_Config.cmake new file mode 100644 index 0000000000..59724daaf0 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5CLucene_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5CLucene REQUIRED) +qt5_use_modules(${MODULE_NAME} CLucene) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Concurrent_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Concurrent_Config.cmake new file mode 100644 index 0000000000..c7193bc530 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Concurrent_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Concurrent REQUIRED) +qt5_use_modules(${MODULE_NAME} Concurrent) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Core_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Core_Config.cmake new file mode 100644 index 0000000000..441f459d3a --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Core_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Core REQUIRED) +qt5_use_modules(${MODULE_NAME} Core) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5DBus_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5DBus_Config.cmake new file mode 100644 index 0000000000..104d4e7f5d --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5DBus_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5DBus REQUIRED) +qt5_use_modules(${MODULE_NAME} DBus) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Declarative_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Declarative_Config.cmake new file mode 100644 index 0000000000..53b28689c9 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Declarative_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Declarative REQUIRED) +qt5_use_modules(${MODULE_NAME} Declarative) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5DesignerComponents_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5DesignerComponents_Config.cmake new file mode 100644 index 0000000000..4864c43344 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5DesignerComponents_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5DesignerComponents REQUIRED) +qt5_use_modules(${MODULE_NAME} DesignerComponents) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Designer_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Designer_Config.cmake new file mode 100644 index 0000000000..f013f888a9 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Designer_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Designer REQUIRED) +qt5_use_modules(${MODULE_NAME} Designer) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Gui_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Gui_Config.cmake new file mode 100644 index 0000000000..eb92e4d058 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Gui_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Gui REQUIRED) +qt5_use_modules(${MODULE_NAME} Gui) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Help_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Help_Config.cmake new file mode 100644 index 0000000000..d7af5d2848 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Help_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Help REQUIRED) +qt5_use_modules(${MODULE_NAME} Help) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5MultimediaWidgets_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5MultimediaWidgets_Config.cmake new file mode 100644 index 0000000000..056599bfc7 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5MultimediaWidgets_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5MultimediaWidgets REQUIRED) +qt5_use_modules(${MODULE_NAME} MultimediaWidgets) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Multimedia_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Multimedia_Config.cmake new file mode 100644 index 0000000000..4a886ba244 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Multimedia_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Multimedia REQUIRED) +qt5_use_modules(${MODULE_NAME} Multimedia) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Network_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Network_Config.cmake new file mode 100644 index 0000000000..6d1218d33a --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Network_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Network REQUIRED) +qt5_use_modules(${MODULE_NAME} Network) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5OpenGL_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5OpenGL_Config.cmake new file mode 100644 index 0000000000..a0ec34abbf --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5OpenGL_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5OpenGL REQUIRED) +qt5_use_modules(${MODULE_NAME} OpenGL) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5PrintSupport_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5PrintSupport_Config.cmake new file mode 100644 index 0000000000..7a634eabd3 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5PrintSupport_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5PrintSupport REQUIRED) +qt5_use_modules(${MODULE_NAME} PrintSupport) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Qml_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Qml_Config.cmake new file mode 100644 index 0000000000..3c740240e9 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Qml_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Qml REQUIRED) +qt5_use_modules(${MODULE_NAME} Qml) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5QuickParticles_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5QuickParticles_Config.cmake new file mode 100644 index 0000000000..291f95a3b4 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5QuickParticles_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5QuickParticles REQUIRED) +qt5_use_modules(${MODULE_NAME} QuickParticles) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5QuickTest_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5QuickTest_Config.cmake new file mode 100644 index 0000000000..e8c08bda37 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5QuickTest_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5QuickTest REQUIRED) +qt5_use_modules(${MODULE_NAME} QuickTest) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Quick_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Quick_Config.cmake new file mode 100644 index 0000000000..3ffa06f038 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Quick_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Quick REQUIRED) +qt5_use_modules(${MODULE_NAME} Quick) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5ScriptTools_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5ScriptTools_Config.cmake new file mode 100644 index 0000000000..0f3ca50ccc --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5ScriptTools_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5ScriptTools REQUIRED) +qt5_use_modules(${MODULE_NAME} ScriptTools) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Script_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Script_Config.cmake new file mode 100644 index 0000000000..74e0283794 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Script_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Script REQUIRED) +qt5_use_modules(${MODULE_NAME} Script) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Sensors_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Sensors_Config.cmake new file mode 100644 index 0000000000..0bd9a5b913 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Sensors_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Sensors REQUIRED) +qt5_use_modules(${MODULE_NAME} Sensors) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5SerialPort_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5SerialPort_Config.cmake new file mode 100644 index 0000000000..84244454bd --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5SerialPort_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5SerialPort REQUIRED) +qt5_use_modules(${MODULE_NAME} SerialPort) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Sql_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Sql_Config.cmake new file mode 100644 index 0000000000..bdfa73aa42 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Sql_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Sql REQUIRED) +qt5_use_modules(${MODULE_NAME} Sql) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Svg_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Svg_Config.cmake new file mode 100644 index 0000000000..3b25ad3850 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Svg_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Svg REQUIRED) +qt5_use_modules(${MODULE_NAME} Svg) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Test_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Test_Config.cmake new file mode 100644 index 0000000000..83cd145f94 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Test_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Test REQUIRED) +qt5_use_modules(${MODULE_NAME} Test) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5V8_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5V8_Config.cmake new file mode 100644 index 0000000000..6a95243e86 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5V8_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5V8 REQUIRED) +qt5_use_modules(${MODULE_NAME} V8) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5WebKitWidgets_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5WebKitWidgets_Config.cmake new file mode 100644 index 0000000000..20a6e672e8 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5WebKitWidgets_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5WebKitWidgets REQUIRED) +qt5_use_modules(${MODULE_NAME} WebKitWidgets) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5WebKit_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5WebKit_Config.cmake new file mode 100644 index 0000000000..2fbd7ad781 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5WebKit_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5WebKit REQUIRED) +qt5_use_modules(${MODULE_NAME} WebKit) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Widgets_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Widgets_Config.cmake new file mode 100644 index 0000000000..858ac3f1fe --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Widgets_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Widgets REQUIRED) +qt5_use_modules(${MODULE_NAME} Widgets) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5X11Extras_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5X11Extras_Config.cmake new file mode 100644 index 0000000000..d24cd6918b --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5X11Extras_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5X11Extras REQUIRED) +qt5_use_modules(${MODULE_NAME} X11Extras) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5XmlPatterns_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5XmlPatterns_Config.cmake new file mode 100644 index 0000000000..c568dc28a6 --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5XmlPatterns_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5XmlPatterns REQUIRED) +qt5_use_modules(${MODULE_NAME} XmlPatterns) diff --git a/CMake/PackageDepends/Qt/MITK_Qt5Xml_Config.cmake b/CMake/PackageDepends/Qt/MITK_Qt5Xml_Config.cmake new file mode 100644 index 0000000000..0879a3253c --- /dev/null +++ b/CMake/PackageDepends/Qt/MITK_Qt5Xml_Config.cmake @@ -0,0 +1,2 @@ +find_package(Qt5Xml REQUIRED) +qt5_use_modules(${MODULE_NAME} Xml) diff --git a/CMake/PackageDepends/Qt/create_qt_packages.sh b/CMake/PackageDepends/Qt/create_qt_packages.sh new file mode 100644 index 0000000000..b582ed5478 --- /dev/null +++ b/CMake/PackageDepends/Qt/create_qt_packages.sh @@ -0,0 +1,15 @@ +QT_BUILD_DIR=/opt/toolkits/ubuntu-12.04/qt-5.1/lib/ + +for lib in $QT_BUILD_DIR/libQt5*.so +do + libname=${lib/*libQt5/Qt5} + libname=${libname/.so/} + + config_filename=MITK_${libname}_Config.cmake + echo "Creating ${config_filename}" + cat << EOF > ${config_filename} +find_package($libname REQUIRED) +qt5_use_modules(\${MODULE_NAME} ${libname#Qt5}) +EOF + +done diff --git a/CMake/StartApp.bat.in b/CMake/StartApp.bat.in new file mode 100644 index 0000000000..20345bfddd --- /dev/null +++ b/CMake/StartApp.bat.in @@ -0,0 +1,2 @@ +PATH=@MITK_RUNTIME_PATH@;%PATH% +@VS_BUILD_TYPE@\@EXEC_NAME@.exe diff --git a/CMake/mitkFunctionGetLibrarySearchPaths.cmake b/CMake/mitkFunctionGetLibrarySearchPaths.cmake index c4cc914e26..ec63836a11 100644 --- a/CMake/mitkFunctionGetLibrarySearchPaths.cmake +++ b/CMake/mitkFunctionGetLibrarySearchPaths.cmake @@ -1,123 +1,152 @@ function(mitkFunctionGetLibrarySearchPaths search_path intermediate_dir) - set(_dir_candidates ${MITK_VTK_LIBRARY_DIRS} ${MITK_ITK_LIBRARY_DIRS} ${QT_LIBRARY_DIR} - ${QT_LIBRARY_DIR}/../bin ${MITK_BINARY_DIR}/bin ${MITK_BINARY_DIR}/bin/plugins) + set(_dir_candidates ${MITK_VTK_LIBRARY_DIRS} ${MITK_ITK_LIBRARY_DIRS} + ${MITK_BINARY_DIR}/bin ${MITK_BINARY_DIR}/bin/plugins) + + # Determine the Qt4/5 library installation prefix + set(_qmake_location ) + if(MITK_USE_Qt4) + set(_qmake_location ${QT_QMAKE_EXECUTABLE}) + elseif(MITK_USE_Qt5 AND TARGET ${Qt5Core_QMAKE_EXECUTABLE}) + get_property(_qmake_location TARGET ${Qt5Core_QMAKE_EXECUTABLE} + PROPERTY IMPORT_LOCATION) + endif() + if(_qmake_location) + if(NOT _qt_install_libs) + if(WIN32) + execute_process(COMMAND ${_qmake_location} -query QT_INSTALL_BINS + OUTPUT_VARIABLE _qt_install_libs + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + execute_process(COMMAND ${_qmake_location} -query QT_INSTALL_LIBS + OUTPUT_VARIABLE _qt_install_libs + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + file(TO_CMAKE_PATH "${_qt_install_libs}" _qt_install_libs) + set(_qt_install_libs ${_qt_install_libs} CACHE INTERNAL "Qt library installation prefix" FORCE) + endif() + if(_qt_install_libs) + list(APPEND _dir_candidates ${_qt_install_libs}) + endif() + elseif(MITK_USE_QT) + message(WARNING "The qmake executable could not be found.") + endif() get_property(_additional_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) if(_additional_paths) list(APPEND _dir_candidates ${_additional_paths}) endif() if(WIN32) if(DCMTK_DIR) list(APPEND _dir_candidates "${DCMTK_DIR}/bin") endif() list(APPEND _dir_candidates "${ITK_DIR}/bin") else() if(DCMTK_DIR) list(APPEND _dir_candidates "${DCMTK_DIR}/lib") endif() list(APPEND _dir_candidates "${ITK_DIR}/lib") endif() # The code below is sub-optimal. It makes assumptions about # the structure of the build directories, pointed to by # the *_DIR variables. Instead, we should rely on package # specific "LIBRARY_DIRS" variables, if they exist. if(MITK_USE_Python AND CTK_PYTHONQT_INSTALL_DIR) list(APPEND _dir_candidates ${CTK_PYTHONQT_INSTALL_DIR}/bin) endif() if(MITK_USE_Boost AND MITK_USE_Boost_LIBRARIES AND NOT MITK_USE_SYSTEM_Boost) list(APPEND _dir_candidates ${Boost_LIBRARY_DIR}) endif() if(ACVD_DIR) list(APPEND _dir_candidates ${ACVD_DIR}/bin) endif() if(ANN_DIR) list(APPEND _dir_candidates ${ANN_DIR}) endif() if(CppUnit_DIR) list(APPEND _dir_candidates ${CppUnit_DIR}) endif() if(GLUT_DIR) list(APPEND _dir_candidates ${GLUT_DIR}) endif() if(GDCM_DIR) list(APPEND _dir_candidates ${GDCM_DIR}/bin) endif() if(GLEW_DIR) list(APPEND _dir_candidates ${GLEW_DIR}) endif() if(tinyxml_DIR) list(APPEND _dir_candidates ${tinyxml_DIR}) endif() if(OpenCV_DIR) list(APPEND _dir_candidates ${OpenCV_DIR}/bin) endif() if(Poco_DIR) list(APPEND _dir_candidates ${Poco_DIR}/lib) endif() if(Qwt_DIR) list(APPEND _dir_candidates ${Qwt_DIR}) endif() if(Qxt_DIR) list(APPEND _dir_candidates ${Qxt_DIR}) endif() if(SOFA_DIR) list(APPEND _dir_candidates ${SOFA_DIR}/bin) endif() if(MITK_USE_TOF_PMDO3 OR MITK_USE_TOF_PMDCAMCUBE OR MITK_USE_TOF_PMDCAMBOARD) list(APPEND _dir_candidates ${MITK_PMD_SDK_DIR}/plugins) endif() if(MITK_USE_BLUEBERRY) # quick-fix for Bug 16606 : the CTK_RUNTIME_LIB_DIRS variable was removed # so check if the variable is empty, otherwise compose the path to CTK starting if(NOT "${CTK_RUNTIME_LIBRARY_DIRS}" STREQUAL "") list(APPEND _dir_candidates ${CTK_RUNTIME_LIBRARY_DIRS}) else() if(MBILOG_ENABLE_DEBUG_MESSAGES) message(STATUS "CTK Runtime library not set, composing hard-coded path") message(STATUS "Using candidate: ${CTK_DIR}/CTK-build/bin" ) endif() list(APPEND _dir_candidates ${CTK_DIR}/CTK-build/bin ) endif() if(DEFINED CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY) if(IS_ABSOLUTE "${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}") list(APPEND _dir_candidates "${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}") else() list(APPEND _dir_candidates "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}") endif() endif() endif() if(MITK_LIBRARY_DIRS) list(APPEND _dir_candidates ${MITK_LIBRARY_DIRS}) endif() list(REMOVE_DUPLICATES _dir_candidates) set(_search_dirs ) foreach(_dir ${_dir_candidates}) if(EXISTS "${_dir}/${intermediate_dir}") list(APPEND _search_dirs "${_dir}/${intermediate_dir}") else() list(APPEND _search_dirs ${_dir}) endif() endforeach() # Special handling for "internal" search dirs. The intermediate directory # might not have been created yet, so we can't check for its existence. # Hence we just add it for Windows without checking. set(_internal_search_dirs ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins) if(WIN32) foreach(_dir ${_internal_search_dirs}) set(_search_dirs ${_dir}/${intermediate_dir} ${_search_dirs}) endforeach() else() set(_search_dirs ${_internal_search_dirs} ${_search_dirs}) endif() list(REMOVE_DUPLICATES _search_dirs) set(${search_path} ${_search_dirs} PARENT_SCOPE) endfunction() diff --git a/CMake/mitkFunctionUseModules.cmake b/CMake/mitkFunctionUseModules.cmake new file mode 100644 index 0000000000..37936c25cf --- /dev/null +++ b/CMake/mitkFunctionUseModules.cmake @@ -0,0 +1,159 @@ +#! This CMake function sets up the necessary include directories, +#! linker dependencies, and compile flags for a given target which +#! depends on a set of MITK modules, packages, and Qt4 and/or Qt5 +#! components. +#! If a dependency is not available, an error is thrown. +function(mitk_use_modules) + + set(_macro_params + TARGET # The target name (required) + MODULES # MITK modules which the given TARGET uses + PACKAGES # MITK packages which the given TARGET uses + QT4_MODULES # Qt4 components the TARGET depends on + QT5_MODULES # Qt5 components the TARGET depends on + ) + + set(_macro_options ) + + MACRO_PARSE_ARGUMENTS(USE "${_macro_params}" "${_macro_options}" ${ARGN}) + + # Sanity checks + if(NOT USE_TARGET) + message(SEND_ERROR "Required TARGET argument missing.") + elseif(NOT TARGET ${USE_TARGET}) + message(SEND_ERROR "The given TARGET argument ${USE_TARGET} is not a valid target") + endif() + set(all_deps ${USE_MODULES} ${USE_PACKAGES}) + set(all_args MODULES PACKAGES) + if(MITK_USE_Qt4) + list(APPEND all_deps ${USE_QT4_MODULES}) + list(APPEND all_args QT4_MODULES) + elseif(MITK_USE_Qt5) + list(APPEND all_deps ${USE_QT5_MODULES}) + list(APPEND all_args QT5_MODULES) + endif() + if(NOT all_deps) + message(SEND_ERROR "The arguments ${all_args} must not all be empty.") + endif() + + # The MODULE_NAME variable is used for example in the MITK_Qt5*_Config.cmake files + set(MODULE_NAME ${USE_TARGET}) + + set(depends "") + # check for each parameter if it is a package (3rd party) + set(package_candidates ${USE_MODULES} ${USE_PACKAGES}) + if(MITK_USE_Qt4 AND USE_QT4_MODULES) + list(APPEND package_candidates Qt4) + endif() + if(MITK_USE_Qt5 AND USE_QT5_MODULES) + list(APPEND package_candidates ${USE_QT5_MODULES}) + endif() + set(package_depends ) + if(package_candidates) + foreach(package ${package_candidates}) + set(is_package) + foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) + if(EXISTS "${dir}/MITK_${package}_Config.cmake") + list(APPEND package_depends ${package}) + set(is_package 1) + break() + endif() + endforeach() + if(NOT is_package) + list(APPEND depends ${package}) + endif() + endforeach() + endif() + + set(first_level_module_deps ${depends}) + set(depends_before "not initialized") + while(NOT "${depends}" STREQUAL "${depends_before}") + set(depends_before ${depends}) + foreach(dependency ${depends}) + if(NOT ${dependency}_CONFIG_FILE) + message(SEND_ERROR "Missing module: ${dependency}") + endif() + include(${${dependency}_CONFIG_FILE}) + list(APPEND depends ${${dependency}_DEPENDS}) + list(APPEND package_depends ${${dependency}_PACKAGE_DEPENDS}) + endforeach() + + if(depends) + list(REMOVE_DUPLICATES depends) + list(SORT depends) + endif() + + if(package_depends) + list(REMOVE_DUPLICATES package_depends) + list(SORT package_depends) + endif() + endwhile() + + set(ALL_INCLUDE_DIRECTORIES) + set(ALL_LIBRARIES) + set(ALL_QT4_MODULES ${USE_QT4_MODULES}) + set(ALL_QT5_MODULES ${USE_QT5_MODULES}) + set(ALL_META_DEPENDENCIES) + + foreach(dependency ${depends}) + if(NOT ${dependency}_CONFIG_FILE) + message(SEND_ERROR "Missing module ${dependency}") + endif() + include(${${dependency}_CONFIG_FILE}) + if(${dependency}_IS_DEPRECATED AND NOT MODULE_IS_DEPRECATED) + # Only print the message if the dependent module + # is not deprecated itself and if it is a first-level dependency. + if(first_level_module_deps) + list(FIND first_level_module_deps ${dependency} _index) + if(_index GREATER -1) + message(WARNING "Module ${dependency} is deprecated since ${${dependency}_DEPRECATED_SINCE}") + endif() + endif() + endif() + + list(APPEND ALL_INCLUDE_DIRECTORIES ${${dependency}_INCLUDE_DIRS}) + list(APPEND ALL_LIBRARIES ${${dependency}_PROVIDES}) + list(APPEND ALL_QT4_MODULES ${${dependency}_QT4_MODULES}) + list(APPEND ALL_QT5_MODULES ${${dependency}_QT5_MODULES}) + if(TARGET ${dependency}-autoload) + list(APPEND ALL_META_DEPENDENCIES ${dependency}-autoload) + endif() + endforeach(dependency) + + if(ALL_QT4_MODULES) + list(REMOVE_DUPLICATES ALL_QT4_MODULES) + endif() + if(ALL_QT5_MODULES) + list(REMOVE_DUPLICATES ALL_QT5_MODULES) + endif() + + set(MODULE_QT4_MODULES ${ALL_QT4_MODULES}) + foreach(package ${package_depends}) + foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) + if(EXISTS "${dir}/MITK_${package}_Config.cmake") + include("${dir}/MITK_${package}_Config.cmake") + break() + endif() + endforeach() + endforeach() + + if(depends) + list(APPEND ALL_INCLUDE_DIRECTORIES ${MODULES_CONF_DIRS}) + endif() + + if(ALL_INCLUDE_DIRECTORIES) + list(REMOVE_DUPLICATES ALL_INCLUDE_DIRECTORIES) + include_directories(${ALL_INCLUDE_DIRECTORIES}) + endif() + + if(ALL_LIBRARIES) + target_link_libraries(${USE_TARGET} ${ALL_LIBRARIES}) + endif() + + set(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} PARENT_SCOPE) + set(ALL_LIBRARIES ${ALL_LIBRARIES} PARENT_SCOPE) + set(ALL_QT4_MODULES ${ALL_QT4_MODULES} PARENT_SCOPE) + set(ALL_QT5_MODULES ${ALL_QT5_MODULES} PARENT_SCOPE) + set(ALL_META_DEPENDENCIES ${ALL_META_DEPENDENCIES} PARENT_SCOPE) + +endfunction() diff --git a/CMake/mitkMacroCreateCTKPlugin.cmake b/CMake/mitkMacroCreateCTKPlugin.cmake index 0d30001f76..b0c6ca3108 100644 --- a/CMake/mitkMacroCreateCTKPlugin.cmake +++ b/CMake/mitkMacroCreateCTKPlugin.cmake @@ -1,77 +1,100 @@ macro(MACRO_CREATE_MITK_CTK_PLUGIN) MACRO_PARSE_ARGUMENTS(_PLUGIN "EXPORT_DIRECTIVE;EXPORTED_INCLUDE_SUFFIXES;MODULE_DEPENDENCIES;SUBPROJECTS" "TEST_PLUGIN;NO_INSTALL" ${ARGN}) + if (MITK_USE_Qt4 AND PLUGIN_QT4_MODULES) + list(APPEND _PLUGIN_MODULE_DEPENDENCIES Qt4) + endif() + if (MITK_USE_Qt5 AND PLUGIN_QT5_MODULES) + list(APPEND _PLUGIN_MODULE_DEPENDENCIES Qt5) + endif() + MITK_CHECK_MODULE(_MODULE_CHECK_RESULT Mitk ${_PLUGIN_MODULE_DEPENDENCIES}) if(NOT _MODULE_CHECK_RESULT) - MITK_USE_MODULE(Mitk ${_PLUGIN_MODULE_DEPENDENCIES}) - - link_directories(${ALL_LIBRARY_DIRS}) - include_directories(${ALL_INCLUDE_DIRECTORIES}) if(_PLUGIN_TEST_PLUGIN) set(is_test_plugin "TEST_PLUGIN") set(_PLUGIN_NO_INSTALL 1) else() set(is_test_plugin) endif() if(_PLUGIN_NO_INSTALL) set(plugin_no_install "NO_INSTALL") else() set(plugin_no_install) endif() + # The PACKAGE_DEPENDS variable is filled in the MITK_CHECK_MODULE() macro + foreach(package ${PACKAGE_DEPENDS}) + if(NOT ${package} MATCHES "^Qt[45].*$") + foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) + if(EXISTS "${dir}/MITK_${package}_Config.cmake") + include("${dir}/MITK_${package}_Config.cmake") + break() + endif() + endforeach() + endif() + endforeach() + if(ALL_LIBRARY_DIRS) + list(REMOVE_DUPLICATES ALL_LIBRARY_DIRS) + link_directories(${ALL_LIBRARY_DIRS}) + endif() + MACRO_CREATE_CTK_PLUGIN(EXPORT_DIRECTIVE ${_PLUGIN_EXPORT_DIRECTIVE} EXPORTED_INCLUDE_SUFFIXES ${_PLUGIN_EXPORTED_INCLUDE_SUFFIXES} DOXYGEN_TAGFILES ${_PLUGIN_DOXYGEN_TAGFILES} MOC_OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED ${is_test_plugin} ${plugin_no_install}) - target_link_libraries(${PLUGIN_TARGET} ${ALL_LIBRARIES}) + mitk_use_modules(TARGET ${PLUGIN_TARGET} + MODULES Mitk ${_PLUGIN_MODULE_DEPENDENCIES} + QT4_MODULES ${PLUGIN_QT4_MODULES} + QT5_MODULES ${PLUGIN_QT5_MODULES} + ) if(ALL_META_DEPENDENCIES) add_dependencies(${PLUGIN_TARGET} ${ALL_META_DEPENDENCIES}) endif() if(MITK_DEFAULT_SUBPROJECTS AND NOT MY_SUBPROJECTS) set(MY_SUBPROJECTS ${MITK_DEFAULT_SUBPROJECTS}) endif() if(MY_SUBPROJECTS) set_property(TARGET ${PLUGIN_TARGET} PROPERTY LABELS ${MY_SUBPROJECTS}) foreach(subproject ${MY_SUBPROJECTS}) add_dependencies(${subproject} ${PLUGIN_TARGET}) endforeach() endif() #------------------------------------------------------------# #------------------ Installer support -----------------------# if(NOT _PLUGIN_NO_INSTALL) set(_autoload_targets ) foreach(_dependency ${ALL_DEPENDENCIES}) get_target_property(_dep_autoloads ${_dependency} MITK_AUTOLOAD_TARGETS) if (_dep_autoloads) list(APPEND _autoload_targets ${_dep_autoloads}) endif() endforeach() # The MITK_AUTOLOAD_TARGETS property is used in the mitkFunctionInstallAutoLoadModules # macro which expects a list of plug-in targets. if (_autoload_targets) list(REMOVE_DUPLICATES _autoload_targets) set_target_properties(${PLUGIN_TARGET} PROPERTIES MITK_AUTOLOAD_TARGETS "${_autoload_targets}") endif() endif() else(NOT _MODULE_CHECK_RESULT) if(NOT MITK_BUILD_ALL_PLUGINS) message(SEND_ERROR "${PROJECT_NAME} is missing requirements and won't be built. Missing: ${_MODULE_CHECK_RESULT}") else() message(STATUS "${PROJECT_NAME} is missing requirements and won't be built. Missing: ${_MODULE_CHECK_RESULT}") endif() endif(NOT _MODULE_CHECK_RESULT) endmacro() diff --git a/CMake/mitkMacroCreateExecutable.cmake b/CMake/mitkMacroCreateExecutable.cmake new file mode 100644 index 0000000000..a4ef63d7bb --- /dev/null +++ b/CMake/mitkMacroCreateExecutable.cmake @@ -0,0 +1,90 @@ +################################################################## +# +# MITK_CREATE_EXECUTABLE +# +#! Creates an executable with MITK dependencies and batch files +#! for proper application start-up. +#! +#! USAGE: +#! +#! \code +#! MITK_CREATE_EXECUTABLE( +#! [DEPENDS ] +#! [PACKAGE_DEPENDS ] +#! [INCLUDE_DIRS ] +#! [TARGET_DEPENDS +#! [WARNINGS_AS_ERRORS] +#! \endcode +#! +#! \param EXECUTABLE_NAME The name for the new executable target +################################################################## +macro(mitk_create_executable EXECUTABLE_NAME) + + set(_macro_params + SUBPROJECTS # list of CDash labels + VERSION # version number, e.g. "1.2.0" + INCLUDE_DIRS # additional include dirs + DEPENDS # list of modules this module depends on + PACKAGE_DEPENDS # list of "packages" this module depends on (e.g. Qt, VTK, etc.) + TARGET_DEPENDS # list of CMake targets this executable should depend on + ADDITIONAL_LIBS # list of additional libraries linked to this executable + FILES_CMAKE # file name of a CMake file setting source list variables + # (defaults to files.cmake) + QT4_MODULES # the executable depends on a given list of Qt 4 modules + QT5_MODULES # the executable depends on a given list of Qt 5 modules + ) + + set(_macro_options + NO_INIT # do not create CppMicroServices initialization code + NO_BATCH_FILE # do not create batch files on Windows + WARNINGS_AS_ERRORS # treat all compiler warnings as errors + ) + + MACRO_PARSE_ARGUMENTS(EXEC "${_macro_params}" "${_macro_options}" ${ARGN}) + + set(EXEC_NAME ${EXECUTABLE_NAME}) + + set(_EXEC_OPTIONS EXECUTABLE) + if(EXEC_NO_INIT) + list(APPEND _EXEC_OPTIONS NO_INIT) + endif() + if(EXEC_WARNINGS_AS_ERRORS) + list(APPEND _EXEC_OPTIONS WARNINGS_AS_ERRORS) + endif() + + mitk_create_module(${EXEC_NAME} + SUBPROJECTS ${EXEC_SUBPROJECTS} + VERSION ${EXEC_VERSION} + INCLUDE_DIRS ${EXEC_INCLUDE_DIRS} + DEPENDS ${EXEC_DEPENDS} + PACKAGE_DEPENDS ${EXEC_PACKAGE_DEPENDS} + TARGET_DEPENDS ${EXEC_TARGET_DEPENDS} + ADDITIONAL_LIBS ${EXEC_ADDITIONAL_LIBS} + FILES_CMAKE ${EXEC_FILES_CMAKE} + QT4_MODULES ${EXEC_QT4_MODULES} + QT5_MODULES ${EXEC_QT5_MODULES} + ${_EXEC_OPTIONS} + ) + + # Create batch files for Windows platforms + if(WIN32) + set(_batch_file_in "${CMAKE_CURRENT_SOURCE_DIR}/${EXEC_NAME}.bat.in") + if(NOT EXISTS "${_batch_file_in}") + set(_batch_file_in "${MITK_CMAKE_DIR}/StartApp.bat.in") + endif() + if(CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(_batch_file_out_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + else() + set(_batch_file_out_dir "${CMAKE_CURRENT_BINARY_DIR}") + endif() + if(NOT EXEC_NO_BATCH_FILE) + foreach(BUILD_TYPE debug release) + mitkFunctionCreateWindowsBatchScript( + ${_batch_file_in} ${_batch_file_out_dir}/${EXEC_NAME}_${BUILD_TYPE}.bat + ${BUILD_TYPE} + ) + endforeach() + endif() + endif() + +endmacro() diff --git a/CMake/mitkMacroCreateModule.cmake b/CMake/mitkMacroCreateModule.cmake index c3351a8c9b..2d3585f942 100644 --- a/CMake/mitkMacroCreateModule.cmake +++ b/CMake/mitkMacroCreateModule.cmake @@ -1,435 +1,562 @@ ################################################################## # # MITK_CREATE_MODULE # #! Creates a module for the automatic module dependency system within MITK. #! Configurations are generated in the moduleConf directory. #! #! USAGE: #! #! \code #! MITK_CREATE_MODULE( #! [INCLUDE_DIRS ] #! [INTERNAL_INCLUDE_DIRS ] #! [DEPENDS ] #! [PACKAGE_DEPENDS ] #! [TARGET_DEPENDS #! [EXPORT_DEFINE ] #! [QT_MODULE] #! [HEADERS_ONLY] #! [WARNINGS_AS_ERRORS] #! \endcode #! +#! 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 +#! #! \param MODULE_NAME_IN The name for the new module #! \param HEADERS_ONLY specify this if the modules just contains header files. ################################################################## macro(MITK_CREATE_MODULE MODULE_NAME_IN) set(_macro_params SUBPROJECTS # list of CDash labels VERSION # module version number, e.g. "1.2.0" INCLUDE_DIRS # exported include dirs (used in mitkMacroCreateModuleConf.cmake) INTERNAL_INCLUDE_DIRS # include dirs internal to this module DEPENDS # list of modules this module depends on DEPENDS_INTERNAL # list of modules this module internally depends on PACKAGE_DEPENDS # list of "packages this module depends on (e.g. Qt, VTK, etc.) TARGET_DEPENDS # list of CMake targets this module should depend on EXPORT_DEFINE # export macro name for public symbols of this module AUTOLOAD_WITH # a module target name identifying the module which will trigger the # automatic loading of this module ADDITIONAL_LIBS # list of addidtional libraries linked to this module + FILES_CMAKE # file name of a CMake file setting source list variables + # (defaults to files.cmake) GENERATED_CPP # not used (?) + QT4_MODULES # the module depends on a given list of Qt 4 modules + QT5_MODULES # the module depends on a given list of Qt 5 modules DEPRECATED_SINCE # marks this modules as deprecated ) set(_macro_options - QT_MODULE # the module makes use of Qt features and needs moc and ui generated files + QT_MODULE # the module makes use of Qt4 features and needs moc and ui generated files 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_INIT # do not create CppMicroServices initialization code WARNINGS_AS_ERRORS # treat all compiler warnings as errors + EXECUTABLE # create an executable; do not use directly, use mitk_create_executable() instead ) MACRO_PARSE_ARGUMENTS(MODULE "${_macro_params}" "${_macro_options}" ${ARGN}) set(MODULE_NAME ${MODULE_NAME_IN}) + 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() + + if (MODULE_QT_MODULE) + message(WARNING "QT_MODULE keyword is deprecated (in module ${MODULE_NAME}). Please replace QT_MODULE by the more specific QT4_MODULES / QT5_MODULES!") + if (NOT MODULE_QT4_MODULES) + set(MODULE_QT4_MODULES QtGui) + endif() + endif() + + if (MODULE_QT4_MODULES) + set (MODULE_QT_MODULE TRUE) # defines that we want to process UIC_FILES, QRC_FILES etc. from files.cmake + if (MITK_USE_Qt4) + list(APPEND MODULE_PACKAGE_DEPENDS Qt4) # QT4_MODULES will create package dependencies to Qt4 modules and define a list of Qt 4 components + endif() + endif() + if (MODULE_QT5_MODULES) + set (MODULE_QT_MODULE TRUE) + if (MITK_USE_Qt5) + list(APPEND MODULE_PACKAGE_DEPENDS ${MODULE_QT5_MODULES}) # QT5_MODULES is just an alias for PACKAGE_DEPENDS + endif() + endif() + if(MODULE_HEADERS_ONLY) set(MODULE_PROVIDES ) if(MODULE_AUTOLOAD_WITH) message(SEND_ERROR "A headers only module cannot be auto-loaded") endif() else() set(MODULE_PROVIDES ${MODULE_NAME}) if(NOT MODULE_NO_INIT AND NOT MODULE_NAME STREQUAL "Mitk") # Add a dependency to the "Mitk" module #list(APPEND MODULE_DEPENDS Mitk) endif() endif() if(MODULE_DEPRECATED_SINCE) set(MODULE_IS_DEPRECATED 1) else() set(MODULE_IS_DEPRECATED 0) endif() if(NOT MODULE_SUBPROJECTS) if(MITK_DEFAULT_SUBPROJECTS) set(MODULE_SUBPROJECTS ${MITK_DEFAULT_SUBPROJECTS}) endif() endif() # check if the subprojects exist as targets if(MODULE_SUBPROJECTS) foreach(subproject ${MODULE_SUBPROJECTS}) if(NOT TARGET ${subproject}) message(SEND_ERROR "The subproject ${subproject} does not have a corresponding target") endif() endforeach() endif() # 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() # create a meta-target if it does not already exist set(_module_autoload_meta_target "${MODULE_AUTOLOAD_WITH}-autoload") if(NOT TARGET ${_module_autoload_meta_target}) add_custom_target(${_module_autoload_meta_target}) endif() endif() # 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 AND NOT (MODULE_QT_MODULE AND NOT MITK_USE_QT)) # first of all we check for the dependencies - MITK_CHECK_MODULE(_MISSING_DEP ${MODULE_DEPENDS}) + MITK_CHECK_MODULE(_MISSING_DEP ${MODULE_DEPENDS} ${MODULE_PACKAGE_DEPENDS}) if(_MISSING_DEP) message("Module ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}") set(MODULE_IS_ENABLED 0) else(_MISSING_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 ${MODULE_PACKAGE_DEPENDS}) if((DEFINED MITK_USE_${_package}) AND NOT (MITK_USE_${_package})) - message("Module ${MODULE_NAME} won't be built. Turn on MITK_USE_${_package} if you want to use it.") + if (${_package} MATCHES "Qt[45]") + message("Module ${MODULE_NAME} won't be built because we lack ${_package}. Check CMake switches MITK_USE_QT and DESIRED_QT_VERSION.") + else() + message("Module ${MODULE_NAME} won't be built. Turn on MITK_USE_${_package} if you want to use it.") + endif() set(MODULE_IS_ENABLED 0) endif() endforeach() + + if (MODULE_QT_MODULE) # disable module if it 1. needs Qt 2. has only one of QT4_MODULES/QT5_MODULES set and 3. DESIRED_QT_VERSION does not match the module + if (MITK_USE_Qt4) + if (NOT MODULE_QT4_MODULES) + set (MODULE_IS_ENABLED 0) + endif() + endif() + + if (MITK_USE_Qt5) + if (NOT MODULE_QT5_MODULES) + set (MODULE_IS_ENABLED 0) + endif() + endif() + endif() + 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 ) - set(Q${KITNAME}_GENERATED_CPP ) - _MITK_CREATE_MODULE_CONF() + # Convert relative include dirs to absolute dirs + set(_include_dirs . ${MODULE_INCLUDE_DIRS}) + set(MODULE_INCLUDE_DIRS) + foreach(dir ${_include_dirs}) + get_filename_component(_abs_dir ${dir} ABSOLUTE) + list(APPEND MODULE_INCLUDE_DIRS ${_abs_dir}) + endforeach() + list(APPEND MODULE_INCLUDE_DIRS ${MITK_BINARY_DIR} ${MODULES_CONF_DIRS}) + + # Convert relative internal include dirs to absolute dirs + set(_include_dirs ${MODULE_INTERNAL_INCLUDE_DIRS}) + set(MODULE_INTERNAL_INCLUDE_DIRS) + foreach(dir ${_include_dirs}) + get_filename_component(_abs_dir ${dir} ABSOLUTE) + list(APPEND MODULE_INTERNAL_INCLUDE_DIRS ${_abs_dir}) + endforeach() + + # Qt generates headers in the binary tree + if(MODULE_QT4_MODULES OR MODULE_QT5_MODULES) + list(APPEND MODULE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + # Add the module specific include dirs + include_directories(${MODULE_INCLUDE_DIRS} ${MODULE_INTERNAL_INCLUDE_DIRS}) + + if(NOT MODULE_EXECUTABLE) + _MITK_CREATE_MODULE_CONF() + endif() if(NOT MODULE_EXPORT_DEFINE) set(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT) endif(NOT MODULE_EXPORT_DEFINE) 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) - set(DEPENDS "${MODULE_DEPENDS}") - if(NOT MODULE_NO_INIT) - # Add a CppMicroServices dependency implicitly, since it is - # needed for the generated "module initialization" code. - set(DEPENDS "CppMicroServices;${DEPENDS}") - endif() - set(DEPENDS_BEFORE "not initialized") - set(PACKAGE_DEPENDS "${MODULE_PACKAGE_DEPENDS}") - MITK_USE_MODULE(${DEPENDS}) - # ok, now create the module itself - include_directories(. ${ALL_INCLUDE_DIRECTORIES}) - include(files.cmake) + include(${MODULE_FILES_CMAKE}) 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) set(use_visibility_flags 0) else() # We only support hidden visibility for gcc for now. Clang 3.0 still has troubles with # correctly marking template declarations and explicit template instantiations as exported. # See http://comments.gmane.org/gmane.comp.compilers.clang.scm/50028 # and http://llvm.org/bugs/show_bug.cgi?id=10113 if(CMAKE_COMPILER_IS_GNUCXX) set(use_visibility_flags 1) else() # set(use_visibility_flags 0) endif() endif() if(CMAKE_COMPILER_IS_GNUCXX) # MinGW does not export all symbols automatically, so no need to set flags. # # With gcc < 4.5, RTTI symbols from classes declared in third-party libraries # which are not "gcc visibility aware" are marked with hidden visibility in # DSOs which include the class declaration and which are compiled with # hidden visibility. This leads to dynamic_cast and exception handling problems. # While this problem could be worked around by sandwiching the include # directives for the third-party headers between "#pragma visibility push/pop" # statements, it is generally safer to just use default visibility with # gcc < 4.5. if(${GCC_VERSION} VERSION_LESS "4.5" OR MINGW) set(use_visibility_flags 0) endif() endif() if(use_visibility_flags) mitkFunctionCheckCAndCXXCompilerFlags("-fvisibility=hidden" module_c_flags module_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-fvisibility-inlines-hidden" module_c_flags module_cxx_flags) endif() configure_file(${MITK_SOURCE_DIR}/CMake/moduleExports.h.in ${CMAKE_BINARY_DIR}/${MODULES_CONF_DIRNAME}/${MODULE_NAME}Exports.h @ONLY) if(MODULE_WARNINGS_AS_ERRORS) if(MSVC_VERSION) mitkFunctionCheckCAndCXXCompilerFlags("/WX" 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", see # http://clang-developers.42468.n3.nabble.com/Wc-0x-static-nonintegral-init-gone-td3999651.html # # 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) # VNL headers throw a lot of these, not fixable for us at least in ITK 3 mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=unused-parameter" module_c_flags module_cxx_flags) # Some DICOM header file in ITK mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=cast-align" module_c_flags module_cxx_flags) endif() endif(MODULE_WARNINGS_AS_ERRORS) if(MODULE_FORCE_STATIC) set(_STATIC STATIC) else() set(_STATIC ) endif(MODULE_FORCE_STATIC) if(NOT MODULE_HEADERS_ONLY) set(MODULE_LIBNAME ${MODULE_PROVIDES}) if(NOT MODULE_NO_INIT) - usFunctionGenerateModuleInit(CPP_FILES - NAME ${MODULE_NAME} - LIBRARY_NAME ${MODULE_LIBNAME} - DEPENDS ${MODULE_DEPENDS} ${MODULE_DEPENDS_INTERNAL} ${MODULE_PACKAGE_DEPENDS} - #VERSION ${MODULE_VERSION} - ) + find_package(CppMicroServices QUIET NO_MODULE REQUIRED) + if(MODULE_EXECUTABLE) + usFunctionGenerateExecutableInit(CPP_FILES + IDENTIFIER ${MODULE_NAME} + ) + else() + usFunctionGenerateModuleInit(CPP_FILES + NAME ${MODULE_NAME} + LIBRARY_NAME ${MODULE_LIBNAME} + ) + endif() endif() if(RESOURCE_FILES) set(res_dir Resources) set(binary_res_files ) set(source_res_files ) 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() set(res_macro_args ) if(binary_res_files) list(APPEND res_macro_args ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${res_dir} FILES ${binary_res_files}) endif() if(source_res_files) list(APPEND res_macro_args ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${res_dir} FILES ${source_res_files}) endif() usFunctionEmbedResources(CPP_FILES LIBRARY_NAME ${MODULE_LIBNAME} ${res_macro_args}) endif() endif() - if(MODULE_QT_MODULE) + # Qt 4 case + if(MITK_USE_Qt4) if(UI_FILES) - QT4_WRAP_UI(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES}) - endif(UI_FILES) - + qt4_wrap_ui(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES}) + endif() if(MOC_H_FILES) - QT4_WRAP_CPP(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - endif(MOC_H_FILES) - + qt4_wrap_cpp(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + endif() if(QRC_FILES) - QT4_ADD_RESOURCES(Q${KITNAME}_GENERATED_QRC_CPP ${QRC_FILES}) - endif(QRC_FILES) + qt4_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}) + # all the same for Qt 5 + 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}) + ORGANIZE_SOURCES(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}) if(MODULE_SUBPROJECTS) set_property(SOURCE ${coverage_sources} APPEND PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() if(NOT MODULE_HEADERS_ONLY) + + # We have to include the MITK__Config.cmake files here because + # some external packages do not provide exported targets with an + # absolute path to link to. So we need to add link directories *before* + # add_library() or add_executable() is called. So far, this is needed only + # for GDCM and ACVD. + + # The PACKAGE_DEPENDS variable is filled in the MITK_CHECK_MODULE() macro + foreach(package ${PACKAGE_DEPENDS}) + if(NOT ${package} MATCHES "^Qt[45].*$") + foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) + if(EXISTS "${dir}/MITK_${package}_Config.cmake") + include("${dir}/MITK_${package}_Config.cmake") + break() + endif() + endforeach() + endif() + endforeach() if(ALL_LIBRARY_DIRS) - # LINK_DIRECTORIES applies only to targets which are added after the call to LINK_DIRECTORIES + list(REMOVE_DUPLICATES ALL_LIBRARY_DIRS) link_directories(${ALL_LIBRARY_DIRS}) - endif(ALL_LIBRARY_DIRS) + endif() - add_library(${MODULE_PROVIDES} ${_STATIC} - ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP} - ${DOX_FILES} ${UI_FILES} ${QRC_FILES}) + if(MODULE_EXECUTABLE) + add_executable(${MODULE_PROVIDES} + ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP} + ${DOX_FILES} ${UI_FILES} ${QRC_FILES}) + else() + add_library(${MODULE_PROVIDES} ${_STATIC} + ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP} + ${DOX_FILES} ${UI_FILES} ${QRC_FILES}) + endif() if(MODULE_TARGET_DEPENDS) add_dependencies(${MODULE_PROVIDES} ${MODULE_TARGET_DEPENDS}) endif() if(MODULE_SUBPROJECTS) set_property(TARGET ${MODULE_PROVIDES} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) foreach(subproject ${MODULE_SUBPROJECTS}) add_dependencies(${subproject} ${MODULE_PROVIDES}) endforeach() endif() - if(ALL_LIBRARIES) - target_link_libraries(${MODULE_PROVIDES} ${ALL_LIBRARIES}) - endif(ALL_LIBRARIES) - - if(MODULE_QT_MODULE AND QT_LIBRARIES) - target_link_libraries(${MODULE_PROVIDES} ${QT_LIBRARIES}) + set(DEPENDS "${MODULE_DEPENDS}") + if(NOT MODULE_NO_INIT) + # Add a CppMicroServices dependency implicitly, since it is + # needed for the generated "module initialization" code. + set(DEPENDS "CppMicroServices;${DEPENDS}") endif() + mitk_use_modules(TARGET ${MODULE_PROVIDES} + MODULES ${DEPENDS} + PACKAGES ${MODULE_PACKAGE_DEPENDS} + QT4_MODULES ${MODULE_QT4_MODULES} + QT5_MODULES ${MODULE_QT5_MODULES} + ) if(MINGW) target_link_libraries(${MODULE_PROVIDES} ssp) # add stack smash protection lib endif() # Apply properties to the module target. # We cannot use set_target_properties like below since there is no way to # differentiate C/C++ and Releas/Debug flags using target properties. # See http://www.cmake.org/Bug/view.php?id=6493 #set_target_properties(${MODULE_PROVIDES} PROPERTIES # COMPILE_FLAGS "${module_compile_flags}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${module_c_flags}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${module_c_flags_debug}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${module_c_flags_release}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${module_cxx_flags}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${module_cxx_flags_debug}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${module_cxx_flags_release}") # 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) 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_PROVIDES}) if(MODULE_AUTOLOAD_WITH) # for auto-loaded modules, adapt the output directory add_dependencies(${_module_autoload_meta_target} ${MODULE_PROVIDES}) 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_PROVIDES} PROPERTIES ${_module_output_prop} ${_module_output_dir}/${MODULE_AUTOLOAD_WITH}) else() set_target_properties(${MODULE_PROVIDES} PROPERTIES ${_module_output_prop} ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH}) endif() set_target_properties(${MODULE_PROVIDES} 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_PROVIDES}) endif() endif() - endif(MODULE_IS_ENABLED) - endif(_MISSING_DEP) - endif(NOT MODULE_IS_EXCLUDED AND NOT (MODULE_QT_MODULE AND NOT MITK_USE_QT)) + endif() + endif() + endif() - if(NOT MODULE_IS_ENABLED) + if(NOT MODULE_IS_ENABLED AND NOT MODULE_EXECUTABLE) _MITK_CREATE_MODULE_CONF() - endif(NOT MODULE_IS_ENABLED) + endif() unset(MODULE_IS_DEPRECATED) endmacro(MITK_CREATE_MODULE) diff --git a/CMake/mitkMacroCreateModuleConf.cmake b/CMake/mitkMacroCreateModuleConf.cmake index a9e02c7dfa..0807acc01c 100644 --- a/CMake/mitkMacroCreateModuleConf.cmake +++ b/CMake/mitkMacroCreateModuleConf.cmake @@ -1,40 +1,35 @@ ################################################################### # # MITK_CREATE_MODULE_CONF # # This can be called in a similar way like MITK_CREATE_MODULE # but it just creates the module configuration files without # actually building it. It is used for integration of legacy libraries # into the MITK module build system # ################################################################## macro(MITK_CREATE_MODULE_CONF MODULE_NAME_IN) - MACRO_PARSE_ARGUMENTS(MODULE "INCLUDE_DIRS;DEPENDS;PACKAGE_DEPENDS" "QT_MODULE;HEADERS_ONLY" ${ARGN}) + MACRO_PARSE_ARGUMENTS(MODULE "INCLUDE_DIRS;DEPENDS;PACKAGE_DEPENDS;QT4_MODULES;QT5_MODULES" "QT_MODULE;HEADERS_ONLY" ${ARGN}) set(MODULE_NAME ${MODULE_NAME_IN}) if(MODULE_HEADERS_ONLY) set(MODULE_PROVIDES ) else() set(MODULE_PROVIDES ${MODULE_NAME}) endif() set(MODULE_IS_ENABLED 1) + + if(MODULE_QT_MODULE) + message(WARNING "The QT_MODULE option is deprecated. Use QT4_MODULES and/or QT5_MODULES instead.") + if(NOT MODULE_QT4_MODULES) + set(MODULE_QT4_MODULES QtGui) + endif() + endif() + + list(APPEND MODULE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) _MITK_CREATE_MODULE_CONF() endmacro(MITK_CREATE_MODULE_CONF) macro(_MITK_CREATE_MODULE_CONF) - if(NOT MODULE_QT_MODULE OR MITK_USE_QT) - set(MODULE_INCLUDE_DIRS_ABSOLUTE "") - foreach(dir ${MODULE_INCLUDE_DIRS}) - get_filename_component(abs_dir ${dir} ABSOLUTE) - set(MODULE_INCLUDE_DIRS_ABSOLUTE ${MODULE_INCLUDE_DIRS_ABSOLUTE} ${abs_dir}) - endforeach(dir) - - set(MODULE_INCLUDE_DIRS ${MODULE_INCLUDE_DIRS_ABSOLUTE} ${CMAKE_CURRENT_SOURCE_DIR}) - - # Qt generates headers in the binary tree - if(MODULE_QT_MODULE) - set(MODULE_INCLUDE_DIRS ${MODULE_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) - endif(MODULE_QT_MODULE) - set(${MODULE_NAME}_CONFIG_FILE "${CMAKE_BINARY_DIR}/${MODULES_CONF_DIRNAME}/${MODULE_NAME}Config.cmake" CACHE INTERNAL "Path to module config" FORCE) - configure_file(${MITK_SOURCE_DIR}/CMake/moduleConf.cmake.in ${${MODULE_NAME}_CONFIG_FILE} @ONLY) - endif(NOT MODULE_QT_MODULE OR MITK_USE_QT) + set(${MODULE_NAME}_CONFIG_FILE "${CMAKE_BINARY_DIR}/${MODULES_CONF_DIRNAME}/${MODULE_NAME}Config.cmake" CACHE INTERNAL "Path to module config" FORCE) + configure_file(${MITK_SOURCE_DIR}/CMake/moduleConf.cmake.in ${${MODULE_NAME}_CONFIG_FILE} @ONLY) endmacro(_MITK_CREATE_MODULE_CONF) diff --git a/CMake/mitkMacroCreateModuleTests.cmake b/CMake/mitkMacroCreateModuleTests.cmake index d1fa655554..c8a19ace0b 100644 --- a/CMake/mitkMacroCreateModuleTests.cmake +++ b/CMake/mitkMacroCreateModuleTests.cmake @@ -1,129 +1,149 @@ # # Create tests and testdriver for this module # # Usage: MITK_CREATE_MODULE_TESTS( [EXTRA_DRIVER_INIT init_code] ) # # EXTRA_DRIVER_INIT is inserted as c++ code in the testdriver and will be executed before each test # macro(MITK_CREATE_MODULE_TESTS) MACRO_PARSE_ARGUMENTS(MODULE_TEST "EXTRA_DRIVER_INIT;EXTRA_DRIVER_INCLUDE;EXTRA_DEPENDS" "" ${ARGN}) if(BUILD_TESTING AND MODULE_IS_ENABLED) set(OLD_MOC_H_FILES ${MOC_H_FILES}) set(MOC_H_FILES) include(files.cmake) include_directories(.) + if(MODULE_TEST_EXTRA_DEPENDS) + message(WARNING "The keyword EXTRA_DEPENDS is deprecated. Use a separate call to mitk_use_modules instead.") + endif() + if(DEFINED MOC_H_FILES) QT4_WRAP_CPP(MODULE_TEST_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) endif(DEFINED MOC_H_FILES) - MITK_USE_MODULE(CppUnit ${MODULE_TEST_EXTRA_DEPENDS}) - include_directories(${ALL_INCLUDE_DIRECTORIES}) + # The PACKAGE_DEPENDS variable is filled in the MITK_CHECK_MODULE() macro + foreach(package ${PACKAGE_DEPENDS}) + if(NOT ${package} MATCHES "^Qt[45].*$") + foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) + if(EXISTS "${dir}/MITK_${package}_Config.cmake") + include("${dir}/MITK_${package}_Config.cmake") + break() + endif() + endforeach() + endif() + endforeach() + if(ALL_LIBRARY_DIRS) + list(REMOVE_DUPLICATES ALL_LIBRARY_DIRS) + link_directories(${ALL_LIBRARY_DIRS}) + endif() set(TESTDRIVER ${MODULE_NAME}TestDriver) set(MODULE_TEST_EXTRA_DRIVER_INIT "${MODULE_TEST_EXTRA_DRIVER_INIT}") # Write a header file containing include directives and custom code # for the test driver. set(_extra_include_content ) list(APPEND MODULE_TEST_EXTRA_DRIVER_INCLUDE "mitkLog.h") list(REMOVE_DUPLICATES MODULE_TEST_EXTRA_DRIVER_INCLUDE) foreach(_include ${MODULE_TEST_EXTRA_DRIVER_INCLUDE}) set(_extra_include_content "${_extra_include_content} #include <${_include}>") endforeach() set(_extra_include_content "${_extra_include_content} #include std::vector globalCmdLineArgs;") set(_extra_include_file ${CMAKE_CURRENT_BINARY_DIR}/${TESTDRIVER}_extras.h) file(WRITE ${_extra_include_file} "${_extra_include_content}") set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " for (int avIndex = 1; avIndex < ac; ++avIndex) globalCmdLineArgs.push_back(av[avIndex]); mitk::LoggingBackend::Register(); ${MODULE_TEST_EXTRA_DRIVER_INIT};" ) set(CMAKE_TESTDRIVER_AFTER_TESTMAIN "mitk::LoggingBackend::Unregister();") create_test_sourcelist(MODULETEST_SOURCE ${MODULE_NAME}TestDriver.cpp ${MODULE_TESTS} ${MODULE_IMAGE_TESTS} ${MODULE_SURFACE_TESTS} ${MODULE_CUSTOM_TESTS} EXTRA_INCLUDE ${_extra_include_file} ) add_executable(${TESTDRIVER} ${MODULETEST_SOURCE} ${MODULE_TEST_GENERATED_MOC_CPP} ${TEST_CPP_FILES}) - target_link_libraries(${TESTDRIVER} ${MODULE_PROVIDES} ${ALL_LIBRARIES}) + mitk_use_modules(TARGET ${TESTDRIVER} + MODULES ${MODULE_PROVIDES} ${MODULE_TEST_EXTRA_DEPENDS} + PACKAGES CppUnit + ) if(MODULE_SUBPROJECTS) foreach(subproject ${MODULE_SUBPROJECTS}) add_dependencies(${subproject} ${TESTDRIVER}) endforeach() endif() # # Now tell CMake which tests should be run. This is done automatically # for all tests in ${KITNAME}_TESTS and ${KITNAME}_IMAGE_TESTS. The IMAGE_TESTS # are run for each image in the TESTIMAGES list. # foreach( test ${MODULE_TESTS} ) get_filename_component(TName ${test} NAME_WE) add_test(${TName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${TName}) # Add labels for CDash subproject support if(MODULE_SUBPROJECTS) set_property(TEST ${TName} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() endforeach( test ) foreach(image ${MODULE_TESTIMAGES} ${ADDITIONAL_TEST_IMAGES} ) if(EXISTS ${image}) set(IMAGE_FULL_PATH ${image}) else(EXISTS ${image}) # todo: maybe search other paths as well # yes, please in mitk/Testing/Data, too set(IMAGE_FULL_PATH ${MITK_DATA_DIR}/${image}) endif(EXISTS ${image}) if(EXISTS ${IMAGE_FULL_PATH}) foreach( test ${MODULE_IMAGE_TESTS} ) get_filename_component(TName ${test} NAME_WE) get_filename_component(ImageName ${IMAGE_FULL_PATH} NAME) add_test(${TName}_${ImageName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${TName} ${IMAGE_FULL_PATH}) # Add labels for CDash subproject support if(MODULE_SUBPROJECTS) set_property(TEST ${TName}_${ImageName} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() endforeach( test ) else(EXISTS ${IMAGE_FULL_PATH}) message("!!!!! No such file: ${IMAGE_FULL_PATH} !!!!!") endif(EXISTS ${IMAGE_FULL_PATH}) endforeach( image ) foreach(surface ${MODULE_TESTSURFACES} ${ADDITIONAL_TEST_SURFACES} ) if(EXISTS ${surface}) set(SURFACE_FULL_PATH ${surface}) else(EXISTS ${surface}) # todo: maybe search other paths as well # yes, please in mitk/Testing/Data, too set(SURFACE_FULL_PATH ${MITK_DATA_DIR}/${surface}) endif(EXISTS ${surface}) if(EXISTS ${SURFACE_FULL_PATH}) foreach( test ${MODULE_SURFACE_TESTS} ) get_filename_component(TName ${test} NAME_WE) get_filename_component(SurfaceName ${SURFACE_FULL_PATH} NAME) add_test(${TName}_${SurfaceName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTDRIVER} ${TName} ${SURFACE_FULL_PATH}) # Add labels for CDash subproject support if(MODULE_SUBPROJECTS) set_property(TEST ${TName}_${SurfaceName} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK) endif() endforeach( test ) else(EXISTS ${SURFACE_FULL_PATH}) message("!!!!! No such surface file: ${SURFACE_FULL_PATH} !!!!!") endif(EXISTS ${SURFACE_FULL_PATH}) endforeach( surface ) set(MOC_H_FILES ${OLD_MOC_H_FILES}) endif(BUILD_TESTING AND MODULE_IS_ENABLED) endmacro(MITK_CREATE_MODULE_TESTS) diff --git a/CMake/mitkMacroUseModule.cmake b/CMake/mitkMacroUseModule.cmake index c11047304c..1e0968bfbd 100644 --- a/CMake/mitkMacroUseModule.cmake +++ b/CMake/mitkMacroUseModule.cmake @@ -1,84 +1,88 @@ macro(MITK_USE_MODULE) + message(WARNING "The MITK_USE_MODULE macro is deprecated, use the mitk_use_modules macro instead.") + set(MODULE_FIRST_LEVEL_DEPENDS ${ARGN}) set(DEPENDS "") set(DEPENDS_BEFORE "not initialized") # check for each parameter if it is a package (3rd party) foreach(package ${MODULE_FIRST_LEVEL_DEPENDS}) set(is_package) foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) if(EXISTS "${dir}/MITK_${package}_Config.cmake") list(APPEND PACKAGE_DEPENDS ${package}) set(is_package 1) break() endif() endforeach() if(NOT is_package) list(APPEND DEPENDS ${package}) endif() endforeach(package) while(NOT "${DEPENDS}" STREQUAL "${DEPENDS_BEFORE}") set(DEPENDS_BEFORE ${DEPENDS}) foreach(dependency ${DEPENDS}) if(NOT ${dependency}_CONFIG_FILE) message(SEND_ERROR "Missing module: ${dependency}") endif() include(${${dependency}_CONFIG_FILE}) list(APPEND DEPENDS ${${dependency}_DEPENDS}) list(APPEND PACKAGE_DEPENDS ${${dependency}_PACKAGE_DEPENDS}) endforeach(dependency) if(DEPENDS) list(REMOVE_DUPLICATES DEPENDS) list(SORT DEPENDS) endif(DEPENDS) if(PACKAGE_DEPENDS) list(REMOVE_DUPLICATES PACKAGE_DEPENDS) list(SORT PACKAGE_DEPENDS) endif(PACKAGE_DEPENDS) endwhile() # CMake Debug set(ALL_DEPENDENCIES ${DEPENDS}) foreach(dependency ${DEPENDS} ${MODULE_DEPENDS_INTERNAL}) if(NOT ${dependency}_CONFIG_FILE) message(SEND_ERROR "Missing module ${dependency}") endif() include(${${dependency}_CONFIG_FILE}) if(${dependency}_IS_DEPRECATED AND NOT MODULE_IS_DEPRECATED) # Only print the message if the dependent module # is not deprecated itself and if it is a first-level dependency. if(MODULE_FIRST_LEVEL_DEPENDS) list(FIND MODULE_FIRST_LEVEL_DEPENDS ${dependency} _index) if(_index GREATER -1) message(WARNING "Module ${dependency} is deprecated since ${${dependency}_DEPRECATED_SINCE}") endif() endif() endif() - set(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} ${${dependency}_INCLUDE_DIRS}) - set(ALL_LIBRARIES ${ALL_LIBRARIES} ${${dependency}_PROVIDES}) - set(ALL_LIBRARY_DIRS ${ALL_LIBRARY_DIRS} ${${dependency}_LIBRARY_DIRS}) + list(APPEND ALL_INCLUDE_DIRECTORIES ${${dependency}_INCLUDE_DIRS}) + list(APPEND ALL_LIBRARIES ${${dependency}_PROVIDES}) + list(APPEND ALL_LIBRARY_DIRS ${${dependency}_LIBRARY_DIRS}) + list(APPEND MODULE_QT4_MODULES ${${dependency}_QT4_MODULES}) + list(APPEND MODULE_QT5_MODULES ${${dependency}_QT5_MODULES}) if(TARGET ${dependency}-autoload) list(APPEND ALL_META_DEPENDENCIES ${dependency}-autoload) endif() endforeach(dependency) foreach(package ${PACKAGE_DEPENDS}) foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) if(EXISTS "${dir}/MITK_${package}_Config.cmake") include("${dir}/MITK_${package}_Config.cmake") break() endif() endforeach() #set(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} ${${package}_INCLUDE_DIRS}) # set(ALL_LIBRARIES ${ALL_LIBRARIES} ${${package}_LIBRARIES}) endforeach(package) set(ALL_LIBRARIES ${ALL_LIBRARIES} ${MODULE_ADDITIONAL_LIBS}) set(ALL_INCLUDE_DIRECTORIES ${MITK_BINARY_DIR} ${ALL_INCLUDE_DIRECTORIES} ${MODULE_INCLUDE_DIRS} ${MODULE_INTERNAL_INCLUDE_DIRS} ${MODULES_CONF_DIRS}) if(ALL_INCLUDE_DIRECTORIES) list(REMOVE_DUPLICATES ALL_INCLUDE_DIRECTORIES) endif() if(ALL_LIBRARY_DIRS) list(REMOVE_DUPLICATES ALL_LIBRARY_DIRS) endif(ALL_LIBRARY_DIRS) endmacro(MITK_USE_MODULE) diff --git a/CMake/mitkSetupVariables.cmake b/CMake/mitkSetupVariables.cmake index cf42fabb11..d65a565504 100644 --- a/CMake/mitkSetupVariables.cmake +++ b/CMake/mitkSetupVariables.cmake @@ -1,265 +1,279 @@ if(MITK_BUILD_ALL_PLUGINS) set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") endif() set(LIBPOSTFIX "") # MITK_VERSION set(MITK_VERSION_MAJOR "2013") set(MITK_VERSION_MINOR "12") set(MITK_VERSION_PATCH "99") 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() # Needed early on for redirecting the BlueBerry documentation output dir set(MITK_DOXYGEN_OUTPUT_DIR ${PROJECT_BINARY_DIR}/Documentation/Doxygen CACHE PATH "Output directory for doxygen generated documentation." ) #----------------------------------- # Configuration of module system #----------------------------------- set(MODULES_CONF_DIRNAME modulesConf) set(MODULES_CONF_DIRS ${MITK_BINARY_DIR}/${MODULES_CONF_DIRNAME}) if(NOT UNIX AND NOT MINGW) set(MITK_WIN32_FORCE_STATIC "STATIC" CACHE INTERNAL "Use this variable to always build static libraries on non-unix platforms") endif() # build the MITK_INCLUDE_DIRS variable set(MITK_INCLUDE_DIRS ${ITK_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} ${PROJECT_BINARY_DIR} # contains mitkConfig.h and similar files ${MODULES_CONF_DIRS} # contains module *Exports.h files ) set(CORE_DIRECTORIES Common DataManagement Algorithms IO Rendering Interactions Controllers Service) foreach(d ${CORE_DIRECTORIES}) list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Core/Code/${d}) endforeach() #list(APPEND MITK_INCLUDE_DIRS #${ITK_INCLUDE_DIRS} #${VTK_INCLUDE_DIRS} # ) foreach(d Utilities Utilities/ipPic Utilities/mbilog) list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/${d}) endforeach() list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/Utilities/mbilog) if(WIN32) list(APPEND MITK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipPic/win32) endif() # additional include dirs variables set(IPSEGMENTATION_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipSegmentation) # variables containing librariy names set(MITK_CORE_LIBRARIES Mitk) set(VTK_FOR_MITK_LIBRARIES vtkalglib vtkChartsCore vtkCommonColor vtkCommonComputationalGeometry vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkDICOMParser vtkDomainsChemistry vtkexoIIc vtkexpat vtkFiltersAMR vtkFiltersCore vtkFiltersExtraction vtkFiltersFlowPaths vtkFiltersGeneral vtkFiltersGeneric vtkFiltersGeometry vtkFiltersHybrid vtkFiltersHyperTree vtkFiltersImaging vtkFiltersModeling vtkFiltersParallel vtkFiltersParallelImaging vtkFiltersProgrammable vtkFiltersSelection vtkFiltersSources vtkFiltersStatistics vtkFiltersTexture vtkFiltersVerdict vtkfreetype vtkftgl vtkGeovisCore vtkgl2ps vtkhdf5 vtkhdf5_hl vtkImagingColor vtkImagingCore vtkImagingFourier vtkImagingGeneral vtkImagingHybrid vtkImagingMath vtkImagingMorphological vtkImagingSources vtkImagingStatistics vtkImagingStencil vtkInfovisCore vtkInfovisLayout vtkInteractionImage vtkInteractionStyle vtkInteractionWidgets vtkIOAMR vtkIOCore vtkIOEnSight vtkIOExodus vtkIOExport vtkIOGeometry vtkIOImage vtkIOImport vtkIOInfovis vtkIOLegacy vtkIOLSDyna vtkIOMINC vtkIOMovie vtkIONetCDF vtkIOParallel vtkIOPLY vtkIOSQL vtkIOVideo vtkIOXML vtkIOXMLParser vtkjpeg vtkjsoncpp vtklibxml2 vtkmetaio vtkNetCDF vtkNetCDF_cxx vtkoggtheora vtkParallelCore vtkpng vtkproj4 vtkRenderingAnnotation vtkRenderingContext2D vtkRenderingCore vtkRenderingFreeType vtkRenderingFreeTypeOpenGL vtkRenderingGL2PS vtkRenderingHybridOpenGL vtkRenderingImage vtkRenderingLabel vtkRenderingLOD vtkRenderingOpenGL vtkRenderingVolume vtkRenderingVolumeAMR vtkRenderingVolumeOpenGL vtkGUISupportQtOpenGL vtksqlite vtksys vtkTestingRendering vtktiff vtkViewsContext2D vtkViewsCore vtkViewsGeovis vtkViewsInfovis vtkzlib vtkGUISupportQt vtkGUISupportQtWebkit ${VTK_JPEG_LIBRARIES} ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_EXPAT_LIBRARIES} ${VTK_FREETYPE_LIBRARIES} ) # TODO: maybe solve this with lib depends mechanism of CMake set(UTIL_FOR_MITK_LIBRARIES mbilog) set(LIBRARIES_FOR_MITK_CORE ${UTIL_FOR_MITK_LIBRARIES} ${VTK_FOR_MITK_LIBRARIES} ${ITK_LIBRARIES} ) set(MITK_LIBRARIES ${MITK_CORE_LIBRARIES} ${LIBRARIES_FOR_MITK_CORE} ) # variables used in CMake macros which are called from external projects set(MITK_VTK_LIBRARY_DIRS ${VTK_LIBRARY_DIRS}) set(MITK_ITK_LIBRARY_DIRS ${ITK_LIBRARY_DIRS}) # variables containing link directories set(MITK_LIBRARY_DIRS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) set(MITK_LINK_DIRECTORIES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${ITK_LIBRARY_DIRS} ${VTK_LIBRARY_DIRS} ${GDCM_LIBRARY_DIRS}) # Qt support if(MITK_USE_QT) - find_package(Qt4 REQUIRED) - set(QMITK_INCLUDE_DIRS - ${MITK_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR}/Modules/Qmitk - ${PROJECT_BINARY_DIR}/Modules/Qmitk - ) + if(DESIRED_QT_VERSION MATCHES 4) + find_package(Qt4 REQUIRED) - set(QMITK_LIBRARIES Qmitk ${MITK_LIBRARIES}) - set(QMITK_LINK_DIRECTORIES ${MITK_LINK_DIRECTORIES}) + set(QMITK_INCLUDE_DIRS + ${MITK_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/Modules/Qmitk + ${PROJECT_BINARY_DIR}/Modules/Qmitk + ) + + set(QMITK_LIBRARIES Qmitk ${MITK_LIBRARIES}) + set(QMITK_LINK_DIRECTORIES ${MITK_LINK_DIRECTORIES}) + elseif(DESIRED_QT_VERSION MATCHES 5) + find_package(Qt5Core REQUIRED) # at least Core required + + set(QMITK_INCLUDE_DIRS + ${MITK_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/Modules/QmlMitk + ${PROJECT_BINARY_DIR}/Modules/QmlMitk + ) + + set(QMITK_LIBRARIES QmlMitk ${MITK_LIBRARIES}) + set(QMITK_LINK_DIRECTORIES ${MITK_LINK_DIRECTORIES}) + endif() endif() if(MITK_BUILD_ALL_PLUGINS) set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") endif() # create a list of types for template instantiations of itk image access functions function(_create_type_seq TYPES seq_var seqdim_var) set(_seq ) set(_seq_dim ) string(REPLACE "," ";" _pixeltypes "${TYPES}") foreach(_pixeltype ${_pixeltypes}) set(_seq "${_seq}(${_pixeltype})") set(_seq_dim "${_seq_dim}((${_pixeltype},dim))") endforeach() set(${seq_var} "${_seq}" PARENT_SCOPE) set(${seqdim_var} "${_seq_dim}" PARENT_SCOPE) endfunction() set(MITK_ACCESSBYITK_PIXEL_TYPES ) set(MITK_ACCESSBYITK_PIXEL_TYPES_SEQ ) set(MITK_ACCESSBYITK_TYPES_DIMN_SEQ ) # concatenate only the simple pixel types to the MITK_ACCESSBYITK_PIXEL_TYPE_SEQ list # see Bug 12682 for detailed information foreach(_type INTEGRAL FLOATING) set(_typelist "${MITK_ACCESSBYITK_${_type}_PIXEL_TYPES}") if(_typelist) if(MITK_ACCESSBYITK_PIXEL_TYPES) set(MITK_ACCESSBYITK_PIXEL_TYPES "${MITK_ACCESSBYITK_PIXEL_TYPES},${_typelist}") else() set(MITK_ACCESSBYITK_PIXEL_TYPES "${_typelist}") endif() endif() _create_type_seq("${_typelist}" MITK_ACCESSBYITK_${_type}_PIXEL_TYPES_SEQ MITK_ACCESSBYITK_${_type}_TYPES_DIMN_SEQ) set(MITK_ACCESSBYITK_PIXEL_TYPES_SEQ "${MITK_ACCESSBYITK_PIXEL_TYPES_SEQ}${MITK_ACCESSBYITK_${_type}_PIXEL_TYPES_SEQ}") set(MITK_ACCESSBYITK_TYPES_DIMN_SEQ "${MITK_ACCESSBYITK_TYPES_DIMN_SEQ}${MITK_ACCESSBYITK_${_type}_TYPES_DIMN_SEQ}") endforeach() # separate processing of the COMPOSITE list to avoid its concatenation to to global list _create_type_seq(${MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES} MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES_SEQ MITK_ACCESSBYITK_COMPOSITE_TYPES_DIMN_SEQ) set(MITK_ACCESSBYITK_DIMENSIONS_SEQ ) string(REPLACE "," ";" _dimensions "${MITK_ACCESSBYITK_DIMENSIONS}") foreach(_dimension ${_dimensions}) set(MITK_ACCESSBYITK_DIMENSIONS_SEQ "${MITK_ACCESSBYITK_DIMENSIONS_SEQ}(${_dimension})") endforeach() diff --git a/CMake/moduleConf.cmake.in b/CMake/moduleConf.cmake.in index 38d759039d..4fea866d81 100644 --- a/CMake/moduleConf.cmake.in +++ b/CMake/moduleConf.cmake.in @@ -1,12 +1,14 @@ set(@MODULE_NAME@_IS_ENABLED "@MODULE_IS_ENABLED@") set(@MODULE_NAME@_IS_DEPRECATED "@MODULE_IS_DEPRECATED@") set(@MODULE_NAME@_DEPRECATED_SINCE "@MODULE_DEPRECATED_SINCE@") if(@MODULE_NAME@_IS_ENABLED) @MODULE_EXTRA_CMAKE_CODE@ set(@MODULE_NAME@_INCLUDE_DIRS "@MODULE_INCLUDE_DIRS@") set(@MODULE_NAME@_PROVIDES "@MODULE_PROVIDES@") set(@MODULE_NAME@_DEPENDS "@MODULE_DEPENDS@") set(@MODULE_NAME@_PACKAGE_DEPENDS "@MODULE_PACKAGE_DEPENDS@") + set(@MODULE_NAME@_QT4_MODULES "@MODULE_QT4_MODULES@") + set(@MODULE_NAME@_QT5_MODULES "@MODULE_QT5_MODULES@") set(@MODULE_NAME@_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@") endif(@MODULE_NAME@_IS_ENABLED) diff --git a/CMakeExternals/CTK.cmake b/CMakeExternals/CTK.cmake index 39b7046e02..a336addd86 100644 --- a/CMakeExternals/CTK.cmake +++ b/CMakeExternals/CTK.cmake @@ -1,93 +1,93 @@ #----------------------------------------------------------------------------- # CTK #----------------------------------------------------------------------------- if(MITK_USE_CTK) # Sanity checks if(DEFINED CTK_DIR AND NOT EXISTS ${CTK_DIR}) message(FATAL_ERROR "CTK_DIR variable is defined but corresponds to non-existing directory") endif() set(proj CTK) set(proj_DEPENDENCIES ) set(CTK_DEPENDS ${proj}) if(NOT DEFINED CTK_DIR) set(revision_tag b6e95196) #IF(${proj}_REVISION_TAG) # SET(revision_tag ${${proj}_REVISION_TAG}) #ENDIF() set(ctk_optional_cache_args ) if(MITK_USE_Python) list(APPEND ctk_optional_cache_args -DCTK_LIB_Scripting/Python/Widgets:BOOL=ON -DCTK_ENABLE_Python_Wrapping:BOOL=ON -DCTK_APP_ctkSimplePythonShell:BOOL=ON -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} -DPYTHON_INCLUDE_DIR2:PATH=${PYTHON_INCLUDE_DIR2} -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} ) else() list(APPEND ctk_optional_cache_args -DCTK_LIB_Scripting/Python/Widgets:BOOL=OFF -DCTK_ENABLE_Python_Wrapping:BOOL=OFF -DCTK_APP_ctkSimplePythonShell:BOOL=OFF ) endif() if(MITK_USE_DCMTK) list(APPEND ctk_optional_cache_args -DDCMTK_DIR:PATH=${DCMTK_DIR} ) list(APPEND proj_DEPENDENCIES DCMTK) else() list(APPEND ctk_optional_cache_args -DDCMTK_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_DCMTK_085525e6.tar.gz ) endif() FOREACH(type RUNTIME ARCHIVE LIBRARY) IF(DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY) LIST(APPEND mitk_optional_cache_args -DCTK_PLUGIN_${type}_OUTPUT_DIRECTORY:PATH=${CTK_PLUGIN_${type}_OUTPUT_DIRECTORY}) ENDIF() ENDFOREACH() ExternalProject_Add(${proj} SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}-src BINARY_DIR ${proj}-build PREFIX ${proj}-cmake URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_${revision_tag}.tar.gz URL_MD5 89a9d356a78c463a818680648443465f UPDATE_COMMAND "" INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} ${ctk_optional_cache_args} - -DDESIRED_QT_VERSION:STRING=4 + -DDESIRED_QT_VERSION:STRING=${DESIRED_QT_VERSION} -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DGit_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DGIT_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DCTK_LIB_CommandLineModules/Backend/LocalProcess:BOOL=ON -DCTK_LIB_CommandLineModules/Frontend/QtGui:BOOL=ON -DCTK_LIB_PluginFramework:BOOL=ON -DCTK_LIB_DICOM/Widgets:BOOL=ON -DCTK_PLUGIN_org.commontk.eventadmin:BOOL=ON -DCTK_PLUGIN_org.commontk.configadmin:BOOL=ON -DCTK_USE_GIT_PROTOCOL:BOOL=OFF -DDCMTK_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_DCMTK_085525e6.tar.gz DEPENDS ${proj_DEPENDENCIES} ) set(CTK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif() endif() diff --git a/CMakeExternals/Qwt.cmake b/CMakeExternals/Qwt.cmake index d74d3356a7..83bf05ef75 100644 --- a/CMakeExternals/Qwt.cmake +++ b/CMakeExternals/Qwt.cmake @@ -1,43 +1,43 @@ #----------------------------------------------------------------------------- # Qwt #----------------------------------------------------------------------------- if(MITK_USE_Qwt) # Sanity checks if(DEFINED Qwt_DIR AND NOT EXISTS ${Qwt_DIR}) message(FATAL_ERROR "Qwt_DIR variable is defined but corresponds to non-existing directory") endif() set(proj Qwt) set(proj_DEPENDENCIES ) set(${proj}_DEPENDS ${proj}) if(NOT DEFINED ${proj}_DIR) set(patch_cmd ${CMAKE_COMMAND} -Dproj:STRING=${proj} -Dproj_target:STRING=qwt -P ${CMAKE_CURRENT_LIST_DIR}/GenerateDefaultCMakeBuildSystem.cmake) ExternalProject_Add(${proj} SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}-src BINARY_DIR ${proj}-build PREFIX ${proj}-cmake URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/qwt-6.1.0.tar.bz2 URL_MD5 aef0437b37f191067a6a9dc01c30ba64 PATCH_COMMAND ${patch_cmd} INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ${qt_project_args} DEPENDS ${proj_DEPENDENCIES} ) set(${proj}_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif() endif() diff --git a/CMakeExternals/QwtCMakeLists.txt b/CMakeExternals/QwtCMakeLists.txt index 550f435484..409d79c3e8 100644 --- a/CMakeExternals/QwtCMakeLists.txt +++ b/CMakeExternals/QwtCMakeLists.txt @@ -1,227 +1,255 @@ - -cmake_minimum_required(VERSION 2.8.4) +if(DESIRED_QT_VERSION MATCHES 5) + cmake_minimum_required(VERSION 2.8.9) +else() + cmake_minimum_required(VERSION 2.8.4) +endif() project(Qwt) set(${PROJECT_NAME}_MAJOR_VERSION 6) set(${PROJECT_NAME}_MINOR_VERSION 1) set(${PROJECT_NAME}_PATCH_VERSION 0) set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}) set(QWT_MOC_HEADERS # General qwt_dyngrid_layout.h qwt_magnifier.h qwt_panner.h qwt_picker.h qwt_text_label.h # QwtPlot qwt_abstract_legend.h qwt_legend.h qwt_legend_label.h qwt_plot.h qwt_plot_renderer.h qwt_plot_canvas.h qwt_plot_panner.h qwt_plot_picker.h qwt_plot_zoomer.h qwt_plot_magnifier.h qwt_sampling_thread.h qwt_scale_widget.h # QwtOpenGL qwt_plot_glcanvas.h # QwtWidgets qwt_abstract_slider.h qwt_abstract_scale.h qwt_analog_clock.h qwt_compass.h qwt_counter.h qwt_dial.h qwt_knob.h qwt_slider.h qwt_thermo.h qwt_wheel.h ) set(QWT_SOURCES # General qwt_abstract_scale_draw.cpp qwt_clipper.cpp qwt_color_map.cpp qwt_column_symbol.cpp qwt_date.cpp qwt_date_scale_draw.cpp qwt_date_scale_engine.cpp qwt_dyngrid_layout.cpp qwt_event_pattern.cpp qwt_graphic.cpp qwt_interval.cpp qwt_interval_symbol.cpp qwt_math.cpp qwt_magnifier.cpp qwt_null_paintdevice.cpp qwt_painter.cpp qwt_painter_command.cpp qwt_panner.cpp qwt_picker.cpp qwt_picker_machine.cpp qwt_pixel_matrix.cpp qwt_point_3d.cpp qwt_point_polar.cpp qwt_round_scale_draw.cpp qwt_scale_div.cpp qwt_scale_draw.cpp qwt_scale_map.cpp qwt_spline.cpp qwt_scale_engine.cpp qwt_symbol.cpp qwt_system_clock.cpp qwt_text_engine.cpp qwt_text_label.cpp qwt_text.cpp qwt_transform.cpp qwt_widget_overlay.cpp # QwtPlot qwt_curve_fitter.cpp qwt_abstract_legend.cpp qwt_legend.cpp qwt_legend_data.cpp qwt_legend_label.cpp qwt_plot.cpp qwt_plot_renderer.cpp qwt_plot_xml.cpp qwt_plot_axis.cpp qwt_plot_curve.cpp qwt_plot_dict.cpp qwt_plot_directpainter.cpp qwt_plot_grid.cpp qwt_plot_histogram.cpp qwt_plot_item.cpp qwt_plot_abstract_barchart.cpp qwt_plot_barchart.cpp qwt_plot_multi_barchart.cpp qwt_plot_intervalcurve.cpp qwt_plot_zoneitem.cpp qwt_plot_tradingcurve.cpp qwt_plot_spectrogram.cpp qwt_plot_spectrocurve.cpp qwt_plot_scaleitem.cpp qwt_plot_legenditem.cpp qwt_plot_seriesitem.cpp qwt_plot_shapeitem.cpp qwt_plot_marker.cpp qwt_plot_textlabel.cpp qwt_plot_layout.cpp qwt_plot_canvas.cpp qwt_plot_panner.cpp qwt_plot_rasteritem.cpp qwt_plot_picker.cpp qwt_plot_zoomer.cpp qwt_plot_magnifier.cpp qwt_plot_rescaler.cpp qwt_point_mapper.cpp qwt_raster_data.cpp qwt_matrix_raster_data.cpp qwt_sampling_thread.cpp qwt_series_data.cpp qwt_point_data.cpp qwt_scale_widget.cpp # QwtSvg qwt_plot_svgitem.cpp # QwtOpenGL qwt_plot_glcanvas.cpp # QwtWidgets qwt_abstract_slider.cpp qwt_abstract_scale.cpp qwt_arrow_button.cpp qwt_analog_clock.cpp qwt_compass.cpp qwt_compass_rose.cpp qwt_counter.cpp qwt_dial.cpp qwt_dial_needle.cpp qwt_knob.cpp qwt_slider.cpp qwt_thermo.cpp qwt_wheel.cpp ) set(_qwt_moc_headers ) foreach(_header ${QWT_MOC_HEADERS}) list(APPEND _qwt_moc_headers src/${_header}) endforeach() set(_qwt_sources ) foreach(_source ${QWT_SOURCES}) list(APPEND _qwt_sources src/${_source}) endforeach() -find_package(Qt4 REQUIRED) +if(DESIRED_QT_VERSION MATCHES 4) + find_package(Qt4 REQUIRED QtCore QtGui QtSvg QtOpenGL QtDesigner) + include(${QT_USE_FILE}) + qt4_wrap_cpp(_qwt_sources ${_qwt_moc_headers}) + + add_library(qwt SHARED ${_qwt_sources}) + target_link_libraries(qwt ${QT_LIBRARIES}) +elseif(DESIRED_QT_VERSION MATCHES 5) + + if (WIN32) + cmake_policy(SET CMP0020 NEW) # Automatically link Qt executables to qtmain target on Windows + endif() -set(QT_USE_QTSVG 1) -set(QT_USE_QTOPENGL 1) -set(QT_USE_QTDESIGNER 1) -include(${QT_USE_FILE}) -qt4_wrap_cpp(_qwt_sources ${_qwt_moc_headers}) + find_package(Qt5Svg REQUIRED) + find_package(Qt5OpenGL REQUIRED) + find_package(Qt5PrintSupport REQUIRED) + find_package(Qt5Concurrent REQUIRED) -add_library(qwt SHARED ${_qwt_sources}) -target_link_libraries(qwt ${QT_LIBRARIES}) + qt5_wrap_cpp(_qwt_sources ${_qwt_moc_headers}) + + add_library(qwt SHARED ${_qwt_sources}) + qt5_use_modules(qwt Svg OpenGL PrintSupport Concurrent) +endif() set_target_properties(qwt PROPERTIES SOVERSION ${${PROJECT_NAME}_VERSION} COMPILE_DEFINITIONS "QWT_DLL;QWT_MAKEDLL") - # Build the designer plug-in include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) set(_qwt_designer_sources designer/qwt_designer_plotdialog.cpp designer/qwt_designer_plugin.cpp ) -qt4_wrap_cpp(_qwt_designer_sources - designer/qwt_designer_plugin.h - designer/qwt_designer_plotdialog.h -) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/plugins/designer) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/plugins/designer) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/plugins/designer) -qt4_add_resources(_qwt_designer_sources designer/qwt_designer_plugin.qrc) -add_library(qwt_designer_plugin SHARED ${_qwt_designer_sources}) -target_link_libraries(qwt_designer_plugin qwt ${QT_LIBRARIES}) +if(DESIRED_QT_VERSION MATCHES 4) + qt4_wrap_cpp(_qwt_designer_sources + designer/qwt_designer_plugin.h + designer/qwt_designer_plotdialog.h + ) + qt4_add_resources(_qwt_designer_sources designer/qwt_designer_plugin.qrc) + add_library(qwt_designer_plugin SHARED ${_qwt_designer_sources}) + target_link_libraries(qwt_designer_plugin qwt ${QT_LIBRARIES}) +elseif(DESIRED_QT_VERSION MATCHES 5) + find_package(Qt5Designer REQUIRED) + include_directories(${Qt5Designer_INCLUDE_DIRS}) + qt5_wrap_cpp(_qwt_designer_sources + designer/qwt_designer_plugin.h + designer/qwt_designer_plotdialog.h + ) + qt5_add_resources(_qwt_designer_sources designer/qwt_designer_plugin.qrc) + + add_library(qwt_designer_plugin SHARED ${_qwt_designer_sources}) + target_link_libraries(qwt_designer_plugin qwt) + qt5_use_modules(qwt_designer_plugin Designer) +endif() set_target_properties(qwt_designer_plugin PROPERTIES SOVERSION ${${PROJECT_NAME}_VERSION} COMPILE_DEFINITIONS QWT_DLL) # Config files set(${PROJECT_NAME}_LIBRARIES qwt) set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src) configure_file(${PROJECT_NAME}Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake @ONLY) export(TARGETS ${${PROJECT_NAME}_LIBRARIES} FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Exports.cmake) # Version information configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}ConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake @ONLY ) diff --git a/CMakeExternals/Qxt.cmake b/CMakeExternals/Qxt.cmake index 4b31a6c901..9a48121003 100644 --- a/CMakeExternals/Qxt.cmake +++ b/CMakeExternals/Qxt.cmake @@ -1,43 +1,43 @@ #----------------------------------------------------------------------------- # Qxt #----------------------------------------------------------------------------- if(MITK_USE_Qxt) # Sanity checks if(DEFINED Qxt_DIR AND NOT EXISTS ${Qxt_DIR}) message(FATAL_ERROR "Qxt_DIR variable is defined but corresponds to non-existing directory") endif() set(proj Qxt) set(proj_DEPENDENCIES ) set(${proj}_DEPENDS ${proj}) if(NOT DEFINED ${proj}_DIR) set(patch_cmd ${CMAKE_COMMAND} -Dproj:STRING=${proj} -Dproj_target:STRING=QxtCore -P ${CMAKE_CURRENT_LIST_DIR}/GenerateDefaultCMakeBuildSystem.cmake) ExternalProject_Add(${proj} SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}-src BINARY_DIR ${proj}-build PREFIX ${proj}-cmake URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/libqxt-0.6.2-dadc327c2a6a-patched.tar.gz URL_MD5 b0438b4c76793c35b606c8aba02748b8 PATCH_COMMAND ${patch_cmd} INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ${qt_project_args} DEPENDS ${proj_DEPENDENCIES} ) set(${proj}_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif() endif() diff --git a/CMakeExternals/VTK.cmake b/CMakeExternals/VTK.cmake index 4b893bc6e4..2d64430a86 100644 --- a/CMakeExternals/VTK.cmake +++ b/CMakeExternals/VTK.cmake @@ -1,98 +1,100 @@ #----------------------------------------------------------------------------- # VTK #----------------------------------------------------------------------------- if(WIN32) option(VTK_USE_SYSTEM_FREETYPE OFF) else(WIN32) option(VTK_USE_SYSTEM_FREETYPE ON) endif(WIN32) # Sanity checks if(DEFINED VTK_DIR AND NOT EXISTS ${VTK_DIR}) message(FATAL_ERROR "VTK_DIR variable is defined but corresponds to non-existing directory") endif() set(proj VTK) set(proj_DEPENDENCIES ) set(VTK_DEPENDS ${proj}) if(NOT DEFINED VTK_DIR) set(additional_cmake_args ) if(MINGW) set(additional_cmake_args -DCMAKE_USE_WIN32_THREADS:BOOL=ON -DCMAKE_USE_PTHREADS:BOOL=OFF -DVTK_USE_VIDEO4WINDOWS:BOOL=OFF # no header files provided by MinGW ) endif() if(MITK_USE_Python) list(APPEND additional_cmake_args -DVTK_WRAP_PYTHON:BOOL=ON -DVTK_USE_TK:BOOL=OFF -DVTK_WINDOWS_PYTHON_DEBUGGABLE:BOOL=OFF -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} -DPYTHON_INCLUDE_DIR2:PATH=${PYTHON_INCLUDE_DIR2} -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} #-DPYTHON_LIBRARIES=${PYTHON_LIBRARY} #-DPYTHON_DEBUG_LIBRARIES=${PYTHON_DEBUG_LIBRARIES} ) else() list(APPEND additional_cmake_args -DVTK_WRAP_PYTHON:BOOL=OFF -DVTK_WINDOWS_PYTHON_DEBUGGABLE:BOOL=OFF ) endif() if(MITK_USE_QT) - list(APPEND additional_cmake_args - -DDESIRED_QT_VERSION:STRING=4 - -DVTK_USE_GUISUPPORT:BOOL=ON - -DVTK_USE_QVTK_QTOPENGL:BOOL=OFF - -DVTK_USE_QT:BOOL=ON - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} - ) + if(DESIRED_QT_VERSION MATCHES 4) # current VTK package has a HARD Qt 4 dependency + list(APPEND additional_cmake_args + -DDESIRED_QT_VERSION:STRING=${DESIRED_QT_VERSION} + -DVTK_USE_GUISUPPORT:BOOL=ON + -DVTK_USE_QVTK_QTOPENGL:BOOL=OFF + -DVTK_USE_QT:BOOL=ON + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ) + endif() endif() set(VTK_URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/vtk-6.0.0.tar.gz) set(VTK_URL_MD5 fa07fb55a905186f7d98807585efb20e) ExternalProject_Add(${proj} SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}-src BINARY_DIR ${proj}-build PREFIX ${proj}-cmake URL ${VTK_URL} URL_MD5 ${VTK_URL_MD5} INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} -DVTK_GROUP_QT:BOOL=ON -DVTK_Group_Qt:BOOL=ON -DVTK_WRAP_TCL:BOOL=OFF -DVTK_WRAP_PYTHON:BOOL=OFF -DVTK_WRAP_JAVA:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON -DVTK_USE_SYSTEM_FREETYPE:BOOL=${VTK_USE_SYSTEM_FREETYPE} -DVTK_LEGACY_REMOVE:BOOL=ON -DModule_vtkTestingRendering:BOOL=ON -DModule_vtkGUISupportQt:BOOL=ON -DModule_vtkGUISupportQtWebkit:BOOL=ON -DModule_vtkGUISupportQtSQL:BOOL=ON -DModule_vtkRenderingQt:BOOL=ON -DVTK_MAKE_INSTANTIATORS:BOOL=ON ${additional_cmake_args} DEPENDS ${proj_DEPENDENCIES} ) set(VTK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index b63c90d39a..215e93de11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,996 +1,1020 @@ -if(APPLE) +if(MITK_USE_QT AND DESIRED_QT_VERSION MATCHES 5) + cmake_minimum_required(VERSION 2.8.9) +elseif(APPLE) # With XCode 4.3, the SDK location changed. Older CMake # versions are not able to find it. cmake_minimum_required(VERSION 2.8.8) else() cmake_minimum_required(VERSION 2.8.5) endif() #----------------------------------------------------------------------------- # Include ctest launchers for dashboard in case of makefile generator #----------------------------------------------------------------------------- if(${CMAKE_VERSION} VERSION_GREATER "2.8.9") include(CTestUseLaunchers) endif() #----------------------------------------------------------------------------- # 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() #----------------------------------------------------------------------------- # 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) endif() #----------------------------------------------------------------------------- # 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 43) # _src_dir_length_max - strlen(ITK-src) 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() #----------------------------------------------------------------------------- # See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details #----------------------------------------------------------------------------- set(project_policies CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used. CMP0002 # NEW: Logical target names must be globally unique. CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths. CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace. CMP0005 # NEW: Preprocessor definition values are now escaped automatically. CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION. CMP0007 # NEW: List command no longer ignores empty elements. CMP0008 # NEW: Libraries linked by full-path must have a valid library file name. CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default. CMP0010 # NEW: Bad variable reference syntax is an error. CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP. CMP0012 # NEW: if() recognizes numbers and boolean constants. CMP0013 # NEW: Duplicate binary directories are not allowed. CMP0014 # NEW: Input directories must have CMakeLists.txt + CMP0020 # NEW: Automatically link Qt executables to qtmain target on Windows ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ +set(MITK_CMAKE_DIR ${MITK_SOURCE_DIR}/CMake) + set(CMAKE_MODULE_PATH - ${MITK_SOURCE_DIR}/CMake + ${MITK_CMAKE_DIR} ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) include(mitkFunctionSuppressWarnings) SUPPRESS_VC_DEPRECATED_WARNINGS() #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- foreach(type LIBRARY RUNTIME ARCHIVE) # Make sure the directory exists if(DEFINED 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_USE_SUPERBUILD) set(output_dir ${MITK_BINARY_DIR}/bin) if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_BINARY_DIR}/MITK-build/bin) endif() else() if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(output_dir ${MITK_BINARY_DIR}/bin) else() set(output_dir ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) endif() endif() set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.") mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) endforeach() #----------------------------------------------------------------------------- # Additional MITK Options (also shown during superbuild) #----------------------------------------------------------------------------- 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_BUILD_ALL_APPS "Build all MITK applications" OFF) set(MITK_BUILD_TUTORIAL OFF CACHE INTERNAL "Deprecated! Use MITK_BUILD_EXAMPLES instead!") option(MITK_BUILD_EXAMPLES "Build the MITK Examples" ${MITK_BUILD_TUTORIAL}) option(MITK_USE_ACVD "Use Approximated Centroidal Voronoi Diagrams" OFF) option(MITK_USE_GLEW "Use the GLEW library" ON) option(MITK_USE_Boost "Use the Boost C++ library" OFF) option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) option(MITK_USE_CTK "Use CTK in MITK" ${MITK_USE_BLUEBERRY}) option(MITK_USE_QT "Use Nokia's Qt library" ${MITK_USE_CTK}) +set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 4 or 5") +set(MITK_DESIRED_QT_VERSION ${DESIRED_QT_VERSION}) option(MITK_USE_DCMTK "EXPERIMENTAL, superbuild only: Use DCMTK in MITK" ${MITK_USE_CTK}) option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) option(MITK_USE_OpenCL "Use OpenCL GPU-Computing library" OFF) option(MITK_USE_Poco "Use the Poco library" ON) option(MITK_USE_SOFA "Use Simulation Open Framework Architecture" OFF) option(MITK_USE_Python "Use Python wrapping in MITK" OFF) set(MITK_USE_CableSwig ${MITK_USE_Python}) option(MITK_ENABLE_PIC_READER "Enable support for reading the DKFZ pic file format." ON) mark_as_advanced(MITK_BUILD_ALL_APPS MITK_USE_GLEW MITK_USE_CTK MITK_USE_DCMTK MITK_ENABLE_PIC_READER ) if(MITK_USE_Python) FIND_PACKAGE(PythonLibs REQUIRED) FIND_PACKAGE(PythonInterp REQUIRED) endif() if(MITK_USE_Boost) 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") endif() +if(MITK_USE_BLUEBERRY) + if(NOT DESIRED_QT_VERSION MATCHES 4) + message("Forcing MITK_USE_BLUEBERRY to OFF because of DESIRED_QT_VERSION ${DESIRED_QT_VERSION}") + set(MITK_USE_BLUEBERRY OFF CACHE BOOL "Build the BlueBerry application platform" FORCE) + endif() +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() if(MITK_USE_CTK) if(NOT MITK_USE_QT) message("Forcing MITK_USE_QT to ON because of MITK_USE_CTK") set(MITK_USE_QT ON CACHE BOOL "Use Nokia's Qt library in MITK" FORCE) + else() + if(NOT DESIRED_QT_VERSION MATCHES 4) + message("Forcing MITK_USE_CTK to OFF because of DESIRED_QT_VERSION ${DESIRED_QT_VERSION}") + set(MITK_USE_CTK OFF CACHE BOOL "Use CTK in MITK" FORCE) + endif() endif() if(NOT MITK_USE_DCMTK) message("Setting MITK_USE_DCMTK to ON because DCMTK needs to be build for CTK") set(MITK_USE_DCMTK ON CACHE BOOL "Use DCMTK in MITK" FORCE) endif() endif() if(MITK_USE_QT) # find the package at the very beginning, so that QT4_FOUND is available - find_package(Qt4 4.6.2 REQUIRED) + if(DESIRED_QT_VERSION MATCHES 4) + find_package(Qt4 4.6.2 REQUIRED) + set(MITK_USE_Qt4 TRUE) + set(MITK_USE_Qt5 FALSE) + endif(DESIRED_QT_VERSION MATCHES 4) + if(DESIRED_QT_VERSION MATCHES 5) + set(MITK_USE_Qt4 FALSE) + set(MITK_USE_Qt5 TRUE) + endif(DESIRED_QT_VERSION MATCHES 5) endif() if(MITK_USE_SOFA) # SOFA requires at least CMake 2.8.8 set(SOFA_CMAKE_VERSION 2.8.8) if(${CMAKE_VERSION} VERSION_LESS ${SOFA_CMAKE_VERSION}) set(MITK_USE_SOFA OFF CACHE BOOL "" FORCE) message(WARNING "Switched off MITK_USE_SOFA\n Minimum required CMake version: ${SOFA_CMAKE_VERSION}\n Installed CMake version: ${CMAKE_VERSION}") endif() # SOFA doesn't support Clang if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(MITK_USE_SOFA OFF CACHE BOOL "" FORCE) message(WARNING "Switched off MITK_USE_SOFA\n Clang is not supported, use GCC instead.") endif() # SOFA/ITK combination requires at least MSVC 2010 if(MSVC_VERSION AND MSVC_VERSION LESS 1600) set(MITK_USE_SOFA OFF CACHE BOOL "" FORCE) message(WARNING "Switched off MITK_USE_SOFA\n MSVC versions less than 2010 are not supported.") endif() # SOFA requires boost library if(MITK_USE_SOFA AND NOT MITK_USE_Boost) message("Forcing MITK_USE_Boost to ON because of MITK_USE_SOFA") set(MITK_USE_Boost ON CACHE BOOL "" FORCE) endif() # SOFA requires boost system library list(FIND MITK_USE_Boost_LIBRARIES system _result) if(_result LESS 0) message("Adding 'system' to MITK_USE_Boost_LIBRARIES.") list(APPEND MITK_USE_Boost_LIBRARIES system) endif() # SOFA requires boost thread library list(FIND MITK_USE_Boost_LIBRARIES thread _result) if(_result LESS 0) message("Adding 'thread' to MITK_USE_Boost_LIBRARIES.") list(APPEND MITK_USE_Boost_LIBRARIES thread) endif() set(MITK_USE_Boost_LIBRARIES ${MITK_USE_Boost_LIBRARIES} CACHE STRING "" FORCE) endif() # 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_DIMENSIONS) set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") endif() #----------------------------------------------------------------------------- # Project.xml #----------------------------------------------------------------------------- # A list of topologically ordered targets set(CTEST_PROJECT_SUBPROJECTS) if(MITK_USE_BLUEBERRY) list(APPEND CTEST_PROJECT_SUBPROJECTS BlueBerry) endif() list(APPEND CTEST_PROJECT_SUBPROJECTS MITK-Core MITK-CoreUI MITK-IGT MITK-ToF MITK-DTI MITK-Registration MITK-Modules # all modules not contained in a specific subproject MITK-Plugins # all plugins not contained in a specific subproject MITK-Examples Unlabeled # special "subproject" catching all unlabeled targets and tests ) # Configure CTestConfigSubProject.cmake that could be used by CTest scripts configure_file(${MITK_SOURCE_DIR}/CTestConfigSubProject.cmake.in ${MITK_BINARY_DIR}/CTestConfigSubProject.cmake) if(CTEST_PROJECT_ADDITIONAL_TARGETS) # those targets will be executed at the end of the ctest driver script # and they also get their own subproject label set(subproject_list "${CTEST_PROJECT_SUBPROJECTS};${CTEST_PROJECT_ADDITIONAL_TARGETS}") else() set(subproject_list "${CTEST_PROJECT_SUBPROJECTS}") endif() # Generate Project.xml file expected by the CTest driver script mitkFunctionGenerateProjectXml(${MITK_BINARY_DIR} MITK "${subproject_list}" ${MITK_USE_SUPERBUILD}) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(CheckCXXSourceCompiles) include(mitkFunctionCheckCompilerFlags) include(mitkFunctionGetGccVersion) include(MacroParseArguments) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkFunctionOrganizeSources) include(mitkFunctionGetVersion) include(mitkFunctionGetVersionDescription) include(mitkFunctionCreateWindowsBatchScript) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionInstallAutoLoadModules) include(mitkFunctionGetLibrarySearchPaths) include(mitkFunctionCompileSnippets) +include(mitkFunctionUseModules) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) +include(mitkMacroCreateExecutable) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) include(mitkMacroGetPMDPlatformString) #----------------------------------------------------------------------------- # Prerequesites #----------------------------------------------------------------------------- find_package(ITK REQUIRED) find_package(VTK REQUIRED) find_package(GDCM PATHS ${ITK_GDCM_DIR} REQUIRED) #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- # ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and mitkWorkbench 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) # TODO: check if necessary option(USE_ITKZLIB "Use the ITK zlib for pic compression." ON) mark_as_advanced(USE_ITKZLIB) if(NOT MITK_FAST_TESTING) if(DEFINED MITK_CTEST_SCRIPT_MODE AND (MITK_CTEST_SCRIPT_MODE STREQUAL "continuous" OR MITK_CTEST_SCRIPT_MODE STREQUAL "experimental") ) set(MITK_FAST_TESTING 1) endif() endif() #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) mitkFunctionGetVersionDescription(${MITK_SOURCE_DIR} MITK) #----------------------------------------------------------------------------- # Installation preparation # # These should be set before any MITK install macros are used #----------------------------------------------------------------------------- # on Mac OSX all BlueBerry plugins get copied into every # application bundle (.app directory) specified here if(MITK_USE_BLUEBERRY AND APPLE) include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/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} ${app_name}) endif() endforeach() endif() #----------------------------------------------------------------------------- # Set symbol visibility Flags #----------------------------------------------------------------------------- # MinGW does not export all symbols automatically, so no need to set flags if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW) set(VISIBILITY_CXX_FLAGS ) #"-fvisibility=hidden -fvisibility-inlines-hidden") 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 "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS}") set(MITK_CXX_FLAGS_DEBUG ) set(MITK_CXX_FLAGS_RELEASE ) set(MITK_EXE_LINKER_FLAGS ) set(MITK_SHARED_LINKER_FLAGS ) include(mitkSetupC++0xVariables) if(WIN32) set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -D_WIN32_WINNT=0x0501 -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN") set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} /wd4231") # warning C4231: nonstandard extension used : 'extern' before template explicit instantiation 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 # the following two lines should be removed after ITK-3097 has # been resolved, see also MITK bug 15279 -Wno-unused-local-typedefs -Wno-array-bounds -fdiagnostics-show-option ) mitkFunctionCheckCAndCXXCompilerFlags(${_flag} MITK_C_FLAGS MITK_CXX_FLAGS) endforeach() endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS) mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS) if(MITK_USE_C++0x) mitkFunctionCheckCompilerFlags("-std=c++0x" MITK_CXX_FLAGS) endif() mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag. # Doing so should allow to build package made for distribution using older linux distro. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0")) mitkFunctionCheckCAndCXXCompilerFlags("-fstack-protector-all" MITK_C_FLAGS MITK_CXX_FLAGS) endif() if(MINGW) # suppress warnings about auto imported symbols set(MITK_SHARED_LINKER_FLAGS "-Wl,--enable-auto-import ${MITK_SHARED_LINKER_FLAGS}") endif() set(MITK_CXX_FLAGS_RELEASE "-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}) +set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR} ${MITK_MODULES_PACKAGE_DEPENDS_DIR}/Qt) #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) option(MITK_ENABLE_RENDERING_TESTING OFF "Enable the MITK rendering tests. Requires x-server in Linux.") #Rendering testing does not work for Linux nightlies, thus it is disabled per default #and activated for Mac and Windows. if(WIN32 OR APPLE) set(MITK_ENABLE_RENDERING_TESTING ON) endif() mark_as_advanced( MITK_ENABLE_RENDERING_TESTING ) # Setup file for setting custom ctest vars configure_file( CMake/CTestCustom.cmake.in ${MITK_BINARY_DIR}/CTestCustom.cmake @ONLY ) # 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( std::exception & excp ) { fprintf(stderr,\"%s\\n\",excp.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 external project template if(MITK_USE_BLUEBERRY) include(mitkTestProjectTemplate) 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() #----------------------------------------------------------------------------- # Compile Utilities and set-up MITK variables #----------------------------------------------------------------------------- include(mitkSetupVariables) #----------------------------------------------------------------------------- # Cleanup #----------------------------------------------------------------------------- file(GLOB _MODULES_CONF_FILES ${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME}/*.cmake) if(_MODULES_CONF_FILES) file(REMOVE ${_MODULES_CONF_FILES}) endif() add_subdirectory(Utilities) if(MITK_USE_BLUEBERRY) # We need to hack a little bit because MITK applications may need # to enable certain BlueBerry plug-ins. However, these plug-ins # are validated separately from the MITK plug-ins and know nothing # about potential MITK plug-in dependencies of the applications. Hence # we cannot pass the MITK application list to the BlueBerry # ctkMacroSetupPlugins call but need to extract the BlueBerry dependencies # from the applications and set them explicitly. include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") foreach(mitk_app ${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) # check if the application is enabled and if target_libraries.cmake exists if((${option_name} OR MITK_BUILD_ALL_APPS) AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/target_libraries.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/target_libraries.cmake") foreach(_target_dep ${target_libraries}) if(_target_dep MATCHES org_blueberry_) string(REPLACE _ . _app_bb_dep ${_target_dep}) # explicitly set the build option for the BlueBerry plug-in set(BLUEBERRY_BUILD_${_app_bb_dep} ON CACHE BOOL "Build the ${_app_bb_dep} plug-in") endif() endforeach() endif() endforeach() set(mbilog_DIR "${mbilog_BINARY_DIR}") if(MITK_BUILD_ALL_PLUGINS) set(BLUEBERRY_BUILD_ALL_PLUGINS ON) endif() set(BLUEBERRY_XPDOC_OUTPUT_DIR ${MITK_DOXYGEN_OUTPUT_DIR}/html/extension-points/html/) add_subdirectory(BlueBerry) set(BlueBerry_DIR ${CMAKE_CURRENT_BINARY_DIR}/BlueBerry CACHE PATH "The directory containing a CMake configuration file for BlueBerry" FORCE) include(mitkMacroCreateCTKPlugin) 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 custom targets representing CDash subprojects #----------------------------------------------------------------------------- foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) if(NOT TARGET ${subproject} AND NOT subproject MATCHES "Unlabeled") add_custom_target(${subproject}) endif() endforeach() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- -link_directories(${MITK_LINK_DIRECTORIES}) - add_subdirectory(Core) add_subdirectory(Modules) if(MITK_USE_BLUEBERRY) find_package(BlueBerry REQUIRED) set(MITK_DEFAULT_SUBPROJECTS MITK-Plugins) # Plug-in testing (needs some work to be enabled again) if(BUILD_TESTING) include(berryTestingHelpers) set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp") get_target_property(_is_macosx_bundle CoreApp MACOSX_BUNDLE) if(APPLE AND _is_macosx_bundle) set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.app/Contents/MacOS/CoreApp") endif() set(BLUEBERRY_TEST_APP_ID "org.mitk.qt.coreapplication") endif() include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake") set(mitk_plugins_fullpath ) foreach(mitk_plugin ${MITK_EXT_PLUGINS}) list(APPEND mitk_plugins_fullpath Plugins/${mitk_plugin}) 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 OUTPUT_VARIABLE ${varname}) endmacro() # Get infos about application directories and build options include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") set(mitk_apps_fullpath ) foreach(mitk_app ${MITK_APPS}) list(APPEND mitk_apps_fullpath "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${mitk_app}") endforeach() - ctkMacroSetupPlugins(${mitk_plugins_fullpath} - BUILD_OPTION_PREFIX MITK_BUILD_ - APPS ${mitk_apps_fullpath} - BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} - COMPACT_OPTIONS) + 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() # 11.3.13, change, muellerm: activate python bundle if python and blueberry is active if( MITK_USE_Python ) set(MITK_BUILD_org.mitk.gui.qt.python ON) endif() endif() #----------------------------------------------------------------------------- # Python Wrapping #----------------------------------------------------------------------------- option(MITK_USE_Python "Build Python integration for MITK (requires CableSwig)." OFF) #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- add_subdirectory(Documentation) #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables # These are the default variables, which can be overwritten ( see below ) include(mitkSetupCPack) set(use_default_config ON) # MITK_APPS is set in Applications/AppList.cmake (included somewhere above # if MITK_USE_BLUEBERRY is set to ON). if(MITK_APPS) set(activated_apps_no 0) list(LENGTH MITK_APPS app_count) # Check how many apps have been enabled # If more than one app has been activated, the we use the # default CPack configuration. Otherwise that apps configuration # will be used, if present. 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) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) MATH(EXPR activated_apps_no "${activated_apps_no} + 1") endif() endforeach() 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 ${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) # 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 "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake") endif() if(EXISTS "${PROJECT_SOURCE_DIR}/Applications/${target_dir}/CPackConfig.cmake.in") set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/Applications/${target_dir}/CPackConfig.cmake") configure_file(${PROJECT_SOURCE_DIR}/Applications/${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 "${target_dir}") endif() endforeach() endif() # 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 #----------------------------------------------------------------------------- -# This is for installation support of external projects depending on -# MITK plugins and modules. The export file should not be used for linking to MITK -# libraries without using LINK_DIRECTORIES, since the exports are incomplete -# yet (depending libraries are not exported). - 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() endforeach() get_property(MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) 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) set(VISIBILITY_AVAILABLE 0) set(visibility_test_flag "") mitkFunctionCheckCompilerFlags("-fvisibility=hidden" visibility_test_flag) if(visibility_test_flag) # The compiler understands -fvisiblity=hidden (probably gcc >= 4 or Clang) set(VISIBILITY_AVAILABLE 1) endif() configure_file(mitkExportMacros.h.in ${MITK_BINARY_DIR}/mitkExportMacros.h) 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) file(GLOB _MODULES_CONF_FILES RELATIVE ${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME} ${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME}/*.cmake) set(MITK_MODULE_NAMES) foreach(_module ${_MODULES_CONF_FILES}) string(REPLACE Config.cmake "" _module_name ${_module}) list(APPEND MITK_MODULE_NAMES ${_module_name}) endforeach() configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY) # If we are under Windows, create two batch files which correctly # set up the environment for the application and for Visual Studio if(WIN32) include(mitkFunctionCreateWindowsBatchScript) set(VS_SOLUTION_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.sln") foreach(VS_BUILD_TYPE debug release) mitkFunctionCreateWindowsBatchScript("${MITK_SOURCE_DIR}/CMake/StartVS.bat.in" ${PROJECT_BINARY_DIR}/StartVS_${VS_BUILD_TYPE}.bat ${VS_BUILD_TYPE}) endforeach() endif(WIN32) #----------------------------------------------------------------------------- # MITK Applications #----------------------------------------------------------------------------- # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Applications) #----------------------------------------------------------------------------- # 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() diff --git a/Core/Code/CMakeLists.txt b/Core/Code/CMakeLists.txt index c62f0d8cdf..3a787ab342 100644 --- a/Core/Code/CMakeLists.txt +++ b/Core/Code/CMakeLists.txt @@ -1,56 +1,56 @@ set(TOOL_CPPS "") # temporary suppress warnings in the following files until image accessors are fully integrated. set_source_files_properties( DataManagement/mitkImage.cpp COMPILE_FLAGS -DMITK_NO_DEPRECATED_WARNINGS ) set_source_files_properties( Controllers/mitkSliceNavigationController.cpp COMPILE_FLAGS -DMITK_NO_DEPRECATED_WARNINGS ) # In MITK_ITK_Config.cmake, we set ITK_NO_IO_FACTORY_REGISTER_MANAGER to 1 unless # the variable is already defined. Setting it to 1 prevents multiple registrations/ # unregistrations of ITK IO factories during library loading/unloading (of MITK # libraries). However, we need "one" place where the IO factories are registered at # least once. This could be the application executable, but every executable would # need to take care of that itself. Instead, we allow the auto registration in the # Mitk Core library. set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 0) MITK_CREATE_MODULE( Mitk INCLUDE_DIRS Algorithms Common DataManagement Controllers Interactions Interfaces IO Rendering ${MITK_BINARY_DIR} INTERNAL_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR} DEPENDS mbilog CppMicroServices - PACKAGE_DEPENDS tinyxml ITK GDCM VTK OpenGL + PACKAGE_DEPENDS tinyxml ITK VTK OpenGL EXPORT_DEFINE MITK_CORE_EXPORT WARNINGS_AS_ERRORS # Do not automatically create CppMicroServices initialization code. # Because the VTK 6 "auto-init" functionality injects file-local static # initialization code in every cpp file which includes a VTK header, # static initialization order becomes an issue again. For the Mitk # core library, we need to ensure that the VTK static initialization stuff # happens before the CppMicroServices initialization, since the latter # might already use VTK code which needs to access VTK object factories. # Hence, CppMicroServices initialization code is placed manually within # the mitkCoreActivator.cpp file. NO_INIT ) # this is needed for libraries which link to Mitk and need # symbols from explicitly instantiated templates if(MINGW) get_target_property(_mitkCore_MINGW_linkflags Mitk LINK_FLAGS) if(NOT _mitkCore_MINGW_linkflags) set(_mitkCore_MINGW_linkflags "") endif(NOT _mitkCore_MINGW_linkflags) set_target_properties(Mitk PROPERTIES LINK_FLAGS "${_mitkCore_MINGW_linkflags} -Wl,--export-all-symbols") endif(MINGW) if(MSVC_IDE OR MSVC_VERSION OR MINGW) target_link_libraries(Mitk psapi.lib) endif(MSVC_IDE OR MSVC_VERSION OR MINGW) # build tests? if(BUILD_TESTING) add_subdirectory(Testing) ENDIF() diff --git a/Core/Code/Interactions/mitkDispatcher.cpp b/Core/Code/Interactions/mitkDispatcher.cpp index 333667723c..ccc3bf06a6 100644 --- a/Core/Code/Interactions/mitkDispatcher.cpp +++ b/Core/Code/Interactions/mitkDispatcher.cpp @@ -1,250 +1,250 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDispatcher.h" #include "mitkInteractionEvent.h" #include "mitkInternalEvent.h" // MicroServices #include "usGetModuleContext.h" #include "mitkInteractionEventObserver.h" mitk::Dispatcher::Dispatcher( const std::string& rendererName ) : m_ProcessingMode(REGULAR) { // LDAP filter string to find all listeners specific for the renderer // corresponding to this dispatcher std::string specificRenderer = "(rendererName=" + rendererName +")"; // LDAP filter string to find all listeners that are not specific // to any renderer std::string anyRenderer = "(!(rendererName=*))"; // LDAP filter string to find only instances of InteractionEventObserver std::string classInteractionEventObserver = "(" + us::ServiceConstants::OBJECTCLASS() + "=" + us_service_interface_iid() + ")"; // Configure the LDAP filter to find all instances of InteractionEventObserver // that are specific to this dispatcher or unspecific to any dispatchers (real global listener) us::LDAPFilter filter( "(&(|"+ specificRenderer + anyRenderer + ")"+classInteractionEventObserver+")" ); // Give the filter to the ObserverTracker m_EventObserverTracker = new us::ServiceTracker(us::GetModuleContext(), filter); m_EventObserverTracker->Open(); } void mitk::Dispatcher::AddDataInteractor(const DataNode* dataNode) { RemoveDataInteractor(dataNode); RemoveOrphanedInteractors(); DataInteractor::Pointer dataInteractor = dataNode->GetDataInteractor(); if (dataInteractor.IsNotNull()) { m_Interactors.push_back(dataInteractor); } } /* * Note: One DataInteractor can only have one DataNode and vice versa, * BUT the m_Interactors list may contain another DataInteractor that is still connected to this DataNode, * in this case we have to remove >1 DataInteractor. (Some special case of switching DataNodes between DataInteractors and registering a * DataNode to a DataStorage after assigning it to an DataInteractor) */ void mitk::Dispatcher::RemoveDataInteractor(const DataNode* dataNode) { for (ListInteractorType::iterator it = m_Interactors.begin(); it != m_Interactors.end();) { if ((*it)->GetDataNode() == dataNode) { it = m_Interactors.erase(it); } else { ++it; } } } size_t mitk::Dispatcher::GetNumberOfInteractors() { return m_Interactors.size(); } mitk::Dispatcher::~Dispatcher() { m_EventObserverTracker->Close(); delete m_EventObserverTracker; m_Interactors.clear(); } bool mitk::Dispatcher::ProcessEvent(InteractionEvent* event) { InteractionEvent::Pointer p = event; - //MITK_INFO << event->GetEventClass(); + bool eventIsHandled = false; /* Filter out and handle Internal Events separately */ InternalEvent* internalEvent = dynamic_cast(event); if (internalEvent != NULL) { eventIsHandled = HandleInternalEvent(internalEvent); // InternalEvents that are handled are not sent to the listeners if (eventIsHandled) { return true; } } switch (m_ProcessingMode) { case CONNECTEDMOUSEACTION: // finished connected mouse action if (std::strcmp(p->GetNameOfClass(), "MouseReleaseEvent") == 0) { m_ProcessingMode = REGULAR; eventIsHandled = m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode()); } // give event to selected interactor if (eventIsHandled == false) { eventIsHandled = m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode()); } break; case GRABINPUT: eventIsHandled = m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode()); SetEventProcessingMode(m_SelectedInteractor); break; case PREFERINPUT: if (m_SelectedInteractor->HandleEvent(event, m_SelectedInteractor->GetDataNode()) == true) { SetEventProcessingMode(m_SelectedInteractor); eventIsHandled = true; } break; case REGULAR: break; } // Standard behavior. Is executed in STANDARD mode and PREFERINPUT mode, if preferred interactor rejects event. if (m_ProcessingMode == REGULAR || (m_ProcessingMode == PREFERINPUT && eventIsHandled == false)) { m_Interactors.sort(cmp()); // sorts interactors by layer (descending); // copy the list to prevent iterator invalidation as executing actions // in HandleEvent() can cause the m_Interactors list to be updated std::list tmpInteractorList( m_Interactors ); std::list::iterator it; for ( it=tmpInteractorList.begin(); it!=tmpInteractorList.end(); it++ ) { DataInteractor::Pointer dataInteractor = *it; if ( (*it)->HandleEvent(event, dataInteractor->GetDataNode()) ) { // if an event is handled several properties are checked, in order to determine the processing mode of the dispatcher SetEventProcessingMode(dataInteractor); if (std::strcmp(p->GetNameOfClass(), "MousePressEvent") == 0 && m_ProcessingMode == REGULAR) { m_SelectedInteractor = dataInteractor; m_ProcessingMode = CONNECTEDMOUSEACTION; } eventIsHandled = true; break; } } } /* Notify InteractionEventObserver */ std::vector > listEventObserver = m_EventObserverTracker->GetServiceReferences(); for (std::vector >::iterator it = listEventObserver.begin(); it != listEventObserver.end(); ++it) { InteractionEventObserver* interactionEventObserver = m_EventObserverTracker->GetService(*it); if (interactionEventObserver != NULL) { if (interactionEventObserver->IsEnabled()) { interactionEventObserver->Notify(event, eventIsHandled); } } } // Process event queue if (!m_QueuedEvents.empty()) { InteractionEvent::Pointer e = m_QueuedEvents.front(); m_QueuedEvents.pop_front(); ProcessEvent(e); } return eventIsHandled; } /* * Checks if DataNodes associated with DataInteractors point back to them. * If not remove the DataInteractors. (This can happen when s.o. tries to set DataNodes to multiple DataInteractors) */ void mitk::Dispatcher::RemoveOrphanedInteractors() { for (ListInteractorType::iterator it = m_Interactors.begin(); it != m_Interactors.end();) { DataNode::Pointer dn = (*it)->GetDataNode(); if (dn.IsNull()) { it = m_Interactors.erase(it); } else { DataInteractor::Pointer interactor = dn->GetDataInteractor(); if (interactor != it->GetPointer()) { it = m_Interactors.erase(it); } else { ++it; } } } } void mitk::Dispatcher::QueueEvent(InteractionEvent* event) { m_QueuedEvents.push_back(event); } void mitk::Dispatcher::SetEventProcessingMode(DataInteractor::Pointer dataInteractor) { m_ProcessingMode = dataInteractor->GetMode(); if (dataInteractor->GetMode() != REGULAR) { m_SelectedInteractor = dataInteractor; } } bool mitk::Dispatcher::HandleInternalEvent(InternalEvent* internalEvent) { if (internalEvent->GetSignalName() == DataInteractor::IntDeactivateMe && internalEvent->GetTargetInteractor() != NULL) { internalEvent->GetTargetInteractor()->GetDataNode()->SetDataInteractor(NULL); internalEvent->GetTargetInteractor()->SetDataNode(NULL); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); return true; } return false; } diff --git a/Core/Code/Rendering/mitkRenderWindow.cpp b/Core/Code/Rendering/mitkRenderWindow.cpp index 0ad11c5af8..c7c8825add 100644 --- a/Core/Code/Rendering/mitkRenderWindow.cpp +++ b/Core/Code/Rendering/mitkRenderWindow.cpp @@ -1,86 +1,88 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkRenderWindow.h" #include "mitkDisplayPositionEvent.h" #include "mitkVtkLayerController.h" #include "mitkRenderingManager.h" #include "vtkRenderer.h" #include "vtkRenderWindowInteractor.h" #include "mitkVtkEventProvider.h" mitk::RenderWindow::RenderWindow(vtkRenderWindow* renWin, const char* name, mitk::RenderingManager* rm ) : m_vtkRenderWindow(renWin) +, m_vtkRenderWindowInteractor(NULL) +, m_vtkMitkEventProvider(NULL) { if(m_vtkRenderWindow == NULL) { m_vtkRenderWindow = vtkRenderWindow::New(); //disable Antialiasing by default m_vtkRenderWindow->SetMultiSamples(0); } if ( m_vtkRenderWindow->GetSize()[0] <= 10 || m_vtkRenderWindow->GetSize()[0] <= 10 ) { m_vtkRenderWindow->SetSize( 100, 100 ); } m_vtkRenderWindowInteractor = vtkRenderWindowInteractor::New(); m_vtkRenderWindowInteractor->SetRenderWindow(m_vtkRenderWindow); m_vtkRenderWindowInteractor->Initialize(); // initialize from RenderWindowBase Initialize(rm,name); m_vtkMitkEventProvider = vtkEventProvider::New(); m_vtkMitkEventProvider->SetInteractor(this->GetVtkRenderWindowInteractor()); m_vtkMitkEventProvider->SetMitkRenderWindow(this); m_vtkMitkEventProvider->SetEnabled(1); } mitk::RenderWindow::~RenderWindow() { Destroy(); m_vtkRenderWindow->Delete(); m_vtkRenderWindowInteractor->Delete(); m_vtkMitkEventProvider->Delete(); } vtkRenderWindow* mitk::RenderWindow::GetVtkRenderWindow() { return m_vtkRenderWindow; } vtkRenderWindowInteractor* mitk::RenderWindow::GetVtkRenderWindowInteractor() { return m_vtkRenderWindowInteractor; } void mitk::RenderWindow::SetSize( int width, int height ) { this->GetVtkRenderWindow()->SetSize( width, height ); this->resizeMitkEvent( width, height ); } void mitk::RenderWindow::ReinitEventProvider() { m_vtkMitkEventProvider->SetEnabled(0); m_vtkMitkEventProvider->SetInteractor(this->GetVtkRenderWindowInteractor()); m_vtkMitkEventProvider->SetMitkRenderWindow(this); m_vtkMitkEventProvider->SetEnabled(1); -} \ No newline at end of file +} diff --git a/Core/Code/Rendering/mitkRenderWindowBase.cpp b/Core/Code/Rendering/mitkRenderWindowBase.cpp index 0e66581227..a9813143bc 100644 --- a/Core/Code/Rendering/mitkRenderWindowBase.cpp +++ b/Core/Code/Rendering/mitkRenderWindowBase.cpp @@ -1,163 +1,165 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkRenderWindowBase.h" #include "mitkDisplayPositionEvent.h" #include "mitkVtkLayerController.h" #include "mitkRenderingManager.h" #include "vtkRenderer.h" mitk::RenderWindowBase::RenderWindowBase( ) +: m_RenderProp(NULL) +, m_InResize(false) { } /* * "Member functions, including virtual functions (10.3), can be called during construction or destruction (12.6.2). When a * virtual function is called directly or indirectly from a constructor (including from the mem-initializer for a data member) or from * a destructor, and the object to which the call applies is the object under construction or destruction, the function called is * the one defined in the constructor or destructor�s own class or in one of its bases, but not a function overriding it in a class * derived from the constructor or destructor�s class, or overriding it in one of the other base classes of the most derived object[..]" * or short: within constructors and destructors classes are not polymorph. */ void mitk::RenderWindowBase::Initialize( mitk::RenderingManager* renderingManager, const char* name ) { if ( renderingManager == NULL ) { renderingManager = mitk::RenderingManager::GetInstance(); } if(m_Renderer.IsNull()) { m_Renderer = mitk::VtkPropRenderer::New( name , GetVtkRenderWindow(), renderingManager ); } m_Renderer->InitRenderer(this->GetVtkRenderWindow()); mitk::BaseRenderer::AddInstance(GetVtkRenderWindow(),m_Renderer); renderingManager->AddRenderWindow(GetVtkRenderWindow()); m_RenderProp = vtkMitkRenderProp::New(); m_RenderProp->SetPropRenderer(m_Renderer); m_Renderer->GetVtkRenderer()->AddViewProp(m_RenderProp); if((this->GetVtkRenderWindow()->GetSize()[0] > 10) && (this->GetVtkRenderWindow()->GetSize()[1] > 10)) m_Renderer->InitSize(this->GetVtkRenderWindow()->GetSize()[0], this->GetVtkRenderWindow()->GetSize()[1]); m_InResize = false; } bool mitk::RenderWindowBase::HandleEvent(InteractionEvent* interactionEvent) { return m_Renderer->GetDispatcher()->ProcessEvent(interactionEvent); } void mitk::RenderWindowBase::Destroy() { m_Renderer->GetRenderingManager()->RemoveRenderWindow(GetVtkRenderWindow()); mitk::BaseRenderer::RemoveInstance(GetVtkRenderWindow()); m_Renderer->GetVtkRenderer()->RemoveViewProp(m_RenderProp); m_RenderProp->Delete(); } mitk::RenderWindowBase::~RenderWindowBase() { } void mitk::RenderWindowBase::mousePressMitkEvent(mitk::MouseEvent *me) { if (m_Renderer.IsNotNull()) m_Renderer->MousePressEvent(me); } void mitk::RenderWindowBase::mouseReleaseMitkEvent(mitk::MouseEvent *me) { if(m_Renderer.IsNotNull()) m_Renderer->MouseReleaseEvent(me); } void mitk::RenderWindowBase::mouseMoveMitkEvent(mitk::MouseEvent *me) { if (m_Renderer.IsNotNull()) m_Renderer->MouseMoveEvent(me); } void mitk::RenderWindowBase::wheelMitkEvent(mitk::WheelEvent *we) { if(m_Renderer.IsNotNull()) { m_Renderer->WheelEvent(we); } } void mitk::RenderWindowBase::keyPressMitkEvent(mitk::KeyEvent* mke) { if (m_Renderer.IsNotNull()) m_Renderer->KeyPressEvent(mke); } void mitk::RenderWindowBase::resizeMitkEvent(int width, int height) { if(m_InResize) //@FIXME CRITICAL probably related to VtkSizeBug return; m_InResize = true; if(m_Renderer.IsNotNull()) { m_Renderer->Resize(width, height); } m_InResize = false; } mitk::SliceNavigationController * mitk::RenderWindowBase::GetSliceNavigationController() { return mitk::BaseRenderer::GetInstance(this->GetVtkRenderWindow())->GetSliceNavigationController(); } mitk::CameraRotationController * mitk::RenderWindowBase::GetCameraRotationController() { return mitk::BaseRenderer::GetInstance(this->GetVtkRenderWindow())->GetCameraRotationController(); } mitk::BaseController * mitk::RenderWindowBase::GetController() { mitk::BaseRenderer * renderer = mitk::BaseRenderer::GetInstance(GetVtkRenderWindow()); switch ( renderer->GetMapperID() ) { case mitk::BaseRenderer::Standard2D: return GetSliceNavigationController(); case mitk::BaseRenderer::Standard3D: return GetCameraRotationController(); default: return GetSliceNavigationController(); } } mitk::VtkPropRenderer* mitk::RenderWindowBase::GetRenderer() { return m_Renderer; } diff --git a/Core/Code/Testing/DICOMTesting/CMakeLists.txt b/Core/Code/Testing/DICOMTesting/CMakeLists.txt index 5e1277b2c5..3dd800979d 100644 --- a/Core/Code/Testing/DICOMTesting/CMakeLists.txt +++ b/Core/Code/Testing/DICOMTesting/CMakeLists.txt @@ -1,41 +1,40 @@ if(BUILD_TESTING) if(GDCM_DIR) # clear variables from prior files.cmake # Else CMake would use the content of these variables and would try to create tests (which are not present in DICOMTesting). set(MODULE_TESTS) set(MODULE_IMAGE_TESTS) set(MODULE_SURFACE_TESTS) set(MODULE_TESTIMAGES) set(MODULE_TESTSURFACES) set(MODULE_CUSTOM_TESTS) set(H_FILES) set(CPP_FILES) # now create a new module only for testing purposes MITK_CREATE_MODULE( mitkDICOMTesting DEPENDS Mitk # Mitk.so ) MITK_CHECK_MODULE(_RESULT mitkDICOMTesting) if(_RESULT) message(STATUS "mitkDICOMTesting application won't be built. Missing: ${_RESULT}") else(_RESULT) # add helpful applications -MITK_USE_MODULE( mitkDICOMTesting ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${ALL_INCLUDE_DIRECTORIES}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) # dumps out image information add_executable(DumpDICOMMitkImage DumpDICOMMitkImage.cpp) -target_link_libraries(DumpDICOMMitkImage ${ALL_LIBRARIES}) +mitk_use_modules(TARGET DumpDICOMMitkImage MODULES mitkDICOMTesting) # compares dumped out image information against reference dump add_executable(VerifyDICOMMitkImageDump VerifyDICOMMitkImageDump.cpp) -target_link_libraries(VerifyDICOMMitkImageDump ${ALL_LIBRARIES}) +mitk_use_modules(TARGET VerifyDICOMMitkImageDump MODULES mitkDICOMTesting) add_subdirectory(Testing) endif() endif() endif() diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index 52098d1950..91566467e6 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -1,56 +1,58 @@ set(MITK_DEFAULT_SUBPROJECTS MITK-Examples) #----------------------------------------------------------------------------- # Set-up example plugins #----------------------------------------------------------------------------- if(MITK_USE_BLUEBERRY) # Specify which plug-ins belong to this project macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin_mitk "^org_mitk_example_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin_mitk OUTPUT_VARIABLE ${varname}) endmacro() set(MITK_EXAMPLE_PLUGIN_TARGETS ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) ctkFunctionExtractOptionNameAndValue(${mitk_example_plugin} plugin_name plugin_value) string(REPLACE "." "_" _plugin_target ${plugin_name}) list(APPEND MITK_EXAMPLE_PLUGIN_TARGETS ${_plugin_target}) mark_as_advanced(${${_plugin_target}_option_name}) endforeach() endif() #----------------------------------------------------------------------------- # Add example executables #----------------------------------------------------------------------------- set(MITK_DIR ${PROJECT_BINARY_DIR}) set(MITK_EXPORTS_FILE_INCLUDED 1) set(_example_dirs MbiLog QtFreeRender - Overlays + QtAppExample + Tutorial +# Overlays# depends on QmitkExt.. ) -if(MITK_USE_QT) +# some examples depend on Qt 5 +if (MITK_USE_Qt5) list(APPEND _example_dirs - Tutorial - QtAppExample - ) + QuickRender + ) endif() if(MITK_USE_BLUEBERRY) list(APPEND _example_dirs BlueBerryExampleLauncher ) endif() foreach(_example_dir ${_example_dirs}) add_subdirectory(${_example_dir}) endforeach() diff --git a/Examples/MbiLog/CMakeLists.txt b/Examples/MbiLog/CMakeLists.txt index 7cae548865..d300229fa8 100644 --- a/Examples/MbiLog/CMakeLists.txt +++ b/Examples/MbiLog/CMakeLists.txt @@ -1,16 +1,5 @@ project(MbiLogExample) find_package(MITK REQUIRED) -MITK_USE_MODULE(Mitk) - -include_directories(${ALL_INCLUDE_DIRECTORIES}) - -add_executable(MitkLogExample MitkLogExample.cpp) -target_link_libraries(MitkLogExample ${ALL_LIBRARIES}) - -# subproject support -set_property(TARGET MitkLogExample PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) -foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) - add_dependencies(${subproject} MitkLogExample) -endforeach() +mitk_create_executable(MitkLogExample DEPENDS Mitk) diff --git a/Examples/MbiLog/files.cmake b/Examples/MbiLog/files.cmake new file mode 100644 index 0000000000..9636f82bd1 --- /dev/null +++ b/Examples/MbiLog/files.cmake @@ -0,0 +1 @@ +set(CPP_FILES MitkLogExample.cpp) diff --git a/Examples/Overlays/CMakeLists.txt b/Examples/Overlays/CMakeLists.txt index 3b4d28e120..50292112cf 100644 --- a/Examples/Overlays/CMakeLists.txt +++ b/Examples/Overlays/CMakeLists.txt @@ -1,16 +1,6 @@ project(OverlayExample) find_package(MITK REQUIRED) -MITK_USE_MODULE(Qmitk) -include_directories(${ALL_INCLUDE_DIRECTORIES}) - -add_executable(OverlayExample OverlayExample.cpp) -target_link_libraries(OverlayExample ${ALL_LIBRARIES}) - -# subproject support -set_property(TARGET OverlayExample PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) -foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) - add_dependencies(${subproject} OverlayExample) -endforeach() +mitk_create_executable(${PROJECT_NAME} DEPENDS Qmitk) diff --git a/Examples/Overlays/files.cmake b/Examples/Overlays/files.cmake new file mode 100644 index 0000000000..3bcefd36f6 --- /dev/null +++ b/Examples/Overlays/files.cmake @@ -0,0 +1 @@ +set(CPP_FILES OverlayExample.cpp) diff --git a/Examples/Plugins/org.mitk.example.gui.customviewer.views/CMakeLists.txt b/Examples/Plugins/org.mitk.example.gui.customviewer.views/CMakeLists.txt index 3169aa4945..d38750bd36 100644 --- a/Examples/Plugins/org.mitk.example.gui.customviewer.views/CMakeLists.txt +++ b/Examples/Plugins/org.mitk.example.gui.customviewer.views/CMakeLists.txt @@ -1,12 +1,8 @@ project(org_mitk_example_gui_customviewer_views) -set(QT_USE_QTSQL 1) - -include_directories(${CTK_INCLUDE_DIRS}) - MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE org_mitk_example_gui_customviewer_views_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES QmitkExt mitkDicomUI NO_INSTALL ) diff --git a/Examples/QtAppExample/CMakeLists.txt b/Examples/QtAppExample/CMakeLists.txt index 0ff4fa624d..30c487358a 100644 --- a/Examples/QtAppExample/CMakeLists.txt +++ b/Examples/QtAppExample/CMakeLists.txt @@ -1,34 +1,13 @@ cmake_minimum_required(VERSION 2.8.5) project(QtAppExample) find_package(MITK REQUIRED) # Check that MITK has been build with Qt support if(NOT MITK_USE_QT) message(SEND_ERROR "MITK needs to be built with MITK_USE_QT set to ON") endif() -# Check prerequisites for this application. -# We need the Qmitk module. -MITK_CHECK_MODULE(result Qmitk) -if(result) - message(SEND_ERROR "MITK module(s) \"${result}\" not available from the MITK build at ${MITK_DIR}") -endif() - -# Set-up the build system to use the Qmitk module -MITK_USE_MODULE(Qmitk) -include_directories(${ALL_INCLUDE_DIRECTORIES}) -link_directories(${ALL_LIBRARY_DIRS}) - -add_executable(${PROJECT_NAME} Step1.cpp) -target_link_libraries(${PROJECT_NAME} ${ALL_LIBRARIES}) - - -# This is for subproject support inside the MITK source tree. -# Ignore/remove the following code if you build an external application. -set_property(TARGET ${PROJECT_NAME} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) -foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) - add_dependencies(${subproject} ${PROJECT_NAME}) -endforeach() - +# Create the executable - it needs the Qmitk module +mitk_create_executable(${PROJECT_NAME} DEPENDS Qmitk) diff --git a/Examples/QtAppExample/files.cmake b/Examples/QtAppExample/files.cmake new file mode 100644 index 0000000000..8c800015f3 --- /dev/null +++ b/Examples/QtAppExample/files.cmake @@ -0,0 +1,2 @@ +# List all source files +set(CPP_FILES Step1.cpp) diff --git a/Examples/QtFreeRender/CMakeLists.txt b/Examples/QtFreeRender/CMakeLists.txt index 01ca0aa51d..460a8525ab 100644 --- a/Examples/QtFreeRender/CMakeLists.txt +++ b/Examples/QtFreeRender/CMakeLists.txt @@ -1,26 +1,4 @@ project(QtFreeRender) find_package(MITK) -# Check prerequisites for this application. -# We need the Mitk module. -MITK_CHECK_MODULE(result Mitk) -if(result) - message(SEND_ERROR "MITK module(s) \"${result}\" not available from the MITK build at ${MITK_DIR}") -endif() - -# Set-up the build system to use the Mitk module -MITK_USE_MODULE(Mitk) -include_directories(${ALL_INCLUDE_DIRECTORIES}) -link_directories(${ALL_LIBRARY_DIRS}) - -usFunctionGenerateExecutableInit(init_src_file IDENTIFIER ${PROJECT_NAME}) - -add_executable(${PROJECT_NAME} QtFreeRender.cpp ${init_src_file}) -target_link_libraries(${PROJECT_NAME} ${ALL_LIBRARIES} ) - -# subproject support -set_property(TARGET ${PROJECT_NAME} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) -foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) - add_dependencies(${subproject} ${PROJECT_NAME}) -endforeach() - +mitk_create_executable(${PROJECT_NAME} DEPENDS Mitk) diff --git a/Examples/QtFreeRender/files.cmake b/Examples/QtFreeRender/files.cmake new file mode 100644 index 0000000000..25abca03d9 --- /dev/null +++ b/Examples/QtFreeRender/files.cmake @@ -0,0 +1 @@ +set(CPP_FILES QtFreeRender.cpp) diff --git a/Examples/QuickRender/CMakeLists.txt b/Examples/QuickRender/CMakeLists.txt new file mode 100644 index 0000000000..a9a22af5ed --- /dev/null +++ b/Examples/QuickRender/CMakeLists.txt @@ -0,0 +1,4 @@ +project(QuickRender) +find_package(MITK REQUIRED) + +mitk_create_executable(${PROJECT_NAME} DEPENDS QmlMitk) diff --git a/Examples/QuickRender/QmlMitkFourRenderWindowWidget.qml b/Examples/QuickRender/QmlMitkFourRenderWindowWidget.qml new file mode 100644 index 0000000000..5dc152d6de --- /dev/null +++ b/Examples/QuickRender/QmlMitkFourRenderWindowWidget.qml @@ -0,0 +1,79 @@ +import QtQuick 2.0 +import QmlMitk 1.0 + +Item { + anchors.fill: parent + + QmlMitkRenderWindowItem { + id : renderwindownodeAxial + objectName : "mitkRenderItemAxial" + + anchors.left : parent.left + anchors.right : parent.horizontalCenter + anchors.top : parent.top + anchors.bottom : parent.verticalCenter + anchors.margins : 0 + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.0) + radius: 1; border.width: 3; border.color: "red" + anchors.fill: renderwindownodeAxial + } + + + QmlMitkRenderWindowItem { + id : renderwindownodeSagittal + objectName : "mitkRenderItemSagittal" + + anchors.left : parent.horizontalCenter + anchors.right : parent.right + anchors.top : parent.top + anchors.bottom : parent.verticalCenter + anchors.margins : 0 + + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.0) + radius: 1; border.width: 3; border.color: "green" + anchors.fill: renderwindownodeSagittal + } + + QmlMitkRenderWindowItem { + id : renderwindownodeFrontal + objectName : "mitkRenderItemFrontal" + + anchors.left : parent.left + anchors.right : parent.horizontalCenter + anchors.top : parent.verticalCenter + anchors.bottom : parent.bottom + anchors.margins : 0 + + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.0) + radius: 1; border.width: 3; border.color: "blue" + anchors.fill: renderwindownodeFrontal + } + + QmlMitkRenderWindowItem { + id : renderwindownode3D + objectName : "mitkRenderItem3D" + + anchors.left : parent.horizontalCenter + anchors.right : parent.right + anchors.top : parent.verticalCenter + anchors.bottom : parent.bottom + anchors.margins : 0 + + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.0) + radius: 1; border.width: 3; border.color: "yellow" + anchors.fill: renderwindownode3D + } + +} diff --git a/Examples/QuickRender/QuickRender.qml b/Examples/QuickRender/QuickRender.qml new file mode 100644 index 0000000000..528ca0648e --- /dev/null +++ b/Examples/QuickRender/QuickRender.qml @@ -0,0 +1,135 @@ +import QtQuick 2.0 +import QmlMitk 1.0 + +Item { + + width: 800 + height: 600 + + Rectangle { + id: topbar + + color: "papayawhip" + + height: 30 + + anchors.top : parent.top + anchors.left : parent.left + anchors.right : parent.right + } + + Rectangle { + id: leftbar + + color: "tomato" + + width: 40 + + anchors.left : parent.left + anchors.top : topbar.bottom + anchors.bottom : parent.bottom + } + + Rectangle { + id: rightbar + + color: "peachpuff" + + width: 40 + + anchors.right : parent.right + anchors.top : topbar.bottom + anchors.bottom : parent.bottom + } + + Rectangle { + id: bottombar + + color: "sandybrown" + + height: 15 + + anchors.bottom : parent.bottom + anchors.left : parent.left + anchors.right : parent.right + } + + + + QmlMitkFourRenderWindowWidget { + id : mitkMultiWidget + objectName : "mitkMultiWidget" + + anchors.left : leftbar.right + anchors.right : rightbar.left + anchors.top : topbar.bottom + anchors.bottom : bottombar.top + anchors.margins : 0 + } + + Rectangle + { + id: reactiveRect + color: "mintcream" + opacity: 0.8 + radius: 10 + border.width: 5 + border.color: "mintcream" + + width: 610 + height: 200 + + anchors.horizontalCenter: mitkMultiWidget.horizontalCenter + anchors.verticalCenter: mitkMultiWidget.verticalCenter + + rotation: 3 + + Text + { + id: label + color: "dodgerblue" + wrapMode: Text.WordWrap + font.pointSize: 16 + font.bold: true + text: "The background is a QmlMitkFourRenderWindowWidget\nwrapping four QmlMitkRenderWindowItems\nbased on QVTKQuickItem from OpenView.\nAll the colorful environment is a QML scene..." + + width: 590 + anchors.horizontalCenter: reactiveRect.horizontalCenter + anchors.verticalCenter: reactiveRect.verticalCenter + + rotation: 2 + + } + + MouseArea { id: mouseArea; anchors.fill: reactiveRect; hoverEnabled: true } + + // When the text is pressed, move, rotate and change the color to yellow. + states: State + { + name: "down"; when: mouseArea.containsMouse == true + + PropertyChanges + { + target: reactiveRect; rotation: -2; + } + + PropertyChanges + { + target: label; color: "deeppink"; rotation: -2 + } + } + + // How do we get from the implicit state to the down sate? + transitions: Transition + { + from: ""; to: "down"; reversible: true + + ParallelAnimation + { + NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad } + ColorAnimation { duration: 500 } + } + } + } + +} diff --git a/Examples/QuickRender/QuickRender.qrc b/Examples/QuickRender/QuickRender.qrc new file mode 100644 index 0000000000..9753ba08dc --- /dev/null +++ b/Examples/QuickRender/QuickRender.qrc @@ -0,0 +1,8 @@ + + + QuickRender.qml + + + QmlMitkFourRenderWindowWidget.qml + + diff --git a/Examples/QuickRender/README.md b/Examples/QuickRender/README.md new file mode 100644 index 0000000000..061b41cb40 --- /dev/null +++ b/Examples/QuickRender/README.md @@ -0,0 +1,48 @@ +MITK Rendering with QML prototype +================================================= + +Summary +------------------ + +This mini-application "QuickRender" demonstrates how to possibly build a Qt5 QML based +application that integrates MITK render windows. + +The `QuickRender` application is located in `Examples/QuickRender` + - it provides no "File/Open" dialog + - should be called with a file loadable by MITK, e.g. a 3D ![NRRD file](http://mitk.org/git/?p=MITK-Data.git;a=blob_plain;f=Pic3D.nrrd;hb=HEAD) + +`./QuickRender ~/NRRD-testimages/nrrd3dblock.nrrd` + +![Screenshot](http://maleike.github.io/MITK/quickrender.png) + +Interaction: + - mouse clicks place the cross-hair + - mouse scroll wheel moves to neighboring slice + - holding the right mouse button and moving up/down changes the zoom level + - holding the middle mouse button and mosing pans the scene (only when zoomed in) + +Code Changes +------------------ + +A new module QmlMitk provides + - class `QmlMitkRenderWindowItem`: provides functionality like `QmitkRenderWindowm` based on `QVTKQuickItem` (from ![OpenView](https://github.com/Kitware/openview)) + - class `QmlMitkFourRenderWindowWidget`: simplified replacement for `QmitkStdMultiWidget`, a minimal combination of four `QmlMitkFourRenderWindowWidget`s + - a Qt 5, QtQuick dependency + +Build Instructions +------------------ + + - build Qt 5.1 + - place the Qt 5.1 qmake application in your environment `PATH` + - build MITK superbuild with + - `MITK_BUILD_EXAMPLES` variable switched to `ON` + - advanced option `MITK_USE_CTK` switched to `OFF` + - `MITK_USE_BLUEBERRY` and `MITK_USE_QT` switched to `OFF` (MITK_USE_QT finds Qt 4) + +Open Issues +------------------ + + - Build system integration of Qt 5 dependency + - Build system integration of OpenView package + - cleaner, fuller interfaces for the two new widgets + - real solution for QmlMitkBigRenderLock diff --git a/Examples/QuickRender/files.cmake b/Examples/QuickRender/files.cmake new file mode 100644 index 0000000000..dc26daa56a --- /dev/null +++ b/Examples/QuickRender/files.cmake @@ -0,0 +1,2 @@ +set(CPP_FILES main.cpp) +set(QRC_FILES QuickRender.qrc) diff --git a/Examples/QuickRender/main.cpp b/Examples/QuickRender/main.cpp new file mode 100644 index 0000000000..335ded0938 --- /dev/null +++ b/Examples/QuickRender/main.cpp @@ -0,0 +1,113 @@ + +#include "QmlMitkFourRenderWindowWidget.h" + +#include +#include + +#include "mitkStandaloneDataStorage.h" +#include "mitkDataNodeFactory.h" +#include "mitkGlobalInteraction.h" + +#include "QmlMitkBigRenderLock.h" + +mitk::DataStorage::Pointer FillDataStorage(int argc, char **argv) +{ + if (argc < 2) + { + fprintf(stderr, "Usage: %s [filename1] [filename2] ...\n", ""); + exit(EXIT_FAILURE); + } + + // Create a DataStorage + mitk::DataStorage::Pointer storage = mitk::StandaloneDataStorage::New().GetPointer(); + + //************************************************************************* + // Part II: Create some data by reading files + //************************************************************************* + int i; + for (i = 1; i < argc; ++i) + { + // For testing + if (strcmp(argv[i], "-testing") == 0) + continue; + + // Create a DataNodeFactory to read a data format supported + // by the DataNodeFactory (many image formats, surface formats, etc.) + mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); + const char * filename = argv[i]; + try + { + nodeReader->SetFileName(filename); + nodeReader->Update(); + + // Since the DataNodeFactory directly creates a node, + // use the datastorage to add the read node + mitk::DataNode::Pointer node = nodeReader->GetOutput(); + storage->Add(node); + + mitk::Image::Pointer image = dynamic_cast(node->GetData()); + if (image.IsNotNull()) + { + // Set the property "volumerendering" to the Boolean value "true" + node->SetProperty("volumerendering", mitk::BoolProperty::New(false)); + node->SetProperty("name", mitk::StringProperty::New("testimage")); + node->SetProperty("layer", mitk::IntProperty::New(1)); + } + } catch (...) + { + fprintf(stderr, "Could not open file %s \n\n", filename); + return 0; + } + } + + return storage; +} + +#include "QmlMitkRenderingManagerFactory.h" +void MitkStaticInitialization() +{ + // TODO THIS IS BAD! Move to module activator + static QmlMitkRenderingManagerFactory sanglier; + + mitk::GlobalInteraction::GetInstance()->Initialize("global"); // unbelievable.. still necessary.. +} + +void SetupRenderWindowItems( QQuickItem* container, mitk::DataStorage::Pointer dataStorage ) +{ + QmlMitkFourRenderWindowWidget* mitkMultiWidget = container->findChild("mitkMultiWidget"); + if (mitkMultiWidget) + { + mitkMultiWidget->SetDataStorage( dataStorage ); + } + else + { + MITK_ERROR << "No QmlMitkFourRenderWindowWidget item found during QuickRender application initialization. Uh oh.."; + exit(EXIT_FAILURE); + } +} + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + MitkStaticInitialization(); + mitk::DataStorage::Pointer dataStorage = FillDataStorage(argc,argv); + + // TODO: where to put this? Module activator?? There must be a more Qt-style place.. + qmlRegisterType("QmlMitk", 1, 0, "QmlMitkRenderWindowItem"); + qmlRegisterType("QmlMitk", 1, 0, "QmlMitkFourRenderWindowWidget"); + QQuickView view; + + view.setSource(QUrl("qrc:///MITK/Examples/QuickRender/QuickRender.qml")); + view.setResizeMode( QQuickView::SizeRootObjectToView ); + + + QQuickItem* root = view.rootObject(); + SetupRenderWindowItems( root, dataStorage ); + + view.show(); + + QmlMitkBigRenderLock giantRenderLock; + app.installEventFilter(&giantRenderLock); + return app.exec(); +} diff --git a/Examples/Tutorial/CMakeLists.txt b/Examples/Tutorial/CMakeLists.txt index a914c9ec14..a740798607 100644 --- a/Examples/Tutorial/CMakeLists.txt +++ b/Examples/Tutorial/CMakeLists.txt @@ -1,56 +1,13 @@ -MITK_CHECK_MODULE(MISSING QmitkExt) -if(MISSING) - message("Tutorial won't be built because QmitkExt is missing.") -else(MISSING) - - MITK_USE_MODULE(QmitkExt) - - include_directories(${ALL_INCLUDE_DIRECTORIES}) - - # initialize only the source lists which need additional files - # Step6 is reused in Step7 and Step8. Step6.cpp has to be added - # explicitly since it is not a member of ${STEP6_CPP} at this point - set(STEP6_CPP Step6RegionGrowing1.cpp Step6RegionGrowing2.cpp Step6RegionGrowing3.cpp Step6main.cpp) - set(STEP7_CPP Step6RegionGrowing1.cpp Step6RegionGrowing2.cpp Step6RegionGrowing3.cpp Step6.cpp Step7main.cpp) - set(STEP8_CPP Step6RegionGrowing1.cpp Step6RegionGrowing2.cpp Step6RegionGrowing3.cpp Step6.cpp Step7.cpp Step8main.cpp) - - # some files need Qt wrapping - QT4_WRAP_CPP(STEP6_MOC_CPP Step6.h) - QT4_WRAP_CPP(STEP7_MOC_CPP Step7.h) - QT4_WRAP_CPP(STEP8_MOC_CPP Step8.h) - - # set additional moc files to build - set(STEP6_CPP ${STEP6_CPP} ${STEP6_MOC_CPP}) - set(STEP7_CPP ${STEP7_CPP} ${STEP7_MOC_CPP} ${STEP6_MOC_CPP}) - set(STEP8_CPP ${STEP8_CPP} ${STEP8_MOC_CPP} ${STEP7_MOC_CPP} ${STEP6_MOC_CPP}) - - # for the others it's all the same - foreach(stepNo RANGE 1 8) - set(STEP${stepNo}_CPP ${STEP${stepNo}_CPP} Step${stepNo}.cpp QtTesting.cpp) - add_executable(Step${stepNo} ${STEP${stepNo}_CPP}) - target_link_libraries(Step${stepNo} ${ALL_LIBRARIES}) - endforeach(stepNo) - - - add_dependencies(Step7 Step6) - add_dependencies(Step8 Step7 Step6) - - foreach(stepNo 1 2 3 4 5 6 7 8) - # subproject support - set_property(TARGET Step${stepNo} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) - foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) - add_dependencies(${subproject} Step${stepNo}) - endforeach() - endforeach() - - # adding additional example for mitk itk and vtk interaction - add_executable(mitkWithITKAndVTK mitkWithITKAndVTK.cpp) - target_link_libraries(mitkWithITKAndVTK ${ALL_LIBRARIES}) - - # subproject support - set_property(TARGET mitkWithITKAndVTK PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) - foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) - add_dependencies(${subproject} mitkWithITKAndVTK) - endforeach() - -endif(MISSING) +foreach(stepNo RANGE 1 8) + mitk_create_executable(Step${stepNo} + FILES_CMAKE Step${stepNo}.cmake + DEPENDS QmitkExt + QT4_MODULES QtGui + ) +endforeach() + +# adding additional example for mitk itk and vtk interaction +mitk_create_executable(mitkWithITKAndVTK + DEPENDS Mitk IpPicSupport + FILES_CMAKE mitkWithITKAndVTK.cmake + ) diff --git a/Examples/Tutorial/Step1.cmake b/Examples/Tutorial/Step1.cmake new file mode 100644 index 0000000000..92a91b1c35 --- /dev/null +++ b/Examples/Tutorial/Step1.cmake @@ -0,0 +1,4 @@ +set(CPP_FILES + Step1.cpp + QtTesting.cpp + ) diff --git a/Examples/Tutorial/Step2.cmake b/Examples/Tutorial/Step2.cmake new file mode 100644 index 0000000000..f5b09d7956 --- /dev/null +++ b/Examples/Tutorial/Step2.cmake @@ -0,0 +1,4 @@ +set(CPP_FILES + Step2.cpp + QtTesting.cpp + ) diff --git a/Examples/Tutorial/Step3.cmake b/Examples/Tutorial/Step3.cmake new file mode 100644 index 0000000000..87d69ded85 --- /dev/null +++ b/Examples/Tutorial/Step3.cmake @@ -0,0 +1,4 @@ +set(CPP_FILES + Step3.cpp + QtTesting.cpp + ) diff --git a/Examples/Tutorial/Step4.cmake b/Examples/Tutorial/Step4.cmake new file mode 100644 index 0000000000..b0f2d178f7 --- /dev/null +++ b/Examples/Tutorial/Step4.cmake @@ -0,0 +1,4 @@ +set(CPP_FILES + Step4.cpp + QtTesting.cpp + ) diff --git a/Examples/Tutorial/Step5.cmake b/Examples/Tutorial/Step5.cmake new file mode 100644 index 0000000000..313b66ea2f --- /dev/null +++ b/Examples/Tutorial/Step5.cmake @@ -0,0 +1,4 @@ +set(CPP_FILES + Step5.cpp + QtTesting.cpp + ) diff --git a/Examples/Tutorial/Step6.cmake b/Examples/Tutorial/Step6.cmake new file mode 100644 index 0000000000..60ce1c74cb --- /dev/null +++ b/Examples/Tutorial/Step6.cmake @@ -0,0 +1,12 @@ +set(CPP_FILES + Step6.cpp + Step6RegionGrowing1.cpp + Step6RegionGrowing2.cpp + Step6RegionGrowing3.cpp + Step6main.cpp + QtTesting.cpp + ) + +set(MOC_H_FILES + Step6.h + ) diff --git a/Examples/Tutorial/Step7.cmake b/Examples/Tutorial/Step7.cmake new file mode 100644 index 0000000000..27bf1fc393 --- /dev/null +++ b/Examples/Tutorial/Step7.cmake @@ -0,0 +1,14 @@ +set(CPP_FILES + Step7.cpp + Step6RegionGrowing1.cpp + Step6RegionGrowing2.cpp + Step6RegionGrowing3.cpp + Step6.cpp + Step7main.cpp + QtTesting.cpp + moc_Step6.cxx + ) + +set(MOC_H_FILES + Step7.h + ) diff --git a/Examples/Tutorial/Step8.cmake b/Examples/Tutorial/Step8.cmake new file mode 100644 index 0000000000..7e46ad2ae8 --- /dev/null +++ b/Examples/Tutorial/Step8.cmake @@ -0,0 +1,16 @@ +set(CPP_FILES + Step8.cpp + Step6RegionGrowing1.cpp + Step6RegionGrowing2.cpp + Step6RegionGrowing3.cpp + Step6.cpp + Step7.cpp + Step8main.cpp + QtTesting.cpp + moc_Step6.cxx + moc_Step7.cxx + ) + +set(MOC_H_FILES + Step8.h + ) diff --git a/Examples/Tutorial/mitkWithITKAndVTK.cmake b/Examples/Tutorial/mitkWithITKAndVTK.cmake new file mode 100644 index 0000000000..626b967de0 --- /dev/null +++ b/Examples/Tutorial/mitkWithITKAndVTK.cmake @@ -0,0 +1,3 @@ +set(CPP_FILES + mitkWithITKAndVTK.cpp +) diff --git a/MITKConfig.cmake.in b/MITKConfig.cmake.in index 46cbd1b149..87f61b9a76 100644 --- a/MITKConfig.cmake.in +++ b/MITKConfig.cmake.in @@ -1,199 +1,211 @@ # Update the CMake module path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "@MITK_SOURCE_DIR@/CMake") set(CppMicroServices_DIR "@MITK_BINARY_DIR@/Core/CppMicroServices") # Include MITK macros include(MacroParseArguments) include(mitkFunctionCheckMitkCompatibility) include(mitkFunctionOrganizeSources) include(mitkFunctionCreateWindowsBatchScript) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionInstallAutoLoadModules) include(mitkFunctionGetLibrarySearchPaths) +include(mitkFunctionUseModules) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) +include(mitkMacroCreateExecutable) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) include(mitkMacroCreateCTKPlugin) include(mitkMacroGetPMDPlatformString) # The MITK version number set(MITK_VERSION_MAJOR "@MITK_VERSION_MAJOR@") set(MITK_VERSION_MINOR "@MITK_VERSION_MINOR@") set(MITK_VERSION_PATCH "@MITK_VERSION_PATCH@") set(MITK_VERSION_STRING "@MITK_VERSION_STRING@") # MITK compiler flags set(MITK_C_FLAGS "@MITK_C_FLAGS@") set(MTTK_C_FLAGS_DEBUG "@MITK_C_FLAGS_DEBUG@") set(MITK_C_FLAGS_RELEASE "@MITK_C_FLAGS_RELEASE@") set(MITK_CXX_FLAGS "@MITK_CXX_FLAGS@") set(MTTK_CXX_FLAGS_DEBUG "@MITK_CXX_FLAGS_DEBUG@") set(MITK_CXX_FLAGS_RELEASE "@MITK_CXX_FLAGS_RELEASE@") set(MITK_EXE_LINKER_FLAGS "@MITK_EXE_LINKER_FLAGS@") set(MITK_SHARED_LINKER_FLAGS "@MITK_SHARED_LINKER_FLAGS@") set(MITK_MODULE_LINKER_FLAGS "@MITK_MODULE_LINKER_FLAGS@") # Internal version numbers, used for approximate compatibility checks # of a MITK development version (non-release). set(MITK_VERSION_PLUGIN_SYSTEM 2) # dropped legacy BlueBerry plug-in CMake support # MITK specific variables set(MITK_SOURCE_DIR "@MITK_SOURCE_DIR@") set(MITK_BINARY_DIR "@MITK_BINARY_DIR@") +set(MITK_CMAKE_DIR "@MITK_CMAKE_DIR@") set(UTILITIES_DIR "@UTILITIES_DIR@") set(REGISTER_QFUNCTIONALITY_CPP_IN "@REGISTER_QFUNCTIONALITY_CPP_IN@") set(MITK_MODULES_PACKAGE_DEPENDS_DIR "@MITK_MODULES_PACKAGE_DEPENDS_DIR@") set(MODULES_PACKAGE_DEPENDS_DIRS "@MODULES_PACKAGE_DEPENDS_DIRS@") set(MITK_DOXYGEN_TAGFILE_NAME "@MITK_DOXYGEN_TAGFILE_NAME@") if(MODULES_CONF_DIRS) list(APPEND MODULES_CONF_DIRS "@MODULES_CONF_DIRS@") list(REMOVE_DUPLICATES MODULES_CONF_DIRS) else() set(MODULES_CONF_DIRS "@MODULES_CONF_DIRS@") endif() set(MODULES_CONF_DIRNAME "@MODULES_CONF_DIRNAME@") foreach(_module @MITK_MODULE_NAMES@) set(${_module}_CONFIG_FILE "@MITK_BINARY_DIR@/@MODULES_CONF_DIRNAME@/${_module}Config.cmake") endforeach() # Include directory variables set(MITK_INCLUDE_DIRS "@MITK_INCLUDE_DIRS@") set(QMITK_INCLUDE_DIRS "@QMITK_INCLUDE_DIRS@") set(IPSEGMENTATION_INCLUDE_DIR "@IPSEGMENTATION_INCLUDE_DIR@") set(IPFUNC_INCLUDE_DIR "@IPFUNC_INCLUDE_DIR@") set(MITK_IGT_INCLUDE_DIRS "@MITK_IGT_INCLUDE_DIRS@") # Library variables set(MITK_LIBRARIES "@MITK_LIBRARIES@") set(QMITK_LIBRARIES "@QMITK_LIBRARIES@") # Link directory variables set(MITK_LINK_DIRECTORIES "@MITK_LINK_DIRECTORIES@") set(QMITK_LINK_DIRECTORIES "@QMITK_LINK_DIRECTORIES@") set(MITK_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@/plugins" @MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG@) set(MITK_VTK_LIBRARY_DIRS "@MITK_VTK_LIBRARY_DIRS@") set(MITK_ITK_LIBRARY_DIRS "@MITK_ITK_LIBRARY_DIRS@") # External projects set(ANN_DIR "@ANN_DIR@") set(CppUnit_DIR "@CppUnit_DIR@") set(GLEW_DIR "@GLEW_DIR@") set(tinyxml_DIR "@tinyxml_DIR@") set(ITK_DIR "@ITK_DIR@") set(VTK_DIR "@VTK_DIR@") set(DCMTK_DIR "@DCMTK_DIR@") set(GDCM_DIR "@GDCM_DIR@") set(BOOST_ROOT "@BOOST_ROOT@") set(OpenCV_DIR "@OpenCV_DIR@") set(Poco_DIR "@Poco_DIR@") set(SOFA_DIR "@SOFA_DIR@") set(Qwt_DIR "@Qwt_DIR@") set(Qxt_DIR "@Qxt_DIR@") set(MITK_QMAKE_EXECUTABLE "@QT_QMAKE_EXECUTABLE@") set(MITK_DATA_DIR "@MITK_DATA_DIR@") # External SDK directories set(MITK_PMD_SDK_DIR @MITK_PMD_SDK_DIR@) # MITK use variables set(MITK_USE_QT @MITK_USE_QT@) +set(MITK_USE_Qt4 @MITK_USE_Qt4@) +set(MITK_USE_Qt5 @MITK_USE_Qt5@) +set(MITK_DESIRED_QT_VERSION @DESIRED_QT_VERSION@) set(MITK_USE_BLUEBERRY @MITK_USE_BLUEBERRY@) set(MITK_USE_SYSTEM_Boost @MITK_USE_SYSTEM_Boost@) set(MITK_USE_Boost @MITK_USE_Boost@) set(MITK_USE_Boost_LIBRARIES @MITK_USE_Boost_LIBRARIES@) set(MITK_USE_CTK @MITK_USE_CTK@) set(MITK_USE_DCMTK @MITK_USE_DCMTK@) set(MITK_USE_OpenCV @MITK_USE_OpenCV@) set(MITK_USE_SOFA @MITK_USE_SOFA@) set(MITK_USE_Python @MITK_USE_Python@) +if(MITK_USE_Qt4) + find_package(Qt4 REQUIRED) +elseif(MITK_USE_Qt5) + find_package(Qt5Core REQUIRED) +endif() + # MITK ToF use variables set(MITK_TOF_PMDCAMCUBE_AVAILABLE @MITK_USE_TOF_PMDCAMCUBE@) if(MITK_TOF_PMDCAMCUBE_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_PMDCAMCUBE "Enable support for PMD Cam Cube" @MITK_USE_TOF_PMDCAMCUBE@) mark_as_advanced(MITK_USE_TOF_PMDCAMCUBE) endif() set(MITK_TOF_PMDCAMBOARD_AVAILABLE @MITK_USE_TOF_PMDCAMBOARD@) if(MITK_TOF_PMDCAMBOARD_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_PMDCAMBOARD "Enable support for PMD Cam Board" @MITK_USE_TOF_PMDCAMBOARD@) mark_as_advanced(MITK_USE_TOF_PMDCAMBOARD) endif() set(MITK_TOF_PMDO3_AVAILABLE @MITK_USE_TOF_PMDO3@) if(MITK_TOF_PMDO3_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_PMDO3 "Enable support for PMD =3" @MITK_USE_TOF_PMDO3@) mark_as_advanced(MITK_USE_TOF_PMDO3) endif() set(MITK_TOF_KINECT_AVAILABLE @MITK_USE_TOF_KINECT@) if(MITK_TOF_KINECT_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_KINECT "Enable support for Kinect" @MITK_USE_TOF_KINECT@) mark_as_advanced(MITK_USE_TOF_KINECT) endif() set(MITK_TOF_MESASR4000_AVAILABLE @MITK_USE_TOF_MESASR4000@) if(MITK_TOF_MESASR4000_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_MESASR4000 "Enable support for MESA SR4000" @MITK_USE_TOF_MESASR4000@) mark_as_advanced(MITK_USE_TOF_MESASR4000) endif() if(MITK_USE_IGT) #include(${MITK_DIR}/mitkIGTConfig.cmake) endif() # Install rules for ToF libraries loaded at runtime include(@MITK_BINARY_DIR@/mitkToFHardwareInstallRules.cmake) if(NOT MITK_EXPORTS_FILE_INCLUDED) if(EXISTS "@MITK_EXPORTS_FILE@") set(MITK_EXPORTS_FILE_INCLUDED 1) include("@MITK_EXPORTS_FILE@") endif(EXISTS "@MITK_EXPORTS_FILE@") endif() # BlueBerry support if(MITK_USE_BLUEBERRY) set(BlueBerry_DIR "@MITK_BINARY_DIR@/BlueBerry") # Don't include the BlueBerry exports file, since the targets are # also exported in the MITK exports file set(BB_PLUGIN_EXPORTS_FILE_INCLUDED 1) find_package(BlueBerry) if(NOT BlueBerry_FOUND) message(SEND_ERROR "MITK does not seem to be configured with BlueBerry support. Set MITK_USE_BLUEBERRY to ON in your MITK build configuration.") endif(NOT BlueBerry_FOUND) set(MITK_PLUGIN_USE_FILE @MITK_PLUGIN_USE_FILE@) if(MITK_PLUGIN_USE_FILE) if(EXISTS ${MITK_PLUGIN_USE_FILE}) include(${MITK_PLUGIN_USE_FILE}) endif() endif() set(MITK_PLUGIN_PROVISIONING_FILE "@MITK_EXTAPP_PROVISIONING_FILE@") set(MITK_PROVISIONING_FILES "${BLUEBERRY_PLUGIN_PROVISIONING_FILE}" "${MITK_PLUGIN_PROVISIONING_FILE}") endif(MITK_USE_BLUEBERRY) # Set properties on exported targets @MITK_EXPORTED_TARGET_PROPERTIES@ diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index 53a3f18f4b..d1cc7b61ed 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,73 +1,76 @@ set(LIBPOSTFIX "Ext") # Modules must be listed according to their dependencies set(module_dirs MitkDataTypesExt MitkAlgorithmsExt MitkMapperExt MitkIOExt + Qt4Qt5TestModule SceneSerializationBase PlanarFigure ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport MitkExt SceneSerialization GraphAlgorithms ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation + OpenViewCore + QmlMitk Qmitk QmitkExt SegmentationUI DiffusionImaging GPGPU IGTBase IGT CameraCalibration IGTUI RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing ToFUI US ClippingTools USUI DicomUI Simulation Remeshing Python ) if(MITK_ENABLE_PIC_READER) list(APPEND module_dirs IpPicSupportIO) endif() set(MITK_DEFAULT_SUBPROJECTS MITK-Modules) foreach(module_dir ${module_dirs}) add_subdirectory(${module_dir}) endforeach() if(MITK_PRIVATE_MODULES) file(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) foreach(subdir ${all_subdirs}) string(FIND ${subdir} "." _result) if(_result EQUAL -1) if(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) message(STATUS "Found private module ${subdir}") add_subdirectory(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) endif() endif() endforeach() endif(MITK_PRIVATE_MODULES) diff --git a/Modules/DeformableRegistrationUI/CMakeLists.txt b/Modules/DeformableRegistrationUI/CMakeLists.txt index 89c824517c..96b8ee467d 100644 --- a/Modules/DeformableRegistrationUI/CMakeLists.txt +++ b/Modules/DeformableRegistrationUI/CMakeLists.txt @@ -1,6 +1,6 @@ MITK_CREATE_MODULE(MitkDeformableRegistrationUI SUBPROJECTS MITK-Registration DEPENDS Qmitk MitkDeformableRegistration - QT_MODULE + QT4_MODULES QtGui EXPORT_DEFINE MITK_DEFORMABLEREGISTRATION_UI_EXPORT ) diff --git a/Modules/DicomUI/CMakeLists.txt b/Modules/DicomUI/CMakeLists.txt index a2a176f202..e8cbcdf183 100644 --- a/Modules/DicomUI/CMakeLists.txt +++ b/Modules/DicomUI/CMakeLists.txt @@ -1,10 +1,8 @@ -set(QT_USE_QTSQL 1) - include_directories(${CTK_INCLUDE_DIRS}) MITK_CREATE_MODULE(mitkDicomUI DEPENDS Mitk - PACKAGE_DEPENDS CTK QT - QT_MODULE + PACKAGE_DEPENDS CTK + QT4_MODULES QtGui QtSql EXPORT_DEFINE MITK_DICOMUI_EXPORT ) diff --git a/Modules/GPGPU/CMakeLists.txt b/Modules/GPGPU/CMakeLists.txt index 03431b7b1c..a07e5d5d6c 100644 --- a/Modules/GPGPU/CMakeLists.txt +++ b/Modules/GPGPU/CMakeLists.txt @@ -1,19 +1,19 @@ if(APPLE) message(STATUS "Module GPGPU is not ported to MacOS yet") else(APPLE) set(package_deps) if(UNIX) list(APPEND package_deps X11) endif() MITK_CREATE_MODULE(mitkGPGPU # INCLUDE_DIRS . DEPENDS Mitk - PACKAGE_DEPENDS QT ${package_deps} GLEW + PACKAGE_DEPENDS ${package_deps} GLEW EXPORT_DEFINE GPGPU_DLL_API - QT_MODULE + QT4_MODULES QtCore QtGui ) endif(APPLE) diff --git a/Modules/IGT/Tutorial/CMakeLists.txt b/Modules/IGT/Tutorial/CMakeLists.txt index b477c15832..85dce3fb31 100644 --- a/Modules/IGT/Tutorial/CMakeLists.txt +++ b/Modules/IGT/Tutorial/CMakeLists.txt @@ -1,7 +1,5 @@ -MITK_USE_MODULE(MitkIGT MitkDataTypesExt) - add_executable(mitkIGTTutorialStep1 mitkIGTTutorialStep1.cpp) -target_link_libraries(mitkIGTTutorialStep1 ${ALL_LIBRARIES}) +mitk_use_modules(TARGET mitkIGTTutorialStep1 MODULES MitkIGT MitkDataTypesExt) add_executable(mitkIGTTutorialStep2 mitkIGTTutorialStep2.cpp) -target_link_libraries(mitkIGTTutorialStep2 ${ALL_LIBRARIES}) +mitk_use_modules(TARGET mitkIGTTutorialStep2 MODULES MitkIGT MitkDataTypesExt) diff --git a/Modules/IGTUI/CMakeLists.txt b/Modules/IGTUI/CMakeLists.txt index 83161cf33e..8403a57dab 100644 --- a/Modules/IGTUI/CMakeLists.txt +++ b/Modules/IGTUI/CMakeLists.txt @@ -1,12 +1,12 @@ MITK_CREATE_MODULE(MitkIGTUI SUBPROJECTS MITK-IGT INCLUDE_DIRS Qmitk DEPENDS MitkIGT Qmitk QmitkExt - QT_MODULE + QT4_MODULES QtGui GENERATED_CPP ${TOOL_GUI_CPPS} ${TOOL_CPPS} ) ## create IGTUI config configure_file(mitkIGTUIConfig.h.in ${PROJECT_BINARY_DIR}/mitkIGTUIConfig.h @ONLY) diff --git a/Modules/OpenCVVideoSupport/UI/CMakeLists.txt b/Modules/OpenCVVideoSupport/UI/CMakeLists.txt index 3d844ae4dd..de4a3b1299 100644 --- a/Modules/OpenCVVideoSupport/UI/CMakeLists.txt +++ b/Modules/OpenCVVideoSupport/UI/CMakeLists.txt @@ -1,11 +1,10 @@ MITK_CREATE_MODULE(mitkOpenCVVideoSupportUI DEPENDS QmitkExt mitkOpenCVVideoSupport - PACKAGE_DEPENDS QT - QT_MODULE + QT4_MODULES QtGui EXPORT_DEFINE MITK_OPENCVVIDEOSUPPORTUI_EXPORT ) # no tests yet #if(BUILD_TESTING) - #add_subdirectory(Testing) + #add_subdirectory(Testing) #endif(BUILD_TESTING) diff --git a/Modules/OpenViewCore/CMakeLists.txt b/Modules/OpenViewCore/CMakeLists.txt new file mode 100644 index 0000000000..3d8aa20d86 --- /dev/null +++ b/Modules/OpenViewCore/CMakeLists.txt @@ -0,0 +1,6 @@ +MITK_CREATE_MODULE(OpenViewCore + PACKAGE_DEPENDS VTK OpenGL + EXPORT_DEFINE OVCORE_EXPORT + QT5_MODULES Qt5Core Qt5Quick + ) + diff --git a/Modules/OpenViewCore/LICENSE b/Modules/OpenViewCore/LICENSE new file mode 100644 index 0000000000..d984dbbb61 --- /dev/null +++ b/Modules/OpenViewCore/LICENSE @@ -0,0 +1,34 @@ +Copyright (c) 2012 Kitware Inc. + +Kitware Inc. +28 Corporate Drive +Clifton Park, NY 12065 +USA + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + + * Neither the name of Kitware nor the names of any contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Modules/OpenViewCore/QVTKInteractor.cxx b/Modules/OpenViewCore/QVTKInteractor.cxx new file mode 100644 index 0000000000..9b1a89ad78 --- /dev/null +++ b/Modules/OpenViewCore/QVTKInteractor.cxx @@ -0,0 +1,265 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: QVTKWidget.cxx + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ +/* + * Copyright 2004 Sandia Corporation. + * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + * license for use of this work by or on behalf of the + * U.S. Government. Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that this Notice and any + * statement of authorship are reproduced on all copies. + */ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +#ifdef _MSC_VER +// Disable warnings that Qt headers give. +#pragma warning(disable:4127) +#pragma warning(disable:4512) +#endif + +#include "QVTKInteractor.h" +#include "QVTKInteractorInternal.h" + +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) +# include "vtkTDxWinDevice.h" +#endif + +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) +# include "vtkTDxMacDevice.h" +#endif + +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) +# include "vtkTDxUnixDevice.h" +#endif + +#include +#include +#include +#include + +#include "vtkObjectFactory.h" +#include "vtkCommand.h" +#include "vtkRenderWindow.h" + +QVTKInteractorInternal::QVTKInteractorInternal(QVTKInteractor* p) + : Parent(p) +{ + this->SignalMapper = new QSignalMapper(this); + QObject::connect(this->SignalMapper, SIGNAL(mapped(int)), this, SLOT(TimerEvent(int)) ); +} + +QVTKInteractorInternal::~QVTKInteractorInternal() +{ +} + +void QVTKInteractorInternal::TimerEvent(int id) +{ + Parent->TimerEvent(id); +} + +/*! allocation method for Qt/VTK interactor + */ +vtkStandardNewMacro(QVTKInteractor); + +/*! constructor for Qt/VTK interactor + */ +QVTKInteractor::QVTKInteractor() +{ + this->Internal = new QVTKInteractorInternal(this); + +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) + this->Device=vtkTDxWinDevice::New(); +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) + this->Device=vtkTDxMacDevice::New(); +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) + this->Device=0; +#endif +} + +void QVTKInteractor::Initialize() +{ +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) + if(this->UseTDx) + { + // this is QWidget::winId(); + HWND hWnd=static_cast(this->GetRenderWindow()->GetGenericWindowId()); + if(!this->Device->GetInitialized()) + { + this->Device->SetInteractor(this); + this->Device->SetWindowHandle(hWnd); + this->Device->Initialize(); + } + } +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) + if(this->UseTDx) + { + if(!this->Device->GetInitialized()) + { + this->Device->SetInteractor(this); + // Do not initialize the device here. + } + } +#endif + this->Initialized = 1; + this->Enable(); +} + +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) +// ---------------------------------------------------------------------------- +vtkTDxUnixDevice *QVTKInteractor::GetDevice() +{ + return this->Device; +} + +// ---------------------------------------------------------------------------- +void QVTKInteractor::SetDevice(vtkTDxDevice *device) +{ + if(this->Device!=device) + { + this->Device=static_cast(device); + } +} +#endif + + +/*! start method for interactor + */ +void QVTKInteractor::Start() +{ + vtkErrorMacro(<<"QVTKInteractor cannot control the event loop."); +} + +/*! terminate the application + */ +void QVTKInteractor::TerminateApp() +{ + // we are in a GUI so let's terminate the GUI the normal way + //qApp->exit(); +} + +// ---------------------------------------------------------------------------- +void QVTKInteractor::StartListening() +{ +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) + if(this->Device->GetInitialized() && !this->Device->GetIsListening()) + { + this->Device->StartListening(); + } +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) + if(this->UseTDx && !this->Device->GetInitialized()) + { + this->Device->Initialize(); + } +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) + if(this->UseTDx && this->Device!=0) + { + this->Device->SetInteractor(this); + } +#endif +} + +// ---------------------------------------------------------------------------- +void QVTKInteractor::StopListening() +{ +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) + if(this->Device->GetInitialized() && this->Device->GetIsListening()) + { + this->Device->StopListening(); + } +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) + if(this->UseTDx && this->Device->GetInitialized()) + { + this->Device->Close(); + } +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) + if(this->UseTDx && this->Device!=0) + { + // this assumes that a outfocus event is emitted prior + // a infocus event on another widget. + this->Device->SetInteractor(0); + } +#endif +} + + +/*! handle timer event + */ +void QVTKInteractor::TimerEvent(int timerId) +{ + if ( !this->GetEnabled() ) + { + return; + } + this->InvokeEvent(vtkCommand::TimerEvent, (void*)&timerId); + + if(this->IsOneShotTimer(timerId)) + { + this->DestroyTimer(timerId); // 'cause our Qt timers are always repeating + } +} + +/*! constructor + */ +QVTKInteractor::~QVTKInteractor() +{ + delete this->Internal; +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) + this->Device->Delete(); +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) + this->Device->Delete(); +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) + this->Device=0; +#endif +} + +/*! create Qt timer with an interval of 10 msec. + */ +int QVTKInteractor::InternalCreateTimer(int timerId, int vtkNotUsed(timerType), unsigned long duration) +{ + QTimer* timer = new QTimer(this->Internal); + timer->start(duration); + this->Internal->SignalMapper->setMapping(timer, timerId); + QObject::connect(timer, SIGNAL(timeout()), this->Internal->SignalMapper, SLOT(map())); + int platformTimerId = timer->timerId(); + this->Internal->Timers.insert(QVTKInteractorInternal::TimerMap::value_type(platformTimerId, timer)); + return platformTimerId; +} + +/*! destroy timer + */ +int QVTKInteractor::InternalDestroyTimer(int platformTimerId) +{ + QVTKInteractorInternal::TimerMap::iterator iter = this->Internal->Timers.find(platformTimerId); + if(iter != this->Internal->Timers.end()) + { + iter->second->stop(); + iter->second->deleteLater(); + this->Internal->Timers.erase(iter); + return 1; + } + return 0; +} diff --git a/Modules/OpenViewCore/QVTKInteractor.h b/Modules/OpenViewCore/QVTKInteractor.h new file mode 100644 index 0000000000..5bc6baca41 --- /dev/null +++ b/Modules/OpenViewCore/QVTKInteractor.h @@ -0,0 +1,140 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: QVTKInteractor.h + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ + +/*========================================================================= + + Copyright 2004 Sandia Corporation. + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +=========================================================================*/ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +// .NAME QVTKInteractor - Handle Qt events. +// .SECTION Description +// QVTKInteractor handles relaying Qt events to VTK. + +#ifndef Q_VTK_INTERACTOR_H +#define Q_VTK_INTERACTOR_H + +#include +#include +#include + +#include "vtkTDxConfigure.h" // defines VTK_USE_TDX +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) +class vtkTDxWinDevice; +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) +class vtkTDxMacDevice; +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) +class vtkTDxDevice; +class vtkTDxUnixDevice; +#endif + +#include "OpenViewCoreExports.h" + +class QVTKInteractorInternal; + +// .NAME QVTKInteractor - An interactor for the QVTKWidget. +// .SECTION Description +// QVTKInteractor is an interactor for a QVTKWiget. + +class OVCORE_EXPORT QVTKInteractor : public vtkRenderWindowInteractor +{ +public: + static QVTKInteractor* New(); + vtkTypeMacro(QVTKInteractor,vtkRenderWindowInteractor); + + // Description: + // Enum for additional event types supported. + // These events can be picked up by command observers on the interactor + enum vtkCustomEvents + { + ContextMenuEvent = vtkCommand::UserEvent + 100, + DragEnterEvent, + DragMoveEvent, + DragLeaveEvent, + DropEvent + }; + + + // Description: + // Overloaded terminiate app, which does nothing in Qt. + // Use qApp->exit() instead. + virtual void TerminateApp(); + + // Description: + // Overloaded start method does nothing. + // Use qApp->exec() instead. + virtual void Start(); + virtual void Initialize(); + + // Description: + // Start listening events on 3DConnexion device. + virtual void StartListening(); + + // Description: + // Stop listening events on 3DConnexion device. + virtual void StopListening(); + + // timer event slot + virtual void TimerEvent(int timerId); + +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) + virtual vtkTDxUnixDevice *GetDevice(); + virtual void SetDevice(vtkTDxDevice *device); +#endif + +protected: + // constructor + QVTKInteractor(); + // destructor + ~QVTKInteractor(); + + // create a Qt Timer + virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration); + // destroy a Qt Timer + virtual int InternalDestroyTimer(int platformTimerId); +#if defined(VTK_USE_TDX) && defined(Q_WS_WIN) + vtkTDxWinDevice *Device; +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_MAC) + vtkTDxMacDevice *Device; +#endif +#if defined(VTK_USE_TDX) && defined(Q_WS_X11) + vtkTDxUnixDevice *Device; +#endif + +private: + + QVTKInteractorInternal* Internal; + + // unimplemented copy + QVTKInteractor(const QVTKInteractor&); + // unimplemented operator= + void operator=(const QVTKInteractor&); + +}; + +#endif diff --git a/Modules/OpenViewCore/QVTKInteractorAdapter.cxx b/Modules/OpenViewCore/QVTKInteractorAdapter.cxx new file mode 100644 index 0000000000..4fd856e0a8 --- /dev/null +++ b/Modules/OpenViewCore/QVTKInteractorAdapter.cxx @@ -0,0 +1,455 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: QVTKInteractorAdapter.cxx + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ +/* + * Copyright 2004 Sandia Corporation. + * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + * license for use of this work by or on behalf of the + * U.S. Government. Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that this Notice and any + * statement of authorship are reproduced on all copies. + */ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +#ifdef _MSC_VER +// Disable warnings that Qt headers give. +#pragma warning(disable:4127) +#pragma warning(disable:4512) +#endif + +#include "QVTKInteractorAdapter.h" +#include "QVTKInteractor.h" + +#include +#include +#include +#include + +#include "vtkCommand.h" + + +// function to get VTK keysyms from ascii characters +static const char* ascii_to_key_sym(int); +// function to get VTK keysyms from Qt keys +static const char* qt_key_to_key_sym(Qt::Key, Qt::KeyboardModifiers modifiers); + +QVTKInteractorAdapter::QVTKInteractorAdapter(QObject* parentObject) + : QObject(parentObject) +{ +} + +QVTKInteractorAdapter::~QVTKInteractorAdapter() +{ +} + +bool QVTKInteractorAdapter::ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren) +{ + if(iren == NULL || e == NULL) + return false; + + const QEvent::Type t = e->type(); + + if(t == QEvent::Resize) + { + QResizeEvent* e2 = static_cast(e); + QSize size = e2->size(); + iren->SetSize(size.width(), size.height()); + return true; + } + + if(t == QEvent::FocusIn) + { + // For 3DConnexion devices: + QVTKInteractor* qiren = QVTKInteractor::SafeDownCast(iren); + if(qiren) + { + qiren->StartListening(); + } + return true; + } + + if(t == QEvent::FocusOut) + { + // For 3DConnexion devices: + QVTKInteractor* qiren = QVTKInteractor::SafeDownCast(iren); + if(qiren) + { + qiren->StopListening(); + } + return true; + } + + // the following events only happen if the interactor is enabled + if(!iren->GetEnabled()) + return false; + + if(t == QEvent::MouseButtonPress || + t == QEvent::MouseButtonRelease || + t == QEvent::MouseButtonDblClick || + t == QEvent::MouseMove) + { + QMouseEvent* e2 = static_cast(e); + + // give interactor the event information + iren->SetEventInformationFlipY(e2->x(), e2->y(), + (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0, + (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0, + 0, + e2->type() == QEvent::MouseButtonDblClick ? 1 : 0); + + if(t == QEvent::MouseMove) + { + iren->InvokeEvent(vtkCommand::MouseMoveEvent, e2); + } + else if(t == QEvent::MouseButtonPress || t == QEvent::MouseButtonDblClick) + { + switch(e2->button()) + { + case Qt::LeftButton: + iren->InvokeEvent(vtkCommand::LeftButtonPressEvent, e2); + break; + + case Qt::MidButton: + iren->InvokeEvent(vtkCommand::MiddleButtonPressEvent, e2); + break; + + case Qt::RightButton: + iren->InvokeEvent(vtkCommand::RightButtonPressEvent, e2); + break; + + default: + break; + } + } + else if(t == QEvent::MouseButtonRelease) + { + switch(e2->button()) + { + case Qt::LeftButton: + iren->InvokeEvent(vtkCommand::LeftButtonReleaseEvent, e2); + break; + + case Qt::MidButton: + iren->InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, e2); + break; + + case Qt::RightButton: + iren->InvokeEvent(vtkCommand::RightButtonReleaseEvent, e2); + break; + + default: + break; + } + } + return true; + } + + if(t == QEvent::Enter) + { + iren->InvokeEvent(vtkCommand::EnterEvent, e); + return true; + } + + if(t == QEvent::Leave) + { + iren->InvokeEvent(vtkCommand::LeaveEvent, e); + return true; + } + + if(t == QEvent::KeyPress || t == QEvent::KeyRelease) + { + QKeyEvent* e2 = static_cast(e); + + // get key and keysym information + int ascii_key = e2->text().length() ? e2->text().unicode()->toLatin1() : 0; + const char* keysym = ascii_to_key_sym(ascii_key); + if(!keysym || + e2->modifiers() == Qt::KeypadModifier) + { + // get virtual keys + keysym = qt_key_to_key_sym(static_cast(e2->key()), + e2->modifiers()); + } + + if(!keysym) + { + keysym = "None"; + } + + // give interactor event information + iren->SetKeyEventInformation( + (e2->modifiers() & Qt::ControlModifier), + (e2->modifiers() & Qt::ShiftModifier), + ascii_key, e2->count(), keysym); + + if(t == QEvent::KeyPress) + { + // invoke vtk event + iren->InvokeEvent(vtkCommand::KeyPressEvent, e2); + + // invoke char event only for ascii characters + if(ascii_key) + { + iren->InvokeEvent(vtkCommand::CharEvent, e2); + } + } + else + { + iren->InvokeEvent(vtkCommand::KeyReleaseEvent, e2); + } + return true; + } + + if(t == QEvent::Wheel) + { + QWheelEvent* e2 = static_cast(e); + + iren->SetEventInformationFlipY(e2->x(), e2->y(), + (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0, + (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0); + + // invoke vtk event + // if delta is positive, it is a forward wheel event + if(e2->delta() > 0) + { + iren->InvokeEvent(vtkCommand::MouseWheelForwardEvent, e2); + } + else + { + iren->InvokeEvent(vtkCommand::MouseWheelBackwardEvent, e2); + } + return true; + } + + if(t == QEvent::ContextMenu) + { + QContextMenuEvent* e2 = static_cast(e); + + // give interactor the event information + iren->SetEventInformationFlipY(e2->x(), e2->y(), + (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0, + (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0); + + // invoke event and pass qt event for additional data as well + iren->InvokeEvent(QVTKInteractor::ContextMenuEvent, e2); + + return true; + } + + if(t == QEvent::DragEnter) + { + QDragEnterEvent* e2 = static_cast(e); + + // invoke event and pass qt event for additional data as well + iren->InvokeEvent(QVTKInteractor::DragEnterEvent, e2); + + return true; + } + + if(t == QEvent::DragLeave) + { + QDragLeaveEvent* e2 = static_cast(e); + + // invoke event and pass qt event for additional data as well + iren->InvokeEvent(QVTKInteractor::DragLeaveEvent, e2); + + return true; + } + + if(t == QEvent::DragMove) + { + QDragMoveEvent* e2 = static_cast(e); + + // give interactor the event information + iren->SetEventInformationFlipY(e2->pos().x(), e2->pos().y()); + + // invoke event and pass qt event for additional data as well + iren->InvokeEvent(QVTKInteractor::DragMoveEvent, e2); + return true; + } + + if(t == QEvent::Drop) + { + QDropEvent* e2 = static_cast(e); + + // give interactor the event information + iren->SetEventInformationFlipY(e2->pos().x(), e2->pos().y()); + + // invoke event and pass qt event for additional data as well + iren->InvokeEvent(QVTKInteractor::DropEvent, e2); + return true; + } + + return false; +} + +// ***** keysym stuff below ***** + +static const char *AsciiToKeySymTable[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, "Tab", 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + "space", "exclam", "quotedbl", "numbersign", + "dollar", "percent", "ampersand", "quoteright", + "parenleft", "parenright", "asterisk", "plus", + "comma", "minus", "period", "slash", + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", "colon", "semicolon", "less", "equal", "greater", "question", + "at", "A", "B", "C", "D", "E", "F", "G", + "H", "I", "J", "K", "L", "M", "N", "O", + "P", "Q", "R", "S", "T", "U", "V", "W", + "X", "Y", "Z", "bracketleft", + "backslash", "bracketright", "asciicircum", "underscore", + "quoteleft", "a", "b", "c", "d", "e", "f", "g", + "h", "i", "j", "k", "l", "m", "n", "o", + "p", "q", "r", "s", "t", "u", "v", "w", + "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Delete", + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +const char* ascii_to_key_sym(int i) +{ + if(i >= 0) + { + return AsciiToKeySymTable[i]; + } + return 0; +} + +#define QVTK_HANDLE(x,y) \ + case x : \ + ret = y; \ + break; + +#define QVTK_HANDLE_KEYPAD(x, y, z) \ + case x : \ + ret = (modifiers & Qt::KeypadModifier) ? (y) : (z); \ + break; + +const char* qt_key_to_key_sym(Qt::Key i, Qt::KeyboardModifiers modifiers) +{ + const char* ret = 0; + switch(i) + { + // Cancel + QVTK_HANDLE(Qt::Key_Backspace, "BackSpace") + QVTK_HANDLE(Qt::Key_Tab, "Tab") + QVTK_HANDLE(Qt::Key_Backtab, "Tab") + QVTK_HANDLE(Qt::Key_Clear, "Clear") + QVTK_HANDLE(Qt::Key_Return, "Return") + QVTK_HANDLE(Qt::Key_Enter, "Return") + QVTK_HANDLE(Qt::Key_Shift, "Shift_L") + QVTK_HANDLE(Qt::Key_Control, "Control_L") + QVTK_HANDLE(Qt::Key_Alt, "Alt_L") + QVTK_HANDLE(Qt::Key_Pause, "Pause") + QVTK_HANDLE(Qt::Key_CapsLock, "Caps_Lock") + QVTK_HANDLE(Qt::Key_Escape, "Escape") + QVTK_HANDLE(Qt::Key_Space, "space") + QVTK_HANDLE(Qt::Key_PageUp, "Prior") + QVTK_HANDLE(Qt::Key_PageDown, "Next") + QVTK_HANDLE(Qt::Key_End, "End") + QVTK_HANDLE(Qt::Key_Home, "Home") + QVTK_HANDLE(Qt::Key_Left, "Left") + QVTK_HANDLE(Qt::Key_Up, "Up") + QVTK_HANDLE(Qt::Key_Right, "Right") + QVTK_HANDLE(Qt::Key_Down, "Down") + QVTK_HANDLE(Qt::Key_Select, "Select") + QVTK_HANDLE(Qt::Key_Execute, "Execute") + QVTK_HANDLE(Qt::Key_SysReq, "Snapshot") + QVTK_HANDLE(Qt::Key_Insert, "Insert") + QVTK_HANDLE(Qt::Key_Delete, "Delete") + QVTK_HANDLE(Qt::Key_Help, "Help") + QVTK_HANDLE_KEYPAD(Qt::Key_0, "KP_0", "0") + QVTK_HANDLE_KEYPAD(Qt::Key_1, "KP_1", "1") + QVTK_HANDLE_KEYPAD(Qt::Key_2, "KP_2", "2") + QVTK_HANDLE_KEYPAD(Qt::Key_3, "KP_3", "3") + QVTK_HANDLE_KEYPAD(Qt::Key_4, "KP_4", "4") + QVTK_HANDLE_KEYPAD(Qt::Key_5, "KP_5", "5") + QVTK_HANDLE_KEYPAD(Qt::Key_6, "KP_6", "6") + QVTK_HANDLE_KEYPAD(Qt::Key_7, "KP_7", "7") + QVTK_HANDLE_KEYPAD(Qt::Key_8, "KP_8", "8") + QVTK_HANDLE_KEYPAD(Qt::Key_9, "KP_9", "9") + QVTK_HANDLE(Qt::Key_A, "a") + QVTK_HANDLE(Qt::Key_B, "b") + QVTK_HANDLE(Qt::Key_C, "c") + QVTK_HANDLE(Qt::Key_D, "d") + QVTK_HANDLE(Qt::Key_E, "e") + QVTK_HANDLE(Qt::Key_F, "f") + QVTK_HANDLE(Qt::Key_G, "g") + QVTK_HANDLE(Qt::Key_H, "h") + QVTK_HANDLE(Qt::Key_I, "i") + QVTK_HANDLE(Qt::Key_J, "h") + QVTK_HANDLE(Qt::Key_K, "k") + QVTK_HANDLE(Qt::Key_L, "l") + QVTK_HANDLE(Qt::Key_M, "m") + QVTK_HANDLE(Qt::Key_N, "n") + QVTK_HANDLE(Qt::Key_O, "o") + QVTK_HANDLE(Qt::Key_P, "p") + QVTK_HANDLE(Qt::Key_Q, "q") + QVTK_HANDLE(Qt::Key_R, "r") + QVTK_HANDLE(Qt::Key_S, "s") + QVTK_HANDLE(Qt::Key_T, "t") + QVTK_HANDLE(Qt::Key_U, "u") + QVTK_HANDLE(Qt::Key_V, "v") + QVTK_HANDLE(Qt::Key_W, "w") + QVTK_HANDLE(Qt::Key_X, "x") + QVTK_HANDLE(Qt::Key_Y, "y") + QVTK_HANDLE(Qt::Key_Z, "z") + QVTK_HANDLE(Qt::Key_Asterisk, "asterisk") + QVTK_HANDLE(Qt::Key_Plus, "plus") + QVTK_HANDLE(Qt::Key_Bar, "bar") + QVTK_HANDLE(Qt::Key_Minus, "minus") + QVTK_HANDLE(Qt::Key_Period, "period") + QVTK_HANDLE(Qt::Key_Slash, "slash") + QVTK_HANDLE(Qt::Key_F1, "F1") + QVTK_HANDLE(Qt::Key_F2, "F2") + QVTK_HANDLE(Qt::Key_F3, "F3") + QVTK_HANDLE(Qt::Key_F4, "F4") + QVTK_HANDLE(Qt::Key_F5, "F5") + QVTK_HANDLE(Qt::Key_F6, "F6") + QVTK_HANDLE(Qt::Key_F7, "F7") + QVTK_HANDLE(Qt::Key_F8, "F8") + QVTK_HANDLE(Qt::Key_F9, "F9") + QVTK_HANDLE(Qt::Key_F10, "F10") + QVTK_HANDLE(Qt::Key_F11, "F11") + QVTK_HANDLE(Qt::Key_F12, "F12") + QVTK_HANDLE(Qt::Key_F13, "F13") + QVTK_HANDLE(Qt::Key_F14, "F14") + QVTK_HANDLE(Qt::Key_F15, "F15") + QVTK_HANDLE(Qt::Key_F16, "F16") + QVTK_HANDLE(Qt::Key_F17, "F17") + QVTK_HANDLE(Qt::Key_F18, "F18") + QVTK_HANDLE(Qt::Key_F19, "F19") + QVTK_HANDLE(Qt::Key_F20, "F20") + QVTK_HANDLE(Qt::Key_F21, "F21") + QVTK_HANDLE(Qt::Key_F22, "F22") + QVTK_HANDLE(Qt::Key_F23, "F23") + QVTK_HANDLE(Qt::Key_F24, "F24") + QVTK_HANDLE(Qt::Key_NumLock, "Num_Lock") + QVTK_HANDLE(Qt::Key_ScrollLock, "Scroll_Lock") + + default: + break; + } + return ret; +} diff --git a/Modules/OpenViewCore/QVTKInteractorAdapter.h b/Modules/OpenViewCore/QVTKInteractorAdapter.h new file mode 100644 index 0000000000..0c0156f9a1 --- /dev/null +++ b/Modules/OpenViewCore/QVTKInteractorAdapter.h @@ -0,0 +1,68 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: QVTKInteractorAdapter.h + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ + +/*========================================================================= + + Copyright 2004 Sandia Corporation. + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +=========================================================================*/ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +// .NAME QVTKInteractorAdapter - Handle Qt events. +// .SECTION Description +// QVTKInteractor handles relaying Qt events to VTK. + +#ifndef Q_VTK_INTERACTOR_ADAPTER_H +#define Q_VTK_INTERACTOR_ADAPTER_H + +#include + +#include "OpenViewCoreExports.h" + +class vtkRenderWindowInteractor; +class QEvent; + +// .NAME QVTKInteractorAdapter - A QEvent translator. +// .SECTION Description +// QVTKInteractorAdapter translates QEvents and send them to a +// vtkRenderWindowInteractor. +class OVCORE_EXPORT QVTKInteractorAdapter : public QObject +{ + Q_OBJECT +public: + // Description: + // Constructor: takes QObject parent + QVTKInteractorAdapter(QObject* parent); + + // Description: + // Destructor + ~QVTKInteractorAdapter(); + + // Description: + // Process a QEvent and send it to the interactor + // returns whether the event was recognized and processed + bool ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren); +}; + +#endif diff --git a/Modules/OpenViewCore/QVTKInteractorInternal.h b/Modules/OpenViewCore/QVTKInteractorInternal.h new file mode 100644 index 0000000000..82b83cb7bd --- /dev/null +++ b/Modules/OpenViewCore/QVTKInteractorInternal.h @@ -0,0 +1,59 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: QVTKInteractor.h + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ + +/*========================================================================= + + Copyright 2004 Sandia Corporation. + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +=========================================================================*/ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +#ifndef Q_VTK_INTERACTOR_INTERNAL_H +#define Q_VTK_INTERACTOR_INTERNAL_H + +#include + +#include +class QVTKInteractor; +class QSignalMapper; +class QTimer; + +// internal class, do not use +class QVTKInteractorInternal : public QObject +{ + Q_OBJECT +public: + QVTKInteractorInternal(QVTKInteractor* p); + ~QVTKInteractorInternal(); +public Q_SLOTS: + void TimerEvent(int id); +public: + QSignalMapper* SignalMapper; + typedef std::map TimerMap; + TimerMap Timers; + QVTKInteractor* Parent; +}; + + +#endif diff --git a/Modules/OpenViewCore/QVTKQuickItem.cxx b/Modules/OpenViewCore/QVTKQuickItem.cxx new file mode 100644 index 0000000000..9f05230509 --- /dev/null +++ b/Modules/OpenViewCore/QVTKQuickItem.cxx @@ -0,0 +1,376 @@ +/*======================================================================== + OpenView -- http://openview.kitware.com + + Copyright 2012 Kitware, Inc. + + Licensed under the BSD license. See LICENSE file for details. + ========================================================================*/ +#include "QVTKQuickItem.h" + +#include +#include +#include +#include +#include +#include + +#include "QVTKInteractor.h" +#include "QVTKInteractorAdapter.h" +#include "vtkGenericOpenGLRenderWindow.h" +#include "vtkEventQtSlotConnect.h" +#include "vtkgl.h" +#include "vtkOpenGLExtensionManager.h" +#include "vtkRenderer.h" +#include "vtkRendererCollection.h" + +#include "vtkCubeSource.h" +#include "vtkPolyDataMapper.h" +#include "vtkProperty.h" + + +#include + +QVTKQuickItem::QVTKQuickItem(QQuickItem* parent) +:QQuickItem(parent) +,m_InitCalledOnce(false) +{ + setFlag(ItemHasContents); + setAcceptHoverEvents(true); + setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton); + + m_interactor = vtkSmartPointer::New(); + m_interactorAdapter = new QVTKInteractorAdapter(NULL); + m_interactorAdapter->moveToThread(this->thread()); + m_interactorAdapter->setParent(this); + m_connect = vtkSmartPointer::New(); + //m_connect->Connect(m_interactor, vtkCommand::RenderEvent, this, SLOT(paint())); + vtkSmartPointer win = vtkSmartPointer::New(); + this->SetRenderWindow(win); + this->geometryChanged(QRectF(x(), y(), width(), height()), QRectF(0, 0, 100, 100)); +} + +QVTKQuickItem::~QVTKQuickItem() +{ + this->SetRenderWindow(0); +} + +void QVTKQuickItem::SetRenderWindow(vtkGenericOpenGLRenderWindow* win) +{ + if(m_win) + { + m_win->SetMapped(0); + //m_connect->Disconnect(m_win, vtkCommand::StartEvent, this, SLOT(Start())); + //m_connect->Disconnect(m_win, vtkCommand::WindowMakeCurrentEvent, this, SLOT(MakeCurrent())); + //m_connect->Disconnect(m_win, vtkCommand::EndEvent, this, SLOT(End())); + //m_connect->Disconnect(m_win, vtkCommand::WindowFrameEvent, this, SLOT(Update())); + m_connect->Disconnect(m_win, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*))); + m_connect->Disconnect(m_win, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*))); + m_connect->Disconnect(m_win, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*))); + } + + m_interactor->SetRenderWindow(win); + m_win = win; + m_interactor->Initialize(); + + if(m_win) + { + m_win->SetMapped(1); + m_win->SetDoubleBuffer(0); + m_win->SetFrontBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); + m_win->SetFrontLeftBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); + m_win->SetBackBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); + m_win->SetBackLeftBuffer(vtkgl::COLOR_ATTACHMENT0_EXT); + + //m_connect->Connect(m_win, vtkCommand::StartEvent, this, SLOT(Start())); + //m_connect->Connect(m_win, vtkCommand::WindowMakeCurrentEvent, this, SLOT(MakeCurrent())); + //m_connect->Connect(m_win, vtkCommand::EndEvent, this, SLOT(End())); + //m_connect->Connect(m_win, vtkCommand::WindowFrameEvent, this, SLOT(Update())); + // Qt::DirectConnection in order to execute callback immediately. + // This avoids an error when vtkTexture attempts to query driver features and it is unable to determine "IsCurrent" + m_connect->Connect(m_win, vtkCommand::WindowIsCurrentEvent, this, SLOT(IsCurrent(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); + m_connect->Connect(m_win, vtkCommand::WindowIsDirectEvent, this, SLOT(IsDirect(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); + m_connect->Connect(m_win, vtkCommand::WindowSupportsOpenGLEvent, this, SLOT(SupportsOpenGL(vtkObject*, unsigned long, void*, void*)), NULL, 0.0, Qt::DirectConnection); + } +} + +vtkGenericOpenGLRenderWindow* QVTKQuickItem::GetRenderWindow() const +{ + return m_win; +} + +QVTKInteractor* QVTKQuickItem::GetInteractor() const +{ + return m_interactor; +} + +void QVTKQuickItem::itemChange(ItemChange change, const ItemChangeData &) +{ + // The ItemSceneChange event is sent when we are first attached to a canvas. + if (change == ItemSceneChange) { + QQuickWindow *c = window(); + if (!c) + { + return; + } + + // Connect our the beforeRendering signal to our paint function. + // Since this call is executed on the rendering thread it must be + // a Qt::DirectConnection + connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); + + // If we allow QML to do the clearing, they would clear what we paint + // and nothing would show. + c->setClearBeforeRendering(false); + } +} + +void QVTKQuickItem::MakeCurrent() +{ + if (!this->window()) + { + m_win->SetAbortRender(1); + cerr << "Could not make current since there is no canvas!" << endl; + return; + } + if (QThread::currentThread() != this->window()->openglContext()->thread()) + { + m_win->SetAbortRender(1); + cerr << "Could not make current since we are on the wrong thread!" << endl; + return; + } + this->window()->openglContext()->makeCurrent(this->window()); +} + +void QVTKQuickItem::Start() +{ + MakeCurrent(); + + if (!m_win->GetAbortRender()) + { + m_win->PushState(); + m_win->OpenGLInitState(); + } +} + +void QVTKQuickItem::End() +{ + if (!m_win->GetAbortRender()) + { + m_win->PopState(); + } + +} + +void QVTKQuickItem::IsCurrent(vtkObject*, unsigned long, void*, void* call_data) +{ + bool* ptr = reinterpret_cast(call_data); + *ptr = QOpenGLContext::currentContext() == this->window()->openglContext(); +} + +void QVTKQuickItem::IsDirect(vtkObject*, unsigned long, void*, void* call_data) +{ + int* ptr = reinterpret_cast(call_data); + *ptr = 1; +} + +void QVTKQuickItem::SupportsOpenGL(vtkObject*, unsigned long, void*, void* call_data) +{ + int* ptr = reinterpret_cast(call_data); + *ptr = true; + //*ptr = QGLFormat::hasOpenGL(); +} + +void QVTKQuickItem::geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry) +{ + QQuickItem::geometryChanged(newGeometry, oldGeometry); + QSize oldSize(oldGeometry.width(), oldGeometry.height()); + QSize newSize(newGeometry.width(), newGeometry.height()); + QResizeEvent e(newSize, oldSize); + if (m_interactorAdapter) + { + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(&e, m_interactor); + this->m_viewLock.unlock(); + } + if(m_win.GetPointer() && window()) + { + this->m_viewLock.lock(); + m_win->SetSize(window()->width(), window()->height()); + QPointF origin = mapToScene(QPointF(0, 0)); + QPointF minPt(origin.x()/window()->width(), (window()->height() - origin.y() - height())/window()->height()); + QPointF maxPt(minPt.x() + width()/window()->width(), minPt.y() + height()/window()->height()); + if (m_win->GetRenderers()->GetFirstRenderer()) + { + m_win->GetRenderers()->GetFirstRenderer()->SetViewport(minPt.x(), minPt.y(), maxPt.x(), maxPt.y()); + } + this->m_viewLock.unlock(); + update(); + } +} + +void QVTKQuickItem::keyPressEvent(QKeyEvent* e) +{ + e->accept(); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(e, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::keyReleaseEvent(QKeyEvent* e) +{ + e->accept(); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(e, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::mousePressEvent(QMouseEvent* e) +{ + e->accept(); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(e, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::mouseReleaseEvent(QMouseEvent* e) +{ + e->accept(); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(e, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::mouseDoubleClickEvent(QMouseEvent* e) +{ + e->accept(); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(e, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::mouseMoveEvent(QMouseEvent* e) +{ + e->accept(); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(e, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::wheelEvent(QWheelEvent* e) +{ + e->accept(); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(e, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::hoverEnterEvent(QHoverEvent* e) +{ + e->accept(); + QEvent e2(QEvent::Enter); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(&e2, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::hoverLeaveEvent(QHoverEvent* e) +{ + e->accept(); + QEvent e2(QEvent::Leave); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(&e2, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::hoverMoveEvent(QHoverEvent* e) +{ + e->accept(); + QMouseEvent e2(QEvent::MouseMove, e->pos(), Qt::NoButton, Qt::NoButton, e->modifiers()); + this->m_viewLock.lock(); + m_interactorAdapter->ProcessEvent(&e2, m_interactor); + this->m_viewLock.unlock(); + update(); +} + +void QVTKQuickItem::init() +{ +} + +void QVTKQuickItem::prepareForRender() +{ +} + +void QVTKQuickItem::cleanupAfterRender() +{ +} + +QSGNode* QVTKQuickItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) +{ + QSGSimpleRectNode *n = static_cast(oldNode); + if (!n) { + n = new QSGSimpleRectNode(); + } + n->markDirty(QSGNode::DirtyForceUpdate); + return n; +} + + +void QVTKQuickItem::paint() +{ + if (!this->isVisible()) + { + return; + } + + if (!this->m_InitCalledOnce) + { + m_win->GetExtensionManager()->LoadExtension("GL_VERSION_1_4"); + m_win->GetExtensionManager()->LoadExtension("GL_VERSION_2_0"); + + init(); + + this->m_InitCalledOnce = true; + } + + this->m_viewLock.lock(); + + // Let subclasses do something each render + prepareForRender(); + + // Make sure viewport is up to date. + // This is needed because geometryChanged() is not called when parent geometry changes, so we miss when widths/heights + // of surrounding elements change. + m_win->SetSize(window()->width(), window()->height()); + QPointF origin = mapToScene(QPointF(0, 0)); + QPointF minPt(origin.x()/window()->width(), (window()->height() - origin.y() - height())/window()->height()); + QPointF maxPt(minPt.x() + width()/window()->width(), minPt.y() + height()/window()->height()); + if (m_win->GetRenderers()->GetFirstRenderer()) + { + m_win->GetRenderers()->GetFirstRenderer()->SetViewport(minPt.x(), minPt.y(), maxPt.x(), maxPt.y()); + } + + // Turn off any QML shader program + vtkgl::UseProgram(0); + + // Set blending correctly + glEnable(GL_BLEND); + vtkgl::BlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + m_win->Render(); + + // Disable alpha test for QML + glDisable(GL_ALPHA_TEST); + + cleanupAfterRender(); + + this->m_viewLock.unlock(); +} diff --git a/Modules/OpenViewCore/QVTKQuickItem.h b/Modules/OpenViewCore/QVTKQuickItem.h new file mode 100644 index 0000000000..f080b3d0db --- /dev/null +++ b/Modules/OpenViewCore/QVTKQuickItem.h @@ -0,0 +1,108 @@ +/*======================================================================== + OpenView -- http://openview.kitware.com + + Copyright 2012 Kitware, Inc. + + Licensed under the BSD license. See LICENSE file for details. + ========================================================================*/ +#ifndef QVTKQuickItem_h +#define QVTKQuickItem_h + +#include + +#include + +#include "vtkSmartPointer.h" +#include "vtkNew.h" + +#include + +#include "OpenViewCoreExports.h" + +class QOpenGLContext; +class QOpenGLFramebufferObject; +class QVTKInteractorAdapter; +class QVTKInteractor; +class vtkEventQtSlotConnect; +class vtkGenericOpenGLRenderWindow; +class vtkObject; +class vtkContextView; + +class OVCORE_EXPORT QVTKQuickItem : public QQuickItem +{ + Q_OBJECT +public: + QVTKQuickItem(QQuickItem* parent = 0); + + // Description: + // destructor + ~QVTKQuickItem(); + + void itemChange(ItemChange change, const ItemChangeData &); + + // Description: + // set the render window to use with this item + void SetRenderWindow(vtkGenericOpenGLRenderWindow* win); + + // Description: + // get the render window used with this item + vtkGenericOpenGLRenderWindow* GetRenderWindow() const; + + // Description: + // get the render window interactor used with this item + // this item enforces its own interactor + QVTKInteractor* GetInteractor() const; + +public slots: + virtual void paint(); + +protected slots: + // slot to make this vtk render window current + virtual void MakeCurrent(); + // slot called when vtk render window starts to draw + virtual void Start(); + // slot called when vtk render window is done drawing + virtual void End(); + // slot called when vtk wants to know if the context is current + virtual void IsCurrent(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data); + // slot called when vtk wants to know if a window is direct + virtual void IsDirect(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data); + // slot called when vtk wants to know if a window supports OpenGL + virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data); + +protected: + + virtual void init(); + virtual void prepareForRender(); + virtual void cleanupAfterRender(); + + // handle item key events + virtual void keyPressEvent(QKeyEvent* e); + virtual void keyReleaseEvent(QKeyEvent* e); + + // handle item mouse events + virtual void mousePressEvent(QMouseEvent* e); + virtual void mouseReleaseEvent(QMouseEvent* e); + virtual void mouseDoubleClickEvent(QMouseEvent* e); + virtual void mouseMoveEvent(QMouseEvent* e); + virtual void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry); + virtual void wheelEvent(QWheelEvent* e); + virtual void hoverEnterEvent(QHoverEvent* e); + virtual void hoverLeaveEvent(QHoverEvent* e); + virtual void hoverMoveEvent(QHoverEvent* e); + + virtual QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updatePaintNodeData); + + QMutex m_viewLock; + +private: + QOpenGLContext* m_context; + vtkSmartPointer m_win; + vtkSmartPointer m_interactor; + QVTKInteractorAdapter* m_interactorAdapter; + vtkSmartPointer m_connect; + + bool m_InitCalledOnce; +}; + +#endif diff --git a/Modules/OpenViewCore/README b/Modules/OpenViewCore/README new file mode 100644 index 0000000000..ff10a2aeb4 --- /dev/null +++ b/Modules/OpenViewCore/README @@ -0,0 +1,15 @@ +This code is a snapshot of the OpenView project at openview.kitware.org + +Code was + - originally taken from + https://github.com/Kitware/openview/tree/74fdaf2ac84b79d56a4ca6e370e55e7fe339a10b/core + - minor modifications were made to the QVTKQuickItem class in order to fix issues and integrate it easier with MITK + https://github.com/maleike/openview/tree/1296a52f4aa3227526bb467671aaacb54a6931fc/core + - a pull request has been filed to contribute code back + +In this MITK snapshot, only the "core" of Openview is built as an MITK module + + - the CMakeLists.txt has been replaced by a minimum MITK module definition + - some #include statements have been changed to + #include "OpenViewExports.h" + which is generated by the MITK module system diff --git a/Modules/OpenViewCore/files.cmake b/Modules/OpenViewCore/files.cmake new file mode 100644 index 0000000000..a3a5951b8a --- /dev/null +++ b/Modules/OpenViewCore/files.cmake @@ -0,0 +1,20 @@ +set(CPP_FILES + vtkEventQtSlotConnect.cxx + QVTKInteractor.cxx + QVTKInteractorAdapter.cxx + QVTKQuickItem.cxx + vtkQtConnection.cxx +) + +set(MOC_H_FILES + QVTKInteractorAdapter.h + QVTKInteractorInternal.h + QVTKQuickItem.h + vtkQtConnection.h +) + +set(UI_FILES +) + +set(QRC_FILES +) diff --git a/Modules/OpenViewCore/original.CMakeLists.txt b/Modules/OpenViewCore/original.CMakeLists.txt new file mode 100644 index 0000000000..8879f93fe7 --- /dev/null +++ b/Modules/OpenViewCore/original.CMakeLists.txt @@ -0,0 +1,48 @@ +qt5_wrap_cpp( ovCore_moc_files + QVTKInteractorAdapter.h + QVTKInteractorInternal.h + QVTKQuickItem.h + vtkQtConnection.h ) + +set( ovCore_srcs + vtkEventQtSlotConnect.cxx + QVTKInteractor.cxx + QVTKInteractorAdapter.cxx + QVTKQuickItem.cxx + vtkQtConnection.cxx + ${ovCore_moc_files} ) + +set( ovCore_libs + vtkRenderingFreeTypeOpenGL + vtkRenderingVolumeOpenGL + vtkInteractionStyle + ${Qt5Widgets_LIBRARIES} + ${Qt5Quick_LIBRARIES} ) + +add_library(ovCore SHARED ${ovCore_srcs}) +target_link_libraries(ovCore ${ovCore_libs}) + +# Generate export header. +generate_export_header("ovCore" EXPORT_FILE_NAME "ovCoreModule.h") + +if(APPLE) + install(TARGETS ovCore LIBRARY DESTINATION "OpenView.app/Contents/Libraries") + install(CODE "execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -id @executable_path/../Libraries/libovCore.dylib ${CMAKE_INSTALL_PREFIX}/OpenView.app/Contents/Libraries/libovCore.dylib)") + + # An odd requirement: since CMake decides to do some install_name_tool + # stuff automatically, it already changed the full path of libovCore.dylib + # to simply the library file with no path. So here we need to change + # that change to instead be relative to @executable_path. If CMake did + # "help" us like that, we would expect to use the following line: + # + # set(install_name_changes "${install_name_changes} -change ${CMAKE_CURRENT_BINARY_DIR}/libovCore.dylib @executable_path/../Libraries/libovCore.dylib" PARENT_SCOPE) + set(install_name_changes "${install_name_changes} -change libovCore.dylib @executable_path/../Libraries/libovCore.dylib" PARENT_SCOPE) + + list(APPEND libs_and_execs "${CMAKE_INSTALL_PREFIX}/OpenView.app/Contents/Libraries/libovCore.dylib") + set(libs_and_execs ${libs_and_execs} PARENT_SCOPE) +else() + install(TARGETS ovCore + RUNTIME DESTINATION "bin" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib") +endif() diff --git a/Modules/OpenViewCore/vtkEventQtSlotConnect.cxx b/Modules/OpenViewCore/vtkEventQtSlotConnect.cxx new file mode 100644 index 0000000000..411f701cd5 --- /dev/null +++ b/Modules/OpenViewCore/vtkEventQtSlotConnect.cxx @@ -0,0 +1,149 @@ +/*========================================================================= + + Copyright 2004 Sandia Corporation. + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +=========================================================================*/ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +/*======================================================================== + !!! WARNING for those who want to contribute code to this file. + !!! If you use a commercial edition of Qt, you can modify this code. + !!! If you use an open source version of Qt, you are free to modify + !!! and use this code within the guidelines of the GPL license. + !!! Unfortunately, you cannot contribute the changes back into this + !!! file. Doing so creates a conflict between the GPL and BSD-like VTK + !!! license. +=========================================================================*/ + +#include "vtkEventQtSlotConnect.h" +#include "vtkObjectFactory.h" +#include "vtkCallbackCommand.h" +#include "vtkQtConnection.h" + +#include + +#include + +// hold all the connections +class vtkQtConnections : public std::vector< vtkQtConnection* > {}; + +vtkStandardNewMacro(vtkEventQtSlotConnect) + +// constructor +vtkEventQtSlotConnect::vtkEventQtSlotConnect() +{ + Connections = new vtkQtConnections; +} + + +vtkEventQtSlotConnect::~vtkEventQtSlotConnect() +{ + // clean out connections + vtkQtConnections::iterator iter; + for(iter=Connections->begin(); iter!=Connections->end(); ++iter) + { + delete (*iter); + } + + delete Connections; +} + +void vtkEventQtSlotConnect::Connect( + vtkObject* vtk_obj, unsigned long event, + const QObject* qt_obj, const char* slot, + void* client_data, float priority + , Qt::ConnectionType type) +{ + if (!vtk_obj || !qt_obj) + { + vtkErrorMacro("Cannot connect NULL objects."); + return; + } + vtkQtConnection* connection = new vtkQtConnection(this); + connection->SetConnection( + vtk_obj, event, qt_obj, slot, client_data, priority + , type); + Connections->push_back(connection); +} + + +void vtkEventQtSlotConnect::Disconnect(vtkObject* vtk_obj, unsigned long event, + const QObject* qt_obj, const char* slot, void* client_data) +{ + if (!vtk_obj) + { + vtkQtConnections::iterator iter; + for(iter=this->Connections->begin(); iter!=this->Connections->end(); ++iter) + { + delete (*iter); + } + this->Connections->clear(); + return; + } + bool all_info = true; + if(slot == NULL || qt_obj == NULL || event == vtkCommand::NoEvent) + all_info = false; + + vtkQtConnections::iterator iter; + for(iter=Connections->begin(); iter!=Connections->end();) + { + // if information matches, remove the connection + if((*iter)->IsConnection(vtk_obj, event, qt_obj, slot, client_data)) + { + delete (*iter); + iter = Connections->erase(iter); + // if user passed in all information, only remove one connection and quit + if(all_info) + iter = Connections->end(); + } + else + ++iter; + } +} + +void vtkEventQtSlotConnect::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); + if(Connections->empty()) + { + os << indent << "No Connections\n"; + } + else + { + os << indent << "Connections:\n"; + vtkQtConnections::iterator iter; + for(iter=Connections->begin(); iter!=Connections->end(); ++iter) + { + (*iter)->PrintSelf(os, indent.GetNextIndent()); + } + } +} + +void vtkEventQtSlotConnect::RemoveConnection(vtkQtConnection* conn) +{ + vtkQtConnections::iterator iter; + for(iter=this->Connections->begin(); iter!=this->Connections->end(); ++iter) + { + if(conn == *iter) + { + delete (*iter); + Connections->erase(iter); + return; + } + } +} + +int vtkEventQtSlotConnect::GetNumberOfConnections() const +{ + return static_cast(this->Connections->size()); +} + diff --git a/Modules/OpenViewCore/vtkEventQtSlotConnect.h b/Modules/OpenViewCore/vtkEventQtSlotConnect.h new file mode 100644 index 0000000000..f283964978 --- /dev/null +++ b/Modules/OpenViewCore/vtkEventQtSlotConnect.h @@ -0,0 +1,103 @@ +/*========================================================================= + + Copyright 2004 Sandia Corporation. + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +=========================================================================*/ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +/*======================================================================== + !!! WARNING for those who want to contribute code to this file. + !!! If you use a commercial edition of Qt, you can modify this code. + !!! If you use an open source version of Qt, you are free to modify + !!! and use this code within the guidelines of the GPL license. + !!! Unfortunately, you cannot contribute the changes back into this + !!! file. Doing so creates a conflict between the GPL and BSD-like VTK + !!! license. +=========================================================================*/ + +// .NAME vtkEventQtSlotConnect - Manage connections between VTK events and Qt slots. +// .SECTION Description +// vtkEventQtSlotConnect provides a way to manage connections between VTK events +// and Qt slots. +// Qt slots to connect with must have one of the following signatures: +// - MySlot() +// - MySlot(vtkObject* caller) +// - MySlot(vtkObject* caller, unsigned long vtk_event) +// - MySlot(vtkObject* caller, unsigned long vtk_event, void* client_data) +// - MySlot(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data) +// - MySlot(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data, vtkCommand*) + + +#ifndef VTK_EVENT_QT_SLOT_CONNECT +#define VTK_EVENT_QT_SLOT_CONNECT + +#include "vtkObject.h" +#include "vtkCommand.h" // for event defines +#include // for version info + +#include "OpenViewCoreExports.h" + +class QObject; +class vtkQtConnections; +class vtkQtConnection; + +// manage connections between VTK object events and Qt slots +class OVCORE_EXPORT vtkEventQtSlotConnect : public vtkObject +{ + public: + static vtkEventQtSlotConnect* New(); + vtkTypeMacro(vtkEventQtSlotConnect, vtkObject) + + // Description: + // Print the current connections between VTK and Qt + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Connect a vtk object's event with a Qt object's slot. Multiple + // connections which are identical are treated as separate connections. + virtual void Connect(vtkObject* vtk_obj, unsigned long event, + const QObject* qt_obj, const char* slot, + void* client_data=NULL, float priority=0.0 + ,Qt::ConnectionType type = Qt::AutoConnection); + + // Description: + // Disconnect a vtk object from a qt object. + // Passing no arguments will disconnect all slots maintained by this object. + // Passing in only a vtk object will disconnect all slots from it. + // Passing only a vtk object and event, will disconnect all slots matching + // the vtk object and event. + // Passing all information in will match all information. + virtual void Disconnect( + vtkObject* vtk_obj=NULL, unsigned long event=vtkCommand::NoEvent, + const QObject* qt_obj=NULL, const char* slot = 0, void* client_data=NULL); + + // Description: + // Allow to query vtkEventQtSlotConnect to know if some Connect() have been + // setup and how many. + virtual int GetNumberOfConnections() const; + + protected: + vtkQtConnections* Connections; + friend class vtkQtConnection; + void RemoveConnection(vtkQtConnection*); + + vtkEventQtSlotConnect(); + ~vtkEventQtSlotConnect(); + + private: + // unimplemented + vtkEventQtSlotConnect(const vtkEventQtSlotConnect&); + void operator=(const vtkEventQtSlotConnect&); +}; + +#endif + diff --git a/Modules/OpenViewCore/vtkQtConnection.cxx b/Modules/OpenViewCore/vtkQtConnection.cxx new file mode 100644 index 0000000000..069c19b6fd --- /dev/null +++ b/Modules/OpenViewCore/vtkQtConnection.cxx @@ -0,0 +1,151 @@ +/*========================================================================= + + Copyright 2004 Sandia Corporation. + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +=========================================================================*/ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +/*======================================================================== + !!! WARNING for those who want to contribute code to this file. + !!! If you use a commercial edition of Qt, you can modify this code. + !!! If you use an open source version of Qt, you are free to modify + !!! and use this code within the guidelines of the GPL license. + !!! Unfortunately, you cannot contribute the changes back into this + !!! file. Doing so creates a conflict between the GPL and BSD-like VTK + !!! license. +=========================================================================*/ + +#include "vtkQtConnection.h" +#include "vtkEventQtSlotConnect.h" +#include "vtkCallbackCommand.h" + +#include +#include + +// constructor +vtkQtConnection::vtkQtConnection(vtkEventQtSlotConnect* owner) + : Owner(owner) +{ + this->Callback = vtkCallbackCommand::New(); + this->Callback->SetCallback(vtkQtConnection::DoCallback); + this->Callback->SetClientData(this); + this->VTKObject = 0; + this->QtObject = 0; + this->ClientData = 0; + this->VTKEvent = vtkCommand::NoEvent; +} + +// destructor, disconnect if necessary +vtkQtConnection::~vtkQtConnection() +{ + if(this->VTKObject) + { + this->VTKObject->RemoveObserver(this->Callback); + //Qt takes care of disconnecting slots + } + this->Callback->Delete(); +} + +void vtkQtConnection::DoCallback(vtkObject* vtk_obj, unsigned long event, + void* client_data, void* call_data) +{ + vtkQtConnection* conn = static_cast(client_data); + conn->Execute(vtk_obj, event, call_data); +} + + +// callback from VTK to emit signal +void vtkQtConnection::Execute(vtkObject* caller, unsigned long e, void* call_data) +{ + if(e != vtkCommand::DeleteEvent || + (e == vtkCommand::DeleteEvent && this->VTKEvent == vtkCommand::DeleteEvent)) + { + emit EmitExecute(caller, e, ClientData, call_data, this->Callback); + } + + if(e == vtkCommand::DeleteEvent) + { + this->Owner->Disconnect(this->VTKObject, this->VTKEvent, this->QtObject, + this->QtSlot.toUtf8().data(), + this->ClientData); + } +} + +bool vtkQtConnection::IsConnection(vtkObject* vtk_obj, unsigned long e, + const QObject* qt_obj, const char* slot, void* client_data) +{ + if(this->VTKObject != vtk_obj) + return false; + + if(e != vtkCommand::NoEvent && e != this->VTKEvent) + return false; + + if(qt_obj && qt_obj != this->QtObject) + return false; + + if(slot && this->QtSlot != slot) + return false; + + if(client_data && this->ClientData != client_data) + return false; + + return true; +} + +// set the connection +void vtkQtConnection::SetConnection( + vtkObject* vtk_obj, unsigned long e, + const QObject* qt_obj, const char* slot, + void* client_data, float priority + , Qt::ConnectionType type) +{ + // keep track of what we connected + this->VTKObject = vtk_obj; + this->QtObject = qt_obj; + this->VTKEvent = e; + this->ClientData = client_data; + this->QtSlot = slot; + + // make a connection between this and the vtk object + vtk_obj->AddObserver(e, this->Callback, priority); + + if(e != vtkCommand::DeleteEvent) + { + vtk_obj->AddObserver(vtkCommand::DeleteEvent, this->Callback); + } + + // make a connection between this and the Qt object + qt_obj->connect( + this, SIGNAL(EmitExecute(vtkObject*,unsigned long,void*,void*,vtkCommand*)), + slot + ,type); + QObject::connect(qt_obj, SIGNAL(destroyed(QObject*)), this, + SLOT(deleteConnection())); +} + +void vtkQtConnection::deleteConnection() +{ + this->Owner->RemoveConnection(this); +} + +void vtkQtConnection::PrintSelf(ostream& os, vtkIndent indent) +{ + if(this->VTKObject && this->QtObject) + { + os << indent << + this->VTKObject->GetClassName() << ":" << + vtkCommand::GetStringFromEventId(this->VTKEvent) << " <----> " << + this->QtObject->metaObject()->className() << "::" << + this->QtSlot.toUtf8().data() << "\n"; + } +} + diff --git a/Modules/OpenViewCore/vtkQtConnection.h b/Modules/OpenViewCore/vtkQtConnection.h new file mode 100644 index 0000000000..3b72568878 --- /dev/null +++ b/Modules/OpenViewCore/vtkQtConnection.h @@ -0,0 +1,104 @@ +/*========================================================================= + + Copyright 2004 Sandia Corporation. + Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive + license for use of this work by or on behalf of the + U.S. Government. Redistribution and use in source and binary forms, with + or without modification, are permitted provided that this Notice and any + statement of authorship are reproduced on all copies. + +=========================================================================*/ + +/*======================================================================== + For general information about using VTK and Qt, see: + http://www.trolltech.com/products/3rdparty/vtksupport.html +=========================================================================*/ + +/*======================================================================== + !!! WARNING for those who want to contribute code to this file. + !!! If you use a commercial edition of Qt, you can modify this code. + !!! If you use an open source version of Qt, you are free to modify + !!! and use this code within the guidelines of the GPL license. + !!! Unfortunately, you cannot contribute the changes back into this + !!! file. Doing so creates a conflict between the GPL and BSD-like VTK + !!! license. +=========================================================================*/ + +// .SECTION Description +// vtkQtConnection is an internal class. + + +#ifndef VTK_QT_CONNECTION +#define VTK_QT_CONNECTION + +#include "vtkObject.h" +#include "vtkCommand.h" // for event defines +#include "qobject.h" + +#include "OpenViewCoreExports.h" + +class QObject; +class vtkCallbackCommand; +class vtkEventQtSlotConnect; + +// class for managing a single VTK/Qt connection +// not to be included in other projects +// only here for moc to process for vtkEventQtSlotConnect +class OVCORE_EXPORT vtkQtConnection : public QObject +{ + Q_OBJECT + + public: + + // constructor + vtkQtConnection(vtkEventQtSlotConnect* owner); + + // destructor, disconnect if necessary + ~vtkQtConnection(); + + // print function + void PrintSelf(ostream& os, vtkIndent indent); + + // callback from VTK to emit signal + void Execute(vtkObject* caller, unsigned long event, void* client_data); + + // set the connection + void SetConnection(vtkObject* vtk_obj, unsigned long event, + const QObject* qt_obj, const char* slot, + void* client_data, float priority=0.0 + ,Qt::ConnectionType type = Qt::AutoConnection); + + // check if a connection matches input parameters + bool IsConnection(vtkObject* vtk_obj, unsigned long event, + const QObject* qt_obj, const char* slot, + void* client_data); + + static void DoCallback(vtkObject* vtk_obj, unsigned long event, + void* client_data, void* call_data); + + signals: + // the qt signal for moc to take care of + void EmitExecute(vtkObject*, unsigned long, void* client_data, void* call_data, vtkCommand*); + + protected slots: + void deleteConnection(); + + protected: + + // the connection information + vtkObject* VTKObject; + vtkCallbackCommand* Callback; + const QObject* QtObject; + void* ClientData; + unsigned long VTKEvent; + QString QtSlot; + vtkEventQtSlotConnect* Owner; + + private: + vtkQtConnection(const vtkQtConnection&); + void operator=(const vtkQtConnection&); + +}; + +#endif + diff --git a/Modules/Overlays/CMakeLists.txt b/Modules/Overlays/CMakeLists.txt index 51fb3c19b7..a3f96543e5 100644 --- a/Modules/Overlays/CMakeLists.txt +++ b/Modules/Overlays/CMakeLists.txt @@ -1,5 +1,4 @@ MITK_CREATE_MODULE( Overlays DEPENDS Qmitk - PACKAGE_DEPENDS QT - QT_MODULE + QT4_MODULES QtGui ) diff --git a/Modules/Python/CMakeLists.txt b/Modules/Python/CMakeLists.txt index a91f85c914..3d688152b6 100644 --- a/Modules/Python/CMakeLists.txt +++ b/Modules/Python/CMakeLists.txt @@ -1,13 +1,13 @@ if( MITK_USE_Python ) MITK_CREATE_MODULE(mitkPython DEPENDS Mitk EXPORT_DEFINE MITK_PYTHON_EXPORT - PACKAGE_DEPENDS QT CTK PythonLibs + PACKAGE_DEPENDS Qt4 CTK PythonLibs QT_MODULE ) configure_file(PythonPath.h.in "${CMAKE_CURRENT_BINARY_DIR}/PythonPath.h" @ONLY) add_subdirectory(Testing) endif() diff --git a/Modules/Qmitk/CMakeLists.txt b/Modules/Qmitk/CMakeLists.txt index d7252919af..3a2b57ed34 100644 --- a/Modules/Qmitk/CMakeLists.txt +++ b/Modules/Qmitk/CMakeLists.txt @@ -1,9 +1,8 @@ MITK_CREATE_MODULE( Qmitk DEPENDS Mitk PlanarFigure - PACKAGE_DEPENDS QT QVTK + QT4_MODULES QtCore QtGui SUBPROJECTS MITK-CoreUI EXPORT_DEFINE QMITK_EXPORT - QT_MODULE ) add_subdirectory(Testing) diff --git a/Modules/QmitkExt/CMakeLists.txt b/Modules/QmitkExt/CMakeLists.txt index d589b5be93..d06c076bfe 100644 --- a/Modules/QmitkExt/CMakeLists.txt +++ b/Modules/QmitkExt/CMakeLists.txt @@ -1,9 +1,8 @@ include_directories(${CTK_INCLUDE_DIRS}) MITK_CREATE_MODULE( QmitkExt INCLUDE_DIRS QmitkApplicationBase QmitkPropertyObservers QmitkFunctionalityComponents DEPENDS MitkAlgorithmsExt Qmitk PACKAGE_DEPENDS Qwt Qxt - QT_MODULE + QT4_MODULES QtCore QtGui ) - diff --git a/Modules/QmlMitk/CMakeLists.txt b/Modules/QmlMitk/CMakeLists.txt new file mode 100644 index 0000000000..3ee6fc3523 --- /dev/null +++ b/Modules/QmlMitk/CMakeLists.txt @@ -0,0 +1,5 @@ +MITK_CREATE_MODULE(QmlMitk + INCLUDE_DIRS InteractionLegacy + DEPENDS Mitk OpenViewCore + QT5_MODULES Qt5Quick +) diff --git a/Modules/QmlMitk/InteractionLegacy/QmitkEventAdapter.cpp b/Modules/QmlMitk/InteractionLegacy/QmitkEventAdapter.cpp new file mode 100644 index 0000000000..5eceb06a78 --- /dev/null +++ b/Modules/QmlMitk/InteractionLegacy/QmitkEventAdapter.cpp @@ -0,0 +1,124 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "QmitkEventAdapter.h" +#include +#include + +#include +#include + +mitk::MouseEvent +QmitkEventAdapter::AdaptMouseEvent(mitk::BaseRenderer* sender, QMouseEvent* mouseEvent) +{ + mitk::Point2D p; + p[0] = mouseEvent->x(); + p[1] = mouseEvent->y(); + + int modifiers = mouseEvent->modifiers(); + int state = 0; + + switch (mouseEvent->type()) + { + case QEvent::MouseButtonRelease: + state |= mouseEvent->button(); + break; + case QEvent::MouseMove: + state |= mouseEvent->buttons(); + break; + default: + break; + } + + if (modifiers & Qt::ShiftModifier) + state |= mitk::BS_ShiftButton; + if (modifiers & Qt::ControlModifier) + state |= mitk::BS_ControlButton; + if (modifiers & Qt::AltModifier) + state |= mitk::BS_AltButton; + if (modifiers & Qt::MetaModifier) + state |= mitk::BS_MetaButton; + if (modifiers & Qt::KeypadModifier) + state |= mitk::BS_Keypad; + + mitk::MouseEvent mitkEvent(sender, mouseEvent->type(), mouseEvent->button(), + state, mitk::Key_none, p); + + return mitkEvent; +} + +mitk::WheelEvent +QmitkEventAdapter::AdaptWheelEvent(mitk::BaseRenderer* sender, QWheelEvent* wheelEvent) +{ + mitk::Point2D p; + p[0] = wheelEvent->x(); + p[1] = wheelEvent->y(); + + int modifiers = wheelEvent->modifiers(); + int state = 0; + + state = wheelEvent->buttons(); + + if (modifiers & Qt::ShiftModifier) + state |= mitk::BS_ShiftButton; + if (modifiers & Qt::ControlModifier) + state |= mitk::BS_ControlButton; + if (modifiers & Qt::AltModifier) + state |= mitk::BS_AltButton; + if (modifiers & Qt::MetaModifier) + state |= mitk::BS_MetaButton; + if (modifiers & Qt::KeypadModifier) + state |= mitk::BS_Keypad; + + mitk::WheelEvent mitkEvent(sender, wheelEvent->type(), wheelEvent->buttons(), + state, mitk::Key_none, p, wheelEvent->delta()); + + return mitkEvent; +} + + +mitk::KeyEvent +QmitkEventAdapter::AdaptKeyEvent(mitk::BaseRenderer* sender, QKeyEvent* keyEvent, const QPoint& cp) +{ + int key = keyEvent->key(); + + // Those keycodes changed in Qt 4 + if (key >= 0x01000000 && key <= 0x01000060) + key -= (0x01000000 - 0x1000); + else if(key >= 0x01001120 && key <= 0x01001262) + key -= 0x01000000; + + mitk::Point2D p; + p[0] = cp.x(); + p[1] = cp.y(); + + int modifiers = keyEvent->modifiers(); + int state = 0; + if (modifiers & Qt::ShiftModifier) + state |= mitk::BS_ShiftButton; + if (modifiers & Qt::ControlModifier) + state |= mitk::BS_ControlButton; + if (modifiers & Qt::AltModifier) + state |= mitk::BS_AltButton; + if (modifiers & Qt::MetaModifier) + state |= mitk::BS_MetaButton; + //if (modifiers & Qt::KeypadModifier) + // state |= mitk::BS_Keypad; + + mitk::KeyEvent mke(sender, keyEvent->type(), mitk::BS_NoButton, state, key, keyEvent->text().toStdString(), p); + + return mke; +} diff --git a/Modules/QmlMitk/InteractionLegacy/QmitkEventAdapter.h b/Modules/QmlMitk/InteractionLegacy/QmitkEventAdapter.h new file mode 100644 index 0000000000..ac9c63362f --- /dev/null +++ b/Modules/QmlMitk/InteractionLegacy/QmitkEventAdapter.h @@ -0,0 +1,44 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef QMITKEVENTADAPTER_H_ +#define QMITKEVENTADAPTER_H_ + +#include + +#include +#include +#include +#include +#include + +/** + * \ingroup QmitkModule + * \deprecatedSince{2013_03} mitk::QmitkEventAdapter is deprecated. It will become + * obsolete. Adaption of events is now handeled (for Qt events) in QmitkRenderWindow. + * Refer to \see DataInteractionPage for general information about the concept of + * the new implementation + */ +class QmlMitk_EXPORT QmitkEventAdapter +{ +public: + + static mitk::MouseEvent AdaptMouseEvent(mitk::BaseRenderer* sender, QMouseEvent* mouseEvent); + static mitk::WheelEvent AdaptWheelEvent(mitk::BaseRenderer* sender, QWheelEvent* wheelEvent); + static mitk::KeyEvent AdaptKeyEvent(mitk::BaseRenderer* sender, QKeyEvent* keyEvent, const QPoint& point); +}; + +#endif /*QMITKEVENTADAPTER_H_*/ diff --git a/Modules/QmlMitk/QmlMitkBigRenderLock.cpp b/Modules/QmlMitk/QmlMitkBigRenderLock.cpp new file mode 100644 index 0000000000..0db66d7efd --- /dev/null +++ b/Modules/QmlMitk/QmlMitkBigRenderLock.cpp @@ -0,0 +1,48 @@ +#include "QmlMitkBigRenderLock.h" + +#include "QVTKQuickItem.h" + +QMutex& QmlMitkBigRenderLock::GetMutex() +{ + static QMutex globalRenderingLock; + return globalRenderingLock; +} + +QmlMitkBigRenderLock::QmlMitkBigRenderLock(QObject* parent) +:QObject(parent) +{ +} + +bool QmlMitkBigRenderLock::eventFilter(QObject* /*obj*/, QEvent* /*event*/) +{ + /* + TODO + + this should BLOCK during rendering, i.e. + + it should acquire a mutex lock which is also acquired by the rendering method in QVTKQuickItem + + TODO: + + THIS MUST BE CHANGED! + + It is NOT sufficient to delay signal delivery, BUT we must block rendering until the signal is completely processed. + TODO: what would happen if a signal receiver calls rendering->ForceImmediateUpdateAll ? + + + + */ + + if ( GetMutex().tryLock() ) + { + // ok, let's continue + } + else + { + GetMutex().lock(); + } + + GetMutex().unlock(); + + return false; // don't actually filter/remove events +} diff --git a/Modules/QmlMitk/QmlMitkBigRenderLock.h b/Modules/QmlMitk/QmlMitkBigRenderLock.h new file mode 100644 index 0000000000..3a4bd52aaa --- /dev/null +++ b/Modules/QmlMitk/QmlMitkBigRenderLock.h @@ -0,0 +1,33 @@ +#ifndef QmlMitkBigRenderLock_h +#define QmlMitkBigRenderLock_h + +#include + +#include "QmlMitkExports.h" + +/** + \brief Workaround lock around MITK rendering. + + QtQuick renders in a thread, MITK datastructures do not + tolerate this well. The current work-around is a big + lock that delays signal delivery while rendering is in + progress. + + The proper solution would be to make data structures + in rendering thread safe. This solution is much more + work though, so it will come later. +*/ +class QmlMitk_EXPORT QmlMitkBigRenderLock : public QObject +{ + Q_OBJECT + public: + + static QMutex& GetMutex(); + + QmlMitkBigRenderLock(QObject* parent = 0); + + protected: + bool eventFilter(QObject *obj, QEvent *event); +}; + +#endif diff --git a/Modules/QmlMitk/QmlMitkFourRenderWindowWidget.cpp b/Modules/QmlMitk/QmlMitkFourRenderWindowWidget.cpp new file mode 100644 index 0000000000..c7089fb80d --- /dev/null +++ b/Modules/QmlMitk/QmlMitkFourRenderWindowWidget.cpp @@ -0,0 +1,102 @@ + +#include "QmlMitkFourRenderWindowWidget.h" + +#include "mitkDisplayInteractor.h" + +#include "usGetModuleContext.h" + +#include + +#include + +QmlMitkFourRenderWindowWidget::QmlMitkFourRenderWindowWidget(QQuickItem* parent) +: QQuickItem(parent) +, m_ChildrenContainer(NULL) +, m_RenderItemAxial(NULL) +, m_RenderItemSagittal(NULL) +, m_RenderItemFrontal(NULL) +, m_RenderItem3D(NULL) +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:///MITK/Modules/QmlMitk/QmlMitkFourRenderWindowWidget.qml")); + m_ChildrenContainer = qobject_cast( component.create() ); + + if (m_ChildrenContainer) + { + QQmlProperty::write(m_ChildrenContainer, "parent", QVariant::fromValue(this)); + QQmlEngine::setObjectOwnership(m_ChildrenContainer, QQmlEngine::CppOwnership); + + SetupWidget(m_ChildrenContainer); + } + else + { + throw std::logic_error("Initialization of QmlMitkFourRenderWindowWidget went dead wrong. Check code..."); + } +} + +QmlMitkFourRenderWindowWidget::~QmlMitkFourRenderWindowWidget() +{ + if (m_ChildrenContainer) + { + m_ChildrenContainer->deleteLater(); + } +} + +void QmlMitkFourRenderWindowWidget::SetupWidget( QQuickItem* parent ) +{ + m_RenderItemAxial = parent->findChild("mitkRenderItemAxial"); + m_RenderItemSagittal = parent->findChild("mitkRenderItemSagittal"); + m_RenderItemFrontal = parent->findChild("mitkRenderItemFrontal"); + m_RenderItem3D = parent->findChild("mitkRenderItem3D"); + + if (m_RenderItemAxial && m_RenderItemSagittal && m_RenderItemFrontal && m_RenderItem3D) + { + m_RenderItemAxial->GetRenderer()->SetMapperID( mitk::BaseRenderer::Standard2D ); + m_RenderItemAxial->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Axial ); + + m_RenderItemSagittal->GetRenderer()->SetMapperID( mitk::BaseRenderer::Standard2D ); + m_RenderItemSagittal->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Sagittal ); + + m_RenderItemFrontal->GetRenderer()->SetMapperID( mitk::BaseRenderer::Standard2D ); + m_RenderItemFrontal->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Frontal ); + + m_RenderItem3D->GetRenderer()->SetMapperID( mitk::BaseRenderer::Standard3D ); + m_RenderItem3D->GetRenderer()->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Original ); + + InitializeMoveZoomInteraction(); + } +} + +void QmlMitkFourRenderWindowWidget::InitializeMoveZoomInteraction() +{ + static mitk::DisplayInteractor::Pointer m_ZoomScroller = mitk::DisplayInteractor::New(); + m_ZoomScroller->LoadStateMachine("DisplayInteraction.xml"); + m_ZoomScroller->SetEventConfig("DisplayConfigMITK.xml"); + + us::ModuleContext* context = us::GetModuleContext(); + context->RegisterService( m_ZoomScroller.GetPointer() ); +} + + +void QmlMitkFourRenderWindowWidget::SetDataStorage( mitk::DataStorage::Pointer storage ) +{ + m_DataStorage = storage; + + // TODO file bug: planes rendering 2D REQUIRES a parent node for all plane geometries! the mapper should just not care if it cannot find others! + // TODO make this conditional, only add if not yet preset... + mitk::DataNode::Pointer planesNodeParent = mitk::DataNode::New(); + m_DataStorage->Add( planesNodeParent ); + + m_RenderItemAxial->SetPlaneNodeParent( planesNodeParent ); + m_RenderItemAxial->GetRenderer()->SetDataStorage( m_DataStorage ); + + m_RenderItemSagittal->SetPlaneNodeParent( planesNodeParent ); + m_RenderItemSagittal->GetRenderer()->SetDataStorage( m_DataStorage ); + + m_RenderItemFrontal->SetPlaneNodeParent( planesNodeParent ); + m_RenderItemFrontal->GetRenderer()->SetDataStorage( m_DataStorage ); + + m_RenderItem3D->SetPlaneNodeParent( planesNodeParent ); + m_RenderItem3D->GetRenderer()->SetDataStorage( m_DataStorage ); +} + diff --git a/Modules/QmlMitk/QmlMitkFourRenderWindowWidget.h b/Modules/QmlMitk/QmlMitkFourRenderWindowWidget.h new file mode 100644 index 0000000000..41d486fc22 --- /dev/null +++ b/Modules/QmlMitk/QmlMitkFourRenderWindowWidget.h @@ -0,0 +1,58 @@ +#ifndef QmlMitkFourRenderWindowWidget_h +#define QmlMitkFourRenderWindowWidget_h + +#include + +#include "QmlMitkRenderWindowItem.h" + +#include "mitkDataStorage.h" + +#include "QmlMitkExports.h" + +/** + \brief QML replacement for QmitkStdMultiWidget. + + A proof-of-concept "multi-widget". Currently exclusively + for use in the QuickRender demo application. + + \warning Subject to change. +*/ +class QmlMitk_EXPORT QmlMitkFourRenderWindowWidget : public QQuickItem +{ + Q_OBJECT + +public: + + QmlMitkFourRenderWindowWidget(QQuickItem* parent = 0); + virtual ~QmlMitkFourRenderWindowWidget(); + + void SetDataStorage( mitk::DataStorage::Pointer storage ); + +signals: + +public slots: + +protected slots: + +protected: + + virtual void SetupWidget( QQuickItem* parent ); + + virtual void InitializeMoveZoomInteraction(); + + mitk::DataStorage::Pointer m_DataStorage; + +private slots: + +private: + + QQuickItem* m_ChildrenContainer; + + QmlMitkRenderWindowItem* m_RenderItemAxial; + QmlMitkRenderWindowItem* m_RenderItemSagittal; + QmlMitkRenderWindowItem* m_RenderItemFrontal; + QmlMitkRenderWindowItem* m_RenderItem3D; + +}; + +#endif diff --git a/Modules/QmlMitk/QmlMitkRenderWindowItem.cpp b/Modules/QmlMitk/QmlMitkRenderWindowItem.cpp new file mode 100644 index 0000000000..0f96ef6647 --- /dev/null +++ b/Modules/QmlMitk/QmlMitkRenderWindowItem.cpp @@ -0,0 +1,397 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QmlMitkRenderWindowItem.h" + +#include + +#include +#include +#include +#include + +// MITK event types +#include "mitkMousePressEvent.h" +#include "mitkMouseMoveEvent.h" +#include "mitkMouseDoubleClickEvent.h" +#include "mitkMouseReleaseEvent.h" +#include "mitkInteractionKeyEvent.h" +#include "mitkMouseWheelEvent.h" +#include "mitkInternalEvent.h" +#include "mitkGeometry2DDataMapper2D.h" + +#include "QmlMitkBigRenderLock.h" + +#define INTERACTION_LEGACY // TODO: remove INTERACTION_LEGACY! + +#if defined INTERACTION_LEGACY + #include "InteractionLegacy/QmitkEventAdapter.h" + #include "mitkGlobalInteraction.h" +#endif + +QmlMitkRenderWindowItem* QmlMitkRenderWindowItem::GetInstanceForVTKRenderWindow( vtkRenderWindow* rw ) +{ + return GetInstances()[rw]; +} + +QMap& QmlMitkRenderWindowItem::GetInstances() +{ + static QMap s_Instances; + return s_Instances; +} + + +QmlMitkRenderWindowItem +::QmlMitkRenderWindowItem(QQuickItem* parent, + const QString& name, + mitk::VtkPropRenderer* /*renderer*/, + mitk::RenderingManager* renderingManager) +: QVTKQuickItem(parent) +{ + mitk::RenderWindowBase::Initialize( renderingManager, name.toStdString().c_str() ); + + /* from QmitkRenderWindow. Required? + setFocusPolicy(Qt::StrongFocus); + setMouseTracking(true); + */ + + GetInstances()[QVTKQuickItem::GetRenderWindow()] = this; +} + +// called from QVTKQuickItem when window is painted for the first time! +void QmlMitkRenderWindowItem::init() +{ + QVTKQuickItem::init(); + + mitk::DataStorage::Pointer m_DataStorage = mitk::RenderWindowBase::GetRenderer()->GetDataStorage(); + if (m_DataStorage.IsNotNull()) + { + mitk::RenderingManager::GetInstance()->InitializeViews( m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()) ); + } + + // TODO the following code needs to be moved to a multi-widget item + if ( mitk::RenderWindowBase::GetRenderer()->GetMapperID() == mitk::BaseRenderer::Standard2D ) + { + this->SetCrossHairPositioningOnClick(true); + } + + if ( mitk::RenderWindowBase::GetRenderer()->GetMapperID() == mitk::BaseRenderer::Standard2D + && m_DataStorage.IsNotNull() ) + { + + mitk::DataNode::Pointer planeNode = mitk::RenderWindowBase::GetRenderer()->GetCurrentWorldGeometry2DNode(); + switch ( mitk::RenderWindowBase::GetRenderer()->GetSliceNavigationController()->GetDefaultViewDirection() ) + { + case mitk::SliceNavigationController::Axial: + planeNode->SetColor(1.0,0.0,0.0); + break; + case mitk::SliceNavigationController::Sagittal: + planeNode->SetColor(0.0,1.0,0.0); + break; + case mitk::SliceNavigationController::Frontal: + planeNode->SetColor(0.0,0.0,1.0); + break; + default: + planeNode->SetColor(1.0,1.0,0.0); + } + planeNode->SetProperty("layer", mitk::IntProperty::New(1000) ); + planeNode->SetProperty("visible", mitk::BoolProperty::New(true) ); + planeNode->SetProperty("helper object", mitk::BoolProperty::New(true) ); + + mitk::Geometry2DDataMapper2D::Pointer mapper = mitk::Geometry2DDataMapper2D::New(); + mapper->SetDatastorageAndGeometryBaseNode( m_DataStorage, m_PlaneNodeParent ); + planeNode->SetMapper( mitk::BaseRenderer::Standard2D, mapper ); + + m_DataStorage->Add( planeNode, m_PlaneNodeParent ); + } +} + +void QmlMitkRenderWindowItem::InitView( mitk::BaseRenderer::MapperSlotId mapperID, + mitk::SliceNavigationController::ViewDirection viewDirection ) +{ + m_MapperID = mapperID; + m_ViewDirection = viewDirection; +} + + +void QmlMitkRenderWindowItem::SetDataStorage(mitk::DataStorage::Pointer storage) +{ + m_DataStorage = storage; +} + +mitk::Point2D QmlMitkRenderWindowItem::GetMousePosition(QMouseEvent* me) const +{ + + mitk::Point2D point; + point[0] = me->x(); + point[1] = me->y(); + return point; +} + +mitk::Point2D QmlMitkRenderWindowItem::GetMousePosition(QWheelEvent* we) const +{ + mitk::Point2D point; + point[0] = we->x(); + point[1] = we->y(); + return point; +} + +mitk::InteractionEvent::MouseButtons QmlMitkRenderWindowItem::GetEventButton(QMouseEvent* me) const +{ + mitk::InteractionEvent::MouseButtons eventButton; + switch (me->button()) + { + case Qt::LeftButton: + eventButton = mitk::InteractionEvent::LeftMouseButton; + break; + case Qt::RightButton: + eventButton = mitk::InteractionEvent::RightMouseButton; + break; + case Qt::MidButton: + eventButton = mitk::InteractionEvent::MiddleMouseButton; + break; + default: + eventButton = mitk::InteractionEvent::NoButton; + break; + } + return eventButton; +} + +mitk::InteractionEvent::MouseButtons QmlMitkRenderWindowItem::GetButtonState(QMouseEvent* me) const +{ + mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; + + if (me->buttons() & Qt::LeftButton) + { + buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; + } + if (me->buttons() & Qt::RightButton) + { + buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; + } + if (me->buttons() & Qt::MidButton) + { + buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; + } + return buttonState; +} + +mitk::InteractionEvent::ModifierKeys QmlMitkRenderWindowItem::GetModifiers(QInputEvent* me) const +{ + mitk::InteractionEvent::ModifierKeys modifiers = mitk::InteractionEvent::NoKey; + + if (me->modifiers() & Qt::ALT) + { + modifiers = modifiers | mitk::InteractionEvent::AltKey; + } + if (me->modifiers() & Qt::CTRL) + { + modifiers = modifiers | mitk::InteractionEvent::ControlKey; + } + if (me->modifiers() & Qt::SHIFT) + { + modifiers = modifiers | mitk::InteractionEvent::ShiftKey; + } + return modifiers; +} + +mitk::InteractionEvent::MouseButtons QmlMitkRenderWindowItem::GetButtonState(QWheelEvent* we) const +{ + mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; + + if (we->buttons() & Qt::LeftButton) + { + buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; + } + if (we->buttons() & Qt::RightButton) + { + buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; + } + if (we->buttons() & Qt::MidButton) + { + buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; + } + return buttonState; +} + + +void QmlMitkRenderWindowItem::mousePressEvent(QMouseEvent* me) +{ + mitk::MousePressEvent::Pointer mPressEvent = + mitk::MousePressEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(me), GetButtonState(me), GetModifiers(me), GetEventButton(me)); + +#if defined INTERACTION_LEGACY + bool modernInteractorHandledEvent = +#endif + mitk::RenderWindowBase::HandleEvent(mPressEvent.GetPointer()); +#if defined INTERACTION_LEGACY + if (!modernInteractorHandledEvent) + { + mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(mitk::RenderWindowBase::GetRenderer(), me)); + mitk::RenderWindowBase::mousePressMitkEvent(&myevent); + } +#endif + + QVTKQuickItem::mousePressEvent(me); + +// if (m_ResendQtEvents) +// me->ignore(); +} + +void QmlMitkRenderWindowItem::mouseReleaseEvent(QMouseEvent* me) +{ + mitk::MouseReleaseEvent::Pointer mReleaseEvent = + mitk::MouseReleaseEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(me), GetButtonState(me), GetModifiers(me), GetEventButton(me)); + +#if defined INTERACTION_LEGACY + bool modernInteractorHandledEvent = +#endif + mitk::RenderWindowBase::HandleEvent(mReleaseEvent.GetPointer()); +#if defined INTERACTION_LEGACY + if (!modernInteractorHandledEvent) + { + mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(mitk::RenderWindowBase::GetRenderer(), me)); + mitk::RenderWindowBase::mouseReleaseMitkEvent(&myevent); + } +#endif + + QVTKQuickItem::mouseReleaseEvent(me); + +// if (m_ResendQtEvents) +// me->ignore(); +} + +void QmlMitkRenderWindowItem::mouseMoveEvent(QMouseEvent* me) +{ + mitk::MouseMoveEvent::Pointer mMoveEvent = + mitk::MouseMoveEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(me), GetButtonState(me), GetModifiers(me)); + +#if defined INTERACTION_LEGACY + bool modernInteractorHandledEvent = +#endif + mitk::RenderWindowBase::HandleEvent(mMoveEvent.GetPointer()); +#if defined INTERACTION_LEGACY + if (!modernInteractorHandledEvent) + { + mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(mitk::RenderWindowBase::GetRenderer(), me)); + mitk::RenderWindowBase::mouseMoveMitkEvent(&myevent); + } +#endif + + QVTKQuickItem::mouseMoveEvent(me); + +// TODO: why was this not put here initially? What is special about mouse move? +// if (m_ResendQtEvents) +// me->ignore(); +} + +void QmlMitkRenderWindowItem::wheelEvent(QWheelEvent *we) +{ + mitk::MouseWheelEvent::Pointer mWheelEvent = + mitk::MouseWheelEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(we), GetButtonState(we), GetModifiers(we), we->delta()); + +#if defined INTERACTION_LEGACY + bool modernInteractorHandledEvent = +#endif + mitk::RenderWindowBase::HandleEvent(mWheelEvent.GetPointer()); +#if defined INTERACTION_LEGACY + if (!modernInteractorHandledEvent) + { // TODO: INTERACTION_LEGACY + mitk::WheelEvent myevent(QmitkEventAdapter::AdaptWheelEvent(mitk::RenderWindowBase::GetRenderer(), we)); + mitk::RenderWindowBase::wheelMitkEvent(&myevent); + } +#endif + + QVTKQuickItem::wheelEvent(we); + +// if (m_ResendQtEvents) +// we->ignore(); +} + + +void QmlMitkRenderWindowItem::prepareForRender() +{ +// Adjust camera is kaputt wenn nicht der renderingmanager dem vtkprop bescheid sagt! +// this is just a workaround + QmlMitkBigRenderLock::GetMutex().lock(); + mitk::RenderWindowBase::GetRenderer()->ForceImmediateUpdate(); +} + +void QmlMitkRenderWindowItem::cleanupAfterRender() +{ + QmlMitkBigRenderLock::GetMutex().unlock(); +} + +void QmlMitkRenderWindowItem::SetCrossHairPositioningOnClick(bool enabled) +{ + if (enabled) + { + mitk::GlobalInteraction::GetInstance()->AddListener( mitk::RenderWindowBase::GetSliceNavigationController() ); + } + else + { + mitk::GlobalInteraction::GetInstance()->RemoveListener( mitk::RenderWindowBase::GetSliceNavigationController() ); + } +} + +void QmlMitkRenderWindowItem::SetPlaneNodeParent( mitk::DataNode::Pointer node ) +{ + m_PlaneNodeParent = node; +} + +void QmlMitkRenderWindowItem::geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry) +{ + QVTKQuickItem::geometryChanged(newGeometry, oldGeometry); + + this->resizeMitkEvent( newGeometry.width(), newGeometry.height() ); +} + +vtkRenderWindow* QmlMitkRenderWindowItem::GetVtkRenderWindow() +{ + return QVTKQuickItem::GetRenderWindow(); +} + +vtkRenderWindowInteractor* QmlMitkRenderWindowItem::GetVtkRenderWindowInteractor() +{ + return QVTKQuickItem::GetInteractor(); +} + + diff --git a/Modules/QmlMitk/QmlMitkRenderWindowItem.h b/Modules/QmlMitk/QmlMitkRenderWindowItem.h new file mode 100644 index 0000000000..435292d0ef --- /dev/null +++ b/Modules/QmlMitk/QmlMitkRenderWindowItem.h @@ -0,0 +1,87 @@ +#ifndef QmlMitkRenderWindowItem_h +#define QmlMitkRenderWindowItem_h + +#include + +#include "mitkRenderWindowBase.h" + +#include + +#include "QmlMitkExports.h" + +/** + \brief QML replacement for QmitkRenderWindow. + + A proof-of-concept render window. Currently exclusively + for use in the QuickRender demo application. + + \warning Subject to change. +*/ +class QmlMitk_EXPORT QmlMitkRenderWindowItem : public QVTKQuickItem, public mitk::RenderWindowBase +{ + Q_OBJECT + +public: + static QmlMitkRenderWindowItem* GetInstanceForVTKRenderWindow( vtkRenderWindow* rw ); + + QmlMitkRenderWindowItem(QQuickItem* parent = 0, + const QString& name = "QML render window", + mitk::VtkPropRenderer* renderer = NULL, + mitk::RenderingManager* renderingManager = NULL); + + virtual vtkRenderWindow* GetVtkRenderWindow(); + virtual vtkRenderWindowInteractor* GetVtkRenderWindowInteractor(); + + void SetDataStorage(mitk::DataStorage::Pointer storage); + + void InitView( mitk::BaseRenderer::MapperSlotId mapperID, + mitk::SliceNavigationController::ViewDirection viewDirection ); + + void SetPlaneNodeParent( mitk::DataNode::Pointer node ); + + void SetCrossHairPositioningOnClick(bool enabled); + +signals: + +public slots: + +protected slots: + +protected: + + virtual void init(); + virtual void prepareForRender(); + virtual void cleanupAfterRender(); + + mitk::Point2D GetMousePosition(QMouseEvent* me) const; + mitk::Point2D GetMousePosition(QWheelEvent* we) const; + mitk::InteractionEvent::MouseButtons GetEventButton(QMouseEvent* me) const; + mitk::InteractionEvent::MouseButtons GetButtonState(QMouseEvent* me) const; + mitk::InteractionEvent::ModifierKeys GetModifiers(QInputEvent* me) const; + mitk::InteractionEvent::MouseButtons GetButtonState(QWheelEvent* we) const; + void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry); // !? + + virtual void mousePressEvent(QMouseEvent* e); + virtual void mouseReleaseEvent(QMouseEvent* e); + virtual void mouseMoveEvent(QMouseEvent* e); + virtual void wheelEvent(QWheelEvent* e); + +private slots: + +private: + mitk::DataStorage::Pointer m_DataStorage; + mitk::DataNode::Pointer m_PlaneNodeParent; + + mitk::BaseRenderer::MapperSlotId m_MapperID; + mitk::SliceNavigationController::ViewDirection m_ViewDirection; + + + QTimer m_Animation; + + vtkSmartPointer m_connect; + + static QMap& GetInstances(); + +}; + +#endif diff --git a/Modules/QmlMitk/QmlMitkRenderingManager.cpp b/Modules/QmlMitk/QmlMitkRenderingManager.cpp new file mode 100644 index 0000000000..0e6b7697fc --- /dev/null +++ b/Modules/QmlMitk/QmlMitkRenderingManager.cpp @@ -0,0 +1,131 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "QmlMitkRenderingManager.h" +#include "QmlMitkRenderWindowItem.h" + + +#include "mitkGeometry3D.h" +#include "mitkBaseRenderer.h" +#include "mitkSliceNavigationController.h" + +#include +#include + + +QmlMitkRenderingManager +::QmlMitkRenderingManager() +:pendingTimerCallbacks(0) +{ +} + +QmlMitkRenderingManager +::~QmlMitkRenderingManager() +{ +} + +void +QmlMitkRenderingManager +::GenerateRenderingRequestEvent() +{ + QCoreApplication::postEvent( this, new QmlMitkRenderingRequestEvent ); +} + + +void +QmlMitkRenderingManager +::StartOrResetTimer() +{ + QTimer::singleShot(200, this, SLOT(TimerCallback())); + pendingTimerCallbacks++; +} + +void +QmlMitkRenderingManager +::TimerCallback() +{ + if(!--pendingTimerCallbacks) + { + this->ExecutePendingHighResRenderingRequest(); + } +} + +#include + +bool +QmlMitkRenderingManager +::event( QEvent *event ) +{ + if ( event->type() == (QEvent::Type) QmlMitkRenderingRequestEvent::RenderingRequest ) + { + // Directly process all pending rendering requests + //this->ExecutePendingRequests(); + this->MyUpdateExecutePendingRequests(); + + return true; + } + + return false; +} + +#include "QVTKQuickItem.h" + +void QmlMitkRenderingManager::MyUpdateExecutePendingRequests() +{ + m_UpdatePending = false; + + // Satisfy all pending update requests + RenderWindowList::iterator it; + int i = 0; + for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it, ++i ) + { + if ( it->second == RENDERING_REQUESTED ) + { + vtkRenderWindow* renderWindow = it->first; + + // If the renderWindow is not valid, we do not want to inadvertantly create + // an entry in the m_RenderWindowList map. It is possible if the user is + // regularly calling AddRenderer and RemoveRenderer for a rendering update + // to come into this method with a renderWindow pointer that is valid in the + // sense that the window does exist within the application, but that + // renderWindow has been temporarily removed from this RenderingManager for + // performance reasons. + if (m_RenderWindowList.find( renderWindow ) == m_RenderWindowList.end()) + { + continue; + } + + // Erase potentially pending requests for this window + m_RenderWindowList[renderWindow] = RENDERING_INACTIVE; + + m_UpdatePending = false; + + // Immediately repaint this window (implementation platform specific) + // If the size is 0 it crahses + int *size = renderWindow->GetSize(); + if ( 0 != size[0] && 0 != size[1] ) + { + QmlMitkRenderWindowItem* qqi = QmlMitkRenderWindowItem::GetInstanceForVTKRenderWindow( renderWindow ); + if (qqi) + { + qqi->update(); + } + } + } + } +} + + diff --git a/Modules/QmlMitk/QmlMitkRenderingManager.h b/Modules/QmlMitk/QmlMitkRenderingManager.h new file mode 100644 index 0000000000..fd5eac1599 --- /dev/null +++ b/Modules/QmlMitk/QmlMitkRenderingManager.h @@ -0,0 +1,85 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#ifndef QmlMitkRenderingManager_h +#define QmlMitkRenderingManager_h + +#include + +#include "mitkRenderingManager.h" + +#include +#include + +class QmlMitkRenderingManagerFactory; + +/** + * \ingroup QmlMitkModule + * \brief Qt/Qml specific implementation of mitk::RenderingManager. + * + * This implementation defines a QmlMitkRenderingRequestEvent to realize the + * rendering request process. The event is put into Qt's event loop to + * receive it back in the GUI thread where we are allowed to do rendering. + * + */ +class QmlMitk_EXPORT QmlMitkRenderingManager : public QObject, public mitk::RenderingManager +{ + Q_OBJECT + +public: + + mitkClassMacro( QmlMitkRenderingManager, mitk::RenderingManager ); + virtual ~QmlMitkRenderingManager(); + + virtual bool event( QEvent *event ); + +protected: + + itkFactorylessNewMacro(Self); + + QmlMitkRenderingManager(); + + virtual void GenerateRenderingRequestEvent(); + + virtual void StartOrResetTimer(); + + int pendingTimerCallbacks; + + protected slots: + + void TimerCallback(); + +private: + + friend class QmlMitkRenderingManagerFactory; + + void MyUpdateExecutePendingRequests(); +}; + +class QmlMitkRenderingRequestEvent : public QEvent +{ +public: + enum Type + { + RenderingRequest = QEvent::MaxUser - 1024 + }; + + QmlMitkRenderingRequestEvent() + : QEvent( (QEvent::Type) RenderingRequest ) {}; +}; + +#endif /* MITKRenderingManager_H_HEADER_INCLUDED_C135A197 */ diff --git a/Modules/QmlMitk/QmlMitkRenderingManagerFactory.cpp b/Modules/QmlMitk/QmlMitkRenderingManagerFactory.cpp new file mode 100644 index 0000000000..11d7f21292 --- /dev/null +++ b/Modules/QmlMitk/QmlMitkRenderingManagerFactory.cpp @@ -0,0 +1,38 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#include "QmlMitkRenderingManagerFactory.h" +#include "QmlMitkRenderingManager.h" + +QmlMitkRenderingManagerFactory +::QmlMitkRenderingManagerFactory() +{ + mitk::RenderingManager::SetFactory( this ); +} + +QmlMitkRenderingManagerFactory +::~QmlMitkRenderingManagerFactory() +{ +} + +mitk::RenderingManager::Pointer +QmlMitkRenderingManagerFactory +::CreateRenderingManager() const +{ + QmlMitkRenderingManager::Pointer specificSmartPtr = QmlMitkRenderingManager::New(); + return specificSmartPtr.GetPointer(); +} diff --git a/Modules/QmlMitk/QmlMitkRenderingManagerFactory.h b/Modules/QmlMitk/QmlMitkRenderingManagerFactory.h new file mode 100644 index 0000000000..1d0917e6f4 --- /dev/null +++ b/Modules/QmlMitk/QmlMitkRenderingManagerFactory.h @@ -0,0 +1,48 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#ifndef QmlMitkRenderingManagerFactory_h +#define QmlMitkRenderingManagerFactory_h + +#include + +#include "mitkRenderingManagerFactory.h" + +/** + * \ingroup QmlMitkModule + * \brief Qt specific implementation of mitk::RenderingManagerFactory. + * + * This class create QmlMitkRenderingManager instances via + * CreateRenderingManager(). + * + */ +class QmlMitk_EXPORT QmlMitkRenderingManagerFactory : public mitk::RenderingManagerFactory +{ +public: + + QmlMitkRenderingManagerFactory(); + + ~QmlMitkRenderingManagerFactory(); + + virtual mitk::RenderingManager::Pointer CreateRenderingManager() const; + +private: + +}; + + +#endif diff --git a/Modules/QmlMitk/README b/Modules/QmlMitk/README new file mode 100644 index 0000000000..8de729e147 --- /dev/null +++ b/Modules/QmlMitk/README @@ -0,0 +1,4 @@ +This module is meant to provide the functionality of QmitkRenderWindow in QML at some time. + +In the current state, this module is just a proof-of-concept and should not be used outside +experimental code. It is subject to substantial change, so do not rely on the current state. diff --git a/Modules/QmlMitk/files.cmake b/Modules/QmlMitk/files.cmake new file mode 100644 index 0000000000..54073f2266 --- /dev/null +++ b/Modules/QmlMitk/files.cmake @@ -0,0 +1,21 @@ +set(CPP_FILES + QmlMitkRenderWindowItem.cpp + QmlMitkRenderingManager.cpp + QmlMitkRenderingManagerFactory.cpp + InteractionLegacy/QmitkEventAdapter.cpp + QmlMitkBigRenderLock.cpp + QmlMitkFourRenderWindowWidget.cpp +) + +set(MOC_H_FILES + QmlMitkRenderWindowItem.h + QmlMitkRenderingManager.h + QmlMitkBigRenderLock.h + QmlMitkFourRenderWindowWidget.h +) + +set(UI_FILES +) + +set(QRC_FILES +) diff --git a/Modules/Qt4Qt5TestModule/CMakeLists.txt b/Modules/Qt4Qt5TestModule/CMakeLists.txt new file mode 100644 index 0000000000..4c4869a3e6 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/CMakeLists.txt @@ -0,0 +1,7 @@ +MITK_CREATE_MODULE(Qt4Qt5TestModule + QT4_MODULES QtCore # we want something in the Qt 4 case + QT5_MODULES Qt5Core # we want something else in the Qt 5 case + SUBPROJECTS MITK-CoreUI +) + +add_subdirectory(Testing) diff --git a/Modules/Qt4Qt5TestModule/QWonderString.cpp b/Modules/Qt4Qt5TestModule/QWonderString.cpp new file mode 100644 index 0000000000..3917e89d5f --- /dev/null +++ b/Modules/Qt4Qt5TestModule/QWonderString.cpp @@ -0,0 +1,59 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "QWonderString.h" + +#if QT_VERSION >= 0x050000 + // Qt 5 or higher + #include +#else + // Qt 4 + #include +#endif + +QWonderString::QWonderString(QObject* parent, const QString& text) +:QObject(parent) +,m_Text(text) +{ +} + +QString QWonderString::text() +{ + return m_Text; +} + +void QWonderString::setText(const QString& text) +{ + m_Text = text; + + if (m_Text.contains("y")) + emit happy(); + + if (m_Text.contains("k")) + emit sad(); +} + +QString QWonderString::penguinUID() +{ + QUuid id = QUuid::createUuid(); +#if QT_VERSION >= 0x050000 + QString returnValue = id.toString(); // explicit in Qt 5 +#else + QString returnValue = id; // implicit in Qt 4 +#endif + + return returnValue; +} diff --git a/Modules/Qt4Qt5TestModule/QWonderString.h b/Modules/Qt4Qt5TestModule/QWonderString.h new file mode 100644 index 0000000000..0ac277fa99 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/QWonderString.h @@ -0,0 +1,56 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef QWonderString_h +#define QWonderString_h + +#include + +#include "Qt4Qt5TestModuleExports.h" + +/** + \brief PURPOSELESS class for testing. + + This class is meant to demonstrate a module that builds with both Qt4 and Qt5! + + There is nothing here to copy.. +*/ +class Qt4Qt5TestModule_EXPORT QWonderString : public QObject +{ + Q_OBJECT + + public: + + QWonderString(QObject* parent = 0, const QString& text = ""); + + QString text(); + + static QString penguinUID(); + + public slots: + void setText(const QString& text); + + signals: + + void happy(); + void sad(); + + protected: + + QString m_Text; +}; + +#endif diff --git a/Modules/Qt4Qt5TestModule/Testing/CMakeLists.txt b/Modules/Qt4Qt5TestModule/Testing/CMakeLists.txt new file mode 100644 index 0000000000..c26edbc7d0 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/Testing/CMakeLists.txt @@ -0,0 +1,5 @@ +list(APPEND PACKAGE_DEPENDS ITK) + +MITK_CREATE_MODULE_TESTS() + +mitk_use_modules(TARGET ${TESTDRIVER} MODULES Mitk QT4_MODULES QtTest QT5_MODULES Qt5Test) diff --git a/Modules/Qt4Qt5TestModule/Testing/QWonderStringTest.cpp b/Modules/Qt4Qt5TestModule/Testing/QWonderStringTest.cpp new file mode 100644 index 0000000000..cb41e4e5bd --- /dev/null +++ b/Modules/Qt4Qt5TestModule/Testing/QWonderStringTest.cpp @@ -0,0 +1,38 @@ +#include "mitkTestingMacros.h" + +#include + +#include "QWonderString.h" + +/** + Just SOME kind of testing, nothing meaningful. + + This test is just company to the Qt4Qt5TestModule, + which is mean to demostrate how to implement a + module for both Qt4 and Qt5 +*/ +int QWonderStringTest(int argc, char* argv[]) +{ + MITK_TEST_CONDITION( !QWonderString::penguinUID().isEmpty(), "Penguin registry working" ) + + QWonderString s; + + QSignalSpy happyCounter( &s, SIGNAL(happy())); + QSignalSpy sadCounter( &s, SIGNAL(sad())); + + MITK_TEST_CONDITION( happyCounter.count() == 0 && sadCounter.count() == 0, "No feelings in the beginning" ) + + s.setText("Happy feet"); + MITK_TEST_CONDITION( happyCounter.count() == 1, "Penguins are happy" ) + + s.setText("Talk too much"); + MITK_TEST_CONDITION( sadCounter.count() == 1, "Penguin ears bleed" ) + + s.setText("Fishy fish"); + MITK_TEST_CONDITION( happyCounter.count() == 2, "Penguins sleepy" ) + + s.setText("Knok knok"); + MITK_TEST_CONDITION( sadCounter.count() == 2, "Penguins irritated" ) + + return EXIT_SUCCESS; +} diff --git a/Modules/Qt4Qt5TestModule/Testing/files.cmake b/Modules/Qt4Qt5TestModule/Testing/files.cmake new file mode 100644 index 0000000000..55bb90f2a9 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/Testing/files.cmake @@ -0,0 +1,5 @@ +set(MODULE_TESTS + QWonderStringTest.cpp +) + + diff --git a/Modules/Qt4Qt5TestModule/files.cmake b/Modules/Qt4Qt5TestModule/files.cmake new file mode 100644 index 0000000000..f20a244879 --- /dev/null +++ b/Modules/Qt4Qt5TestModule/files.cmake @@ -0,0 +1,7 @@ +set(CPP_FILES + QWonderString.cpp +) + +set(MOC_H_FILES + QWonderString.h +) diff --git a/Modules/RigidRegistration/CMakeLists.txt b/Modules/RigidRegistration/CMakeLists.txt index 9be694ca5e..ae71051393 100644 --- a/Modules/RigidRegistration/CMakeLists.txt +++ b/Modules/RigidRegistration/CMakeLists.txt @@ -1,7 +1,8 @@ MITK_CREATE_MODULE(MitkRigidRegistration SUBPROJECTS MITK-Registration DEPENDS Mitk + QT4_MODULES QtGui EXPORT_DEFINE MITK_RIGIDREGISTRATION_EXPORT ) add_subdirectory(Testing) diff --git a/Modules/RigidRegistrationUI/CMakeLists.txt b/Modules/RigidRegistrationUI/CMakeLists.txt index 7edd59da5c..871aa796a3 100644 --- a/Modules/RigidRegistrationUI/CMakeLists.txt +++ b/Modules/RigidRegistrationUI/CMakeLists.txt @@ -1,7 +1,7 @@ MITK_CREATE_MODULE(MitkRigidRegistrationUI SUBPROJECTS MITK-Registration INCLUDE_DIRS RigidRegistrationMetrics RigidRegistrationOptimizer RigidRegistrationTransforms DEPENDS Qmitk MitkRigidRegistration - QT_MODULE + QT4_MODULES QtGui EXPORT_DEFINE MITK_RIGIDREGISTRATION_UI_EXPORT ) diff --git a/Modules/SegmentationUI/CMakeLists.txt b/Modules/SegmentationUI/CMakeLists.txt index b4e029cc0c..a6a331c06e 100644 --- a/Modules/SegmentationUI/CMakeLists.txt +++ b/Modules/SegmentationUI/CMakeLists.txt @@ -1,6 +1,6 @@ MITK_CREATE_MODULE ( SegmentationUI INCLUDE_DIRS Qmitk DEPENDS Qmitk Segmentation QmitkExt -PACKAGE_DEPENDS QT CTK -QT_MODULE +PACKAGE_DEPENDS CTK +QT4_MODULES QtCore QtGui ) diff --git a/Modules/ToFUI/CMakeLists.txt b/Modules/ToFUI/CMakeLists.txt index 7320e2a23a..07b31b76c8 100644 --- a/Modules/ToFUI/CMakeLists.txt +++ b/Modules/ToFUI/CMakeLists.txt @@ -1,8 +1,8 @@ MITK_CREATE_MODULE(mitkTOFUI SUBPROJECTS MITK-ToF INCLUDE_DIRS Qmitk DEPENDS mitkToFHardware mitkToFProcessing Qmitk QmitkExt Overlays - QT_MODULE + QT4_MODULES QtGui GENERATED_CPP ${TOOL_GUI_CPPS} ${TOOL_CPPS} ) diff --git a/Modules/USUI/CMakeLists.txt b/Modules/USUI/CMakeLists.txt index 10c7fde455..586355d8a6 100644 --- a/Modules/USUI/CMakeLists.txt +++ b/Modules/USUI/CMakeLists.txt @@ -1,8 +1,8 @@ MITK_CREATE_MODULE(MitkUSUI #SUBPROJECTS MITK-US INCLUDE_DIRS Qmitk DEPENDS Mitk MitkUS Qmitk QmitkExt - QT_MODULE + QT4_MODULES QtGui GENERATED_CPP ${TOOL_GUI_CPPS} ${TOOL_CPPS} ) diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 3599933f46..1a97bfea5e 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,49 +1,58 @@ # Plug-ins must be ordered according to their dependencies +if (MITK_USE_Qt4) set(MITK_EXT_PLUGINS org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.diffusionimaging:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.dtiatlasapp:OFF org.mitk.gui.qt.examples:OFF org.mitk.gui.qt.examplesopencv:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.meshdecimation:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.registration:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF ) + +else() + +set(MITK_EXT_PLUGINS + # empty so far +) + +endif() diff --git a/Plugins/org.mitk.gui.qt.cmdlinemodules/CMakeLists.txt b/Plugins/org.mitk.gui.qt.cmdlinemodules/CMakeLists.txt index 6eb04a182e..04dbdb5f28 100644 --- a/Plugins/org.mitk.gui.qt.cmdlinemodules/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.cmdlinemodules/CMakeLists.txt @@ -1,10 +1,9 @@ project(org_mitk_gui_qt_cmdlinemodules) -set(QT_USE_QTUITOOLS 1) -include(${QT_USE_FILE}) +set(PLUGIN_QT4_MODULES QtUiTools) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE CLI_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES CTK QmitkExt ) diff --git a/Plugins/org.mitk.gui.qt.cmdlinemodules/src/internal/QmitkDataStorageComboBoxWithSelectNone.h b/Plugins/org.mitk.gui.qt.cmdlinemodules/src/internal/QmitkDataStorageComboBoxWithSelectNone.h index 7b1a80cd1a..ed74ff16f1 100644 --- a/Plugins/org.mitk.gui.qt.cmdlinemodules/src/internal/QmitkDataStorageComboBoxWithSelectNone.h +++ b/Plugins/org.mitk.gui.qt.cmdlinemodules/src/internal/QmitkDataStorageComboBoxWithSelectNone.h @@ -1,141 +1,143 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDataStorageComboBoxWithSelectNone_h #define QmitkDataStorageComboBoxWithSelectNone_h #include #include "QmitkDataStorageComboBox.h" #include "QmitkCustomVariants.h" #include "mitkDataNode.h" /** * \class QmitkDataStorageComboBoxWithSelectNone * \brief Displays all or a subset (defined by a predicate) of nodes of the Data Storage, * and additionally, index 0 is always "please select", indicating no selection, and will * hence always return a NULL mitk::DataNode* if asked for the node at index 0. * * \author Matt Clarkson (m.clarkson@ucl.ac.uk) * \ingroup org_mitk_gui_qt_cmdlinemodules_internal * \sa QmitkDataStorageComboBox */ class QmitkDataStorageComboBoxWithSelectNone : public QmitkDataStorageComboBox { + typedef mitk::DataNode::Pointer DataNodePtr; + Q_OBJECT - Q_PROPERTY(mitk::DataNode::Pointer SelectedNode READ GetSelectedNode WRITE SetSelectedNode) + Q_PROPERTY(DataNodePtr SelectedNode READ GetSelectedNode WRITE SetSelectedNode) Q_PROPERTY(QString currentValue READ currentValue WRITE setCurrentValue) public: /** * \brief Calls base class constructor. * \see QmitkDataStorageComboBox */ QmitkDataStorageComboBoxWithSelectNone(QWidget* parent = 0, bool autoSelectNewNodes=false); /** * \brief Calls base class constructor. * \see QmitkDataStorageComboBox */ QmitkDataStorageComboBoxWithSelectNone( mitk::DataStorage* _DataStorage, const mitk::NodePredicateBase* predicate, QWidget* parent = 0, bool autoSelectNewNodes=false); /** * \brief Nothing to do. * \see QmitkDataStorageComboBox */ ~QmitkDataStorageComboBoxWithSelectNone(); /** * \brief Stores the string that will be present on index 0, currently equal to "please select". */ static const QString ZERO_ENTRY_STRING; /** * \brief Searches for a given node, returning the index if found. * \param dataNode an mitk::DataNode, can be NULL. * \return int -1 if not found, and compared to base class, will add 1 onto the retrieved index. */ virtual int Find( const mitk::DataNode* dataNode ) const; /** * \brief Retrieves the node at a given index, where if index is zero, will always return NULL. * \param index An integer between 0 and n = number of nodes. * \return mitk::DataNode::Pointer NULL or a data node pointer. */ virtual mitk::DataNode::Pointer GetNode(int index) const; /** * \brief Returns the selected DataNode or NULL if there is none, or the current index is zero. */ virtual mitk::DataNode::Pointer GetSelectedNode() const; /** * \brief Sets the combo box to the index that contains the specified node, or 0 if the node cannot be found. */ virtual void SetSelectedNode(const mitk::DataNode::Pointer& node); /** * \brief Removes a node from the ComboBox at a specified index (if the index exists). * Gets called when a DataStorage Remove Event was thrown. */ virtual void RemoveNode(int index); /** * \brief Set a DataNode in the ComboBox at the specified index (if the index exists). * Internally the method just calls InsertNode(unsigned int) */ virtual void SetNode(int index, const mitk::DataNode* dataNode); /** * \brief Get the current file path. */ virtual QString currentValue() const; /** * \brief Set the current file path. */ virtual void setCurrentValue(const QString& path); protected: /** * \brief Checks if the given index is within range. */ bool HasIndex(unsigned int index) const; /** * \brief Inserts a new node at the given index, unless index is 0, which is silently ignored. */ virtual void InsertNode(int index, const mitk::DataNode* dataNode); /** * \brief Reset function whenever datastorage or predicate changes. */ virtual void Reset(); private: /** * \brief This should store the current file path of the current image. * * * The reason is so that we can store and retrieve a temporary file name. */ QString m_CurrentPath; }; #endif // QmitkDataStorageComboBoxWithSelectNone_h diff --git a/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt b/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt index cf964bb5c0..f379e7d3ab 100644 --- a/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt @@ -1,24 +1,20 @@ project(org_mitk_gui_qt_dicom) find_program(DCMTK_STORESCP storescp PATHS "${DCMTK_DIR}/bin" PATH_SUFFIXES Release Debug DOC "Dcmtk storage provider which is used to store dicom files which are transfered over network." NO_DEFAULT_PATH) mark_as_advanced(DCMTK_STORESCP) if(NOT EXISTS ${DCMTK_STORESCP}) message(WARNING "Couldn't find program storescp without the program query retrieve of the dicom plugin won't work!") else(NOT EXISTS ${DCMTK_STORESCP}) configure_file( org_mitk_gui_qt_dicom_config.h.in org_mitk_gui_qt_dicom_config.h @ONLY) MITK_INSTALL_HELPER_APP(${DCMTK_STORESCP}) - set(QT_USE_QTSQL 1) - - include_directories(${CTK_INCLUDE_DIRS}) - MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE DICOM_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES QmitkExt mitkDicomUI ) endif() diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt b/Plugins/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt index 4d1d73e677..c4498d22fd 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt @@ -1,18 +1,15 @@ -set(QT_USE_QTWEBKIT TRUE) -include(${QT_USE_FILE}) - -if(QT_QTWEBKIT_FOUND) - add_definitions(-DQT_WEBKIT) -endif(QT_QTWEBKIT_FOUND) - # The project name must correspond to the directory name of your plug-in # and must not contain periods. project(org_mitk_gui_qt_diffusionimagingapp) +set(PLUGIN_QT4_MODULES QtWebKit) + MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE DIFFUSIONIMAGING_APP_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES Qmitk SceneSerialization ) -target_link_libraries(${PLUGIN_TARGET} ${QT_LIBRARIES}) +if(QT_QTWEBKIT_FOUND) + add_definitions(-DQT_WEBKIT) +endif(QT_QTWEBKIT_FOUND) diff --git a/Plugins/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt b/Plugins/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt index b304be87ac..4119f8f41d 100644 --- a/Plugins/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt @@ -1,18 +1,15 @@ -set(QT_USE_QTWEBKIT TRUE) -include(${QT_USE_FILE}) - -if(QT_QTWEBKIT_FOUND) - add_definitions(-DQT_WEBKIT) -endif(QT_QTWEBKIT_FOUND) - # The project name must correspond to the directory name of your plug-in # and must not contain periods. project(org_mitk_gui_qt_dtiatlasapp) +set(PLUGIN_QT4_MODULES QtWebKit) + MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE DTIATLAS_APP_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES Qmitk SceneSerialization ) -target_link_libraries(${PLUGIN_TARGET} ${QT_LIBRARIES}) +if(QT_QTWEBKIT_FOUND) + add_definitions(-DQT_WEBKIT) +endif(QT_QTWEBKIT_FOUND) diff --git a/Plugins/org.mitk.gui.qt.extapplication/CMakeLists.txt b/Plugins/org.mitk.gui.qt.extapplication/CMakeLists.txt index 50c9d87cc7..bc737494af 100644 --- a/Plugins/org.mitk.gui.qt.extapplication/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.extapplication/CMakeLists.txt @@ -1,13 +1,12 @@ -set(QT_USE_QTWEBKIT TRUE) -include(${QT_USE_FILE}) - -if(QT_QTWEBKIT_FOUND) - add_definitions(-DQT_WEBKIT) -endif(QT_QTWEBKIT_FOUND) - project(org_mitk_gui_qt_extapplication) +set(PLUGIN_QT4_MODULES QtWebKit QtGui) + MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE MITK_QT_EXTAPP EXPORTED_INCLUDE_SUFFIXES src ) + +if(QT_QTWEBKIT_FOUND) + add_definitions(-DQT_WEBKIT) +endif(QT_QTWEBKIT_FOUND) diff --git a/SuperBuild.cmake b/SuperBuild.cmake index 63bc212f3d..8bdd0035fd 100644 --- a/SuperBuild.cmake +++ b/SuperBuild.cmake @@ -1,413 +1,453 @@ #----------------------------------------------------------------------------- # Convenient macro allowing to download a file #----------------------------------------------------------------------------- macro(downloadFile url dest) file(DOWNLOAD ${url} ${dest} STATUS status) list(GET status 0 error_code) list(GET status 1 error_msg) if(error_code) message(FATAL_ERROR "error: Failed to download ${url} - ${error_msg}") endif() endmacro() #----------------------------------------------------------------------------- # MITK Prerequisites #----------------------------------------------------------------------------- if(UNIX AND NOT APPLE) include(mitkFunctionCheckPackageHeader) # Check for libxt-dev mitkFunctionCheckPackageHeader(StringDefs.h libxt-dev /usr/include/X11/) # Check for libtiff4-dev mitkFunctionCheckPackageHeader(tiff.h libtiff4-dev) # Check for libwrap0-dev mitkFunctionCheckPackageHeader(tcpd.h libwrap0-dev) endif() +#----------------------------------------------------------------------------- +# Qt options for external projects and MITK +#----------------------------------------------------------------------------- + +if(MITK_USE_QT) + set(qt_project_args -DDESIRED_QT_VERSION:STRING=${DESIRED_QT_VERSION}) +else() + set(qt_project_args ) +endif() + +if(MITK_USE_Qt4) + list(APPEND qt_project_args + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} ) +endif() +if(MITK_USE_Qt5) + find_program(QT_QMAKE_EXECUTABLE qmake) + if(NOT QT_QMAKE_EXECUTABLE) + message(FATAL_ERROR "Qt qmake executable not found.") + endif() + execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_VERSION + OUTPUT_VARIABLE _qt_version + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(_qt_version_minimum "5.0.0") + if(_qt_version VERSION_LESS _qt_version_minimum) + message(SEND_ERROR "Qt version ${_qt_version} too old. At least Qt ${_qt_version_minimum} is required") + endif() + execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PREFIX + OUTPUT_VARIABLE _qt_install_prefix + OUTPUT_STRIP_TRAILING_WHITESPACE) + file(TO_CMAKE_PATH "${_qt_install_prefix}" _qt_install_prefix) + list(APPEND qt_project_args + -DCMAKE_PREFIX_PATH:PATH=${_qt_install_prefix}) +endif() #----------------------------------------------------------------------------- # ExternalProjects #----------------------------------------------------------------------------- set(external_projects tinyxml GLUT ANN CppUnit GLEW VTK ACVD GDCM CableSwig OpenCV Poco ITK Boost DCMTK CTK SOFA MITKData Qwt - Qxt ) +# Qxt supports Qt5. We need to also support it in QxtCMakeLists.txt +if(MITK_USE_Qt4) + list(APPEND external_projects Qxt) +endif() + # These are "hard" dependencies and always set to ON set(MITK_USE_tinyxml 1) set(MITK_USE_ANN 1) set(MITK_USE_GLEW 1) set(MITK_USE_GDCM 1) set(MITK_USE_ITK 1) set(MITK_USE_VTK 1) # Semi-hard dependencies, enabled by user-controlled variables set(MITK_USE_CableSwig ${MITK_USE_Python}) if(MITK_USE_QT) set(MITK_USE_Qwt 1) - set(MITK_USE_Qxt 1) + if(MITK_USE_Qt4) + set(MITK_USE_Qxt 1) #TODO: Check how Qxt builds with Qt 5 + endif() endif() if(MITK_USE_BLUEBERRY) set(MITK_USE_CppUnit 1) endif() if(MITK_USE_SOFA) set(MITK_USE_GLUT 1) endif() # A list of "nice" external projects, playing well together with CMake set(nice_external_projects ${external_projects}) list(REMOVE_ITEM nice_external_projects Boost) foreach(proj ${nice_external_projects}) if(MITK_USE_${proj}) set(EXTERNAL_${proj}_DIR "${${proj}_DIR}" CACHE PATH "Path to ${proj} build directory") mark_as_advanced(EXTERNAL_${proj}_DIR) if(EXTERNAL_${proj}_DIR) set(${proj}_DIR ${EXTERNAL_${proj}_DIR}) endif() endif() endforeach() if(MITK_USE_Boost) set(EXTERNAL_BOOST_ROOT "${BOOST_ROOT}" CACHE PATH "Path to Boost directory") mark_as_advanced(EXTERNAL_BOOST_ROOT) if(EXTERNAL_BOOST_ROOT) set(BOOST_ROOT ${EXTERNAL_BOOST_ROOT}) endif() endif() if(BUILD_TESTING) set(EXTERNAL_MITK_DATA_DIR "${MITK_DATA_DIR}" CACHE PATH "Path to the MITK data directory") mark_as_advanced(EXTERNAL_MITK_DATA_DIR) if(EXTERNAL_MITK_DATA_DIR) set(MITK_DATA_DIR ${EXTERNAL_MITK_DATA_DIR}) endif() endif() # Look for git early on, if needed if((BUILD_TESTING AND NOT EXTERNAL_MITK_DATA_DIR) OR (MITK_USE_CTK AND NOT EXTERNAL_CTK_DIR)) find_package(Git REQUIRED) endif() #----------------------------------------------------------------------------- # External project settings #----------------------------------------------------------------------------- include(ExternalProject) set(ep_base "${CMAKE_BINARY_DIR}/CMakeExternals") set_property(DIRECTORY PROPERTY EP_BASE ${ep_base}) set(ep_install_dir ${ep_base}/Install) #set(ep_build_dir ${ep_base}/Build) set(ep_source_dir ${ep_base}/Source) #set(ep_parallelism_level) set(ep_build_shared_libs ON) set(ep_build_testing OFF) if(NOT MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL) set(MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL http://mitk.org/download/thirdparty) endif() # Compute -G arg for configuring external projects with the same CMake generator: if(CMAKE_EXTRA_GENERATOR) set(gen "${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") else() set(gen "${CMAKE_GENERATOR}") endif() # Use this value where semi-colons are needed in ep_add args: set(sep "^^") ## if(MSVC_VERSION) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj /MP") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /MP") endif() set(ep_common_args -DBUILD_TESTING:BOOL=${ep_build_testing} -DCMAKE_INSTALL_PREFIX:PATH=${ep_install_dir} -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} #debug flags -DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG} -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG} #release flags -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE} #relwithdebinfo -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO} #link flags -DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS} ) # Include external projects foreach(p ${external_projects}) include(CMakeExternals/${p}.cmake) endforeach() #----------------------------------------------------------------------------- # Set superbuild boolean args #----------------------------------------------------------------------------- set(mitk_cmake_boolean_args BUILD_SHARED_LIBS WITH_COVERAGE BUILD_TESTING MITK_USE_QT MITK_BUILD_ALL_PLUGINS MITK_BUILD_ALL_APPS MITK_BUILD_TUTORIAL # Deprecated. Use MITK_BUILD_EXAMPLES instead MITK_BUILD_EXAMPLES MITK_USE_ACVD MITK_USE_CppUnit MITK_USE_GLEW MITK_USE_Boost MITK_USE_SYSTEM_Boost MITK_USE_BLUEBERRY MITK_USE_CTK MITK_USE_DCMTK MITK_USE_OpenCV MITK_USE_Poco MITK_USE_SOFA MITK_USE_Python MITK_USE_OpenCL MITK_ENABLE_PIC_READER ) #----------------------------------------------------------------------------- # Create the final variable containing superbuild boolean args #----------------------------------------------------------------------------- set(mitk_superbuild_boolean_args) foreach(mitk_cmake_arg ${mitk_cmake_boolean_args}) list(APPEND mitk_superbuild_boolean_args -D${mitk_cmake_arg}:BOOL=${${mitk_cmake_arg}}) endforeach() if(MITK_BUILD_ALL_PLUGINS) list(APPEND mitk_superbuild_boolean_args -DBLUEBERRY_BUILD_ALL_PLUGINS:BOOL=ON) endif() #----------------------------------------------------------------------------- # MITK Utilities #----------------------------------------------------------------------------- set(proj MITK-Utilities) ExternalProject_Add(${proj} DOWNLOAD_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS # Mandatory dependencies ${tinyxml_DEPENDS} ${ANN_DEPENDS} ${VTK_DEPENDS} ${ITK_DEPENDS} # Optionnal dependencies ${ACVD_DEPENDS} ${CppUnit_DEPENDS} ${GLUT_DEPENDS} ${GLEW_DEPENDS} ${Boost_DEPENDS} ${CTK_DEPENDS} ${DCMTK_DEPENDS} ${OpenCV_DEPENDS} ${Poco_DEPENDS} ${SOFA_DEPENDS} ${MITK-Data_DEPENDS} ${Qwt_DEPENDS} ${Qxt_DEPENDS} ) #----------------------------------------------------------------------------- # Additional MITK CXX/C Flags #----------------------------------------------------------------------------- set(MITK_ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags for MITK") set(MITK_ADDITIONAL_C_FLAGS_RELEASE "" CACHE STRING "Additional Release C Flags for MITK") set(MITK_ADDITIONAL_C_FLAGS_DEBUG "" CACHE STRING "Additional Debug C Flags for MITK") mark_as_advanced(MITK_ADDITIONAL_C_FLAGS MITK_ADDITIONAL_C_FLAGS_DEBUG MITK_ADDITIONAL_C_FLAGS_RELEASE) set(MITK_ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags for MITK") set(MITK_ADDITIONAL_CXX_FLAGS_RELEASE "" CACHE STRING "Additional Release CXX Flags for MITK") set(MITK_ADDITIONAL_CXX_FLAGS_DEBUG "" CACHE STRING "Additional Debug CXX Flags for MITK") mark_as_advanced(MITK_ADDITIONAL_CXX_FLAGS MITK_ADDITIONAL_CXX_FLAGS_DEBUG MITK_ADDITIONAL_CXX_FLAGS_RELEASE) set(MITK_ADDITIONAL_EXE_LINKER_FLAGS "" CACHE STRING "Additional exe linker flags for MITK") set(MITK_ADDITIONAL_SHARED_LINKER_FLAGS "" CACHE STRING "Additional shared linker flags for MITK") set(MITK_ADDITIONAL_MODULE_LINKER_FLAGS "" CACHE STRING "Additional module linker flags for MITK") mark_as_advanced(MITK_ADDITIONAL_EXE_LINKER_FLAGS MITK_ADDITIONAL_SHARED_LINKER_FLAGS MITK_ADDITIONAL_MODULE_LINKER_FLAGS) #----------------------------------------------------------------------------- # MITK Configure #----------------------------------------------------------------------------- if(MITK_INITIAL_CACHE_FILE) set(mitk_initial_cache_arg -C "${MITK_INITIAL_CACHE_FILE}") endif() set(mitk_optional_cache_args ) foreach(type RUNTIME ARCHIVE LIBRARY) if(DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY) list(APPEND mitk_optional_cache_args -DCTK_PLUGIN_${type}_OUTPUT_DIRECTORY:PATH=${CTK_PLUGIN_${type}_OUTPUT_DIRECTORY}) endif() endforeach() + # Optional python variables if(MITK_USE_Python) list(APPEND mitk_optional_cache_args -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} -DPYTHON_INCLUDE_DIR2:PATH=${PYTHON_INCLUDE_DIR2} ) endif() set(proj MITK-Configure) ExternalProject_Add(${proj} LIST_SEPARATOR ^^ DOWNLOAD_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_CACHE_ARGS # --------------- Build options ---------------- -DBUILD_TESTING:BOOL=${ep_build_testing} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/MITK-build/install -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} # --------------- Compile options ---------------- -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} ${MITK_ADDITIONAL_C_FLAGS}" "-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} ${MITK_ADDITIONAL_CXX_FLAGS}" # debug flags "-DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG} ${MITK_ADDITIONAL_CXX_FLAGS_DEBUG}" "-DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG} ${MITK_ADDITIONAL_C_FLAGS_DEBUG}" # release flags "-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} ${MITK_ADDITIONAL_CXX_FLAGS_RELEASE}" "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE} ${MITK_ADDITIONAL_C_FLAGS_RELEASE}" # relwithdebinfo -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO} # link flags "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} ${MITK_ADDITIONAL_EXE_LINKER_FLAGS}" "-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} ${MITK_ADDITIONAL_SHARED_LINKER_FLAGS}" "-DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_MODULE_LINKER_FLAGS} ${MITK_ADDITIONAL_MODULE_LINKER_FLAGS}" # Output directories -DMITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY} -DMITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY} -DMITK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${MITK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY} # ------------- Boolean build options -------------- ${mitk_superbuild_boolean_args} ${mitk_optional_cache_args} -DMITK_USE_SUPERBUILD:BOOL=OFF -DCTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS} # ----------------- Miscellaneous --------------- -DMITK_CTEST_SCRIPT_MODE:STRING=${MITK_CTEST_SCRIPT_MODE} -DMITK_SUPERBUILD_BINARY_DIR:PATH=${MITK_BINARY_DIR} -DMITK_MODULES_TO_BUILD:INTERNAL=${MITK_MODULES_TO_BUILD} + ${qt_project_args} -DMITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES:STRING=${MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES} -DMITK_ACCESSBYITK_FLOATING_PIXEL_TYPES:STRING=${MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES} -DMITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES:STRING=${MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES} -DMITK_ACCESSBYITK_DIMENSIONS:STRING=${MITK_ACCESSBYITK_DIMENSIONS} # --------------- External project dirs --------------- - -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DMITK_KWSTYLE_EXECUTABLE:FILEPATH=${MITK_KWSTYLE_EXECUTABLE} -DCTK_DIR:PATH=${CTK_DIR} -DDCMTK_DIR:PATH=${DCMTK_DIR} -Dtinyxml_DIR:PATH=${tinyxml_DIR} -DGLUT_DIR:PATH=${GLUT_DIR} -DGLEW_DIR:PATH=${GLEW_DIR} -DANN_DIR:PATH=${ANN_DIR} -DCppUnit_DIR:PATH=${CppUnit_DIR} -DVTK_DIR:PATH=${VTK_DIR} # FindVTK expects VTK_DIR -DITK_DIR:PATH=${ITK_DIR} # FindITK expects ITK_DIR -DACVD_DIR:PATH=${ACVD_DIR} -DOpenCV_DIR:PATH=${OpenCV_DIR} -DPoco_DIR:PATH=${Poco_DIR} -DSOFA_DIR:PATH=${SOFA_DIR} -DGDCM_DIR:PATH=${GDCM_DIR} -DBOOST_ROOT:PATH=${BOOST_ROOT} -DMITK_USE_Boost_LIBRARIES:STRING=${MITK_USE_Boost_LIBRARIES} -DMITK_DATA_DIR:PATH=${MITK_DATA_DIR} -DQwt_DIR:PATH=${Qwt_DIR} -DQxt_DIR:PATH=${Qxt_DIR} CMAKE_ARGS ${mitk_initial_cache_arg} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} BINARY_DIR ${CMAKE_BINARY_DIR}/MITK-build BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS MITK-Utilities ) #----------------------------------------------------------------------------- # MITK #----------------------------------------------------------------------------- if(CMAKE_GENERATOR MATCHES ".*Makefiles.*") set(mitk_build_cmd "$(MAKE)") else() set(mitk_build_cmd ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/MITK-build --config ${CMAKE_CFG_INTDIR}) endif() if(NOT DEFINED SUPERBUILD_EXCLUDE_MITKBUILD_TARGET OR NOT SUPERBUILD_EXCLUDE_MITKBUILD_TARGET) set(MITKBUILD_TARGET_ALL_OPTION "ALL") else() set(MITKBUILD_TARGET_ALL_OPTION "") endif() add_custom_target(MITK-build ${MITKBUILD_TARGET_ALL_OPTION} COMMAND ${mitk_build_cmd} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/MITK-build DEPENDS MITK-Configure ) #----------------------------------------------------------------------------- # Custom target allowing to drive the build of the MITK project itself #----------------------------------------------------------------------------- add_custom_target(MITK COMMAND ${mitk_build_cmd} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/MITK-build ) diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 75c0cd5785..4004ea5de9 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -1,24 +1,26 @@ SUPPRESS_ALL_WARNINGS() # most stuff of these uses itk_zlib.h (via mitkIpPic.h) find_package(ITK) include(${ITK_USE_FILE}) # some legacy util files include in the old style with prefixed directory, # like #include include_directories(.) subdirs( ipPic ipFunc ipSegmentation mbilog qtsingleapplication KWStyle ) # mbilog is independent of mitk, and cant use mitk macros # configuring happens through mbilog/mbilogConfig.cmake.in set(mbilog_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/mbilog" "${CMAKE_CURRENT_BINARY_DIR}/mbilog") set(mbilog_CONFIG_FILE "${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME}/mbilogConfig.cmake" CACHE INTERNAL "Path to module config" FORCE) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mbilog/mbilogConfig.cmake.in" "${mbilog_CONFIG_FILE}") + +set_property(GLOBAL APPEND PROPERTY MITK_MODULE_TARGETS mbilog) diff --git a/Utilities/ipFunc/CMakeLists.txt b/Utilities/ipFunc/CMakeLists.txt index 4245d5c7a5..43e4dc59e6 100644 --- a/Utilities/ipFunc/CMakeLists.txt +++ b/Utilities/ipFunc/CMakeLists.txt @@ -1,46 +1,48 @@ -set(IPFUNC_FILES +set(IPFUNC_FILES AddC.c AddI.c AddSl.c And.c Border.c BorderX.c Box.c Box2d.c Box3d.c Canny.c Close.c CompressM.c Conv.c Convert.c CopyTags.c Curtosis.c CurtosisR.c Dila.c DivC.c DivI.c DrawPoly.c Equal.c Ero.c Error.c Exp.c ExtT.c ExtrC.c ExtrR.c ExtrROI.c Extrema.c FillArea.c Frame.c GaussF.c Grad.c Grav.c Hist.c Histo.c HitMiss.c HitMissI.c Inertia.c Inv.c LN.c Label.c Laplace.c LevWind.c Log.c MakePicName.c Malloc.c Mean.c MeanC.c MeanF.c MeanR.c MeanROI.c Median.c Morph.c MultC.c MultI.c Norm.c NormXY.c Not.c OpCl.c Open.c Or.c Pot.c Range.c Rank.c Refl.c RegGrow.c Roberts.c Rotate.c SDev.c SDevC.c SDevR.c SDevROI.c ScBl.c ScFact.c ScNN.c Scale.c SelInv.c SelMM.c Select.c SetErrno.c SetTag.c Shp.c Skewness.c SkewnessR.c Sobel.c Sqrt.c SubC.c SubI.c Thresh.c Transpose.c Var.c VarC.c VarR.c VarROI.c Window.c WindowR.c Xchange.c ZeroCr.c _BorderX.c _DrawPoly.c ipGetANew.c - ) + ) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ipPic) add_library(mitkIpFunc ${MITK_WIN32_FORCE_STATIC} ${IPFUNC_FILES}) target_link_libraries(mitkIpFunc mitkIpPic ) if(UNIX) target_link_libraries(mitkIpFunc m ) endif(UNIX) +set_property(GLOBAL APPEND PROPERTY MITK_MODULE_TARGETS mitkIpFunc) + MITK_CREATE_MODULE_CONF(mitkIpFunc INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS mitkIpPic ) diff --git a/Utilities/ipPic/CMakeLists.txt b/Utilities/ipPic/CMakeLists.txt index da54989652..41579ea041 100644 --- a/Utilities/ipPic/CMakeLists.txt +++ b/Utilities/ipPic/CMakeLists.txt @@ -1,31 +1,33 @@ find_package(ITK) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-DMITK_IPPIC_COMPILE) set(IPPIC_FILES - ipPicInfo.c ipPicType.c + ipPicInfo.c ipPicType.c ipPicAddT.c ipPicQueryT.c ipPicDelT.c ipPicGetT.c - ipPicOldGet.c ipPicOldGetH.c ipPicOldGetS.c - ipPicGet.c ipPicGetH.c ipPicGetS.c - ipPicPut.c ipPicPutS.c - ipPicGetMem.c ipPicPutMem.c - ipPicCopyS.c ipPicCopyH.c - ipPicNew.c ipPicClear.c ipPicFree.c ipPicClone.c - ipEndian.c ipFRead.c ipFWrite.c - ipError.c - ipPicSize.c ipPicElements.c + ipPicOldGet.c ipPicOldGetH.c ipPicOldGetS.c + ipPicGet.c ipPicGetH.c ipPicGetS.c + ipPicPut.c ipPicPutS.c + ipPicGetMem.c ipPicPutMem.c + ipPicCopyS.c ipPicCopyH.c + ipPicNew.c ipPicClear.c ipPicFree.c ipPicClone.c + ipEndian.c ipFRead.c ipFWrite.c + ipError.c + ipPicSize.c ipPicElements.c ipPicTSVSize.c ipPicTSVElements.c ) add_library(mitkIpPic ${MITK_WIN32_FORCE_STATIC} ${IPPIC_FILES}) if(USE_ITKZLIB) target_link_libraries(mitkIpPic itkzlib) else(USE_ITKZLIB) target_link_libraries(mitkIpPic z) endif(USE_ITKZLIB) MITK_CREATE_MODULE_CONF(mitkIpPic INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ) +set_property(GLOBAL APPEND PROPERTY MITK_MODULE_TARGETS mitkIpPic) + diff --git a/Utilities/qtsingleapplication/CMakeLists.txt b/Utilities/qtsingleapplication/CMakeLists.txt index fd206ea7c6..867e117802 100644 --- a/Utilities/qtsingleapplication/CMakeLists.txt +++ b/Utilities/qtsingleapplication/CMakeLists.txt @@ -1,37 +1,38 @@ -if(MITK_USE_QT) # only if MITK is built with Qt +if(MITK_USE_Qt4) # only if MITK is built with Qt 4 project(QtSingleApplication) set(_MOC_HEADERS qtlocalpeer.h qtsingleapplication.h qtsinglecoreapplication.h ) -set(_HEADERS +set(_HEADERS qthandlenewappinstance.h qtlockedfile.h ) set(_SOURCES qthandlenewappinstance.cpp qtlocalpeer.cpp qtsingleapplication.cpp qtsinglecoreapplication.cpp ) find_package(Qt4 REQUIRED) -set(QT_USE_QTNETWORKING 1) +set(QT_USE_QTNETWORK 1) include(${QT_USE_FILE}) qt4_wrap_cpp(_SOURCES ${_MOC_HEADERS}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_library(qtsingleapplication STATIC ${_SOURCES}) target_link_libraries(qtsingleapplication ${QT_LIBRARIES}) -MITK_CREATE_MODULE_CONF(qtsingleapplication) - -endif(MITK_USE_QT) # only if MITK is built with Qt +MITK_CREATE_MODULE_CONF(qtsingleapplication + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + QT4_MODULES QtNetwork) +endif(MITK_USE_Qt4) # only if MITK is built with Qt 4