diff --git a/CMakeLists.txt b/CMakeLists.txt index 182958d1d8..e5e1ce68a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,519 +1,521 @@ cmake_minimum_required(VERSION 2.8.2) project(MITK) #----------------------------------------------------------------------------- # 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 ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ set(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) #----------------------------------------------------------------------------- # Superbuild Option - Enabled by default #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON) #----------------------------------------------------------------------------- # 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(FATAL_ERROR "MITK_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing 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) # some targets in Utilities also depend on Qt. Use this option # to decide if they should be build option(MITK_USE_QT "Use Trolltech's Qt library" ON) if(MITK_USE_QT) # find the package at the very beginning, so that QT4_FOUND is available find_package(Qt4 4.6.0 REQUIRED) endif() option(MITK_INSTALL_RPATH_RELATIVE "Use relative rpath entries for installation packages" OFF) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) option(MITK_BUILD_TUTORIAL "Build the MITK tutorial" ON) option(MITK_USE_Boost "Use the Boost C++ library" OFF) option(MITK_USE_GDCMIO "Use the GDCMIO class instead of ImageIO2 for DICOM" ON) option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) option(MITK_USE_CTK "EXEPERIMENTAL, superbuild only: Use CTK in MITK" OFF) option(MITK_USE_DCMTK "EXEPERIMENTAL, superbuild only: Use DCMTK in MITK" OFF) mark_as_advanced(MITK_INSTALL_RPATH_RELATIVE MITK_BUILD_ALL_PLUGINS MITK_USE_CTK MITK_USE_DCMTK ) #----------------------------------------------------------------------------- # Additional CXX/C Flags #----------------------------------------------------------------------------- set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags") mark_as_advanced(ADDITIONAL_C_FLAGS) set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags") mark_as_advanced(ADDITIONAL_CXX_FLAGS) #----------------------------------------------------------------------------- # 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-DTI MITK-Registration MITK-Modules # all modules not contained in a specific subproject MITK-Plugins # all plugins not contained in a specific subproject ) # Configure CTestConfigSubProject.cmake that could be used by CTest scripts configure_file(${MITK_SOURCE_DIR}/CTestConfigSubProject.cmake.in ${MITK_BINARY_DIR}/CTestConfigSubProject.cmake) # Generate Project.xml file expected by the CTest driver script mitkFunctionGenerateProjectXml(${MITK_BINARY_DIR} ${PROJECT_NAME} "${CTEST_PROJECT_SUBPROJECTS}" ${MITK_USE_SUPERBUILD}) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(mitkFunctionCheckCompilerFlags) include(mitkFunctionGetGccVersion) include(MacroParseArguments) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkFunctionOrganizeSources) include(mitkFunctionGetVersion) include(mitkFunctionCreateWindowsBatchScript) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) #----------------------------------------------------------------------------- # Prerequesites #----------------------------------------------------------------------------- find_package(ITK REQUIRED) find_package(VTK REQUIRED) #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- # ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and ExtApp 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) #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) #----------------------------------------------------------------------------- # 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 "${CMAKE_C_FLAGS} ${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}") set(MITK_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}") if(CMAKE_COMPILER_IS_GNUCXX) set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2") mitkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags) 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")) mitkFunctionCheckCompilerFlags("-fstack-protector-all" cflags) endif() if(MINGW) # suppress warnings about auto imported symbols set(MITK_CXX_FLAGS "-Wl,--enable-auto-import ${MITK_CXX_FLAGS}") # we need to define a Windows version set(MITK_CXX_FLAGS "-D_WIN32_WINNT=0x0500 ${MITK_CXX_FLAGS}") endif() set(MITK_C_FLAGS "${cflags} ${MITK_C_FLAGS}") #set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${MITK_CXX_FLAGS}") set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wstrict-null-sentinel ${MITK_CXX_FLAGS}") endif() #----------------------------------------------------------------------------- # MITK Modules #----------------------------------------------------------------------------- set(MITK_MODULES_CONF_DIR ${MITK_BINARY_DIR}/modulesConf CACHE INTERNAL "Modules Conf") 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_GUI_TESTING OFF "Enable the MITK GUI tests") # 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() configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h) endif() #----------------------------------------------------------------------------- # 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 #----------------------------------------------------------------------------- add_subdirectory(Utilities) include(mitkSetupVariables) if(MITK_USE_BLUEBERRY) include(mitkSetupBlueBerry) endif() #----------------------------------------------------------------------------- # Set C/CXX Flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS ${MITK_CXX_FLAGS}) set(CMAKE_C_FLAGS ${MITK_C_FLAGS}) if(MITK_USE_QT) add_definitions(-DQWT_DLL) endif() #----------------------------------------------------------------------------- # Add custom targets representing CDash subprojects #----------------------------------------------------------------------------- foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) if(NOT TARGET ${subproject}) add_custom_target(${subproject}) endif() endforeach() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- link_directories(${MITK_LINK_DIRECTORIES}) add_subdirectory(Core) set(MITK_DEFAULT_SUBPROJECTS MITK-CoreUI) if(MITK_USE_QT AND QT4_FOUND) add_subdirectory(CoreUI/Qmitk) endif() add_subdirectory(Modules) if(MITK_USE_BLUEBERRY) set(mitk_core_plugins CoreUI/Bundles/org.mitk.core.services:ON CoreUI/Bundles/org.mitk.gui.common:ON CoreUI/Bundles/org.mitk.gui.qt.common:ON CoreUI/Bundles/org.mitk.gui.qt.application:ON ) set(mitk_ext_plugins Modules/Bundles/org.mitk.core.ext:ON Modules/Bundles/org.mitk.core.jobs:OFF + Modules/Bundles/org.mitk.gui.qt.ext:ON + Modules/Bundles/org.mitk.gui.qt.extapplication:ON ) ctkMacroSetupExternalPlugins(${mitk_core_plugins} ${mitk_ext_plugins} BUILD_OPTION_PREFIX MITK_BUILD_ BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) set(MITK_COREAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.provisioning") if(EXISTS "${MITK_COREAPP_PROVISIONING_FILE}") file(REMOVE "${MITK_COREAPP_PROVISIONING_FILE}") endif() file(APPEND "${MITK_COREAPP_PROVISIONING_FILE}" "READ file://${BLUEBERRY_PLUGIN_PROVISIONING_FILE}\n") FunctionCreateProvisioningInfo(prov_info "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins" ${mitk_core_plugins}) file(APPEND "${MITK_COREAPP_PROVISIONING_FILE}" "${prov_info}") set(MITK_EXTAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ExtApp.provisioning") if(EXISTS "${MITK_EXTAPP_PROVISIONING_FILE}") file(REMOVE "${MITK_EXTAPP_PROVISIONING_FILE}") endif() file(APPEND "${MITK_EXTAPP_PROVISIONING_FILE}" "READ file://${MITK_COREAPP_PROVISIONING_FILE}\n") FunctionCreateProvisioningInfo(prov_info "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins" ${mitk_ext_plugins}) file(APPEND "${MITK_EXTAPP_PROVISIONING_FILE}" "${prov_info}") set(MITK_CORE_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkCorePluginUseFile.cmake") ctkFunctionGeneratePluginUseFile(${MITK_CORE_PLUGIN_USE_FILE}) endif() if(MITK_USE_BLUEBERRY) add_subdirectory(Modules/Bundles) endif() add_subdirectory(Applications) #----------------------------------------------------------------------------- # Python Wrapping #----------------------------------------------------------------------------- set(MITK_WRAPPING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Wrapping) set(MITK_WRAPPING_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Wrapping) option(MITK_USE_PYTHON "Build cswig Python wrapper support (requires CableSwig)." OFF) if(MITK_USE_PYTHON) add_subdirectory(Wrapping) endif() #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- add_subdirectory(Documentation) #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- if(MITK_INSTALL_RPATH_RELATIVE) set(CMAKE_INSTALL_RPATH ".") else() set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/bin") endif() # on Mac OSX all BlueBerry plugins get copied into every # application bundle (.app directory) specified here if(APPLE) if(MITK_BUILD_org.mitk.gui.qt.extapplication) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} ExtApp) endif() if(MITK_BUILD_org.mitk.gui.qt.application) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} CoreApp) endif() endif(APPLE) # set MITK cpack variables include(mitkSetupCPack) if(MITK_BUILD_org.mitk.gui.qt.application) list(APPEND CPACK_CREATE_DESKTOP_LINKS "CoreApp") endif() if(MITK_BUILD_org.mitk.gui.qt.extapplication) list(APPEND CPACK_CREATE_DESKTOP_LINKS "ExtApp") endif() configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") # 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}) if(MITK_USE_BLUEBERRY) set(enabled_plugins ${BLUEBERRY_ENABLED_PLUGINS} ${MITK_CORE_ENABLED_PLUGINS} ${MITK_MODULES_ENABLED_PLUGINS} ) # This is for installation support of external projects depending on # MITK plugins. The export file should not be used for linking to MITK # libraries without using LINK_DIRECTORIES, since the exports are incomplete # yet(depending libraries are not exported). foreach(plugin ${enabled_plugins}) string(REPLACE "." "_" plugin_target ${plugin}) export(TARGETS ${plugin_target} APPEND FILE ${MITK_EXPORTS_FILE}) endforeach() endif() configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(VECMATH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/vecmath) set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc) set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY) diff --git a/Modules/Bundles/CMakeLists.txt b/Modules/Bundles/CMakeLists.txt index 7333c3929a..65f518d63c 100644 --- a/Modules/Bundles/CMakeLists.txt +++ b/Modules/Bundles/CMakeLists.txt @@ -1,41 +1,43 @@ IF(MITK_USE_BLUEBERRY) # INCLUDE("${MITK_BINARY_DIR}/mitkExtConfig.cmake") # INCLUDE("${MITK_BINARY_DIR}/QmitkExtConfig.cmake") INCLUDE("${MITK_BINARY_DIR}/Bundles/MITKCoreBundleList.cmake") SET(MITK_DEFAULT_SUBPROJECTS MITK-Plugins) SET(_mitk_bundles_default "org.mitk.planarfigure" ) IF(QT4_FOUND) LIST(APPEND _mitk_bundles_default "org.mitk.gui.qt.ext" "org.mitk.gui.qt.extapplication") # ExtApp required bundles LIST(APPEND _mitk_bundles_default "org.mitk.gui.qt.imagenavigator" "org.mitk.gui.qt.datamanager") # BlueBerry depends on CTK which depends on Qt, so we # need the Qt include direcotries INCLUDE(${QT_USE_FILE}) ENDIF() SET(PLUGIN_EXCLUDE_LIST org.mitk.core.ext org.mitk.gui.qt.volumetry org.mitk.core.jobs + org.mitk.gui.qt.ext + org.mitk.gui.qt.extapplication ) MACRO_COLLECT_PLUGINS(OUTPUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ExtBundles CACHE_PLUGIN_SOURCE_DIRS MITK_MODULES_PLUGIN_SOURCE_DIRS CACHE_PLUGIN_OUTPUT_DIRS MITK_MODULES_PLUGIN_OUTPUT_DIRS CACHE_PLUGIN_TARGETS MITK_MODULES_ENABLED_PLUGINS BUNDLE_LIST_PATH "${MITK_BINARY_DIR}/Bundles/MITKModulesBundleList.cmake" CMAKE_CACHE_PREFIX "MITK" PLUGIN_DEFAULT_ON ${_mitk_bundles_default} PLUGIN_EXCLUDES ${PLUGIN_EXCLUDE_LIST} ${MITK_BUILD_ALL_PLUGINS_OPTION}) ENDIF(MITK_USE_BLUEBERRY) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/CMakeLists.txt b/Modules/Bundles/org.mitk.gui.qt.ext/CMakeLists.txt index 1c3f5680b3..fa177c7c10 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/CMakeLists.txt +++ b/Modules/Bundles/org.mitk.gui.qt.ext/CMakeLists.txt @@ -1 +1,7 @@ -MACRO_CREATE_MITK_PLUGIN(QmitkExt SceneSerialization) +PROJECT(org_mitk_gui_qt_ext) + +MACRO_CREATE_MITK_CTK_PLUGIN( + EXPORT_DIRECTIVE MITK_QT_COMMON_EXT_EXPORT + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDENCIES QmitkExt SceneSerialization +) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/META-INF/MANIFEST.MF b/Modules/Bundles/org.mitk.gui.qt.ext/META-INF/MANIFEST.MF deleted file mode 100644 index 2162052291..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: Common Qt Ext Plugin -Bundle-SymbolicName: org.mitk.gui.qt.ext -Bundle-Version: 0.1 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Require-Bundle: org.mitk.core.ext, org.mitk.gui.qt.common -Bundle-Activator: QmitkCommonExtPlugin diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/files.cmake b/Modules/Bundles/org.mitk.gui.qt.ext/files.cmake index a4cec86825..bdf77f6b2d 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/files.cmake +++ b/Modules/Bundles/org.mitk.gui.qt.ext/files.cmake @@ -1,48 +1,51 @@ SET(SRC_CPP_FILES QmitkCommonWorkbenchWindowAdvisor.cpp QmitkExtPreferencePage.cpp QmitkInputDevicesPrefPage.cpp QmitkExtActionBarAdvisor.cpp QmitkExtWorkbenchWindowAdvisor.cpp QmitkExtFileOpenAction.cpp QmitkExtDnDFrameWidget.cpp QmitkExtFileSaveProjectAction.cpp ) SET(INTERNAL_CPP_FILES QmitkCommonExtPlugin.cpp ) SET(UI_FILES ) SET(MOC_H_FILES + src/internal/QmitkCommonExtPlugin.h src/internal/QmitkExtWorkbenchWindowAdvisorHack.h src/QmitkExtFileOpenAction.h src/QmitkExtFileSaveProjectAction.h src/QmitkExtDnDFrameWidget.h - + src/QmitkExtPreferencePage.h + src/QmitkInputDevicesPrefPage.h ) -SET(RESOURCE_FILES +SET(CACHED_RESOURCE_FILES # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench + plugin.xml ) -SET(RES_FILES +SET(QRC_FILES # uncomment the following line if you want to use Qt resources resources/org_mitk_gui_qt_ext.qrc ) -SET(CPP_FILES manifest.cpp) +SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/manifest.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/manifest.cpp deleted file mode 100644 index 280597c22a..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/manifest.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. - - =========================================================================*/ - -#include - -#include "src/internal/QmitkCommonExtPlugin.h" -#include "src/QmitkExtPreferencePage.h" -#include "src/QmitkInputDevicesPrefPage.h" - -POCO_BEGIN_MANIFEST(berry::IBundleActivator) - POCO_EXPORT_CLASS(QmitkCommonExtPlugin) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryIPreferencePage, berry::IPreferencePage) - POCO_EXPORT_CLASS(QmitkExtPreferencePage) - POCO_EXPORT_CLASS(QmitkInputDevicesPrefPage) -POCO_END_MANIFEST - diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.ext/manifest_headers.cmake new file mode 100644 index 0000000000..7b96659458 --- /dev/null +++ b/Modules/Bundles/org.mitk.gui.qt.ext/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "Common Qt Ext Plugin") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.core.ext org.mitk.gui.qt.common) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/plugin.xml b/Modules/Bundles/org.mitk.gui.qt.ext/plugin.xml index 41b6671d4e..07393a4cb7 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/plugin.xml +++ b/Modules/Bundles/org.mitk.gui.qt.ext/plugin.xml @@ -1,18 +1,18 @@ - + - - + + diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.h index 70578cec51..8f6f8bc35b 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.h @@ -1,42 +1,42 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ Version: $Revision: 21070 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QmitkCommonWorkbenchWindowAdvisor_h #define QmitkCommonWorkbenchWindowAdvisor_h -#include "mitkQtCommonExtDll.h" +#include #include #include /// /// \brief a WorkbenchWindowAdvisor that does common stuff when opening a MITK Workbench (e.g adding a /// QmitkFunctionalityCoordinator instance) /// \see QmitkFunctionalityCoordinator /// class MITK_QT_COMMON_EXT_EXPORT QmitkCommonWorkbenchWindowAdvisor : public berry::WorkbenchWindowAdvisor { public: QmitkCommonWorkbenchWindowAdvisor( berry::IWorkbenchWindowConfigurer::Pointer configurer ); void PostWindowCreate(); private: QmitkFunctionalityCoordinator::Pointer m_FunctionalityCoordinator; }; #endif /*QMITKEXTWORKBENCHWINDOWADVISOR_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h index 4f980ecde8..986d7d987c 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h @@ -1,36 +1,36 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKEXTACTIONBARADVISOR_H_ #define QMITKEXTACTIONBARADVISOR_H_ #include -#include "mitkQtCommonExtDll.h" +#include class MITK_QT_COMMON_EXT_EXPORT QmitkExtActionBarAdvisor : public berry::ActionBarAdvisor { public: QmitkExtActionBarAdvisor(berry::IActionBarConfigurer::Pointer configurer); protected: void FillMenuBar(void* menuBar); }; #endif /*QMITKEXTACTIONBARADVISOR_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.h index 2a68bb5a4c..19d245ac67 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.h @@ -1,51 +1,51 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ Version: $Revision: 16224 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QmitkExtDndFrameWidget_h #define QmitkExtDndFrameWidget_h #ifdef __MINGW32__ // We need to inlclude winbase.h here in order to declare // atomic intrinsics like InterlockedIncrement correctly. // Otherwhise, they would be declared wrong within qatomic_windows.h . #include #endif #include -#include "mitkQtCommonExtDll.h" +#include //drag&drop class QDragEnterEvent; class QDropEvent; class QMouseEvent; class MITK_QT_COMMON_EXT_EXPORT QmitkExtDnDFrameWidget : public QWidget { Q_OBJECT public: QmitkExtDnDFrameWidget(QWidget *parent); private: void dragEnterEvent( QDragEnterEvent *event ); void dropEvent( QDropEvent * event ); }; #endif diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.h index e6ee1c1b37..7bffaaca62 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.h @@ -1,55 +1,55 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ Version: $Revision: 21070 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKEXTFILEOPENACTION_H_ #define QMITKEXTFILEOPENACTION_H_ #ifdef __MINGW32__ // We need to inlclude winbase.h here in order to declare // atomic intrinsics like InterlockedIncrement correctly. // Otherwhise, they would be declared wrong within qatomic_windows.h . #include #endif #include #include -#include "mitkQtCommonExtDll.h" +#include #include #include class MITK_QT_COMMON_EXT_EXPORT QmitkExtFileOpenAction : public QAction { Q_OBJECT public: QmitkExtFileOpenAction(berry::IWorkbenchWindow::Pointer window); QmitkExtFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window); protected slots: void Run(); private: void init ( berry::IWorkbenchWindow::Pointer window ); berry::IWorkbenchWindow::Pointer m_Window; berry::IPreferences::WeakPtr m_GeneralPreferencesNode; }; #endif /*QMITKEXTFILEOPENACTION_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h index 7c366767dd..7b00d8361c 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h @@ -1,52 +1,52 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-10-09 16:36:23 +0200 (Fr, 09 Okt 2009) $ Version: $Revision: 19414 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QmitkExtFileSaveProjectAction_H_ #define QmitkExtFileSaveProjectAction_H_ #ifdef __MINGW32__ // We need to inlclude winbase.h here in order to declare // atomic intrinsics like InterlockedIncrement correctly. // Otherwhise, they would be declared wrong within qatomic_windows.h . #include #endif #include -#include "mitkQtCommonExtDll.h" +#include #include class MITK_QT_COMMON_EXT_EXPORT QmitkExtFileSaveProjectAction : public QAction { Q_OBJECT public: QmitkExtFileSaveProjectAction(berry::IWorkbenchWindow::Pointer window); protected slots: void Run(); private: berry::IWorkbenchWindow::Pointer m_Window; }; #endif /*QmitkExtFileSaveProjectAction_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.cpp index fca9eacd5d..9bae8f9cc1 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.cpp @@ -1,69 +1,75 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ Version: $Revision: 18019 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkExtPreferencePage.h" #include #include #include #include #include #include #include #include #include #include QmitkExtPreferencePage::QmitkExtPreferencePage() : m_MainControl(0) { } +QmitkExtPreferencePage::QmitkExtPreferencePage(const QmitkExtPreferencePage& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + void QmitkExtPreferencePage::Init(berry::IWorkbench::Pointer ) { } void QmitkExtPreferencePage::CreateQtControl(QWidget* parent) { //empty page m_MainControl = new QWidget(parent); QVBoxLayout *layout = new QVBoxLayout; m_MainControl->setLayout(layout); this->Update(); } QWidget* QmitkExtPreferencePage::GetQtControl() const { return m_MainControl; } bool QmitkExtPreferencePage::PerformOk() { return true; } void QmitkExtPreferencePage::PerformCancel() { } void QmitkExtPreferencePage::Update() { } diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.h index 6943d6297d..cbf712a7b4 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtPreferencePage.h @@ -1,83 +1,87 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ Version: $Revision: 16224 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKExtPreferencePage_H_ #define QMITKExtPreferencePage_H_ #include "berryIQtPreferencePage.h" #include #include class QWidget; class QCheckBox; -class QmitkExtPreferencePage : public berry::IQtPreferencePage +class QmitkExtPreferencePage : public QObject, public berry::IQtPreferencePage { + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) public: /** * Default constructor */ QmitkExtPreferencePage(); + QmitkExtPreferencePage(const QmitkExtPreferencePage& other); + /** * @see berry::IPreferencePage::Init(berry::IWorkbench::Pointer workbench) */ void Init(berry::IWorkbench::Pointer workbench); /** * @see berry::IPreferencePage::CreateQtControl(void* parent) */ void CreateQtControl(QWidget* widget); /** * @see berry::IPreferencePage::CreateQtControl() */ QWidget* GetQtControl() const; /** * @see berry::IPreferencePage::PerformOk() */ virtual bool PerformOk(); /** * @see berry::IPreferencePage::PerformCancel() */ virtual void PerformCancel(); /** * @see berry::IPreferencePage::Update() */ virtual void Update(); /** * @see berry::IPreferencePage::FlushReferences() */ void FlushPreferences(); protected: QWidget* m_MainControl; berry::IPreferences::Pointer m_ExtPreferencesNode; }; #endif /* QMITKExtPreferencePage_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp index 65005d3602..6668b77da5 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp @@ -1,972 +1,967 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkExtWorkbenchWindowAdvisor.h" #include "QmitkExtActionBarAdvisor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // UGLYYY #include "internal/QmitkExtWorkbenchWindowAdvisorHack.h" +#include "internal/QmitkCommonExtPlugin.h" #include "mitkUndoController.h" #include "mitkVerboseLimitedLinearUndo.h" #include #include #include #include QmitkExtWorkbenchWindowAdvisorHack * QmitkExtWorkbenchWindowAdvisorHack::undohack = new QmitkExtWorkbenchWindowAdvisorHack(); +QString QmitkExtWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME = "QtSettings.ini"; + class PartListenerForTitle: public berry::IPartListener { public: PartListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) { } Events::Types GetPartEventTypes() const { return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void PartActivated(berry::IWorkbenchPartReference::Pointer ref) { if (ref.Cast ()) { windowAdvisor->UpdateTitle(false); } } void PartBroughtToTop(berry::IWorkbenchPartReference::Pointer ref) { if (ref.Cast ()) { windowAdvisor->UpdateTitle(false); } } void PartClosed(berry::IWorkbenchPartReference::Pointer /*ref*/) { windowAdvisor->UpdateTitle(false); } void PartHidden(berry::IWorkbenchPartReference::Pointer ref) { if (!windowAdvisor->lastActiveEditor.Expired() && ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) { windowAdvisor->UpdateTitle(true); } } void PartVisible(berry::IWorkbenchPartReference::Pointer ref) { if (!windowAdvisor->lastActiveEditor.Expired() && ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) { windowAdvisor->UpdateTitle(false); } } private: QmitkExtWorkbenchWindowAdvisor* windowAdvisor; }; class PartListenerForImageNavigator: public berry::IPartListener { public: PartListenerForImageNavigator(QAction* act) : imageNavigatorAction(act) { } Events::Types GetPartEventTypes() const { return Events::OPENED | Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void PartOpened(berry::IWorkbenchPartReference::Pointer ref) { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(true); } } void PartClosed(berry::IWorkbenchPartReference::Pointer ref) { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(false); } } void PartVisible(berry::IWorkbenchPartReference::Pointer ref) { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(true); } } void PartHidden(berry::IWorkbenchPartReference::Pointer ref) { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(false); } } private: QAction* imageNavigatorAction; }; class PerspectiveListenerForTitle: public berry::IPerspectiveListener { public: PerspectiveListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : windowAdvisor(wa), perspectivesClosed(false) { } Events::Types GetPerspectiveEventTypes() const { return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED // remove the following line when command framework is finished | Events::CLOSED | Events::OPENED; } void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, berry::IPerspectiveDescriptor::Pointer /*perspective*/) { windowAdvisor->UpdateTitle(false); } void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/, berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/, berry::IPerspectiveDescriptor::Pointer /*newPerspective*/) { windowAdvisor->UpdateTitle(false); } void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, berry::IPerspectiveDescriptor::Pointer /*perspective*/) { windowAdvisor->UpdateTitle(false); } void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/, berry::IPerspectiveDescriptor::Pointer /*perspective*/) { if (perspectivesClosed) { QListIterator i(windowAdvisor->viewActions); while (i.hasNext()) { i.next()->setEnabled(true); } windowAdvisor->fileSaveProjectAction->setEnabled(true); windowAdvisor->closeProjectAction->setEnabled(true); windowAdvisor->undoAction->setEnabled(true); windowAdvisor->redoAction->setEnabled(true); windowAdvisor->imageNavigatorAction->setEnabled(true); windowAdvisor->resetPerspAction->setEnabled(true); windowAdvisor->closePerspAction->setEnabled(true); } perspectivesClosed = false; } void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/, berry::IPerspectiveDescriptor::Pointer /*perspective*/) { berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow(); bool allClosed = true; if (wnd->GetActivePage()) { std::vector perspectives(wnd->GetActivePage()->GetOpenPerspectives()); allClosed = perspectives.empty(); } if (allClosed) { perspectivesClosed = true; QListIterator i(windowAdvisor->viewActions); while (i.hasNext()) { i.next()->setEnabled(false); } windowAdvisor->fileSaveProjectAction->setEnabled(false); windowAdvisor->closeProjectAction->setEnabled(false); windowAdvisor->undoAction->setEnabled(false); windowAdvisor->redoAction->setEnabled(false); windowAdvisor->imageNavigatorAction->setEnabled(false); windowAdvisor->resetPerspAction->setEnabled(false); windowAdvisor->closePerspAction->setEnabled(false); } } private: QmitkExtWorkbenchWindowAdvisor* windowAdvisor; bool perspectivesClosed; }; class PerspectiveListenerForMenu: public berry::IPerspectiveListener { public: PerspectiveListenerForMenu(QmitkExtWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) { } Events::Types GetPerspectiveEventTypes() const { return Events::ACTIVATED | Events::DEACTIVATED; } void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, berry::IPerspectiveDescriptor::Pointer perspective) { QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; if (action) { action->setChecked(true); } } void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, berry::IPerspectiveDescriptor::Pointer perspective) { QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; if (action) { action->setChecked(false); } } private: QmitkExtWorkbenchWindowAdvisor* windowAdvisor; }; QmitkExtWorkbenchWindowAdvisor::QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer) : QmitkCommonWorkbenchWindowAdvisor(configurer), lastInput(0), wbAdvisor(wbAdvisor), showViewToolbar(true), showVersionInfo(true) { productName = berry::Platform::GetConfiguration().getString("application.baseName"); } berry::ActionBarAdvisor::Pointer QmitkExtWorkbenchWindowAdvisor::CreateActionBarAdvisor( berry::IActionBarConfigurer::Pointer configurer) { berry::ActionBarAdvisor::Pointer actionBarAdvisor( new QmitkExtActionBarAdvisor(configurer)); return actionBarAdvisor; } void* QmitkExtWorkbenchWindowAdvisor::CreateEmptyWindowContents(void* parent) { QWidget* parentWidget = static_cast(parent); QLabel* label = new QLabel(parentWidget); label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu."); label->setContentsMargins(10,10,10,10); label->setAlignment(Qt::AlignTop); label->setEnabled(false); parentWidget->layout()->addWidget(label); return label; } void QmitkExtWorkbenchWindowAdvisor::ShowViewToolbar(bool show) { showViewToolbar = show; } void QmitkExtWorkbenchWindowAdvisor::ShowVersionInfo(bool show) { showVersionInfo = show; } void QmitkExtWorkbenchWindowAdvisor::SetProductName(const std::string& product) { productName = product; } void QmitkExtWorkbenchWindowAdvisor::SetWindowIcon(const std::string& wndIcon) { windowIcon = wndIcon; } void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() { QmitkCommonWorkbenchWindowAdvisor::PostWindowCreate(); // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); if (!windowIcon.empty()) { mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon))); } mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); /*mainWindow->setStyleSheet("color: white;" "background-color: #808080;" "selection-color: #659EC7;" "selection-background-color: #808080;" " QMenuBar {" "background-color: #808080; }");*/ // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); menuBar->setContextMenuPolicy(Qt::PreventContextMenu); QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); QAction* fileOpenAction = new QmitkExtFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window); fileMenu->addAction(fileOpenAction); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png")); fileMenu->addAction(fileSaveProjectAction); closeProjectAction = new QmitkCloseProjectAction(window); closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png")); fileMenu->addAction(closeProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const std::vector& viewDescriptors = viewRegistry->GetViews(); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"), "&Undo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), QKeySequence("CTRL+Z")); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png") , "&Redo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), QKeySequence("CTRL+Y")); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL); QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); // add part listener for image navigator imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction); window->GetPartService()->AddPartListener(imageNavigatorPartListener); berry::IViewPart::Pointer imageNavigatorView = window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } imageNavigatorAction->setToolTip("Open image navigator for navigating through image"); // toolbar for showing file open, undo, redo and other main actions QToolBar* mainActionsToolBar = new QToolBar; mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif mainActionsToolBar->addAction(fileOpenAction); mainActionsToolBar->addAction(fileSaveProjectAction); mainActionsToolBar->addAction(closeProjectAction); mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); mainActionsToolBar->addAction(imageNavigatorAction); mainWindow->addToolBar(mainActionsToolBar); #ifdef __APPLE__ mainWindow->setUnifiedTitleAndToolBarOnMac(true); #endif // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); windowMenu->addSeparator(); QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); QMenu* viewMenu = windowMenu->addMenu("Show &View"); viewMenu->setObjectName("Show View"); windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), QKeySequence("CTRL+P")); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QActionGroup* perspGroup = new QActionGroup(menuBar); std::vector perspectives( perspRegistry->GetPerspectives()); bool skip = false; for (std::vector::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (unsigned int i=0; iGetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } QAction* perspAction = new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction)); } perspMenu->addActions(perspGroup->actions()); // sort elements (converting vector to map...) std::vector::const_iterator iter; std::map VDMap; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; std::pair p( (*iter)->GetLabel(), (*iter)); VDMap.insert(p); } // ================================================== // ==== View Toolbar ================================== QToolBar* qToolbar = new QToolBar; std::map::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); viewMenu->addAction(viewAction); if (showViewToolbar) { qToolbar->addAction(viewAction); } } if (showViewToolbar) { mainWindow->addToolBar(qToolbar); } else delete qToolbar; - Poco::Path path; - berry::IBundle::Pointer bundle = berry::Platform::GetBundle("org.mitk.gui.qt.ext"); - berry::Platform::GetStatePath(path, bundle); - - QString qPath = QString::fromStdString(path.toString()); - qPath.append("PreferencesQt.ini"); - - QSettings settings(qPath, QSettings::IniFormat); + QSettings settings(GetQSettingsFile(), QSettings::IniFormat); mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); // ==================================================== // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("Help"); helpMenu->addAction("&Welcome",QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onIntro())); helpMenu->addAction("&Help Contents",QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onHelp()), QKeySequence("F1")); helpMenu->addAction("&About",QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onAbout())); // ===================================================== QStatusBar* qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); QmitkProgressBar *progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); // progBar->AddStepsToDo(2); // progBar->Progress(1); mainWindow->setStatusBar(qStatusBar); QmitkMemoryUsageIndicatorView* memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); } void QmitkExtWorkbenchWindowAdvisor::PreWindowOpen() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); // show the shortcut bar and progress indicator, which are hidden by // default //configurer->SetShowPerspectiveBar(true); //configurer->SetShowFastViewBars(true); //configurer->SetShowProgressIndicator(true); // // add the drag and drop support for the editor area // configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); // configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); // configurer.addEditorAreaTransfer(FileTransfer.getInstance()); // configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); // configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( // configurer.getWindow())); this->HookTitleUpdateListeners(configurer); menuPerspectiveListener = new PerspectiveListenerForMenu(this); configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener); } //-------------------------------------------------------------------------------- // Ugly hack from here on. Feel free to delete when command framework // and undo buttons are done. //-------------------------------------------------------------------------------- QmitkExtWorkbenchWindowAdvisorHack::QmitkExtWorkbenchWindowAdvisorHack() : QObject() { } QmitkExtWorkbenchWindowAdvisorHack::~QmitkExtWorkbenchWindowAdvisorHack() { } void QmitkExtWorkbenchWindowAdvisorHack::onUndo() { mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); if (model) { if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) { mitk::VerboseLimitedLinearUndo::StackDescription descriptions = verboseundo->GetUndoDescriptions(); if (descriptions.size() >= 1) { MITK_INFO << "Undo " << descriptions.front().second; } } model->Undo(); } else { MITK_ERROR << "No undo model instantiated"; } } void QmitkExtWorkbenchWindowAdvisorHack::onRedo() { mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); if (model) { if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) { mitk::VerboseLimitedLinearUndo::StackDescription descriptions = verboseundo->GetRedoDescriptions(); if (descriptions.size() >= 1) { MITK_INFO << "Redo " << descriptions.front().second; } } model->Redo(); } else { MITK_ERROR << "No undo model instantiated"; } } void QmitkExtWorkbenchWindowAdvisorHack::onImageNavigator() { // get ImageNavigatorView berry::IViewPart::Pointer imageNavigatorView = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); if (imageNavigatorView) { bool isImageNavigatorVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) { berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->HideView(imageNavigatorView); return; } } berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagenavigator"); //berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); } void QmitkExtWorkbenchWindowAdvisorHack::onEditPreferences() { QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow()); _PreferencesDialog.exec(); } void QmitkExtWorkbenchWindowAdvisorHack::onQuit() { berry::PlatformUI::GetWorkbench()->Close(); } void QmitkExtWorkbenchWindowAdvisorHack::onResetPerspective() { berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); } void QmitkExtWorkbenchWindowAdvisorHack::onClosePerspective() { berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); page->ClosePerspective(page->GetPerspective(), true, true); } void QmitkExtWorkbenchWindowAdvisorHack::onNewWindow() { berry::PlatformUI::GetWorkbench()->OpenWorkbenchWindow(0); } void QmitkExtWorkbenchWindowAdvisorHack::onIntro() { bool hasIntro = berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro(); if (!hasIntro) { QRegExp reg("(.*)(\\n)*"); QRegExp reg2("(\\n)*(.*)"); QFile file(":/org.mitk.gui.qt.ext/index.html"); file.open(QIODevice::ReadOnly | QIODevice::Text); // Als Text-Datei nur zum Lesen öffnen QString text = QString(file.readAll()); file.close(); QString title = text; title.replace(reg, ""); title.replace(reg2, ""); std::cout << title.toStdString() << std::endl; QMessageBox::information(NULL, title, text, "Close"); } else { berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false); } } void QmitkExtWorkbenchWindowAdvisorHack::onHelp() { berry::QtAssistantUtil::OpenActivePartHelp(); } void QmitkExtWorkbenchWindowAdvisorHack::onAbout() { QmitkAboutDialog* aboutDialog = new QmitkAboutDialog(QApplication::activeWindow(),NULL); aboutDialog->open(); } void QmitkExtWorkbenchWindowAdvisor::HookTitleUpdateListeners( berry::IWorkbenchWindowConfigurer::Pointer configurer) { // hook up the listeners to update the window title titlePartListener = new PartListenerForTitle(this); titlePerspectiveListener = new PerspectiveListenerForTitle(this); editorPropertyListener = new berry::PropertyChangeIntAdapter< QmitkExtWorkbenchWindowAdvisor>(this, &QmitkExtWorkbenchWindowAdvisor::PropertyChange); // configurer.getWindow().addPageListener(new IPageListener() { // public void pageActivated(IWorkbenchPage page) { // updateTitle(false); // } // // public void pageClosed(IWorkbenchPage page) { // updateTitle(false); // } // // public void pageOpened(IWorkbenchPage page) { // // do nothing // } // }); configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener); configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener); } std::string QmitkExtWorkbenchWindowAdvisor::ComputeTitle() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); berry::IWorkbenchPage::Pointer currentPage = configurer->GetWindow()->GetActivePage(); berry::IEditorPart::Pointer activeEditor; if (currentPage) { activeEditor = lastActiveEditor.Lock(); } std::string title; //TODO Product // IProduct product = Platform.getProduct(); // if (product != null) { // title = product.getName(); // } // instead of the product name, we use a custom variable for now title = productName + " " + MITK_VERSION_STRING; if (showVersionInfo) { // add version informatioin QString mitkRevision(MITK_REVISION); mitkRevision = mitkRevision.left(6) + " (" MITK_REVISION_NAME ")"; QString versions = QString(" (ITK %1.%2.%3 VTK %4.%5.%6 Qt %7 MITK %8)") .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH) .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION) .arg(QT_VERSION_STR) .arg(mitkRevision); title += versions.toStdString(); } if (currentPage) { if (activeEditor) { lastEditorTitle = activeEditor->GetTitleToolTip(); if (!lastEditorTitle.empty()) title = lastEditorTitle + " - " + title; } berry::IPerspectiveDescriptor::Pointer persp = currentPage->GetPerspective(); std::string label = ""; if (persp) { label = persp->GetLabel(); } berry::IAdaptable* input = currentPage->GetInput(); if (input && input != wbAdvisor->GetDefaultPageInput()) { label = currentPage->GetLabel(); } if (!label.empty()) { title = label + " - " + title; } } title += " (Not for use in diagnosis or treatment of patients)"; return title; } void QmitkExtWorkbenchWindowAdvisor::RecomputeTitle() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); std::string oldTitle = configurer->GetTitle(); std::string newTitle = ComputeTitle(); if (newTitle != oldTitle) { configurer->SetTitle(newTitle); } } void QmitkExtWorkbenchWindowAdvisor::UpdateTitle(bool editorHidden) { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); berry::IWorkbenchWindow::Pointer window = configurer->GetWindow(); berry::IEditorPart::Pointer activeEditor; berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage(); berry::IPerspectiveDescriptor::Pointer persp; berry::IAdaptable* input = 0; if (currentPage) { activeEditor = currentPage->GetActiveEditor(); persp = currentPage->GetPerspective(); input = currentPage->GetInput(); } if (editorHidden) { activeEditor = 0; } // Nothing to do if the editor hasn't changed if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock() && persp == lastPerspective.Lock() && input == lastInput) { return; } if (!lastActiveEditor.Expired()) { lastActiveEditor.Lock()->RemovePropertyListener(editorPropertyListener); } lastActiveEditor = activeEditor; lastActivePage = currentPage; lastPerspective = persp; lastInput = input; if (activeEditor) { activeEditor->AddPropertyListener(editorPropertyListener); } RecomputeTitle(); } void QmitkExtWorkbenchWindowAdvisor::PropertyChange(berry::Object::Pointer /*source*/, int propId) { if (propId == berry::IWorkbenchPartConstants::PROP_TITLE) { if (!lastActiveEditor.Expired()) { std::string newTitle = lastActiveEditor.Lock()->GetPartName(); if (lastEditorTitle != newTitle) { RecomputeTitle(); } } } } void QmitkExtWorkbenchWindowAdvisor::SetPerspectiveExcludeList(std::vector v) { this->perspectiveExcludeList = v; } std::vector QmitkExtWorkbenchWindowAdvisor::GetPerspectiveExcludeList() { return this->perspectiveExcludeList; } void QmitkExtWorkbenchWindowAdvisor::PostWindowClose() { - Poco::Path path; - berry::IBundle::Pointer bundle = berry::Platform::GetBundle("org.mitk.gui.qt.ext"); - berry::Platform::GetStatePath(path, bundle); + berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); + QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); - QString qPath = QString::fromStdString(path.toString()); - qPath.append("PreferencesQt.ini"); - - berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); - QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); + QSettings settings(GetQSettingsFile(), QSettings::IniFormat); + settings.setValue("ToolbarPosition", mainWindow->saveState()); +} - QSettings settings(qPath, QSettings::IniFormat); - settings.setValue("ToolbarPosition", mainWindow->saveState()); +QString QmitkExtWorkbenchWindowAdvisor::GetQSettingsFile() const +{ + QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME); + return settingsInfo.canonicalFilePath(); } diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h index 9dfe8c6116..639ec8970d 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h @@ -1,127 +1,131 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKEXTWORKBENCHWINDOWADVISOR_H_ #define QMITKEXTWORKBENCHWINDOWADVISOR_H_ #include #include #include #include #include -#include "mitkQtCommonExtDll.h" +#include #include "QmitkCommonWorkbenchWindowAdvisor.h" #include class QAction; class QMenu; class MITK_QT_COMMON_EXT_EXPORT QmitkExtWorkbenchWindowAdvisor : public QmitkCommonWorkbenchWindowAdvisor { public: QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer); berry::ActionBarAdvisor::Pointer CreateActionBarAdvisor( berry::IActionBarConfigurer::Pointer configurer); void* CreateEmptyWindowContents(void* parent); void PostWindowCreate(); void PreWindowOpen(); void PostWindowClose(); void ShowViewToolbar(bool show); void ShowVersionInfo(bool show); //TODO should be removed when product support is here void SetProductName(const std::string& product); void SetWindowIcon(const std::string& wndIcon); void SetPerspectiveExcludeList(std::vector v); std::vector GetPerspectiveExcludeList(); private: /** * Hooks the listeners needed on the window * * @param configurer */ void HookTitleUpdateListeners(berry::IWorkbenchWindowConfigurer::Pointer configurer); std::string ComputeTitle(); void RecomputeTitle(); + QString GetQSettingsFile() const; + /** * Updates the window title. Format will be: [pageInput -] * [currentPerspective -] [editorInput -] [workspaceLocation -] productName * @param editorHidden TODO */ void UpdateTitle(bool editorHidden); void PropertyChange(berry::Object::Pointer /*source*/, int propId); + static QString QT_SETTINGS_FILENAME; + berry::IPartListener::Pointer titlePartListener; berry::IPerspectiveListener::Pointer titlePerspectiveListener; berry::IPerspectiveListener::Pointer menuPerspectiveListener; berry::IPartListener::Pointer imageNavigatorPartListener; berry::IPropertyChangeListener::Pointer editorPropertyListener; friend struct berry::PropertyChangeIntAdapter; friend class PartListenerForTitle; friend class PerspectiveListenerForTitle; friend class PerspectiveListenerForMenu; friend class PartListenerForImageNavigator; berry::IEditorPart::WeakPtr lastActiveEditor; berry::IPerspectiveDescriptor::WeakPtr lastPerspective; berry::IWorkbenchPage::WeakPtr lastActivePage; std::string lastEditorTitle; berry::IAdaptable* lastInput; berry::WorkbenchAdvisor* wbAdvisor; bool showViewToolbar; bool showVersionInfo; std::string productName; std::string windowIcon; // stringlist for excluding perspectives from the perspective menu entry (e.g. Welcome Perspective) std::vector perspectiveExcludeList; // maps perspective ids to QAction objects std::map mapPerspIdToAction; // actions which will be enabled/disabled depending on the application state QList viewActions; QAction* fileSaveProjectAction; QAction* closeProjectAction; QAction* undoAction; QAction* redoAction; QAction* imageNavigatorAction; QAction* resetPerspAction; QAction* closePerspAction; }; #endif /*QMITKEXTWORKBENCHWINDOWADVISOR_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.cpp index 5c33dcd749..f9ebdd90bc 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.cpp @@ -1,189 +1,195 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ Version: $Revision: 18019 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkInputDevicesPrefPage.h" #include #include #include #include #include #include #include #include #include #include #include QmitkInputDevicesPrefPage::QmitkInputDevicesPrefPage() : m_MainControl(0) { // gets the old setting of the preferences and loads them into the preference node berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); this->m_InputDevicesPrefNode = prefService->GetSystemPreferences()->Node(mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES); } +QmitkInputDevicesPrefPage::QmitkInputDevicesPrefPage(const QmitkInputDevicesPrefPage& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + void QmitkInputDevicesPrefPage::Init(berry::IWorkbench::Pointer ) { } void QmitkInputDevicesPrefPage::CreateQtControl(QWidget* parent) { m_MainControl = new QWidget(parent); QVBoxLayout *layout = new QVBoxLayout; mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry = berry::Platform::GetServiceRegistry().GetServiceById(mitk::CoreExtConstants::INPUTDEVICE_SERVICE); std::vector temp(inputDeviceRegistry->GetInputDevices()); for(std::vector::const_iterator it = temp.begin(); it != temp.end();++it) { QString inputDeviceName(QString::fromStdString((*it)->GetName())); QCheckBox* checkBox = new QCheckBox((inputDeviceName),m_MainControl); layout->addWidget(checkBox); m_InputDevices.insert(checkBox,(*it)->GetID()); if(inputDeviceName == "WiiMote") { m_WiiMoteModes = new QGroupBox("WiiMote Modus"); m_WiiMoteHeadTracking = new QRadioButton (QString::fromStdString(mitk::CoreExtConstants::WIIMOTE_HEADTRACKING)); m_WiiMoteSurfaceInteraction = new QRadioButton (QString::fromStdString(mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION)); m_WiiMoteHeadTracking->setChecked(true); QVBoxLayout* vBoxLayout = new QVBoxLayout; vBoxLayout->addWidget(m_WiiMoteHeadTracking); vBoxLayout->addWidget(m_WiiMoteSurfaceInteraction); m_WiiMoteModes->setLayout(vBoxLayout); layout->addWidget(m_WiiMoteModes); } } layout->addStretch(); m_MainControl->setLayout(layout); this->Update(); } QWidget* QmitkInputDevicesPrefPage::GetQtControl() const { return m_MainControl; } bool QmitkInputDevicesPrefPage::PerformOk() { bool result = true; mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry = berry::Platform::GetServiceRegistry(). GetServiceById(mitk::CoreExtConstants::INPUTDEVICE_SERVICE); QHashIterator it(m_InputDevices); while (it.hasNext()) { it.next(); mitk::IInputDeviceDescriptor::Pointer inputdevice(inputDeviceRegistry->Find(it.value())); if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) { QString headTracking(m_WiiMoteHeadTracking->text()); QString surfaceInteraction(m_WiiMoteSurfaceInteraction->text()); this->m_InputDevicesPrefNode->PutBool (headTracking.toStdString(),m_WiiMoteHeadTracking->isChecked()); this->m_InputDevicesPrefNode->PutBool (surfaceInteraction.toStdString(),m_WiiMoteSurfaceInteraction->isChecked()); // forced flush of the preferences is needed // because otherwise the mitk::WiiMoteActivator class // cannot distinguish the two different modes without // changing the interface for all input devices berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry(). GetServiceById(berry::IPreferencesService::ID); if (prefService) { prefService->GetSystemPreferences()->Flush(); } } if(it.key()->isChecked()) { result &= inputdevice->CreateInputDevice()->RegisterInputDevice(); } else { result &= inputdevice->CreateInputDevice()->UnRegisterInputDevice(); // temporary fix, unclean solution: // e.g. user activates SpaceNavigator and leaves the // the wiimote deactivated, the user will get the warning // despite the fact that it has never been activated if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) { // until now 2010-09-06 there were some unfixed problems // with reconnecting the wiimote after disconnecting it. // It was suggested that it might have something to do // with the type of stack, that is used for the pairing. // MS-Stack for example does not work properly. QMessageBox::information(NULL,"WiiMote supportproblem", "A reconnect of the WiiMote is not yet supported! " "Please restart the application, if you want to " "activate the Wii remote/s again."); } } if(result) { this->m_InputDevicesPrefNode->PutBool(it.value(),it.key()->isChecked()); } } return result; } void QmitkInputDevicesPrefPage::PerformCancel() { } void QmitkInputDevicesPrefPage::Update() { QHashIterator it(m_InputDevices); while (it.hasNext()) { it.next(); it.key()->setChecked(this->m_InputDevicesPrefNode->GetBool(it.value(), false)); if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) { m_WiiMoteHeadTracking->setChecked( this->m_InputDevicesPrefNode->GetBool(mitk::CoreExtConstants::WIIMOTE_HEADTRACKING,false)); m_WiiMoteSurfaceInteraction->setChecked (this->m_InputDevicesPrefNode->GetBool(mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION,false)); } } } diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.h index 403e95a33a..eb9f87cfa9 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkInputDevicesPrefPage.h @@ -1,88 +1,92 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ Version: $Revision: 16224 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITK_INPUTDEVICESPREFPAGE_H_ #define QMITK_INPUTDEVICESPREFPAGE_H_ #include "berryIQtPreferencePage.h" #include #include #include #include class QWidget; class QCheckBox; -class QmitkInputDevicesPrefPage : public berry::IQtPreferencePage +class QmitkInputDevicesPrefPage : public QObject, public berry::IQtPreferencePage { + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) public: /** * Default constructor */ QmitkInputDevicesPrefPage(); + QmitkInputDevicesPrefPage(const QmitkInputDevicesPrefPage& other); + /** * @see berry::IPreferencePage::Init(berry::IWorkbench::Pointer workbench) */ void Init(berry::IWorkbench::Pointer workbench); /** * @see berry::IPreferencePage::CreateQtControl(void* parent) */ void CreateQtControl(QWidget* widget); /** * @see berry::IPreferencePage::CreateQtControl() */ QWidget* GetQtControl() const; /** * @see berry::IPreferencePage::PerformOk() */ virtual bool PerformOk(); /** * @see berry::IPreferencePage::PerformCancel() */ virtual void PerformCancel(); /** * @see berry::IPreferencePage::Update() */ virtual void Update(); protected: QWidget* m_MainControl; QHash m_InputDevices; // specific for Wiimote QGroupBox* m_WiiMoteModes; QRadioButton* m_WiiMoteHeadTracking; QRadioButton* m_WiiMoteSurfaceInteraction; berry::IPreferences::Pointer m_InputDevicesPrefNode; }; #endif // QMITK_INPUTDEVICESPREFPAGE_H_ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp index c38bdf4c8a..0394e857f4 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp @@ -1,25 +1,51 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkCommonExtPlugin.h" #include -void QmitkCommonExtPlugin::Start(berry::IBundleContext::Pointer /*context*/) +#include "../QmitkExtPreferencePage.h" +#include "../QmitkInputDevicesPrefPage.h" + +#include + +ctkPluginContext* QmitkCommonExtPlugin::_context = 0; + +void QmitkCommonExtPlugin::start(ctkPluginContext* context) +{ + this->_context = context; + + QmitkExtRegisterClasses(); + + BERRY_REGISTER_EXTENSION_CLASS(QmitkExtPreferencePage, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkInputDevicesPrefPage, context) +} + +void QmitkCommonExtPlugin::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + + this->_context = 0; +} + +ctkPluginContext* QmitkCommonExtPlugin::getContext() { - QmitkExtRegisterClasses(); + return _context; } + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_ext, QmitkCommonExtPlugin) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h index 5845f19e54..f7b5e63220 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h @@ -1,32 +1,42 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKCOMMONEXTPLUGIN_H_ #define QMITKCOMMONEXTPLUGIN_H_ -#include +#include -class QmitkCommonExtPlugin : public berry::Plugin +class QmitkCommonExtPlugin : public QObject, public ctkPluginActivator { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + public: - void Start(berry::IBundleContext::Pointer context); + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + + static ctkPluginContext* getContext(); + +private: + + static ctkPluginContext* _context; }; #endif /* QMITKCOMMONEXTPLUGIN_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/CMakeLists.txt b/Modules/Bundles/org.mitk.gui.qt.extapplication/CMakeLists.txt index 8de641b0c1..b23edacdae 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/CMakeLists.txt +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/CMakeLists.txt @@ -1,5 +1,6 @@ -INCLUDE(${QT_USE_FILE}) +PROJECT(org_mitk_gui_qt_extapplication) -MACRO_CREATE_MITK_PLUGIN() - -TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ${QT_LIBRARIES}) \ No newline at end of file +MACRO_CREATE_MITK_CTK_PLUGIN( + EXPORT_DIRECTIVE MITK_QT_EXTAPP + EXPORTED_INCLUDE_SUFFIXES src +) diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/META-INF/MANIFEST.MF b/Modules/Bundles/org.mitk.gui.qt.extapplication/META-INF/MANIFEST.MF deleted file mode 100644 index daad17bc17..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: MITK Ext Application -Bundle-SymbolicName: org.mitk.gui.qt.extapplication -Bundle-Version: 1.0.0 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Bundle-Activator: QmitkExtApplicationPlugin -Require-Bundle: org.mitk.gui.qt.ext \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/MitkExtQtHelpCollectionProject.qhcp b/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/MitkExtQtHelpCollectionProject.qhcp index 24c2f774e3..5e40147f58 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/MitkExtQtHelpCollectionProject.qhcp +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/MitkExtQtHelpCollectionProject.qhcp @@ -1,17 +1,17 @@ MITK Help - qthelp://org.mitk.gui.qt.extapplication/bundle/index.html - false + qthelp://org.mitk.gui.qt.extapplication/bundle/index.html + false false true MitkExt About MITK Help - \ No newline at end of file + diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/files.cmake b/Modules/Bundles/org.mitk.gui.qt.extapplication/files.cmake index 08976692fa..69f823e5e5 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/files.cmake +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/files.cmake @@ -1,49 +1,52 @@ SET(SRC_CPP_FILES QmitkExtApplication.cpp QmitkExtAppWorkbenchAdvisor.cpp ) SET(INTERNAL_CPP_FILES QmitkExtApplicationPlugin.cpp QmitkExtDefaultPerspective.cpp ) SET(MOC_H_FILES - + src/QmitkExtApplication.h + src/internal/QmitkExtApplicationPlugin.h + src/internal/QmitkExtDefaultPerspective.h ) -SET(RESOURCE_FILES +SET(CACHED_RESOURCE_FILES # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench + plugin.xml resources/icon_research.xpm ) -SET(RES_FILES +SET(QRC_FILES # uncomment the following line if you want to use Qt resources resources/QmitkExtApplication.qrc ) -SET(CPP_FILES manifest.cpp) +SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) #----------- Qt Help Collection Project -------------# IF (BLUEBERRY_USE_QT_HELP) SET(_plugin_qhcp_input "${CMAKE_CURRENT_SOURCE_DIR}/documentation/MitkExtQtHelpCollectionProject.qhcp") - SET(_plugin_qhcp_output "${PLUGIN_OUTPUT_DIR}/resources/MitkExtQtHelpCollection_${MITK_WC_REVISION_HASH}.qhc") + SET(_plugin_qhcp_output "${CMAKE_CURRENT_BINARY_DIR}/MitkExtQtHelpCollection_${MITK_WC_REVISION_HASH}.qhc") ADD_CUSTOM_COMMAND(OUTPUT ${_plugin_qhcp_output} COMMAND ${QT_COLLECTIONGENERATOR_EXECUTABLE} ${_plugin_qhcp_input} -o ${_plugin_qhcp_output} DEPENDS ${_plugin_qhcp_input} ) - SET(FILE_DEPENDENCIES ${_plugin_qhcp_output}) + LIST(APPEND CACHED_RESOURCE_FILES ${_plugin_qhcp_output}) ENDIF() diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/manifest.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/manifest.cpp deleted file mode 100644 index c7c9dfd60a..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/manifest.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. - -=========================================================================*/ - -#include - -#include "src/QmitkExtApplication.h" -#include "src/internal/QmitkExtApplicationPlugin.h" -#include "src/internal/QmitkExtDefaultPerspective.h" - -POCO_BEGIN_MANIFEST(berry::IBundleActivator) - POCO_EXPORT_CLASS(QmitkExtApplicationPlugin) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryIApplication, berry::IApplication) - POCO_EXPORT_CLASS(QmitkExtApplication) -POCO_END_MANIFEST - -POCO_BEGIN_NAMED_MANIFEST(berryIPerspectiveFactory, berry::IPerspectiveFactory) - POCO_EXPORT_CLASS(QmitkExtDefaultPerspective) -POCO_END_MANIFEST diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.extapplication/manifest_headers.cmake new file mode 100644 index 0000000000..0462ac1ab9 --- /dev/null +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Ext Application") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.ext) diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.cpp index e3ef6334a4..1c69240e61 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.cpp @@ -1,62 +1,62 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkExtAppWorkbenchAdvisor.h" #include "internal/QmitkExtApplicationPlugin.h" #include #include const std::string QmitkExtAppWorkbenchAdvisor::DEFAULT_PERSPECTIVE_ID = "org.mitk.extapp.defaultperspective"; void QmitkExtAppWorkbenchAdvisor::Initialize(berry::IWorkbenchConfigurer::Pointer configurer) { berry::QtWorkbenchAdvisor::Initialize(configurer); configurer->SetSaveAndRestore(true); QString collectionFile = QmitkExtApplicationPlugin::GetDefault()->GetQtHelpCollectionFile(); if (!collectionFile.isEmpty()) { - berry::IBundleContext::Pointer context = QmitkExtApplicationPlugin::GetDefault()->GetBundleContext(); + ctkPluginContext* context = QmitkExtApplicationPlugin::GetDefault()->GetPluginContext(); typedef std::vector BundleContainer; - BundleContainer bundles; - context->ListBundles(bundles); - berry::QtAssistantUtil::RegisterQCHFiles(collectionFile, bundles); + BundleContainer bundles = berry::Platform::GetBundles(); + QList > plugins = context->getPlugins(); + berry::QtAssistantUtil::RegisterQCHFiles(collectionFile, bundles, plugins); } berry::QtAssistantUtil::SetHelpColletionFile(collectionFile); berry::QtAssistantUtil::SetDefaultHelpUrl("qthelp://org.mitk.gui.qt.extapplication/bundle/index.html"); } berry::WorkbenchWindowAdvisor* QmitkExtAppWorkbenchAdvisor::CreateWorkbenchWindowAdvisor( berry::IWorkbenchWindowConfigurer::Pointer configurer) { QmitkExtWorkbenchWindowAdvisor* advisor = new QmitkExtWorkbenchWindowAdvisor(this, configurer); advisor->SetWindowIcon(":/QmitkExtApplication/icon_research.xpm"); return advisor; //return new QmitkExtWorkbenchWindowAdvisor(this, configurer); } std::string QmitkExtAppWorkbenchAdvisor::GetInitialWindowPerspectiveId() { return DEFAULT_PERSPECTIVE_ID; } diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.cpp index 5b01a23fa6..fc458628d9 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.cpp @@ -1,38 +1,49 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkExtApplication.h" #include #include "QmitkExtAppWorkbenchAdvisor.h" +QmitkExtApplication::QmitkExtApplication() +{ + +} + +QmitkExtApplication::QmitkExtApplication(const QmitkExtApplication& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + int QmitkExtApplication::Start() { berry::Display* display = berry::PlatformUI::CreateDisplay(); int code = berry::PlatformUI::CreateAndRunWorkbench(display, new QmitkExtAppWorkbenchAdvisor()); // exit the application with an appropriate return code return code == berry::PlatformUI::RETURN_RESTART ? EXIT_RESTART : EXIT_OK; } void QmitkExtApplication::Stop() { } diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.h index b2ee27bad2..6d645d75bd 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.h +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.h @@ -1,33 +1,39 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKEXTAPPLICATION_H_ #define QMITKEXTAPPLICATION_H_ #include #include "mitkQtExtAppDll.h" -class MITK_QT_EXTAPP QmitkExtApplication : public berry::IApplication +class MITK_QT_EXTAPP QmitkExtApplication : public QObject, public berry::IApplication { + Q_OBJECT + Q_INTERFACES(berry::IApplication) + public: + + QmitkExtApplication(); + QmitkExtApplication(const QmitkExtApplication& other); int Start(); void Stop(); }; #endif /*QMITKEXTAPPLICATION_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp index 8bf789aacf..e19f41b00d 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp @@ -1,64 +1,92 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkExtApplicationPlugin.h" +#include "QmitkExtDefaultPerspective.h" +#include "../QmitkExtApplication.h" #include #include +#include +#include QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::inst = 0; QmitkExtApplicationPlugin::QmitkExtApplicationPlugin() { inst = this; } QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::GetDefault() { return inst; } -void QmitkExtApplicationPlugin::Start(berry::IBundleContext::Pointer context) +void QmitkExtApplicationPlugin::start(ctkPluginContext* context) { + berry::AbstractUICTKPlugin::start(context); + this->context = context; + + BERRY_REGISTER_EXTENSION_CLASS(QmitkExtDefaultPerspective, context); + BERRY_REGISTER_EXTENSION_CLASS(QmitkExtApplication, context); } -berry::IBundleContext::Pointer QmitkExtApplicationPlugin::GetBundleContext() const +ctkPluginContext* QmitkExtApplicationPlugin::GetPluginContext() const { return context; } QString QmitkExtApplicationPlugin::GetQtHelpCollectionFile() const { - Poco::Path collectionPath = context->GetThisBundle()->GetPath(); - collectionPath.pushDirectory("resources"); - - std::string collectionFilename; - std::string na = "n/a"; + QString collectionFilename; + QString na("n/a"); if (na != MITK_REVISION) collectionFilename = "MitkExtQtHelpCollection_" MITK_REVISION ".qhc"; else collectionFilename = "MitkExtQtHelpCollection.qhc"; - collectionPath.setFileName(collectionFilename); + QFileInfo collectionFileInfo = context->getDataFile(collectionFilename); + QFileInfo pluginFileInfo = QFileInfo(QUrl(context->getPlugin()->getLocation()).toLocalFile()); + + if (!collectionFileInfo.exists() || + pluginFileInfo.lastModified() > collectionFileInfo.lastModified()) + { + // extract the qhc file from the plug-in + QByteArray content = context->getPlugin()->getResource(collectionFilename); + if (content.isEmpty()) + { + BERRY_WARN << "Could not get plug-in resource: " << collectionFilename.toStdString(); + } + else + { + QFile file(collectionFileInfo.canonicalFilePath()); + file.open(QIODevice::WriteOnly); + file.write(content); + } + } - QString collectionFile = QString::fromStdString(collectionPath.toString()); - if (QFileInfo(collectionFile).exists()) - return collectionFile; - return QString(""); + if (collectionFileInfo.exists()) + { + return collectionFileInfo.absoluteFilePath(); + } + + return QString(); } + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_extapplication, QmitkExtApplicationPlugin) diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h index b70cc55a0f..bed364617c 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h @@ -1,47 +1,50 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKEXTAPPLICATIONPLUGIN_H_ #define QMITKEXTAPPLICATIONPLUGIN_H_ -#include +#include #include -class QmitkExtApplicationPlugin : public berry::AbstractUIPlugin +class QmitkExtApplicationPlugin : public QObject, public berry::AbstractUICTKPlugin { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + public: QmitkExtApplicationPlugin(); static QmitkExtApplicationPlugin* GetDefault(); - berry::IBundleContext::Pointer GetBundleContext() const; + ctkPluginContext* GetPluginContext() const; - void Start(berry::IBundleContext::Pointer); + void start(ctkPluginContext*); QString GetQtHelpCollectionFile() const; private: static QmitkExtApplicationPlugin* inst; - berry::IBundleContext::Pointer context; + ctkPluginContext* context; }; #endif /* QMITKEXTAPPLICATIONPLUGIN_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp index 3ce52c16dc..0dc572ab61 100755 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp @@ -1,38 +1,47 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #include "QmitkExtDefaultPerspective.h" #include "berryIViewLayout.h" +QmitkExtDefaultPerspective::QmitkExtDefaultPerspective() +{ +} + +QmitkExtDefaultPerspective::QmitkExtDefaultPerspective(const QmitkExtDefaultPerspective& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} void QmitkExtDefaultPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { std::string editorArea = layout->GetEditorArea(); layout->AddView("org.mitk.views.datamanager", berry::IPageLayout::LEFT, 0.3f, editorArea); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.datamanager"); lo->SetCloseable(false); layout->AddView("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, 0.5f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer bottomFolder = layout->CreateFolder("bottom", berry::IPageLayout::BOTTOM, 0.7f, editorArea); bottomFolder->AddView("org.mitk.views.propertylistview"); bottomFolder->AddView("org.blueberry.views.logview"); } diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h index 86f2263e17..7410a50c58 100755 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h @@ -1,31 +1,38 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html 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 notices for more information. =========================================================================*/ #ifndef QMITKEXTDEFAULTPERSPECTIVE_H_ #define QMITKEXTDEFAULTPERSPECTIVE_H_ #include -struct QmitkExtDefaultPerspective : public berry::IPerspectiveFactory +class QmitkExtDefaultPerspective : public QObject, public berry::IPerspectiveFactory { - + Q_OBJECT + Q_INTERFACES(berry::IPerspectiveFactory) + +public: + + QmitkExtDefaultPerspective(); + QmitkExtDefaultPerspective(const QmitkExtDefaultPerspective& other); + void CreateInitialLayout(berry::IPageLayout::Pointer layout); }; #endif /* QMITKEXTDEFAULTPERSPECTIVE_H_ */