diff --git a/CMakeLists.txt b/CMakeLists.txt index 9420268412..abf1e8704d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,1022 +1,1022 @@ if(MITK_USE_QT AND DESIRED_QT_VERSION MATCHES 5) cmake_minimum_required(VERSION 2.8.9) elseif(APPLE) # With XCode 4.3, the SDK location changed. Older CMake # versions are not able to find it. cmake_minimum_required(VERSION 2.8.8) else() cmake_minimum_required(VERSION 2.8.5) endif() #----------------------------------------------------------------------------- # Include ctest launchers for dashboard in case of makefile generator #----------------------------------------------------------------------------- if(${CMAKE_VERSION} VERSION_GREATER "2.8.9") include(CTestUseLaunchers) endif() #----------------------------------------------------------------------------- # Set a default build type if none was specified #----------------------------------------------------------------------------- if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Debug' as none was specified.") set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() #----------------------------------------------------------------------------- # Superbuild Option - Enabled by default #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON) if(MITK_USE_SUPERBUILD) project(MITK-superbuild) set(MITK_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(MITK_BINARY_DIR ${PROJECT_BINARY_DIR}) else() project(MITK) endif() #----------------------------------------------------------------------------- # Warn if source or build path is too long #----------------------------------------------------------------------------- if(WIN32) set(_src_dir_length_max 50) set(_bin_dir_length_max 50) if(MITK_USE_SUPERBUILD) set(_src_dir_length_max 43) # _src_dir_length_max - strlen(ITK-src) set(_bin_dir_length_max 40) # _bin_dir_length_max - strlen(MITK-build) endif() string(LENGTH "${MITK_SOURCE_DIR}" _src_n) string(LENGTH "${MITK_BINARY_DIR}" _bin_n) # The warnings should be converted to errors if(_src_n GREATER _src_dir_length_max) message(WARNING "MITK source code directory path length is too long (${_src_n} > ${_src_dir_length_max})." "Please move the MITK source code directory to a directory with a shorter path." ) endif() if(_bin_n GREATER _bin_dir_length_max) message(WARNING "MITK build directory path length is too long (${_bin_n} > ${_bin_dir_length_max})." "Please move the MITK build directory to a directory with a shorter path." ) endif() endif() #----------------------------------------------------------------------------- # See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details #----------------------------------------------------------------------------- set(project_policies CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used. CMP0002 # NEW: Logical target names must be globally unique. CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths. CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace. CMP0005 # NEW: Preprocessor definition values are now escaped automatically. CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION. CMP0007 # NEW: List command no longer ignores empty elements. CMP0008 # NEW: Libraries linked by full-path must have a valid library file name. CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default. CMP0010 # NEW: Bad variable reference syntax is an error. CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP. CMP0012 # NEW: if() recognizes numbers and boolean constants. CMP0013 # NEW: Duplicate binary directories are not allowed. CMP0014 # NEW: Input directories must have CMakeLists.txt CMP0020 # NEW: Automatically link Qt executables to qtmain target on Windows ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ set(MITK_CMAKE_DIR ${MITK_SOURCE_DIR}/CMake) set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR} ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) include(mitkFunctionSuppressWarnings) SUPPRESS_VC_DEPRECATED_WARNINGS() #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- foreach(type LIBRARY RUNTIME ARCHIVE) # Make sure the directory exists if(DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY AND NOT EXISTS ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) message("Creating directory MITK_CMAKE_${type}_OUTPUT_DIRECTORY: ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") file(MAKE_DIRECTORY "${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") endif() if(MITK_USE_SUPERBUILD) set(output_dir ${MITK_BINARY_DIR}/bin) if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_BINARY_DIR}/MITK-build/bin) endif() else() if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(output_dir ${MITK_BINARY_DIR}/bin) else() set(output_dir ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) endif() endif() set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.") mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) endforeach() #----------------------------------------------------------------------------- # Additional MITK Options (also shown during superbuild) #----------------------------------------------------------------------------- option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON) option(WITH_COVERAGE "Enable/Disable coverage" OFF) option(BUILD_TESTING "Test the project" ON) option(MITK_BUILD_ALL_APPS "Build all MITK applications" OFF) set(MITK_BUILD_TUTORIAL OFF CACHE INTERNAL "Deprecated! Use MITK_BUILD_EXAMPLES instead!") option(MITK_BUILD_EXAMPLES "Build the MITK Examples" ${MITK_BUILD_TUTORIAL}) option(MITK_USE_ACVD "Use Approximated Centroidal Voronoi Diagrams" OFF) option(MITK_USE_GLEW "Use the GLEW library" ON) option(MITK_USE_Boost "Use the Boost C++ library" OFF) option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) option(MITK_USE_CTK "Use CTK in MITK" ${MITK_USE_BLUEBERRY}) option(MITK_USE_QT "Use Nokia's Qt library" ${MITK_USE_CTK}) set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 4 or 5") set(MITK_DESIRED_QT_VERSION ${DESIRED_QT_VERSION}) option(MITK_USE_DCMTK "EXPERIMENTAL, superbuild only: Use DCMTK in MITK" ${MITK_USE_CTK}) option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) option(MITK_USE_OpenCL "Use OpenCL GPU-Computing library" OFF) option(MITK_USE_Poco "Use the Poco library" ON) option(MITK_USE_SOFA "Use Simulation Open Framework Architecture" OFF) option(MITK_USE_Python "Use Python wrapping in MITK" OFF) set(MITK_USE_CableSwig ${MITK_USE_Python}) option(MITK_ENABLE_PIC_READER "Enable support for reading the DKFZ pic file format." ON) mark_as_advanced(MITK_BUILD_ALL_APPS MITK_USE_GLEW MITK_USE_CTK MITK_USE_DCMTK MITK_ENABLE_PIC_READER ) if(MITK_USE_Python) FIND_PACKAGE(PythonLibs REQUIRED) FIND_PACKAGE(PythonInterp REQUIRED) endif() if(MITK_USE_Boost) option(MITK_USE_SYSTEM_Boost "Use the system Boost" OFF) set(MITK_USE_Boost_LIBRARIES "" CACHE STRING "A semi-colon separated list of required Boost libraries") endif() if(MITK_USE_BLUEBERRY) if(NOT DESIRED_QT_VERSION MATCHES 4) message("Forcing MITK_USE_BLUEBERRY to OFF because of DESIRED_QT_VERSION ${DESIRED_QT_VERSION}") set(MITK_USE_BLUEBERRY OFF CACHE BOOL "Build the BlueBerry application platform" FORCE) endif() endif() if(MITK_USE_BLUEBERRY) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) mark_as_advanced(MITK_BUILD_ALL_PLUGINS) if(NOT MITK_USE_CTK) message("Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY") set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE) endif() endif() if(MITK_USE_CTK) if(NOT MITK_USE_QT) message("Forcing MITK_USE_QT to ON because of MITK_USE_CTK") set(MITK_USE_QT ON CACHE BOOL "Use Nokia's Qt library in MITK" FORCE) else() if(NOT DESIRED_QT_VERSION MATCHES 4) message("Forcing MITK_USE_CTK to OFF because of DESIRED_QT_VERSION ${DESIRED_QT_VERSION}") set(MITK_USE_CTK OFF CACHE BOOL "Use CTK in MITK" FORCE) endif() endif() if(NOT MITK_USE_DCMTK) message("Setting MITK_USE_DCMTK to ON because DCMTK needs to be build for CTK") set(MITK_USE_DCMTK ON CACHE BOOL "Use DCMTK in MITK" FORCE) endif() endif() if(MITK_USE_QT) # find the package at the very beginning, so that QT4_FOUND is available if(DESIRED_QT_VERSION MATCHES 4) set(MITK_QT4_MINIMUM_VERSION 4.6.2) find_package(Qt4 ${MITK_QT4_MINIMUM_VERSION} REQUIRED) set(MITK_USE_Qt4 TRUE) set(MITK_USE_Qt5 FALSE) endif(DESIRED_QT_VERSION MATCHES 4) if(DESIRED_QT_VERSION MATCHES 5) set(MITK_QT5_MINIMUM_VERSION 5.0.0) set(MITK_USE_Qt4 FALSE) set(MITK_USE_Qt5 TRUE) endif(DESIRED_QT_VERSION MATCHES 5) endif() if(MITK_USE_SOFA) # SOFA requires at least CMake 2.8.8 set(SOFA_CMAKE_VERSION 2.8.8) if(${CMAKE_VERSION} VERSION_LESS ${SOFA_CMAKE_VERSION}) set(MITK_USE_SOFA OFF CACHE BOOL "" FORCE) message(WARNING "Switched off MITK_USE_SOFA\n Minimum required CMake version: ${SOFA_CMAKE_VERSION}\n Installed CMake version: ${CMAKE_VERSION}") endif() # SOFA doesn't support Clang if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(MITK_USE_SOFA OFF CACHE BOOL "" FORCE) message(WARNING "Switched off MITK_USE_SOFA\n Clang is not supported, use GCC instead.") endif() # SOFA/ITK combination requires at least MSVC 2010 if(MSVC_VERSION AND MSVC_VERSION LESS 1600) set(MITK_USE_SOFA OFF CACHE BOOL "" FORCE) message(WARNING "Switched off MITK_USE_SOFA\n MSVC versions less than 2010 are not supported.") endif() # SOFA requires boost library if(MITK_USE_SOFA AND NOT MITK_USE_Boost) message("Forcing MITK_USE_Boost to ON because of MITK_USE_SOFA") set(MITK_USE_Boost ON CACHE BOOL "" FORCE) endif() # SOFA requires boost system library list(FIND MITK_USE_Boost_LIBRARIES system _result) if(_result LESS 0) message("Adding 'system' to MITK_USE_Boost_LIBRARIES.") list(APPEND MITK_USE_Boost_LIBRARIES system) endif() # SOFA requires boost thread library list(FIND MITK_USE_Boost_LIBRARIES thread _result) if(_result LESS 0) message("Adding 'thread' to MITK_USE_Boost_LIBRARIES.") list(APPEND MITK_USE_Boost_LIBRARIES thread) endif() set(MITK_USE_Boost_LIBRARIES ${MITK_USE_Boost_LIBRARIES} CACHE STRING "" FORCE) endif() # Customize the default pixel types for multiplex macros set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") mark_as_advanced(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES MITK_ACCESSBYITK_DIMENSIONS ) # consistency checks if(NOT MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES) set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES) set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES) set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_DIMENSIONS) set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") endif() #----------------------------------------------------------------------------- # Project.xml #----------------------------------------------------------------------------- # A list of topologically ordered targets set(CTEST_PROJECT_SUBPROJECTS) if(MITK_USE_BLUEBERRY) list(APPEND CTEST_PROJECT_SUBPROJECTS BlueBerry) endif() list(APPEND CTEST_PROJECT_SUBPROJECTS MITK-Core MITK-CoreUI MITK-IGT MITK-ToF MITK-DTI MITK-Registration MITK-Modules # all modules not contained in a specific subproject MITK-Plugins # all plugins not contained in a specific subproject MITK-Examples Unlabeled # special "subproject" catching all unlabeled targets and tests ) # Configure CTestConfigSubProject.cmake that could be used by CTest scripts configure_file(${MITK_SOURCE_DIR}/CTestConfigSubProject.cmake.in ${MITK_BINARY_DIR}/CTestConfigSubProject.cmake) if(CTEST_PROJECT_ADDITIONAL_TARGETS) # those targets will be executed at the end of the ctest driver script # and they also get their own subproject label set(subproject_list "${CTEST_PROJECT_SUBPROJECTS};${CTEST_PROJECT_ADDITIONAL_TARGETS}") else() set(subproject_list "${CTEST_PROJECT_SUBPROJECTS}") endif() # Generate Project.xml file expected by the CTest driver script mitkFunctionGenerateProjectXml(${MITK_BINARY_DIR} MITK "${subproject_list}" ${MITK_USE_SUPERBUILD}) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(CheckCXXSourceCompiles) include(mitkFunctionCheckCompilerFlags) include(mitkFunctionGetGccVersion) include(MacroParseArguments) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkFunctionOrganizeSources) include(mitkFunctionGetVersion) include(mitkFunctionGetVersionDescription) include(mitkFunctionCreateWindowsBatchScript) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionInstallAutoLoadModules) include(mitkFunctionGetLibrarySearchPaths) include(mitkFunctionCompileSnippets) include(mitkFunctionUseModules) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) include(mitkMacroCreateExecutable) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) include(mitkMacroGetPMDPlatformString) #----------------------------------------------------------------------------- # Prerequesites #----------------------------------------------------------------------------- find_package(ITK REQUIRED) find_package(VTK REQUIRED) find_package(GDCM PATHS ${ITK_GDCM_DIR} REQUIRED) #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- # ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and mitkWorkbench option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON) mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW) # TODO: check if necessary option(USE_ITKZLIB "Use the ITK zlib for pic compression." ON) mark_as_advanced(USE_ITKZLIB) if(NOT MITK_FAST_TESTING) if(DEFINED MITK_CTEST_SCRIPT_MODE AND (MITK_CTEST_SCRIPT_MODE STREQUAL "continuous" OR MITK_CTEST_SCRIPT_MODE STREQUAL "experimental") ) set(MITK_FAST_TESTING 1) endif() endif() #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) mitkFunctionGetVersionDescription(${MITK_SOURCE_DIR} MITK) #----------------------------------------------------------------------------- # Installation preparation # # These should be set before any MITK install macros are used #----------------------------------------------------------------------------- # on Mac OSX all BlueBerry plugins get copied into every # application bundle (.app directory) specified here if(MITK_USE_BLUEBERRY AND APPLE) include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 1 option_name) list(GET target_info_list 0 app_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} ${app_name}) endif() endforeach() endif() #----------------------------------------------------------------------------- # Set symbol visibility Flags #----------------------------------------------------------------------------- # MinGW does not export all symbols automatically, so no need to set flags if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW) set(VISIBILITY_CXX_FLAGS ) #"-fvisibility=hidden -fvisibility-inlines-hidden") endif() #----------------------------------------------------------------------------- # Set coverage Flags #----------------------------------------------------------------------------- if(WITH_COVERAGE) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG") set(COVERAGE_CXX_FLAGS ${coverage_flags}) set(COVERAGE_C_FLAGS ${coverage_flags}) endif() endif() #----------------------------------------------------------------------------- # MITK C/CXX Flags #----------------------------------------------------------------------------- set(MITK_C_FLAGS "${COVERAGE_C_FLAGS}") set(MITK_C_FLAGS_DEBUG ) set(MITK_C_FLAGS_RELEASE ) set(MITK_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS}") set(MITK_CXX_FLAGS_DEBUG ) set(MITK_CXX_FLAGS_RELEASE ) set(MITK_EXE_LINKER_FLAGS ) set(MITK_SHARED_LINKER_FLAGS ) include(mitkSetupC++0xVariables) if(WIN32) set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -D_WIN32_WINNT=0x0501 -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN") set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} /wd4231") # warning C4231: nonstandard extension used : 'extern' before template explicit instantiation endif() if(NOT MSVC_VERSION) foreach(_flag -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=gnu -Wno-error=unknown-pragmas # The strict-overflow warning is generated by ITK template code -Wno-error=strict-overflow -Woverloaded-virtual -Wstrict-null-sentinel #-Wold-style-cast #-Wsign-promo # the following two lines should be removed after ITK-3097 has # been resolved, see also MITK bug 15279 -Wno-unused-local-typedefs -Wno-array-bounds -fdiagnostics-show-option ) mitkFunctionCheckCAndCXXCompilerFlags(${_flag} MITK_C_FLAGS MITK_CXX_FLAGS) endforeach() endif() mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS) mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS) if(MITK_USE_C++0x) mitkFunctionCheckCompilerFlags("-std=c++0x" MITK_CXX_FLAGS) endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag. # Doing so should allow to build package made for distribution using older linux distro. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0")) mitkFunctionCheckCAndCXXCompilerFlags("-fstack-protector-all" MITK_C_FLAGS MITK_CXX_FLAGS) endif() if(MINGW) # suppress warnings about auto imported symbols set(MITK_SHARED_LINKER_FLAGS "-Wl,--enable-auto-import ${MITK_SHARED_LINKER_FLAGS}") endif() set(MITK_CXX_FLAGS_RELEASE "-D_FORTIFY_SOURCE=2 ${MITK_CXX_FLAGS_RELEASE}") endif() set(MITK_MODULE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) set(MITK_EXE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) #----------------------------------------------------------------------------- # MITK Packages #----------------------------------------------------------------------------- set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR} ${MITK_MODULES_PACKAGE_DEPENDS_DIR}/Qt) #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) option(MITK_ENABLE_RENDERING_TESTING OFF "Enable the MITK rendering tests. Requires x-server in Linux.") #Rendering testing does not work for Linux nightlies, thus it is disabled per default #and activated for Mac and Windows. if(WIN32 OR APPLE) set(MITK_ENABLE_RENDERING_TESTING ON) endif() mark_as_advanced( MITK_ENABLE_RENDERING_TESTING ) # Setup file for setting custom ctest vars configure_file( CMake/CTestCustom.cmake.in ${MITK_BINARY_DIR}/CTestCustom.cmake @ONLY ) # Configuration for the CMake-generated test driver set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ") set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " try {") set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " } catch( std::exception & excp ) { fprintf(stderr,\"%s\\n\",excp.what()); return EXIT_FAILURE; } catch( ... ) { printf(\"Exception caught in the test driver\\n\"); return EXIT_FAILURE; } ") set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output") if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR}) file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR}) endif() # Test the external project template if(MITK_USE_BLUEBERRY) include(mitkTestProjectTemplate) endif() # Test the package target include(mitkPackageTest) endif() configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h) #----------------------------------------------------------------------------- # MITK_SUPERBUILD_BINARY_DIR #----------------------------------------------------------------------------- # If MITK_SUPERBUILD_BINARY_DIR isn't defined, it means MITK is *NOT* build using Superbuild. # In that specific case, MITK_SUPERBUILD_BINARY_DIR should default to MITK_BINARY_DIR if(NOT DEFINED MITK_SUPERBUILD_BINARY_DIR) set(MITK_SUPERBUILD_BINARY_DIR ${MITK_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # Compile Utilities and set-up MITK variables #----------------------------------------------------------------------------- include(mitkSetupVariables) #----------------------------------------------------------------------------- # Cleanup #----------------------------------------------------------------------------- file(GLOB _MODULES_CONF_FILES ${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME}/*.cmake) if(_MODULES_CONF_FILES) file(REMOVE ${_MODULES_CONF_FILES}) endif() add_subdirectory(Utilities) if(MITK_USE_BLUEBERRY) # We need to hack a little bit because MITK applications may need # to enable certain BlueBerry plug-ins. However, these plug-ins # are validated separately from the MITK plug-ins and know nothing # about potential MITK plug-in dependencies of the applications. Hence # we cannot pass the MITK application list to the BlueBerry # ctkMacroSetupPlugins call but need to extract the BlueBerry dependencies # from the applications and set them explicitly. include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") foreach(mitk_app ${MITK_APPS}) # extract target_dir and option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 target_dir) list(GET target_info_list 1 option_name) # check if the application is enabled and if target_libraries.cmake exists if((${option_name} OR MITK_BUILD_ALL_APPS) AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/target_libraries.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/target_libraries.cmake") foreach(_target_dep ${target_libraries}) if(_target_dep MATCHES org_blueberry_) string(REPLACE _ . _app_bb_dep ${_target_dep}) # explicitly set the build option for the BlueBerry plug-in set(BLUEBERRY_BUILD_${_app_bb_dep} ON CACHE BOOL "Build the ${_app_bb_dep} plug-in") endif() endforeach() endif() endforeach() set(mbilog_DIR "${mbilog_BINARY_DIR}") if(MITK_BUILD_ALL_PLUGINS) set(BLUEBERRY_BUILD_ALL_PLUGINS ON) endif() set(BLUEBERRY_XPDOC_OUTPUT_DIR ${MITK_DOXYGEN_OUTPUT_DIR}/html/extension-points/html/) add_subdirectory(BlueBerry) set(BlueBerry_DIR ${CMAKE_CURRENT_BINARY_DIR}/BlueBerry CACHE PATH "The directory containing a CMake configuration file for BlueBerry" FORCE) include(mitkMacroCreateCTKPlugin) endif() #----------------------------------------------------------------------------- # Set C/CXX and linker flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MITK_CXX_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MITK_CXX_FLAGS_RELEASE}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MITK_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${MITK_C_FLAGS_RELEASE}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MITK_EXE_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MITK_SHARED_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${MITK_MODULE_LINKER_FLAGS}") #----------------------------------------------------------------------------- # Add custom targets representing CDash subprojects #----------------------------------------------------------------------------- foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) if(NOT TARGET ${subproject} AND NOT subproject MATCHES "Unlabeled") add_custom_target(${subproject}) endif() endforeach() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- add_subdirectory(Core) add_subdirectory(Modules) if(MITK_USE_BLUEBERRY) find_package(BlueBerry REQUIRED) set(MITK_DEFAULT_SUBPROJECTS MITK-Plugins) # Plug-in testing (needs some work to be enabled again) if(BUILD_TESTING) include(berryTestingHelpers) set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp") get_target_property(_is_macosx_bundle CoreApp MACOSX_BUNDLE) if(APPLE AND _is_macosx_bundle) set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.app/Contents/MacOS/CoreApp") endif() set(BLUEBERRY_TEST_APP_ID "org.mitk.qt.coreapplication") endif() include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake") set(mitk_plugins_fullpath ) foreach(mitk_plugin ${MITK_EXT_PLUGINS}) list(APPEND mitk_plugins_fullpath Plugins/${mitk_plugin}) endforeach() if(EXISTS ${MITK_PRIVATE_MODULES}/PluginList.cmake) include(${MITK_PRIVATE_MODULES}/PluginList.cmake) foreach(mitk_plugin ${MITK_PRIVATE_PLUGINS}) list(APPEND mitk_plugins_fullpath ${MITK_PRIVATE_MODULES}/${mitk_plugin}) endforeach() endif() if(MITK_BUILD_EXAMPLES) - include("${CMAKE_CURRENT_SOURCE_DIR}/Examples/Plugins/PluginList.cmake") + include("${CMAKE_CURRENT_SOURCE_DIR}/Examples/Plugins/PluginList.cmake") set(mitk_example_plugins_fullpath ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) list(APPEND mitk_example_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) list(APPEND mitk_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) endforeach() endif() # Specify which plug-ins belong to this project macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin_mitk "^org_mitk_[a-zA-Z0-9_]+$") set(re_ctkplugin_bb "^org_blueberry_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin_mitk re_ctkplugin_bb OUTPUT_VARIABLE ${varname}) endmacro() # Get infos about application directories and build options include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") set(mitk_apps_fullpath ) foreach(mitk_app ${MITK_APPS}) list(APPEND mitk_apps_fullpath "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${mitk_app}") endforeach() if (mitk_plugins_fullpath) ctkMacroSetupPlugins(${mitk_plugins_fullpath} BUILD_OPTION_PREFIX MITK_BUILD_ APPS ${mitk_apps_fullpath} BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) endif() set(MITK_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkPluginUseFile.cmake") if(${PROJECT_NAME}_PLUGIN_LIBRARIES) ctkFunctionGeneratePluginUseFile(${MITK_PLUGIN_USE_FILE}) else() file(REMOVE ${MITK_PLUGIN_USE_FILE}) set(MITK_PLUGIN_USE_FILE ) endif() # 11.3.13, change, muellerm: activate python bundle if python and blueberry is active if( MITK_USE_Python ) set(MITK_BUILD_org.mitk.gui.qt.python ON) endif() endif() #----------------------------------------------------------------------------- # Python Wrapping #----------------------------------------------------------------------------- option(MITK_USE_Python "Build Python integration for MITK (requires CableSwig)." OFF) #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- add_subdirectory(Documentation) #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables # These are the default variables, which can be overwritten ( see below ) include(mitkSetupCPack) set(use_default_config ON) # MITK_APPS is set in Applications/AppList.cmake (included somewhere above # if MITK_USE_BLUEBERRY is set to ON). if(MITK_APPS) set(activated_apps_no 0) list(LENGTH MITK_APPS app_count) # Check how many apps have been enabled # If more than one app has been activated, the we use the # default CPack configuration. Otherwise that apps configuration # will be used, if present. foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 1 option_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) MATH(EXPR activated_apps_no "${activated_apps_no} + 1") endif() endforeach() if(app_count EQUAL 1 AND (activated_apps_no EQUAL 1 OR MITK_BUILD_ALL_APPS)) # Corner case if there is only one app in total set(use_project_cpack ON) elseif(activated_apps_no EQUAL 1 AND NOT MITK_BUILD_ALL_APPS) # Only one app is enabled (no "build all" flag set) set(use_project_cpack ON) else() # Less or more then one app is enabled set(use_project_cpack OFF) endif() foreach(mitk_app ${MITK_APPS}) # extract target_dir and option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 target_dir) list(GET target_info_list 1 option_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) # check whether application specific configuration files will be used if(use_project_cpack) # use files if they exist if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake") endif() if(EXISTS "${PROJECT_SOURCE_DIR}/Applications/${target_dir}/CPackConfig.cmake.in") set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/Applications/${target_dir}/CPackConfig.cmake") configure_file(${PROJECT_SOURCE_DIR}/Applications/${target_dir}/CPackConfig.cmake.in ${CPACK_PROJECT_CONFIG_FILE} @ONLY) set(use_default_config OFF) endif() endif() # add link to the list list(APPEND CPACK_CREATE_DESKTOP_LINKS "${target_dir}") endif() endforeach() endif() # if no application specific configuration file was used, use default if(use_default_config) configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") endif() # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake") file(REMOVE ${MITK_EXPORTS_FILE}) set(targets_to_export) get_property(module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS) if(module_targets) list(APPEND targets_to_export ${module_targets}) endif() if(MITK_USE_BLUEBERRY) if(MITK_PLUGIN_LIBRARIES) list(APPEND targets_to_export ${MITK_PLUGIN_LIBRARIES}) endif() endif() export(TARGETS ${targets_to_export} APPEND FILE ${MITK_EXPORTS_FILE}) set(MITK_EXPORTED_TARGET_PROPERTIES ) foreach(target_to_export ${targets_to_export}) get_target_property(autoload_targets ${target_to_export} MITK_AUTOLOAD_TARGETS) if(autoload_targets) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_TARGETS \"${autoload_targets}\")") endif() get_target_property(autoload_dir ${target_to_export} MITK_AUTOLOAD_DIRECTORY) if(autoload_dir) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_DIRECTORY \"${autoload_dir}\")") endif() endforeach() get_property(MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) set(VISIBILITY_AVAILABLE 0) set(visibility_test_flag "") mitkFunctionCheckCompilerFlags("-fvisibility=hidden" visibility_test_flag) if(visibility_test_flag) # The compiler understands -fvisiblity=hidden (probably gcc >= 4 or Clang) set(VISIBILITY_AVAILABLE 1) endif() configure_file(mitkExportMacros.h.in ${MITK_BINARY_DIR}/mitkExportMacros.h) configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc) set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities) file(GLOB _MODULES_CONF_FILES RELATIVE ${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME} ${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME}/*.cmake) set(MITK_MODULE_NAMES) foreach(_module ${_MODULES_CONF_FILES}) string(REPLACE Config.cmake "" _module_name ${_module}) list(APPEND MITK_MODULE_NAMES ${_module_name}) endforeach() configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY) # If we are under Windows, create two batch files which correctly # set up the environment for the application and for Visual Studio if(WIN32) include(mitkFunctionCreateWindowsBatchScript) set(VS_SOLUTION_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.sln") foreach(VS_BUILD_TYPE debug release) mitkFunctionCreateWindowsBatchScript("${MITK_SOURCE_DIR}/CMake/StartVS.bat.in" ${PROJECT_BINARY_DIR}/StartVS_${VS_BUILD_TYPE}.bat ${VS_BUILD_TYPE}) endforeach() endif(WIN32) #----------------------------------------------------------------------------- # MITK Applications #----------------------------------------------------------------------------- # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Applications) #----------------------------------------------------------------------------- # MITK Examples #----------------------------------------------------------------------------- if(MITK_BUILD_EXAMPLES) # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Examples) endif() diff --git a/Examples/BlueBerryExampleLauncher/CMakeLists.txt b/Examples/BlueBerryExampleLauncher/CMakeLists.txt index d09e54b80e..c37e80b50e 100644 --- a/Examples/BlueBerryExampleLauncher/CMakeLists.txt +++ b/Examples/BlueBerryExampleLauncher/CMakeLists.txt @@ -1,67 +1,84 @@ project(BlueBerryExampleLauncher) set(_source_files BlueBerryExampleLauncher.cpp BlueBerryExampleLauncherDialog.cpp ) set(_source_moc_h_files BlueBerryExampleLauncherDialog.h ) set(_source_ui_files BlueBerryExampleLauncherDialog.ui ) # this is a workaround for Visual Studio. The relative include paths in the generated # moc files can get very long and can't be resolved by the MSVC compiler. foreach(_moc_src ${_source_moc_h_files}) qt4_wrap_cpp(_source_files ${_moc_src} OPTIONS -f${_moc_src}) endforeach() qt4_wrap_ui(_source_files ${_source_ui_files}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) -FunctionCreateBlueBerryApplication( - NAME ${PROJECT_NAME} - DESCRIPTION "MITK Application Framework Demo" - SOURCES ${_source_files} - PLUGINS ${MITK_EXAMPLE_PLUGIN_TARGETS} - NO_PROVISIONING - NO_INSTALL - SHOW_CONSOLE -) - -# subproject support -set_property(TARGET ${PROJECT_NAME} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) -foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) - add_dependencies(${subproject} ${PROJECT_NAME}) -endforeach() - #----------------------------------------------------------------------------- # Create provisioning files #----------------------------------------------------------------------------- set(_plugins_for_all_demos org.blueberry.compat ) file(GLOB _demo_configurations Configurations/*.cmake) +set(ALL_REQUIRED_PLUGINS ${_plugins_for_all_demos}) foreach(_demo_config_file ${_demo_configurations}) set(REQUIRED_PLUGINS ) set(DESCRIPTION ) include(${_demo_config_file}) get_filename_component(_name ${_demo_config_file} NAME_WE) FunctionCreateProvisioningFile(FILE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_${_name}.provisioning PLUGINS ${REQUIRED_PLUGINS} ${_plugins_for_all_demos} NO_INSTALL ) if(DESCRIPTION) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/BlueBerryExampleDescription.txt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_${_name}.txt @ONLY) endif() + list(APPEND ALL_REQUIRED_PLUGINS ${REQUIRED_PLUGINS}) +endforeach() + +list(REMOVE_DUPLICATES ALL_REQUIRED_PLUGINS) +set(ALL_REQUIRED_PLUGIN_TARGETS ) +foreach(req_plugin ${ALL_REQUIRED_PLUGINS}) + string(REPLACE "." "_" _plugin_target ${req_plugin}) + if(TARGET ${_plugin_target}) + list(APPEND ALL_REQUIRED_PLUGIN_TARGETS ${_plugin_target}) + endif() +endforeach() + +#----------------------------------------------------------------------------- +# Create the example launcher +#----------------------------------------------------------------------------- + +FunctionCreateBlueBerryApplication( + NAME ${PROJECT_NAME} + DESCRIPTION "MITK Application Framework Demo" + SOURCES ${_source_files} +# PLUGINS ${ALL_REQUIRED_PLUGIN_TARGETS} + NO_PROVISIONING + NO_INSTALL + SHOW_CONSOLE +) + +add_dependencies(${PROJECT_NAME} ${ALL_REQUIRED_PLUGIN_TARGETS}) + +# subproject support +set_property(TARGET ${PROJECT_NAME} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) +foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) + add_dependencies(${subproject} ${PROJECT_NAME}) endforeach() diff --git a/Examples/BlueBerryExampleLauncher/Configurations/ExamplePlugins.cmake b/Examples/BlueBerryExampleLauncher/Configurations/ExamplePlugins.cmake new file mode 100644 index 0000000000..8540b83658 --- /dev/null +++ b/Examples/BlueBerryExampleLauncher/Configurations/ExamplePlugins.cmake @@ -0,0 +1,12 @@ +set(REQUIRED_PLUGINS + org.commontk.configadmin + org.mitk.gui.qt.extapplication + org.mitk.gui.qt.datamanager + org.mitk.gui.qt.stdmultiwidgeteditor + org.mitk.example.gui.imaging + org.mitk.example.gui.opencv +) + +set(DESCRIPTION +"The included example plug-ins demonstrate various basic features of MITK." +) diff --git a/Examples/Plugins/PluginList.cmake b/Examples/Plugins/PluginList.cmake index ceb74aedde..0df040b96a 100644 --- a/Examples/Plugins/PluginList.cmake +++ b/Examples/Plugins/PluginList.cmake @@ -1,15 +1,18 @@ # Plug-ins must be ordered according to their dependencies set(MITK_EXAMPLE_PLUGINS org.mitk.example.gui.minimalapplication:ON org.mitk.example.gui.customviewer:ON org.mitk.example.gui.customviewer.views:ON org.mitk.example.gui.multipleperspectives:ON org.mitk.example.gui.selectionserviceqt:ON org.mitk.example.gui.selectionservicemitk:ON org.mitk.example.gui.selectionservicemitk.views:ON org.mitk.example.gui.extensionpointdefinition:ON org.mitk.example.gui.extensionpointcontribution:ON org.mitk.example.gui.regiongrowing:ON + + org.mitk.example.gui.imaging:ON + org.mitk.example.gui.opencv:ON ) diff --git a/Plugins/org.mitk.gui.qt.examples/CMakeLists.txt b/Examples/Plugins/org.mitk.example.gui.imaging/CMakeLists.txt similarity index 79% rename from Plugins/org.mitk.gui.qt.examples/CMakeLists.txt rename to Examples/Plugins/org.mitk.example.gui.imaging/CMakeLists.txt index c4ecaf406e..2fea55d352 100644 --- a/Plugins/org.mitk.gui.qt.examples/CMakeLists.txt +++ b/Examples/Plugins/org.mitk.example.gui.imaging/CMakeLists.txt @@ -1,7 +1,7 @@ -project(org_mitk_gui_qt_examples) +project(org_mitk_example_gui_imaging) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE EXAMPLES_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES QmitkExt Segmentation ) diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/ColorImageProcessing.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/ColorImageProcessing.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/ColorImageProcessing.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/ColorImageProcessing.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/IsoSurfaceGUI.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/IsoSurfaceGUI.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/IsoSurfaceGUI.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/IsoSurfaceGUI.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/IsoSurfaceIcon.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/IsoSurfaceIcon.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/IsoSurfaceIcon.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/IsoSurfaceIcon.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/MITKExamples.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/MITKExamples.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/MITKExamples.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/MITKExamples.dox diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkColourImageProcessing.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkColourImageProcessing.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkColourImageProcessing.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkColourImageProcessing.dox diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkIsoSurfaceUserManual.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkIsoSurfaceUserManual.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkIsoSurfaceUserManual.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkIsoSurfaceUserManual.dox diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkRegionGrowingUserManual.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkRegionGrowingUserManual.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkRegionGrowingUserManual.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkRegionGrowingUserManual.dox diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkSimpleExampleUserManual.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkSimpleExampleUserManual.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkSimpleExampleUserManual.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkSimpleExampleUserManual.dox diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkSimpleMeasurementUserManual.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkSimpleMeasurementUserManual.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/QmitkSimpleMeasurementUserManual.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/QmitkSimpleMeasurementUserManual.dox diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/SimpleExample.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/SimpleExample.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/SimpleExample.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/SimpleExample.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/SimpleMeasurementGUI.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/SimpleMeasurementGUI.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/SimpleMeasurementGUI.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/SimpleMeasurementGUI.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/SimpleMeasurementIcon.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/SimpleMeasurementIcon.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/SimpleMeasurementIcon.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/SimpleMeasurementIcon.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/org_mitk_gui_qt_viewinitialization.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/org_mitk_gui_qt_viewinitialization.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/org_mitk_gui_qt_viewinitialization.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/org_mitk_gui_qt_viewinitialization.dox diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/regiongrowing.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/regiongrowing.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/regiongrowing.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/regiongrowing.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/regiongrowing.xpm b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/regiongrowing.xpm similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/regiongrowing.xpm rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/regiongrowing.xpm diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/viewInitializationIcon.png b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/viewInitializationIcon.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/viewInitializationIcon.png rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/viewInitializationIcon.png diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/UserManual/viewInitializationIcon.xpm b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/viewInitializationIcon.xpm similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/UserManual/viewInitializationIcon.xpm rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/UserManual/viewInitializationIcon.xpm diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox b/Examples/Plugins/org.mitk.example.gui.imaging/documentation/doxygen/modules.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox rename to Examples/Plugins/org.mitk.example.gui.imaging/documentation/doxygen/modules.dox diff --git a/Plugins/org.mitk.gui.qt.examples/files.cmake b/Examples/Plugins/org.mitk.example.gui.imaging/files.cmake similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/files.cmake rename to Examples/Plugins/org.mitk.example.gui.imaging/files.cmake diff --git a/Plugins/org.mitk.gui.qt.examples/manifest_headers.cmake b/Examples/Plugins/org.mitk.example.gui.imaging/manifest_headers.cmake similarity index 77% rename from Plugins/org.mitk.gui.qt.examples/manifest_headers.cmake rename to Examples/Plugins/org.mitk.example.gui.imaging/manifest_headers.cmake index 4c2e3fe85b..6b439718ea 100644 --- a/Plugins/org.mitk.gui.qt.examples/manifest_headers.cmake +++ b/Examples/Plugins/org.mitk.example.gui.imaging/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "MITK Examples") 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.gui.qt.common.legacy) \ No newline at end of file +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Examples/Plugins/org.mitk.example.gui.imaging/plugin.xml b/Examples/Plugins/org.mitk.example.gui.imaging/plugin.xml new file mode 100644 index 0000000000..ce3ad0916b --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.imaging/plugin.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.examples/resources/ColorImageProcessing.png b/Examples/Plugins/org.mitk.example.gui.imaging/resources/ColorImageProcessing.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/ColorImageProcessing.png rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/ColorImageProcessing.png diff --git a/Plugins/org.mitk.gui.qt.examples/resources/QmitkColourImageProcessingView.qrc b/Examples/Plugins/org.mitk.example.gui.imaging/resources/QmitkColourImageProcessingView.qrc similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/QmitkColourImageProcessingView.qrc rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/QmitkColourImageProcessingView.qrc diff --git a/Plugins/org.mitk.gui.qt.examples/resources/QmitkSimpleExampleView.qrc b/Examples/Plugins/org.mitk.example.gui.imaging/resources/QmitkSimpleExampleView.qrc similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/QmitkSimpleExampleView.qrc rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/QmitkSimpleExampleView.qrc diff --git a/Plugins/org.mitk.gui.qt.examples/resources/QmitkVolumetryView.qrc b/Examples/Plugins/org.mitk.example.gui.imaging/resources/QmitkVolumetryView.qrc similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/QmitkVolumetryView.qrc rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/QmitkVolumetryView.qrc diff --git a/Plugins/org.mitk.gui.qt.examples/resources/SimpleExample.png b/Examples/Plugins/org.mitk.example.gui.imaging/resources/SimpleExample.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/SimpleExample.png rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/SimpleExample.png diff --git a/Plugins/org.mitk.gui.qt.examples/resources/SimpleMeasurement.png b/Examples/Plugins/org.mitk.example.gui.imaging/resources/SimpleMeasurement.png similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/SimpleMeasurement.png rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/SimpleMeasurement.png diff --git a/Plugins/org.mitk.gui.qt.examples/resources/isoSurface.xpm b/Examples/Plugins/org.mitk.example.gui.imaging/resources/isoSurface.xpm similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/isoSurface.xpm rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/isoSurface.xpm diff --git a/Plugins/org.mitk.gui.qt.examples/resources/isosurface.qrc b/Examples/Plugins/org.mitk.example.gui.imaging/resources/isosurface.qrc similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/isosurface.qrc rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/isosurface.qrc diff --git a/Plugins/org.mitk.gui.qt.examples/resources/surfaceUtilities.xpm b/Examples/Plugins/org.mitk.example.gui.imaging/resources/surfaceUtilities.xpm similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/surfaceUtilities.xpm rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/surfaceUtilities.xpm diff --git a/Plugins/org.mitk.gui.qt.examples/resources/viewInitializationIcon.xpm b/Examples/Plugins/org.mitk.example.gui.imaging/resources/viewInitializationIcon.xpm similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/viewInitializationIcon.xpm rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/viewInitializationIcon.xpm diff --git a/Plugins/org.mitk.gui.qt.examples/resources/volumetryIcon.xpm b/Examples/Plugins/org.mitk.example.gui.imaging/resources/volumetryIcon.xpm similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/resources/volumetryIcon.xpm rename to Examples/Plugins/org.mitk.example.gui.imaging/resources/volumetryIcon.xpm diff --git a/Plugins/org.mitk.gui.qt.examples/src/ExamplesDll.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/ExamplesDll.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/ExamplesDll.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/ExamplesDll.h diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp similarity index 73% rename from Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp index 96877d9ea9..5922bf736a 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp @@ -1,283 +1,254 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkColourImageProcessingView.h" + +#include "ui_QmitkColourImageProcessingViewControls.h" + #include "mitkColourImageProcessor.h" +#include "mitkDataNodeObject.h" +#include "mitkTransferFunction.h" +#include "mitkTransferFunctionProperty.h" -#include "mitkNodePredicateDataType.h" -#include "QmitkDataStorageComboBox.h" -#include "QmitkStdMultiWidget.h" -#include -#include +#include "QmitkPiecewiseFunctionCanvas.h" +#include "QmitkColorTransferFunctionCanvas.h" #include #include #include -#include - -#include -#include -#include "QmitkPiecewiseFunctionCanvas.h" -#include "QmitkColorTransferFunctionCanvas.h" +#include +#include #include #include const std::string QmitkColourImageProcessingView::VIEW_ID = "org.mitk.views.colourimageprocessing"; QmitkColourImageProcessingView::QmitkColourImageProcessingView() -: QmitkFunctionality(), - m_MultiWidget(NULL) + : m_Controls(NULL) { - m_Controls=NULL; - m_Color[0]= 255; m_Color[1]= 0; m_Color[2]= 0; } -QmitkColourImageProcessingView::~QmitkColourImageProcessingView() +void QmitkColourImageProcessingView::SetFocus() { - berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); - if(s) - s->RemoveSelectionListener(m_SelectionListener); + m_Controls->m_ConvertImageToRGBA->setFocus(); } void QmitkColourImageProcessingView::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { m_Controls = new Ui::QmitkColourImageProcessingViewControls; m_Controls->setupUi(parent); connect( m_Controls->m_ConvertImageToRGBA, SIGNAL( clicked(bool) ),this, SLOT( OnConvertToRGBAImage() )); connect( m_Controls->m_ConvertImageMaskToRGBA, SIGNAL( clicked(bool) ),this, SLOT( OnConvertToRGBAImage() )); connect( m_Controls->m_ConvertImageMaskColorToRGBA, SIGNAL( clicked(bool) ),this, SLOT( OnConvertImageMaskColorToRGBAImage() )); connect( m_Controls->m_ColorButton, SIGNAL( clicked(bool) ),this, SLOT( OnChangeColor() )); connect( m_Controls->m_CombineRGBAButton, SIGNAL( clicked(bool) ),this, SLOT( OnCombineRGBA() )); m_Controls->m_ImageSelectedLabel->hide(); m_Controls->m_NoImageSelectedLabel->show(); - - - } - - m_SelectionListener = berry::ISelectionListener::Pointer(new berry::SelectionChangedAdapter - (this, &QmitkColourImageProcessingView::SelectionChanged)); - berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); - if(s) - s->AddSelectionListener(m_SelectionListener); - } -void QmitkColourImageProcessingView::SelectionChanged( berry::IWorkbenchPart::Pointer, berry::ISelection::ConstPointer selection ) +void QmitkColourImageProcessingView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList &nodes) { - - mitk::DataNodeSelection::ConstPointer _DataNodeSelection - = selection.Cast(); - - if(_DataNodeSelection.IsNotNull()) + if(!nodes.isEmpty()) { - std::vector selectedNodes; - mitk::DataNodeObject* _DataNodeObject = 0; + QList selectedNodes; - for(mitk::DataNodeSelection::iterator it = _DataNodeSelection->Begin();it != _DataNodeSelection->End(); ++it) + foreach(const mitk::DataNode::Pointer node, nodes) { - _DataNodeObject = dynamic_cast((*it).GetPointer()); - if(_DataNodeObject) + if( node.IsNotNull() ) { - mitk::DataNode::Pointer node = _DataNodeObject->GetDataNode(); - - if( node.IsNotNull() && dynamic_cast(node->GetData())&&dynamic_cast(node->GetData())->GetDimension()>=3 ) + mitk::Image* image = dynamic_cast(node->GetData()); + if (image->GetDimension()>=3) + { selectedNodes.push_back( node ); + } } } mitk::DataNode::Pointer node; if(selectedNodes.size() > 0) + { node=selectedNodes[0]; - if( node.IsNotNull() ) - { m_SelectedNode = node; m_Controls->m_NoImageSelectedLabel->hide(); m_Controls->m_ImageSelectedLabel->show(); std::string infoText = std::string("Selected Image: ") + node->GetName(); if(selectedNodes.size() > 1) { mitk::DataNode::Pointer node2; node2=selectedNodes[1]; m_SelectedNode2=node2; infoText = infoText + " and " + node2->GetName(); } else { m_SelectedNode2= 0; } - m_Controls->m_ImageSelectedLabel->setText( QString( infoText.c_str() ) ); - } else { m_Controls->m_ImageSelectedLabel->hide(); m_Controls->m_NoImageSelectedLabel->show(); m_SelectedNode = 0; m_SelectedNode2= 0; } - } } - void QmitkColourImageProcessingView::OnConvertToRGBAImage() { if(m_SelectedNode.IsNull()) return; mitk::TransferFunctionProperty::Pointer transferFunctionProp = dynamic_cast(m_SelectedNode->GetProperty("TransferFunction")); if(transferFunctionProp.IsNull()) return; mitk::TransferFunction::Pointer tf = transferFunctionProp->GetValue(); if(tf.IsNull()) return; mitk::mitkColourImageProcessor CImageProcessor; mitk::Image::Pointer RGBAImageResult; if(m_SelectedNode2.IsNotNull()) { RGBAImageResult = CImageProcessor.convertWithBinaryToRGBAImage(dynamic_cast(m_SelectedNode->GetData()),dynamic_cast(m_SelectedNode2->GetData()),tf); } else { RGBAImageResult = CImageProcessor.convertToRGBAImage(dynamic_cast(m_SelectedNode->GetData()),tf); } if (!RGBAImageResult) { QMessageBox::warning(NULL, "Warning", QString("Unsupported pixeltype")); return; } mitk::DataNode::Pointer dtn = mitk::DataNode::New(); dtn->SetData( RGBAImageResult ); dtn->SetName(m_SelectedNode->GetName() + "_RGBA"); - this->GetDefaultDataStorage()->Add( dtn ); // add as a child, because the segmentation "derives" from the original + this->GetDataStorage()->Add( dtn ); // add as a child, because the segmentation "derives" from the original MITK_INFO << "convertToRGBAImage finish"; - } void QmitkColourImageProcessingView::OnConvertImageMaskColorToRGBAImage( ) { if(m_SelectedNode.IsNull()) return; mitk::TransferFunctionProperty::Pointer transferFunctionProp = dynamic_cast(m_SelectedNode->GetProperty("TransferFunction")); if(transferFunctionProp.IsNull()) return; mitk::TransferFunction::Pointer tf = transferFunctionProp->GetValue(); if(tf.IsNull()) return; mitk::mitkColourImageProcessor CImageProcessor; mitk::Image::Pointer RGBAImageResult; if(m_SelectedNode2.IsNotNull()) { RGBAImageResult = CImageProcessor.convertWithBinaryAndColorToRGBAImage(dynamic_cast(m_SelectedNode->GetData()),dynamic_cast(m_SelectedNode2->GetData()),tf, m_Color); } else { RGBAImageResult = CImageProcessor.convertToRGBAImage(dynamic_cast(m_SelectedNode->GetData()),tf); } if (!RGBAImageResult) { QMessageBox::warning(NULL, "Warning", QString("Unsupported pixeltype")); return; } mitk::DataNode::Pointer dtn = mitk::DataNode::New(); dtn->SetData( RGBAImageResult ); dtn->SetName(m_SelectedNode->GetName() + "_RGBA"); - this->GetDefaultDataStorage()->Add( dtn ); // add as a child, because the segmentation "derives" from the original - + this->GetDataStorage()->Add( dtn ); // add as a child, because the segmentation "derives" from the original } void QmitkColourImageProcessingView::OnChangeColor( ) { QColor color = QColorDialog::getColor(); if (color.spec() == 0) { color.setRed(255); color.setGreen(0); color.setBlue(0); } m_Color[0]= color.red(); m_Color[1]= color.green(); m_Color[2]= color.blue(); m_Controls->m_ColorButton->setStyleSheet(QString("background-color:rgb(%1,%2, %3)").arg(color.red()).arg(color.green()).arg(color.blue())); } void QmitkColourImageProcessingView::OnCombineRGBA( ) { if(m_SelectedNode.IsNull()) return; if(m_SelectedNode2.IsNull()) return; mitk::mitkColourImageProcessor CImageProcessor; mitk::Image::Pointer RGBAImageResult; - RGBAImageResult = CImageProcessor.combineRGBAImage(dynamic_cast(m_SelectedNode->GetData()),dynamic_cast(m_SelectedNode2->GetData())); + RGBAImageResult = CImageProcessor.combineRGBAImage(dynamic_cast(m_SelectedNode->GetData()),dynamic_cast(m_SelectedNode2->GetData())); MITK_INFO <<"RGBAImage Result"; mitk::DataNode::Pointer dtn = mitk::DataNode::New(); dtn->SetData( RGBAImageResult ); - this->GetDefaultDataStorage()->Add( dtn ); // add as a child, because the segmentation "derives" from the original - + this->GetDataStorage()->Add( dtn ); // add as a child, because the segmentation "derives" from the original } diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h similarity index 64% rename from Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h index 0a010864f8..cacf816a64 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h @@ -1,77 +1,65 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QMITKCOLOURIMAGEPROCESSINGVIEW_H_INCLUDED #define _QMITKCOLOURIMAGEPROCESSINGVIEW_H_INCLUDED -#include -#include -#include -#include - -#include "mitkDataStorage.h" +#include -#include -#include - -#include +#include -#include "ui_QmitkColourImageProcessingViewControls.h" +namespace Ui { +class QmitkColourImageProcessingViewControls; +} -class QmitkColourImageProcessingView : public QmitkFunctionality +class QmitkColourImageProcessingView : public QmitkAbstractView { Q_OBJECT public: static const std::string VIEW_ID; QmitkColourImageProcessingView(); - virtual ~QmitkColourImageProcessingView(); +private: + + virtual void SetFocus(); virtual void CreateQtPartControl(QWidget *parent); - virtual void SelectionChanged(berry::IWorkbenchPart::Pointer part, berry::ISelection::ConstPointer selection); + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes); -protected slots: +private slots: void OnConvertToRGBAImage(); void OnConvertImageMaskColorToRGBAImage(); void OnCombineRGBA(); void OnChangeColor(); -protected: +private: Ui::QmitkColourImageProcessingViewControls* m_Controls; - QmitkStdMultiWidget* m_MultiWidget; - - berry::ISelectionListener::Pointer m_SelectionListener; - - - -private: - mitk::WeakPointer m_SelectedNode; mitk::WeakPointer m_SelectedNode2; + int m_Color[3]; }; #endif // _QMITKCOLOURIMAGEPROCESSINGVIEW_H_INCLUDED - diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/mitkColourImageProcessor.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/colourimageprocessing/mitkColourImageProcessor.h diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurface.cpp similarity index 69% rename from Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurface.cpp index 02e8316a52..069de09f00 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.cpp +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurface.cpp @@ -1,228 +1,162 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkIsoSurface.h" -//#include //GUI -//#include //image //MITK headers #include #include -#include #include //Qmitk headers #include #include //Qt-GUI headers -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include QmitkIsoSurface::QmitkIsoSurface(QObject * /*parent*/, const char * /*name*/) -: QmitkFunctionality() , - m_Controls(NULL), +: m_Controls(NULL), m_MitkImage(NULL), m_SurfaceCounter(0) { - //SetAvailability(true); } - - -//QWidget * QmitkIsoSurface::CreateMainWidget(QWidget *) -//{ -// return NULL; -//} - - -//QWidget * QmitkIsoSurface::CreateControlWidget(QWidget *parent) -//{ -// if (m_Controls == NULL) -// { -// m_Controls = new QmitkIsoSurfaceControls(parent); -// } -// return m_Controls; -//} - void QmitkIsoSurface::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { m_Controls = new Ui::QmitkIsoSurfaceControls; m_Controls->setupUi(parent); this->CreateConnections(); - m_Controls->m_ImageSelector->SetDataStorage(this->GetDefaultDataStorage()); + m_Controls->m_ImageSelector->SetDataStorage(this->GetDataStorage()); m_Controls->m_ImageSelector->SetPredicate(mitk::NodePredicateDataType::New("Image")); berry::IPreferences::Pointer prefs = this->GetPreferences(); if(prefs.IsNotNull()) m_Controls->thresholdLineEdit->setText(QString::fromStdString(prefs->Get("defaultThreshold", "0"))); } } +void QmitkIsoSurface::SetFocus() +{ + m_Controls->m_ImageSelector->setFocus(); +} + void QmitkIsoSurface::CreateConnections() { if ( m_Controls ) { connect( m_Controls->m_ImageSelector, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), this, SLOT(ImageSelected(const mitk::DataNode*)) ); connect( m_Controls->createSurfacePushButton, SIGNAL(clicked()), this, SLOT(CreateSurface()) ); } } - -//QAction * QmitkIsoSurface::CreateAction(QActionGroup *parent) -//{ -// QAction* action; -// action = new QAction( tr( "IsoSurface" ), QPixmap((const char**)isoSurface_xpm), tr( "IsoSurface" ), 0, parent, "IsoSurface" ); -// return action; -//} - - -void QmitkIsoSurface::DataStorageChanged() -{ - //m_Controls->m_ImageSelector->Update(); -} - - void QmitkIsoSurface::ImageSelected(const mitk::DataNode* item) { // nothing selected (NULL selection) if( item == 0 || item->GetData() == 0 ) return; m_MitkImage = dynamic_cast (item->GetData()); } - void QmitkIsoSurface::CreateSurface() { QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); if(m_MitkImage != NULL) { //Value Gauss //float gsDev = 1.5; //Value for DecimatePro float targetReduction = 0.05; //ImageToSurface Instance mitk::DataNode::Pointer node = m_Controls->m_ImageSelector->GetSelectedNode(); mitk::ManualSegmentationToSurfaceFilter::Pointer filter = mitk::ManualSegmentationToSurfaceFilter::New(); if (filter.IsNull()) { std::cout<<"NULL Pointer for ManualSegmentationToSurfaceFilter"<SetInput( m_MitkImage ); filter->SetGaussianStandardDeviation( 0.5 ); filter->SetUseGaussianImageSmooth( true ); filter->SetThreshold( getThreshold()); //if( Gauss ) --> TH manipulated for vtkMarchingCube filter->SetTargetReduction( targetReduction ); int numOfPolys = filter->GetOutput()->GetVtkPolyData()->GetNumberOfPolys(); if(numOfPolys>2000000) { QApplication::restoreOverrideCursor(); if(QMessageBox::question(NULL, "CAUTION!!!", "The number of polygons is greater than 2 000 000. If you continue, the program might crash. How do you want to go on?", "Proceed anyway!", "Cancel immediately! (maybe you want to insert an other threshold)!",QString::null,0 ,1)==1) { return; } QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); } mitk::DataNode::Pointer surfaceNode = mitk::DataNode::New(); surfaceNode->SetData( filter->GetOutput() ); int layer = 0; ++m_SurfaceCounter; std::ostringstream buffer; buffer << m_SurfaceCounter; std::string surfaceNodeName = "Surface " + buffer.str(); node->GetIntProperty("layer", layer); surfaceNode->SetIntProperty("layer", layer+1); surfaceNode->SetProperty("Surface", mitk::BoolProperty::New(true)); surfaceNode->SetProperty("name", mitk::StringProperty::New(surfaceNodeName)); - /* - mitk::DataTreeIteratorClone iteratorClone = m_DataTreeIterator; - bool isSurface = false; - - while(!(iteratorClone->IsAtEnd())&&(isSurface == false)) - { - iteratorClone->Get()->GetBoolProperty("Surface", isSurface); - if(isSurface == false) - { - ++iteratorClone; - } - } - - iteratorClone= iteratorOnImageToBeSkinExtracted; - iteratorClone->Add(surfaceNode); - iteratorClone->GetTree()->Modified(); - */ - this->GetDefaultDataStorage()->Add(surfaceNode, node); - - mitk::Surface::Pointer surface = filter->GetOutput(); + this->GetDataStorage()->Add(surfaceNode, node); //to show surfaceContur surfaceNode->SetColor( m_RainbowColor.GetNextColor() ); surfaceNode->SetVisibility(true); - this->GetActiveStdMultiWidget()->RequestUpdate(); - - }//if m_MitkImage != NULL + mitk::IRenderWindowPart* renderPart = this->GetRenderWindowPart(); + if (renderPart) + { + renderPart->RequestUpdate(); + } + } QApplication::restoreOverrideCursor(); } - float QmitkIsoSurface::getThreshold() { return m_Controls->thresholdLineEdit->text().toFloat(); } -void QmitkIsoSurface::StdMultiWidgetAvailable( QmitkStdMultiWidget& /*stdMultiWidget*/ ) -{ - m_Parent->setEnabled(true); -} - -void QmitkIsoSurface::StdMultiWidgetNotAvailable() -{ - m_Parent->setEnabled(false); -} - QmitkIsoSurface::~QmitkIsoSurface() { - berry::IPreferences::Pointer prefs = this->GetPreferences(); if(prefs.IsNotNull()) prefs->Put("defaultThreshold", m_Controls->thresholdLineEdit->text().toStdString()); } diff --git a/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurface.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurface.h new file mode 100644 index 0000000000..2f8d2db309 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurface.h @@ -0,0 +1,92 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef QMITK_ISOSURFACE_H__INCLUDED +#define QMITK_ISOSURFACE_H__INCLUDED + +#include "QmitkAbstractView.h" +#include "mitkColorSequenceRainbow.h" +#include "mitkDataStorage.h" +#include "ui_QmitkIsoSurfaceControls.h" + +/** + * \brief IsoSurface + * + * \sa QmitkAbstractView + */ +class QmitkIsoSurface : public QmitkAbstractView +{ + Q_OBJECT + +public: + + QmitkIsoSurface(QObject *parent=0, const char *name=0); + + virtual ~QmitkIsoSurface(); + +private: + + /** + * \brief method for creating the widget containing the application controls, like sliders, buttons etc. + */ + virtual void CreateQtPartControl(QWidget *parent); + + virtual void SetFocus(); + + /** + * \brief method for creating the connections of main and control widget + */ + virtual void CreateConnections(); + +private slots: + + /* + * just an example slot for the example TreeNodeSelector widget + */ + void ImageSelected(const mitk::DataNode* item); + + /** + * \brief method for creating a surface object + */ + void CreateSurface(); + +private: + + /** + * controls containing sliders for scrolling through the slices + */ + Ui::QmitkIsoSurfaceControls * m_Controls; + + /** + * image which is used to create the surface + */ + mitk::Image* m_MitkImage; + + /** + * read thresholdvalue from GUI and convert it to float + */ + float getThreshold(); + + /** + * variable to count Surfaces and give it to name + */ + int m_SurfaceCounter; + + mitk::ColorSequenceRainbow m_RainbowColor; +}; + +#endif // QMITK_ISOSURFACE_H__INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurfaceControls.ui b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurfaceControls.ui similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurfaceControls.ui rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/isosurface/QmitkIsoSurfaceControls.ui diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/mitkPluginActivator.cpp diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/mitkPluginActivator.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/mitkPluginActivator.h diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleView.cpp similarity index 57% rename from Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleView.cpp index 7f768e68a7..83e94feeaa 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.cpp +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleView.cpp @@ -1,305 +1,275 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkSimpleExampleView.h" -#include "mitkNodePredicateDataType.h" +#include "QmitkStepperAdapter.h" +#include "QmitkRenderWindow.h" -#include "QmitkDataStorageComboBox.h" -#include "QmitkStdMultiWidget.h" - -#include - -#include +#include "mitkMovieGenerator.h" #include "mitkNodePredicateProperty.h" #include "mitkNodePredicateNot.h" #include "mitkProperties.h" -#include + +#include #include #include #include #include -#include "vtkImageWriter.h" -#include "vtkPNGWriter.h" -#include "vtkJPEGWriter.h" -#include "vtkRenderLargeImage.h" +#include +#include +#include +#include const std::string QmitkSimpleExampleView::VIEW_ID = "org.mitk.views.simpleexample"; QmitkSimpleExampleView::QmitkSimpleExampleView() -: QmitkFunctionality(), - m_Controls(NULL), - m_MultiWidget(NULL), - m_NavigatorsInitialized(false) -{ -} - -QmitkSimpleExampleView::QmitkSimpleExampleView(const QmitkSimpleExampleView& other) +: m_Controls(NULL), + m_NavigatorsInitialized(false), + m_Parent(NULL) { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); } QmitkSimpleExampleView::~QmitkSimpleExampleView() { } void QmitkSimpleExampleView::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { + m_Parent = parent; // create GUI widgets m_Controls = new Ui::QmitkSimpleExampleViewControls; m_Controls->setupUi(parent); this->CreateConnections(); + + this->RenderWindowPartActivated(this->GetRenderWindowPart()); } } -void QmitkSimpleExampleView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) +void QmitkSimpleExampleView::SetFocus() +{ + m_Controls->renderWindowComboBox->setFocus(); +} + +void QmitkSimpleExampleView::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) { - m_MultiWidget = &stdMultiWidget; + if (renderWindowPart == NULL) + { + m_Parent->setEnabled(false); + return; + } + + QHashIterator renderIter(renderWindowPart->GetQmitkRenderWindows()); + while(renderIter.hasNext()) + { + renderIter.next(); + m_Controls->renderWindowComboBox->addItem(renderIter.key()); + } - new QmitkStepperAdapter(m_Controls->sliceNavigatorAxial, m_MultiWidget->mitkWidget1->GetSliceNavigationController()->GetSlice(), "sliceNavigatorAxialFromSimpleExample"); - new QmitkStepperAdapter(m_Controls->sliceNavigatorSagittal, m_MultiWidget->mitkWidget2->GetSliceNavigationController()->GetSlice(), "sliceNavigatorSagittalFromSimpleExample"); - new QmitkStepperAdapter(m_Controls->sliceNavigatorFrontal, m_MultiWidget->mitkWidget3->GetSliceNavigationController()->GetSlice(), "sliceNavigatorFrontalFromSimpleExample"); - new QmitkStepperAdapter(m_Controls->sliceNavigatorTime, m_MultiWidget->GetTimeNavigationController()->GetTime(), "sliceNavigatorTimeFromSimpleExample"); - new QmitkStepperAdapter(m_Controls->movieNavigatorTime, m_MultiWidget->GetTimeNavigationController()->GetTime(), "movieNavigatorTimeFromSimpleExample"); + RenderWindowSelected(m_Controls->renderWindowComboBox->currentText()); + m_TimeStepper.reset(new QmitkStepperAdapter(m_Controls->sliceNavigatorTime, renderWindowPart->GetTimeNavigationController()->GetTime(), "sliceNavigatorTimeFromSimpleExample")); + m_MovieStepper.reset(new QmitkStepperAdapter(m_Controls->movieNavigatorTime, renderWindowPart->GetTimeNavigationController()->GetTime(), "movieNavigatorTimeFromSimpleExample")); + + m_Parent->setEnabled(true); } -void QmitkSimpleExampleView::StdMultiWidgetNotAvailable() +void QmitkSimpleExampleView::RenderWindowPartDeactivated(mitk::IRenderWindowPart* /*renderWindowPart*/) { - m_MultiWidget = NULL; + m_Parent->setEnabled(false); + + m_SliceStepper.reset(); + m_TimeStepper.reset(); + m_MovieStepper.reset(); + m_Controls->renderWindowComboBox->clear(); } void QmitkSimpleExampleView::CreateConnections() { if ( m_Controls ) { - connect(m_Controls->stereoSelect, SIGNAL(activated(int)), this, SLOT(stereoSelectionChanged(int)) ); - connect(m_Controls->reInitializeNavigatorsButton, SIGNAL(clicked()), this, SLOT(initNavigators()) ); - connect(m_Controls->genMovieButton, SIGNAL(clicked()), this, SLOT(generateMovie()) ); - connect(m_Controls->m_RenderWindow1Button, SIGNAL(clicked()), this, SLOT(OnRenderWindow1Clicked()) ); - connect(m_Controls->m_RenderWindow2Button, SIGNAL(clicked()), this, SLOT(OnRenderWindow2Clicked()) ); - connect(m_Controls->m_RenderWindow3Button, SIGNAL(clicked()), this, SLOT(OnRenderWindow3Clicked()) ); - connect(m_Controls->m_RenderWindow4Button, SIGNAL(clicked()), this, SLOT(OnRenderWindow4Clicked()) ); + connect(m_Controls->renderWindowComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(RenderWindowSelected(QString)) ); + connect(m_Controls->stereoSelect, SIGNAL(activated(int)), this, SLOT(StereoSelectionChanged(int)) ); + connect(m_Controls->reInitializeNavigatorsButton, SIGNAL(clicked()), this, SLOT(InitNavigators()) ); + connect(m_Controls->genMovieButton, SIGNAL(clicked()), this, SLOT(GenerateMovie()) ); connect(m_Controls->m_TakeScreenshotBtn, SIGNAL(clicked()), this, SLOT(OnTakeScreenshot()) ); connect(m_Controls->m_TakeHighResScreenShotBtn, SIGNAL(clicked()), this, SLOT(OnTakeHighResolutionScreenshot()) ); } } -void QmitkSimpleExampleView::Activated() -{ - QmitkFunctionality::Activated(); -} - -void QmitkSimpleExampleView::Deactivated() -{ - QmitkFunctionality::Deactivated(); -} - -void QmitkSimpleExampleView::initNavigators() +void QmitkSimpleExampleView::InitNavigators() { /* get all nodes that have not set "includeInBoundingBox" to false */ mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox", mitk::BoolProperty::New(false))); mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetDataStorage()->GetSubset(pred); /* calculate bounding geometry of these nodes */ mitk::TimeGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs); /* initialize the views to the bounding geometry */ m_NavigatorsInitialized = mitk::RenderingManager::GetInstance()->InitializeViews(bounds); //m_NavigatorsInitialized = mitk::RenderingManager::GetInstance()->InitializeViews(GetDefaultDataStorage()); } -void QmitkSimpleExampleView::generateMovie() +void QmitkSimpleExampleView::GenerateMovie() { - QmitkRenderWindow* movieRenderWindow = GetMovieRenderWindow(); + QmitkRenderWindow* movieRenderWindow = GetSelectedRenderWindow(); //mitk::Stepper::Pointer stepper = multiWidget->mitkWidget1->GetSliceNavigationController()->GetSlice(); mitk::Stepper::Pointer stepper = movieRenderWindow->GetSliceNavigationController()->GetSlice(); mitk::MovieGenerator::Pointer movieGenerator = mitk::MovieGenerator::New(); if (movieGenerator.IsNotNull()) { movieGenerator->SetStepper( stepper ); movieGenerator->SetRenderer( mitk::BaseRenderer::GetInstance(movieRenderWindow->GetRenderWindow()) ); QString movieFileName = QFileDialog::getSaveFileName(0, "Choose a file name", QString(), "Movie (*.avi)"); if (!movieFileName.isEmpty()) { movieGenerator->SetFileName( movieFileName.toStdString().c_str() ); movieGenerator->WriteMovie(); } } } -void QmitkSimpleExampleView::stereoSelectionChanged( int id ) +void QmitkSimpleExampleView::StereoSelectionChanged( int id ) { /* From vtkRenderWindow.h tells us about stereo rendering: Set/Get what type of stereo rendering to use. CrystalEyes mode uses frame-sequential capabilities available in OpenGL to drive LCD shutter glasses and stereo projectors. RedBlue mode is a simple type of stereo for use with red-blue glasses. Anaglyph mode is a superset of RedBlue mode, but the color output channels can be configured using the AnaglyphColorMask and the color of the original image can be (somewhat maintained using AnaglyphColorSaturation; the default colors for Anaglyph mode is red-cyan. Interlaced stereo mode produces a composite image where horizontal lines alternate between left and right views. StereoLeft and StereoRight modes choose one or the other stereo view. Dresden mode is yet another stereoscopic interleaving. */ - vtkRenderWindow * vtkrenderwindow = m_MultiWidget->mitkWidget4->GetRenderWindow(); + mitk::IRenderWindowPart* renderWindowPart = this->GetRenderWindowPart(); + vtkRenderWindow * vtkrenderwindow = this->GetSelectedRenderWindow()->GetVtkRenderWindow(); // note: foreground vtkRenderers (at least the department logo renderer) produce errors in stereoscopic visualization. // Therefore, we disable the logo visualization during stereo rendering. switch(id) { case 0: vtkrenderwindow->StereoRenderOff(); break; case 1: vtkrenderwindow->SetStereoTypeToRedBlue(); vtkrenderwindow->StereoRenderOn(); - m_MultiWidget->DisableDepartmentLogo(); + renderWindowPart->EnableDecorations(false, QStringList(mitk::IRenderWindowPart::DECORATION_LOGO)); break; case 2: vtkrenderwindow->SetStereoTypeToDresden(); vtkrenderwindow->StereoRenderOn(); - m_MultiWidget->DisableDepartmentLogo(); + renderWindowPart->EnableDecorations(false, QStringList(mitk::IRenderWindowPart::DECORATION_LOGO)); break; } - mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget4->GetRenderWindow())->SetMapperID(2); - m_MultiWidget->RequestUpdate(); -} - -QmitkRenderWindow* QmitkSimpleExampleView::GetMovieRenderWindow() -{ - //check which RenderWindow should be used to generate the movie, e.g. which button is toggled - if(m_Controls->m_RenderWindow1Button->isChecked()) - { - return m_MultiWidget->mitkWidget1; - } - else if(m_Controls->m_RenderWindow2Button->isChecked()) - { - return m_MultiWidget->mitkWidget2; - } - else if(m_Controls->m_RenderWindow3Button->isChecked()) - { - return m_MultiWidget->mitkWidget3; - } - else if(m_Controls->m_RenderWindow4Button->isChecked()) - { - return m_MultiWidget->mitkWidget4; - } - else //as default take widget1 - { - return m_MultiWidget->mitkWidget1; - } - + mitk::BaseRenderer::GetInstance(vtkrenderwindow)->SetMapperID(2); + renderWindowPart->RequestUpdate(); } -void QmitkSimpleExampleView::OnRenderWindow1Clicked() -{ - m_Controls->m_RenderWindow2Button->setChecked(false); - m_Controls->m_RenderWindow3Button->setChecked(false); - m_Controls->m_RenderWindow4Button->setChecked(false); -} -void QmitkSimpleExampleView::OnRenderWindow2Clicked() -{ - m_Controls->m_RenderWindow1Button->setChecked(false); - m_Controls->m_RenderWindow3Button->setChecked(false); - m_Controls->m_RenderWindow4Button->setChecked(false); -} -void QmitkSimpleExampleView::OnRenderWindow3Clicked() -{ - m_Controls->m_RenderWindow2Button->setChecked(false); - m_Controls->m_RenderWindow1Button->setChecked(false); - m_Controls->m_RenderWindow4Button->setChecked(false); -} -void QmitkSimpleExampleView::OnRenderWindow4Clicked() +QmitkRenderWindow* QmitkSimpleExampleView::GetSelectedRenderWindow() const { - m_Controls->m_RenderWindow2Button->setChecked(false); - m_Controls->m_RenderWindow3Button->setChecked(false); - m_Controls->m_RenderWindow1Button->setChecked(false); + QString id = m_Controls->renderWindowComboBox->currentText(); + if (id.isEmpty()) + { + return NULL; + } + else + { + return this->GetRenderWindowPart()->GetQmitkRenderWindow(id); + } } - void QmitkSimpleExampleView::OnTakeHighResolutionScreenshot() { QString fileName = QFileDialog::getSaveFileName(NULL, "Save screenshot to...", QDir::currentPath(), "JPEG file (*.jpg);;PNG file (*.png)"); - // only works correctly for 3D RenderWindow - vtkRenderer* renderer = m_MultiWidget->mitkWidget4->GetRenderer()->GetVtkRenderer(); + vtkRenderer* renderer = this->GetSelectedRenderWindow()->GetRenderer()->GetVtkRenderer(); if (renderer == NULL) return; this->TakeScreenshot(renderer, 4, fileName); } void QmitkSimpleExampleView::OnTakeScreenshot() { QString fileName = QFileDialog::getSaveFileName(NULL, "Save screenshot to...", QDir::currentPath(), "JPEG file (*.jpg);;PNG file (*.png)"); - QmitkRenderWindow* renWin = this->GetMovieRenderWindow(); + QmitkRenderWindow* renWin = this->GetSelectedRenderWindow(); if (renWin == NULL) return; vtkRenderer* renderer = renWin->GetRenderer()->GetVtkRenderer(); if (renderer == NULL) return; this->TakeScreenshot(renderer, 1, fileName); } void QmitkSimpleExampleView::TakeScreenshot(vtkRenderer* renderer, unsigned int magnificationFactor, QString fileName) { if ((renderer == NULL) ||(magnificationFactor < 1) || fileName.isEmpty()) return; bool doubleBuffering( renderer->GetRenderWindow()->GetDoubleBuffer() ); renderer->GetRenderWindow()->DoubleBufferOff(); vtkImageWriter* fileWriter; QFileInfo fi(fileName); QString suffix = fi.suffix(); if (suffix.compare("png", Qt::CaseInsensitive) == 0) { fileWriter = vtkPNGWriter::New(); } else // default is jpeg { vtkJPEGWriter* w = vtkJPEGWriter::New(); w->SetQuality(100); w->ProgressiveOff(); fileWriter = w; } vtkRenderLargeImage* magnifier = vtkRenderLargeImage::New(); magnifier->SetInput(renderer); magnifier->SetMagnification(magnificationFactor); //magnifier->Update(); fileWriter->SetInputConnection(magnifier->GetOutputPort()); fileWriter->SetFileName(fileName.toLatin1()); // vtkRenderLargeImage has problems with different layers, therefore we have to // temporarily deactivate all other layers. // we set the background to white, because it is nicer than black... double oldBackground[3]; renderer->GetBackground(oldBackground); double white[] = {1.0, 1.0, 1.0}; renderer->SetBackground(white); - m_MultiWidget->DisableColoredRectangles(); - m_MultiWidget->DisableDepartmentLogo(); - m_MultiWidget->DisableGradientBackground(); + mitk::IRenderWindowPart* renderWindowPart = this->GetRenderWindowPart(); + renderWindowPart->EnableDecorations(false); fileWriter->Write(); fileWriter->Delete(); - m_MultiWidget->EnableColoredRectangles(); - m_MultiWidget->EnableDepartmentLogo(); - m_MultiWidget->EnableGradientBackground(); + renderWindowPart->EnableDecorations(true); + renderer->SetBackground(oldBackground); renderer->GetRenderWindow()->SetDoubleBuffer(doubleBuffering); } + +void QmitkSimpleExampleView::RenderWindowSelected(const QString &id) +{ + if (!id.isEmpty()) + { + m_SliceStepper.reset(new QmitkStepperAdapter(m_Controls->sliceNavigator, + this->GetRenderWindowPart()->GetQmitkRenderWindow(id)->GetSliceNavigationController()->GetSlice(), + "sliceNavigatorFromSimpleExample")); + } +} diff --git a/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleView.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleView.h new file mode 100644 index 0000000000..d007df5729 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleView.h @@ -0,0 +1,107 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED +#define _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED + +#include +#include + +#include "ui_QmitkSimpleExampleViewControls.h" + +class QmitkStepperAdapter; + +class vtkRenderer; + +/** + * \brief QmitkSimpleExampleView + * + * \sa QmitkAbstractView + */ +class QmitkSimpleExampleView : public QmitkAbstractView, public mitk::IRenderWindowPartListener +{ + + // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) + Q_OBJECT + +public: + + static const std::string VIEW_ID; + + QmitkSimpleExampleView(); + ~QmitkSimpleExampleView(); + +private: + + virtual void CreateQtPartControl(QWidget *parent); + + virtual void SetFocus(); + + /// \brief Creation of the connections of main and control widget + virtual void CreateConnections(); + + virtual void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart); + virtual void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart); + + /** + * return the renderwindow of which the movie shall be created, what depends on the combo box + */ + QmitkRenderWindow* GetSelectedRenderWindow() const; + + /// writes a screenshot in JPEG or PNG format to the file fileName + void TakeScreenshot(vtkRenderer* renderer, unsigned int magnificationFactor, QString fileName); + +private slots: + + /** + * Qt slot for reacting on the selected render window from the combo box + */ + void RenderWindowSelected(const QString& id); + + /** + * qt slot for event processing from a qt widget defining the stereo mode of a render window + */ + void StereoSelectionChanged(int id); + + /** + * initialize the slice and temporal sliders according to the image dimensions + */ + void InitNavigators(); + + /** + * generate a movie as *.avi from the active render window + */ + void GenerateMovie(); + + /// takes screenshot of the 3D window in 4x resolution of the render window + void OnTakeHighResolutionScreenshot(); + + /// takes screenshot of the selected render window + void OnTakeScreenshot(); + +private: + + Ui::QmitkSimpleExampleViewControls* m_Controls; + + bool m_NavigatorsInitialized; + + QScopedPointer m_SliceStepper; + QScopedPointer m_TimeStepper; + QScopedPointer m_MovieStepper; + + QWidget* m_Parent; +}; +#endif // _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED diff --git a/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui new file mode 100644 index 0000000000..7ad0f94fba --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui @@ -0,0 +1,199 @@ + + + QmitkSimpleExampleViewControls + + + + 0 + 0 + 298 + 610 + + + + + 0 + 0 + + + + false + + + Form1 + + + + + + Render Window + + + + + + + + + + + + Slice + + + + + + + + 1 + 0 + + + + + + + + + + + + Time + + + + + + + + 1 + 0 + + + + + + + + + + Take Screenshot + + + + + + + Screenshot will be 4 times larger than current render window size + + + Take HighDef 3D Screenshot + + + + + + + + 32767 + 23 + + + + Generate Movie + + + + + + + + + Movie + + + + + + + + 1 + 0 + + + + + + + + + + + 200 + 0 + + + + + stereo off + + + + + red-blue stereo + + + + + D4D stereo + + + + + + + + Re-initialize Navigators + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 230 + + + + + + + + + + QmitkSliderNavigatorWidget + QWidget +
QmitkSliderNavigatorWidget.h
+ 1 +
+ + QmitkPrimitiveMovieNavigatorWidget + QWidget +
QmitkPrimitiveMovieNavigatorWidget.h
+ 1 +
+
+ + stereoSelect + + + +
diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp similarity index 61% rename from Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp index 4be057453d..5816430fd0 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp @@ -1,284 +1,306 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkSimpleMeasurement.h" -// #include -#include +#include "ui_QmitkSimpleMeasurementControls.h" +#include #include - +#include #include #include #include #include #include #include +QmitkSimpleMeasurement::QmitkSimpleMeasurement() +{ +} + QmitkSimpleMeasurement::~QmitkSimpleMeasurement() { -//remove all measurements when view is closed -for (int i=0; iGetDataStorage()->Remove(m_CreatedDistances.at(i));} -for (int i=0; iGetDataStorage()->Remove(m_CreatedAngles.at(i));} -for (int i=0; iGetDataStorage()->Remove(m_CreatedPaths.at(i));} + //remove all measurements when view is closed + for (std::size_t i=0; iGetDataStorage()->Remove(m_CreatedDistances.at(i)); + } + for (std::size_t i=0; iGetDataStorage()->Remove(m_CreatedAngles.at(i)); + } + for (std::size_t i=0; iGetDataStorage()->Remove(m_CreatedPaths.at(i)); + } + + if (m_PointSetInteractor.IsNotNull()) + { + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(m_PointSetInteractor.GetPointer()); + } } void QmitkSimpleMeasurement::Activated() { - std::vector selection = this->GetDataManagerSelection(); - this->OnSelectionChanged( selection ); - + this->OnSelectionChanged(berry::IWorkbenchPart::Pointer(), this->GetCurrentSelection()); } void QmitkSimpleMeasurement::Deactivated() { - std::vector selection; - this->OnSelectionChanged( selection ); +} + +void QmitkSimpleMeasurement::Visible() +{ +} + +void QmitkSimpleMeasurement::Hidden() +{ +} + +void QmitkSimpleMeasurement::ActivatedZombieView(berry::SmartPointer /*zombieView*/) +{ + // something else was selected. remove old interactor + if (m_PointSetInteractor.IsNotNull()) + { + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(m_PointSetInteractor.GetPointer()); + } } void QmitkSimpleMeasurement::AddDistanceSimpleMeasurement() { mitk::PointSet::Pointer pointSet = mitk::PointSet::New(); QString name = "Distance " + QString::number(m_CreatedDistances.size()+1); mitk::DataNode::Pointer CurrentPointSetNode = mitk::DataNode::New(); CurrentPointSetNode->SetData(pointSet); CurrentPointSetNode->SetProperty("show contour", mitk::BoolProperty::New(true)); CurrentPointSetNode->SetProperty("name", mitk::StringProperty::New(name.toStdString())); CurrentPointSetNode->SetProperty("show distances", mitk::BoolProperty::New(true)); // add to ds and remember as created m_CreatedDistances.push_back(CurrentPointSetNode); this->GetDataStorage()->Add(CurrentPointSetNode); // make new selection - std::vector selection; + QList selection; selection.push_back( CurrentPointSetNode ); this->FireNodesSelected( selection ); - this->OnSelectionChanged( selection ); + this->OnSelectionChanged(berry::IWorkbenchPart::Pointer(), selection ); } void QmitkSimpleMeasurement::AddAngleSimpleMeasurement() { mitk::PointSet::Pointer pointSet = mitk::PointSet::New(); QString name = "Angle " + QString::number(m_CreatedAngles.size()+1); mitk::DataNode::Pointer _CurrentPointSetNode = mitk::DataNode::New(); _CurrentPointSetNode->SetData(pointSet); _CurrentPointSetNode->SetProperty("show contour", mitk::BoolProperty::New(true)); _CurrentPointSetNode->SetProperty("name", mitk::StringProperty::New(name.toStdString())); _CurrentPointSetNode->SetProperty("show angles", mitk::BoolProperty::New(true)); // add to ds and remember as created this->GetDataStorage()->Add(_CurrentPointSetNode); m_CreatedAngles.push_back( _CurrentPointSetNode ); // make new selection - std::vector selection; + QList selection; selection.push_back( _CurrentPointSetNode ); this->FireNodesSelected( selection ); - this->OnSelectionChanged( selection ); + this->OnSelectionChanged(berry::IWorkbenchPart::Pointer(), selection ); } void QmitkSimpleMeasurement::AddPathSimpleMeasurement() { mitk::PointSet::Pointer pointSet = mitk::PointSet::New(); QString name = "Path " + QString::number(m_CreatedPaths.size()+1); mitk::DataNode::Pointer _CurrentPointSetNode = mitk::DataNode::New(); _CurrentPointSetNode->SetData(pointSet); _CurrentPointSetNode->SetProperty("show contour", mitk::BoolProperty::New(true)); _CurrentPointSetNode->SetProperty("name", mitk::StringProperty::New(name.toStdString())); _CurrentPointSetNode->SetProperty("show distances", mitk::BoolProperty::New(true)); _CurrentPointSetNode->SetProperty("show angles", mitk::BoolProperty::New(true)); // add to ds and remember as created this->GetDataStorage()->Add(_CurrentPointSetNode); m_CreatedPaths.push_back( _CurrentPointSetNode ); // make new selection - std::vector selection; + QList selection; selection.push_back( _CurrentPointSetNode ); this->FireNodesSelected( selection ); - this->OnSelectionChanged( selection ); + this->OnSelectionChanged(berry::IWorkbenchPart::Pointer(), selection ); } void QmitkSimpleMeasurement::CreateQtPartControl( QWidget* parent ) { m_CreatedDistances = std::vector(); m_CreatedAngles = std::vector(); m_CreatedPaths = std::vector(); m_Controls = new Ui::QmitkSimpleMeasurementControls; m_Controls->setupUi(parent); connect( (QObject*)(m_Controls->pbDistance), SIGNAL(clicked()),(QObject*) this, SLOT(AddDistanceSimpleMeasurement()) ); connect( (QObject*)(m_Controls->pbAngle), SIGNAL(clicked()),(QObject*) this, SLOT(AddAngleSimpleMeasurement()) ); connect( (QObject*)(m_Controls->pbPath), SIGNAL(clicked()),(QObject*) this, SLOT(AddPathSimpleMeasurement()) ); connect( (QObject*)(m_Controls->m_Finished), SIGNAL(clicked()),(QObject*) this, SLOT(Finished()) ); EndEditingMeasurement(); } +void QmitkSimpleMeasurement::SetFocus() +{ + m_Controls->m_Finished->setFocus(); +} + void QmitkSimpleMeasurement::Finished() { - OnSelectionChanged(std::vector()); + OnSelectionChanged(berry::IWorkbenchPart::Pointer(), QList()); } -void QmitkSimpleMeasurement::OnSelectionChanged( std::vector nodes ) +void QmitkSimpleMeasurement::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList &nodes) { - mitk::DataNode* selectedNode = 0; + mitk::DataNode::Pointer selectedNode ; if(nodes.size() > 0) selectedNode = nodes.front(); mitk::PointSet* pointSet = 0; - if(selectedNode) + if(selectedNode.IsNotNull()) pointSet = dynamic_cast ( selectedNode->GetData() ); // something else was selected. remove old interactor if (m_PointSetInteractor.IsNotNull()) { - mitk::GlobalInteraction::GetInstance()->RemoveInteractor(m_PointSetInteractor); + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(m_PointSetInteractor.GetPointer()); } bool pointsetCreatedByThis = false; // only go further if a pointset was selected if(pointSet) { // see if this pointset was created by us std::vector::iterator it = std::find( m_CreatedDistances.begin() , m_CreatedDistances.end(), selectedNode); if (it != m_CreatedDistances.end()) pointsetCreatedByThis = true; it = std::find( m_CreatedAngles.begin() , m_CreatedAngles.end(), selectedNode); if (it != m_CreatedAngles.end()) pointsetCreatedByThis = true; it = std::find( m_CreatedPaths.begin() , m_CreatedPaths.end(), selectedNode); if (it != m_CreatedPaths.end()) pointsetCreatedByThis = true; } // do nothing if it was not created by us or it is no pointset node or we are not activated - if(pointsetCreatedByThis && this->IsActivated()) + if(pointsetCreatedByThis) { // otherwise: set text and add interactor for the pointset m_Controls->selectedPointSet->setText( QString::fromStdString(selectedNode->GetName()) ); mitk::PointSetInteractor::Pointer newPointSetInteractor - = mitk::PointSetInteractor::New("pointsetinteractor", selectedNode); + = mitk::PointSetInteractor::New("pointsetinteractor", selectedNode.GetPointer()); mitk::GlobalInteraction::GetInstance()->AddInteractor(newPointSetInteractor); m_PointSetInteractor = newPointSetInteractor; float green[] = { 0, 255, 0 }; float red[] = { 255, 0, 0 }; selectedNode->SetColor(green); if(m_SelectedPointSetNode.IsNotNull()) m_SelectedPointSetNode->SetColor(red); m_SelectedPointSetNode = selectedNode; StartEditingMeasurement(); } else { EndEditingMeasurement(); } } -bool QmitkSimpleMeasurement::IsExclusiveFunctionality() const -{ - return true; -} - void QmitkSimpleMeasurement::NodeRemoved( const mitk::DataNode* node ) { // remove a node if it is destroyed from our created array - std::vector::iterator it = std::find( m_CreatedDistances.begin() - , m_CreatedDistances.end(), node); - if(it != m_CreatedDistances.end()) - m_CreatedDistances.erase(it); - - it = std::find( m_CreatedAngles.begin() - , m_CreatedAngles.end(), node); - if(it != m_CreatedAngles.end()) - m_CreatedAngles.erase(it); - - it = std::find( m_CreatedPaths.begin() - , m_CreatedPaths.end(), node); - if(it != m_CreatedPaths.end()) - m_CreatedPaths.erase(it); + m_CreatedDistances.erase(std::remove(m_CreatedDistances.begin(), m_CreatedDistances.end(), node), m_CreatedDistances.end()); + m_CreatedAngles.erase(std::remove(m_CreatedAngles.begin(), m_CreatedAngles.end(), node), m_CreatedAngles.end()); + m_CreatedPaths.erase(std::remove(m_CreatedPaths.begin(), m_CreatedPaths.end(), node), m_CreatedPaths.end()); } void QmitkSimpleMeasurement::StartEditingMeasurement() { -m_Controls->explain_label->setVisible(true); -m_Controls->m_Finished->setVisible(true); -m_Controls->pbDistance->setEnabled(false); -m_Controls->pbAngle->setEnabled(false); -m_Controls->pbPath->setEnabled(false); -UpdateMeasurementList(); + m_Controls->explain_label->setVisible(true); + m_Controls->m_Finished->setVisible(true); + m_Controls->pbDistance->setEnabled(false); + m_Controls->pbAngle->setEnabled(false); + m_Controls->pbPath->setEnabled(false); + UpdateMeasurementList(); } void QmitkSimpleMeasurement::EndEditingMeasurement() { -m_Controls->pbDistance->setEnabled(true); -m_Controls->pbAngle->setEnabled(true); -m_Controls->pbPath->setEnabled(true); -m_Controls->explain_label->setVisible(false); -m_Controls->m_Finished->setVisible(false); -m_Controls->selectedPointSet->setText( "None" ); -UpdateMeasurementList(); + m_Controls->pbDistance->setEnabled(true); + m_Controls->pbAngle->setEnabled(true); + m_Controls->pbPath->setEnabled(true); + m_Controls->explain_label->setVisible(false); + m_Controls->m_Finished->setVisible(false); + m_Controls->selectedPointSet->setText( "None" ); + UpdateMeasurementList(); } void QmitkSimpleMeasurement::UpdateMeasurementList() { -m_Controls->m_MeasurementList->clear(); + m_Controls->m_MeasurementList->clear(); -for (int i=0; i(m_CreatedDistances.at(i)->GetData()); - if(points->GetSize()<2) distance = "not available"; - else distance = QString::number(points->GetPoint(0).EuclideanDistanceTo(points->GetPoint(1))) + " mm"; - QString name = QString(m_CreatedDistances.at(i)->GetName().c_str()) + " (" + distance + ")"; - newItem->setText(name); - m_Controls->m_MeasurementList->insertItem(m_Controls->m_MeasurementList->count(), newItem); + QListWidgetItem *newItem = new QListWidgetItem; + QString distance; + mitk::PointSet::Pointer points = dynamic_cast(m_CreatedDistances.at(i)->GetData()); + if(points->GetSize()<2) + { + distance = "not available"; + } + else + { + distance = QString::number(points->GetPoint(0).EuclideanDistanceTo(points->GetPoint(1))) + " mm"; + } + QString name = QString(m_CreatedDistances.at(i)->GetName().c_str()) + " (" + distance + ")"; + newItem->setText(name); + m_Controls->m_MeasurementList->insertItem(m_Controls->m_MeasurementList->count(), newItem); } -for (int i=0; iGetName().c_str(); - newItem->setText(name); - m_Controls->m_MeasurementList->insertItem(m_Controls->m_MeasurementList->count(), newItem); + QListWidgetItem *newItem = new QListWidgetItem; + QString name = m_CreatedDistances.at(i)->GetName().c_str(); + newItem->setText(name); + m_Controls->m_MeasurementList->insertItem(m_Controls->m_MeasurementList->count(), newItem); } -for (int i=0; iGetName().c_str(); - newItem->setText(name); - m_Controls->m_MeasurementList->insertItem(m_Controls->m_MeasurementList->count(), newItem); + QListWidgetItem *newItem = new QListWidgetItem; + QString name = m_CreatedDistances.at(i)->GetName().c_str(); + newItem->setText(name); + m_Controls->m_MeasurementList->insertItem(m_Controls->m_MeasurementList->count(), newItem); } - } diff --git a/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurement.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurement.h new file mode 100644 index 0000000000..9313b01104 --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurement.h @@ -0,0 +1,106 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef MITKSIMPELEMEASUREMENT_H +#define MITKSIMPELEMEASUREMENT_H + +#include +#include + +#include + +#include "ui_QmitkSimpleMeasurementControls.h" + +namespace Ui { +class QmitkSimpleMeasurementControls; +} + +namespace mitk { +class PointSetInteractor; +} + + +/** + * \brief SimpleMeasurement + * Allows to measure distances, angles, etc. + * + * \sa QmitkAbstractView + */ +class QmitkSimpleMeasurement : public QmitkAbstractView, public mitk::IZombieViewPart +{ + Q_OBJECT + +public: + + QmitkSimpleMeasurement(); + virtual ~QmitkSimpleMeasurement(); + +private: + + virtual void CreateQtPartControl(QWidget* parent); + + virtual void SetFocus(); + + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes); + + virtual void NodeRemoved(const mitk::DataNode* node); + + virtual void Activated(); + virtual void Deactivated(); + virtual void Visible(); + virtual void Hidden(); + + virtual void ActivatedZombieView(berry::SmartPointer zombieView); + +private slots: + + void AddDistanceSimpleMeasurement(); + void AddAngleSimpleMeasurement(); + void AddPathSimpleMeasurement(); + + void Finished(); + +private: + + /** + * controls containing sliders for scrolling through the slices + */ + Ui::QmitkSimpleMeasurementControls * m_Controls; + + /* + * Interactor for performing the simplemeasurements. + */ + mitk::WeakPointer m_PointSetInteractor; + + /* + * Interactor for performing the simplemeasurements. + */ + mitk::WeakPointer m_SelectedPointSetNode; + + /** @brief + * Node representing the PointSets which were created by this application. + */ + std::vector m_CreatedDistances; + std::vector m_CreatedAngles; + std::vector m_CreatedPaths; + + void StartEditingMeasurement(); + void EndEditingMeasurement(); + void UpdateMeasurementList(); + +}; + +#endif // QMITK_MEASUREMENT_H__INCLUDED diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/QmitkSurfaceUtilities.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/QmitkSurfaceUtilities.cpp similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/QmitkSurfaceUtilities.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/QmitkSurfaceUtilities.cpp diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/QmitkSurfaceUtilities.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/QmitkSurfaceUtilities.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/QmitkSurfaceUtilities.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/QmitkSurfaceUtilities.h diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/QmitkSurfaceUtilitiesControls.ui b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/QmitkSurfaceUtilitiesControls.ui similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/QmitkSurfaceUtilitiesControls.ui rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/QmitkSurfaceUtilitiesControls.ui diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceModifier.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceModifier.cpp similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceModifier.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceModifier.cpp diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceModifier.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceModifier.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceModifier.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceModifier.h diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.cpp similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.cpp diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkSurfaceToPointSetFilter.h diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkTargetPointsCalculator.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkTargetPointsCalculator.cpp similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkTargetPointsCalculator.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkTargetPointsCalculator.cpp diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkTargetPointsCalculator.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkTargetPointsCalculator.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/surfaceutilities/mitkTargetPointsCalculator.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/surfaceutilities/mitkTargetPointsCalculator.h diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationView.cpp similarity index 91% rename from Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.cpp rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationView.cpp index 9b92b43e5f..6a4915c856 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.cpp +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationView.cpp @@ -1,193 +1,190 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkViewInitializationView.h" #include "mitkNodePredicateDataType.h" #include "QmitkDataStorageComboBox.h" -#include "QmitkStdMultiWidget.h" #include "mitkFocusManager.h" #include "mitkGlobalInteraction.h" #include "itkCommand.h" #include const std::string QmitkViewInitializationView::VIEW_ID = "org.mitk.views.viewinitialization"; QmitkViewInitializationView::QmitkViewInitializationView() -: QmitkFunctionality(), - m_Controls(NULL), - m_MultiWidget(NULL) +: m_Controls(NULL) { m_CommandTag = 0; } QmitkViewInitializationView::~QmitkViewInitializationView() { } void QmitkViewInitializationView::CreateQtPartControl(QWidget *parent) { if (!m_Controls) { // create GUI widgets m_Controls = new Ui::QmitkViewInitializationViewControls; m_Controls->setupUi(parent); this->CreateConnections(); } } -void QmitkViewInitializationView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) +void QmitkViewInitializationView::SetFocus() { - m_MultiWidget = &stdMultiWidget; -} - -void QmitkViewInitializationView::StdMultiWidgetNotAvailable() -{ - m_MultiWidget = NULL; + m_Controls->pbApply->setFocus(); } void QmitkViewInitializationView::CreateConnections() { if ( m_Controls ) { connect( (QObject*)(m_Controls->pbApply), SIGNAL(clicked()),(QObject*) this, SLOT(OnApply()) ); connect( (QObject*)(m_Controls->pbReset), SIGNAL(clicked()),(QObject*) this, SLOT(OnResetAll()) ); } } void QmitkViewInitializationView::Activated() { //init render window selector (List Widget) this->InitRenderWindowSelector(); - QmitkFunctionality::Activated(); } void QmitkViewInitializationView::Deactivated() { mitk::FocusManager* fm = mitk::GlobalInteraction::GetInstance()->GetFocusManager(); fm->RemoveObserver(m_CommandTag); - QmitkFunctionality::Deactivated(); } +void QmitkViewInitializationView::Visible() +{ +} + +void QmitkViewInitializationView::Hidden() +{ +} void QmitkViewInitializationView::OnApply() { mitk::SliceNavigationController::ViewDirection viewDirection( mitk::SliceNavigationController::Axial ); if( m_Controls->rbAxial->isChecked() ) viewDirection = mitk::SliceNavigationController::Axial; else if( m_Controls->rbFrontal->isChecked()) viewDirection = mitk::SliceNavigationController::Frontal; else if( m_Controls->rbSagittal->isChecked() ) viewDirection = mitk::SliceNavigationController::Sagittal; vtkRenderWindow* renderwindow = this->GetSelectedRenderWindow(); if(renderwindow != NULL) { mitk::BaseRenderer::GetInstance(renderwindow)->GetSliceNavigationController()->Update(viewDirection, m_Controls->cbTop->isChecked(), m_Controls->cbFrontSide->isChecked(), m_Controls->cbRotated->isChecked() ); mitk::BaseRenderer::GetInstance(renderwindow)->GetDisplayGeometry()->Fit(); } } void QmitkViewInitializationView::OnResetAll() { /* calculate bounding geometry of these nodes */ - mitk::TimeGeometry::Pointer bounds = this->GetDefaultDataStorage()->ComputeBoundingGeometry3D(); + mitk::TimeGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(); /* initialize the views to the bounding geometry */ mitk::RenderingManager::GetInstance()->InitializeViews(bounds); } vtkRenderWindow* QmitkViewInitializationView::GetSelectedRenderWindow() { int selectedItem = m_Controls->m_lbRenderWindows->currentRow(); int itemNumber = 0; mitk::BaseRenderer::BaseRendererMapType::iterator mapit; for(mapit = mitk::BaseRenderer::baseRendererMap.begin(); mapit != mitk::BaseRenderer::baseRendererMap.end(); mapit++, itemNumber++) { if(itemNumber==selectedItem) break; } if(itemNumber==selectedItem) { return (*mapit).first; } return NULL; } void QmitkViewInitializationView::InitRenderWindowSelector() { itk::SimpleMemberCommand::Pointer updateRendererListCommand = itk::SimpleMemberCommand::New(); updateRendererListCommand->SetCallbackFunction( this, &QmitkViewInitializationView::UpdateRendererList ); mitk::FocusManager* fm = mitk::GlobalInteraction::GetInstance()->GetFocusManager(); m_CommandTag = fm->AddObserver(mitk::FocusEvent(), updateRendererListCommand); this->UpdateRendererList(); } void QmitkViewInitializationView::UpdateRendererList() { vtkRenderWindow* focusedRenderWindow = NULL; mitk::FocusManager* fm = mitk::GlobalInteraction::GetInstance()->GetFocusManager(); mitk::BaseRenderer::ConstPointer br = fm->GetFocused(); if (br.IsNotNull()) { focusedRenderWindow = br->GetRenderWindow(); } int selectedItem = -1; int itemNumber = 0; m_Controls->m_lbRenderWindows->clear(); for(mitk::BaseRenderer::BaseRendererMapType::iterator mapit = mitk::BaseRenderer::baseRendererMap.begin(); mapit != mitk::BaseRenderer::baseRendererMap.end(); mapit++, itemNumber++) { if( (*mapit).second->GetName()) { m_Controls->m_lbRenderWindows->addItem(QString((*mapit).second->GetName())); if(focusedRenderWindow==(*mapit).first) selectedItem = itemNumber; } } if (selectedItem>=0) { m_Controls->m_lbRenderWindows->setCurrentRow(selectedItem); } else { m_Controls->m_lbRenderWindows->clearSelection(); } } diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationView.h similarity index 81% rename from Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationView.h index 988fab554e..a143bcfe8e 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.h +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationView.h @@ -1,92 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QMITKVIEWINITIALIZATIONVIEW_H_INCLUDED #define _QMITKVIEWINITIALIZATIONVIEW_H_INCLUDED -#include +#include +#include #include #include "vtkRenderWindow.h" #include "ui_QmitkViewInitializationViewControls.h" /*! * \ingroup org_mitk_gui_qt_viewinitialization_internal * * \brief QmitkViewInitializationView * * Document your class here. * * \sa QmitkFunctionality */ -class QmitkViewInitializationView : public QmitkFunctionality +class QmitkViewInitializationView : public QmitkAbstractView, public mitk::ILifecycleAwarePart { // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT - public: +public: static const std::string VIEW_ID; QmitkViewInitializationView(); virtual ~QmitkViewInitializationView(); virtual void CreateQtPartControl(QWidget *parent); + virtual void SetFocus(); + /// \brief Creation of the connections of main and control widget virtual void CreateConnections(); - /// \brief Called when the functionality is activated - virtual void Activated(); - - virtual void Deactivated(); - - virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); - virtual void StdMultiWidgetNotAvailable(); - -protected: +private: vtkRenderWindow* GetSelectedRenderWindow(); void InitRenderWindowSelector(); void UpdateRendererList(); -protected slots: + virtual void Activated(); + virtual void Deactivated(); + virtual void Visible(); + virtual void Hidden(); + +private slots: virtual void OnApply(); virtual void OnResetAll(); -protected: +private: Ui::QmitkViewInitializationViewControls* m_Controls; - QmitkStdMultiWidget* m_MultiWidget; - unsigned long m_CommandTag; }; #endif // _QMITKVIEWINITIALIZATIONVIEW_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui similarity index 100% rename from Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui diff --git a/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryView.cpp b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryView.cpp new file mode 100644 index 0000000000..3e2955c78e --- /dev/null +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryView.cpp @@ -0,0 +1,253 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "QmitkVolumetryView.h" + +#include "ui_QmitkVolumetryViewControls.h" + +#include "mitkVolumeCalculator.h" +#include "mitkImageStatisticsHolder.h" + +#include +#include +#include +#include + +const std::string QmitkVolumetryView::VIEW_ID = "org.mitk.views.volumetry"; + +QmitkVolumetryView::QmitkVolumetryView() + : m_Controls(NULL) + , m_ParentWidget(NULL) +{ +} + +void QmitkVolumetryView::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + m_ParentWidget = parent; + // create GUI widgets + m_Controls = new Ui::QmitkVolumetryViewControls; + m_Controls->setupUi(parent); + this->CreateConnections(); + } +} + +void QmitkVolumetryView::SetFocus() +{ + m_Controls->m_CalcButton->setFocus(); +} + +void QmitkVolumetryView::CreateConnections() +{ + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->m_ThresholdSlider), SIGNAL(valueChanged(int)), this, SLOT(OnThresholdSliderChanged(int)) ); + connect( (QObject*)(m_Controls->m_CalcButton), SIGNAL(clicked()), this, SLOT(OnCalculateVolume()) ); + connect( (QObject*)(m_Controls->m_TimeSeriesButton), SIGNAL(clicked()), this, SLOT(OnTimeSeriesButtonClicked()) ); + connect( (QObject*)(m_Controls->m_SaveCsvButton), SIGNAL(clicked()), this, SLOT(OnSaveCsvButtonClicked()) ); + } +} + +void QmitkVolumetryView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList &nodes) +{ + m_SelectedDataNode = NULL; + if (!nodes.isEmpty() && dynamic_cast(nodes.front()->GetData())) + { + m_SelectedDataNode = nodes.front(); + m_ParentWidget->setEnabled(true); + } + + if (m_SelectedDataNode.IsNull() || m_SelectedDataNode.GetPointer() == m_OverlayNode.GetPointer()) + { + m_SelectedDataNode = NULL; + m_ParentWidget->setEnabled(false); + return; + } + + if (m_OverlayNode) + { + this->GetDataStorage()->Remove(m_OverlayNode); + m_OverlayNode = NULL; + } + + this->CreateOverlayChild(); + + m_Controls->m_CalcButton->setEnabled(false); + m_Controls->m_TimeSeriesButton->setEnabled(false); + m_Controls->m_SaveCsvButton->setEnabled(false); + m_Controls->m_TextEdit->clear(); + + mitk::Image* image = dynamic_cast(m_SelectedDataNode->GetData()); + image->Update(); + if (image && image->IsInitialized()) + { + if (image->GetDimension() == 4) + { + m_Controls->m_TimeSeriesButton->setEnabled(true); + } + else + { + m_Controls->m_CalcButton->setEnabled(true); + } + int minVal = (int)image->GetStatistics()->GetScalarValue2ndMin(); + int maxVal = (int)image->GetStatistics()->GetScalarValueMaxNoRecompute(); + if (minVal == maxVal) + --minVal; + m_Controls->m_ThresholdSlider->setMinimum(minVal); + m_Controls->m_ThresholdSlider->setMaximum(maxVal); + m_Controls->m_ThresholdSlider->setEnabled(true); + this->UpdateSlider(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } +} + +void QmitkVolumetryView::OnCalculateVolume() +{ + if (m_SelectedDataNode.IsNotNull() ) + { + mitk::Image* image = dynamic_cast(m_SelectedDataNode->GetData()); + std::cout << "Dimension:" << image->GetDimension() << std::endl; + std::cout << "Dimension[3]:" << image->GetDimension(3) << std::endl; + mitk::VolumeCalculator::Pointer volCalc = mitk::VolumeCalculator::New(); + volCalc->SetImage(image); + volCalc->SetThreshold(m_Controls->m_ThresholdSlider->value()); + volCalc->ComputeVolume(); + std::stringstream vs; + vs << volCalc->GetVolume() << " ml"; + m_Controls->m_Result->setText(vs.str().c_str() ); + } +} + +void QmitkVolumetryView::OnTimeSeriesButtonClicked() +{ + if (m_SelectedDataNode.IsNotNull() ) + { + mitk::Image* image = dynamic_cast(m_SelectedDataNode->GetData()); + mitk::VolumeCalculator::Pointer volCalc = mitk::VolumeCalculator::New(); + volCalc->SetImage(image); + volCalc->SetThreshold(m_Controls->m_ThresholdSlider->value()); + volCalc->ComputeVolume(); + std::vector volumes = volCalc->GetVolumes(); + std::stringstream vs; + int timeStep = 0; + for (std::vector::iterator it = volumes.begin(); it != volumes.end(); it++) + { + vs << timeStep++ << "\t" << *it << std::endl; + } + m_Controls->m_TextEdit->setText(vs.str().c_str()); + m_Controls->m_TextEdit->setTabStopWidth(20); + m_Controls->m_SaveCsvButton->setEnabled(true); + } +} + +const mitk::DataNode* QmitkVolumetryView::GetImageNode() const +{ + return m_SelectedDataNode; +} + +void QmitkVolumetryView::UpdateSlider() +{ + if (m_SelectedDataNode.IsNotNull() && dynamic_cast(m_SelectedDataNode->GetData())) + { + int intSliderValue = (int)m_Controls->m_ThresholdSlider->value(); + QString stringSliderValue; + stringSliderValue.setNum(intSliderValue); + m_Controls->m_ThresholdLineEdit->setText(stringSliderValue); + } +} + + +void QmitkVolumetryView::UpdateSliderLabel() +{ + int sliderValue = atoi(m_Controls->m_ThresholdLineEdit->text().toLatin1()); + m_Controls->m_ThresholdSlider->setValue(sliderValue); + this->UpdateSlider(); + +} + +void QmitkVolumetryView::OnThresholdSliderChanged( int value) +{ + if (m_OverlayNode) + { + m_OverlayNode->SetLevelWindow(mitk::LevelWindow(value,1)); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + + this->UpdateSlider(); + } +} + +void QmitkVolumetryView::CreateOverlayChild() +{ + if (m_SelectedDataNode.IsNotNull()) + { + m_OverlayNode = mitk::DataNode::New(); + mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New("volume threshold overlay image" ); + m_OverlayNode->SetProperty( "reslice interpolation", m_SelectedDataNode->GetProperty("reslice interpolation") ); + m_OverlayNode->SetProperty( "name", nameProp ); + m_OverlayNode->SetData(m_SelectedDataNode->GetData()); + m_OverlayNode->SetColor(0.0,1.0,0.0); + m_OverlayNode->SetOpacity(.25); + int layer = 0; + m_SelectedDataNode->GetIntProperty("layer", layer); + m_OverlayNode->SetIntProperty("layer", layer+1); + m_OverlayNode->SetLevelWindow(mitk::LevelWindow(m_Controls->m_ThresholdSlider->value(),1)); + + this->GetDataStorage()->Add(m_OverlayNode); + } +} + +mitk::DataNode* QmitkVolumetryView::GetOverlayNode() const +{ + return m_OverlayNode; +} + +mitk::Image* QmitkVolumetryView::GetImage() const +{ + return dynamic_cast(m_SelectedDataNode->GetData()); +} + +void QmitkVolumetryView::OnSaveCsvButtonClicked() +{ + static QString lastSavePath = QDir::homePath(); + + QString s = QFileDialog::getSaveFileName( this->m_ParentWidget, "Save as..", lastSavePath, "CSV Files (*.csv)"); + /*"Save file dialog" + "Choose a filename to save under" );*/ + + if (!s.isEmpty()) + { + lastSavePath = s; + QFile saveFile(s); + + if (saveFile.open(QIODevice::WriteOnly)) + { + QTextStream stream( &saveFile ); + stream << m_Controls->m_TextEdit->toPlainText().replace('\t',';'); + saveFile.close(); + } + else + { + // QMessageBox::critical(NULL,"Save Error!",QString("Saving of CSV failed! Couldn't open output file \"") + saveFile + QString("\""),QMessageBox:Ok,QMessageBox::NoButton); + //QMessageBox::critical(NULL,"Save Error!","Saving of CSV failed! Couldn't open output file \"" + saveFile.name() +"\"",QMessageBox::Ok,QMessageBox::NoButton); + } + } +} + + + + + diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.h b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryView.h similarity index 60% rename from Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.h rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryView.h index 17f2b9fd45..957c67a317 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.h +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryView.h @@ -1,114 +1,95 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QMITKVOLUMETRYVIEW_H_INCLUDED #define _QMITKVOLUMETRYVIEW_H_INCLUDED -#include +#include -#include +#include "mitkWeakPointer.h" -#include "ui_QmitkVolumetryViewControls.h" +namespace Ui { +class QmitkVolumetryViewControls; +} - -/*! - * \ingroup org_mitk_gui_qt_volumetry_internal - * +/** * \brief QmitkVolumetryView * - * Document your class here. - * - * \sa QmitkFunctionality + * \sa QmitkAbstractView */ -class QmitkVolumetryView : public QmitkFunctionality +class QmitkVolumetryView : public QmitkAbstractView { - - // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT - public: +public: static const std::string VIEW_ID; QmitkVolumetryView(); - virtual ~QmitkVolumetryView(); +private: virtual void CreateQtPartControl(QWidget *parent); + virtual void SetFocus(); + /// \brief Creation of the connections of main and control widget virtual void CreateConnections(); - /// \brief Called when the functionality is activated - virtual void Activated(); - - virtual void Deactivated(); - - virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); - virtual void StdMultiWidgetNotAvailable(); - -protected: + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes); - mitk::Image* GetImage(); + mitk::Image* GetImage() const; - mitk::DataNode* GetOverlayNode(); + mitk::DataNode* GetOverlayNode() const; void CreateOverlayChild(); void UpdateSliderLabel(); void UpdateSlider(); - const mitk::DataNode* GetImageNode(); - - -protected slots: + const mitk::DataNode* GetImageNode() const; +private slots: void OnCalculateVolume(); void OnTimeSeriesButtonClicked(); void OnThresholdSliderChanged( int value ); void OnSaveCsvButtonClicked(); - void OnImageSelected(const mitk::DataNode* item); - - - -protected: +private: Ui::QmitkVolumetryViewControls* m_Controls; - QmitkStdMultiWidget* m_MultiWidget; - /// store weak pointer of the DataNode mitk::WeakPointer m_SelectedDataNode; - mitk::DataNode::Pointer m_OverlayNode; mitk::DataStorage::Pointer m_DataStorage; + QWidget* m_ParentWidget; }; #endif // _QMITKVOLUMETRYVIEW_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryViewControls.ui b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryViewControls.ui similarity index 53% rename from Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryViewControls.ui rename to Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryViewControls.ui index 2dbb4ee07e..7a2ff00ce4 100644 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryViewControls.ui +++ b/Examples/Plugins/org.mitk.example.gui.imaging/src/internal/volumetry/QmitkVolumetryViewControls.ui @@ -1,194 +1,185 @@ - + + QmitkVolumetryViewControls - - + + 0 0 277 450 - + 0 0 - + QmitkTemplate - + - - - - + - + - - + + Threshold - - + + false - - + + 0 0 - + C&alc! - + Alt+A - - + + false - - + + 0 0 - + Time series - - + + Qt::Vertical - + QSizePolicy::Expanding - + 20 149 - - + + false - - + + 0 0 - + Save CSV - + - + - - + + 1000 - + Qt::Horizontal - - - + + + 0 0 - + 30 0 - + 50 32767 - + 1000 - - - + + + 0 0 - + - - + + Qt::Vertical - + QSizePolicy::Expanding - + 20 220 - - - - QmitkDataStorageComboBox - QComboBox -
QmitkDataStorageComboBox.h
-
-
+ - QmitkDataStorageComboBox.h + QmitkDataStorageComboBox.h
diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/CMakeLists.txt b/Examples/Plugins/org.mitk.example.gui.opencv/CMakeLists.txt similarity index 86% rename from Plugins/org.mitk.gui.qt.examplesopencv/CMakeLists.txt rename to Examples/Plugins/org.mitk.example.gui.opencv/CMakeLists.txt index 51c996fc51..451ab71074 100644 --- a/Plugins/org.mitk.gui.qt.examplesopencv/CMakeLists.txt +++ b/Examples/Plugins/org.mitk.example.gui.opencv/CMakeLists.txt @@ -1,9 +1,9 @@ # The project name must correspond to the directory name of your plug-in # and must not contain periods. -project(org_mitk_gui_qt_examplesopencv) +project(org_mitk_example_gui_opencv) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE EXAMPLESOPENCV_EXPORTS EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES mitkOpenCVVideoSupportUI -) \ No newline at end of file +) diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/MITKExamplesOpenCV.dox b/Examples/Plugins/org.mitk.example.gui.opencv/documentation/UserManual/MITKExamplesOpenCV.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/MITKExamplesOpenCV.dox rename to Examples/Plugins/org.mitk.example.gui.opencv/documentation/UserManual/MITKExamplesOpenCV.dox diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/VideoPlayerUserManual.dox b/Examples/Plugins/org.mitk.example.gui.opencv/documentation/UserManual/VideoPlayerUserManual.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/VideoPlayerUserManual.dox rename to Examples/Plugins/org.mitk.example.gui.opencv/documentation/UserManual/VideoPlayerUserManual.dox diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/videoplayer.gif b/Examples/Plugins/org.mitk.example.gui.opencv/documentation/UserManual/videoplayer.gif similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/videoplayer.gif rename to Examples/Plugins/org.mitk.example.gui.opencv/documentation/UserManual/videoplayer.gif diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox b/Examples/Plugins/org.mitk.example.gui.opencv/documentation/doxygen/modules.dox similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox rename to Examples/Plugins/org.mitk.example.gui.opencv/documentation/doxygen/modules.dox diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/files.cmake b/Examples/Plugins/org.mitk.example.gui.opencv/files.cmake similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/files.cmake rename to Examples/Plugins/org.mitk.example.gui.opencv/files.cmake diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake b/Examples/Plugins/org.mitk.example.gui.opencv/manifest_headers.cmake similarity index 78% rename from Plugins/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake rename to Examples/Plugins/org.mitk.example.gui.opencv/manifest_headers.cmake index d08127c1a3..2c59fae3da 100644 --- a/Plugins/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake +++ b/Examples/Plugins/org.mitk.example.gui.opencv/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "MITK Examples OpenCV") set(Plugin-Version "1.0") set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common.legacy) \ No newline at end of file +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/plugin.xml b/Examples/Plugins/org.mitk.example.gui.opencv/plugin.xml similarity index 71% rename from Plugins/org.mitk.gui.qt.examplesopencv/plugin.xml rename to Examples/Plugins/org.mitk.example.gui.opencv/plugin.xml index 40948d03a5..16e9d773f5 100644 --- a/Plugins/org.mitk.gui.qt.examplesopencv/plugin.xml +++ b/Examples/Plugins/org.mitk.example.gui.opencv/plugin.xml @@ -1,17 +1,14 @@ - diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/resources/videoplayer.gif b/Examples/Plugins/org.mitk.example.gui.opencv/resources/videoplayer.gif similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/resources/videoplayer.gif rename to Examples/Plugins/org.mitk.example.gui.opencv/resources/videoplayer.gif diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.cpp b/Examples/Plugins/org.mitk.example.gui.opencv/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.cpp rename to Examples/Plugins/org.mitk.example.gui.opencv/src/internal/mitkPluginActivator.cpp diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.h b/Examples/Plugins/org.mitk.example.gui.opencv/src/internal/mitkPluginActivator.h similarity index 100% rename from Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.h rename to Examples/Plugins/org.mitk.example.gui.opencv/src/internal/mitkPluginActivator.h diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.cpp b/Examples/Plugins/org.mitk.example.gui.opencv/src/internal/videoplayer/QmitkVideoPlayer.cpp similarity index 64% rename from Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.cpp rename to Examples/Plugins/org.mitk.example.gui.opencv/src/internal/videoplayer/QmitkVideoPlayer.cpp index 088bdd99b5..ba6fa8c85d 100644 --- a/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.cpp +++ b/Examples/Plugins/org.mitk.example.gui.opencv/src/internal/videoplayer/QmitkVideoPlayer.cpp @@ -1,58 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkVideoPlayer.h" #include #include #include #include QmitkVideoPlayer::QmitkVideoPlayer() -: m_VideoSource(0) -, m_VideoBackground( new QmitkVideoBackground(m_VideoSource) ) + : m_VideoSource(0) + , m_VideoBackground( new QmitkVideoBackground(m_VideoSource) ) { } QmitkVideoPlayer::~QmitkVideoPlayer() { // save video preferences } -bool QmitkVideoPlayer::IsExclusiveFunctionality() const -{ - return false; -} - void QmitkVideoPlayer::CreateQtPartControl( QWidget* parent ) { // retrieve old preferences m_VideoSource = mitk::OpenCVVideoSource::New(); m_VideoBackground = new QmitkVideoBackground(m_VideoSource); m_VideoBackground->setParent(parent); QVBoxLayout* layout = new QVBoxLayout; - m_OpenCVVideoControls = new QmitkOpenCVVideoControls(m_VideoBackground, - this->GetActiveStdMultiWidget()); + QmitkRenderWindow* renderWindow = NULL; + if (this->GetRenderWindowPart()) + { + renderWindow = this->GetRenderWindowPart()->GetActiveQmitkRenderWindow(); + } + m_OpenCVVideoControls = new QmitkOpenCVVideoControls(m_VideoBackground, renderWindow); layout->addWidget( m_OpenCVVideoControls ); parent->setLayout( layout ); } -void QmitkVideoPlayer::StdMultiWidgetAvailable( QmitkStdMultiWidget& stdMultiWidget ) +void QmitkVideoPlayer::SetFocus() +{ + m_OpenCVVideoControls->setFocus(); +} + +void QmitkVideoPlayer::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) +{ + m_OpenCVVideoControls->SetRenderWindow(renderWindowPart->GetActiveQmitkRenderWindow()); +} + +void QmitkVideoPlayer::RenderWindowPartDeactivated(mitk::IRenderWindowPart* /*renderWindowPart*/) { - m_OpenCVVideoControls->SetStdMultiWidget( &stdMultiWidget ); + m_OpenCVVideoControls->SetRenderWindow(NULL); } diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.h b/Examples/Plugins/org.mitk.example.gui.opencv/src/internal/videoplayer/QmitkVideoPlayer.h similarity index 58% rename from Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.h rename to Examples/Plugins/org.mitk.example.gui.opencv/src/internal/videoplayer/QmitkVideoPlayer.h index 93f35cfe14..5142af3996 100644 --- a/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.h +++ b/Examples/Plugins/org.mitk.example.gui.opencv/src/internal/videoplayer/QmitkVideoPlayer.h @@ -1,46 +1,54 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#if !defined(QmitkVideoPlayer_h) +#ifndef QmitkVideoPlayer_h #define QmitkVideoPlayer_h -#include +#include +#include + #include class QmitkVideoBackground; class QmitkOpenCVVideoControls; -/*! -\brief Allows to play videos with OpenCV -*/ -class QmitkVideoPlayer: public QmitkFunctionality + +/** + * \brief Allows to play videos with OpenCV + */ +class QmitkVideoPlayer: public QmitkAbstractView, public mitk::IRenderWindowPartListener { Q_OBJECT - public: - QmitkVideoPlayer(); - virtual ~QmitkVideoPlayer(); - virtual bool IsExclusiveFunctionality() const; - virtual void StdMultiWidgetAvailable(QmitkStdMultiWidget& stdMultiWidget); - protected: - // Pseudo Ctor - void CreateQtPartControl(QWidget* parent); -protected: +public: + + QmitkVideoPlayer(); + virtual ~QmitkVideoPlayer(); + +private: + + void CreateQtPartControl(QWidget* parent); + + void SetFocus(); + + void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart); + void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart); + mitk::OpenCVVideoSource::Pointer m_VideoSource; QmitkVideoBackground* m_VideoBackground; QmitkOpenCVVideoControls* m_OpenCVVideoControls; }; -#endif // !defined(QmitkVideoPlayer_h) +#endif // QmitkVideoPlayer_h diff --git a/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.cpp b/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.cpp index 72a65022da..c406341717 100644 --- a/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.cpp +++ b/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.cpp @@ -1,329 +1,316 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkOpenCVVideoControls.h" #include -#include +#include #include QmitkOpenCVVideoControls::QmitkOpenCVVideoControls( QmitkVideoBackground* _VideoBackground - , QmitkStdMultiWidget* _MultiWidget + , QmitkRenderWindow* _RenderWindow , QWidget * parent, Qt::WindowFlags f) : QWidget(parent, f) , m_VideoBackground(0) -, m_MultiWidget(0) +, m_RenderWindow(0) , m_VideoSource(0) , m_Controls(new Ui::QmitkOpenCVVideoControls) , m_SliderCurrentlyMoved(false) { m_Controls->setupUi(this); m_Controls->FileChooser->SetFileMustExist(true); m_Controls->FileChooser->SetSelectDir(false); - this->SetStdMultiWidget(_MultiWidget); + this->SetRenderWindow(_RenderWindow); this->SetVideoBackground(_VideoBackground); } QmitkOpenCVVideoControls::~QmitkOpenCVVideoControls() { if(m_VideoSource != 0 && m_VideoSource->IsCapturingEnabled()) this->Stop(); // emulate stop } void QmitkOpenCVVideoControls::on_UseGrabbingDeviceButton_clicked( bool /*checked=false*/ ) { m_Controls->GrabbingDevicePanel->setEnabled(true); m_Controls->VideoFilePanel->setEnabled(false); } void QmitkOpenCVVideoControls::on_UseVideoFileButton_clicked( bool /*checked=false*/ ) { m_Controls->GrabbingDevicePanel->setEnabled(false); m_Controls->VideoFilePanel->setEnabled(true); m_Controls->FileChooser->setEnabled(true); } //void QmitkOpenCVVideoControls::on_VideoProgressSlider_sliderMoved( int value ) //{ // MITK_DEBUG << "progress bar slider clicked"; // double progressRatio = static_cast(value)/static_cast(m_Controls->VideoProgressSlider->maximum()); // MITK_DEBUG << "progressRatio" << progressRatio; // m_VideoSource->SetVideoCaptureProperty(CV_CAP_PROP_POS_AVI_RATIO, progressRatio); //} void QmitkOpenCVVideoControls::on_VideoProgressSlider_sliderPressed() { m_SliderCurrentlyMoved = true; // temporary pause the video while sliding if( !m_VideoSource->GetCapturePaused() ) m_VideoSource->PauseCapturing(); MITK_DEBUG << "freezing video with old pos ratio: "<< m_VideoSource->GetVideoCaptureProperty(CV_CAP_PROP_POS_AVI_RATIO); } void QmitkOpenCVVideoControls::on_VideoProgressSlider_sliderReleased() { double progressRatio = static_cast(m_Controls->VideoProgressSlider->value()) /static_cast(m_Controls->VideoProgressSlider->maximum()); m_VideoSource->SetVideoCaptureProperty(CV_CAP_PROP_POS_AVI_RATIO, progressRatio); MITK_DEBUG << "resuming video with new pos ratio: "<< progressRatio; // resume the video ( if it was not paused by the user) if( m_VideoSource->GetCapturePaused() && m_Controls->PlayButton->isChecked() ) m_VideoSource->PauseCapturing(); m_SliderCurrentlyMoved = false; } void QmitkOpenCVVideoControls::on_RepeatVideoButton_clicked( bool checked/*=false */ ) { MITK_INFO << "repeat video clicked"; m_VideoSource->SetRepeatVideo(checked); } void QmitkOpenCVVideoControls::on_PlayButton_clicked( bool checked/*=false*/ ) { MITK_INFO << "play button clicked"; if(checked) { if( m_VideoSource->GetCapturePaused() ) { this->SwitchPlayButton(false); m_VideoSource->PauseCapturing(); } else { if(m_Controls->UseGrabbingDeviceButton->isChecked()) { m_VideoSource->SetVideoCameraInput(m_Controls->GrabbingDeviceNumber->text().toInt(),false); m_Controls->VideoFileControls->setEnabled(false); } else { m_VideoSource->SetVideoFileInput(m_Controls->FileChooser->GetFile().c_str(), m_Controls->RepeatVideoButton->isChecked(), false); m_VideoSource->SetRepeatVideo(m_Controls->RepeatVideoButton->isChecked()); m_Controls->VideoProgressSlider->setValue(0); } m_VideoSource->StartCapturing(); if(!m_VideoSource->IsCapturingEnabled()) { MITK_ERROR << "Video could not be initialized!"; m_Controls->PlayButton->setChecked(false); } else { int hertz = m_Controls->UpdateRate->text().toInt(); int updateTime = itk::Math::Round( 1000.0/hertz ); // resets the whole background m_VideoBackground->SetTimerDelay( updateTime ); - m_VideoBackground->AddRenderWindow( m_MultiWidget->GetRenderWindow4()->GetRenderWindow() ); + m_VideoBackground->AddRenderWindow( m_RenderWindow->GetVtkRenderWindow() ); this->connect( m_VideoBackground, SIGNAL(NewFrameAvailable(mitk::VideoSource*)) , this, SLOT(NewFrameAvailable(mitk::VideoSource*))); - m_MultiWidget->DisableGradientBackground(); m_VideoBackground->Enable(); this->m_Controls->StopButton->setEnabled(true); // show video file controls if(m_Controls->UseVideoFileButton->isChecked()) { m_Controls->VideoFileControls->setEnabled(true); m_Controls->RepeatVideoButton->setEnabled(true); m_Controls->VideoProgressSlider->setEnabled(true); } // show pause button this->SwitchPlayButton(false); // disable other controls m_Controls->GrabbingDevicePanel->setEnabled(false); m_Controls->VideoFilePanel->setEnabled(false); m_Controls->UseGrabbingDeviceButton->setEnabled(false); m_Controls->UseVideoFileButton->setEnabled(false); m_Controls->UpdateRatePanel->setEnabled(false); } } } else { // show pause button this->SwitchPlayButton(true); m_VideoSource->PauseCapturing(); } } void QmitkOpenCVVideoControls::on_StopButton_clicked( bool /*checked=false*/ ) { this->Stop(); } void QmitkOpenCVVideoControls::Stop() { // disable video file controls, stop button and show play button again m_Controls->UseGrabbingDeviceButton->setEnabled(true); m_Controls->UseVideoFileButton->setEnabled(true); if(m_Controls->UseGrabbingDeviceButton->isChecked()) on_UseGrabbingDeviceButton_clicked(true); else on_UseVideoFileButton_clicked(true); m_Controls->UpdateRatePanel->setEnabled(true); m_Controls->VideoFileControls->setEnabled(false); this->m_Controls->StopButton->setEnabled(false); this->SwitchPlayButton(true); - if(m_MultiWidget) - m_MultiWidget->EnableGradientBackground(); if(m_VideoBackground) { m_VideoBackground->Disable(); - if(m_MultiWidget) - m_VideoBackground->RemoveRenderWindow( m_MultiWidget->GetRenderWindow4()->GetRenderWindow() ); + if(m_RenderWindow) + m_VideoBackground->RemoveRenderWindow( m_RenderWindow->GetVtkRenderWindow() ); this->disconnect( m_VideoBackground, SIGNAL(NewFrameAvailable(mitk::VideoSource*)) , this, SLOT(NewFrameAvailable(mitk::VideoSource*))); } if(m_VideoSource != 0) m_VideoSource->StopCapturing(); } void QmitkOpenCVVideoControls::Reset() { this->Stop(); } void QmitkOpenCVVideoControls::SwitchPlayButton(bool paused) { if(paused) { m_Controls->PlayButton->setText("Play"); m_Controls->PlayButton->setIcon( QIcon(":/OpenCVVideoSupportUI/media-playback-start.png") ); m_Controls->PlayButton->setChecked(false); } else { m_Controls->PlayButton->setText("Pause"); m_Controls->PlayButton->setIcon( QIcon(":/OpenCVVideoSupportUI/media-playback-pause.png") ); m_Controls->PlayButton->setChecked(true); } } void QmitkOpenCVVideoControls::NewFrameAvailable( mitk::VideoSource* /*videoSource*/ ) { emit NewOpenCVFrameAvailable( m_VideoSource->GetCurrentFrame() ); if(!m_SliderCurrentlyMoved) m_Controls->VideoProgressSlider->setValue( itk::Math::Round( m_VideoSource->GetVideoCaptureProperty(CV_CAP_PROP_POS_AVI_RATIO) *m_Controls->VideoProgressSlider->maximum() ) ); } -void QmitkOpenCVVideoControls::SetStdMultiWidget( QmitkStdMultiWidget* _MultiWidget ) +void QmitkOpenCVVideoControls::SetRenderWindow( QmitkRenderWindow* _RenderWindow ) { - if(m_MultiWidget == _MultiWidget) + if(m_RenderWindow == _RenderWindow) return; - if(m_MultiWidget != 0) - this->disconnect( m_MultiWidget, SIGNAL(destroyed(QObject*)) - , this, SLOT(QObjectDestroyed(QObject*))); - // In Reset() m_MultiWidget is used, set it to 0 now for avoiding errors - if(_MultiWidget == 0) - m_MultiWidget = 0; + if(_RenderWindow == 0) + m_RenderWindow = 0; this->Reset(); - m_MultiWidget = _MultiWidget; + m_RenderWindow = _RenderWindow; - if(m_MultiWidget == 0) + if(m_RenderWindow == 0) { - MITK_WARN << "m_MultiWidget is 0"; this->setEnabled(false); } else { this->setEnabled(true); - - this->connect( m_MultiWidget, SIGNAL(destroyed(QObject*)) - , this, SLOT(QObjectDestroyed(QObject*))); } } -QmitkStdMultiWidget* QmitkOpenCVVideoControls::GetStdMultiWidget() const +QmitkRenderWindow* QmitkOpenCVVideoControls::GetRenderWindow() const { - return m_MultiWidget; + return m_RenderWindow; } void QmitkOpenCVVideoControls::SetVideoBackground( QmitkVideoBackground* _VideoBackground ) { if(m_VideoBackground == _VideoBackground) return; if(m_VideoBackground != 0) this->disconnect( m_VideoBackground, SIGNAL(destroyed(QObject*)) , this, SLOT(QObjectDestroyed(QObject*))); this->Reset(); m_VideoBackground = _VideoBackground; if(m_VideoBackground == 0) { m_VideoSource = 0; MITK_WARN << "m_MultiWidget is 0"; this->setEnabled(false); } else { this->setEnabled(true); m_VideoSource = dynamic_cast(m_VideoBackground->GetVideoSource()); // preset form entries if(m_VideoSource != 0) { if(!m_VideoSource->GetVideoFileName().empty()) { m_Controls->FileChooser->SetFile( m_VideoSource->GetVideoFileName() ); on_UseGrabbingDeviceButton_clicked( false ); } else if( m_VideoSource->GetGrabbingDeviceNumber() >= 0) m_Controls->GrabbingDeviceNumber->setValue( m_VideoSource->GetGrabbingDeviceNumber() ); m_Controls->UpdateRate->setValue( m_VideoBackground->GetTimerDelay() ); this->connect( m_VideoBackground, SIGNAL(destroyed(QObject*)) , this, SLOT(QObjectDestroyed(QObject*))); } else { MITK_WARN << "m_VideoSource is 0"; this->setEnabled(false); } } } QmitkVideoBackground* QmitkOpenCVVideoControls::GetVideoBackground() const { return m_VideoBackground; } void QmitkOpenCVVideoControls::QObjectDestroyed( QObject * obj /*= 0 */ ) { - if(m_MultiWidget == obj) - this->SetStdMultiWidget(0); - else if(m_VideoBackground == obj) + if(m_VideoBackground == obj) { m_VideoSource = 0; this->SetVideoBackground(0); } } diff --git a/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.h b/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.h index f967f7bffb..6bd9d6ee63 100644 --- a/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.h +++ b/Modules/OpenCVVideoSupport/UI/QmitkOpenCVVideoControls.h @@ -1,100 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkOpenCVVideoControls_h #define QmitkOpenCVVideoControls_h #include #include #include -class QmitkStdMultiWidget; +class QmitkRenderWindow; class QmitkVideoBackground; namespace mitk { class VideoSource; class OpenCVVideoSource; } /// /// \brief Offers widgets to play/pause/stop a video on a certain render window with /// the use of an !initialized! QmitkVideoBackground. The QmitkVideoBackground should /// contain an OpenCVVideoSource is then owned by this widget (and deleted) /// class MITK_OPENCVVIDEOSUPPORTUI_EXPORT QmitkOpenCVVideoControls : public QWidget { Q_OBJECT public: /// /// Construct the widget with the given render window and the given preset values /// - QmitkOpenCVVideoControls(QmitkVideoBackground* _VideoBackground, QmitkStdMultiWidget* _MultiWidget + QmitkOpenCVVideoControls(QmitkVideoBackground* _VideoBackground, QmitkRenderWindow* _RenderWindow , QWidget * parent = 0, Qt::WindowFlags f = 0); /// /// call reset if video playback is enabled here /// virtual ~QmitkOpenCVVideoControls(); /// - /// sets the multiwidget for this video player + /// sets the render window for this video player /// - void SetStdMultiWidget(QmitkStdMultiWidget* _MultiWidget); + void SetRenderWindow(QmitkRenderWindow* _RenderWindow); /// - /// returns the current multiwidget + /// returns the current render window /// - QmitkStdMultiWidget* GetStdMultiWidget() const; + QmitkRenderWindow* GetRenderWindow() const; /// /// sets the qmitkvideobackground for this /// void SetVideoBackground(QmitkVideoBackground* _VideoBackground); /// /// returns the current QmitkVideoBackground /// QmitkVideoBackground* GetVideoBackground() const; signals: /// /// When playback is started this informs when a new frame was grabbed /// void NewOpenCVFrameAvailable(const IplImage*); protected slots: void on_UseGrabbingDeviceButton_clicked(bool checked=false); void on_UseVideoFileButton_clicked(bool checked=false); void on_VideoProgressSlider_sliderPressed(); void on_VideoProgressSlider_sliderReleased(); void on_RepeatVideoButton_clicked( bool checked=false ); void on_PlayButton_clicked(bool checked=false); void on_StopButton_clicked(bool checked=false); void Stop(); void Reset(); void SwitchPlayButton(bool paused); void QObjectDestroyed( QObject * obj = 0 ); void NewFrameAvailable(mitk::VideoSource* videoSource); protected: QmitkVideoBackground* m_VideoBackground; - QmitkStdMultiWidget* m_MultiWidget; + QmitkRenderWindow* m_RenderWindow; mitk::OpenCVVideoSource* m_VideoSource; Ui::QmitkOpenCVVideoControls* m_Controls; bool m_SliderCurrentlyMoved; }; #endif diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 1a97bfea5e..be564e382b 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,58 +1,56 @@ # Plug-ins must be ordered according to their dependencies if (MITK_USE_Qt4) set(MITK_EXT_PLUGINS org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF org.mitk.diffusionimaging:OFF org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.dtiatlasapp:OFF - org.mitk.gui.qt.examples:OFF - org.mitk.gui.qt.examplesopencv:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.meshdecimation:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.registration:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF ) else() set(MITK_EXT_PLUGINS # empty so far ) endif() diff --git a/Plugins/org.mitk.gui.qt.examples/plugin.xml b/Plugins/org.mitk.gui.qt.examples/plugin.xml deleted file mode 100644 index 5e898c6628..0000000000 --- a/Plugins/org.mitk.gui.qt.examples/plugin.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.h b/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.h deleted file mode 100644 index a11a3d2932..0000000000 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.h +++ /dev/null @@ -1,121 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#if !defined(QMITK_ISOSURFACE_H__INCLUDED) -#define QMITK_ISOSURFACE_H__INCLUDED - -#include "QmitkFunctionality.h" -#include "mitkColorSequenceRainbow.h" -#include "mitkDataStorage.h" -#include "ui_QmitkIsoSurfaceControls.h" - -//class QmitkStdMultiWidget; -//class QmitkIsoSurfaceControls; - -/*! - \brief IsoSurface - - \sa QmitkFunctionality - \ingroup org_mitk_gui_qt_isosurface_internal - */ -class QmitkIsoSurface : public QmitkFunctionality -{ - Q_OBJECT - - public: - /*! - \brief default constructor - */ - QmitkIsoSurface(QObject *parent=0, const char *name=0); - - virtual ~QmitkIsoSurface(); - - /*! - \brief method for creating the widget containing the application controls, like sliders, buttons etc. - */ - //virtual QWidget * CreateControlWidget(QWidget *parent); - virtual void CreateQtPartControl(QWidget *parent); - - /*! - \brief method for creating the applications main widget - */ - //virtual QWidget * CreateMainWidget(QWidget * parent); - - /*! - \brief method for creating the connections of main and control widget - */ - virtual void CreateConnections(); - - /*! - \brief method for creating an QAction object, i.e. button & menu entry @param parent the parent QWidget - */ - //virtual QAction * CreateAction(QActionGroup *parent); - - /// - /// Called when a StdMultiWidget is available. - /// - virtual void StdMultiWidgetAvailable(QmitkStdMultiWidget& stdMultiWidget); - /// - /// Called when no StdMultiWidget is available. - /// - virtual void StdMultiWidgetNotAvailable(); - - protected slots: - - virtual void DataStorageChanged(); - - /* - * just an example slot for the example TreeNodeSelector widget - */ - void ImageSelected(const mitk::DataNode* item); - - /*! - \brief method for creating a surface object - */ - void CreateSurface(); - - protected: - /*! - * default main widget containing 4 windows showing 3 - * orthogonal slices of the volume and a 3d render window - */ - //QmitkStdMultiWidget * m_MultiWidget; - - /*! - * controls containing sliders for scrolling through the slices - */ - Ui::QmitkIsoSurfaceControls * m_Controls; - - /*! - * image which is used to create the surface - */ - mitk::Image* m_MitkImage; - - /*! - * read thresholdvalue from GUI and convert it to float - */ - float getThreshold(); - - /*! - * variable to count Surfaces and give it to name - */ - int m_SurfaceCounter; - - mitk::ColorSequenceRainbow m_RainbowColor; -}; - -#endif // !defined(QMITK_ISOSURFACE_H__INCLUDED) - diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.h b/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.h deleted file mode 100644 index 0fa7202074..0000000000 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.h +++ /dev/null @@ -1,103 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED -#define _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED - -#include - -#include - -#include "ui_QmitkSimpleExampleViewControls.h" - -#include - -/*! - * \ingroup org_mitk_gui_qt_simpleexample_internal - * - * \brief QmitkSimpleExampleView - * - * Document your class here. - * - * \sa QmitkFunctionality - */ -class QmitkSimpleExampleView : public QmitkFunctionality -{ - - // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) - Q_OBJECT - - public: - - static const std::string VIEW_ID; - - QmitkSimpleExampleView(); - QmitkSimpleExampleView(const QmitkSimpleExampleView& other); - virtual ~QmitkSimpleExampleView(); - - virtual void CreateQtPartControl(QWidget *parent); - - /// \brief Creation of the connections of main and control widget - virtual void CreateConnections(); - - /// \brief Called when the functionality is activated - virtual void Activated(); - - virtual void Deactivated(); - - virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); - virtual void StdMultiWidgetNotAvailable(); - -protected slots: - - /*! - qt slot for event processing from a qt widget defining the stereo mode of widget 4 - */ - void stereoSelectionChanged(int id); - - /*! - initialize the axial, sagittal, coronal and temporal slider according to the image dimensions - */ - void initNavigators(); - - /*! - generate a movie as *.avi from the active render window - */ - void generateMovie(); - - /*! - return the renderwindow of which the movie shall be created, what depends on the toggled button - */ - QmitkRenderWindow* GetMovieRenderWindow(); - - void OnRenderWindow1Clicked(); - void OnRenderWindow2Clicked(); - void OnRenderWindow3Clicked(); - void OnRenderWindow4Clicked(); - void OnTakeHighResolutionScreenshot(); ///< takes screenshot of the 3D window in 4x resolution of the render window - void OnTakeScreenshot(); ///< takes screenshot of the selected render window - -protected: - - Ui::QmitkSimpleExampleViewControls* m_Controls; - - QmitkStdMultiWidget* m_MultiWidget; - - void TakeScreenshot(vtkRenderer* renderer, unsigned int magnificationFactor, QString fileName); ///< writes a screenshot in JPEG or PNG format to the file fileName - - bool m_NavigatorsInitialized; -}; -#endif // _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui b/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui deleted file mode 100644 index ed5d70daca..0000000000 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui +++ /dev/null @@ -1,237 +0,0 @@ - - - QmitkSimpleExampleViewControls - - - - 0 - 0 - 231 - 610 - - - - - 0 - 0 - - - - false - - - Form1 - - - - 4 - - - 4 - - - - - - 0 - 0 - - - - - - - - - - - - - - - - - - - - Re-initialize Navigators - - - - - - - - - - - - 30 - 32767 - - - - 1 - - - true - - - true - - - - - - - - 30 - 32767 - - - - 4 - - - true - - - false - - - - - - - - 30 - 32767 - - - - 2 - - - true - - - - - - - - 30 - 32767 - - - - 3 - - - true - - - - - - - - - - - Take Screenshot - - - - - - - Screenshot will be 4 times larger than current render window size - - - Take HighDef 3D Screenshot - - - - - - - - 32767 - 23 - - - - Generate Movie - - - - - - - - - - - - 200 - 0 - - - - - stereo off - - - - - red-blue stereo - - - - - D4D stereo - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 230 - - - - - - - - - - QmitkPrimitiveMovieNavigatorWidget - QWidget -
QmitkPrimitiveMovieNavigatorWidget.h
- 1 -
- - QmitkSliderNavigatorWidget - QWidget -
QmitkSliderNavigatorWidget.h
- 1 -
-
- - reInitializeNavigatorsButton - stereoSelect - - - -
diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.h b/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.h deleted file mode 100644 index 670e1b9a22..0000000000 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.h +++ /dev/null @@ -1,107 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKSIMPELEMEASUREMENT_H -#define MITKSIMPELEMEASUREMENT_H - -//#include "QmitkFunctionality.h" - -#include -#include -#include - -#include -#include - -#include "ui_QmitkSimpleMeasurementControls.h" - -class QmitkStdMultiWidget; -//!mm -//class QmitkSimpleMeasurementControls; -//! - -/*! -\brief SimpleMeasurement -Allows to measure distances, angles, etc. - -\sa QmitkFunctionality -\ingroup org_mitk_gui_qt_simplemeasurement_internal -*/ -class QmitkSimpleMeasurement : public QmitkFunctionality -{ - Q_OBJECT - - - public: - - QmitkSimpleMeasurement() {} - - virtual ~QmitkSimpleMeasurement(); - virtual void Activated(); - virtual void Deactivated(); - virtual bool IsExclusiveFunctionality() const; - /// - /// Called when the selection in the workbench changed - /// - virtual void OnSelectionChanged(std::vector nodes); - - virtual void NodeRemoved(const mitk::DataNode* node); - - protected: - // Pseudo Ctor - void CreateQtPartControl(QWidget* parent); - - protected slots: - - void AddDistanceSimpleMeasurement(); - - void AddAngleSimpleMeasurement(); - - void AddPathSimpleMeasurement(); - - void Finished(); - - protected: - - /*! - * controls containing sliders for scrolling through the slices - */ - Ui::QmitkSimpleMeasurementControls * m_Controls; - - /* - * Interactor for performing the simplemeasurements. - */ - mitk::WeakPointer m_PointSetInteractor; - - /* - * Interactor for performing the simplemeasurements. - */ - mitk::WeakPointer m_SelectedPointSetNode; - - /** @brief - * Node representing the PointSets which were created by this application. - */ - std::vector m_CreatedDistances; - std::vector m_CreatedAngles; - std::vector m_CreatedPaths; - - void StartEditingMeasurement(); - void EndEditingMeasurement(); - void UpdateMeasurementList(); - -}; - -#endif // !defined(QMITK_MEASUREMENT_H__INCLUDED) diff --git a/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.cpp deleted file mode 100644 index f77d52b410..0000000000 --- a/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "QmitkVolumetryView.h" - -#include "mitkNodePredicateDataType.h" - -#include "QmitkDataStorageComboBox.h" -#include "QmitkStdMultiWidget.h" - -#include - - - - -#include "itkImage.h" -#include -#include "mitkDataNode.h" -#include "mitkRenderingManager.h" -#include "mitkVolumeCalculator.h" - -#include -#include -#include - -const std::string QmitkVolumetryView::VIEW_ID = "org.mitk.views.volumetry"; - -QmitkVolumetryView::QmitkVolumetryView() -: QmitkFunctionality(), - m_Controls(NULL), - m_MultiWidget(NULL) -{ - //m_DataStorage = this->GetDefaultDataStorage(); -} - -QmitkVolumetryView::~QmitkVolumetryView() -{ -} - -void QmitkVolumetryView::CreateQtPartControl(QWidget *parent) -{ - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkVolumetryViewControls; - m_Controls->setupUi(parent); - this->CreateConnections(); - - // define data type for combobox - m_Controls->m_ImageSelector->SetDataStorage( this->GetDefaultDataStorage() ); - m_Controls->m_ImageSelector->SetPredicate( mitk::NodePredicateDataType::New("Image") ); - } -} - -void QmitkVolumetryView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) -{ - m_MultiWidget = &stdMultiWidget; -} - -void QmitkVolumetryView::StdMultiWidgetNotAvailable() -{ - m_MultiWidget = NULL; -} - -void QmitkVolumetryView::CreateConnections() -{ - if ( m_Controls ) - { - - connect( m_Controls->m_ImageSelector, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), this, SLOT(OnImageSelected(const mitk::DataNode*)) ); - - //connect( (QObject*)(m_Controls->m_Button), SIGNAL(clicked()), this, SLOT(DoSomething()) ); - connect( (QObject*)(m_Controls->m_ThresholdSlider), SIGNAL(valueChanged(int)), this, SLOT(OnThresholdSliderChanged(int)) ); - //connect( (QObject*)(m_Controls->m_ThresholdLineEdit), SIGNAL(valueChanged(int)), this, SLOT(OnThresholdLineEdit(int)) ); - //connect( (QObject*)(m_Controls->m_TextEdit), SIGNAL(valueChanged(int)), this, SLOT(OnTextEditChanged(int)) ); - connect( (QObject*)(m_Controls->m_CalcButton), SIGNAL(clicked()), this, SLOT(OnCalculateVolume()) ); - connect( (QObject*)(m_Controls->m_TimeSeriesButton), SIGNAL(clicked()), this, SLOT(OnTimeSeriesButtonClicked()) ); - connect( (QObject*)(m_Controls->m_SaveCsvButton), SIGNAL(clicked()), this, SLOT(OnSaveCsvButtonClicked()) ); - } -} - -void QmitkVolumetryView::Activated() -{ - QmitkFunctionality::Activated(); -} - -void QmitkVolumetryView::Deactivated() -{ - QmitkFunctionality::Deactivated(); -} - - -void QmitkVolumetryView::OnImageSelected(const mitk::DataNode* item) -{ - // nothing selected (NULL selection) - if( item == NULL || item->GetData() == NULL ) - return; - - m_SelectedDataNode = const_cast(item); - - std::cout << "Selected mitk::Image at address " << m_SelectedDataNode->GetData() << std::endl; - - - if(item == m_OverlayNode.GetPointer()) - return; - - if (m_OverlayNode) - { - this->GetDefaultDataStorage()->Remove(m_OverlayNode); - // remove it from the tree - //mitk::DataTreeIteratorClone overlayIt = mitk::DataTreeHelper::FindIteratorToNode(m_DataTreeIteratorClone->GetTree(),m_OverlayNode); - //if (overlayIt.IsNotNull()) { overlayIt->Remove(); } - m_OverlayNode = NULL; - } - - this->CreateOverlayChild(); - - //std::string name; - //if (node->GetName(name)) - //{ - // // m_TreeNodeNameLabel->setText( name.c_str() ); - //} - - m_Controls->m_CalcButton->setEnabled(false); - m_Controls->m_TimeSeriesButton->setEnabled(false); - m_Controls->m_SaveCsvButton->setEnabled(false); - m_Controls->m_TextEdit->clear(); - - if (m_SelectedDataNode.IsNotNull() ) - { - mitk::Image* image = dynamic_cast(m_SelectedDataNode->GetData()); - if (image == NULL) - { - MITK_INFO << "QmitkVolumetryView::OnImageSelected no image selected."; - return; - } - image->Update(); - if (image && image->IsInitialized()) - { - if (image->GetDimension() == 4) - { - m_Controls->m_TimeSeriesButton->setEnabled(true); - } - else - { - m_Controls->m_CalcButton->setEnabled(true); - } - int minVal = (int)image->GetScalarValue2ndMin(); - int maxVal = (int)image->GetScalarValueMaxNoRecompute(); - if (minVal == maxVal) - --minVal; - m_Controls->m_ThresholdSlider->setMinimum(minVal); - m_Controls->m_ThresholdSlider->setMaximum(maxVal); - m_Controls->m_ThresholdSlider->setEnabled(true); - this->UpdateSlider(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - } -} - -void QmitkVolumetryView::OnCalculateVolume() -{ - if (m_SelectedDataNode.IsNotNull() ) - { - mitk::Image* image = dynamic_cast(m_SelectedDataNode->GetData()); - if (image) - { - std::cout << "Dimension:" << image->GetDimension() << std::endl; - std::cout << "Dimension[3]:" << image->GetDimension(3) << std::endl; - mitk::VolumeCalculator::Pointer volCalc = mitk::VolumeCalculator::New(); - volCalc->SetImage(image); - volCalc->SetThreshold(m_Controls->m_ThresholdSlider->value()); - volCalc->ComputeVolume(); - std::stringstream vs; - vs << volCalc->GetVolume() << " ml"; - m_Controls->m_Result->setText(vs.str().c_str() ); - } - } -} - -void QmitkVolumetryView::OnTimeSeriesButtonClicked() -{ - if (m_SelectedDataNode.IsNotNull() ) - { - mitk::Image* image = dynamic_cast(m_SelectedDataNode->GetData()); - if (image) - { - mitk::VolumeCalculator::Pointer volCalc = mitk::VolumeCalculator::New(); - volCalc->SetImage(image); - volCalc->SetThreshold(m_Controls->m_ThresholdSlider->value()); - volCalc->ComputeVolume(); - std::vector volumes = volCalc->GetVolumes(); - std::stringstream vs; - int timeStep = 0; - for (std::vector::iterator it = volumes.begin(); it != volumes.end(); it++) - { - vs << timeStep++ << "\t" << *it << std::endl; - } - m_Controls->m_TextEdit->setText(vs.str().c_str()); - m_Controls->m_TextEdit->setTabStopWidth(20); - m_Controls->m_SaveCsvButton->setEnabled(true); - } - } -} - -const mitk::DataNode* QmitkVolumetryView::GetImageNode() -{ - return m_SelectedDataNode; -} - -void QmitkVolumetryView::UpdateSlider() -{ - if (m_SelectedDataNode.IsNotNull() && dynamic_cast(m_SelectedDataNode->GetData())) - { - int intSliderValue = (int)m_Controls->m_ThresholdSlider->value(); - QString stringSliderValue; - stringSliderValue.setNum(intSliderValue); - m_Controls->m_ThresholdLineEdit->setText(stringSliderValue); - } -} - - -void QmitkVolumetryView::UpdateSliderLabel() -{ - int sliderValue = atoi(m_Controls->m_ThresholdLineEdit->text().toLatin1()); - m_Controls->m_ThresholdSlider->setValue(sliderValue); - this->UpdateSlider(); - -} - -void QmitkVolumetryView::OnThresholdSliderChanged( int value) -{ - if (m_OverlayNode) - { - m_OverlayNode->SetLevelWindow(mitk::LevelWindow(value,1)); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - this->UpdateSlider(); - } -} - -void QmitkVolumetryView::CreateOverlayChild() -{ - if (m_SelectedDataNode.IsNotNull()) - { - m_OverlayNode = mitk::DataNode::New(); - mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New("volume threshold overlay image" ); - m_OverlayNode->SetProperty( "reslice interpolation", m_SelectedDataNode->GetProperty("reslice interpolation") ); - m_OverlayNode->SetProperty( "name", nameProp ); - m_OverlayNode->SetData(m_SelectedDataNode->GetData()); - m_OverlayNode->SetColor(0.0,1.0,0.0); - m_OverlayNode->SetOpacity(.25); - int layer = 0; - m_SelectedDataNode->GetIntProperty("layer", layer); - m_OverlayNode->SetIntProperty("layer", layer+1); - m_OverlayNode->SetLevelWindow(mitk::LevelWindow(m_Controls->m_ThresholdSlider->value(),1)); - - - this->GetDefaultDataStorage()->Add(m_OverlayNode); - - //// hack!!! - //mitk::DataTreeIteratorClone iteratorClone = m_DataTreeIteratorClone; - //while ( !iteratorClone->IsAtEnd() ) - //{ - // mitk::DataNode::Pointer node = iteratorClone->Get(); - // if ( node == m_SelectedDataNode ) - // { - // iteratorClone->Add(m_OverlayNode); - // break; - // } - // ++iteratorClone; - //} - } -} - - -mitk::DataNode* QmitkVolumetryView::GetOverlayNode() -{ - return m_OverlayNode; -} - - - - -mitk::Image* QmitkVolumetryView::GetImage() -{ - return dynamic_cast(m_SelectedDataNode->GetData()); -} -void QmitkVolumetryView::OnSaveCsvButtonClicked() -{ - static QString lastSavePath = QDir::homePath(); - - - QString s = QFileDialog::getSaveFileName( this->m_Parent, "Save as..", lastSavePath, "CSV Files (*.csv)"); - /*"Save file dialog" - "Choose a filename to save under" );*/ - - - if (! s.isEmpty()) - { - lastSavePath = s; - QFile saveFile(s); - - if ( saveFile.open(QIODevice::WriteOnly)) - { - QTextStream stream( &saveFile ); - stream << m_Controls->m_TextEdit->toPlainText().replace('\t',';'); - saveFile.close(); - } - else - { - // QMessageBox::critical(NULL,"Save Error!",QString("Saving of CSV failed! Couldn't open output file \"") + saveFile + QString("\""),QMessageBox:Ok,QMessageBox::NoButton); - //QMessageBox::critical(NULL,"Save Error!","Saving of CSV failed! Couldn't open output file \"" + saveFile.name() +"\"",QMessageBox::Ok,QMessageBox::NoButton); - } - } -} - - - - -