diff --git a/CMake/PackageDepends/MITK_VTK_Config.cmake b/CMake/PackageDepends/MITK_VTK_Config.cmake index 33c599ce49..e81aee00b9 100644 --- a/CMake/PackageDepends/MITK_VTK_Config.cmake +++ b/CMake/PackageDepends/MITK_VTK_Config.cmake @@ -1,8 +1,12 @@ find_package(VTK COMPONENTS ${VTK_REQUIRED_COMPONENTS_BY_MODULE} 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() +if(MITK_USE_Qt5) + find_package(Qt5Widgets REQUIRED QUIET) +endif() + list(APPEND ALL_INCLUDE_DIRECTORIES ${VTK_INCLUDE_DIRS}) list(APPEND ALL_LIBRARIES ${VTK_LIBRARIES}) list(APPEND ALL_COMPILE_DEFINITIONS ${VTK_DEFINITIONS}) diff --git a/CMake/mitkFunctionUseModules.cmake b/CMake/mitkFunctionUseModules.cmake index c4def1f1e5..3a1845717b 100644 --- a/CMake/mitkFunctionUseModules.cmake +++ b/CMake/mitkFunctionUseModules.cmake @@ -1,185 +1,188 @@ function(_mitk_parse_package_args) set(packages ${ARGN}) set(PACKAGE_NAMES ) foreach(_package ${packages}) string(REPLACE "|" ";" _package_list ${_package}) if("${_package_list}" STREQUAL "${_package}") list(APPEND PACKAGE_NAMES ${_package}) else() list(GET _package_list 0 _package_name) list(GET _package_list 1 _package_components) if(NOT _package_name OR NOT _package_components) message(SEND_ERROR "PACKAGE argument syntax wrong. ${_package} is not of the form PACKAGE[|COMPONENT1[+COMPONENT2]...]") endif() list(APPEND PACKAGE_NAMES ${_package_name}) endif() endforeach() if(PACKAGE_NAMES) set(package_names_normalized ) list(REMOVE_DUPLICATES PACKAGE_NAMES) list(FIND PACKAGE_NAMES Qt4 _has_qt4_dep) list(FIND PACKAGE_NAMES Qt5 _has_qt5_dep) foreach(_package_name ${PACKAGE_NAMES}) set(${_package_name}_REQUIRED_COMPONENTS ) # Special filter for exclusive OR Qt4 / Qt5 dependency if(_package_name STREQUAL "Qt4") if(MITK_USE_Qt4 OR NOT MITK_USE_Qt5) # MITK_USE_Qt4 is ON or both MITK_USE_Qt4 and MITK_USE_Qt5 # are OFF. So list Qt4 as a dependency. list(APPEND package_names_normalized ${_package_name}) elseif(MITK_USE_Qt5 AND _has_qt5_dep EQUAL -1) # List Qt4 as a dependency only if there is no Qt5 dependency # so the module will not be build because of the missing # MITK_USE_Qt4 list(APPEND package_names_normalized ${_package_name}) endif() elseif(_package_name STREQUAL "Qt5") if(MITK_USE_Qt5 OR NOT MITK_USE_Qt4) list(APPEND package_names_normalized ${_package_name}) elseif(MITK_USE_Qt4 AND _has_qt4_dep EQUAL -1) list(APPEND package_names_normalized ${_package_name}) endif() else() list(APPEND package_names_normalized ${_package_name}) endif() endforeach() set(PACKAGE_NAMES ${package_names_normalized}) endif() foreach(_package ${packages}) string(REPLACE "|" ";" _package_list ${_package}) if(NOT "${_package_list}" STREQUAL "${_package}") list(GET _package_list 0 _package_name) list(GET _package_list 1 _package_components) string(REPLACE "+" ";" _package_components_list "${_package_components}") list(APPEND ${_package_name}_REQUIRED_COMPONENTS ${_package_components_list}) endif() endforeach() foreach(_package_name ${PACKAGE_NAMES}) if(${_package_name}_REQUIRED_COMPONENTS) list(REMOVE_DUPLICATES ${_package_name}_REQUIRED_COMPONENTS) endif() set(${_package_name}_REQUIRED_COMPONENTS ${${_package_name}_REQUIRED_COMPONENTS} PARENT_SCOPE) endforeach() set(PACKAGE_NAMES ${PACKAGE_NAMES} PARENT_SCOPE) endfunction() #! 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 or packages. #! #! A package argument is of the form #! #! PACKAGE[|COMPONENT1[+COMPONENT2]...] #! #! where PACKAGE is the package name (e.g. VTK) and components are #! the names of required package components or libraries. #! #! 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 ) 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_INCLUDE_DIRECTORIES) set(ALL_LIBRARIES) set(ALL_COMPILE_DEFINITIONS) set(ALL_META_DEPENDENCIES) set(depends ${USE_MODULES}) set(package_depends ${USE_PACKAGES}) # Get transitive MODULE and PACKAGE dependencies if(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 package_depends ${${dependency}_PACKAGE_DEPENDS}) list(APPEND depends ${${dependency}_DEPENDS}) endforeach() list(REMOVE_DUPLICATES depends) list(SORT depends) endwhile() # Iterate over all module dependencies foreach(dependency ${depends}) 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. list(FIND USE_MODULES ${dependency} _index) if(_index GREATER -1) message(WARNING "Module ${dependency} is deprecated since ${${dependency}_DEPRECATED_SINCE}") endif() endif() list(APPEND ALL_INCLUDE_DIRECTORIES ${${dependency}_INCLUDE_DIRS}) list(APPEND ALL_LIBRARIES ${${dependency}_TARGET}) if(TARGET ${dependency}-autoload) list(APPEND ALL_META_DEPENDENCIES ${dependency}-autoload) endif() endforeach() list(APPEND ALL_INCLUDE_DIRECTORIES ${MODULES_CONF_DIRS}) endif() # Parse package dependencies if(package_depends) _mitk_parse_package_args(${package_depends}) + # Some package config files like MITK_Qt5_Config.cmake rely on a + # properly set "MODULE_NAME" variable for the current target. + set(MODULE_NAME ${USE_TARGET}) # Read all package information foreach(_package ${PACKAGE_NAMES}) set(${_package}_REQUIRED_COMPONENTS_BY_MODULE ${${_package}_REQUIRED_COMPONENTS}) set(_package_found 0) foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) if((NOT DEFINED MITK_USE_${_package} OR MITK_USE_${_package}) AND EXISTS "${dir}/MITK_${_package}_Config.cmake") include("${dir}/MITK_${_package}_Config.cmake") set(_package_found 1) break() endif() endforeach() if(NOT _package_found) message(SEND_ERROR "Missing package: ${_package}") endif() endforeach() endif() if(ALL_INCLUDE_DIRECTORIES) include_directories(${ALL_INCLUDE_DIRECTORIES}) endif() if(ALL_COMPILE_DEFINITIONS) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${ALL_COMPILE_DEFINITIONS}) 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_META_DEPENDENCIES ${ALL_META_DEPENDENCIES} PARENT_SCOPE) endfunction() diff --git a/CMakeExternals/Qxt.cmake b/CMakeExternals/Qxt.cmake index 9a48121003..3e56c585ef 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 + URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/libqxt-3e7424f842d4.tar.gz + URL_MD5 a41a1e6d114cdabfc655f278176ca062 PATCH_COMMAND ${patch_cmd} INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} ${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/QxtCMakeLists.txt b/CMakeExternals/QxtCMakeLists.txt index e12c272714..c6d8c33ff9 100644 --- a/CMakeExternals/QxtCMakeLists.txt +++ b/CMakeExternals/QxtCMakeLists.txt @@ -1,480 +1,551 @@ - -cmake_minimum_required(VERSION 2.8.4) +if(DESIRED_QT_VERSION MATCHES 5) + cmake_minimum_required(VERSION 2.8.12) +else() + cmake_minimum_required(VERSION 2.8.4) +endif() project(Qxt) set(${PROJECT_NAME}_MAJOR_VERSION 0) set(${PROJECT_NAME}_MINOR_VERSION 6) -set(${PROJECT_NAME}_PATCH_VERSION 2) +set(${PROJECT_NAME}_PATCH_VERSION 99) set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}) -macro(QT4_GENERATE_MOCS) +macro(_qt_generate_mocs) foreach(file ${ARGN}) get_filename_component(source_path ${file} PATH) get_filename_component(source_name ${file} NAME_WE) get_filename_component(source_ext ${file} EXT) set(moc_file ${CMAKE_CURRENT_BINARY_DIR}/${source_path}/moc_${source_name}.cpp) - QT4_GENERATE_MOC(${file} ${moc_file}) + if(DESIRED_QT_VERSION MATCHES "4") + QT4_GENERATE_MOC(${file} ${moc_file}) + else() + qt5_generate_moc(${file} ${moc_file}) + endif() set_property(SOURCE ${source_path}/${source_name}.cpp APPEND PROPERTY OBJECT_DEPENDS ${moc_file}) endforeach() endmacro() +macro(_qt_wrap_cpp) + if(DESIRED_QT_VERSION MATCHES "4") + qt4_wrap_cpp(${ARGN}) + else() + qt5_wrap_cpp(${ARGN}) + endif() +endmacro() + +macro(_qt_add_resources) + if(DESIRED_QT_VERSION MATCHES "4") + qt4_add_resources(${ARGN}) + else() + qt5_add_resources(${ARGN}) + endif() +endmacro() + set(${PROJECT_NAME}_LIBRARIES QxtCore - QxtGui + QxtWidgets QxtNetwork QxtWeb ) set(QXT_CORE_MOC_HEADERS qxtabstractconnectionmanager.h qxtboundfunction.h qxtcsvmodel.h qxtdaemon.h qxtdeplex.h qxtdeplex_p.h qxtfifo.h qxtfilelock.h qxtjob.h qxtjob_p.h qxtlinesocket.h qxtlinesocket_p.h qxtlocale.h qxtlogger.h qxtlogger_p.h qxtmultisignalwaiter.h qxtnamespace.h qxtpipe.h qxtpipe_p.h qxtpointerlist.h qxtsignalgroup.h qxtsignalwaiter.h qxtslotjob.h qxtslotjob_p.h qxtstdio.h qxtstdio_p.h qxtstdstreambufdevice.h qxtrpcservice.h qxtrpcservice_p.h ) set(QXT_GUI_MOC_HEADERS qxtbasespinbox.h qxtcheckcombobox.h qxtcheckcombobox_p.h qxtconfigdialog.h qxtconfigdialog_p.h qxtconfigwidget.h qxtconfigwidget_p.h qxtconfirmationmessage.h qxtcountrycombobox.h qxtcountrycombobox_p.h qxtcountrymodel.h qxtcountrymodel_p.h qxtcrumbview.h qxtcrumbview_p.h qxtflowview.h qxtflowview_p.h qxtgroupbox.h qxtheaderview.h qxtitemdelegate.h qxtitemdelegate_p.h qxtlabel.h qxtletterboxwidget.h qxtletterboxwidget_p.h qxtlineedit.h qxtlistwidget.h qxtlistwidget_p.h qxtlanguagecombobox.h qxtlanguagecombobox_p.h qxtprogresslabel.h qxtproxystyle.h qxtpushbutton.h qxtspanslider.h qxtspanslider_p.h qxtstars.h qxtstringspinbox.h qxtstringvalidator.h qxttablewidget.h qxttablewidget_p.h qxttabwidget.h qxttabwidget_p.h qxttooltip_p.h qxttreewidget.h qxttreewidget_p.h qxtscheduleheaderwidget.h qxtscheduleitemdelegate.h qxtscheduleview.h qxtscheduleviewheadermodel_p.h qxtscheduleview_p.h qxtsortfilterproxymodel.h qxtfilterdialog.h qxtfilterdialog_p.h qxtlookuplineedit.h # !qws:!symbian - qxtapplication.h - qxtglobalshortcut.h + #qxtapplication.h + #qxtglobalshortcut.h ) set(QXT_NETWORK_MOC_HEADERS qxtjsonrpcclient.h qxtsmtp.h qxtrpcpeer.h qxtsmtp_p.h + qxtsslserver.h + qxtsslconnectionmanager.h qxttcpconnectionmanager.h qxttcpconnectionmanager_p.h qxtxmlrpcclient.h ) set(QXT_WEB_MOC_HEADERS qxtabstracthttpconnector.h qxtabstractwebservice.h qxtabstractwebsessionmanager.h qxtabstractwebsessionmanager_p.h qxthttpsessionmanager.h qxtwebcontent.h qxtwebservicedirectory.h qxtwebservicedirectory_p.h qxtwebslotservice.h qxtwebcgiservice.h qxtwebcgiservice_p.h ) set(QXT_NETWORK_MANUAL_MOC_HEADERS qxtjsonrpccall.h qxtxmlrpccall.h ) set(QXT_CORE_SOURCES qxtabstractconnectionmanager.cpp qxtabstractfileloggerengine.cpp qxtabstractiologgerengine.cpp qxtbasicfileloggerengine.cpp qxtbasicstdloggerengine.cpp qxtcommandoptions.cpp qxtcsvmodel.cpp qxtdaemon.cpp qxtdatastreamsignalserializer.cpp qxtdeplex.cpp qxterror.cpp qxtfifo.cpp qxtfilelock.cpp qxtglobal.cpp qxthmac.cpp qxtlocale.cpp qxtjson.cpp qxtjob.cpp qxtlinesocket.cpp qxtlinkedtree.cpp qxtlogger.cpp qxtloggerengine.cpp qxtlogstream.cpp qxtmetaobject.cpp qxtmodelserializer.cpp qxtmultisignalwaiter.cpp qxtnull.cpp qxtpipe.cpp qxtpointerlist.cpp qxtsignalgroup.cpp qxtsignalwaiter.cpp qxtslotjob.cpp qxtslotmapper.cpp qxtstdio.cpp qxtstdstreambufdevice.cpp qxttimer.cpp qxtrpcservice.cpp qxtxmlfileloggerengine.cpp ) set(QXT_GUI_SOURCES qxtbasespinbox.cpp qxtcheckcombobox.cpp qxtconfigdialog.cpp qxtconfigwidget.cpp qxtconfirmationmessage.cpp qxtcountrymodel.cpp qxtcountrycombobox.cpp qxtcrumbview.cpp qxtflowview.cpp qxtflowview_p.cpp qxtgroupbox.cpp qxtheaderview.cpp qxtitemdelegate.cpp qxtlabel.cpp qxtletterboxwidget.cpp qxtlineedit.cpp qxtlistwidget.cpp qxtlistwidgetitem.cpp qxtlanguagecombobox.cpp qxtprogresslabel.cpp qxtproxystyle.cpp qxtpushbutton.cpp qxtspanslider.cpp qxtstars.cpp qxtstringspinbox.cpp qxtstringvalidator.cpp qxttablewidget.cpp qxttablewidgetitem.cpp qxttabwidget.cpp qxttooltip.cpp qxttreewidget.cpp qxttreewidgetitem.cpp qxtscheduleitemdelegate.cpp qxtscheduleview.cpp qxtscheduleview_p.cpp qxtscheduleviewheadermodel_p.cpp qxtstyleoptionscheduleviewitem.cpp qxtscheduleheaderwidget.cpp qxtsortfilterproxymodel.cpp qxtfilterdialog.cpp qxtlookuplineedit.cpp # !qws:!symbian - qxtapplication.cpp - qxtglobalshortcut.cpp + #qxtapplication.cpp + #qxtglobalshortcut.cpp ) set(QXT_NETWORK_SOURCES qxtjsonrpccall.cpp qxtjsonrpcclient.cpp qxtmailattachment.cpp qxtmailmessage.cpp qxtrpcpeer.cpp qxtsmtp.cpp + qxtsslserver.cpp + qxtsslconnectionmanager.cpp qxttcpconnectionmanager.cpp qxtxmlrpccall.cpp qxtxmlrpcclient.cpp qxtxmlrpc_p.cpp ) set(QXT_WEB_SOURCES qxtabstracthttpconnector.cpp qxtabstractwebservice.cpp qxtabstractwebsessionmanager.cpp qxthtmltemplate.cpp qxthttpserverconnector.cpp qxthttpsessionmanager.cpp qxtscgiserverconnector.cpp qxtwebcontent.cpp qxtwebevent.cpp qxtwebservicedirectory.cpp qxtwebslotservice.cpp qxtwebcgiservice.cpp ) if(UNIX) - list(APPEND QXT_CORE_MOC_HEADERS qxtserialdevice.h qxtserialdevice_p.h) + list(APPEND QXT_CORE_MOC_HEADERS unix/qxtserialdevice.h unix/qxtserialdevice_p.h) list(APPEND QXT_CORE_SOURCES - qxtfilelock_unix.cpp qxtserialdevice.cpp qxtserialdevice_unix.cpp) + unix/qxtfilelock_unix.cpp unix/qxtserialdevice.cpp unix/qxtserialdevice_unix.cpp) if(APPLE) list(APPEND QXT_GUI_SOURCES - qxtapplication_mac.cpp qxtglobalshortcut_mac.cpp) + #mac/qxtapplication_mac.cpp + #mac/qxtglobalshortcut_mac.cpp + ) else() + if(DESIRED_QT_VERSION MATCHES "5") + find_package(Qt5X11Extras REQUIRED) + endif() list(APPEND QXT_GUI_SOURCES - qxtapplication_x11.cpp qxtglobalshortcut_x11.cpp - qxtscreen_x11.cpp qxtwindowsystem_x11.cpp) + #x11/qxtapplication_x11.cpp + #x11/qxtglobalshortcut_x11.cpp + x11/qxtscreen_x11.cpp + #x11/qxtwindowsystem_x11.cpp + ) endif() endif() if(NOT APPLE) - list(APPEND QXT_GUI_SOURCES qxtscreen.cpp qxtwindowsystem.cpp) + list(APPEND QXT_GUI_SOURCES + qxtscreen.cpp + #qxtwindowsystem.cpp + ) endif() if(WIN32) - list(APPEND QXT_CORE_SOURCES qxtfilelock_win.cpp) + list(APPEND QXT_CORE_SOURCES win/qxtfilelock_win.cpp) list(APPEND QXT_GUI_SOURCES - qxtapplication_win.cpp qxtglobalshortcut_win.cpp - qxtscreen_win.cpp qxtwindowsystem_win.cpp) + #win/qxtapplication_win.cpp + #win/qxtglobalshortcut_win.cpp + win/qxtscreen_win.cpp + #win/qxtwindowsystem_win.cpp + ) endif() set(_qxt_core_moc_headers ) foreach(_header ${QXT_CORE_MOC_HEADERS}) list(APPEND _qxt_core_moc_headers src/core/${_header}) endforeach() set(_qxt_gui_moc_headers ) foreach(_header ${QXT_GUI_MOC_HEADERS}) - list(APPEND _qxt_gui_moc_headers src/gui/${_header}) + list(APPEND _qxt_gui_moc_headers src/widgets/${_header}) endforeach() set(_qxt_network_moc_headers ) foreach(_header ${QXT_NETWORK_MOC_HEADERS}) list(APPEND _qxt_network_moc_headers src/network/${_header}) endforeach() set(_qxt_network_manual_moc_headers ) foreach(_header ${QXT_NETWORK_MANUAL_MOC_HEADERS}) list(APPEND _qxt_network_manual_moc_headers src/network/${_header}) endforeach() set(_qxt_web_moc_headers ) foreach(_header ${QXT_WEB_MOC_HEADERS}) list(APPEND _qxt_web_moc_headers src/web/${_header}) endforeach() set(_qxt_core_sources ) foreach(_source ${QXT_CORE_SOURCES}) list(APPEND _qxt_core_sources src/core/${_source}) endforeach() set(_qxt_gui_sources ) foreach(_source ${QXT_GUI_SOURCES}) - list(APPEND _qxt_gui_sources src/gui/${_source}) + list(APPEND _qxt_gui_sources src/widgets/${_source}) endforeach() set(_qxt_network_sources ) foreach(_source ${QXT_NETWORK_SOURCES}) list(APPEND _qxt_network_sources src/network/${_source}) endforeach() set(_qxt_web_sources ) foreach(_source ${QXT_WEB_SOURCES}) list(APPEND _qxt_web_sources src/web/${_source}) endforeach() -set(_qxt_gui_resources src/gui/resources.qrc) +set(_qxt_gui_resources src/widgets/resources.qrc) set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/core ${CMAKE_CURRENT_SOURCE_DIR}/include/QxtCore - ${CMAKE_CURRENT_SOURCE_DIR}/src/gui - ${CMAKE_CURRENT_SOURCE_DIR}/include/QxtGui + ${CMAKE_CURRENT_SOURCE_DIR}/src/widgets + ${CMAKE_CURRENT_SOURCE_DIR}/include/QxtWidgets ${CMAKE_CURRENT_SOURCE_DIR}/src/network ${CMAKE_CURRENT_SOURCE_DIR}/include/QxtNetwork ${CMAKE_CURRENT_SOURCE_DIR}/src/web ${CMAKE_CURRENT_SOURCE_DIR}/include/QxtWeb ) include_directories(${${PROJECT_NAME}_INCLUDE_DIRS}) -find_package(Qt4 REQUIRED) - -set(QT_USE_QTNETWORK 1) -set(QT_USE_QTDESIGNER 1) -include(${QT_USE_FILE}) +if(DESIRED_QT_VERSION MATCHES "4") + find_package(Qt4 REQUIRED) + set(QT_USE_QTNETWORK 1) + set(QT_USE_QTDESIGNER 1) + include(${QT_USE_FILE}) +else() + if (WIN32) + cmake_policy(SET CMP0020 NEW) # Automatically link Qt executables to qtmain target on Windows + endif() + find_package(Qt5 COMPONENTS Network Designer Widgets REQUIRED) +endif() # Build the QxtCore library -qt4_wrap_cpp(_qxt_core_sources ${_qxt_core_moc_headers}) +_qt_wrap_cpp(_qxt_core_sources ${_qxt_core_moc_headers}) add_library(QxtCore SHARED ${_qxt_core_sources}) -target_link_libraries(QxtCore ${QT_LIBRARIES}) +if(DESIRED_QT_VERSION MATCHES "4") + target_link_libraries(QxtCore ${QT_LIBRARIES}) +else() + target_link_libraries(QxtCore Qt5::Core) +endif() set_target_properties(QxtCore PROPERTIES SOVERSION ${${PROJECT_NAME}_VERSION} COMPILE_DEFINITIONS "BUILD_QXT_CORE") -# Build the QxtGui library -qt4_wrap_cpp(_qxt_gui_sources ${_qxt_gui_moc_headers}) -qt4_add_resources(_qxt_gui_sources ${_qxt_gui_resources}) +# Build the QxtWidgets (formerly QxtGui) library +_qt_wrap_cpp(_qxt_gui_sources ${_qxt_gui_moc_headers}) +_qt_add_resources(_qxt_gui_sources ${_qxt_gui_resources}) -set(QxtGui_link_libraries ${QT_LIBRARIES}) +if(DESIRED_QT_VERSION MATCHES "4") + set(QxtGui_link_libraries ${QT_LIBRARIES}) +else() + set(QxtGui_link_libraries Qt5::Widgets) + if(UNIX AND NOT APPLE) + list(APPEND QxtGui_link_libraries Qt5::X11Extras) + endif() +endif() if(APPLE) find_library(CARBON_FW NAMES Carbon) list(APPEND QxtGui_link_libraries ${CARBON_FW}) endif() -add_library(QxtGui SHARED ${_qxt_gui_sources}) -target_link_libraries(QxtGui QxtCore ${QxtGui_link_libraries}) +add_library(QxtWidgets SHARED ${_qxt_gui_sources}) +target_link_libraries(QxtWidgets QxtCore ${QxtGui_link_libraries}) -set_target_properties(QxtGui PROPERTIES +set_target_properties(QxtWidgets PROPERTIES SOVERSION ${${PROJECT_NAME}_VERSION} COMPILE_DEFINITIONS "BUILD_QXT_GUI") # Build the QxtNetwork library -qt4_wrap_cpp(_qxt_network_sources ${_qxt_network_moc_headers}) -qt4_add_resources(_qxt_network_sources ${_qxt_network_resources}) +_qt_wrap_cpp(_qxt_network_sources ${_qxt_network_moc_headers}) +_qt_add_resources(_qxt_network_sources ${_qxt_network_resources}) # The generate moc_* sources are included directly in .cpp files -QT4_GENERATE_MOCS(${_qxt_network_manual_moc_headers}) +_qt_generate_mocs(${_qxt_network_manual_moc_headers}) include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/network) add_library(QxtNetwork SHARED ${_qxt_network_sources}) -target_link_libraries(QxtNetwork QxtCore ${QT_LIBRARIES}) +if(DESIRED_QT_VERSION MATCHES "4") + target_link_libraries(QxtNetwork QxtCore ${QT_LIBRARIES}) +else() + target_link_libraries(QxtNetwork Qt5::Network) +endif() set_target_properties(QxtNetwork PROPERTIES SOVERSION ${${PROJECT_NAME}_VERSION} COMPILE_DEFINITIONS "BUILD_QXT_NETWORK") # Build the QxtWeb library -qt4_wrap_cpp(_qxt_web_sources ${_qxt_web_moc_headers}) +_qt_wrap_cpp(_qxt_web_sources ${_qxt_web_moc_headers}) add_library(QxtWeb SHARED ${_qxt_web_sources}) target_link_libraries(QxtWeb QxtCore QxtNetwork ${QT_LIBRARIES}) set_target_properties(QxtWeb PROPERTIES SOVERSION ${${PROJECT_NAME}_VERSION} COMPILE_DEFINITIONS "BUILD_QXT_WEB") # Build the designer plug-in set(_qxt_designer_sources src/designer/qxtbasespinboxplugin.cpp src/designer/qxtcheckcomboboxplugin.cpp src/designer/qxtcountrycomboboxplugin.cpp src/designer/qxtdesignerplugin.cpp src/designer/qxtdesignerplugins.cpp src/designer/qxtflowviewplugin.cpp src/designer/qxtgroupboxplugin.cpp src/designer/qxtlabelplugin.cpp src/designer/qxtlanguagecomboboxplugin.cpp src/designer/qxtletterboxwidgetplugin.cpp src/designer/qxtlineeditplugin.cpp src/designer/qxtlistwidgetplugin.cpp src/designer/qxtprogresslabelplugin.cpp src/designer/qxtpushbuttonplugin.cpp src/designer/qxtspansliderplugin.cpp src/designer/qxtstarsplugin.cpp src/designer/qxtstringspinboxplugin.cpp src/designer/qxttablewidgetplugin.cpp src/designer/qxttreewidgetplugin.cpp ) -qt4_wrap_cpp(_qxt_designer_sources +set(wrap_cpp_options ) +if(DESIRED_QT_VERSION MATCHES "5") + list(APPEND wrap_cpp_options TARGET QxtDesignerPlugins) +endif() + +_qt_wrap_cpp(_qxt_designer_sources src/designer/qxtbasespinboxplugin.h src/designer/qxtcheckcomboboxplugin.h src/designer/qxtcountrycomboboxplugin.h src/designer/qxtdesignerplugins.h src/designer/qxtflowviewplugin.h src/designer/qxtgroupboxplugin.h src/designer/qxtlabelplugin.h src/designer/qxtlanguagecomboboxplugin.h src/designer/qxtletterboxwidgetplugin.h src/designer/qxtlineeditplugin.h src/designer/qxtlistwidgetplugin.h src/designer/qxtprogresslabelplugin.h src/designer/qxtpushbuttonplugin.h src/designer/qxtspansliderplugin.h src/designer/qxtstarsplugin.h src/designer/qxtstringspinboxplugin.h src/designer/qxttablewidgetplugin.h src/designer/qxttreewidgetplugin.h - + ${wrap_cpp_options} ) -qt4_add_resources(_qxt_designer_sources src/designer/resources.qrc) +_qt_add_resources(_qxt_designer_sources src/designer/resources.qrc) add_library(QxtDesignerPlugins SHARED ${_qxt_designer_sources}) -target_link_libraries(QxtDesignerPlugins QxtGui QxtCore ${QT_LIBRARIES}) +if(DESIRED_QT_VERSION MATCHES "4") + target_link_libraries(QxtDesignerPlugins QxtWidgets QxtCore ${QT_LIBRARIES}) +else() + target_link_libraries(QxtDesignerPlugins QxtWidgets QxtCore Qt5::Designer) +endif() set_target_properties(QxtDesignerPlugins PROPERTIES SOVERSION ${${PROJECT_NAME}_VERSION} COMPILE_DEFINITIONS BUILD_QXT_DESIGNER) # Config files configure_file(${PROJECT_NAME}Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake @ONLY) export(TARGETS ${Qxt_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/VTK.cmake b/CMakeExternals/VTK.cmake index b506779371..a3ef5f7bd6 100644 --- a/CMakeExternals/VTK.cmake +++ b/CMakeExternals/VTK.cmake @@ -1,99 +1,94 @@ #----------------------------------------------------------------------------- # 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) - 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} - -DModule_vtkGUISupportQt:BOOL=ON - -DModule_vtkGUISupportQtWebkit:BOOL=ON - -DModule_vtkGUISupportQtSQL:BOOL=ON - -DModule_vtkRenderingQt:BOOL=ON - -DVTK_Group_Qt:BOOL=ON - ) - endif() + list(APPEND additional_cmake_args + -DVTK_QT_VERSION:STRING=${DESIRED_QT_VERSION} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + -DModule_vtkGUISupportQt:BOOL=ON + -DModule_vtkGUISupportQtWebkit:BOOL=ON + -DModule_vtkGUISupportQtSQL:BOOL=ON + -DModule_vtkRenderingQt:BOOL=ON + -DVTK_Group_Qt:BOOL=ON + ) endif() set(VTK_URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/VTK-6.1.0.tar.gz) set(VTK_URL_MD5 25e4dfb3bad778722dcaec80cd5dab7d) 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_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 -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 b69ca79eb2..02645197da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,1045 +1,1052 @@ -cmake_minimum_required(VERSION 2.8.9) +set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 4 or 5") +if(DESIRED_QT_VERSION MATCHES "4") + cmake_minimum_required(VERSION 2.8.9) +else() + cmake_minimum_required(VERSION 2.8.12) +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_CMAKE_DIR} ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) include(mitkFunctionSuppressWarnings) include(mitkFunctionEnableBuildConfiguration) include(FeatureSummary) 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) macro(env_option name doc value) set(_value $ENV{${name}}) if("${_value}" STREQUAL "") set(_value ${value}) endif() option(${name} "${doc}" ${_value}) endmacro() # ----------------------------------------- # Qt version related variables env_option(MITK_USE_QT "Use Nokia's Qt library" ON) -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}) if(MITK_USE_QT) # find the package at the very beginning, so that QT4_FOUND is available if(DESIRED_QT_VERSION MATCHES 4) set(MITK_QT4_MINIMUM_VERSION 4.7) find_package(Qt4 ${MITK_QT4_MINIMUM_VERSION} REQUIRED) set(MITK_USE_Qt4 TRUE) set(MITK_USE_Qt5 FALSE) - endif(DESIRED_QT_VERSION MATCHES 4) + endif() if(DESIRED_QT_VERSION MATCHES 5) set(MITK_QT5_MINIMUM_VERSION 5.0.0) set(MITK_USE_Qt4 FALSE) set(MITK_USE_Qt5 TRUE) - endif(DESIRED_QT_VERSION MATCHES 5) + set(QT5_INSTALL_PREFIX "" CACHE PATH "The install location of Qt5") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT5_INSTALL_PREFIX}) + find_package(Qt5Core ${MITK_QT5_MINIMUM_VERSION} REQUIRED) + endif() else() set(MITK_USE_Qt4 FALSE) set(MITK_USE_Qt5 FALSE) endif() # ----------------------------------------- # MITK_USE_* build variables env_option(MITK_BUILD_ALL_APPS "Build all MITK applications" OFF) set(MITK_BUILD_TUTORIAL OFF CACHE INTERNAL "Deprecated! Use MITK_BUILD_EXAMPLES instead!") env_option(MITK_BUILD_EXAMPLES "Build the MITK Examples" ${MITK_BUILD_TUTORIAL}) env_option(MITK_USE_ACVD "Use Approximated Centroidal Voronoi Diagrams" OFF) env_option(MITK_USE_CppUnit "Use CppUnit for unit tests" ON) if(BUILD_TESTING AND NOT MITK_USE_CppUnit) message("> Forcing MITK_USE_CppUnit to ON because BUILD_TESTING=ON") set(MITK_USE_CppUnit ON CACHE BOOL "Use CppUnit for unit tests" FORCE) endif() env_option(MITK_USE_GLEW "Use the GLEW library" ON) env_option(MITK_USE_Boost "Use the Boost C++ library" OFF) env_option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ${MITK_USE_Qt4}) env_option(MITK_USE_CTK "Use CTK in MITK" ${MITK_USE_Qt4}) env_option(MITK_USE_DCMTK "EXPERIMENTAL, superbuild only: Use DCMTK in MITK" ${MITK_USE_CTK}) env_option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) env_option(MITK_USE_OpenCL "Use OpenCL GPU-Computing library" OFF) env_option(MITK_USE_Poco "Use the Poco library" ON) env_option(MITK_USE_SOFA "Use Simulation Open Framework Architecture" OFF) env_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) set(MITK_BUILD_CONFIGURATION "Custom" CACHE STRING "Use pre-defined MITK configurations") set_property(CACHE MITK_BUILD_CONFIGURATION PROPERTY STRINGS Custom Default All) mitkFunctionEnableBuildConfiguration() mark_as_advanced(MITK_BUILD_ALL_APPS MITK_USE_CppUnit MITK_USE_GLEW MITK_USE_CTK MITK_USE_DCMTK MITK_ENABLE_PIC_READER MITK_BUILD_CONFIGURATION ) 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 AND NOT MITK_USE_Qt4) message("> Forcing MITK_USE_BLUEBERRY to OFF because Qt4 is not used.") set(MITK_USE_BLUEBERRY OFF CACHE BOOL "Build the BlueBerry application platform" FORCE) endif() if(MITK_USE_CTK AND NOT MITK_USE_Qt4) message("> Forcing MITK_USE_CTK to OFF because Qt4 is not used.") set(MITK_USE_CTK OFF CACHE BOOL "Use CTK in MITK" FORCE) endif() if(MITK_USE_BLUEBERRY) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) mark_as_advanced(MITK_BUILD_ALL_PLUGINS) if(NOT MITK_USE_CTK) message("> Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY") set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE) endif() endif() if(MITK_USE_CTK AND NOT MITK_USE_DCMTK) message("> Forcing MITK_USE_DCMTK to ON because of MITK_USE_CTK") set(MITK_USE_DCMTK ON CACHE BOOL "Use DCMTK in MITK" FORCE) 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/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) # Allow setting external SOFA plugins directory and SOFA plugins set(MITK_USE_SOFA_PLUGINS_DIR ${MITK_USE_SOFA_PLUGINS_DIR} CACHE PATH "External SOFA plugins directory" FORCE) set(MITK_USE_SOFA_PLUGINS ${MITK_USE_SOFA_PLUGINS} CACHE PATH "List of semicolon-separated plugin names" 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") # Print configuration summary message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL) return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(WriteBasicConfigVersionFile) 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(mitkFunctionCheckModuleDependencies) include(mitkFunctionCreateModule) include(mitkMacroCreateExecutable) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) include(mitkMacroGetPMDPlatformString) #----------------------------------------------------------------------------- # 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} Mitk${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 ) 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 # the following line should be removed after fixing bug 17637 mitkFunctionCheckCompilerFlags("/wd4316" MITK_CXX_FLAGS) # warning C4316: object alignment on heap 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 AND NOT APPLE) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS) mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS) endif() if(CMAKE_COMPILER_IS_GNUCXX) 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}) #----------------------------------------------------------------------------- # 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 #----------------------------------------------------------------------------- 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() 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 #----------------------------------------------------------------------------- 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) write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${MITK_VERSION_STRING} COMPATIBILITY AnyNewerVersion) # 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() #----------------------------------------------------------------------------- # Print configuration summary #----------------------------------------------------------------------------- message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL ) diff --git a/Examples/QuickRender/main.cpp b/Examples/QuickRender/main.cpp index 335ded0938..38e49783f3 100644 --- a/Examples/QuickRender/main.cpp +++ b/Examples/QuickRender/main.cpp @@ -1,113 +1,114 @@ #include "QmlMitkFourRenderWindowWidget.h" #include #include #include "mitkStandaloneDataStorage.h" #include "mitkDataNodeFactory.h" #include "mitkGlobalInteraction.h" +#include "mitkImage.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/Modules/OpenViewCore/CMakeLists.txt b/Modules/OpenViewCore/CMakeLists.txt index c1a6dcefcb..8c78eff114 100644 --- a/Modules/OpenViewCore/CMakeLists.txt +++ b/Modules/OpenViewCore/CMakeLists.txt @@ -1,5 +1,4 @@ MITK_CREATE_MODULE( - PACKAGE_DEPENDS Qt5|Core+Quick VTK OpenGL - EXPORT_DEFINE OVCORE_EXPORT + PACKAGE_DEPENDS Qt5|Core+Quick VTK|vtkGUISupportQt OpenGL ) diff --git a/Modules/OpenViewCore/QVTKInteractor.h b/Modules/OpenViewCore/QVTKInteractor.h index a74e1c5c18..e1bb0291d1 100644 --- a/Modules/OpenViewCore/QVTKInteractor.h +++ b/Modules/OpenViewCore/QVTKInteractor.h @@ -1,140 +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 class QVTKInteractorInternal; // .NAME QVTKInteractor - An interactor for the QVTKWidget. // .SECTION Description // QVTKInteractor is an interactor for a QVTKWiget. -class MitkOVCORE_EXPORT QVTKInteractor : public vtkRenderWindowInteractor +class MitkOpenViewCore_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.h b/Modules/OpenViewCore/QVTKInteractorAdapter.h index 80b5f9a943..2c472eadaa 100644 --- a/Modules/OpenViewCore/QVTKInteractorAdapter.h +++ b/Modules/OpenViewCore/QVTKInteractorAdapter.h @@ -1,68 +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 class vtkRenderWindowInteractor; class QEvent; // .NAME QVTKInteractorAdapter - A QEvent translator. // .SECTION Description // QVTKInteractorAdapter translates QEvents and send them to a // vtkRenderWindowInteractor. -class MitkOVCORE_EXPORT QVTKInteractorAdapter : public QObject +class MitkOpenViewCore_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/QVTKQuickItem.h b/Modules/OpenViewCore/QVTKQuickItem.h index 818a0e30ca..7b4614410a 100644 --- a/Modules/OpenViewCore/QVTKQuickItem.h +++ b/Modules/OpenViewCore/QVTKQuickItem.h @@ -1,108 +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 class QOpenGLContext; class QOpenGLFramebufferObject; class QVTKInteractorAdapter; class QVTKInteractor; class vtkEventQtSlotConnect; class vtkGenericOpenGLRenderWindow; class vtkObject; class vtkContextView; -class MitkOVCORE_EXPORT QVTKQuickItem : public QQuickItem +class MitkOpenViewCore_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/vtkEventQtSlotConnect.h b/Modules/OpenViewCore/vtkEventQtSlotConnect.h index b5d9904625..ce007d427b 100644 --- a/Modules/OpenViewCore/vtkEventQtSlotConnect.h +++ b/Modules/OpenViewCore/vtkEventQtSlotConnect.h @@ -1,103 +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 class QObject; class vtkQtConnections; class vtkQtConnection; // manage connections between VTK object events and Qt slots -class MitkOVCORE_EXPORT vtkEventQtSlotConnect : public vtkObject +class MitkOpenViewCore_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.h b/Modules/OpenViewCore/vtkQtConnection.h index 2569c7f3b2..1fc88c03ba 100644 --- a/Modules/OpenViewCore/vtkQtConnection.h +++ b/Modules/OpenViewCore/vtkQtConnection.h @@ -1,104 +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 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 MitkOVCORE_EXPORT vtkQtConnection : public QObject +class MitkOpenViewCore_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/QmlItems/InteractionLegacy/QmitkEventAdapter.h b/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.h index ac9c63362f..537ccfcbf9 100644 --- a/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.h +++ b/Modules/QmlItems/InteractionLegacy/QmitkEventAdapter.h @@ -1,44 +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 #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 +class MitkQmlItems_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/QmlItems/QmlMitkBigRenderLock.h b/Modules/QmlItems/QmlMitkBigRenderLock.h index 3a4bd52aaa..b4a36019b2 100644 --- a/Modules/QmlItems/QmlMitkBigRenderLock.h +++ b/Modules/QmlItems/QmlMitkBigRenderLock.h @@ -1,33 +1,33 @@ #ifndef QmlMitkBigRenderLock_h #define QmlMitkBigRenderLock_h #include -#include "QmlMitkExports.h" +#include "MitkQmlItemsExports.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 +class MitkQmlItems_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/QmlItems/QmlMitkFourRenderWindowWidget.h b/Modules/QmlItems/QmlMitkFourRenderWindowWidget.h index 5082536363..4fef3c2333 100644 --- a/Modules/QmlItems/QmlMitkFourRenderWindowWidget.h +++ b/Modules/QmlItems/QmlMitkFourRenderWindowWidget.h @@ -1,58 +1,58 @@ #ifndef QmlMitkFourRenderWindowWidget_h #define QmlMitkFourRenderWindowWidget_h #include #include "QmlMitkRenderWindowItem.h" #include "mitkDataStorage.h" -#include "QmlMitkCoreExports.h" +#include "MitkQmlItemsExports.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 +class MitkQmlItems_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/QmlItems/QmlMitkRenderWindowItem.cpp b/Modules/QmlItems/QmlMitkRenderWindowItem.cpp index 0f96ef6647..e5b6a2c3d7 100644 --- a/Modules/QmlItems/QmlMitkRenderWindowItem.cpp +++ b/Modules/QmlItems/QmlMitkRenderWindowItem.cpp @@ -1,397 +1,405 @@ /**************************************************************************** ** ** 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::Point2D mousePosition = GetMousePosition(me); + mitk::Point3D worldPosition = mitk::RenderWindowBase::GetRenderer()->Map2DRendererPositionTo3DWorldPosition(mousePosition); mitk::MousePressEvent::Pointer mPressEvent = - mitk::MousePressEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(me), GetButtonState(me), GetModifiers(me), GetEventButton(me)); + mitk::MousePressEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, worldPosition, 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::Point2D mousePosition = GetMousePosition(me); + mitk::Point3D worldPosition = mitk::RenderWindowBase::GetRenderer()->Map2DRendererPositionTo3DWorldPosition(mousePosition); mitk::MouseReleaseEvent::Pointer mReleaseEvent = - mitk::MouseReleaseEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(me), GetButtonState(me), GetModifiers(me), GetEventButton(me)); + mitk::MouseReleaseEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, worldPosition, 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::Point2D mousePosition = GetMousePosition(me); + mitk::Point3D worldPosition = mitk::RenderWindowBase::GetRenderer()->Map2DRendererPositionTo3DWorldPosition(mousePosition); mitk::MouseMoveEvent::Pointer mMoveEvent = - mitk::MouseMoveEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(me), GetButtonState(me), GetModifiers(me)); + mitk::MouseMoveEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, worldPosition, 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::Point2D mousePosition = GetMousePosition(we); + mitk::Point3D worldPosition = mitk::RenderWindowBase::GetRenderer()->Map2DRendererPositionTo3DWorldPosition(mousePosition); mitk::MouseWheelEvent::Pointer mWheelEvent = - mitk::MouseWheelEvent::New(mitk::RenderWindowBase::GetRenderer(), GetMousePosition(we), GetButtonState(we), GetModifiers(we), we->delta()); + mitk::MouseWheelEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, worldPosition, 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/QmlItems/QmlMitkRenderWindowItem.h b/Modules/QmlItems/QmlMitkRenderWindowItem.h index 435292d0ef..67e6328b83 100644 --- a/Modules/QmlItems/QmlMitkRenderWindowItem.h +++ b/Modules/QmlItems/QmlMitkRenderWindowItem.h @@ -1,87 +1,87 @@ #ifndef QmlMitkRenderWindowItem_h #define QmlMitkRenderWindowItem_h #include #include "mitkRenderWindowBase.h" #include -#include "QmlMitkExports.h" +#include "MitkQmlItemsExports.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 +class MitkQmlItems_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/QmlItems/QmlMitkRenderingManager.h b/Modules/QmlItems/QmlMitkRenderingManager.h index fd5eac1599..a23f1b0bed 100644 --- a/Modules/QmlItems/QmlMitkRenderingManager.h +++ b/Modules/QmlItems/QmlMitkRenderingManager.h @@ -1,85 +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 #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 +class MitkQmlItems_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/QmlItems/QmlMitkRenderingManagerFactory.h b/Modules/QmlItems/QmlMitkRenderingManagerFactory.h index 1d0917e6f4..f4134f72f8 100644 --- a/Modules/QmlItems/QmlMitkRenderingManagerFactory.h +++ b/Modules/QmlItems/QmlMitkRenderingManagerFactory.h @@ -1,48 +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 #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 +class MitkQmlItems_EXPORT QmlMitkRenderingManagerFactory : public mitk::RenderingManagerFactory { public: QmlMitkRenderingManagerFactory(); ~QmlMitkRenderingManagerFactory(); virtual mitk::RenderingManager::Pointer CreateRenderingManager() const; private: }; #endif diff --git a/SuperBuild.cmake b/SuperBuild.cmake index 9fcd7f85ab..67695e3ad1 100644 --- a/SuperBuild.cmake +++ b/SuperBuild.cmake @@ -1,471 +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 supports Qt5. We need to also support it in QxtCMakeLists.txt -if(MITK_USE_Qt4) +#if(MITK_USE_Qt4) list(APPEND external_projects Qxt) -endif() +#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) - if(MITK_USE_Qt4) - set(MITK_USE_Qwt 1) + set(MITK_USE_Qwt 1) + #if(MITK_USE_Qt4) set(MITK_USE_Qxt 1) #TODO: Check how Qxt builds with Qt 5 - endif() + #endif() 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() # Setup file for setting custom ctest vars configure_file( CMake/SuperbuildCTestCustom.cmake.in ${MITK_BINARY_DIR}/CTestCustom.cmake @ONLY ) 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} + -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} -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} ) # Pass the CMAKE_OSX variables to external projects if(APPLE) set(MAC_OSX_ARCHITECTURE_ARGS -DCMAKE_OSX_ARCHITECTURES:PATH=${CMAKE_OSX_ARCHITECTURES} -DCMAKE_OSX_DEPLOYMENT_TARGET:PATH=${CMAKE_OSX_DEPLOYMENT_TARGET} -DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT} ) set(ep_common_args ${MAC_OSX_ARCHITECTURE_ARGS} ${ep_common_args} ) endif() # 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 -DMITK_BUILD_CONFIGURATION:STRING=${MITK_BUILD_CONFIGURATION} -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 --------------- -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} ${MAC_OSX_ARCHITECTURE_ARGS} 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 )