diff --git a/Applications/CoreApp/CMakeLists.txt b/Applications/CoreApp/CMakeLists.txt index adf226b3e0..2706e0dab3 100644 --- a/Applications/CoreApp/CMakeLists.txt +++ b/Applications/CoreApp/CMakeLists.txt @@ -1,36 +1,37 @@ project(CoreApp) set(_app_options) if(MITK_SHOW_CONSOLE_WINDOW) list(APPEND _app_options SHOW_CONSOLE) endif() # Create a cache entry for the provisioning file which is used to export # the file name in the MITKConfig.cmake file. This will keep external projects # which rely on this file happy. set(MITK_COREAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.provisioning" CACHE INTERNAL "CoreApp provisioning file" FORCE) set(_plugins org.blueberry.compat - org.mitk.gui.qt.application + org.mitk.gui.qt.coreapplication + org.mitk.gui.qt.stdmultiwidgeteditor ) # Plug-ins listed below will not be # - added as a build-time dependency to the executable # - listed in the provisioning file for the executable # - installed if they are external plug-ins set(_exclude_plugins ) FunctionCreateBlueBerryApplication( NAME CoreApp DESCRIPTION "MITK - CoreApp Application" PLUGINS ${_plugins} ${_app_options} ) # subproject support ADD_DEPENDENCIES(MITK-CoreUI CoreApp) IF(MITK_ENABLE_GUI_TESTING) ADD_DEPENDENCIES(MITK-CoreUI solstice) ENDIF() diff --git a/Applications/CoreApp/CoreApp.cpp b/Applications/CoreApp/CoreApp.cpp index 528b389506..16f4fdf8a5 100644 --- a/Applications/CoreApp/CoreApp.cpp +++ b/Applications/CoreApp/CoreApp.cpp @@ -1,94 +1,94 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/ for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include #include class QSafeApplication : public QApplication { public: QSafeApplication(int& argc, char** argv) : QApplication(argc, argv) {} /** * Reimplement notify to catch unhandled exceptions and open an error message. * * @param receiver * @param event * @return */ bool notify(QObject* receiver, QEvent* event) { QString msg; try { return QApplication::notify(receiver, event); } catch (Poco::Exception& e) { msg = QString::fromStdString(e.displayText()); } catch (std::exception& e) { msg = e.what(); } catch (...) { msg = "Unknown exception"; } QString text( "An error occurred. You should save all data and quit the program to prevent possible data loss.\nSee the error log for details.\n\n"); text += msg; QMessageBox::critical(0, "Error", text); return false; } }; int main(int argc, char** argv) { QSafeApplication safeApp(argc, argv); safeApp.setApplicationName("CoreApp"); safeApp.setOrganizationName("DKFZ"); // These paths replace the .ini file and are tailored for installation // packages created with CPack. If a .ini file is presented, it will // overwrite the settings in MapConfiguration Poco::Path basePath(argv[0]); basePath.setFileName(""); Poco::Path provFile(basePath); provFile.setFileName("CoreApp.provisioning"); Poco::Util::MapConfiguration* coreConfig(new Poco::Util::MapConfiguration()); coreConfig->setString(berry::Platform::ARG_PROVISIONING, provFile.toString()); - coreConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.application"); + coreConfig->setString(berry::Platform::ARG_APPLICATION, "org.mitk.qt.coreapplication"); // Preload the org.mitk.gui.qt.common plug-in (and hence also Qmitk) to speed // up a clean-cache start. This also works around bugs in older gcc and glibc implementations, // which have difficulties with multiple dynamic opening and closing of shared libraries with // many global static initializers. It also helps if dependent libraries have weird static // initialization methods and/or missing de-initialization code. coreConfig->setString(berry::Platform::ARG_PRELOAD_LIBRARY, "liborg_mitk_gui_qt_common"); return berry::Starter::Run(argc, argv, coreConfig); } diff --git a/Applications/CoreApp/target_libraries.cmake b/Applications/CoreApp/target_libraries.cmake index 1339ede64f..d492e12335 100644 --- a/Applications/CoreApp/target_libraries.cmake +++ b/Applications/CoreApp/target_libraries.cmake @@ -1,10 +1,11 @@ # A list of plug-in targets which should be automatically enabled # (or be available in external projects) for this application. set(target_libraries org_blueberry_compat org_blueberry_ui_qt org_blueberry_ui_qt_help - org_mitk_gui_qt_application + org_mitk_gui_qt_coreapplication + org_mitk_gui_qt_stdmultiwidgeteditor ) diff --git a/Applications/ExtApp/CMakeLists.txt b/Applications/ExtApp/CMakeLists.txt index 634c01bcf6..9d31b41f87 100644 --- a/Applications/ExtApp/CMakeLists.txt +++ b/Applications/ExtApp/CMakeLists.txt @@ -1,40 +1,40 @@ project(ExtApp) set(_app_options) if(MITK_SHOW_CONSOLE_WINDOW) list(APPEND _app_options SHOW_CONSOLE) endif() MITK_USE_MODULE(qtsingleapplication) include_directories(${ALL_INCLUDE_DIRECTORIES}) # Create a cache entry for the provisioning file which is used to export # the file name in the MITKConfig.cmake file. This will keep external projects # which rely on this file happy. set(MITK_EXTAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ExtApp.provisioning" CACHE INTERNAL "ExtApp provisioning file" FORCE) # Plug-ins listed below will not be # - added as a build-time dependency to the executable # - listed in the provisioning file for the executable # - installed if they are external plug-ins set(_exclude_plugins org.blueberry.test org.blueberry.uitest - org.mitk.gui.qt.application + org.mitk.gui.qt.coreapplication org.mitk.gui.qt.diffusionimagingapp ) FunctionCreateBlueBerryApplication( NAME ExtApp DESCRIPTION "MITK - ExtApp Application" EXCLUDE_PLUGINS ${_exclude_plugins} LINK_LIBRARIES ${ALL_LIBRARIES} ${_app_options} ) # Add a build time dependency to legacy BlueBerry bundles. if(MITK_MODULES_ENABLED_PLUGINS) add_dependencies(ExtApp ${MITK_MODULES_ENABLED_PLUGINS}) endif() diff --git a/Applications/PluginGenerator/CMakeLists.txt b/Applications/PluginGenerator/CMakeLists.txt index 2d3c8c92b9..009c9c9c02 100644 --- a/Applications/PluginGenerator/CMakeLists.txt +++ b/Applications/PluginGenerator/CMakeLists.txt @@ -1,77 +1,77 @@ cmake_minimum_required(VERSION 2.8.4) project(MITKPluginGenerator) set(VERSION_MAJOR 1) -set(VERSION_MINOR 3) +set(VERSION_MINOR 4) set(VERSION_PATCH 0) set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set(standalone_build 1) else() set(standalone_build 0) endif() #----------------------------------------------------------------------------- # Prerequisites #----------------------------------------------------------------------------- set(QT_DONT_USE_QTGUI 1) set(QT_USE_QTNETWORK 1) find_package(Qt 4.6.2 REQUIRED) include(${QT_USE_FILE}) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PluginGeneratorConfig.h.in" "${CMAKE_CURRENT_BINARY_DIR}/PluginGeneratorConfig.h" @ONLY) include_directories("${CMAKE_CURRENT_BINARY_DIR}") #----------------------------------------------------------------------------- # Executable #----------------------------------------------------------------------------- set(src_files PluginGenerator.cpp ctkCommandLineParser.cpp ) qt4_wrap_cpp(src_files ctkCommandLineParser.h) qt4_add_resources(src_files plugin_template.qrc project_template.qrc) set(exec_target ${PROJECT_NAME}) add_executable(${exec_target} ${src_files}) target_link_libraries(${exec_target} ${QT_LIBRARIES}) if(NOT standalone_build) # subproject support add_dependencies(MITK-CoreUI ${exec_target}) endif() #----------------------------------------------------------------------------- # Win32 Convenience #----------------------------------------------------------------------------- if(WIN32 AND NOT standalone_build) file(TO_NATIVE_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}" native_runtime_dir) add_custom_target(NewPlugin start "MITK PluginGenerator" /D "${native_runtime_dir}" cmd /K ${exec_target}.exe -h DEPENDS ${exec_target}) endif() #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(NOT standalone_build) # Test the plugin generator include(mitkTestPluginGenerator) endif() #----------------------------------------------------------------------------- # Packaging support #----------------------------------------------------------------------------- if(standalone_build) include(SetupPackaging.cmake) endif() diff --git a/Applications/PluginGenerator/Changelog.txt b/Applications/PluginGenerator/Changelog.txt index 85bc88326e..e29ddb89ac 100644 --- a/Applications/PluginGenerator/Changelog.txt +++ b/Applications/PluginGenerator/Changelog.txt @@ -1,45 +1,54 @@ This is the change log for the MITK Plugin Generator +Changes since version 1.3.0 +====================================================================== + +Changes in the generated files +---------------------------------------------------------------------- + + - The generated View does not have a hard dependency on the + QmitkStdMultiWidgetEditor editor anymore. + Changes since version 1.2.0 ====================================================================== Changes in the generated files ---------------------------------------------------------------------- - Added gcc linker flag --as-needed to get same behavior as on Windows - Improved MITK superbuild configuration options Changes since version 1.1.1 ====================================================================== Changes in the MITKPluginGenerator executable ---------------------------------------------------------------------- - Added a visual clue in the help text about required arguments. - Added support for checking for new versions online. Changes in the generated files ---------------------------------------------------------------------- - The plug-in activator class and file name are now derived from the plug-in symbolic name. - Adapted to changes in CTK CMake macros. - Improved generated superbuild script to correctly pass -j options. - Using new BlueBerry FunctionCreateBlueBerryApplication() macro to create the demo application. Changes since version 1.0.0 ====================================================================== Changes in the MITKPluginGenerator executable ---------------------------------------------------------------------- - Added printing the version number to the console. - Added hint how to get more help if something went wrong. Changes in the generated files ---------------------------------------------------------------------- - Fixed user manual for the generated plugin. - Added comments in the generated project's CMakeLists.txt file about how to set-up the MITK module system. diff --git a/Applications/PluginGenerator/PluginTemplate/documentation/doxygen/modules.dox b/Applications/PluginGenerator/PluginTemplate/documentation/doxygen/modules.dox index d29e765f4d..4a1244f9a8 100644 --- a/Applications/PluginGenerator/PluginTemplate/documentation/doxygen/modules.dox +++ b/Applications/PluginGenerator/PluginTemplate/documentation/doxygen/modules.dox @@ -1,16 +1,16 @@ /** - \defgroup $(plugin-target) $(plugin-symbolic-name) Plugin + \defgroup $(plugin-target) $(plugin-symbolic-name) \ingroup MITKPlugins \brief Describe your plugin here. */ /** \defgroup $(plugin-target)_internal Internal \ingroup $(plugin-target) \brief This subcategory includes the internal classes of the $(plugin-symbolic-name) plugin. Other plugins must not rely on these classes. They contain implementation details and their interface may change at any time. We mean it. */ diff --git a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp index 4354ab0dc0..a6f2db8927 100644 --- a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp +++ b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.cpp @@ -1,94 +1,86 @@ $(license) // Blueberry #include #include // Qmitk #include "$(view-file-name).h" -#include "QmitkStdMultiWidget.h" // Qt #include const std::string $(view-class-name)::VIEW_ID = "$(view-id)"; -$(view-class-name)::$(view-class-name)() -: QmitkFunctionality() -{ -} - -$(view-class-name)::~$(view-class-name)() +void $(view-class-name)::SetFocus() { + m_Controls.buttonPerformImageProcessing->setFocus(); } void $(view-class-name)::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); connect( m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoImageProcessing()) ); } -void $(view-class-name)::OnSelectionChanged( std::vector nodes ) +void $(view-class-name)::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, + const QList& nodes ) { // iterate all selected objects, adjust warning visibility - for( std::vector::iterator it = nodes.begin(); - it != nodes.end(); - ++it ) + foreach( mitk::DataNode::Pointer node, nodes ) { - mitk::DataNode::Pointer node = *it; - if( node.IsNotNull() && dynamic_cast(node->GetData()) ) { m_Controls.labelWarning->setVisible( false ); m_Controls.buttonPerformImageProcessing->setEnabled( true ); return; } } m_Controls.labelWarning->setVisible( true ); m_Controls.buttonPerformImageProcessing->setEnabled( false ); } void $(view-class-name)::DoImageProcessing() { - std::vector nodes = this->GetDataManagerSelection(); + QList nodes = this->GetDataManagerSelection(); if (nodes.empty()) return; mitk::DataNode* node = nodes.front(); if (!node) { // Nothing selected. Inform the user and return QMessageBox::information( NULL, "Template", "Please load and select an image before starting image processing."); return; } // here we have a valid mitk::DataNode // a node itself is not very useful, we need its data item (the image) mitk::BaseData* data = node->GetData(); if (data) { // test if this data item is an image or not (could also be a surface or something totally different) mitk::Image* image = dynamic_cast( data ); if (image) { std::stringstream message; std::string name; message << "Performing image processing for image "; if (node->GetName(name)) { // a property called "name" was found for this DataNode message << "'" << name << "'"; } message << "."; MITK_INFO << message.str(); // actually do something here... } } } diff --git a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h index 570f90d6d7..f70cd5870f 100644 --- a/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h +++ b/Applications/PluginGenerator/PluginTemplate/src/internal/QmitkTemplateView.h @@ -1,51 +1,51 @@ $(license) #ifndef $(view-file-name)_h #define $(view-file-name)_h #include -#include +#include #include "ui_$(view-file-name)Controls.h" /*! \brief $(view-class-name) \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ -class $(view-class-name) : public QmitkFunctionality +class $(view-class-name) : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; - $(view-class-name)(); - virtual ~$(view-class-name)(); - virtual void CreateQtPartControl(QWidget *parent); protected slots: /// \brief Called when the user clicks the GUI button void DoImageProcessing(); protected: + + virtual void SetFocus(); /// \brief called by QmitkFunctionality when DataManager's selection has changed - virtual void OnSelectionChanged( std::vector nodes ); + virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, + const QList& nodes ); Ui::$(view-file-name)Controls m_Controls; }; #endif // $(view-file-name)_h diff --git a/Applications/PluginGenerator/ProjectTemplate/CMakeLists.txt b/Applications/PluginGenerator/ProjectTemplate/CMakeLists.txt index c54a6b4a9e..409be62fba 100644 --- a/Applications/PluginGenerator/ProjectTemplate/CMakeLists.txt +++ b/Applications/PluginGenerator/ProjectTemplate/CMakeLists.txt @@ -1,381 +1,388 @@ cmake_minimum_required(VERSION 2.8.4) # Change project and application name to your own set(MY_PROJECT_NAME $(project-name)) set(MY_APP_NAME $(project-app-name)) #----------------------------------------------------------------------------- # 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(${MY_PROJECT_NAME}_USE_SUPERBUILD "Build ${MY_PROJECT_NAME} and the projects it depends on via SuperBuild.cmake." ON) if(${MY_PROJECT_NAME}_USE_SUPERBUILD) project(${MY_PROJECT_NAME}-superbuild) set(${MY_PROJECT_NAME}_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(${MY_PROJECT_NAME}_BINARY_DIR ${PROJECT_BINARY_DIR}) else() project(${MY_PROJECT_NAME}) 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 ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ set(CMAKE_MODULE_PATH ${${MY_PROJECT_NAME}_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(MacroEmptyExternalProject) #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- foreach(type LIBRARY RUNTIME ARCHIVE) set(output_dir ${${MY_PROJECT_NAME}_BINARY_DIR}/bin) 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 Options (also shown during superbuild) #----------------------------------------------------------------------------- option(BUILD_SHARED_LIBS "Build ${MY_PROJECT_NAME} with shared libraries" ON) option(WITH_COVERAGE "Enable/Disable coverage" OFF) option(BUILD_TESTING "Test the project" ON) option(${MY_PROJECT_NAME}_BUILD_ALL_PLUGINS "Build all ${MY_PROJECT_NAME} plugins" OFF) mark_as_advanced(${MY_PROJECT_NAME}_INSTALL_RPATH_RELATIVE ${MY_PROJECT_NAME}_BUILD_ALL_PLUGINS ) #----------------------------------------------------------------------------- # Additional CXX/C Flags #----------------------------------------------------------------------------- set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags") mark_as_advanced(ADDITIONAL_C_FLAGS) set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags") mark_as_advanced(ADDITIONAL_CXX_FLAGS) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(${MY_PROJECT_NAME}_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # Prerequesites #----------------------------------------------------------------------------- find_package(MITK REQUIRED) + +if(COMMAND mitkFunctionCheckMitkCompatibility) + mitkFunctionCheckMitkCompatibility(VERSIONS MITK_VERSION_PLUGIN_SYSTEM 1 REQUIRED) +else() + message(SEND_ERROR "Your MITK version is too old. Please use Git hash b86bf28 or newer") +endif() + link_directories(${MITK_LINK_DIRECTORIES}) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- set(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) include(mitkFunctionCheckCompilerFlags) include(mitkFunctionGetGccVersion) include(mitkFunctionGetVersion) #----------------------------------------------------------------------------- # Set project specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- set(${PROJECT_NAME}_VERSION_MAJOR "0") set(${PROJECT_NAME}_VERSION_MINOR "1") set(${PROJECT_NAME}_VERSION_PATCH "1") set(${PROJECT_NAME}_VERSION_STRING "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}") # Ask the user if a console window should be shown with the applications option(${PROJECT_NAME}_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting GUI Applications" ON) mark_as_advanced(${PROJECT_NAME}_SHOW_CONSOLE_WINDOW) if(NOT UNIX AND NOT MINGW) set(MITK_WIN32_FORCE_STATIC "STATIC") endif() set(${PROJECT_NAME}_MODULES_PACKAGE_DEPENDS_DIR "${PROJECT_SOURCE_DIR}/CMake/PackageDepends") list(APPEND MODULES_PACKAGE_DEPENDS_DIRS ${${PROJECT_NAME}_MODULES_PACKAGE_DEPENDS_DIR}) #----------------------------------------------------------------------------- # Get project version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${PROJECT_SOURCE_DIR} ${PROJECT_NAME}) #----------------------------------------------------------------------------- # Installation preparation # # These should be set before any MITK install macros are used #----------------------------------------------------------------------------- # on Mac OSX all CTK plugins get copied into every # application bundle (.app directory) specified here set(MACOSX_BUNDLE_NAMES) if(APPLE) list(APPEND MACOSX_BUNDLE_NAMES ${MY_APP_NAME}) endif(APPLE) #----------------------------------------------------------------------------- # 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) # The MITK module build system does not yet support default hidden visibility set(VISIBILITY_CXX_FLAGS ) # "-fvisibility=hidden -fvisibility-inlines-hidden") endif() #----------------------------------------------------------------------------- # Set coverage Flags #----------------------------------------------------------------------------- if(WITH_COVERAGE) if(CMAKE_COMPILER_IS_GNUCXX) set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG") set(COVERAGE_CXX_FLAGS ${coverage_flags}) set(COVERAGE_C_FLAGS ${coverage_flags}) endif() endif() #----------------------------------------------------------------------------- # Project C/CXX Flags #----------------------------------------------------------------------------- set(${PROJECT_NAME}_C_FLAGS "${COVERAGE_C_FLAGS} ${ADDITIONAL_C_FLAGS}") set(${PROJECT_NAME}_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}") if(CMAKE_COMPILER_IS_GNUCXX) set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2") mitkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags) # Enable link dependency optimization to only link libraries which satisfy undefined # symbol references. This aligns the link behavior with the one from the Windows linker. mitkFunctionCheckCompilerFlags("-Wl,--as-needed" cflags) mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag. # Doing so should allow to build package made for distribution using older linux distro. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0")) mitkFunctionCheckCompilerFlags("-fstack-protector-all" cflags) endif() if(MINGW) # suppress warnings about auto imported symbols set(${PROJECT_NAME}_CXX_FLAGS "-Wl,--enable-auto-import ${${PROJECT_NAME}_CXX_FLAGS}") # we need to define a Windows version set(${PROJECT_NAME}_CXX_FLAGS "-D_WIN32_WINNT=0x0500 ${${PROJECT_NAME}_CXX_FLAGS}") endif() set(${PROJECT_NAME}_C_FLAGS "${cflags} ${${PROJECT_NAME}_C_FLAGS}") set(${PROJECT_NAME}_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wstrict-null-sentinel -Wsign-promo ${${PROJECT_NAME}_CXX_FLAGS}") # The following line produces a lot of warnings in MITK header files... #set(${PROJECT_NAME}_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${${PROJECT_NAME}_CXX_FLAGS}") endif() #----------------------------------------------------------------------------- # Set C/CXX Flags #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${PROJECT_NAME}_CXX_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${PROJECT_NAME}_C_FLAGS}") #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) # Setup file for setting custom ctest vars configure_file( CMake/CTestCustom.cmake.in ${CMAKE_CURRENT_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; } ") endif() #----------------------------------------------------------------------------- # ${MY_PROJECT_NAME}_SUPERBUILD_BINARY_DIR #----------------------------------------------------------------------------- # If ${MY_PROJECT_NAME}_SUPERBUILD_BINARY_DIR isn't defined, it means this project is # *NOT* build using Superbuild. In that specific case, ${MY_PROJECT_NAME}_SUPERBUILD_BINARY_DIR # should default to PROJECT_BINARY_DIR if(NOT DEFINED ${PROJECT_NAME}_SUPERBUILD_BINARY_DIR) set(${PROJECT_NAME}_SUPERBUILD_BINARY_DIR ${PROJECT_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # Qt support #----------------------------------------------------------------------------- if(MITK_USE_QT) set(QT_QMAKE_EXECUTABLE ${MITK_QMAKE_EXECUTABLE}) add_definitions(-DQWT_DLL) endif() #----------------------------------------------------------------------------- # MITK modules #----------------------------------------------------------------------------- # This project's directory holding module config files #set(${PROJECT_NAME}_MODULES_CONF_DIR "${PROJECT_BINARY_DIR}/${MODULES_CONF_DIRNAME}") # Append this projects's module config directory to the global list # (This is used to get include directories for the Exports.h files right) #list(APPEND MODULES_CONF_DIRS ${${PROJECT_NAME}_MODULES_CONF_DIR}) # Clean the modulesConf directory. This ensures that modules are sorted # according to their dependencies in the Modules/CMakeLists.txt file #file(GLOB _modules_conf_files ${${PROJECT_NAME}_MODULES_CONF_DIR}/*.cmake) #if(_modules_conf_files) # file(REMOVE ${_modules_conf_files}) #endif() #add_subdirectory(Modules) #----------------------------------------------------------------------------- # CTK plugins #----------------------------------------------------------------------------- # The CMake code in this section *must* be in the top-level CMakeLists.txt file macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin "^$(project-plugin-base)_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin OUTPUT_VARIABLE ${varname}) endmacro() include(${CMAKE_CURRENT_SOURCE_DIR}/Plugins/Plugins.cmake) ctkMacroSetupPlugins(${PROJECT_PLUGINS} BUILD_OPTION_PREFIX ${MY_PROJECT_NAME}_ BUILD_ALL ${${MY_PROJECT_NAME}_BUILD_ALL_PLUGINS}) #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- add_subdirectory(Apps/$(project-app-name)) #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables include(mitkSetupCPack) # Customize CPack variables for this project include(CPackSetup) list(APPEND CPACK_CREATE_DESKTOP_LINKS "${MY_APP_NAME}") configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}CPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}CPackOptions.cmake") # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- # 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("${PROJECT_SOURCE_DIR}/CMake/StartVS.bat.in" ${PROJECT_BINARY_DIR}/StartVS_${VS_BUILD_TYPE}.bat ${VS_BUILD_TYPE}) endforeach() endif(WIN32) diff --git a/Applications/Tests/QtFreeRender/QtFreeRender.cpp b/Applications/Tests/QtFreeRender/QtFreeRender.cpp index 97c5b5c432..c57e196637 100644 --- a/Applications/Tests/QtFreeRender/QtFreeRender.cpp +++ b/Applications/Tests/QtFreeRender/QtFreeRender.cpp @@ -1,390 +1,396 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 21985 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkRenderWindow.h" #include #include #include #include #include #include #include #include "mitkProperties.h" #include "mitkGeometry2DDataMapper2D.h" #include "mitkGlobalInteraction.h" #include "mitkDisplayInteractor.h" #include "mitkPositionEvent.h" #include "mitkStateEvent.h" #include "mitkLine.h" #include "mitkInteractionConst.h" #include "mitkVtkLayerController.h" #include "mitkPositionTracker.h" #include "mitkDisplayVectorInteractor.h" #include "mitkSlicesRotator.h" #include "mitkSlicesSwiveller.h" #include "mitkRenderWindowFrame.h" #include "mitkGradientBackground.h" #include "mitkCoordinateSupplier.h" #include "mitkDataStorage.h" #include "vtkTextProperty.h" #include "vtkCornerAnnotation.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkAnnotatedCubeActor.h" #include "vtkOrientationMarkerWidget.h" #include "vtkProperty.h" //##Documentation //## @brief Example of a NON QT DEPENDENT MITK RENDERING APPLICATION. mitk::DisplayVectorInteractor::Pointer m_MoveAndZoomInteractor; mitk::CoordinateSupplier::Pointer m_LastLeftClickPositionSupplier; mitk::GradientBackground::Pointer m_GradientBackground4; mitk::RenderWindowFrame::Pointer m_RectangleRendering1; mitk::RenderWindowFrame::Pointer m_RectangleRendering2; mitk::RenderWindowFrame::Pointer m_RectangleRendering3; mitk::RenderWindowFrame::Pointer m_RectangleRendering4; mitk::SliceNavigationController::Pointer m_TimeNavigationController; mitk::DataStorage::Pointer m_DataStorage; mitk::DataNode::Pointer m_PlaneNode1; mitk::DataNode::Pointer m_PlaneNode2; mitk::DataNode::Pointer m_PlaneNode3; mitk::DataNode::Pointer m_Node; mitk::RenderWindow::Pointer mitkWidget1; mitk::RenderWindow::Pointer mitkWidget2; mitk::RenderWindow::Pointer mitkWidget3; mitk::RenderWindow::Pointer mitkWidget4; void InitializeWindows() { // Set default view directions for SNCs mitkWidget1->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Transversal ); mitkWidget2->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Sagittal ); mitkWidget3->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Frontal ); mitkWidget4->GetSliceNavigationController()->SetDefaultViewDirection( mitk::SliceNavigationController::Original ); //initialize m_TimeNavigationController: send time via sliceNavigationControllers m_TimeNavigationController = mitk::SliceNavigationController::New("dummy"); m_TimeNavigationController->ConnectGeometryTimeEvent( mitkWidget1->GetSliceNavigationController() , false); m_TimeNavigationController->ConnectGeometryTimeEvent( mitkWidget2->GetSliceNavigationController() , false); m_TimeNavigationController->ConnectGeometryTimeEvent( mitkWidget3->GetSliceNavigationController() , false); m_TimeNavigationController->ConnectGeometryTimeEvent( mitkWidget4->GetSliceNavigationController() , false); mitkWidget1->GetSliceNavigationController() ->ConnectGeometrySendEvent(mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow())); // Set TimeNavigationController to RenderingManager // (which uses it internally for views initialization!) mitk::RenderingManager::GetInstance()->SetTimeNavigationController( m_TimeNavigationController ); //reverse connection between sliceNavigationControllers and m_TimeNavigationController mitkWidget1->GetSliceNavigationController() ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); mitkWidget2->GetSliceNavigationController() ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); mitkWidget3->GetSliceNavigationController() ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); mitkWidget4->GetSliceNavigationController() ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); // Let NavigationControllers listen to GlobalInteraction mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); gi->AddListener( m_TimeNavigationController ); m_LastLeftClickPositionSupplier = mitk::CoordinateSupplier::New("navigation", NULL); mitk::GlobalInteraction::GetInstance()->AddListener( m_LastLeftClickPositionSupplier ); m_GradientBackground4 = mitk::GradientBackground::New(); m_GradientBackground4->SetRenderWindow( mitkWidget4->GetVtkRenderWindow() ); m_GradientBackground4->SetGradientColors(0.1,0.1,0.1,0.5,0.5,0.5); m_GradientBackground4->Enable(); m_RectangleRendering1 = mitk::RenderWindowFrame::New(); m_RectangleRendering1->SetRenderWindow( mitkWidget1->GetVtkRenderWindow() ); m_RectangleRendering1->Enable(1.0,0.0,0.0); m_RectangleRendering2 = mitk::RenderWindowFrame::New(); m_RectangleRendering2->SetRenderWindow( mitkWidget2->GetVtkRenderWindow() ); m_RectangleRendering2->Enable(0.0,1.0,0.0); m_RectangleRendering3 = mitk::RenderWindowFrame::New(); m_RectangleRendering3->SetRenderWindow( mitkWidget3->GetVtkRenderWindow() ); m_RectangleRendering3->Enable(0.0,0.0,1.0); m_RectangleRendering4 = mitk::RenderWindowFrame::New(); m_RectangleRendering4->SetRenderWindow( mitkWidget4->GetVtkRenderWindow() ); m_RectangleRendering4->Enable(1.0,1.0,0.0); } void AddDisplayPlaneSubTree() { // add the displayed planes of the multiwidget to a node to which the subtree // @a planesSubTree points ... float white[3] = {1.0f,1.0f,1.0f}; mitk::Geometry2DDataMapper2D::Pointer mapper; mitk::IntProperty::Pointer layer = mitk::IntProperty::New(1000); // ... of widget 1 m_PlaneNode1 = (mitk::BaseRenderer::GetInstance(mitkWidget1->GetVtkRenderWindow()))->GetCurrentWorldGeometry2DNode(); m_PlaneNode1->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow())); m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true)); m_PlaneNode1->SetProperty("name", mitk::StringProperty::New("widget1Plane")); m_PlaneNode1->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); m_PlaneNode1->SetProperty("helper object", mitk::BoolProperty::New(true)); m_PlaneNode1->SetProperty("layer",layer); m_PlaneNode1->SetColor(1.0,0.0,0.0); mapper = mitk::Geometry2DDataMapper2D::New(); m_PlaneNode1->SetMapper(mitk::BaseRenderer::Standard2D, mapper); // ... of widget 2 m_PlaneNode2 =( mitk::BaseRenderer::GetInstance(mitkWidget2->GetVtkRenderWindow()))->GetCurrentWorldGeometry2DNode(); m_PlaneNode2->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow())); m_PlaneNode2->SetProperty("visible", mitk::BoolProperty::New(true)); m_PlaneNode2->SetProperty("name", mitk::StringProperty::New("widget2Plane")); m_PlaneNode2->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); m_PlaneNode2->SetProperty("helper object", mitk::BoolProperty::New(true)); m_PlaneNode2->SetProperty("layer",layer); m_PlaneNode2->SetColor(0.0,1.0,0.0); mapper = mitk::Geometry2DDataMapper2D::New(); m_PlaneNode2->SetMapper(mitk::BaseRenderer::Standard2D, mapper); // ... of widget 3 m_PlaneNode3 = (mitk::BaseRenderer::GetInstance(mitkWidget3->GetVtkRenderWindow()))->GetCurrentWorldGeometry2DNode(); m_PlaneNode3->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow())); m_PlaneNode3->SetProperty("visible", mitk::BoolProperty::New(true)); m_PlaneNode3->SetProperty("name", mitk::StringProperty::New("widget3Plane")); m_PlaneNode3->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); m_PlaneNode3->SetProperty("helper object", mitk::BoolProperty::New(true)); m_PlaneNode3->SetProperty("layer",layer); m_PlaneNode3->SetColor(0.0,0.0,1.0); mapper = mitk::Geometry2DDataMapper2D::New(); m_PlaneNode3->SetMapper(mitk::BaseRenderer::Standard2D, mapper); m_Node = mitk::DataNode::New(); m_Node->SetProperty("name", mitk::StringProperty::New("Widgets")); m_Node->SetProperty("helper object", mitk::BoolProperty::New(true)); //AddPlanesToDataStorage if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_Node.IsNotNull()) { if (m_DataStorage.IsNotNull()) { m_DataStorage->Add(m_Node); m_DataStorage->Add(m_PlaneNode1, m_Node); m_DataStorage->Add(m_PlaneNode2, m_Node); m_DataStorage->Add(m_PlaneNode3, m_Node); static_cast(m_PlaneNode1->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); static_cast(m_PlaneNode2->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); static_cast(m_PlaneNode3->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); } } } void Fit() { vtkRenderer * vtkrenderer; mitk::BaseRenderer::GetInstance(mitkWidget1->GetVtkRenderWindow())->GetDisplayGeometry()->Fit(); mitk::BaseRenderer::GetInstance(mitkWidget2->GetVtkRenderWindow())->GetDisplayGeometry()->Fit(); mitk::BaseRenderer::GetInstance(mitkWidget3->GetVtkRenderWindow())->GetDisplayGeometry()->Fit(); mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow())->GetDisplayGeometry()->Fit(); int w = vtkObject::GetGlobalWarningDisplay(); vtkObject::GlobalWarningDisplayOff(); vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget1->GetVtkRenderWindow())->GetVtkRenderer(); if ( vtkrenderer!= NULL ) vtkrenderer->ResetCamera(); vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget2->GetVtkRenderWindow())->GetVtkRenderer(); if ( vtkrenderer!= NULL ) vtkrenderer->ResetCamera(); vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget3->GetVtkRenderWindow())->GetVtkRenderer(); if ( vtkrenderer!= NULL ) vtkrenderer->ResetCamera(); vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow())->GetVtkRenderer(); if ( vtkrenderer!= NULL ) vtkrenderer->ResetCamera(); vtkObject::SetGlobalWarningDisplay(w); } int main(int argc, char* argv[]) { if(argc<2) { fprintf( stderr, "Usage: %s [filename1] [filename2] ...\n\n", "" ); return 1; } // Create a DataStorage m_DataStorage = mitk::StandaloneDataStorage::New(); //************************************************************************* // Part II: Create some data by reading files //************************************************************************* int i; for(i=1; iSetFileName(filename); nodeReader->Update(); // Since the DataNodeFactory directly creates a node, // use the datastorage to add the read node mitk::DataNode::Pointer node = nodeReader->GetOutput(); m_DataStorage->Add(node); mitk::Image::Pointer image = dynamic_cast(node->GetData()); if(image.IsNotNull()) { // Set the property "volumerendering" to the Boolean value "true" node->SetProperty("volumerendering", mitk::BoolProperty::New(false)); node->SetProperty("name", mitk::StringProperty::New("testimage")); node->SetProperty("layer",mitk::IntProperty::New(1)); } } catch(...) { fprintf( stderr, "Could not open file %s \n\n", filename ); exit(2); } } //************************************************************************* // Part V: Create window and pass the tree to it //************************************************************************* // Global Interaction initialize mitk::GlobalInteraction::GetInstance()->Initialize("global"); // instantiate display interactor m_MoveAndZoomInteractor = mitk::DisplayVectorInteractor::New( "moveNzoom", new mitk::DisplayInteractor() ); mitk::GlobalInteraction::GetInstance()->AddListener(m_MoveAndZoomInteractor); // Create renderwindows mitkWidget1 = mitk::RenderWindow::New(); mitkWidget2 = mitk::RenderWindow::New(); mitkWidget3 = mitk::RenderWindow::New(); mitkWidget4 = mitk::RenderWindow::New(); // Tell the renderwindow which (part of) the datastorage to render mitkWidget1->GetRenderer()->SetDataStorage(m_DataStorage); mitkWidget2->GetRenderer()->SetDataStorage(m_DataStorage); mitkWidget3->GetRenderer()->SetDataStorage(m_DataStorage); mitkWidget4->GetRenderer()->SetDataStorage(m_DataStorage); // Let NavigationControllers listen to GlobalInteraction mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); gi->AddListener( mitkWidget1->GetSliceNavigationController() ); gi->AddListener( mitkWidget2->GetSliceNavigationController() ); gi->AddListener( mitkWidget3->GetSliceNavigationController() ); gi->AddListener( mitkWidget4->GetSliceNavigationController() ); // Use it as a 2D View mitkWidget1->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D); mitkWidget2->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D); mitkWidget3->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard2D); mitkWidget4->GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard3D); + - - - mitkWidget1->GetVtkRenderWindow()->SetSize(400, 400); + mitkWidget1->SetSize(400, 400); mitkWidget2->GetVtkRenderWindow()->SetPosition(mitkWidget1->GetVtkRenderWindow()->GetPosition()[0]+420, mitkWidget1->GetVtkRenderWindow()->GetPosition()[1]); - mitkWidget2->GetVtkRenderWindow()->SetSize(400, 400); + mitkWidget2->SetSize(400, 400); mitkWidget3->GetVtkRenderWindow()->SetPosition(mitkWidget1->GetVtkRenderWindow()->GetPosition()[0], mitkWidget1->GetVtkRenderWindow()->GetPosition()[1]+450); - mitkWidget3->GetVtkRenderWindow()->SetSize(400, 400); + mitkWidget3->SetSize(400, 400); mitkWidget4->GetVtkRenderWindow()->SetPosition(mitkWidget1->GetVtkRenderWindow()->GetPosition()[0]+420, mitkWidget1->GetVtkRenderWindow()->GetPosition()[1]+450); - mitkWidget4->GetVtkRenderWindow()->SetSize(400, 400); + mitkWidget4->SetSize(400, 400); InitializeWindows(); AddDisplayPlaneSubTree(); Fit(); // Initialize the RenderWindows mitk::TimeSlicedGeometry::Pointer geo = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()); mitk::RenderingManager::GetInstance()->InitializeViews( geo ); m_DataStorage->Print( std::cout ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + + // reinit the mitkVTKEventProvider; + // this is only necessary once after calling + // ForceImmediateUpdateAll() for the first time + mitkWidget1->ReinitEventProvider(); + mitkWidget2->ReinitEventProvider(); + mitkWidget3->ReinitEventProvider(); mitkWidget1->GetVtkRenderWindow()->Render(); mitkWidget2->GetVtkRenderWindow()->Render(); mitkWidget3->GetVtkRenderWindow()->Render(); mitkWidget4->GetVtkRenderWindow()->Render(); - mitkWidget1->GetVtkRenderWindowInteractor()->Start(); + mitkWidget4->GetVtkRenderWindowInteractor()->Start(); return 0; } diff --git a/BlueBerry/BlueBerryConfig.cmake.in b/BlueBerry/BlueBerryConfig.cmake.in index 122098b65d..8d97a76a25 100644 --- a/BlueBerry/BlueBerryConfig.cmake.in +++ b/BlueBerry/BlueBerryConfig.cmake.in @@ -1,90 +1,82 @@ # ------------------------------------------------------------------------- # Package requirements # ------------------------------------------------------------------------- SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "@BLUEBERRY_SOURCE_DIR@/CMake") SET(CTK_DIR "@CTK_DIR@") FIND_PACKAGE(CTK REQUIRED) SET(mbilog_DIR "@mbilog_DIR@") FIND_PACKAGE(mbilog REQUIRED) FIND_PACKAGE(Poco REQUIRED) FIND_PACKAGE(Doxygen) # ------------------------------------------------------------------------- # BlueBerry directory vars # ------------------------------------------------------------------------- SET(BLUEBERRY_PLUGINS_SOURCE_DIR "@BLUEBERRY_PLUGINS_SOURCE_DIR@") SET(BLUEBERRY_PLUGINS_BINARY_DIR "@BLUEBERRY_PLUGINS_BINARY_DIR@") SET(BLUEBERRY_PLUGIN_SOURCE_DIRS "@BLUEBERRY_PLUGINS_SOURCE_DIR@") -SET(BLUEBERRY_PLUGINS_OUTPUT_DIR "@BLUEBERRY_PLUGINS_OUTPUT_DIR@") SET(BLUEBERRY_SOURCE_DIR "@BLUEBERRY_SOURCE_DIR@") SET(BlueBerry_SOURCE_DIR "@BLUEBERRY_SOURCE_DIR@") SET(BLUEBERRY_BINARY_DIR "@BLUEBERRY_BINARY_DIR@") # ------------------------------------------------------------------------- # BlueBerry CMake file includes # ------------------------------------------------------------------------- SET(BLUEBERRY_PLUGIN_USE_FILE @BB_PLUGIN_USE_FILE@) IF(BLUEBERRY_PLUGIN_USE_FILE) IF(EXISTS ${BLUEBERRY_PLUGIN_USE_FILE}) INCLUDE(${BLUEBERRY_PLUGIN_USE_FILE}) ENDIF() ENDIF() IF(NOT BB_PLUGIN_EXPORTS_FILE_INCLUDED AND NOT CMAKE_PROJECT_NAME STREQUAL "MITK") INCLUDE("@BB_PLUGIN_EXPORTS_FILE@") SET(BB_PLUGIN_EXPORTS_FILE_INCLUDED 1) ENDIF() # ------------------------------------------------------------------------- # BlueBerry CMake variables # ------------------------------------------------------------------------- SET(BLUEBERRY_DEBUG_POSTFIX @BLUEBERRY_DEBUG_POSTFIX@) SET(BLUEBERRY_USE_QT_HELP @BLUEBERRY_USE_QT_HELP@) SET(QT_HELPGENERATOR_EXECUTABLE "@QT_HELPGENERATOR_EXECUTABLE@") SET(QT_COLLECTIONGENERATOR_EXECUTABLE "@QT_COLLECTIONGENERATOR_EXECUTABLE@") SET(QT_ASSISTANT_EXECUTABLE "@QT_ASSISTANT_EXECUTABLE@") SET(QT_XMLPATTERNS_EXECUTABLE "@QT_XMLPATTERNS_EXECUTABLE@") SET(BLUEBERRY_PLUGIN_TARGETS @my_plugin_targets@) -SET(BLUEBERRY_ENABLED_PLUGINS @my_plugin_targets@) SET(BLUEBERRY_PLUGIN_PROVISIONING_FILE "@BLUEBERRY_PROVISIONING_FILE@") SET(BLUEBERRY_DOXYGEN_TAGFILE_NAME @BLUEBERRY_DOXYGEN_TAGFILE_NAME@) # ------------------------------------------------------------------------- # BlueBerry CMake macros # ------------------------------------------------------------------------- INCLUDE(MacroParseArguments) INCLUDE(MacroConvertSchema) INCLUDE(MacroOrganizeSources) -INCLUDE(berryPluginHelpers) -INCLUDE(MacroCollectPlugins) -INCLUDE(MacroParseManifest) -INCLUDE(MacroCreatePlugin) INCLUDE(MacroCreateCTKPlugin) INCLUDE(MacroCreateQtHelp) -INCLUDE(MacroInstallPlugin) INCLUDE(MacroInstallCTKPlugin) -INCLUDE(MacroInstallThirdPartyPlugins) INCLUDE(FunctionInstallThirdPartyCTKPlugins) INCLUDE(FunctionCreateProvisioningFile) INCLUDE(FunctionCreateBlueBerryApplication) diff --git a/BlueBerry/Build/BundleGenerator/CMakeLists.txt b/BlueBerry/Build/BundleGenerator/CMakeLists.txt deleted file mode 100644 index 221ca83f1c..0000000000 --- a/BlueBerry/Build/BundleGenerator/CMakeLists.txt +++ /dev/null @@ -1,302 +0,0 @@ -PROJECT(BlueBerryPluginGenerator) - -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -MARK_AS_ADVANCED( -CMAKE_BACKWARDS_COMPATIBILITY CMAKE_INSTALL_PREFIX CMAKE_BUILD_TYPE) - -FIND_FILE(PLUGIN_TEMPLATE BundleTemplate - ${PROJECT_SOURCE_DIR}/../../CMake - DOC "Path to the plugin templates") - -IF(BUNDLE_DEFAULTS_FILE) - IF(EXISTS "${BUNDLE_DEFAULTS_FILE}") - INCLUDE(${BUNDLE_DEFAULTS_FILE}) - ELSE(EXISTS "${BUNDLE_DEFAULTS_FILE}") - MESSAGE(SEND_ERROR "cannot find supplied defaults file: ${BUNDLE_DEFAULTS_FILE}") - ENDIF(EXISTS "${BUNDLE_DEFAULTS_FILE}") -ELSE(BUNDLE_DEFAULTS_FILE) - INCLUDE(${PLUGIN_TEMPLATE}/BundleDefaults.cmake) -ENDIF(BUNDLE_DEFAULTS_FILE) - -SET(PLUGIN_ID "${DEFAULT_PLUGIN_ID}" CACHE STRING "unique plugin id (i.e. your.domain.pluginid) (required)") -SET(PLUGIN_NAME "" CACHE STRING "a human-readable description of your plugin (required)") -SET(CUSTOM_PROJECT_NAME "" CACHE STRING "Your project name (optional)") -OPTION(GUI_SUPPORT "enable this if your plugin contributes to the UI" ON) - -STRING(REPLACE " " "" CUSTOM_PROJECT_NAME_NOWS "${CUSTOM_PROJECT_NAME}") -SET(CUSTOM_PROJECT_NAME "${CUSTOM_PROJECT_NAME_NOWS}" CACHE STRING "Your project name (optional)" FORCE) - - -IF(PLUGIN_ID AND PLUGIN_NAME) - -SET(PLUGIN_VERSION "${DEFAULT_PLUGIN_VERSION}" CACHE STRING "plugin version (required)") -SET(PLUGIN_VENDOR "${DEFAULT_PLUGIN_VENDOR}" CACHE STRING "plugin vendor (optional)") - -SET(ACTIVATOR_CLASS "" CACHE STRING "class name for your plugin activator (optional)") - -IF(GUI_SUPPORT) - - STRING(REGEX REPLACE "[^a-zA-Z_]" "" _view_baseid "${PLUGIN_NAME}") - STRING(TOLOWER ${_view_baseid} _lview_baseid) - - SET(_default_view_class_name "${DEFAULT_VIEW_CLASS_BEGIN}${_view_baseid}View") - - SET(VIEW_NAME "${PLUGIN_NAME}" CACHE STRING "a human-readable name of your view (required)") - SET(VIEW_CLASS "${_default_view_class_name}" CACHE STRING "class name of the view") - IF(VIEW_CLASS) - STRING(TOUPPER ${VIEW_CLASS} UVIEW_CLASS) - ENDIF(VIEW_CLASS) - SET(VIEW_BASE_CLASS ${DEFAULT_VIEW_BASE_CLASS} CACHE STRING "base class of your new view class (required)") - SET(VIEW_BASE_CLASS_H ${DEFAULT_VIEW_BASE_CLASS_H} CACHE STRING "base class header (required)") - - SET(VIEW_ID "${DEFAULT_VIEW_BASEID}${_lview_baseid}" CACHE STRING "unique view id (i.e. your.domain.viewid) (required)") - - #SET(EDITOR_CLASS "" CACHE STRING "") - #SET(EDITOR_TYPE "" CACHE STRING "") -ENDIF(GUI_SUPPORT) - -#SET(GENERATE_SERVICE "" CACHE STRING "") -#SET(GENERATE_SERVICE_CLASS "" CACHE STRING "") - -SET(_required_bundles ${DEFAULT_REQUIRED_BUNDLES}) -IF(GUI_SUPPORT) - SET(_required_bundles ${DEFAULT_REQUIRED_BUNDLES_FOR_GUI}) -ENDIF(GUI_SUPPORT) -SET(REQUIRED_PLUGINS ${_required_bundles} CACHE STRING "a semicolon-separated list of required plugins (optional)") - -IF(ACTIVATOR_CLASS) - SET(FULLY_QUALIFIED_ACTIVATOR "${BUNDLE_NAMESPACE}::${ACTIVATOR_CLASS}") - STRING(TOUPPER ${ACTIVATOR_CLASS} UACTIVATOR_CLASS) - IF(GUI_SUPPORT) - SET(ACTIVATOR_BASE_CLASS "berry::AbstractUIPlugin") - SET(ACTIVATOR_BASE_CLASS_H "berryAbstractUIPlugin.h") - ELSE() - SET(ACTIVATOR_BASE_CLASS "berry::Plugin") - SET(ACTIVATOR_BASE_CLASS_H "berryPlugin.h") - ENDIF() -ELSE(ACTIVATOR_CLASS) - SET(FULLY_QUALIFIED_ACTIVATOR "") -ENDIF(ACTIVATOR_CLASS) - -SET(PROJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CUSTOM_PROJECT_NAME}") -IF(CUSTOM_PROJECT_NAME) - SET(PLUGIN_DIR "${PROJECT_DIR}/Bundles/${PLUGIN_ID}") -ELSE(CUSTOM_PROJECT_NAME) - SET(PLUGIN_DIR "${PROJECT_DIR}/${PLUGIN_ID}") -ENDIF(CUSTOM_PROJECT_NAME) - -IF(NOT EXISTS "${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF") - MESSAGE(FATAL_ERROR "Could not find ${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF!") -ENDIF(NOT EXISTS "${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF") - -# ====================== PROJECT FILES =============================== - -IF(CUSTOM_PROJECT_NAME AND EXISTS "${PLUGIN_TEMPLATE}/project/CMakeListsTemplate.txt") - - SET(CUSTOM_PROJECT_EXECUTABLE ${CUSTOM_PROJECT_NAME} CACHE STRING "the name of your project's executable") - - IF(GUI_SUPPORT) - SET(FIND_PACKAGE_QT4 "FIND_PACKAGE(Qt4 REQUIRED)") - ENDIF(GUI_SUPPORT) - - SET(BLUEBERRY_BINARY_DIR "@BLUEBERRY_BINARY_DIR@") - SET(BLUEBERRY_PLUGINS_OUTPUT_DIR "@BLUEBERRY_PLUGINS_OUTPUT_DIR@") - SET(PLUGIN_CACHE_DIR "@PLUGIN_CACHE_DIR@") - SET(PLUGIN_BINARY_DIRS "@PLUGIN_BINARY_DIRS@") - SET(MITK_PLUGIN_BINARY_DIRS "@MITK_PLUGIN_BINARY_DIRS@") - - SET(BATCH_FILE_PATH "@MITK_RUNTIME_PATH@;@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/@VS_BUILD_TYPE@") - SET(BATCH_FILE_VS_PATH ${BATCH_FILE_PATH}) - SET(BATCH_FILE_EXEC_CMD "@APP_BUILD_TYPE@\\${CUSTOM_PROJECT_EXECUTABLE}.exe") - SET(BATCH_FILE_VS_EXEC_CMD "\@PROJECT_BINARY_DIR\@/${CUSTOM_PROJECT_NAME}.sln") - - CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/CMakeListsTemplate.txt" - "${PROJECT_DIR}/CMakeLists.txt" @ONLY) - - CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/Bundles/CMakeListsTemplate.txt" - "${PROJECT_DIR}/Bundles/CMakeLists.txt" @ONLY) - - CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/AppTemplate.cpp" - "${PROJECT_DIR}/${CUSTOM_PROJECT_EXECUTABLE}.cpp" @ONLY) - - CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/AppTemplate.ini" - "${PROJECT_DIR}/${CUSTOM_PROJECT_EXECUTABLE}.ini" COPYONLY) - - CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/startAppTemplate.bat" - "${PROJECT_DIR}/start${CUSTOM_PROJECT_EXECUTABLE}.bat.in" @ONLY) - - CONFIGURE_FILE("${PLUGIN_TEMPLATE}/project/startVS2008Template.bat" - "${PROJECT_DIR}/startVS2008.bat.in" @ONLY) - -ENDIF() - - -# ====================== END PROJECT FILES =========================== - - -STRING(REPLACE . _ NormalizedPluginID ${PLUGIN_ID}) -STRING(TOUPPER ${NormalizedPluginID} UNormalizedPluginID) - -# ----- START cut plugin_ID from last '.' till end ------------ -SET(LAST_PART_PLUGIN_ID ${PLUGIN_ID}) -STRING(REGEX MATCH "\\.[^\\.]*$" LAST_PART_PLUGIN_ID ${LAST_PART_PLUGIN_ID}) -STRING(LENGTH ${LAST_PART_PLUGIN_ID} LengthStr) -MATH(EXPR LengthStr "${LengthStr}-1") -STRING(SUBSTRING ${LAST_PART_PLUGIN_ID} 1 ${LengthStr} LAST_PART_PLUGIN_ID) -MATH(EXPR LengthStr "${LengthStr}-1") -STRING(SUBSTRING ${LAST_PART_PLUGIN_ID} 0 1 LAST_PART_PLUGIN_ID_FIRST_LETTER) -STRING(TOUPPER ${LAST_PART_PLUGIN_ID_FIRST_LETTER} LAST_PART_PLUGIN_ID_FIRST_LETTER) -STRING(SUBSTRING ${LAST_PART_PLUGIN_ID} 1 ${LengthStr} LAST_PART_PLUGIN_ID_REST) -SET(LAST_PART_PLUGIN_ID ${LAST_PART_PLUGIN_ID_FIRST_LETTER}${LAST_PART_PLUGIN_ID_REST}) -STRING(TOUPPER ${LAST_PART_PLUGIN_ID} ULAST_PART_PLUGIN_ID) -# ------ END -------------------------------------------------- - - -# --------------------- META-INF/MANIFEST_TEMPLATE.MF --------------------- -SET(REQUIRED_PLUGINS_MF "${REQUIRED_PLUGINS}") -STRING(REPLACE ";" "," REQUIRED_PLUGINS_MF "${REQUIRED_PLUGINS_MF}" ) -CONFIGURE_FILE(${PLUGIN_TEMPLATE}/META-INF/MANIFEST_TEMPLATE.MF ${PLUGIN_DIR}/META-INF/MANIFEST.MF @ONLY) - -# ----------------- documentation/doxygen/modulesTemplate.dox ------------ -IF(DOXYGEN_INGROUP) - SET(DOXYGEN_INGROUP_CMD "\\ingroup ${DOXYGEN_INGROUP}") -ENDIF(DOXYGEN_INGROUP) -CONFIGURE_FILE(${PLUGIN_TEMPLATE}/documentation/doxygen/modulesTemplate.dox - ${PLUGIN_DIR}/documentation/doxygen/modules.dox @ONLY) - -# ----------------- documentation/Manual/Manual.dox ------------ -CONFIGURE_FILE(${PLUGIN_TEMPLATE}/documentation/Manual/Manual.dox - ${PLUGIN_DIR}/documentation/Manual/Manual.dox @ONLY) -CONFIGURE_FILE(${PLUGIN_TEMPLATE}/documentation/Manual/icon.png - ${PLUGIN_DIR}/documentation/Manual/icon.png @ONLY) - -# ----------------- resources directory --------------------------------- -IF(GUI_SUPPORT) - FILE(MAKE_DIRECTORY ${PLUGIN_DIR}/resources) - IF(EXISTS ${PLUGIN_TEMPLATE}/resources/qtresources.qrc) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/resources/qtresources.qrc ${PLUGIN_DIR}/resources/${VIEW_CLASS}.qrc @ONLY) - ENDIF(EXISTS ${PLUGIN_TEMPLATE}/resources/qtresources.qrc) - - IF(EXISTS ${PLUGIN_TEMPLATE}/resources/icon.xpm) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/resources/icon.xpm ${PLUGIN_DIR}/resources/icon.xpm @ONLY) - ENDIF(EXISTS ${PLUGIN_TEMPLATE}/resources/icon.xpm) -ENDIF() - - -# -------------------- BundleDllTemplate.h ------------------------------- -IF(EXISTS ${PLUGIN_TEMPLATE}/src/BundleDllTemplate.h) - IF(BUNDLE_NAMESPACE) - STRING(TOUPPER ${BUNDLE_NAMESPACE} UBUNDLE_NAMESPACE) - ENDIF(BUNDLE_NAMESPACE) - IF(UBUNDLE_NAMESPACE) - SET(DLL_DEFINE "${UBUNDLE_NAMESPACE}_${ULAST_PART_PLUGIN_ID}_EXPORT") - ELSE(UBUNDLE_NAMESPACE) - SET(DLL_DEFINE "${ULAST_PART_PLUGIN_ID}_EXPORT") - ENDIF(UBUNDLE_NAMESPACE) - - - SET(Dll_HEADER ${BUNDLE_NAMESPACE}${LAST_PART_PLUGIN_ID}Dll.h) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/BundleDllTemplate.h ${PLUGIN_DIR}/src/${Dll_HEADER} @ONLY) -ENDIF(EXISTS ${PLUGIN_TEMPLATE}/src/BundleDllTemplate.h) - - -# --------------------- src/internal/ViewTemplateControls.ui ---------------------------- -IF (GUI_SUPPORT) - IF(EXISTS ${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui) - SET(VIEW_CONTROLS "${VIEW_CLASS}Controls") - SET(VIEW_CONTROLS_UI "${VIEW_CONTROLS}.ui") - SET(VIEW_CONTROLS_FILE "ui_${VIEW_CONTROLS}.h") - SET(VIEW_CONTROLS_CLASS "${VIEW_CONTROLS}") - - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui ${PLUGIN_DIR}/src/internal/${VIEW_CONTROLS_UI} @ONLY) - ENDIF(EXISTS ${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui) -ENDIF() - -# --------------------- src/internal/ViewTemplate[.h,.cpp] ---------------------------- -IF(VIEW_CLASS) - SET(VIEW_CLASS_H "${BUNDLE_NAMESPACE}${VIEW_CLASS}.h") - SET(VIEW_CLASS_CPP "${BUNDLE_NAMESPACE}${VIEW_CLASS}.cpp") - - IF(BUNDLE_NAMESPACE) - SET(BEGIN_NAMESPACE "namespace ${BUNDLE_NAMESPACE} {") - SET(END_NAMESPACE "} //namespace ${BUNDLE_NAMESPACE}") - ENDIF(BUNDLE_NAMESPACE) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ViewTemplate.h ${PLUGIN_DIR}/src/internal/${VIEW_CLASS_H} @ONLY) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ViewTemplate.cpp ${PLUGIN_DIR}/src/internal/${VIEW_CLASS_CPP} @ONLY) -ENDIF(VIEW_CLASS) - -# ---------------------- pluginTemplate.xml --------------------------------- -IF(VIEW_CLASS) - SET(XP_VIEW " - - " -) -ENDIF(VIEW_CLASS) -CONFIGURE_FILE(${PLUGIN_TEMPLATE}/pluginTemplate.xml ${PLUGIN_DIR}/plugin.xml @ONLY) - -# ----------------------- ActivatorTemplate[.h,.cpp] ------------------------ -IF(ACTIVATOR_CLASS) - SET(ACTIVATOR_CLASS_H "${BUNDLE_NAMESPACE}${ACTIVATOR_CLASS}.h") - SET(ACTIVATOR_CLASS_CPP "${BUNDLE_NAMESPACE}${ACTIVATOR_CLASS}.cpp") - - IF(BUNDLE_NAMESPACE) - SET(BEGIN_NAMESPACE "namespace ${BUNDLE_NAMESPACE} {") - SET(END_NAMESPACE "} //namespace ${BUNDLE_NAMESPACE}") - ENDIF(BUNDLE_NAMESPACE) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ActivatorTemplate.h ${PLUGIN_DIR}/src/internal/${ACTIVATOR_CLASS_H} @ONLY) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/src/internal/ActivatorTemplate.cpp ${PLUGIN_DIR}/src/internal/${ACTIVATOR_CLASS_CPP} @ONLY) -ENDIF() - -# ----------------------- manifestTemplate.cpp ---------------------------- -IF(VIEW_CLASS) - SET(SET_MANIFEST_SRC "SET(CPP_FILES manifest.cpp)") - SET(MANIFEST_VIEW_ENTRY "#include \"src/internal/${VIEW_CLASS_H}\" - -POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart) - POCO_EXPORT_CLASS(${BUNDLE_NAMESPACE}::${VIEW_CLASS}) -POCO_END_MANIFEST") -ENDIF(VIEW_CLASS) - -IF(ACTIVATOR_CLASS) - SET(SET_MANIFEST_SRC "SET(CPP_FILES manifest.cpp)") - SET(MANIFEST_ACTIVATOR_ENTRY "#include \"src/internal/${ACTIVATOR_CLASS_H}\" - -POCO_BEGIN_MANIFEST(berry::IBundleActivator) - POCO_EXPORT_CLASS(${BUNDLE_NAMESPACE}::${ACTIVATOR_CLASS}) -POCO_END_MANIFEST") -ENDIF() - -IF(VIEW_CLASS OR ACTIVATOR_CLASS) - CONFIGURE_FILE(${PLUGIN_TEMPLATE}/manifestTemplate.cpp ${PLUGIN_DIR}/manifest.cpp @ONLY) -ENDIF() - -# ---------------------- CMakeListsTemplate.txt ----------------------------- -SET(CREATE_PLUGIN_MACRO "${DEFAULT_CREATE_PLUGIN_MACRO}") -IF(GUI_SUPPORT) - SET(CREATE_PLUGIN_MACRO "${DEFAULT_CREATE_GUI_PLUGIN_MACRO}") -ENDIF(GUI_SUPPORT) - -CONFIGURE_FILE(${PLUGIN_TEMPLATE}/CMakeListsTemplate.txt ${PLUGIN_DIR}/CMakeLists.txt @ONLY) - -# ---------------------- filesTemplate.cmake ------------------------------ -SET(PLUGIN_SOURCES "") -SET(PLUGIN_INTERNAL_SOURCES "") -IF(VIEW_CLASS) - SET(PLUGIN_INTERNAL_SOURCES "${PLUGIN_INTERNAL_SOURCES}${VIEW_CLASS_CPP}\n") -ENDIF(VIEW_CLASS) -IF(ACTIVATOR_CLASS) - SET(PLUGIN_INTERNAL_SOURCES "${PLUGIN_INTERNAL_SOURCES}${ACTIVATOR_CLASS_CPP}\n") -ENDIF(ACTIVATOR_CLASS) -IF(GUI_SUPPORT AND EXISTS ${PLUGIN_TEMPLATE}/src/internal/ControlsTemplate.ui) - SET(PLUGIN_RESOURCE_FILES "resources/icon.xpm") - SET(PLUGIN_RES_FILES "resources/${VIEW_CLASS}.qrc") - SET(PLUGIN_UI_FILES "src/internal/${VIEW_CONTROLS_UI}") - SET(PLUGIN_MOC_H_FILES "src/internal/${VIEW_CLASS}.h") -ENDIF() - -CONFIGURE_FILE(${PLUGIN_TEMPLATE}/filesTemplate.cmake ${PLUGIN_DIR}/files.cmake @ONLY) - -ENDIF(PLUGIN_ID AND PLUGIN_NAME) diff --git a/BlueBerry/Bundles/org.blueberry.test/documentation/doxygen/modules.dox b/BlueBerry/Bundles/org.blueberry.test/documentation/doxygen/modules.dox index 571a6e2f81..15d1afa735 100644 --- a/BlueBerry/Bundles/org.blueberry.test/documentation/doxygen/modules.dox +++ b/BlueBerry/Bundles/org.blueberry.test/documentation/doxygen/modules.dox @@ -1,16 +1,16 @@ /** - \defgroup org_blueberry_test org.blueberry.test Plugin + \defgroup org_blueberry_test org.blueberry.test \ingroup BlueBerryPlugins \brief Describe your plugin here. */ /** \defgroup org_blueberry_test_internal Internal \ingroup org_blueberry_test \brief This subcategory includes the internal classes of the org.blueberry.test plugin. Other plugins must not rely on these classes. They contain implementation details and their interface may change at any time. We mean it. */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/documentation/doxygen/modules.dox b/BlueBerry/Bundles/org.blueberry.ui.qt.help/documentation/doxygen/modules.dox index 5e117fce39..b2561ea7f5 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/documentation/doxygen/modules.dox +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/documentation/doxygen/modules.dox @@ -1,46 +1,46 @@ /** - \defgroup org_blueberry_ui_qt_help org.blueberry.ui.qt.help Plugin + \defgroup org_blueberry_ui_qt_help org.blueberry.ui.qt.help \ingroup BlueBerryPlugins \brief Provides access to Qt Help information from inside the Workbench. This plug-in collects all Qt QCH files (*.qch) from plug-ins in the RESOLVED state and registers them internally. The plug-in can be configured using the CTK Config Admin service and it listens to certain event topics on the CTK Event Admin. The following configuration properties for the service PID "org.blueberry.services.help" are supported: - \b homePage A QString property containing the a qthelp url pointing to the applications home page. The plug-in subscribes to the following event topics: - \b org/blueberry/help/CONTEXTHELP_REQUESTED signals a request for showing context sensitive help. If no properties are attached to the event, a qthelp url is constructed using the currently active part ID from the workbench. If the url is invalid, the home page is shown instead.

Supported event properties are: - \e url Show the given url The example below demonstrates how to provide configuration data for the org.blueberry.ui.qt.help plug-in. \snippet org.blueberry.ui.qt.help-config/main.cpp 0 Requesting context help may look like this: \snippet org.blueberry.ui.qt.help-config/main.cpp 1 */ /** \defgroup org_blueberry_ui_qt_help_internal Internal \ingroup org_blueberry_ui_qt_help \brief This subcategory includes the internal classes of the org.blueberry.ui.qt.help plugin. Other plugins must not rely on these classes. They contain implementation details and their interface may change at any time. We mean it. */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/documentation/doxygen/modules.dox b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/documentation/doxygen/modules.dox index cd16815f18..9a37cee3c1 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/documentation/doxygen/modules.dox +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.objectinspector/documentation/doxygen/modules.dox @@ -1,16 +1,16 @@ /** - \defgroup org_blueberry_ui_qt_objectinspector org.blueberry.ui.qt.objectinspector Plugin + \defgroup org_blueberry_ui_qt_objectinspector org.blueberry.ui.qt.objectinspector \ingroup BlueBerryPlugins \brief Describe your plugin here. */ /** \defgroup org_blueberry_ui_qt_objectinspector_internal Internal \ingroup org_blueberry_ui_qt_objectinspector \brief This subcategory includes the internal classes of the org.blueberry.ui.qt.objectinspector plugin. Other plugins must not rely on these classes. They contain implementation details and their interface may change at any time. We mean it. */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake index e0307afbf8..1b3e9007c2 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake @@ -1,116 +1,114 @@ SET(SRC_CPP_FILES berryIQtPreferencePage.cpp berryIQtStyleManager.cpp berryQCHPluginListener.cpp berryQtAssistantUtil.cpp berryQModelIndexObject.cpp berryQtEditorPart.cpp berryQtItemSelection.cpp berryQtIntroPart.cpp berryQtPreferences.cpp berryQtSelectionProvider.cpp berryQtViewPart.cpp # application application/berryQtWorkbenchAdvisor.cpp ) SET(INTERNAL_CPP_FILES defaultpresentation/berryEmptyTabFolder.cpp defaultpresentation/berryEmptyTabItem.cpp defaultpresentation/berryNativeTabFolder.cpp defaultpresentation/berryNativeTabItem.cpp defaultpresentation/berryQCTabBar.cpp defaultpresentation/berryQtWorkbenchPresentationFactory.cpp util/berryAbstractTabFolder.cpp util/berryLeftToRightTabOrder.cpp util/berryPartInfo.cpp util/berryPresentablePartFolder.cpp util/berryReplaceDragHandler.cpp util/berryTabbedStackPresentation.cpp util/berryTabFolderEvent.cpp - berryQtControlWidget.cpp berryQtDisplay.cpp berryQtDnDTweaklet.cpp berryQtFileImageDescriptor.cpp berryQtGlobalEventFilter.cpp berryQtIconImageDescriptor.cpp berryQtImageTweaklet.cpp berryQtMainWindowControl.cpp berryQtMessageDialogTweaklet.cpp berryQtMissingImageDescriptor.cpp berryQtOpenPerspectiveAction.cpp berryQtPerspectiveSwitcher.cpp berryQtPluginActivator.cpp berryQtSafeApplication.cpp berryQtSash.cpp berryQtShell.cpp berryQtShowViewAction.cpp berryQtShowViewDialog.cpp berryQtStyleManager.cpp berryQtStylePreferencePage.cpp berryQtTracker.cpp - berryQtWidgetController.cpp berryQtWidgetsTweaklet.cpp berryQtWidgetsTweakletImpl.cpp berryQtWorkbenchPageTweaklet.cpp berryQtWorkbenchTweaklet.cpp berryQtWorkbenchWindow.cpp ) SET(MOC_H_FILES src/berryQCHPluginListener.h src/berryQtSelectionProvider.h src/internal/defaultpresentation/berryNativeTabFolder.h src/internal/defaultpresentation/berryNativeTabItem.h src/internal/defaultpresentation/berryQCTabBar.h src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h src/internal/berryQtDisplay.h src/internal/berryQtDnDTweaklet.h src/internal/berryQtGlobalEventFilter.h src/internal/berryQtImageTweaklet.h src/internal/berryQtMainWindowControl.h src/internal/berryQtMessageDialogTweaklet.h src/internal/berryQtOpenPerspectiveAction.h src/internal/berryQtPerspectiveSwitcher.h src/internal/berryQtSash.h src/internal/berryQtShowViewAction.h src/internal/berryQtStyleManager.h src/internal/berryQtStylePreferencePage.h src/internal/berryQtTracker.h src/internal/berryQtWidgetsTweaklet.h src/internal/berryQtWidgetsTweakletImpl.h src/internal/berryQtWorkbenchTweaklet.h src/internal/berryQtWorkbenchPageTweaklet.h src/internal/berryQtPluginActivator.h ) SET(UI_FILES src/internal/berryQtShowViewDialog.ui src/internal/berryQtStylePreferencePage.ui src/internal/berryQtStatusPart.ui ) SET(QRC_FILES resources/org_blueberry_ui_qt.qrc ) SET(CACHED_RESOURCE_FILES plugin.xml ) SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h index 0baed08f2e..36873b7203 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtSelectionProvider.h @@ -1,69 +1,69 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYQTSELECTIONPROVIDER_H_ #define BERRYQTSELECTIONPROVIDER_H_ #include #include #include #include #include namespace berry { class BERRY_UI_QT QtSelectionProvider: public QObject, public ISelectionProvider { Q_OBJECT public: berryObjectMacro(QtSelectionProvider) QtSelectionProvider(); void AddSelectionChangedListener(ISelectionChangedListener::Pointer listener); void RemoveSelectionChangedListener( ISelectionChangedListener::Pointer listener); ISelection::ConstPointer GetSelection() const; void SetSelection(ISelection::Pointer selection); QItemSelection GetQItemSelection() const; void SetQItemSelection(const QItemSelection& selection); QItemSelectionModel* GetItemSelectionModel() const; void SetItemSelectionModel(QItemSelectionModel* combo); protected: ISelectionChangedListener::Events selectionEvents; QItemSelectionModel* qSelectionModel; protected slots: -virtual void FireSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); + virtual void FireSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); }; } #endif /* BERRYQTSELECTIONPROVIDER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtControlWidget.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtControlWidget.h deleted file mode 100755 index f458f2dd4a..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtControlWidget.h +++ /dev/null @@ -1,57 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef BERRYQTCONTROLWIDGET_H_ -#define BERRYQTCONTROLWIDGET_H_ - -#include - -#include "berryQtWidgetController.h" - -namespace berry { - -class QtControlWidget : public QFrame -{ - -public: - - QtControlWidget(QWidget* parent, Shell* shell, Qt::WindowFlags f = 0); - - ~QtControlWidget(); - - void FireActivateEvent(); - -protected: - - // used for shell listeners - void changeEvent(QEvent* event); - void closeEvent(QCloseEvent* closeEvent); - - // used for control listeners - void moveEvent(QMoveEvent* event); - void resizeEvent(QResizeEvent* event); - - -private: - - QtWidgetController::Pointer controller; -}; - -} - -#endif /* BERRYQTCONTROLWIDGET_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h index c66d57eb64..fd3bbb5792 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtMainWindowControl.h @@ -1,56 +1,56 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYQTMAINWINDOWCONTROL_H_ #define BERRYQTMAINWINDOWCONTROL_H_ #include -#include "berryQtWidgetController.h" +#include namespace berry { class QtMainWindowControl : public QMainWindow { Q_OBJECT public: QtMainWindowControl(Shell* shell, QWidget* parent = 0, Qt::WindowFlags flags = 0); protected: // used for shell listeners void changeEvent(QEvent* event); void closeEvent(QCloseEvent* closeEvent); // used for control listeners void moveEvent(QMoveEvent* event); void resizeEvent(QResizeEvent* event); void inFocusEvent(QFocusEvent* event); private: QtWidgetController::Pointer controller; }; } #endif /* BERRYQTMAINWINDOWCONTROL_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp index 8e65e622d3..da0b7471a9 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtShell.cpp @@ -1,224 +1,224 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY { } without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryQtShell.h" #include "berryQtWidgetsTweakletImpl.h" #include "berryQtMainWindowControl.h" -#include "berryQtControlWidget.h" +#include #include #include #include #include #include namespace berry { QtShell::QtShell(QWidget* parent, Qt::WindowFlags flags) : updatesDisabled(false) { if (parent == 0 || flags.testFlag(Qt::Window)) { widget = new QtMainWindowControl(this, parent, flags); widget->setUpdatesEnabled(false); updatesDisabled = true; widget->setAttribute(Qt::WA_DeleteOnClose); } else { widget = new QtControlWidget(parent, this, flags | Qt::Dialog); widget->setObjectName("shell widget"); } } QtShell::~QtShell() { widget->deleteLater(); } void QtShell::SetBounds(const Rectangle& bounds) { widget->move(bounds.x, bounds.y); widget->resize(bounds.width, bounds.height); } Rectangle QtShell::GetBounds() const { const QRect& qRect = widget->frameGeometry(); const QSize& size = widget->size(); Rectangle rect(qRect.x(), qRect.y(), size.width(), size.height()); return rect; } void QtShell::SetLocation(int x, int y) { widget->move(x, y); } Point QtShell::ComputeSize(int /*wHint*/, int /*hHint*/, bool changed) { if (changed) widget->updateGeometry(); QSize size(widget->size()); Point point(size.width(), size.height()); return point; } std::string QtShell::GetText() const { return widget->windowTitle().toStdString(); } void QtShell::SetText(const std::string& text) { QString title(QString::fromStdString(text)); widget->setWindowTitle(title); widget->setObjectName(title); } bool QtShell::IsVisible() { return widget->isVisible(); } void QtShell::SetVisible(bool visible) { widget->setVisible(visible); } void QtShell::SetActive() { widget->activateWindow(); widget->raise(); } void* QtShell::GetControl() { return widget; } void QtShell::SetImages(const std::vector& /*images*/) { } bool QtShell::GetMaximized() { return widget->isMaximized(); } bool QtShell::GetMinimized() { return widget->isMinimized(); } void QtShell::SetMaximized(bool maximized) { maximized ? widget->showMaximized() : widget->showNormal(); } void QtShell::SetMinimized(bool minimized) { minimized ? widget->showMinimized() : widget->showNormal(); } void QtShell::AddShellListener(IShellListener::Pointer listener) { QVariant variant = widget->property(QtWidgetController::PROPERTY_ID); poco_assert(variant.isValid()); QtWidgetController::Pointer controller = variant.value(); poco_assert(controller != 0); controller->AddShellListener(listener); } void QtShell::RemoveShellListener(IShellListener::Pointer listener) { QVariant variant = widget->property(QtWidgetController::PROPERTY_ID); if (variant.isValid()) { QtWidgetController::Pointer controller = variant.value(); if (controller != 0) controller->RemoveShellListener(listener); } } void QtShell::Open(bool block) { if (updatesDisabled) { widget->setUpdatesEnabled(true); updatesDisabled = false; } widget->setWindowModality(block ? Qt::WindowModal : Qt::NonModal); widget->show(); } void QtShell::Close() { widget->close(); } std::vector QtShell::GetShells() { GuiWidgetsTweaklet* widgetTweaklet = Tweaklets::Get(GuiWidgetsTweaklet::KEY); std::vector allShells(widgetTweaklet->GetShells()); std::vector descendants; for (std::size_t i = 0; i < allShells.size(); ++i) { Shell::Pointer shell = allShells[i]; if (widgetTweaklet->GetShell(shell->GetControl()) == this) { descendants.push_back(shell); } } return descendants; } int QtShell::GetStyle() { Qt::WindowFlags qtFlags = widget->windowFlags(); int berryFlags = 0; if (!(qtFlags & Qt::FramelessWindowHint)) berryFlags |= Constants::BORDER; if (qtFlags & Qt::WindowTitleHint) berryFlags |= Constants::TITLE; if (qtFlags & Qt::WindowSystemMenuHint) berryFlags |= Constants::CLOSE; if (qtFlags & Qt::WindowMinimizeButtonHint) berryFlags |= Constants::MIN; if (qtFlags & Qt::WindowMaximizeButtonHint) berryFlags |= Constants::MAX; if (widget->windowModality() == Qt::WindowModal) berryFlags |= Constants::PRIMARY_MODAL; else if(widget->windowModality() == Qt::ApplicationModal) berryFlags |= Constants::APPLICATION_MODAL; return berryFlags; } QWidget* QtShell::GetWidget() { return widget; } } diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetController.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetController.h deleted file mode 100755 index deb98314a1..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetController.h +++ /dev/null @@ -1,71 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef BERRYIQTCONTROLWIDGET_H_ -#define BERRYIQTCONTROLWIDGET_H_ - -#include -#include - -#include - -namespace berry { - -class Shell; - -class QtWidgetController : public Object -{ - -public: - - berryObjectMacro(QtWidgetController) - - static const char PROPERTY_ID[]; - - QtWidgetController(Shell* shell); - - ~QtWidgetController(); - - void AddControlListener(GuiTk::IControlListener::Pointer listener); - void RemoveControlListener(GuiTk::IControlListener::Pointer listener); - - void AddShellListener(IShellListener::Pointer listener); - void RemoveShellListener(IShellListener::Pointer listener); - - SmartPointer GetShell(); - -protected: - - friend class QtControlWidget; - friend class QtMainWindowControl; - - GuiTk::IControlListener::Events controlEvents; - IShellListener::Events shellEvents; - - void ShellDestroyed(); - - Shell* shell; - -}; - -} - -//TODO WeakPointer: register a weak pointer as metatype -Q_DECLARE_METATYPE(berry::QtWidgetController::Pointer) - -#endif /* BERRYIQTCONTROLWIDGET_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp index cc71b97c05..176b6a52ae 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.cpp @@ -1,447 +1,447 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryLog.h" #include "berryQtWidgetsTweakletImpl.h" #include "berryQtSash.h" #include "berryQtShell.h" -#include "berryQtControlWidget.h" +#include #include #include #include #include #include namespace berry { QtSelectionListenerWrapper::QtSelectionListenerWrapper(QWidget* w) : widget(w) { } void QtSelectionListenerWrapper::AddListener(GuiTk::ISelectionListener::Pointer listener) { QAbstractButton* button = qobject_cast(widget); if (button != 0) { this->connect(button, "clicked(bool)", this, "QAbstractButtonClicked(bool)"); selectionEvents.AddListener(listener); } BERRY_WARN << "WARNING: QtWidgetsTweaklet: no suitable type for listening for selections found!\n"; } int QtSelectionListenerWrapper::RemoveListener(GuiTk::ISelectionListener::Pointer listener) { selectionEvents.RemoveListener(listener); return static_cast(std::max(selectionEvents.selected.GetListeners().size(), selectionEvents.defaultSelected.GetListeners().size())); } void QtSelectionListenerWrapper::QAbstractButtonClicked(bool /*checked*/) { GuiTk::SelectionEvent::Pointer event(new GuiTk::SelectionEvent(widget)); selectionEvents.selected(event); } void QtWidgetsTweakletImpl::AddSelectionListener(QWidget* widget, GuiTk::ISelectionListener::Pointer listener) { if (widget == 0) return; // special handling for berry::QtSash QtSash* sash = qobject_cast(widget); if (sash != 0) { sash->AddSelectionListener(listener); return; } // "normal" Qt widgets get wrapped QtSelectionListenerWrapper* wrapper = selectionListenerMap[widget]; if (wrapper == 0) { wrapper = new QtSelectionListenerWrapper(widget); selectionListenerMap[widget] = wrapper; } wrapper->AddListener(listener); } void QtWidgetsTweakletImpl::RemoveSelectionListener(QWidget* widget, GuiTk::ISelectionListener::Pointer listener) { if (widget == 0) return; // special handling for berry::QtSash QtSash* sash = qobject_cast(widget); if (sash != 0) { sash->RemoveSelectionListener(listener); return; } QtSelectionListenerWrapper* wrapper = selectionListenerMap[widget]; if (wrapper == 0) return; if (wrapper->RemoveListener(listener) == 0) { selectionListenerMap.erase(wrapper); delete wrapper; } } Rectangle QtWidgetsTweakletImpl::GetScreenSize(int i) { QDesktopWidget *desktop = QApplication::desktop(); QRect screenGeometry; if (i < 0) screenGeometry = desktop->screen()->geometry(); else screenGeometry = desktop->screenGeometry(i); return (Rectangle(screenGeometry.x(), screenGeometry.y() , screenGeometry.width(), screenGeometry.height())); } unsigned int QtWidgetsTweakletImpl::GetScreenNumber() { QDesktopWidget *desktop = QApplication::desktop(); // get the primary screen unsigned int numScreens = desktop->numScreens(); return numScreens; } int QtWidgetsTweakletImpl::GetPrimaryScreenNumber() { QDesktopWidget *desktop = QApplication::desktop(); // get the primary screen int primaryScreenNr = desktop->primaryScreen(); return primaryScreenNr; } Rectangle QtWidgetsTweakletImpl::GetAvailableScreenSize(int i) { QDesktopWidget *desktop = QApplication::desktop(); QRect screenGeometry; if (i < 0) screenGeometry = desktop->screen()->geometry(); else screenGeometry = desktop->availableGeometry(i); return (Rectangle(screenGeometry.x(), screenGeometry.y() , screenGeometry.width(), screenGeometry.height())); } int QtWidgetsTweakletImpl::GetClosestScreenNumber(const Rectangle& r) { QDesktopWidget *desktop = QApplication::desktop(); return desktop->screenNumber(QPoint(r.x + r.width/2, r.y + r.height/2)); } void QtWidgetsTweakletImpl::AddControlListener(QtWidgetController* controller, GuiTk::IControlListener::Pointer listener) { controller->AddControlListener(listener); } void QtWidgetsTweakletImpl::RemoveControlListener(QtWidgetController* controller, GuiTk::IControlListener::Pointer listener) { controller->RemoveControlListener(listener); } bool QtWidgetsTweakletImpl::GetEnabled(QWidget* widget) { return widget->isEnabled(); } void QtWidgetsTweakletImpl::SetEnabled(QWidget* widget, bool enabled) { widget->setEnabled(enabled); } void QtWidgetsTweakletImpl::SetBounds(QWidget* widget, const Rectangle& bounds) { widget->setGeometry(bounds.x, bounds.y, bounds.width, bounds.height); } Rectangle QtWidgetsTweakletImpl::GetBounds(QWidget* widget) { const QRect& geometry = widget->geometry(); Rectangle rect(geometry.x(), geometry.y(), geometry.width(), geometry.height()); return rect; } void QtWidgetsTweakletImpl::SetVisible(QWidget* widget, bool visible) { widget->setVisible(visible); } bool QtWidgetsTweakletImpl::GetVisible(QWidget* widget) { return !widget->isHidden(); } bool QtWidgetsTweakletImpl::IsVisible(QWidget* widget) { return widget->isVisible(); } Rectangle QtWidgetsTweakletImpl::GetClientArea(QWidget* widget) { const QRect& contentsRect = widget->contentsRect(); Rectangle rect(contentsRect.x(), contentsRect.y(), contentsRect.width(), contentsRect.height()); return rect; } void* QtWidgetsTweakletImpl::GetParent(QWidget* widget) { return widget->parentWidget(); } bool QtWidgetsTweakletImpl::SetParent(QWidget* widget, QWidget* parent) { if (parent != widget->parentWidget()) { widget->setParent(parent); return true; } return false; } void QtWidgetsTweakletImpl::SetData(QWidget* object, const std::string& id, Object::Pointer data) { if (object == 0) return; QVariant variant; if (data != 0) variant.setValue(data); object->setProperty(id.c_str(), variant); } Object::Pointer QtWidgetsTweakletImpl::GetData(QWidget* object, const std::string& id) { if (object == 0) return Object::Pointer(0); QVariant variant = object->property(id.c_str()); if (variant.isValid()) { return variant.value(); } return Object::Pointer(0); } Point QtWidgetsTweakletImpl::GetCursorLocation() { QPoint qpoint = QCursor::pos(); return Point(qpoint.x(), qpoint.y()); } QWidget* QtWidgetsTweakletImpl::GetCursorControl() { return QApplication::widgetAt(QCursor::pos()); } QWidget* QtWidgetsTweakletImpl::FindControl(const std::vector& shells, const Point& location) { for (std::vector::const_iterator iter = shells.begin(); iter != shells.end(); ++iter) { QWidget* shellWidget = static_cast((*iter)->GetControl()); QWidget* control = shellWidget->childAt(location.x, location.y); if (control) return control; } return 0; } bool QtWidgetsTweakletImpl::IsChild(QObject* parentToTest, QObject* childToTest) { bool found = false; QObject* parent = childToTest->parent(); while (!found && parent != 0) { if (parent == parentToTest) found = true; parent = parent->parent(); } return found; } QWidget* QtWidgetsTweakletImpl::GetFocusControl() { return QApplication::focusWidget(); } bool QtWidgetsTweakletImpl::IsReparentable(QWidget* /*widget*/) { return true; } void QtWidgetsTweakletImpl::MoveAbove(QWidget* widgetToMove, QWidget* /*widget*/) { widgetToMove->raise(); } void QtWidgetsTweakletImpl::MoveBelow(QWidget* widgetToMove, QWidget* /*widget*/) { widgetToMove->lower(); } void QtWidgetsTweakletImpl::Dispose(QWidget* widget) { delete widget; widget = 0; } Shell::Pointer QtWidgetsTweakletImpl::CreateShell(Shell::Pointer parent, int style) { Qt::WindowFlags qtFlags(Qt::CustomizeWindowHint); if (style & Constants::MAX) qtFlags |= Qt::WindowMaximizeButtonHint; if (style & Constants::MIN) qtFlags |= Qt::WindowMinimizeButtonHint; if (style & Constants::CLOSE) { qtFlags |= Qt::WindowSystemMenuHint; #if QT_VERSION >= 0x040500 qtFlags |= Qt::WindowCloseButtonHint; #endif } if (!(style & Constants::BORDER)) qtFlags |= Qt::FramelessWindowHint; if (style & Constants::TITLE) qtFlags |= Qt::WindowTitleHint; if (style & Constants::TOOL) qtFlags |= Qt::Tool; QWidget* parentWidget = 0; if (parent != 0) parentWidget = static_cast(parent->GetControl()); QtShell* qtshell = new QtShell(parentWidget, qtFlags); Shell::Pointer shell(qtshell); shellList.push_back(shell); if ((style & Constants::APPLICATION_MODAL) || (style & Constants::SYSTEM_MODAL)) qtshell->GetWidget()->setWindowModality(Qt::ApplicationModal); if (style & Constants::PRIMARY_MODAL) qtshell->GetWidget()->setWindowModality(Qt::WindowModal); return shell; } QWidget* QtWidgetsTweakletImpl::CreateComposite(QWidget* parent) { QWidget* composite = new QtControlWidget(parent, 0); composite->setObjectName("created composite"); return composite; } void QtWidgetsTweakletImpl::DisposeShell(Shell::Pointer shell) { shellList.remove(shell); } std::vector QtWidgetsTweakletImpl::GetShells() { std::vector shells(shellList.begin(), shellList.end()); return shells; } Shell::Pointer QtWidgetsTweakletImpl::GetShell(QWidget* widget) { QWidget* qwindow = widget->window(); QVariant variant = qwindow->property(QtWidgetController::PROPERTY_ID); if (variant.isValid()) { QtWidgetController::Pointer controller = variant.value(); poco_assert(controller != 0); return controller->GetShell(); } return Shell::Pointer(0); } Shell::Pointer QtWidgetsTweakletImpl::GetActiveShell() { QWidget* qwidget = QApplication::activeWindow(); if (qwidget == 0) return Shell::Pointer(0); QVariant variant = qwidget->property(QtWidgetController::PROPERTY_ID); if (variant.isValid()) { return variant.value()->GetShell(); } return Shell::Pointer(0); } Rectangle QtWidgetsTweakletImpl::ToControl(QWidget* coordinateSystem, const Rectangle& toConvert) { QPoint globalUpperLeft(toConvert.x, toConvert.y); QPoint globalLowerRight(toConvert.x + toConvert.width, toConvert.y + toConvert.height); QPoint upperLeft = coordinateSystem->mapFromGlobal(globalUpperLeft); QPoint lowerRight = coordinateSystem->mapFromGlobal(globalLowerRight); return Rectangle(upperLeft.x(), upperLeft.y(), lowerRight.x() - upperLeft.x(), lowerRight.y() - upperLeft.y()); } Point QtWidgetsTweakletImpl::ToControl(QWidget* coordinateSystem, const Point& toConvert) { QPoint displayPoint(toConvert.x, toConvert.y); QPoint localPoint = coordinateSystem->mapFromGlobal(displayPoint); return Point(localPoint.x(), localPoint.y()); } Rectangle QtWidgetsTweakletImpl::ToDisplay(QWidget* coordinateSystem, const Rectangle& toConvert) { QPoint upperLeft(toConvert.x, toConvert.y); QPoint lowerRight(toConvert.x + toConvert.width, toConvert.y + toConvert.height); QPoint globalUpperLeft = coordinateSystem->mapToGlobal(upperLeft); QPoint globalLowerRight = coordinateSystem->mapToGlobal(lowerRight); return Rectangle(globalUpperLeft.x(), globalUpperLeft.y(), globalLowerRight.x() - globalUpperLeft.x(), globalLowerRight.y() - globalUpperLeft.y()); } Point QtWidgetsTweakletImpl::ToDisplay(QWidget* coordinateSystem, const Point& toConvert) { QPoint localPoint(toConvert.x, toConvert.y); QPoint displayPoint = coordinateSystem->mapToGlobal(localPoint); return Point(displayPoint.x(), displayPoint.y()); } } diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h index 732c22d78b..c86774ed31 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetsTweakletImpl.h @@ -1,160 +1,160 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYQTWIDGETSTWEAKLETIMPL_H_ #define BERRYQTWIDGETSTWEAKLETIMPL_H_ -#include "berryQtWidgetController.h" +#include #include #include #include #include #include #include Q_DECLARE_METATYPE(berry::Object::Pointer) namespace berry { class QtSelectionListenerWrapper : public QObject { Q_OBJECT public: QtSelectionListenerWrapper(QWidget* widget); QWidget* widget; void AddListener(GuiTk::ISelectionListener::Pointer listener); int RemoveListener(GuiTk::ISelectionListener::Pointer listener); protected slots: void QAbstractButtonClicked(bool checked); private: GuiTk::ISelectionListener::Events selectionEvents; }; class QtWidgetsTweakletImpl { public: void AddSelectionListener(QWidget* widget, GuiTk::ISelectionListener::Pointer listener); void RemoveSelectionListener(QWidget* widget, GuiTk::ISelectionListener::Pointer listener); void AddControlListener(QtWidgetController* widget, GuiTk::IControlListener::Pointer listener); void RemoveControlListener(QtWidgetController* widget, GuiTk::IControlListener::Pointer listener); bool GetEnabled(QWidget* widget); void SetEnabled(QWidget* widget, bool enabled); void SetBounds(QWidget* widget, const Rectangle& bounds); Rectangle GetBounds(QWidget* widget); void SetVisible(QWidget* widget, bool visible); bool GetVisible(QWidget* widget); bool IsVisible(QWidget* widget); Rectangle GetClientArea(QWidget* widget); void* GetParent(QWidget* widget); bool SetParent(QWidget* widget, QWidget* parent); void SetData(QWidget* widget, const std::string& id, Object::Pointer data); Object::Pointer GetData(QWidget* widget, const std::string& id); Rectangle GetScreenSize(int i = -1); unsigned int GetScreenNumber(); int GetPrimaryScreenNumber(); Rectangle GetAvailableScreenSize(int i = -1); int GetClosestScreenNumber(const Rectangle&); Point GetCursorLocation(); QWidget* GetCursorControl(); QWidget* FindControl(const std::vector& shells, const Point& location); /** * Determines if one control is a child of another. Returns true iff the second * argument is a child of the first (or the same object). * * @param potentialParent * @param childToTest * @return */ bool IsChild(QObject* potentialParent, QObject* childToTest); /** * Returns the control which currently has keyboard focus, * or null if keyboard events are not currently going to * any of the controls built by the currently running * application. * * @return the control under the cursor */ QWidget* GetFocusControl(); bool IsReparentable(QWidget* widget); void MoveAbove(QWidget* widgetToMove, QWidget* widget); void MoveBelow(QWidget* widgetToMove, QWidget* widget); void Dispose(QWidget* widget); Shell::Pointer CreateShell(Shell::Pointer parent, int style); void DisposeShell(Shell::Pointer shell); QWidget* CreateComposite(QWidget* parent); std::vector GetShells(); Shell::Pointer GetShell(QWidget* widget); Shell::Pointer GetActiveShell(); Rectangle ToControl(QWidget* coordinateSystem, const Rectangle& toConvert); Point ToControl(QWidget* coordinateSystem, const Point& toConvert); Rectangle ToDisplay(QWidget* coordinateSystem, const Rectangle& toConvert); Point ToDisplay(QWidget* coordinateSystem, const Point& toConvert); private: typedef std::map SelectionListenerMap; SelectionListenerMap selectionListenerMap; std::list shellList; friend class QtShell; }; } #endif /* BERRYQTWIDGETSTWEAKLETIMPL_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp index b470bb3893..dbfe149154 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchPageTweaklet.cpp @@ -1,81 +1,81 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryQtWorkbenchPageTweaklet.h" -#include "berryQtControlWidget.h" +#include #include #include #include namespace berry { QtWorkbenchPageTweaklet::QtWorkbenchPageTweaklet() { } QtWorkbenchPageTweaklet::QtWorkbenchPageTweaklet(const QtWorkbenchPageTweaklet& other) { Q_UNUSED(other) } void* QtWorkbenchPageTweaklet::CreateClientComposite(void* pageControl) { QWidget* parent = static_cast(pageControl); QtControlWidget* client = new QtControlWidget(parent, 0); client->setObjectName("Client Composite"); parent->layout()->setContentsMargins(3, 3, 3, 3); parent->layout()->addWidget(client); // we have to enable visibility to get a proper layout (see bug #1654) client->setVisible(true); return client; } void* QtWorkbenchPageTweaklet::CreatePaneControl(void* parent) { QWidget* qParent = static_cast(parent); QtControlWidget* control = new QtControlWidget(qParent, 0); // the object name is used in the global event filter to find // the pane control over which a mouse pressed event occured // --> do not change the object name control->setObjectName("PartPaneControl"); return control; } Object::Pointer QtWorkbenchPageTweaklet::CreateStatusPart(void* parent, const std::string& title, const std::string& msg) { Ui::QtStatusPart statusPart; statusPart.setupUi(static_cast(parent)); statusPart.m_TitleLabel->setText(QString::fromStdString(title)); statusPart.m_DetailsLabel->setText(QString::fromStdString(msg)); return Object::Pointer(0); } IEditorPart::Pointer QtWorkbenchPageTweaklet::CreateErrorEditorPart(const std::string& /*partName*/, const std::string& /*msg*/) { return IEditorPart::Pointer(0); } } diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp index c643116de8..3f9d1ae364 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchTweaklet.cpp @@ -1,72 +1,72 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryQtWorkbenchTweaklet.h" -#include "berryQtControlWidget.h" +#include #include #include #include "berryQtShowViewDialog.h" #include "berryQtDisplay.h" #include "berryQtWorkbenchWindow.h" #include #include #include namespace berry { QtWorkbenchTweaklet::QtWorkbenchTweaklet() { } QtWorkbenchTweaklet::QtWorkbenchTweaklet(const QtWorkbenchTweaklet& other) { } Display* QtWorkbenchTweaklet::CreateDisplay() { return new QtDisplay(); } bool QtWorkbenchTweaklet::IsRunning() { return QApplication::instance() != 0; } WorkbenchWindow::Pointer QtWorkbenchTweaklet::CreateWorkbenchWindow(int number) { WorkbenchWindow::Pointer wnd(new QtWorkbenchWindow(number)); return wnd; } IDialog::Pointer QtWorkbenchTweaklet::CreateStandardDialog(const std::string& dialogid) { if (dialogid == DIALOG_ID_SHOW_VIEW) return IDialog::Pointer(new QtShowViewDialog(PlatformUI::GetWorkbench()->GetViewRegistry())); else return IDialog::Pointer(0); } } // namespace berry diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp index 437ce598a6..73fe55c22c 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWorkbenchWindow.cpp @@ -1,67 +1,67 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryQtWorkbenchWindow.h" -#include "berryQtControlWidget.h" +#include #include "berryQtPerspectiveSwitcher.h" #include #include #include namespace berry { QtWorkbenchWindow::QtWorkbenchWindow(int number) : WorkbenchWindow(number) { } void* QtWorkbenchWindow::CreatePageComposite(void* p) { QWidget* parent = static_cast (p); QtControlWidget* pageArea = new QtControlWidget(parent, 0); pageArea->setObjectName("Page Composite"); new QHBoxLayout(pageArea); if (qobject_cast (parent) != 0) qobject_cast (parent)->setCentralWidget(pageArea); else parent->layout()->addWidget(pageArea); // we have to enable visibility to get a proper layout (see bug #1654) pageArea->setVisible(true); parent->setVisible(true); pageComposite = pageArea; return pageArea; } void QtWorkbenchWindow::CreateDefaultContents(Shell::Pointer shell) { QMainWindow* mainWindow = static_cast(shell->GetControl()); if (GetWindowConfigurer()->GetShowPerspectiveBar() && mainWindow) { mainWindow->addToolBar(new QtPerspectiveSwitcher(IWorkbenchWindow::Pointer(this))); } // Create the client composite area (where page content goes). CreatePageComposite(shell->GetControl()); } } diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp index adc4204cf8..f7e39c0f3f 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryNativeTabFolder.cpp @@ -1,359 +1,359 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryNativeTabFolder.h" #include "berryNativeTabItem.h" #include "berryQCTabBar.h" -#include "../berryQtControlWidget.h" +#include #include #include #include #include #include #include #include #include #include namespace berry { AbstractTabItem* NativeTabFolder::GetTab(int index) { return tabControl->getTab(index); } void NativeTabFolder::TabSelectionChanged(int index) { this->FireEvent(TabFolderEvent::EVENT_TAB_SELECTED, tabControl->getTab(index)); } void NativeTabFolder::DragStarted(const QPoint& location) { Point point(location.x(), location.y()); this->HandleDragStarted(location); } void NativeTabFolder::ViewFormDestroyed(QObject*) { viewForm = 0; content = 0; } NativeTabFolder::NativeTabFolder(QWidget* parent) : QObject(parent) { content = 0; viewForm = new QtControlWidget(parent, 0); viewForm->setObjectName("ViewForm"); viewForm->installEventFilter(this); QVBoxLayout* layout = new QVBoxLayout(viewForm); layout->setContentsMargins(0,0,0,0); layout->setSpacing(0); viewForm->setLayout(layout); connect(viewForm, SIGNAL(destroyed(QObject*)), this, SLOT(ViewFormDestroyed(QObject*))); QWidget* topControls = new QWidget(viewForm); topControls->setMinimumSize(0, 24); topControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); layout->addWidget(topControls); QHBoxLayout* topLayout = new QHBoxLayout(topControls); topLayout->setContentsMargins(0, 0, 0, 0); topLayout->setSpacing(0); tabControl = new QCTabBar(topControls); tabControl->installEventFilter(this); tabControl->setMinimumSize(0, 25); tabControl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); topLayout->addWidget(tabControl); QFrame* topRightControls = new QFrame(topControls); topRightControls->setObjectName("TabTopRightControls"); topRightControls->setMinimumSize(6, 25); topRightControls->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); topLayout->addWidget(topRightControls); contentFrame = new QFrame(viewForm); contentFrame->setObjectName("ViewFormContentFrame"); contentFrame->installEventFilter(this); contentFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QVBoxLayout* contentFrameLayout = new QVBoxLayout(contentFrame); contentFrameLayout->setContentsMargins(0,0,0,0); contentFrameLayout->setSpacing(0); //contentFrame->setLayout(layout); layout->addWidget(contentFrame); this->connect(tabControl, SIGNAL(currentChanged(int)), this, SLOT(TabSelectionChanged(int))); this->connect(tabControl, SIGNAL(dragStarted(const QPoint&)), this, SLOT(DragStarted(const QPoint&))); //std::cout << "Created: viewForm <-- " << qPrintable(parent->objectName()); //for (parent = parent->parentWidget(); parent != 0; parent = parent->parentWidget()) // std::cout << " <-- " << qPrintable(parent->objectName()); //std::cout << std::endl; //parent = viewForm; //std::cout << "Created control: QCTabBar <-- " << qPrintable(parent->objectName()); //for (parent = parent->parentWidget(); parent != 0; parent = parent->parentWidget()) // std::cout << " <-- " << qPrintable(parent->objectName()); //std::cout << std::endl; //attachListeners(control, false); // viewForm = new ViewForm(control, SWT.FLAT); // attachListeners(viewForm, false); // systemToolbar = new StandardSystemToolbar(viewForm, true, false, true, true, true); // systemToolbar.addListener(systemToolbarListener); // viewForm.setTopRight(systemToolbar.getControl()); // // topCenter = new ProxyControl(viewForm); // topCenterCache = new SizeCache(); // // title = new CLabel(viewForm, SWT.LEFT); // attachListeners(title, false); // viewForm.setTopLeft(title); skinManager = Platform::GetServiceRegistry().GetServiceById(IQtStyleManager::ID); } NativeTabFolder::~NativeTabFolder() { if (!PlatformUI::GetWorkbench()->IsClosing()) { BERRY_DEBUG << "Deleting viewForm"; if (content != 0) { content->setParent(0); } viewForm->deleteLater(); } } bool NativeTabFolder::eventFilter(QObject* watched, QEvent* event) { if (event->type() == QEvent::MouseButtonPress) { QMouseEvent* mouseEvent = static_cast(event); this->HandleMousePress(mouseEvent->pos()); } return QObject::eventFilter(watched, event); } void NativeTabFolder::UpdateColors() { QString tabStyle = this->GetActive() == 1 ? skinManager->GetActiveTabStylesheet() : skinManager->GetTabStylesheet(); //tabControl->setStyleSheet(tabSkin); //contentFrame->setStyleSheet(tabSkin); viewForm->setStyleSheet(tabStyle); } void NativeTabFolder::SetActive(int activeState) { AbstractTabFolder::SetActive(activeState); this->UpdateColors(); } void NativeTabFolder::CloseButtonClicked(AbstractTabItem* item) { this->FireEvent(TabFolderEvent::EVENT_CLOSE, item); } QSize NativeTabFolder::ComputeSize(int /*widthHint*/, int /*heightHint*/) { return QSize(50,50); } AbstractTabItem* NativeTabFolder::Add(int index, int flags) { NativeTabItem* item = new NativeTabItem(this, index, flags); return item; } void NativeTabFolder::Move(int from, int to) { int tabCount = tabControl->count(); if (to > tabCount) to = tabCount; tabControl->moveAbstractTab(from, to); } void NativeTabFolder::Layout(bool flushCache) { AbstractTabFolder::Layout(flushCache); // QRect rect1 = tabControl->geometry(); // QRect rect2 = viewForm->geometry(); // std::cout << "QCTabBar geometry is: x=" << rect1.x() << ", y=" << rect1.y() << ", width=" << rect1.width() << ", height=" << rect1.height() << std::endl; // std::cout << "ViewForm geometry is: " << rect2.x() << ", y=" << rect2.y() << ", width=" << rect2.width() << ", height=" << rect2.height() << std::endl; // Rectangle oldBounds = viewForm.getBounds(); // Rectangle newBounds = control.getClientArea(); // // viewForm.setBounds(newBounds); // // if (Util.equals(oldBounds, newBounds)) // { // viewForm.layout(flushCache); // } } QPoint NativeTabFolder::GetPaneMenuLocation() { return AbstractTabFolder::GetPaneMenuLocation(); //return systemToolbar.getPaneMenuLocation(); } void NativeTabFolder::SetState(int state) { AbstractTabFolder::SetState(state); //systemToolbar.setState(state); } QRect NativeTabFolder::GetClientArea() { if (content == 0) { return QRect(); } return content->geometry(); } std::vector NativeTabFolder::GetItems() { return tabControl->getTabs(); } void NativeTabFolder::SetSelection(AbstractTabItem* toSelect) { if (toSelect == 0) { return; } tabControl->setCurrentTab(toSelect); } void NativeTabFolder::SetSelectedInfo(const PartInfo& /*info*/) { // if (!Util.equals(title.getText(), info.title)) // { // title.setText(info.title); // } // if (title.getImage() != info.image) // { // title.setImage(info.image); // } } QRect NativeTabFolder::GetTabArea() { return tabControl->geometry(); // Rectangle bounds = control.getBounds(); // // Rectangle clientArea = control.getClientArea(); // // bounds.x = 0; // bounds.y = 0; // Geometry.expand(bounds, 0, 0, -(clientArea.height + clientArea.y), 0); // // return Geometry.toDisplay(control.getParent(), bounds); } QWidget* NativeTabFolder::GetControl() { return viewForm; } bool NativeTabFolder::IsOnBorder(const QPoint& /*globalPos*/) { // Point localPos = getControl().toControl(globalPos); // // Rectangle clientArea = getClientArea(); // return localPos.y > clientArea.y && localPos.y < clientArea.y // + clientArea.height; return false; } AbstractTabItem* NativeTabFolder::GetSelection() { return tabControl->getCurrentTab(); } QWidget* NativeTabFolder::GetContentParent() { return contentFrame; } void NativeTabFolder::SetContent(QWidget* newContent) { //viewForm.setContent(newContent); if (content != 0) { contentFrame->layout()->removeWidget(content); disconnect(content); } content = newContent; content->installEventFilter(this); //((QBoxLayout*)contentFrame->layout())->addWidget(content, 1); contentFrame->layout()->addWidget(content); } QCTabBar* NativeTabFolder::GetTabFolder() { return tabControl; } void NativeTabFolder::SetSelectedTitle(const QString& /*newTitle*/) { //title.setText(newTitle); } void NativeTabFolder::SetSelectedImage(const QPixmap* /*image*/) { //title.setImage(image); } AbstractTabItem* NativeTabFolder::GetItem(const QPoint& toFind) { QPoint localPoint = tabControl->mapFromGlobal(toFind); int index = tabControl->tabAt(localPoint); if (index < 0) return 0; return tabControl->getTab(index); } void NativeTabFolder::EnablePaneMenu(bool /*enabled*/) { //systemToolbar.enablePaneMenu(enabled); } } diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp index be33f04826..90b0df926d 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.cpp @@ -1,168 +1,168 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryQtWorkbenchPresentationFactory.h" #include "berryNativeTabFolder.h" #include "berryEmptyTabFolder.h" #include "../util/berryPresentablePartFolder.h" #include "../util/berryTabbedStackPresentation.h" #include "../berryQtSash.h" -#include "../berryQtControlWidget.h" +#include #include namespace berry { QtWorkbenchPresentationFactory::QtWorkbenchPresentationFactory() {} QtWorkbenchPresentationFactory::QtWorkbenchPresentationFactory( const QtWorkbenchPresentationFactory& other) { } StackPresentation::Pointer QtWorkbenchPresentationFactory::CreateEditorPresentation( void* parent, IStackPresentationSite::Pointer site) { NativeTabFolder* folder = new NativeTabFolder(static_cast (parent)); // /* // * Set the minimum characters to display, if the preference is something // * other than the default. This is mainly intended for RCP applications // * or for expert users (i.e., via the plug-in customization file). // * // * Bug 32789. // */ // final IPreferenceStore store = PlatformUI.getPreferenceStore(); // if (store // .contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) { // final int minimumCharacters = store // .getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS); // if (minimumCharacters >= 0) { // folder.setMinimumCharacters(minimumCharacters); // } // } PresentablePartFolder* partFolder = new PresentablePartFolder(folder); StackPresentation::Pointer result(new TabbedStackPresentation(site, partFolder)); //, new StandardEditorSystemMenu(site)); // DefaultThemeListener themeListener = // new DefaultThemeListener(folder, result.getTheme()); // result.getTheme().addListener(themeListener); // // new DefaultMultiTabListener(result.getApiPreferences(), IWorkbenchPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder); // // new DefaultSimpleTabListener(result.getApiPreferences(), IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, folder); return result; } StackPresentation::Pointer QtWorkbenchPresentationFactory::CreateViewPresentation( void* parent, IStackPresentationSite::Pointer site) { NativeTabFolder* folder = new NativeTabFolder(static_cast (parent)); // final IPreferenceStore store = PlatformUI.getPreferenceStore(); // final int minimumCharacters = store // .getInt(IWorkbenchPreferenceConstants.VIEW_MINIMUM_CHARACTERS); // if (minimumCharacters >= 0) { // folder.setMinimumCharacters(minimumCharacters); // } PresentablePartFolder* partFolder = new PresentablePartFolder(folder); //folder->SetUnselectedCloseVisible(false); //folder->SetUnselectedImageVisible(true); StackPresentation::Pointer result(new TabbedStackPresentation(site, partFolder)); //, new StandardViewSystemMenu(site)); // DefaultThemeListener themeListener = // new DefaultThemeListener(folder, result.getTheme()); // result.getTheme().addListener(themeListener); // // new DefaultSimpleTabListener(result.getApiPreferences(), IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, folder); return result; } StackPresentation::Pointer QtWorkbenchPresentationFactory::CreateStandaloneViewPresentation( void* parent, IStackPresentationSite::Pointer site, bool showTitle) { if (showTitle) { return this->CreateViewPresentation(parent, site); } EmptyTabFolder* folder = new EmptyTabFolder(static_cast (parent), true); StackPresentation::Pointer presentation(new TabbedStackPresentation(site, folder)); //, new StandardViewSystemMenu(site)); return presentation; } std::string QtWorkbenchPresentationFactory::GetId() { return "berryQtWorkbenchPresentationFactory"; } void* QtWorkbenchPresentationFactory::CreateSash(void* parent, int style) { Qt::Orientation orientation = style & SASHORIENTATION_HORIZONTAL ? Qt::Horizontal : Qt::Vertical; QWidget* sash = new QtSash(orientation, static_cast (parent)); sash->setObjectName("Sash widget"); if (orientation == Qt::Horizontal) sash->setFixedHeight(this->GetSashSize(style)); else sash->setFixedWidth(this->GetSashSize(style)); return sash; } int QtWorkbenchPresentationFactory::GetSashSize(int /*style*/) { return 3; } void QtWorkbenchPresentationFactory::UpdateTheme() { QWidgetList topLevels = QApplication::topLevelWidgets(); QListIterator topIt(topLevels); while (topIt.hasNext()) { QWidget* topWidget = topIt.next(); QList folders = topWidget->findChildren (); QListIterator i(folders); while (i.hasNext()) { i.next()->UpdateColors(); } } } } diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp index 55c0e00112..187df577c4 100755 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/util/berryPresentablePartFolder.cpp @@ -1,436 +1,436 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryPresentablePartFolder.h" #include "berryAbstractTabItem.h" #include "../berryQtWidgetsTweaklet.h" -#include "../berryQtControlWidget.h" +#include #include #include namespace berry { PresentablePartFolder::ContentProxyListener::ContentProxyListener( PresentablePartFolder* folder) : folder(folder) { } GuiTk::IControlListener::Events::Types PresentablePartFolder::ContentProxyListener::GetEventTypes() const { return Events::MOVED & Events::RESIZED; } void PresentablePartFolder::ContentProxyListener::ControlMoved( GuiTk::ControlEvent::Pointer /*e*/) { folder->LayoutContent(); } void PresentablePartFolder::ContentProxyListener::ControlResized( GuiTk::ControlEvent::Pointer /*e*/) { } PresentablePartFolder::ShellListener::ShellListener(AbstractTabFolder* _folder) : folder(_folder) { } void PresentablePartFolder::ShellListener::ShellActivated(ShellEvent::Pointer /*e*/) { folder->ShellActive(true); } void PresentablePartFolder::ShellListener::ShellDeactivated( ShellEvent::Pointer /*e*/) { folder->ShellActive(false); } PresentablePartFolder::ChildPropertyChangeListener::ChildPropertyChangeListener( PresentablePartFolder* folder) : presentablePartFolder(folder) { } void PresentablePartFolder::ChildPropertyChangeListener::PropertyChange( Object::Pointer source, int property) { if (source.Cast () != 0) { IPresentablePart::Pointer part = source.Cast (); presentablePartFolder->ChildPropertyChanged(part, property); } } PartInfo PresentablePartFolder::tempPartInfo = PartInfo(); void PresentablePartFolder::LayoutContent() { if (current != 0) { Rectangle clientArea = DragUtil::GetDisplayBounds(contentProxy); Rectangle bounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->ToControl( folder->GetControl()->parentWidget(), clientArea); current->SetBounds(bounds); } } void PresentablePartFolder::InternalRemove(IPresentablePart::Pointer toRemove) { AbstractTabItem* item = this->GetTab(toRemove); if (item != 0) { item->Dispose(); } // do not use item anymore! if (std::find(partList.begin(), partList.end(), toRemove) != partList.end()) { toRemove->RemovePropertyListener(childPropertyChangeListener); partList.remove(toRemove); } } void PresentablePartFolder::ChildPropertyChanged( IPresentablePart::Pointer part, int property) { AbstractTabItem* tab = this->GetTab(part); if (property == IPresentablePart::PROP_HIGHLIGHT_IF_BACK) { if (tab != 0 && this->GetCurrent() != part) {//Set bold if it doesn't currently have focus tab->SetBold(true); this->InitTab(tab, part); } } // else if (property == IPresentablePart::PROP_TOOLBAR) // { // if (tab != 0 && this->GetCurrent() == part) // { // folder->FlushToolbarSize(); // } // if (tab != 0) // { // this->InitTab(tab, part); // if (this->GetCurrent() == part) // { // this->Layout(true); // } // } else if (property == IPresentablePart::PROP_CONTENT_DESCRIPTION || property == IPresentablePart::PROP_PANE_MENU || property == IPresentablePart::PROP_TITLE) { if (tab != 0) { this->InitTab(tab, part); if (this->GetCurrent() == part) { this->Layout(true); } } } else if (property == IPresentablePart::PROP_PREFERRED_SIZE) { TabFolderEvent::Pointer event( new TabFolderEvent(TabFolderEvent::EVENT_PREFERRED_SIZE, tab, 0, 0)); folder->FireEvent(event); } else { if (tab != 0) this->InitTab(tab, part); } } PresentablePartFolder::~PresentablePartFolder() { Tweaklets::Get(QtWidgetsTweaklet::KEY)->GetShell(folder->GetControl())->RemoveShellListener( shellListener); for (std::list::iterator iter = partList.begin(); iter != partList.end(); ++iter) { (*iter)->RemovePropertyListener(childPropertyChangeListener); } for (QWidget* currentWidget = contentProxy; currentWidget != 0 && currentWidget != folder->GetControl()->parentWidget(); currentWidget = currentWidget->parentWidget()) { Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(currentWidget, contentListener); } BERRY_DEBUG << "DELETING PresentablePartFolder and contentProxy\n"; delete folder; } void PresentablePartFolder::InitTab(AbstractTabItem* item, IPresentablePart::Pointer part) { tempPartInfo.Set(part); item->SetInfo(tempPartInfo); item->SetBusy(part->IsBusy()); if (part == this->GetCurrent()) { folder->SetSelectedInfo(tempPartInfo); //TODO Pane menu //folder->EnablePaneMenu(part->GetMenu() != 0); //setToolbar(part.getToolBar()); } } PresentablePartFolder::PresentablePartFolder(AbstractTabFolder* _folder) : folder(_folder), isVisible(true), shellListener(new ShellListener(folder)), childPropertyChangeListener(new ChildPropertyChangeListener(this)) { Shell::Pointer controlShell = Tweaklets::Get(QtWidgetsTweaklet::KEY)->GetShell(folder->GetControl()); controlShell->AddShellListener(shellListener); folder->ShellActive(Tweaklets::Get(QtWidgetsTweaklet::KEY)->GetActiveShell() == controlShell); //folder.getControl().addDisposeListener(tabDisposeListener); //toolbarProxy = new ProxyControl(folder.getToolbarParent()); // NOTE: if the shape of contentProxy changes, the fix for bug 85899 in EmptyTabFolder.computeSize may need adjustment. contentListener = new ContentProxyListener(this); contentProxy = new QtControlWidget(folder->GetContentParent(), 0); contentProxy->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //contentProxy->setVisible(false); for (QWidget* currentWidget = contentProxy; currentWidget != 0 && currentWidget != folder->GetControl()->parentWidget(); currentWidget = currentWidget->parentWidget()) { Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(currentWidget, contentListener); } folder->SetContent(contentProxy); } std::vector PresentablePartFolder::GetPartList() { std::vector items = folder->GetItems(); std::vector result; for (unsigned int i = 0; i < items.size(); i++) { result.push_back(this->GetPartForTab(items[i])); } return result; } void PresentablePartFolder::Insert(IPresentablePart::Pointer part, int idx) { poco_assert(folder->GetControl() != 0); if (this->GetTab(part) != 0) { if (this->IndexOf(part) != idx) this->Move(part, idx); return; } idx = std::min(idx, static_cast(folder->GetItemCount())); AbstractTabItem* item = 0; int style = 0; if (part->IsCloseable()) { style |= Constants::CLOSE; } item = folder->Add(idx, style); item->SetData(part); this->InitTab(item, part); part->AddPropertyListener(childPropertyChangeListener); partList.push_back(part); } void PresentablePartFolder::Remove(IPresentablePart::Pointer toRemove) { if (toRemove == current) { this->Select(IPresentablePart::Pointer(0)); } this->InternalRemove(toRemove); } void PresentablePartFolder::Move(IPresentablePart::Pointer part, int newIndex) { int currentIndex = this->IndexOf(part); if (currentIndex == newIndex) { return; } folder->Move(currentIndex, newIndex); //this->InternalRemove(part); //this->Insert(part, newIndex); //if (current == part) //{ // folder->SetSelection(this->GetTab(part)); //} } std::size_t PresentablePartFolder::Size() { return folder->GetItemCount(); } void PresentablePartFolder::SetBounds(const QRect& bounds) { QSize minSize = folder->ComputeSize(bounds.width(), Constants::DEFAULT); QRect newBounds(bounds); if (folder->GetState() == IStackPresentationSite::STATE_MINIMIZED && minSize.height() < bounds.height()) { newBounds.setHeight(minSize.height()); } // Set the tab folder's bounds folder->GetControl()->setGeometry(newBounds); this->Layout(false); } void PresentablePartFolder::Select(IPresentablePart::Pointer toSelect) { if (toSelect == current) { return; } if (toSelect != 0) { toSelect->SetVisible(true); } if (current != 0) { current->SetVisible(false); //setToolbar(null); } current = toSelect; AbstractTabItem* selectedItem = this->GetTab(toSelect); folder->SetSelection(selectedItem); if (selectedItem != 0) { // Determine if we need to un-bold this tab selectedItem->SetBold(false); this->InitTab(selectedItem, toSelect); } // else // { // setToolbar(null); // } this->Layout(true); } IPresentablePart::Pointer PresentablePartFolder::GetPartForTab( AbstractTabItem* tab) { if (tab == 0) { return IPresentablePart::Pointer(0); } IPresentablePart::Pointer part = tab->GetData().Cast (); return part; } AbstractTabItem* PresentablePartFolder::GetTab(IPresentablePart::Pointer part) { return folder->FindItem(part); } int PresentablePartFolder::IndexOf(IPresentablePart::Pointer part) { AbstractTabItem* item = this->GetTab(part); if (item == 0) { return -1; } return folder->IndexOf(item); } AbstractTabFolder* PresentablePartFolder::GetTabFolder() { return folder; } void PresentablePartFolder::SetVisible(bool isVisible) { this->isVisible = isVisible; this->GetTabFolder()->SetVisible(isVisible); if (isVisible) { this->Layout(true); } } void PresentablePartFolder::Layout(bool changed) { if (!isVisible) { // Don't bother with layout if we're not visible return; } // Lay out the tab folder and compute the client area folder->Layout(changed); //toolbarProxy.layout(); this->LayoutContent(); } IPresentablePart::Pointer PresentablePartFolder::GetCurrent() { return current; } } diff --git a/BlueBerry/Bundles/org.blueberry.ui/documentation/doxygen/modules.dox b/BlueBerry/Bundles/org.blueberry.ui/documentation/doxygen/modules.dox index 743dae86b2..8c3525ed7b 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/documentation/doxygen/modules.dox +++ b/BlueBerry/Bundles/org.blueberry.ui/documentation/doxygen/modules.dox @@ -1,17 +1,17 @@ /** - \defgroup org_blueberry_ui org.blueberry.ui Plugin + \defgroup org_blueberry_ui org.blueberry.ui \ingroup BlueBerryPlugins \brief This is the user interface plugin. It provides a GUI-Toolkit independent framework to build an BlueBerry workbench. */ /** \defgroup org_blueberry_ui_internal Internal \ingroup org_blueberry_ui \brief This subcategory includes the internal classes of the org.blueberry.ui plugin. Other plugins must not rely on these classes. They contain implementation details and their interface may change at any time. We mean it. */ \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/files.cmake b/BlueBerry/Bundles/org.blueberry.ui/files.cmake index e11cedbf06..756f8586ea 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.ui/files.cmake @@ -1,231 +1,235 @@ SET(MOC_H_FILES src/internal/berryWorkbenchPlugin.h src/internal/intro/berryEditorIntroAdapterPart.h src/berryWorkbenchPart.h src/berryEditorPart.h src/berryViewPart.h src/intro/berryIntroPart.h ) SET(CACHED_RESOURCE_FILES plugin.xml ) SET(SRC_CPP_FILES berryAbstractSourceProvider.cpp berryAbstractUIPlugin.cpp berryAbstractUICTKPlugin.cpp berryConstants.cpp berryDisplay.cpp berryEditorPart.cpp berryFileEditorInput.cpp berryGeometry.cpp + berryIDropTargetListener.cpp berryIEditorRegistry.cpp berryImageDescriptor.cpp berryIMemento.cpp berryIPageLayout.cpp berryIPartListener.cpp berryIPerspectiveListener.cpp berryIPropertyChangeListener.cpp berryISaveablePart.cpp berryISaveablesLifecycleListener.cpp berryISelectionChangedListener.cpp berryISelectionListener.cpp berryIShellListener.cpp berryISizeProvider.cpp berryISourceProviderListener.cpp berryISources.cpp berryIStructuredSelection.cpp berryIWindowListener.cpp berryIWorkbenchListener.cpp berryIWorkbenchPage.cpp berryIWorkbenchPartConstants.cpp berryPlatformUI.cpp berryPoint.cpp berryPropertyChangeEvent.cpp berryRectangle.cpp berrySameShellProvider.cpp berrySaveable.cpp berrySaveablesLifecycleEvent.cpp berrySelectionChangedEvent.cpp berryShell.cpp berryShellEvent.cpp berryUIException.cpp berryViewPart.cpp berryWindow.cpp berryWorkbenchPart.cpp berryWorkbenchPreferenceConstants.cpp berryXMLMemento.cpp #application application/berryActionBarAdvisor.cpp application/berryWorkbenchAdvisor.cpp application/berryWorkbenchWindowAdvisor.cpp #commands #commands/berryAbstractContributionFactory.cpp #commands/berryCommandContributionItem.cpp #commands/berryCommandContributionItemParameter.cpp #commands/berryContributionItem.cpp #commands/berryContributionManager.cpp #commands/berryICommandImageService.cpp #commands/berryICommandService.cpp #commands/berryIContributionManagerOverrides.cpp #commands/berryIMenuItem.cpp #commands/berryIMenuItemListener.cpp #commands/berryIMenuListener.cpp #commands/berryIToolItemListener.cpp #commands/berryIUIElementListener.cpp #commands/berryMenuManager.cpp #commands/berrySubContributionItem.cpp #commands/berryUIElement.cpp #dialogs dialogs/berryIDialog.cpp dialogs/berryMessageDialog.cpp #guitk guitk/berryGuiTkControlEvent.cpp guitk/berryGuiTkEvent.cpp guitk/berryGuiTkIControlListener.cpp guitk/berryGuiTkIMenuListener.cpp guitk/berryGuiTkISelectionListener.cpp guitk/berryGuiTkSelectionEvent.cpp #handlers handlers/berryHandlerUtil.cpp handlers/berryIHandlerActivation.cpp handlers/berryShowViewHandler.cpp #src intro/berryIntroPart.cpp #tweaklets tweaklets/berryDnDTweaklet.cpp tweaklets/berryGuiWidgetsTweaklet.cpp tweaklets/berryImageTweaklet.cpp tweaklets/berryMessageDialogTweaklet.cpp tweaklets/berryWorkbenchPageTweaklet.cpp tweaklets/berryWorkbenchTweaklet.cpp #presentations presentations/berryIPresentablePart.cpp presentations/berryIPresentationFactory.cpp presentations/berryIStackPresentationSite.cpp presentations/berryStackDropResult.cpp presentations/berryStackPresentation.cpp #testing testing/berryTestableObject.cpp #util util/berrySafeRunnable.cpp ) SET(INTERNAL_CPP_FILES #intro intro/berryEditorIntroAdapterPart.cpp intro/berryIntroConstants.cpp intro/berryIntroDescriptor.cpp intro/berryIntroPartAdapterSite.cpp intro/berryIntroRegistry.cpp intro/berryViewIntroAdapterPart.cpp intro/berryWorkbenchIntroManager.cpp berryAbstractPartSelectionTracker.cpp berryAbstractSelectionService.cpp berryBundleUtility.cpp berryContainerPlaceholder.cpp berryDetachedPlaceHolder.cpp berryDefaultSaveable.cpp berryDefaultStackPresentationSite.cpp berryDetachedWindow.cpp berryDragUtil.cpp berryEditorAreaHelper.cpp berryEditorDescriptor.cpp berryEditorManager.cpp berryEditorReference.cpp berryEditorRegistry.cpp berryEditorRegistryReader.cpp berryEditorSashContainer.cpp berryEditorSite.cpp berryErrorViewPart.cpp berryFileEditorMapping.cpp berryFolderLayout.cpp berryIDragOverListener.cpp berryLayoutHelper.cpp berryLayoutPart.cpp berryLayoutPartSash.cpp berryLayoutTree.cpp berryLayoutTreeNode.cpp berryNullEditorInput.cpp berryPageLayout.cpp berryPagePartSelectionTracker.cpp berryPageSelectionService.cpp berryPartList.cpp berryPartPane.cpp berryPartPlaceholder.cpp berryPartSashContainer.cpp berryPartService.cpp berryPartSite.cpp berryPartStack.cpp berryPartTester.cpp berryPerspective.cpp berryPerspectiveDescriptor.cpp berryPerspectiveExtensionReader.cpp berryPerspectiveHelper.cpp berryPerspectiveRegistry.cpp berryPerspectiveRegistryReader.cpp berryPlaceholderFolderLayout.cpp berryPreferenceConstants.cpp berryPresentablePart.cpp berryPresentationFactoryUtil.cpp berryPresentationSerializer.cpp + berryQtControlWidget.cpp + berryQtDnDControlWidget.cpp + berryQtWidgetController.cpp berryRegistryReader.cpp berrySaveablesList.cpp berryServiceLocator.cpp berryServiceLocatorCreator.cpp berryShellPool.cpp berrySourcePriorityNameMapping.cpp berryStackablePart.cpp berryStickyViewDescriptor.cpp berryStickyViewManager.cpp berryTweaklets.cpp berryViewDescriptor.cpp berryViewFactory.cpp berryViewLayout.cpp berryViewReference.cpp berryViewRegistry.cpp berryViewRegistryReader.cpp berryViewSashContainer.cpp berryViewSite.cpp berryWorkbenchPage.cpp berryWindowManager.cpp berryWindowPartSelectionTracker.cpp berryWindowSelectionService.cpp berryWorkbench.cpp berryWorkbenchConfigurer.cpp berryWorkbenchConstants.cpp berryWorkbenchPagePartList.cpp berryWorkbenchPartReference.cpp berryWorkbenchPlugin.cpp berryWorkbenchRegistryConstants.cpp berryWorkbenchServiceRegistry.cpp berryWorkbenchTestable.cpp berryWorkbenchWindow.cpp berryWorkbenchWindowConfigurer.cpp berryWWinPartService.cpp ) SET(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) SET(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h index faed1a6a07..b088b2c567 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/application/berryIWorkbenchWindowConfigurer.h @@ -1,376 +1,375 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYIWORKBENCHWINDOWCONFIGURER_H_ #define BERRYIWORKBENCHWINDOWCONFIGURER_H_ #include #include #include "../berryShell.h" #include "../berryIMemento.h" #include "../berryPoint.h" +#include "../berryIDropTargetListener.h" namespace berry { struct IWorkbenchConfigurer; struct IWorkbenchWindow; /** * Interface providing special access for configuring workbench windows. *

* %Window configurer objects are in 1-1 correspondence with the workbench * windows they configure. Clients may use Get/SetData to * associate arbitrary state with the window configurer object. *

*

* Note that these objects are only available to the main application * (the plug-in that creates and owns the workbench). *

*

* This interface is not intended to be implemented by clients. *

* * @see IWorkbenchConfigurer#GetWindowConfigurer() * @see WorkbenchAdvisor#PreWindowOpen() * @note This interface is not intended to be implemented by clients. */ struct BERRY_UI IWorkbenchWindowConfigurer : public Object { berryInterfaceMacro(IWorkbenchWindowConfigurer, berry); /** * Returns the underlying workbench window. * * @return the workbench window */ virtual SmartPointer GetWindow() = 0; /** * Returns the workbench configurer. * * @return the workbench configurer */ virtual SmartPointer GetWorkbenchConfigurer() = 0; /* * Returns the action bar configurer for this workbench * window. * * @return the action bar configurer */ //virtual IActionBarConfigurer GetActionBarConfigurer() = 0; /** * Returns the title of the underlying workbench window. * * @return the window title */ virtual std::string GetTitle() = 0; /** * Sets the title of the underlying workbench window. * * @param title the window title */ virtual void SetTitle(const std::string& title) = 0; /** * Returns whether the underlying workbench window has a menu bar. *

* The initial value is true. *

* * @return true for a menu bar, and false * for no menu bar */ virtual bool GetShowMenuBar() = 0; /** * Sets whether the underlying workbench window has a menu bar. * * @param show true for a menu bar, and false * for no menu bar */ virtual void SetShowMenuBar(bool show) = 0; /** * Returns whether the underlying workbench window has a cool bar. *

* The initial value is true. *

* * @return true for a cool bar, and false * for no cool bar */ virtual bool GetShowCoolBar() = 0; /** * Sets whether the underlying workbench window has a cool bar. * * @param show true for a cool bar, and false * for no cool bar */ virtual void SetShowCoolBar(bool show) = 0; /** * Returns whether the underlying workbench window has a status line. *

* The initial value is true. *

* * @return true for a status line, and false * for no status line */ virtual bool GetShowStatusLine() = 0; /** * Sets whether the underlying workbench window has a status line. * * @param show true for a status line, and false * for no status line */ virtual void SetShowStatusLine(bool show) = 0; /** * Returns whether the underlying workbench window has a perspective bar (the * perspective bar provides buttons to quickly switch between perspectives). *

* The initial value is false. *

* * @return true for a perspective bar, and false * for no perspective bar */ virtual bool GetShowPerspectiveBar() = 0; /** * Sets whether the underlying workbench window has a perspective bar (the * perspective bar provides buttons to quickly switch between perspectives). * * @param show true for a perspective bar, and * false for no perspective bar */ virtual void SetShowPerspectiveBar(bool show) = 0; /** * Returns whether the underlying workbench window has a progress indicator. *

* The initial value is false. *

* * @return true for a progress indicator, and false * for no progress indicator */ virtual bool GetShowProgressIndicator() = 0; /** * Sets whether the underlying workbench window has a progress indicator. * * @param show true for a progress indicator, and false * for no progress indicator */ virtual void SetShowProgressIndicator(bool show) = 0; /** * Returns the style bits to use for the window's shell when it is created. * The default is SWT.SHELL_TRIM. * * @return the shell style bits */ virtual int GetShellStyle() = 0; /** * Sets the style bits to use for the window's shell when it is created. * This method has no effect after the shell is created. * That is, it must be called within the WorkbenchAdvisor#PreWindowOpen() * callback. *

* For more details on the applicable shell style bits, see the * documentation for Shell. *

* * @param shellStyle the shell style bits */ virtual void SetShellStyle(int shellStyle) = 0; /** * Returns the size to use for the window's shell when it is created. * * @return the initial size to use for the shell */ virtual Point GetInitialSize() = 0; /** * Sets the size to use for the window's shell when it is created. * This method has no effect after the shell is created. * That is, it must be called within the WorkbenchAdvisor#PreWindowOpen() * callback. * * @param initialSize the initial size to use for the shell */ virtual void SetInitialSize(Point initialSize) = 0; /* * Returns the data associated with this workbench window at the given key. * * @param key the key * @return the data, or null if there is no data at the given * key */ //virtual Object getData(String key); /* * Sets the data associated with this workbench window at the given key. * * @param key the key * @param data the data, or null to delete existing data */ //virtual void setData(String key, Object data); - /* - * Adds the given drag and drop Transfer type to the ones + /** + * Adds the given drag and drop Mime types to the ones * supported for drag and drop on the editor area of this workbench window. *

* The workbench advisor would ordinarily call this method from the - * preWindowOpen callback. + * PreWindowOpen callback. * A newly-created workbench window supports no drag and drop transfer - * types. Adding EditorInputTransfer.getInstance() - * enables IEditorInputs to be transferred. + * types. *

*

* Note that drag and drop to the editor area requires adding one or more - * transfer types (using addEditorAreaTransfer) and + * transfer types (using AddEditorAreaTransfer) and * configuring a drop target listener - * (with configureEditorAreaDropListener) + * (with ConfigureEditorAreaDropListener) * capable of handling any of those transfer types. *

* * @param transfer a drag and drop transfer object * @see #configureEditorAreaDropListener * @see org.blueberry.ui.part.EditorInputTransfer */ - //virtual void addEditorAreaTransfer(Transfer transfer); + virtual void AddEditorAreaTransfer(const QStringList& transferTypes) = 0; - /* + /** * Configures the drop target listener for the editor area of this workbench window. *

* The workbench advisor ordinarily calls this method from the - * preWindowOpen callback. + * PreWindowOpen callback. * A newly-created workbench window has no configured drop target listener for its * editor area. *

*

* Note that drag and drop to the editor area requires adding one or more - * transfer types (using addEditorAreaTransfer) and + * transfer types (using AddEditorAreaTransfer) and * configuring a drop target listener - * (with configureEditorAreaDropListener) + * (with ConfigureEditorAreaDropListener) * capable of handling any of those transfer types. *

* * @param dropTargetListener the drop target listener that will handle * requests to drop an object on to the editor area of this window * - * @see #addEditorAreaTransfer + * @see #AddEditorAreaTransfer */ - //virtual void configureEditorAreaDropListener( - // DropTargetListener dropTargetListener); + virtual void ConfigureEditorAreaDropListener(const IDropTargetListener::Pointer& dropTargetListener) = 0; /* * Creates the menu bar for the window's shell. *

* This should only be called if the advisor is defining custom window contents * in createWindowContents, and may only be called once. * The caller must set it in the shell using Shell.setMenuBar(Menu) * but must not make add, remove or change items in the result. * The menu bar is populated by the window's menu manager. * The application can add to the menu manager in the advisor's * fillActionBars method instead. *

* * @return the menu bar, suitable for setting in the shell */ //virtual Menu createMenuBar(); /* * Creates the cool bar control. *

* This should only be called if the advisor is defining custom window contents * in createWindowContents, and may only be called once. * The caller must lay out the cool bar appropriately within the parent, * but must not add, remove or change items in the result (hence the * return type of Control). * The cool bar is populated by the window's cool bar manager. * The application can add to the cool bar manager in the advisor's * fillActionBars method instead. *

* * @param parent the parent composite * @return the cool bar control, suitable for laying out in the parent */ //virtual Control createCoolBarControl(Composite parent); /* * Creates the status line control. *

* This should only be called if the advisor is defining custom window contents * in createWindowContents, and may only be called once. * The caller must lay out the status line appropriately within the parent, * but must not add, remove or change items in the result (hence the * return type of Control). * The status line is populated by the window's status line manager. * The application can add to the status line manager in the advisor's * fillActionBars method instead. *

* * @param parent the parent composite * @return the status line control, suitable for laying out in the parent */ //virtual Control createStatusLineControl(Composite parent); /** * Creates the page composite, in which the window's pages, and their * views and editors, appear. *

* This should only be called if the advisor is defining custom window contents * in WorkbenchWindowAdvisor#CreateWindowContents(), and may only be called once. * The caller must lay out the page composite appropriately within the parent, * but must not add, remove or change items in the result. * The page composite is populated by the workbench. *

* * @param parent the parent composite * @return the page composite, suitable for laying out in the parent */ virtual void* CreatePageComposite(void* parent) = 0; /** * Saves the current state of the window using the specified memento. * * @param memento the memento in which to save the window's state * @return a status object indicating whether the save was successful * @see IWorkbenchConfigurer#RestoreWorkbenchWindow(IMemento::Pointer) */ virtual bool SaveState(IMemento::Pointer memento) = 0; }; } #endif /*BERRYIWORKBENCHWINDOWCONFIGURER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.cpp new file mode 100644 index 0000000000..47185c7dee --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.cpp @@ -0,0 +1,49 @@ +/*========================================================================= + +Program: BlueBerry Platform +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "berryIDropTargetListener.h" + +namespace berry { + +void IDropTargetListener::Events::AddListener(IDropTargetListener* l) +{ + if (l == 0) return; + + Types t = l->GetDropTargetEventTypes(); + + if (t & ENTER) + dragEnter += DragEnterDelegate(l, &IDropTargetListener::DragEnterEvent); + if (t & LEAVE) + dragLeave += DragLeaveDelegate(l, &IDropTargetListener::DragLeaveEvent); + if (t & MOVE) + dragMove += DragMoveDelegate(l, &IDropTargetListener::DragMoveEvent); + if (t & DROP) + drop += DropDelegate(l, &IDropTargetListener::DropEvent); +} + +void IDropTargetListener::Events::RemoveListener(IDropTargetListener* l) +{ + if (l == 0) return; + + dragEnter -= DragEnterDelegate(l, &IDropTargetListener::DragEnterEvent); + dragLeave -= DragLeaveDelegate(l, &IDropTargetListener::DragLeaveEvent); + dragMove -= DragMoveDelegate(l, &IDropTargetListener::DragMoveEvent); + drop -= DropDelegate(l, &IDropTargetListener::DropEvent); +} + +} diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.h new file mode 100644 index 0000000000..fb415dacd7 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIDropTargetListener.h @@ -0,0 +1,86 @@ +/*========================================================================= + +Program: BlueBerry Platform +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef BERRYIDROPTARGETLISTENER_H +#define BERRYIDROPTARGETLISTENER_H + +#include +#include + +#include + + +class QDragEnterEvent; +class QDragLeaveEvent; +class QDragMoveEvent; +class QDropEvent; + +namespace berry { + +struct BERRY_UI IDropTargetListener : public Object { + + berryInterfaceMacro(IDropTargetListener, berry); + + struct Events { + + enum Type { + NONE = 0x00000000, + ENTER = 0x00000001, + LEAVE = 0x00000002, + MOVE = 0x00000004, + DROP = 0x00000008, + + ALL = 0xffffffff + }; + + Q_DECLARE_FLAGS(Types, Type) + + typedef Message1 DragEnterEventType; + typedef Message1 DragLeaveEventType; + typedef Message1 DragMoveEventType; + typedef Message1 DropEventType; + + DragEnterEventType dragEnter; + DragLeaveEventType dragLeave; + DragMoveEventType dragMove; + DropEventType drop; + + void AddListener(IDropTargetListener* listener); + void RemoveListener(IDropTargetListener* listener); + + private: + typedef MessageDelegate1 DragEnterDelegate; + typedef MessageDelegate1 DragLeaveDelegate; + typedef MessageDelegate1 DragMoveDelegate; + typedef MessageDelegate1 DropDelegate; + }; + + virtual Events::Types GetDropTargetEventTypes() const = 0; + + virtual void DragEnterEvent(QDragEnterEvent* /*event*/) {} + virtual void DragLeaveEvent(QDragLeaveEvent* /*event*/) {} + virtual void DragMoveEvent(QDragMoveEvent* /*event*/) {} + virtual void DropEvent(QDropEvent* /*event*/) {} + +}; + +} + +Q_DECLARE_OPERATORS_FOR_FLAGS(berry::IDropTargetListener::Events::Types) + +#endif // BERRYIDROPTARGETLISTENER_H diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h index cce6986567..3715834d05 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIEditorRegistry.h @@ -1,288 +1,288 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKIEDITORREGISTRY_H_ #define MITKIEDITORREGISTRY_H_ #include #include #include "berryIEditorDescriptor.h" #include "berryIFileEditorMapping.h" namespace berry { /** * \ingroup org_blueberry_ui * * Registry of editors known to the workbench. *

* An editor can be created in one of two ways: *

    *
  • An editor can be defined by an extension to the workbench.
  • *
  • The user manually associates an editor with a given resource extension * type. This will override any default workbench or platform association. *
  • *
*

*

* The registry does not keep track of editors that are "implicitly" determined. * For example a bitmap (.bmp) file will typically not have a * registered editor. Instead, when no registered editor is found, the * underlying OS is consulted. *

*

* This interface is not intended to be implemented by clients. *

* * @see org.blueberry.ui.IWorkbench#getEditorRegistry() * @noimplement This interface is not intended to be implemented by clients. */ struct BERRY_UI IEditorRegistry { /** * The property identifier for the contents of this registry. */ static const int PROP_CONTENTS; // = 0x01; /** * The identifier for the system external editor descriptor. This descriptor * is always present in the registry on all platforms. * This editor requires an input which implements * {@link org.blueberry.ui.IPathEditorInput IPathEditorInput}. * Use {@link #findEditor findEditor} to access the editor descriptor for * this identifier. * * @since 3.0 */ static const std::string SYSTEM_EXTERNAL_EDITOR_ID; // = "org.blueberry.ui.systemExternalEditor"; //$NON-NLS-1$ /** * The identifier for the system in-place editor descriptor. This descriptor * is only present in the registry on platforms that support in-place editing * (for example Win32). This editor requires an input which implements * {@link org.blueberry.ui.IInPlaceEditorInput IInPlaceEditorInput}. Use * {@link #findEditor findEditor} to access the editor descriptor for this * identifier. * * @since 3.0 */ static const std::string SYSTEM_INPLACE_EDITOR_ID; // = "org.blueberry.ui.systemInPlaceEditor"; //$NON-NLS-1$ - /** + /* * Adds a listener for changes to properties of this registry. * Has no effect if an identical listener is already registered. *

* The properties ids are as follows: *

    *
  • PROP_CONTENTS: Triggered when the file editor mappings in * the editor registry change.
  • *
*

* * @param listener a property listener */ // virtual void AddPropertyListener(IPropertyListener listener) = 0; virtual ~IEditorRegistry(); /** * Finds and returns the descriptor of the editor with the given editor id. * * @param editorId the editor id * @return the editor descriptor with the given id, or null if not * found */ virtual IEditorDescriptor::Pointer FindEditor(const std::string& editorId) = 0; /** * Returns the default editor. The default editor always exist. * * @return the descriptor of the default editor * @deprecated The system external editor is the default editor. * Use findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID) * instead. */ virtual IEditorDescriptor::Pointer GetDefaultEditor() = 0; /** * Returns the default editor for a given file name. This method assumes an * unknown content type for the given file. *

* The default editor is determined by taking the file extension for the * file and obtaining the default editor for that extension. *

* * @param fileName * the file name in the system * @return the descriptor of the default editor, or null if * not found */ virtual IEditorDescriptor::Pointer GetDefaultEditor(const std::string& fileName) = 0; - /** + /* * Returns the default editor for a given file name and with the given content type. *

* The default editor is determined by taking the file extension for the * file and obtaining the default editor for that extension. *

* * @param fileName the file name in the system * @param contentType the content type or null for the unknown content type * @return the descriptor of the default editor, or null if not * found * @since 3.1 */ //virtual IEditorDescriptor::Pointer GetDefaultEditor(const std::string& fileName, IContentType contentType) = 0; - /** + /** * Returns the list of file editors registered to work against the file with * the given file name. This method assumes an unknown content type for the * given file. *

* Note: Use getDefaultEditor(String) if you only the need * the default editor rather than all candidate editors. *

* * @param fileName * the file name in the system * @return a list of editor descriptors */ - virtual std::list GetEditors(const std::string& fileName) = 0; + virtual std::list GetEditors(const std::string& fileName) = 0; - /** + /* * Returns the list of file editors registered to work against the file with * the given file name and with the given content type. *

* Note: Use getDefaultEditor(String) if you only the need * the default editor rather than all candidate editors. *

* * @param fileName * the file name in the system * @param contentType * the content type or null for the unknown * content type * @return a list of editor descriptors * @since 3.1 */ //virtual std::vector GetEditors(const std::string& fileName, IContentType contentType) = 0; /** * Returns a list of mappings from file type to editor. The resulting list * is sorted in ascending order by file extension. *

* Each mapping defines an extension and the set of editors that are * available for that type. The set of editors includes those registered * via plug-ins and those explicitly associated with a type by the user * in the workbench preference pages. *

* * @return a list of mappings sorted alphabetically by extension */ virtual std::vector GetFileEditorMappings() = 0; - /** + /* * Returns the image descriptor associated with a given file. This image is * usually displayed next to the given file. This method assumes an unknown * content type for the given file. *

* The image is determined by taking the file extension of the file and * obtaining the image for the default editor associated with that * extension. A default image is returned if no default editor is available. *

* * @param filename * the file name in the system * @return the descriptor of the image to display next to the file */ // virtual ImageDescriptor* GetImageDescriptor(const std::string& filename) = 0; - /** + /* * Returns the image descriptor associated with a given file. This image is * usually displayed next to the given file. *

* The image is determined by taking the file extension of the file and * obtaining the image for the default editor associated with that * extension. A default image is returned if no default editor is available. *

* * @param filename * the file name in the system * @param contentType * the content type of the file or null for the * unknown content type * @return the descriptor of the image to display next to the file * @since 3.1 */ // virtual ImageDescriptor* GetImageDescriptor(const std::tring& filename, IContentType contentType) = 0; - /** + /* * Removes the given property listener from this registry. * Has no affect if an identical listener is not registered. * * @param listener a property listener */ // virtual void RemovePropertyListener(IPropertyListener listener) = 0; /** * Sets the default editor id for the files that match that * specified file name or extension. The specified editor must be * defined as an editor for that file name or extension. * * @param fileNameOrExtension the file name or extension pattern (e.g. "*.xml"); * @param editorId the editor id or null for no default */ virtual void SetDefaultEditor(const std::string& fileNameOrExtension, const std::string& editorId) = 0; /** * Returns whether there is an in-place editor that could handle a file * with the given name. * * @param filename the file name * @return true if an in-place editor is available, and * false otherwise * @since 3.0 */ virtual bool IsSystemInPlaceEditorAvailable(const std::string& filename) = 0; /** * Returns whether the system has an editor that could handle a file * with the given name. * * @param filename the file name * @return true if an external editor available, and * false otherwise * @since 3.0 */ virtual bool IsSystemExternalEditorAvailable(const std::string& filename) = 0; - /** + /* * Returns the image descriptor associated with the system editor that * would be used to edit this file externally. * * @param filename the file name * @return the descriptor of the external editor image, or null * if none * @since 3.0 */ // virtual ImageDescriptor GetSystemExternalEditorImageDescriptor(const std::string& filename) = 0; }; } #endif /*MITKIEDITORREGISTRY_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp index 0dc26c9e9f..3ef751e5de 100755 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.cpp @@ -1,597 +1,610 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryEditorSashContainer.h" #include "berryPresentationSerializer.h" #include "berryWorkbenchConstants.h" #include "berryWorkbenchPlugin.h" #include "berryLayoutTree.h" +#include "berryWorkbenchWindowConfigurer.h" +#include "berryWorkbenchWindow.h" +#include "berryQtDnDControlWidget.h" + #include "../tweaklets/berryGuiWidgetsTweaklet.h" #include #include namespace berry { const std::string EditorSashContainer::DEFAULT_WORKBOOK_ID = "DefaultEditorWorkbook"; void EditorSashContainer::AddChild(const RelationshipInfo& info) { PartSashContainer::AddChild(info); this->UpdateStackButtons(); } void EditorSashContainer::ChildAdded(LayoutPart::Pointer child) { PartSashContainer::ChildAdded(child); if (child.Cast () != 0) { editorWorkbooks.push_back(child.Cast ()); } } void EditorSashContainer::ChildRemoved(LayoutPart::Pointer child) { PartSashContainer::ChildRemoved(child); if (child.Cast () != 0) { editorWorkbooks.remove(child.Cast()); if (activeEditorWorkbook == child) { this->SetActiveWorkbook(PartStack::Pointer(0), false); } this->UpdateStackButtons(); } } PartStack::Pointer EditorSashContainer::CreateDefaultWorkbook() { PartStack::Pointer newWorkbook = this->NewEditorWorkbook(); newWorkbook->SetID(DEFAULT_WORKBOOK_ID); this->Add(newWorkbook); return newWorkbook; } +void EditorSashContainer::AddDropSupport() +{ + WorkbenchWindowConfigurer::Pointer winConfigurer = page->GetWorkbenchWindow().Cast()->GetWindowConfigurer(); + + QtDnDControlWidget* dropWidget = static_cast(GetParent()); + dropWidget->SetTransferTypes(winConfigurer->GetTransfers()); + dropWidget->AddDropListener(winConfigurer->GetDropTargetListener().GetPointer()); +} + PartStack::Pointer EditorSashContainer::NewEditorWorkbook() { PartStack::Pointer newWorkbook(new PartStack(page, true, PresentationFactoryUtil::ROLE_EDITOR)); std::stringstream buf; buf << newWorkbook->GetClassName() << newWorkbook.GetPointer(); newWorkbook->SetID(buf.str()); return newWorkbook; } void* EditorSashContainer::CreateParent(void* parentWidget) { - return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateComposite(parentWidget); + //return Tweaklets::Get(GuiWidgetsTweaklet::KEY)->CreateComposite(parentWidget); + return new QtDnDControlWidget(static_cast(parentWidget)); } void EditorSashContainer::DisposeParent() { this->parent = 0; } bool EditorSashContainer::IsActiveWorkbook(PartStack::Pointer workbook) { return activeEditorWorkbook == workbook; } PartStack::Pointer EditorSashContainer::CreateStack() { return this->NewEditorWorkbook(); } void EditorSashContainer::SetVisiblePart( IStackableContainer::Pointer container, PartPane::Pointer visiblePart) { PartStack::Pointer stack = container.Cast(); if (stack == 0) return; stack->GetContainer().Cast()->SetActiveWorkbook(stack, true); stack->SetSelection(visiblePart); } StackablePart::Pointer EditorSashContainer::GetVisiblePart( IStackableContainer::Pointer container) { PartStack::Pointer refPart = container.Cast(); return refPart->GetSelection(); } EditorSashContainer::EditorSashContainer(const std::string& editorId, WorkbenchPage* page, void* parent) : PartSashContainer(editorId, page, parent) { this->CreateDefaultWorkbook(); } bool EditorSashContainer::AllowsAdd(LayoutPart::Pointer layoutPart) { return LayoutPart::AllowsAdd(layoutPart); } void EditorSashContainer::AddEditor(PartPane::Pointer pane, PartStack::Pointer stack) { //EditorStack workbook = getActiveWorkbook(); stack->Add(pane); } void EditorSashContainer::UpdateStackButtons() { // // This is applicable only when the new // // min/max behaviour is being used // Perspective persp = getPage().getActivePerspective(); // if (!Perspective.useNewMinMax(persp)) // return; // // // Find the upper Right editor stack // LayoutPart[] stacks = getChildren(); // EditorStack winner = getUpperRightEditorStack(stacks); // // // Now hide the buttons for all but the upper right stack // for (int i = 0; i < stacks.length; i++) // { // if (!(stacks[i] instanceof EditorStack) // ) // continue; // ((EditorStack) stacks[i]).showMinMax(stacks[i] == winner); // } // // // Force the stack's presentation state to match its perspective // persp.refreshEditorAreaVisibility(); } PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack() { return this->GetUpperRightEditorStack(this->GetChildren()); } PartStack::Pointer EditorSashContainer::GetUpperRightEditorStack( const ILayoutContainer::ChildrenType& stacks) { // Find the upper Right editor stack PartStack::Pointer winner; Rectangle winnerRect; for (ILayoutContainer::ChildrenType::const_iterator iter = stacks.begin(); iter != stacks.end(); ++iter) { LayoutPart::Pointer part = *iter; if (part.Cast() == 0) continue; PartStack::Pointer stack = part.Cast(); Rectangle bb = stack->GetBounds(); if (iter == stacks.begin() || bb.y < winnerRect.y || (bb.y == winnerRect.y && bb.x > winnerRect.x)) { winner = stack; winnerRect = bb; } } return winner; } PartStack::Pointer EditorSashContainer::GetActiveWorkbook() { if (activeEditorWorkbook == 0) { if (editorWorkbooks.size() < 1) { this->SetActiveWorkbook(this->CreateDefaultWorkbook(), false); } else { this->SetActiveWorkbook(editorWorkbooks.front(), false); } } return activeEditorWorkbook; } std::string EditorSashContainer::GetActiveWorkbookID() { return this->GetActiveWorkbook()->GetID(); } std::list EditorSashContainer::GetEditorWorkbooks() { return editorWorkbooks; } std::size_t EditorSashContainer::GetEditorWorkbookCount() { return editorWorkbooks.size(); } void EditorSashContainer::FindSashes(LayoutPart::Pointer pane, PartPane::Sashes& sashes) { //Find the sashes around the current editor and //then the sashes around the editor area. PartSashContainer::FindSashes(pane, sashes); ILayoutContainer::Pointer container = this->GetContainer(); if (container != 0) { container->FindSashes(LayoutPart::Pointer(this), sashes); } } void EditorSashContainer::RemoveAllEditors() { PartStack::Pointer currentWorkbook = this->GetActiveWorkbook(); // Iterate over a copy so the original can be modified. std::list workbooks(editorWorkbooks); for (std::list::iterator iter = workbooks.begin(); iter != workbooks.end(); ++iter) { PartStack::Pointer workbook = *iter; std::list children = workbook->GetChildren(); for (std::list::iterator childIter = children.begin(); childIter != children.end(); ++childIter) { workbook->Remove(*childIter); } if (workbook != currentWorkbook) { this->Remove(workbook); workbook->Dispose(); } } } void EditorSashContainer::RemoveEditor(PartPane::Pointer pane) { PartStack::Pointer workbook = pane->GetContainer().Cast(); if (workbook == 0) { return; } workbook->Remove(pane); // remove the editor workbook if empty if (workbook->GetItemCount() < 1 /* && editorWorkbooks.size() > 1*/) { // // If the user closes the last editor and the editor area // // is maximized, restore it // Perspective persp = getPage().getActivePerspective(); // if (Perspective.useNewMinMax(persp)) // { // if (persp.getPresentation().getMaximizedStack() instanceof EditorStack) // persp.getPresentation().getMaximizedStack(). // setState(IStackPresentationSite.STATE_RESTORED); // } this->Remove(workbook); workbook->Dispose(); } } bool EditorSashContainer::RestoreState(IMemento::Pointer memento) { //TODO EditorSashContainer restore state // MultiStatus // result = // new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, 0); bool result = true; // Remove the default editor workbook that is // initialy created with the editor area. // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // // public void runWithException() throws Throwable // { PartStack::Pointer defaultWorkbook; for (ILayoutContainer::ChildrenType::iterator i = children.begin(); i != children.end(); ++i) { LayoutPart::Pointer child = *i; if (child->GetID() == DEFAULT_WORKBOOK_ID) { defaultWorkbook = child.Cast(); if (defaultWorkbook->GetItemCount() > 0) { defaultWorkbook = 0; } } } if (defaultWorkbook) { Remove(defaultWorkbook); } // }} // ); // Restore the relationship/layout std::vector infos(memento->GetChildren(WorkbenchConstants::TAG_INFO)); Poco::HashMap mapIDtoPart(infos.size()); for (std::size_t i = 0; i < infos.size(); i++) { // Get the info details. IMemento::Pointer childMem = infos[i]; std::string partID; childMem->GetString(WorkbenchConstants::TAG_PART, partID); std::string relativeID; childMem->GetString(WorkbenchConstants::TAG_RELATIVE, relativeID); int relationship = 0; int left = 0, right = 0; if (!relativeID.empty()) { childMem->GetInteger(WorkbenchConstants::TAG_RELATIONSHIP, relationship); childMem->GetInteger(WorkbenchConstants::TAG_RATIO_LEFT, left); childMem->GetInteger(WorkbenchConstants::TAG_RATIO_RIGHT, right); } PartStack::Pointer workbook; // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // // public void runWithException() throws Throwable // { // Create the part. workbook = NewEditorWorkbook(); workbook->SetID(partID); // 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active workbook->SetContainer(ILayoutContainer::Pointer(this)); // }} // ); IMemento::Pointer workbookMemento = childMem->GetChild( WorkbenchConstants::TAG_FOLDER); if (workbookMemento) { //result.add(workbook[0].restoreState(workbookMemento)); result &= workbook->RestoreState(workbookMemento); } const int myLeft = left, myRight = right, myRelationship = relationship; // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // // public void runWithException() throws Throwable // { // Add the part to the layout if (relativeID.empty()) { Add(workbook); } else { LayoutPart::Pointer refPart = mapIDtoPart[relativeID]; if (refPart) { Add(workbook, myRelationship, myLeft, myRight, refPart); } else { WorkbenchPlugin::Log("Unable to find part for ID: " + relativeID); } } // }} // ); mapIDtoPart[partID] = workbook; } return result; } bool EditorSashContainer::SaveState(IMemento::Pointer memento) { std::vector relationships(ComputeRelation()); // MultiStatus // result = // new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, 0); bool result = true; for (std::size_t i = 0; i < relationships.size(); i++) { // Save the relationship info .. // private LayoutPart part; // private int relationship; // private float ratio; // private LayoutPart relative; const RelationshipInfo& info = relationships[i]; IMemento::Pointer childMem = memento->CreateChild( WorkbenchConstants::TAG_INFO); childMem->PutString(WorkbenchConstants::TAG_PART, info.part->GetID()); PartStack::Pointer stack = info.part.Cast(); if (stack) { IMemento::Pointer folderMem = childMem->CreateChild( WorkbenchConstants::TAG_FOLDER); //result.add(stack.saveState(folderMem)); result &= stack->SaveState(folderMem); } if (info.relative != 0) { childMem->PutString(WorkbenchConstants::TAG_RELATIVE, info.relative->GetID()); childMem->PutInteger(WorkbenchConstants::TAG_RELATIONSHIP, info.relationship); childMem->PutInteger(WorkbenchConstants::TAG_RATIO_LEFT, info.left); childMem->PutInteger(WorkbenchConstants::TAG_RATIO_RIGHT, info.right); } } return result; } void EditorSashContainer::SetActiveWorkbook(PartStack::Pointer newWorkbook, bool hasFocus) { if (newWorkbook != 0) { if (std::find(editorWorkbooks.begin(), editorWorkbooks.end(), newWorkbook) == editorWorkbooks.end()) { return; } } PartStack::Pointer oldWorkbook = activeEditorWorkbook; activeEditorWorkbook = newWorkbook; if (oldWorkbook != 0 && oldWorkbook != newWorkbook) { oldWorkbook->SetActive(StackPresentation::AS_INACTIVE); } if (newWorkbook != 0) { if (hasFocus) { newWorkbook->SetActive(StackPresentation::AS_ACTIVE_FOCUS); } else { newWorkbook->SetActive(StackPresentation::AS_ACTIVE_NOFOCUS); } } this->UpdateTabList(); } void EditorSashContainer::SetActiveWorkbookFromID(const std::string& id) { for (std::list::iterator iter = editorWorkbooks.begin(); iter != editorWorkbooks.end(); ++iter) { PartStack::Pointer workbook = *iter; if (workbook->GetID() == id) { this->SetActiveWorkbook(workbook, false); } } } PartStack::Pointer EditorSashContainer::GetWorkbookFromID(const std::string& id) { for (std::list::iterator iter = editorWorkbooks.begin(); iter != editorWorkbooks.end(); ++iter) { PartStack::Pointer workbook = *iter; if (workbook->GetID() == id) { return workbook; } } return PartStack::Pointer(0); } void EditorSashContainer::UpdateTabList() { void* parent = this->GetParent(); if (parent != 0) { // parent may be 0 on startup PartStack::Pointer wb(this->GetActiveWorkbook()); //TODO EditorSashContainer update tab list // if (wb == 0) // { // parent.setTabList(new Control[0]); // } // else // { // parent.setTabList(wb.getTabList()); // } } } void EditorSashContainer::CreateControl(void* parent) { PartSashContainer::CreateControl(parent); - //TODO DND - //let the user drop files/editor input on the editor area - //this->AddDropSupport(); + ///let the user drop files/editor input on the editor area + this->AddDropSupport(); } bool EditorSashContainer::IsCompressible() { //Added for bug 19524 return true; } bool EditorSashContainer::IsStackType(IStackableContainer::Pointer toTest) { if (toTest.Cast() == 0) return false; return (toTest.Cast ()->GetAppearance() == PresentationFactoryUtil::ROLE_EDITOR); } bool EditorSashContainer::IsPaneType(StackablePart::Pointer toTest) { if (toTest.Cast() == 0) return false; return (toTest.Cast ()->GetPartReference().Cast () != 0); } bool EditorSashContainer::RestorePresentationState(IMemento::Pointer /*areaMem*/) { std::list workbooks = this->GetEditorWorkbooks(); for (std::list::iterator iter = workbooks.begin(); iter != workbooks.end(); ++iter) { PartStack::Pointer workbook = *iter; IMemento::Pointer memento = workbook->GetSavedPresentationState(); if (memento == 0) { continue; } std::list listParts = workbook->GetPresentableParts(); std::vector parts(listParts.begin(), listParts.end()); PresentationSerializer serializer(parts); //StartupThreading.runWithoutExceptions(new StartupRunnable() // { // public void runWithException() throws Throwable // { workbook->GetPresentation()->RestoreState(&serializer, memento); // }} // ); } //return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$ return true; } } diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h index 9c1ab97f6a..3bf62730c0 100755 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryEditorSashContainer.h @@ -1,268 +1,254 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYEDITORSASHCONTAINER_H_ #define BERRYEDITORSASHCONTAINER_H_ #include "berryPartSashContainer.h" #include "berryPartStack.h" #include namespace berry { /** * Represents the area set aside for editor workbooks. * This container only accepts editor stacks (PartStack) and PartSash * as layout parts. * * Note no views are allowed within this container. */ class EditorSashContainer: public PartSashContainer { public: berryObjectMacro(EditorSashContainer); private: std::list editorWorkbooks; PartStack::Pointer activeEditorWorkbook; // DropTarget dropTarget; - //TODO DND - // void AddDropSupport() { - // if (dropTarget == null) { - // WorkbenchWindowConfigurer winConfigurer = ((WorkbenchWindow) page - // .getWorkbenchWindow()).getWindowConfigurer(); - // - // dropTarget = new DropTarget(getControl(), DND.DROP_DEFAULT - // | DND.DROP_COPY | DND.DROP_LINK); - // dropTarget.setTransfer(winConfigurer.getTransfers()); - // if (winConfigurer.getDropTargetListener() != null) { - // dropTarget.addDropListener(winConfigurer - // .getDropTargetListener()); - // } - // } - // } + void AddDropSupport(); PartStack::Pointer NewEditorWorkbook(); protected: /* (non-Javadoc) * @see org.blueberry.ui.internal.PartSashContainer#addChild(org.blueberry.ui.internal.PartSashContainer.RelationshipInfo) */ void AddChild(const RelationshipInfo& info); /** * Notification that a child layout part has been * added to the container. Subclasses may override * this method to perform any container specific * work. */ void ChildAdded(LayoutPart::Pointer child); /** * Notification that a child layout part has been * removed from the container. Subclasses may override * this method to perform any container specific * work. */ void ChildRemoved(LayoutPart::Pointer child); PartStack::Pointer CreateDefaultWorkbook(); /** * Subclasses override this method to specify * the composite to use to parent all children * layout parts it contains. */ void* CreateParent(void* parentWidget); /** * Subclasses override this method to dispose * of any swt resources created during createParent. */ void DisposeParent(); /** * Return true is the workbook specified * is the active one. */ bool IsActiveWorkbook(PartStack::Pointer workbook); //TODO DND // /* package */DropTarget getDropTarget() { // return dropTarget; // } /* (non-Javadoc) * @see org.blueberry.ui.internal.PartSashContainer#createStack(org.blueberry.ui.internal.LayoutPart) */ PartStack::Pointer CreateStack(); /* (non-Javadoc) * @see org.blueberry.ui.internal.PartSashContainer#setVisiblePart(org.blueberry.ui.internal.ILayoutContainer, org.blueberry.ui.internal.LayoutPart) */ void SetVisiblePart(IStackableContainer::Pointer container, PartPane::Pointer visiblePart); /* (non-Javadoc) * @see org.blueberry.ui.internal.PartSashContainer#getVisiblePart(org.blueberry.ui.internal.ILayoutContainer) */ StackablePart::Pointer GetVisiblePart(IStackableContainer::Pointer container); public: static const std::string DEFAULT_WORKBOOK_ID; EditorSashContainer(const std::string& editorId, WorkbenchPage* page, void* parent); bool AllowsAdd(LayoutPart::Pointer layoutPart); /** * Add an editor to the active workbook. */ void AddEditor(PartPane::Pointer pane, PartStack::Pointer stack); /** * Hides the min/max buttons for all editor stacks * -except- for the upper/left one. */ void UpdateStackButtons(); /** * @param stacks * @return the EditorStack in the upper right position */ PartStack::Pointer GetUpperRightEditorStack(); /** * @param stacks * @return the EditorStack in the upper right position */ PartStack::Pointer GetUpperRightEditorStack( const ILayoutContainer::ChildrenType& stacks); /** * Return the editor workbook which is active. */ PartStack::Pointer GetActiveWorkbook(); /** * Return the editor workbook id which is active. */ std::string GetActiveWorkbookID(); /** * Return the all the editor workbooks. */ std::list GetEditorWorkbooks(); /** * Return the all the editor workbooks. */ std::size_t GetEditorWorkbookCount(); /** * Find the sashes around the specified part. */ void FindSashes(LayoutPart::Pointer pane, PartPane::Sashes& sashes); /** * Remove all the editors */ void RemoveAllEditors(); /** * Remove an editor from its' workbook. */ void RemoveEditor(PartPane::Pointer pane); /** * @see IPersistablePart */ bool RestoreState(IMemento::Pointer memento); /** * @see IPersistablePart */ bool SaveState(IMemento::Pointer memento); /** * Set the editor workbook which is active. */ void SetActiveWorkbook(PartStack::Pointer newWorkbook, bool hasFocus); /** * Set the editor workbook which is active. */ void SetActiveWorkbookFromID(const std::string& id); PartStack::Pointer GetWorkbookFromID(const std::string& id); /** * Updates the editor area's tab list to include the active * editor and its tab. */ void UpdateTabList(); /** * @see org.blueberry.ui.internal.LayoutPart#createControl(org.blueberry.swt.widgets.Composite) */ void CreateControl(void* parent); /** * @see org.blueberry.ui.internal.LayoutPart#getImportance() */ bool IsCompressible(); /* (non-Javadoc) * @see org.blueberry.ui.internal.PartSashContainer#isStackType(org.blueberry.ui.internal.LayoutPart) */ bool IsStackType(IStackableContainer::Pointer toTest); /* (non-Javadoc) * @see org.blueberry.ui.internal.PartSashContainer#isPaneType(org.blueberry.ui.internal.LayoutPart) */ bool IsPaneType(StackablePart::Pointer toTest); /* (non-Javadoc) * @see org.blueberry.ui.internal.PartSashContainer#pickPartToZoom() */ // LayoutPart pickPartToZoom() { // return getActiveWorkbook(); // } /** * Restore the presentation state. Loop over the workbooks, create the appropriate serializer and pass to the presentation. * * @param areaMem the memento containing presentation * @return the restoration status */ bool RestorePresentationState(IMemento::Pointer areaMem); }; } #endif /* BERRYEDITORSASHCONTAINER_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtControlWidget.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.cpp similarity index 100% rename from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtControlWidget.cpp rename to BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.cpp diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.h new file mode 100755 index 0000000000..d6049af4ea --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtControlWidget.h @@ -0,0 +1,59 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef BERRYQTCONTROLWIDGET_H_ +#define BERRYQTCONTROLWIDGET_H_ + +#include + +#include "berryQtWidgetController.h" + +#include + +namespace berry { + +class BERRY_UI QtControlWidget : public QFrame +{ + +public: + + QtControlWidget(QWidget* parent, Shell* shell, Qt::WindowFlags f = 0); + + ~QtControlWidget(); + + void FireActivateEvent(); + +protected: + + // used for shell listeners + void changeEvent(QEvent* event); + void closeEvent(QCloseEvent* closeEvent); + + // used for control listeners + void moveEvent(QMoveEvent* event); + void resizeEvent(QResizeEvent* event); + + +private: + + QtWidgetController::Pointer controller; +}; + +} + +#endif /* BERRYQTCONTROLWIDGET_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.cpp new file mode 100644 index 0000000000..61d8c3dc48 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.cpp @@ -0,0 +1,85 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "berryShell.h" + +#include "berryQtDnDControlWidget.h" + +#include +#include +#include +#include + +namespace berry { + +QtDnDControlWidget::QtDnDControlWidget(QWidget* parent) + : QtControlWidget(parent, 0) +{ +} + +void QtDnDControlWidget::SetTransferTypes(const QStringList& types) +{ + transferTypes = types; + if (types.isEmpty()) + { + this->setAcceptDrops(false); + } + else + { + this->setAcceptDrops(true); + } +} + +void QtDnDControlWidget::AddDropListener(IDropTargetListener* listener) +{ + dndEvents.AddListener(listener); +} + +void QtDnDControlWidget::RemoveDropListener(IDropTargetListener* listener) +{ + dndEvents.RemoveListener(listener); +} + +void QtDnDControlWidget::dragEnterEvent(QDragEnterEvent* event) +{ + foreach (QString type, transferTypes) + { + if (event->mimeData()->hasFormat(type)) + { + event->acceptProposedAction(); + dndEvents.dragEnter(event); + break; + } + } +} + +void QtDnDControlWidget::dragMoveEvent(QDragMoveEvent* event) +{ + dndEvents.dragMove(event); +} + +void QtDnDControlWidget::dragLeaveEvent(QDragLeaveEvent* event) +{ + dndEvents.dragLeave(event); +} + +void QtDnDControlWidget::dropEvent(QDropEvent* event) +{ + dndEvents.drop(event); +} + +} diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.h new file mode 100644 index 0000000000..74f29e723b --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtDnDControlWidget.h @@ -0,0 +1,55 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef BERRYQTDNDCONTROLWIDGET_H +#define BERRYQTDNDCONTROLWIDGET_H + +#include "berryQtControlWidget.h" + +#include "../berryIDropTargetListener.h" + +#include + +namespace berry { + +class QtDnDControlWidget : public QtControlWidget +{ +public: + QtDnDControlWidget(QWidget *parent = 0); + + void SetTransferTypes(const QStringList& types); + + void AddDropListener(IDropTargetListener* listener); + void RemoveDropListener(IDropTargetListener* listener); + +protected: + + void dragEnterEvent(QDragEnterEvent* event); + void dragMoveEvent(QDragMoveEvent* event); + void dragLeaveEvent(QDragLeaveEvent* event); + void dropEvent(QDropEvent* event); + +private: + + IDropTargetListener::Events dndEvents; + QStringList transferTypes; +}; + +} + +#endif // BERRYQTDNDCONTROLWIDGET_H diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetController.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.cpp similarity index 100% rename from BlueBerry/Bundles/org.blueberry.ui.qt/src/internal/berryQtWidgetController.cpp rename to BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.cpp diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.h new file mode 100755 index 0000000000..042e660705 --- /dev/null +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryQtWidgetController.h @@ -0,0 +1,73 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef BERRYIQTCONTROLWIDGET_H_ +#define BERRYIQTCONTROLWIDGET_H_ + +#include +#include + +#include + +#include + +namespace berry { + +class Shell; + +class BERRY_UI QtWidgetController : public Object +{ + +public: + + berryObjectMacro(QtWidgetController) + + static const char PROPERTY_ID[]; + + QtWidgetController(Shell* shell); + + ~QtWidgetController(); + + void AddControlListener(GuiTk::IControlListener::Pointer listener); + void RemoveControlListener(GuiTk::IControlListener::Pointer listener); + + void AddShellListener(IShellListener::Pointer listener); + void RemoveShellListener(IShellListener::Pointer listener); + + SmartPointer GetShell(); + +protected: + + friend class QtControlWidget; + friend class QtMainWindowControl; + + GuiTk::IControlListener::Events controlEvents; + IShellListener::Events shellEvents; + + void ShellDestroyed(); + + Shell* shell; + +}; + +} + +//TODO WeakPointer: register a weak pointer as metatype +Q_DECLARE_METATYPE(berry::QtWidgetController::Pointer) + +#endif /* BERRYIQTCONTROLWIDGET_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h index e80643ba4f..a419413ef9 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h @@ -1,630 +1,631 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYWORKBENCHWINDOW_H_ #define BERRYWORKBENCHWINDOW_H_ #include "../berryIWorkbenchWindow.h" #include "../berryIPerspectiveListener.h" #include "../guitk/berryGuiTkIControlListener.h" #include "../berryWindow.h" #include "berryWorkbenchWindowConfigurer.h" #include "berryShellPool.h" #include "berryServiceLocator.h" #include "berryWWinPartService.h" #include "../application/berryWorkbenchAdvisor.h" #include "../application/berryWorkbenchWindowAdvisor.h" #include "../application/berryActionBarAdvisor.h" #include namespace berry { struct IWorkbench; struct IWorkbenchPage; class WorkbenchPage; struct IPartService; struct ISelectionService; struct IPerspectiveDescriptor; class Workbench; /** * \ingroup org_blueberry_ui * */ class BERRY_UI WorkbenchWindow: public Window, public IWorkbenchWindow { public: berryObjectMacro(WorkbenchWindow); WorkbenchWindow(int number); ~WorkbenchWindow(); Object::Pointer GetService(const std::string& key); bool HasService(const std::string& key) const; int Open(); bool Close(); Shell::Pointer GetShell(); /** * @see org.blueberry.ui.IPageService */ void AddPerspectiveListener(IPerspectiveListener::Pointer l); /** * @see org.blueberry.ui.IPageService */ void RemovePerspectiveListener(IPerspectiveListener::Pointer l); /** * @see org.blueberry.ui.IPageService */ IPerspectiveListener::Events& GetPerspectiveEvents(); SmartPointer GetActivePage(); /** * Sets the active page within the window. * * @param in * identifies the new active page, or null for no * active page */ void SetActivePage(SmartPointer in); IWorkbench* GetWorkbench(); IPartService* GetPartService(); ISelectionService* GetSelectionService(); SmartPointer OpenPage(const std::string& perspectiveId, IAdaptable* input); SmartPointer OpenPage(IAdaptable* input); //TODO menu manager //virtual void* GetMenuManager() = 0; virtual bool SaveState(IMemento::Pointer memento); /** * Called when this window is about to be closed. * * Subclasses may overide to add code that returns false to * prevent closing under certain conditions. */ virtual bool OkToClose(); bool RestoreState(IMemento::Pointer memento, SmartPointer< IPerspectiveDescriptor> activeDescriptor); /** * Returns the number. This corresponds to a page number in a window or a * window number in the workbench. */ int GetNumber(); /** *

* Indicates the start of a large update within this window. This is used to * disable CPU-intensive, change-sensitive services that were temporarily * disabled in the midst of large changes. This method should always be * called in tandem with largeUpdateEnd, and the event loop * should not be allowed to spin before that method is called. *

*

* Important: always use with largeUpdateEnd! *

* * @since 3.1 */ void LargeUpdateStart(); /** *

* Indicates the end of a large update within this window. This is used to * re-enable services that were temporarily disabled in the midst of large * changes. This method should always be called in tandem with * largeUpdateStart, and the event loop should not be * allowed to spin before this method is called. *

*

* Important: always protect this call by using finally! *

* * @since 3.1 */ void LargeUpdateEnd(); protected: friend class WorkbenchConfigurer; friend class WorkbenchWindowConfigurer; friend class WorkbenchWindowConfigurer::WindowActionBarConfigurer; friend class Workbench; friend class LayoutPartSash; + friend class EditorSashContainer; friend class WorkbenchPage; friend class DetachedWindow; /** * Returns the GUI dependent page composite, under which the window's * pages create their controls. */ void* GetPageComposite(); /** * Creates and remembers the client composite, under which workbench pages * create their controls. * * @since 3.0 */ virtual void* CreatePageComposite(void* parent) = 0; /** * Creates the contents of the workbench window, including trim controls and * the client composite. This MUST create the client composite via a call to * createClientComposite. * * @since 3.0 */ void* CreateContents(Shell::Pointer parent); /** * Creates the default contents and layout of the shell. * * @param shell * the shell */ virtual void CreateDefaultContents(Shell::Pointer shell); /** * Returns the unique object that applications use to configure this window. *

* IMPORTANT This method is declared package-private to prevent regular * plug-ins from downcasting IWorkbenchWindow to WorkbenchWindow and getting * hold of the workbench window configurer that would allow them to tamper * with the workbench window. The workbench window configurer is available * only to the application. *

*/ WorkbenchWindowConfigurer::Pointer GetWindowConfigurer(); /* * @see berry::Window#configureShell(Shell::Pointer) */ void ConfigureShell(Shell::Pointer shell); ShellPool::Pointer GetDetachedWindowPool(); /** * Fills the window's real action bars. * * @param flags * indicate which bars to fill */ void FillActionBars(int flags); /** * The WorkbenchWindow implementation of this method * delegates to the window configurer. * * @since 3.0 */ Point GetInitialSize(); /** * Returns the default page input for workbench pages opened in this window. * * @return the default page input or null if none * @since 3.1 */ IAdaptable* GetDefaultPageInput(); bool IsClosing(); /** * Opens a new page. Assumes that busy cursor is active. *

* Note: Since release 2.0, a window is limited to contain at most * one page. If a page exist in the window when this method is used, then * another window is created for the new page. Callers are strongly * recommended to use the IWorkbench.openPerspective APIs to * programmatically show a perspective. *

*/ SmartPointer BusyOpenPage(const std::string& perspID, IAdaptable* input); bool ClosePage(SmartPointer in, bool save); /** * Makes the window visible and frontmost. */ void MakeVisible(); /** * The composite under which workbench pages create their controls. * * @since 3.0 */ void* pageComposite; private: /** * Constant indicating that all the actions bars should be filled. * * @since 3.0 */ static const int FILL_ALL_ACTION_BARS; ShellPool::Pointer detachedWindowShells; /** * Object for configuring this workbench window. Lazily initialized to an * instance unique to this window. * * @since 3.0 */ WorkbenchWindowConfigurer::Pointer windowConfigurer; WorkbenchWindowAdvisor* windowAdvisor; ActionBarAdvisor::Pointer actionBarAdvisor; int number; /** * The number of large updates that are currently going on. If this is * number is greater than zero, then UI updateActionBars is a no-op. */ int largeUpdates; bool closing; bool shellActivated; bool updateDisabled; /** * The map of services maintained by the workbench window. These services * are initialized during workbench window during the * {@link #configureShell(Shell)}. */ ServiceLocator::Pointer serviceLocator; bool emptyWindowContentsCreated; void* emptyWindowContents; Rectangle normalBounds; bool asMaximizedState; IPerspectiveListener::Events perspectiveEvents; WWinPartService partService; struct ServiceLocatorOwner: public IDisposable { ServiceLocatorOwner(WorkbenchWindow* wnd); WorkbenchWindow* window; void Dispose(); }; IDisposable::Pointer serviceLocatorOwner; class PageList { private: // List of pages in the order they were created; std::list > pagesInCreationOrder; // List of pages where the top is the last activated. std::list > pagesInActivationOrder; // The page explicitly activated SmartPointer active; public: typedef std::list >::iterator iterator; bool Add(SmartPointer object); iterator Begin(); iterator End(); void Clear(); bool Contains(SmartPointer object); bool Remove(SmartPointer object); bool IsEmpty(); const std::list >& GetPages(); void SetActive(SmartPointer page); SmartPointer GetActive(); SmartPointer GetNextActive(); }; PageList pageList; /** * Notifies interested parties (namely the advisor) that the window is about * to be opened. * * @since 3.1 */ void FireWindowOpening(); /** * Notifies interested parties (namely the advisor) that the window has been * restored from a previously saved state. * * @throws WorkbenchException * passed through from the advisor * @since 3.1 */ void FireWindowRestored(); /** * Notifies interested parties (namely the advisor) that the window has been * created. * * @since 3.1 */ void FireWindowCreated(); /** * Notifies interested parties (namely the advisor and the window listeners) * that the window has been opened. * * @since 3.1 */ void FireWindowOpened(); /** * Notifies interested parties (namely the advisor) that the window's shell * is closing. Allows the close to be vetoed. * * @return true if the close should proceed, * false if it should be canceled * @since 3.1 */ bool FireWindowShellClosing(); /** * Notifies interested parties (namely the advisor and the window listeners) * that the window has been closed. * * @since 3.1 */ void FireWindowClosed(); // /** // * Fires page activated // */ // void FirePageActivated(IWorkbenchPage::Pointer page); // // /** // * Fires page closed // */ // void FirePageClosed(IWorkbenchPage::Pointer page); // // /** // * Fires page opened // */ // void FirePageOpened(IWorkbenchPage::Pointer page); /** * Fires perspective activated */ void FirePerspectiveActivated(SmartPointer page, IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective deactivated. * * @since 3.2 */ void FirePerspectivePreDeactivate(SmartPointer page, IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective deactivated. * * @since 3.1 */ void FirePerspectiveDeactivated(SmartPointer page, IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective changed */ void FirePerspectiveChanged(SmartPointer , IPerspectiveDescriptor::Pointer perspective, const std::string& changeId); /** * Fires perspective changed for an affected part */ void FirePerspectiveChanged(SmartPointer , IPerspectiveDescriptor::Pointer perspective, IWorkbenchPartReference::Pointer partRef, const std::string& changeId); /** * Fires perspective closed */ void FirePerspectiveClosed(SmartPointer , IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective opened */ void FirePerspectiveOpened(SmartPointer , IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective saved as. * * @since 3.1 */ void FirePerspectiveSavedAs(SmartPointer , IPerspectiveDescriptor::Pointer oldPerspective, IPerspectiveDescriptor::Pointer newPerspective); /** * Returns the workbench advisor. Assumes the workbench has been created * already. *

* IMPORTANT This method is declared private to prevent regular plug-ins * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of * the workbench advisor that would allow them to tamper with the workbench. * The workbench advisor is internal to the application. *

*/ /* private - DO NOT CHANGE */ WorkbenchAdvisor* GetAdvisor(); /** * Returns the window advisor, creating a new one for this window if needed. *

* IMPORTANT This method is declared private to prevent regular plug-ins * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of * the window advisor that would allow them to tamper with the window. The * window advisor is internal to the application. *

*/ /* private - DO NOT CHANGE */ WorkbenchWindowAdvisor* GetWindowAdvisor(); /** * Returns the action bar advisor, creating a new one for this window if * needed. *

* IMPORTANT This method is declared private to prevent regular plug-ins * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of * the action bar advisor that would allow them to tamper with the window's * action bars. The action bar advisor is internal to the application. *

*/ /* private - DO NOT CHANGE */ ActionBarAdvisor::Pointer GetActionBarAdvisor(); /* * Returns the IWorkbench implementation. */ Workbench* GetWorkbenchImpl(); bool UnableToRestorePage(IMemento::Pointer pageMem); /** * Close the window. * * Assumes that busy cursor is active. */ bool BusyClose(); /** * Unconditionally close this window. Assumes the proper flags have been set * correctly (e.i. closing and updateDisabled) */ bool HardClose(); /** * Close all of the pages. */ void CloseAllPages(); /** * Save all of the pages. Returns true if the operation succeeded. */ bool SaveAllPages(bool bConfirm); void ShowEmptyWindowContents(); void HideEmptyWindowContents(); struct ShellActivationListener: public IShellListener { ShellActivationListener(WorkbenchWindow::Pointer window); void ShellActivated(ShellEvent::Pointer event); void ShellDeactivated(ShellEvent::Pointer event); private: WorkbenchWindow::WeakPtr window; }; IShellListener::Pointer shellActivationListener; /** * Hooks a listener to track the activation and deactivation of the window's * shell. Notifies the active part and editor of the change */ void TrackShellActivation(Shell::Pointer shell); struct ControlResizeListener: public GuiTk::IControlListener { ControlResizeListener(WorkbenchWindow* window); GuiTk::IControlListener::Events::Types GetEventTypes() const; void ControlMoved(GuiTk::ControlEvent::Pointer e); void ControlResized(GuiTk::ControlEvent::Pointer e); private: void SaveBounds(); WorkbenchWindow* window; }; GuiTk::IControlListener::Pointer controlResizeListener; /** * Hooks a listener to track the resize of the window's shell. Stores the * new bounds if in normal state - that is, not in minimized or maximized * state) */ void TrackShellResize(Shell::Pointer newShell); }; } #endif /*BERRYWORKBENCHWINDOW_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp index 352b708770..673b563e16 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.cpp @@ -1,221 +1,267 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "berryWorkbenchWindowConfigurer.h" #include "berryWorkbenchWindow.h" #include "../berryImageDescriptor.h" #include "berryWorkbench.h" +#include "berryWorkbenchPage.h" +#include "berryEditorSashContainer.h" #include "berryWorkbenchPlugin.h" +#include "berryQtDnDControlWidget.h" + namespace berry { WorkbenchWindowConfigurer::WindowActionBarConfigurer::WindowActionBarConfigurer(WorkbenchWindow::WeakPtr wnd) : window(wnd) { } void WorkbenchWindowConfigurer::WindowActionBarConfigurer::SetProxy(IActionBarConfigurer::Pointer proxy) { this->proxy = proxy; } IWorkbenchWindowConfigurer::Pointer WorkbenchWindowConfigurer::WindowActionBarConfigurer::GetWindowConfigurer() { return WorkbenchWindow::Pointer(window)->GetWindowConfigurer(); } void* WorkbenchWindowConfigurer::WindowActionBarConfigurer::GetMenuManager() { if (proxy.IsNotNull()) { return proxy->GetMenuManager(); } //TODO window menu manager //return window->GetMenuManager(); return 0; } WorkbenchWindowConfigurer::WorkbenchWindowConfigurer(WorkbenchWindow::Pointer window) : shellStyle(0), showPerspectiveBar(false), showStatusLine(true), showToolBar(true), showMenuBar(true), showProgressIndicator(false), initialSize(1024,768) { if (window.IsNull()) { throw Poco::InvalidArgumentException(); } this->window = window; windowTitle = "BlueBerry Application"; } IWorkbenchWindow::Pointer WorkbenchWindowConfigurer::GetWindow() { return IWorkbenchWindow::Pointer(window); } IWorkbenchConfigurer::Pointer WorkbenchWindowConfigurer::GetWorkbenchConfigurer() { return dynamic_cast(PlatformUI::GetWorkbench())->GetWorkbenchConfigurer(); } std::string WorkbenchWindowConfigurer::BasicGetTitle() { return windowTitle; } std::string WorkbenchWindowConfigurer::GetTitle() { Shell::Pointer shell = window.Lock()->GetShell(); if (shell) { // update the cached title windowTitle = shell->GetText(); } return windowTitle; } void WorkbenchWindowConfigurer::SetTitle(const std::string& title) { windowTitle = title; Shell::Pointer shell = window.Lock()->GetShell(); if (shell) { shell->SetText(title); } } bool WorkbenchWindowConfigurer::GetShowMenuBar() { return showMenuBar; } void WorkbenchWindowConfigurer::SetShowMenuBar(bool show) { showMenuBar = show; // WorkbenchWindow win = (WorkbenchWindow) getWindow(); // Shell shell = win.getShell(); // if (shell != null) // { // boolean showing = shell.getMenuBar() != null; // if (show != showing) // { // if (show) // { // shell.setMenuBar(win.getMenuBarManager().getMenu()); // } // else // { // shell.setMenuBar(null); // } // } // } } bool WorkbenchWindowConfigurer::GetShowCoolBar() { return showToolBar; } void WorkbenchWindowConfigurer::SetShowCoolBar(bool show) { showToolBar = show; //window.setCoolBarVisible(show); // @issue need to be able to reconfigure after window's controls created } bool WorkbenchWindowConfigurer::GetShowPerspectiveBar() { return showPerspectiveBar; } void WorkbenchWindowConfigurer::SetShowPerspectiveBar(bool show) { showPerspectiveBar = show; //window.setPerspectiveBarVisible(show); // @issue need to be able to reconfigure after window's controls created } bool WorkbenchWindowConfigurer::GetShowStatusLine() { return showStatusLine; } void WorkbenchWindowConfigurer::SetShowStatusLine(bool show) { showStatusLine = show; // @issue need to be able to reconfigure after window's controls created } bool WorkbenchWindowConfigurer::GetShowProgressIndicator() { return showProgressIndicator; } void WorkbenchWindowConfigurer::SetShowProgressIndicator(bool show) { showProgressIndicator = show; // @issue need to be able to reconfigure after window's controls created } +void WorkbenchWindowConfigurer::AddEditorAreaTransfer(const QStringList& transfers) +{ + if (transfers.isEmpty()) return; + + int oldSize = transferTypes.size(); + transferTypes.unite(QSet::fromList(transfers)); + + if (transferTypes.size() == oldSize) return; + + WorkbenchPage::Pointer page = window.Lock()->GetActivePage().Cast(); + if (page) + { + QtDnDControlWidget* dropTarget = + static_cast(page->GetEditorPresentation()->GetLayoutPart().Cast()->GetParent()); + dropTarget->SetTransferTypes(transferTypes.toList()); + } +} + +void WorkbenchWindowConfigurer::ConfigureEditorAreaDropListener(const IDropTargetListener::Pointer& listener) +{ + if (listener == 0) return; + dropTargetListener = listener; + + WorkbenchPage::Pointer page = window.Lock()->GetActivePage().Cast(); + if (page) + { + QtDnDControlWidget* dropTarget = + static_cast(page->GetEditorPresentation()->GetLayoutPart().Cast()->GetParent()); + dropTarget->AddDropListener(listener.GetPointer()); + } +} + +QStringList WorkbenchWindowConfigurer::GetTransfers() const +{ + return transferTypes.toList(); +} + +IDropTargetListener::Pointer WorkbenchWindowConfigurer::GetDropTargetListener() const +{ + return dropTargetListener; +} + IActionBarConfigurer::Pointer WorkbenchWindowConfigurer::GetActionBarConfigurer() { if (actionBarConfigurer.IsNull()) { // lazily initialize actionBarConfigurer = new WindowActionBarConfigurer(window); } return actionBarConfigurer; } int WorkbenchWindowConfigurer::GetShellStyle() { return shellStyle; } void WorkbenchWindowConfigurer::SetShellStyle(int shellStyle) { this->shellStyle = shellStyle; } Point WorkbenchWindowConfigurer::GetInitialSize() { return initialSize; } void WorkbenchWindowConfigurer::SetInitialSize(Point size) { initialSize = size; } void WorkbenchWindowConfigurer::CreateDefaultContents(Shell::Pointer shell) { WorkbenchWindow::Pointer(window)->CreateDefaultContents(shell); } void* WorkbenchWindowConfigurer::CreatePageComposite(void* parent) { return WorkbenchWindow::Pointer(window)->CreatePageComposite(parent); } bool WorkbenchWindowConfigurer::SaveState(IMemento::Pointer memento) { return WorkbenchWindow::Pointer(window)->SaveState(memento); } } diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h index bcd43b1f26..7022ad84a0 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindowConfigurer.h @@ -1,492 +1,457 @@ /*========================================================================= Program: BlueBerry Platform Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef BERRYWORKBENCHWINDOWCONFIGURER_H_ #define BERRYWORKBENCHWINDOWCONFIGURER_H_ #include "../application/berryIActionBarConfigurer.h" #include "../application/berryIWorkbenchConfigurer.h" #include "../application/berryIWorkbenchWindowConfigurer.h" #include +#include + namespace berry { class WorkbenchWindow; /** * Internal class providing special access for configuring workbench windows. *

* Note that these objects are only available to the main application * (the plug-in that creates and owns the workbench). *

*

* This class is not intended to be instantiated or subclassed by clients. *

* * @since 3.0 */ class WorkbenchWindowConfigurer : public IWorkbenchWindowConfigurer { friend class WorkbenchWindow; public: berryObjectMacro(WorkbenchWindowConfigurer); /** * The workbench window associated with this configurer. */ private: WeakPointer window; /** * The shell style bits to use when the window's shell is being created. */ private: int shellStyle; /** * The window title to set when the window's shell has been created. */ private: std::string windowTitle; /** * Whether the workbench window should show the fast view bars. */ //private: boolean showFastViewBars = false; /** * Whether the workbench window should show the perspective bar */ private: bool showPerspectiveBar; /** * Whether the workbench window should show the status line. */ private: bool showStatusLine; /** * Whether the workbench window should show the main tool bar. */ private: bool showToolBar; /** * Whether the workbench window should show the main menu bar. */ private: bool showMenuBar; /** * Whether the workbench window should have a progress indicator. */ private: bool showProgressIndicator; /** * Table to hold arbitrary key-data settings (key type: String, * value type: Object). * @see #setData */ //private: Map extraData = new HashMap(1); /** * Holds the list drag and drop Transfer for the * editor area */ - //private: ArrayList transferTypes = new ArrayList(3); + private: QSet transferTypes; /** * The DropTargetListener implementation for handling a * drop into the editor area. */ - //private: DropTargetListener dropTargetListener = null; + private: IDropTargetListener::Pointer dropTargetListener; /** * The initial size to use for the shell. */ private: Point initialSize; /** * Action bar configurer that changes this workbench window. * This implementation keeps track of of cool bar items */ private: class WindowActionBarConfigurer : public IActionBarConfigurer { private: IActionBarConfigurer::Pointer proxy; private: WeakPointer window; public: berryObjectMacro(WindowActionBarConfigurer); public: WindowActionBarConfigurer(WeakPointer wnd); /** * Sets the proxy to use, or null for none. * * @param proxy the proxy */ public: void SetProxy(IActionBarConfigurer::Pointer proxy); /* (non-Javadoc) * @see org.blueberry.ui.application.IActionBarConfigurer#getWindowConfigurer() */ public: IWorkbenchWindowConfigurer::Pointer GetWindowConfigurer(); /** * Returns whether the given id is for a cool item. * * @param the item id * @return true if it is a cool item, * and false otherwise */ // /* package */boolean containsCoolItem(String id) { // ICoolBarManager cbManager = getCoolBarManager(); // if (cbManager == null) { // return false; // } // IContributionItem cbItem = cbManager.find(id); // if (cbItem == null) { // return false; // } // //@ issue: maybe we should check if cbItem is visible? // return true; // } /* (non-Javadoc) * @see org.blueberry.ui.application.IActionBarConfigurer */ // public: IStatusLineManager getStatusLineManager() { // if (proxy != null) { // return proxy.getStatusLineManager(); // } // return window.getStatusLineManager(); // } /* (non-Javadoc) * @see org.blueberry.ui.application.IActionBarConfigurer */ public: void* GetMenuManager(); /* (non-Javadoc) * @see org.blueberry.ui.internal.AbstractActionBarConfigurer */ // public: ICoolBarManager getCoolBarManager() { // if (proxy != null) { // return proxy.getCoolBarManager(); // } // return window.getCoolBarManager2(); // } /* (non-Javadoc) * @see org.blueberry.ui.application.IActionBarConfigurer */ // public: void registerGlobalAction(IAction action) { // if (proxy != null) { // proxy.registerGlobalAction(action); // } // window.registerGlobalAction(action); // } /* (non-Javadoc) * @see org.blueberry.ui.application.IActionBarConfigurer#createToolBarManager() */ // public: IToolBarManager createToolBarManager() { // if (proxy != null) { // return proxy.createToolBarManager(); // } // return getActionBarPresentationFactory().createToolBarManager(); // } /* (non-Javadoc) * @see org.blueberry.ui.application.IActionBarConfigurer#createToolBarContributionItem(org.blueberry.jface.action.IToolBarManager, java.lang.String) */ // public: IToolBarContributionItem createToolBarContributionItem(IToolBarManager toolBarManager, String id) { // if (proxy != null) { // return proxy.createToolBarContributionItem(toolBarManager, id); // } // return getActionBarPresentationFactory().createToolBarContributionItem(toolBarManager, id); // } }; /** * Object for configuring this workbench window's action bars. * Lazily initialized to an instance unique to this window. */ private: WindowActionBarConfigurer::Pointer actionBarConfigurer; /** * Creates a new workbench window configurer. *

* This method is declared package-private:. Clients obtain instances * via {@link WorkbenchAdvisor#getWindowConfigurer * WorkbenchAdvisor.getWindowConfigurer} *

* * @param window the workbench window that this object configures * @see WorkbenchAdvisor#getWindowConfigurer */ public: WorkbenchWindowConfigurer(SmartPointer window); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getWindow */ public: IWorkbenchWindow::Pointer GetWindow(); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getWorkbenchConfigurer() */ public: IWorkbenchConfigurer::Pointer GetWorkbenchConfigurer(); /** * Returns the title as set by setTitle, without consulting the shell. * * @return the window title as set, or null if not set */ /* package */std::string BasicGetTitle(); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getTitle */ public: std::string GetTitle(); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setTitle */ public: void SetTitle(const std::string& title); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getShowMenuBar */ public: bool GetShowMenuBar(); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setShowMenuBar */ public: void SetShowMenuBar(bool show); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getShowToolBar */ public: bool GetShowCoolBar(); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: void SetShowCoolBar(bool show); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: bool GetShowPerspectiveBar(); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: void SetShowPerspectiveBar(bool show); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getShowStatusLine */ public: bool GetShowStatusLine(); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setShowStatusLine */ public: void SetShowStatusLine(bool show); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: bool GetShowProgressIndicator(); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: void SetShowProgressIndicator(bool show); /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#getData */ // public: Object getData(String key) { // if (key == null) { // throw new IllegalArgumentException(); // } // return extraData.get(key); // } /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#setData */ // public: void setData(String key, Object data) { // if (key == null) { // throw new IllegalArgumentException(); // } // if (data != null) { // extraData.put(key, data); // } else { // extraData.remove(key); // } // } /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#addEditorAreaTransfer */ -// public: void addEditorAreaTransfer(Transfer tranfer) { -// if (tranfer != null && !transferTypes.contains(tranfer)) { -// transferTypes.add(tranfer); -// Transfer[] transfers = new Transfer[transferTypes.size()]; -// transferTypes.toArray(transfers); -// IWorkbenchPage[] pages = window.getPages(); -// for (int i = 0; i < pages.length; i++) { -// WorkbenchPage page = (WorkbenchPage) pages[i]; -// DropTarget dropTarget = ((EditorSashContainer) page -// .getEditorPresentation().getLayoutPart()) -// .getDropTarget(); -// if (dropTarget != null) { -// dropTarget.setTransfer(transfers); -// } -// } -// } -// } + public: void AddEditorAreaTransfer(const QStringList& transferTypes); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ -// public: void configureEditorAreaDropListener( -// DropTargetListener dropTargetListener) { -// if (dropTargetListener != null) { -// this.dropTargetListener = dropTargetListener; -// IWorkbenchPage[] pages = window.getPages(); -// for (int i = 0; i < pages.length; i++) { -// WorkbenchPage page = (WorkbenchPage) pages[i]; -// DropTarget dropTarget = ((EditorSashContainer) page -// .getEditorPresentation().getLayoutPart()) -// .getDropTarget(); -// if (dropTarget != null) { -// dropTarget.addDropListener(this.dropTargetListener); -// } -// } -// } -// } + public: void ConfigureEditorAreaDropListener(const IDropTargetListener::Pointer &listener); /** * Returns the array of Transfer added by the application */ -// /* package */Transfer[] getTransfers() { -// Transfer[] transfers = new Transfer[transferTypes.size()]; -// transferTypes.toArray(transfers); -// return transfers; -// } +public: QStringList GetTransfers() const; /** * Returns the drop listener provided by the application. */ -// /* package */DropTargetListener getDropTargetListener() { -// return dropTargetListener; -// } +public: IDropTargetListener::Pointer GetDropTargetListener() const; /* (non-javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: IActionBarConfigurer::Pointer GetActionBarConfigurer(); /** * Returns whether the given id is for a cool item. * * @param the item id * @return true if it is a cool item, * and false otherwise */ // /* package */boolean containsCoolItem(String id) { // // trigger lazy initialization // getActionBarConfigurer(); // return actionBarConfigurer.containsCoolItem(id); // } /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: int GetShellStyle(); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: void SetShellStyle(int shellStyle); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: Point GetInitialSize(); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: void SetInitialSize(Point size); /** * Creates the default window contents. * * @param shell the shell */ public: void CreateDefaultContents(Shell::Pointer shell); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ // public: Menu createMenuBar() { // return window.getMenuManager().createMenuBar(window.getShell()); // } /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ // public: Control createCoolBarControl(Composite parent) { // ICoolBarManager coolBarManager = window.getCoolBarManager2(); // if (coolBarManager != null) { // if (coolBarManager instanceof ICoolBarManager2) { // return ((ICoolBarManager2) coolBarManager).createControl2(parent); // } // if (coolBarManager instanceof CoolBarManager) { // return ((CoolBarManager) coolBarManager).createControl(parent); // } // } // return null; // } /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ // public: Control createStatusLineControl(Composite parent) { // return window.getStatusLineManager().createControl(parent); // } /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer */ public: void* CreatePageComposite(void* parent); /* (non-Javadoc) * @see org.blueberry.ui.application.IWorkbenchWindowConfigurer#saveState(org.blueberry.ui.IMemento) */ public: bool SaveState(IMemento::Pointer memento) ; }; } #endif /*BERRYWORKBENCHWINDOWCONFIGURER_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.uitest/documentation/doxygen/modules.dox b/BlueBerry/Bundles/org.blueberry.uitest/documentation/doxygen/modules.dox index 673360d53b..599c765dc4 100644 --- a/BlueBerry/Bundles/org.blueberry.uitest/documentation/doxygen/modules.dox +++ b/BlueBerry/Bundles/org.blueberry.uitest/documentation/doxygen/modules.dox @@ -1,16 +1,16 @@ /** - \defgroup org_blueberry_uitest org.blueberry.uitest Plugin + \defgroup org_blueberry_uitest org.blueberry.uitest \ingroup BlueBerryPlugins \brief Describe your plugin here. */ /** \defgroup org_blueberry_uitest_internal Internal \ingroup org_blueberry_uitest \brief This subcategory includes the internal classes of the org.blueberry.uitest plugin. Other plugins must not rely on these classes. They contain implementation details and their interface may change at any time. We mean it. */ diff --git a/BlueBerry/CMake/BundleTemplate/BundleDefaults.cmake b/BlueBerry/CMake/BundleTemplate/BundleDefaults.cmake deleted file mode 100644 index c4ad9c1df4..0000000000 --- a/BlueBerry/CMake/BundleTemplate/BundleDefaults.cmake +++ /dev/null @@ -1,27 +0,0 @@ -SET(BUNDLE_NAMESPACE "berry") -SET(DEFAULT_REQUIRED_BUNDLES "org.blueberry.osgi") -SET(DEFAULT_REQUIRED_BUNDLES_FOR_GUI "org.blueberry.ui.qt") -SET(DEFAULT_VIEW_BASE_CLASS "berry::QtViewPart")#qt -SET(DEFAULT_VIEW_BASE_CLASS_H "berryQtViewPart.h")#qt) -SET(PROJECT_STATIC_VAR "BERRY_STATIC") -SET(DOXYGEN_INGROUP "BlueBerryPlugins") - -SET(DEFAULT_CREATE_PLUGIN_MACRO "MACRO_CREATE_PLUGIN()") -SET(DEFAULT_CREATE_GUI_PLUGIN_MACRO "MACRO_CREATE_QT_PLUGIN()") - -SET(PLUGIN_COPYRIGHT "/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2008-06-13 21:02:28 +0200 (Fr, 13 Jun 2008) $ -Version: $Revision: 14620 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/") diff --git a/BlueBerry/CMake/BundleTemplate/BundleTemplate.cpp b/BlueBerry/CMake/BundleTemplate/BundleTemplate.cpp deleted file mode 100644 index f87d6887e8..0000000000 --- a/BlueBerry/CMake/BundleTemplate/BundleTemplate.cpp +++ /dev/null @@ -1,22 +0,0 @@ -@PLUGIN_COPYRIGHT@ - -#include "@GENERATE_VIEW_CLASS@.h" - -#include "berryPlatform.h" -#include "service/berryIExtensionPointService.h" -#include "event/berryPlatformEvents.h" - -#include "Poco/Delegate.h" - -#include - -namespace berry { - -const std::string RuntimePlugin::@PLUGIN_ID@ = "org.blueberry.core.runtime"; - -void -RuntimePlugin::Start(IBundleContext::Pointer /*context*/) -{ -} - -} diff --git a/BlueBerry/CMake/BundleTemplate/BundleTemplate.h b/BlueBerry/CMake/BundleTemplate/BundleTemplate.h deleted file mode 100644 index 6fb14a6b56..0000000000 --- a/BlueBerry/CMake/BundleTemplate/BundleTemplate.h +++ /dev/null @@ -1,26 +0,0 @@ -@PLUGIN_COPYRIGHT@ - -#ifndef (@GENERATE_VIEW_CLASS@_H_INCLUDED) -#define @GENERATE_VIEW_CLASS@_H_INCLUDED - -#include -#include -#include - -#include - -namespace berry { - -class BERRY_RUNTIME @GENERATE_VIEW_CLASS@ : public Plugin -{ -public: - - static const std::string @PLUGIN_ID@; - - void Start(IBundleContext::Pointer context); - -}; - -} - -#endif /*@GENERATE_VIEW_CLASS@_H_INCLUDED*/ diff --git a/BlueBerry/CMake/BundleTemplate/CMakeListsTemplate.txt b/BlueBerry/CMake/BundleTemplate/CMakeListsTemplate.txt deleted file mode 100644 index 43071944bb..0000000000 --- a/BlueBerry/CMake/BundleTemplate/CMakeListsTemplate.txt +++ /dev/null @@ -1,2 +0,0 @@ - -@CREATE_PLUGIN_MACRO@ diff --git a/BlueBerry/CMake/BundleTemplate/META-INF/MANIFEST_TEMPLATE.MF b/BlueBerry/CMake/BundleTemplate/META-INF/MANIFEST_TEMPLATE.MF deleted file mode 100644 index 0343e4c83a..0000000000 --- a/BlueBerry/CMake/BundleTemplate/META-INF/MANIFEST_TEMPLATE.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: @PLUGIN_NAME@ -Bundle-SymbolicName: @PLUGIN_ID@ -Bundle-Version: @PLUGIN_VERSION@ -Bundle-Vendor: @PLUGIN_VENDOR@ -Require-Bundle: @REQUIRED_PLUGINS_MF@ -Bundle-Activator: @FQ_ACTIVATOR_CLASS@ \ No newline at end of file diff --git a/BlueBerry/CMake/BundleTemplate/documentation/doxygen/modulesTemplate.dox b/BlueBerry/CMake/BundleTemplate/documentation/doxygen/modulesTemplate.dox deleted file mode 100644 index 40ff4b9720..0000000000 --- a/BlueBerry/CMake/BundleTemplate/documentation/doxygen/modulesTemplate.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup @NormalizedPluginID@ @PLUGIN_ID@ Plugin - @DOXYGEN_INGROUP_CMD@ - - \brief Describe your plugin here. - -*/ - -/** - \defgroup @NormalizedPluginID@_internal Internal - \ingroup @NormalizedPluginID@ - - \brief This subcategory includes the internal classes of the @PLUGIN_ID@ plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ \ No newline at end of file diff --git a/BlueBerry/CMake/BundleTemplate/filesTemplate.cmake b/BlueBerry/CMake/BundleTemplate/filesTemplate.cmake deleted file mode 100644 index cd249d5cd9..0000000000 --- a/BlueBerry/CMake/BundleTemplate/filesTemplate.cmake +++ /dev/null @@ -1,18 +0,0 @@ -SET(SRC_CPP_FILES - @PLUGIN_SOURCES@ -) - -SET(INTERNAL_CPP_FILES - @PLUGIN_INTERNAL_SOURCES@ -) - -@SET_MANIFEST_SRC@ - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/BlueBerry/CMake/BundleTemplate/manifestTemplate.cpp b/BlueBerry/CMake/BundleTemplate/manifestTemplate.cpp deleted file mode 100755 index ee2301e29d..0000000000 --- a/BlueBerry/CMake/BundleTemplate/manifestTemplate.cpp +++ /dev/null @@ -1,12 +0,0 @@ -@PLUGIN_COPYRIGHT@ - -#include "Poco/ClassLibrary.h" - -#include -#include "src/internal/@VIEW_CLASS_H@" - - -//******************** Views ********************** -POCO_BEGIN_NAMED_MANIFEST(berryIViewPart, berry::IViewPart) - POCO_EXPORT_CLASS(@BUNDLE_NAMESPACE@::@VIEW_CLASS@) -POCO_END_MANIFEST diff --git a/BlueBerry/CMake/BundleTemplate/pluginTemplate.xml b/BlueBerry/CMake/BundleTemplate/pluginTemplate.xml deleted file mode 100755 index 73704913d0..0000000000 --- a/BlueBerry/CMake/BundleTemplate/pluginTemplate.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - -@XP_VIEW@ - - diff --git a/BlueBerry/CMake/BundleTemplate/src/BundleDllTemplate.h b/BlueBerry/CMake/BundleTemplate/src/BundleDllTemplate.h deleted file mode 100644 index 10e997317f..0000000000 --- a/BlueBerry/CMake/BundleTemplate/src/BundleDllTemplate.h +++ /dev/null @@ -1,28 +0,0 @@ -@PLUGIN_COPYRIGHT@ - -#ifndef _@DLL_DEFINE@_DLL_H_ -#define _@DLL_DEFINE@_DLL_H_ - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the @NormalizedPluginID@_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// @NormalizedPluginID@_EXPORTS functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(@PROJECT_STATIC_VAR@) - #if defined(@NormalizedPluginID@_EXPORTS) - #define @DLL_DEFINE@ __declspec(dllexport) - #else - #define @DLL_DEFINE@ __declspec(dllimport) - #endif -#endif - - -#if !defined(@DLL_DEFINE@) - #define @DLL_DEFINE@ -#endif - -#endif /*_@DLL_DEFINE@_DLL_H_*/ diff --git a/BlueBerry/CMake/BundleTemplate/src/internal/ViewTemplate.cpp b/BlueBerry/CMake/BundleTemplate/src/internal/ViewTemplate.cpp deleted file mode 100644 index 26d9f4cfeb..0000000000 --- a/BlueBerry/CMake/BundleTemplate/src/internal/ViewTemplate.cpp +++ /dev/null @@ -1,26 +0,0 @@ -@PLUGIN_COPYRIGHT@ - -#include -#include -#include - -#include "@VIEW_CLASS_H@" - -@BEGIN_NAMESPACE@ - -const std::string @VIEW_CLASS@::VIEW_ID = "@VIEW_ID@"; - -void @VIEW_CLASS@::CreateQtPartControl(QWidget* parent) -{ - QVBoxLayout* layout = new QVBoxLayout(parent); - layout->setContentsMargins(0,0,0,0); - m_ButtonStart = new QPushButton("start", parent); - layout->addWidget(m_ButtonStart); -} - -void @VIEW_CLASS@::SetFocus() -{ - m_ButtonStart->setFocus(); -} - -@END_NAMESPACE@ diff --git a/BlueBerry/CMake/BundleTemplate/src/internal/ViewTemplate.h b/BlueBerry/CMake/BundleTemplate/src/internal/ViewTemplate.h deleted file mode 100644 index 4d3a7664d9..0000000000 --- a/BlueBerry/CMake/BundleTemplate/src/internal/ViewTemplate.h +++ /dev/null @@ -1,50 +0,0 @@ -@PLUGIN_COPYRIGHT@ - -#ifndef @UBUNDLE_NAMESPACE@_@UVIEW_CLASS@_H_INCLUDED -#define @UBUNDLE_NAMESPACE@_@UVIEW_CLASS@_H_INCLUDED - -#include <@VIEW_BASE_CLASS_H@> -#include - -class QWidget; -class QPushButton; - -@BEGIN_NAMESPACE@ - -/*! - * \ingroup @NormalizedPluginID@_internal - * - * \brief @PLUGIN_NAME@ - * - * You need to reimplement the methods SetFocus() and CreateQtPartControl(QWidget*) - * from @VIEW_BASE_CLASS@ - * - * \sa @VIEW_BASE_CLASS@ - */ -class @VIEW_CLASS@ : public @VIEW_BASE_CLASS@ -{ -public: - - static const std::string VIEW_ID; - - /*! - * \brief Gives focus to a specific control in the view - * This method is called from the framework when the view is activated. - */ - void SetFocus(); - -protected: - - /*! - * \brief Builds the user interface of the view - * This method is called from the framework. The parent widget has no layout, so - * you should set one adapted to your needs. - */ - void CreateQtPartControl(QWidget* parent); - - QPushButton* m_ButtonStart; -}; - -@END_NAMESPACE@ - -#endif /*@UBUNDLE_NAMESPACE@_@UVIEW_CLASS@_H_INCLUDED*/ diff --git a/BlueBerry/CMake/MacroCollectPlugins.cmake b/BlueBerry/CMake/MacroCollectPlugins.cmake deleted file mode 100755 index 1396bc7bf9..0000000000 --- a/BlueBerry/CMake/MacroCollectPlugins.cmake +++ /dev/null @@ -1,197 +0,0 @@ -# Recursively searches for plugins (i.e. directories containing a -# META-INF/MANIFEST.MF file). The macro adds the found directories -# to cmake and writes information about the configured plug-ins in a file -# -# MACRO_COLLECT_PLUGINS(OUTPUT_DIR plugin_output_dir -# [CACHE_PLUGIN_SOURCE_DIRS cache_src_dirs] -# [CACHE_PLUGIN_OUTPUT_DIRS cache_out_dirs] -# [CACHE_PLUGIN_TARGETS cache_plugin_targets] -# [BUNDLE_LIST_PATH bundle_list_path] -# [CMAKE_CACHE_PREFIX cache_prefix] -# [ENABLE_PLUGIN_MACROS macro...] -# [PLUGIN_DEFAULT_ON id...] -# [PLUGIN_EXCLUDES id...] -# [DEFAULT_BUILD_ON] -# [FORCE_BUILD_ALL] -# ) -# -# plugin_output_dir is the common binary output directory for all -# plugins found. It is available as PLUGINS_OUTPUT_BASE_DIR -# and used by the MACRO_CREATE_PLUGIN macro. -# -# CACHE_PLUGIN_SOURCE_DIRS and CACHE_PLUGIN_OUTPUT_DIRS -# names of CMake cache variables where the base plugin source -# and output directories will be appended. This is useful if this -# macro is invoked multiple times in different places and you want -# to record the directories. The variables -# can than later be used to configure your applications .ini file. -# Be sure to clear the cache variables before the first invokation -# of this macro. -# -# CACHE_PLUGIN_TARGETS -# is used as the name of a cache variable which -# stores a list of enabled plug-ins (their CMake target names) -# -# BUNDLE_LIST_PATH -# The full path for the generated cmake file containing the _BUILD_ -# variables. If not set, "${PROJECT_BINARY_DIR}/${PROJECT_NAME}BundleList.cmake" -# is used. -# -# CMAKE_CACHE_PREFIX -# is prepended to the CMake cache variables -# -# ENABLE_PLUGIN_MACROS -# macro... is a list containing macro names which will be evaluated -# to determine if a specific plug-in should be build. The parameter list of -# the macro is () and the macro must set the variable -# ENABLE_PLUGIN to true or false. For Qt4, a default macro is provided. -# -# PLUGIN_DEFAULT_ON -# id... is a list of bundle symbolic names for which the -# CMake build option should default to ON -# -# PLUGIN_EXCLUDES -# id... is a list of bundle symbolic names which will be excluded from -# the build process -# -# DEFAULT_BUILD_ON if set, the generated CMake option for building plug-ins -# defaults to ON. Otherwise, it is set to OFF. -# -# FORCE_BUILD_ALL if set, the BUILD_pluginname variables are ignored and all -# plugins under this directory are build -# -# -# The following variables can be used after the macro is invoked: -# -# PLUGINS_SOURCE_BASE_DIR the directory where this macro has been invoked -# PLUGINS_OUTPUT_BASE_DIR the output directory for the bundles -# ENABLED_PLUGINS_RELATIVE_DIRS a list of bundle directories relative to -# PLUGINS_SOURCE_BASE_DIR which are build -# ENABLED_PLUGINS_ABSOLUTE_DIRS the same as ENABLED_PLUGINS_RELATIVE_DIRS -# but with absolute paths -# -MACRO(MACRO_COLLECT_PLUGINS) - -MACRO_PARSE_ARGUMENTS(_COLLECT "OUTPUT_DIR;CACHE_PLUGIN_SOURCE_DIRS;CACHE_PLUGIN_OUTPUT_DIRS;CACHE_PLUGIN_TARGETS;BUNDLE_LIST_PATH;PLUGIN_EXCLUDES;PLUGIN_DEFAULT_ON;CMAKE_CACHE_PREFIX;ENABLE_PLUGIN_MACROS" "DEFAULT_BUILD_ON;FORCE_BUILD_ALL" ${ARGN}) - -IF(NOT _COLLECT_ADD_DIR) - SET(_COLLECT_ADD_DIR 1) -ENDIF(NOT _COLLECT_ADD_DIR) - -IF(NOT _COLLECT_BUNDLE_LIST_PATH) - SET(_COLLECT_BUNDLE_LIST_PATH "${PROJECT_BINARY_DIR}/${PROJECT_NAME}BundleList.cmake") -ENDIF(NOT _COLLECT_BUNDLE_LIST_PATH) - -IF(_COLLECT_CMAKE_CACHE_PREFIX) - SET(_COLLECT_CMAKE_CACHE_PREFIX "${_COLLECT_CMAKE_CACHE_PREFIX}_") -ENDIF(_COLLECT_CMAKE_CACHE_PREFIX) - -LIST(APPEND _COLLECT_ENABLE_PLUGIN_MACROS "_MACRO_ENABLE_QT4_PLUGINS") - -SET(PLUGINS_OUTPUT_BASE_DIR ${_COLLECT_OUTPUT_DIR}) - -# writes the file ${CMAKE_CURRENT_BINARY_DIR}/berryEnablePlugin.cmake -_MACRO_CREATE_ENABLE_PLUGIN_CODE(${_COLLECT_ENABLE_PLUGIN_MACROS}) - -SET(PLUGINS_SOURCE_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - -IF(_COLLECT_CACHE_PLUGIN_SOURCE_DIRS) - SET(${_COLLECT_CACHE_PLUGIN_SOURCE_DIRS} ${${_COLLECT_CACHE_PLUGIN_SOURCE_DIRS}} "\"${PLUGINS_SOURCE_BASE_DIR}\"" - CACHE INTERNAL "List of base plugin source directories" FORCE) -ENDIF(_COLLECT_CACHE_PLUGIN_SOURCE_DIRS) - -IF(_COLLECT_CACHE_PLUGIN_OUTPUT_DIRS) - SET(${_COLLECT_CACHE_PLUGIN_OUTPUT_DIRS} ${${_COLLECT_CACHE_PLUGIN_OUTPUT_DIRS}} "${_COLLECT_OUTPUT_DIR}" - CACHE INTERNAL "List of base plugin output directories" FORCE) -ENDIF(_COLLECT_CACHE_PLUGIN_OUTPUT_DIRS) - -SET(ENABLED_PLUGINS_RELATIVE_DIRS ) -SET(ENABLED_PLUGINS_ABSOLUTE_DIRS ) -SET(_plugins_target_list ) -FILE(GLOB all_dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *) -FOREACH(dir_relative_entry ${all_dirs}) - SET(dir_entry "${CMAKE_CURRENT_SOURCE_DIR}/${dir_relative_entry}") - IF(EXISTS "${dir_entry}/META-INF/MANIFEST.MF") - MACRO_PARSE_MANIFEST("${dir_entry}/META-INF/MANIFEST.MF" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${dir_relative_entry}") - - IF(BUNDLE-SYMBOLICNAME) - - LIST(FIND _COLLECT_PLUGIN_EXCLUDES ${BUNDLE-SYMBOLICNAME} _excluded) - IF(_excluded EQUAL -1) - - # include the generated file with the custom macro code for - # checking if a bundle should be enabled - INCLUDE("${_enable_plugins_file}") - - IF(_enable_bundle) - # The bundle is considered valid for the current configuration - # i.e. a build option will be displayed and internal variables are set - - SET(${BUNDLE-SYMBOLICNAME}_SRC_DIR "${dir_entry}") - SET(${BUNDLE-SYMBOLICNAME}_BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/${dir_relative_entry}") - SET(${BUNDLE-SYMBOLICNAME}_OUT_DIR "${_COLLECT_OUTPUT_DIR}/${BUNDLE-SYMBOLICNAME}") - # write the variable in .cmake file, so external projects have access to them - SET(BLUEBERRY_BUNDLE_VARIABLES "${BLUEBERRY_BUNDLE_VARIABLES} -SET(${BUNDLE-SYMBOLICNAME}_SRC_DIR \"${${BUNDLE-SYMBOLICNAME}_SRC_DIR}\") -SET(${BUNDLE-SYMBOLICNAME}_BIN_DIR \"${${BUNDLE-SYMBOLICNAME}_BIN_DIR}\") -SET(${BUNDLE-SYMBOLICNAME}_OUT_DIR \"${${BUNDLE-SYMBOLICNAME}_OUT_DIR}\")") - - # compute the default for the build option (ON/OFF) - SET(_default_bundle_option ${_COLLECT_DEFAULT_BUILD_ON}) - LIST(FIND _COLLECT_PLUGIN_DEFAULT_ON ${BUNDLE-SYMBOLICNAME} _PLUGIN_DEFAULT_ON_found) - IF(_PLUGIN_DEFAULT_ON_found GREATER -1) - SET(_default_bundle_option 1) - ENDIF() - - OPTION("${_COLLECT_CMAKE_CACHE_PREFIX}BUILD_${BUNDLE-SYMBOLICNAME}" "Build ${BUNDLE-SYMBOLICNAME} Plugin" ${_default_bundle_option}) - - # test if the bundle should be build - IF(${_COLLECT_CMAKE_CACHE_PREFIX}BUILD_${BUNDLE-SYMBOLICNAME} OR _COLLECT_FORCE_BUILD_ALL) - LIST(APPEND ENABLED_PLUGINS_RELATIVE_DIRS "${dir_relative_entry}") - LIST(APPEND ENABLED_PLUGINS_ABSOLUTE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/${dir_relative_entry}") - STRING(REPLACE . _ _plugin_target ${BUNDLE-SYMBOLICNAME}) - - SET(${dir_relative_entry}_forced_build ${_COLLECT_FORCE_BUILD_ALL}) - - # record that this bundle is being build. - SET(_BUILD_${BUNDLE-SYMBOLICNAME} 1) - SET(BLUEBERRY_BUNDLE_VARIABLES "${BLUEBERRY_BUNDLE_VARIABLES} -SET(_BUILD_${BUNDLE-SYMBOLICNAME} 1)") - - ELSE() - # the build option for the bundle is off, hence we delete the MANIFEST.MF - # file in the output directory to prevent the bundle loader from finding - # the disabled bundle. - FILE(REMOVE "${${BUNDLE-SYMBOLICNAME}_OUT_DIR}/META-INF/MANIFEST.MF") - ENDIF() - ENDIF() - ENDIF() - ENDIF() - ENDIF() -ENDFOREACH() - -# add Poco directories for all plugins -INCLUDE_DIRECTORIES(${Poco_INCLUDE_DIRS}) -LINK_DIRECTORIES(${Poco_LIBRARY_DIR}) - -SET(PLUGIN_TARGETS "" CACHE INTERNAL "Temporary list of plug-in targets") -FOREACH(_subdir ${ENABLED_PLUGINS_RELATIVE_DIRS}) - INCLUDE("${CMAKE_CURRENT_BINARY_DIR}/${_subdir}/Manifest.cmake") - IF(${_subdir}_forced_build) - SET(CURRENT_PLUGIN_BUILD_FORCED ON) - ELSE() - SET(CURRENT_PLUGIN_BUILD_FORCED OFF) - ENDIF() - #MACRO_PARSE_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}/${_subdir}/META-INF/MANIFEST.MF") - ADD_SUBDIRECTORY(${_subdir}) -ENDFOREACH(_subdir ${ENABLED_PLUGINS_RELATIVE_DIRS}) - -IF(_COLLECT_CACHE_PLUGIN_TARGETS) - SET(${_COLLECT_CACHE_PLUGIN_TARGETS} ${PLUGIN_TARGETS} CACHE INTERNAL "A list of enabled plug-ins") -ENDIF(_COLLECT_CACHE_PLUGIN_TARGETS) - -IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/BundleList.cmake.in) - CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/BundleList.cmake.in" "${_COLLECT_BUNDLE_LIST_PATH}" @ONLY) -ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/BundleList.cmake.in) - -ENDMACRO(MACRO_COLLECT_PLUGINS) diff --git a/BlueBerry/CMake/MacroCreatePlugin.cmake b/BlueBerry/CMake/MacroCreatePlugin.cmake deleted file mode 100755 index bbeb9e50b9..0000000000 --- a/BlueBerry/CMake/MacroCreatePlugin.cmake +++ /dev/null @@ -1,218 +0,0 @@ -# MACRO_CREATE_PLUGIN() -# -# Creates the current plugin. -# This macro should be called from the plugins CMakeLists.txt file. The plugin -# library is build in a subdirectory of PLUGIN_OUTPUT_DIR, which is derived from -# the variable PLUGIN_OUTPUT_BASE_DIR coming from COLLECT_PLUGINS(). -# The target name is available as PLUGIN_TARGET -# to add additional libraries in your CMakeLists.txt. Include paths and link -# libraries are set depending on the value of the Required-Bundles header -# in your plugins MANIFEST.MF file. -# -# Available variables: -# -# - PLUGIN_OUTPUT_DIR the binary output directory of your plugin -# - PLUGIN_TARGET the target name of your plugins dll -# -# -MACRO(MACRO_CREATE_PLUGIN) - - IF(MSVC80) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) - ENDIF(MSVC80) - - MESSAGE(STATUS "Creating plugin ${BUNDLE-SYMBOLICNAME}") - PROJECT(${BUNDLE-SYMBOLICNAME}) - - STRING(REPLACE . _ PLUGIN_TARGET ${BUNDLE-SYMBOLICNAME}) - - SET(PLUGIN_OUTPUT_DIR ${${BUNDLE-SYMBOLICNAME}_OUT_DIR}) - FILE(MAKE_DIRECTORY ${PLUGIN_OUTPUT_DIR}) - - INCLUDE(files.cmake) - - SET(PLUGIN_CPP_FILES ${CPP_FILES}) - SET(PLUGIN_MOC_H_FILES ${MOC_H_FILES}) - SET(PLUGIN_UI_FILES ${UI_FILES}) - SET(PLUGIN_RESOURCE_FILES ${RESOURCE_FILES}) - SET(PLUGIN_RES_FILES ${RES_FILES}) - SET(PLUGIN_H_FILES ${H_FILES}) - SET(PLUGIN_TXX_FILES ${TXX_FILES}) - SET(PLUGIN_DOX_FILES ${DOX_FILES}) - SET(PLUGIN_CMAKE_FILES ${CMAKE_FILES} files.cmake) - SET(PLUGIN_FILE_DEPENDENCIES ${FILE_DEPENDENCIES}) - - - # Copy the META-INF directory into the binary output dir - - SET (PLUGIN_META_FILES ${PLUGIN_META_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/META-INF/MANIFEST.MF) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/META-INF/MANIFEST.MF ${PLUGIN_OUTPUT_DIR}/META-INF/MANIFEST.MF COPYONLY) - - # Copy the plugin.xml into the binary output dir - SET(PLUGINXML ${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml) - IF(EXISTS ${PLUGINXML}) - SET (PLUGIN_META_FILES ${PLUGIN_META_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml) - CONFIGURE_FILE(${PLUGINXML} ${PLUGIN_OUTPUT_DIR}/plugin.xml COPYONLY) - ENDIF(EXISTS ${PLUGINXML}) - - # Copy the resource files into the binary output dir - FOREACH(_resource ${PLUGIN_RESOURCE_FILES}) - CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/${_resource}" "${PLUGIN_OUTPUT_DIR}/${_resource}" COPYONLY) - ENDFOREACH(_resource ${PLUGIN_RESOURCE_FILES}) - - SET(PLUGIN_GENERATED_UI_FILES ) - IF(PLUGIN_UI_FILES) - QT4_WRAP_UI(PLUGIN_GENERATED_UI_FILES ${PLUGIN_UI_FILES}) - ENDIF(PLUGIN_UI_FILES) - - SET(PLUGIN_GENERATED_MOC_FILES ) - IF(PLUGIN_MOC_H_FILES) - # 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. See bug #1961 - # for details. - FOREACH(moc_h_file ${PLUGIN_MOC_H_FILES}) - QT4_WRAP_CPP(PLUGIN_GENERATED_MOC_FILES ${moc_h_file} OPTIONS -f${moc_h_file}) - ENDFOREACH(moc_h_file) - ENDIF(PLUGIN_MOC_H_FILES) - - SET(PLUGIN_GENERATED_QRC_FILES ) - IF(PLUGIN_RES_FILES) - QT4_ADD_RESOURCES(PLUGIN_GENERATED_QRC_FILES ${PLUGIN_RES_FILES}) - ENDIF(PLUGIN_RES_FILES) - - #------------------------------------------------------------# - #------------------ Qt Help support -------------------------# - - SET(PLUGIN_GENERATED_QCH_FILES ) - IF (BLUEBERRY_USE_QT_HELP AND - EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual") - SET(PLUGIN_DOXYGEN_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual") - SET(PLUGIN_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/documentation/UserManual") - _MACRO_CREATE_QT_COMPRESSED_HELP(PLUGIN_GENERATED_QCH_FILES ) - ENDIF() - - - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}) - IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/includes.cmake") - INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/includes.cmake) - FOREACH(_added_incldir ${ADDITIONAL_INCLUDE_DIRECTORIES}) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/${_added_incldir}) - ENDFOREACH() - ENDIF() - _MACRO_SETUP_PLUGIN_DEPENDENCIES(_linklibs) - - MACRO_ORGANIZE_SOURCES(SOURCE ${PLUGIN_CPP_FILES} - HEADER ${PLUGIN_H_FILES} - TXX ${PLUGIN_TXX_FILES} - DOC ${PLUGIN_DOX_FILES} - UI ${PLUGIN_UI_FILES} - QRC ${PLUGIN_RES_FILES} - META ${PLUGIN_META_FILES} - MOC ${PLUGIN_GENERATED_MOC_FILES} - GEN_UI ${PLUGIN_GENERATED_UI_FILES} - GEN_QRC ${PLUGIN_GENERATED_QRC_FILES}) - - SET(_all_target_files - ${PLUGIN_CPP_FILES} - ${PLUGIN_H_FILES} - ${PLUGIN_TXX_FILES} - ${PLUGIN_DOX_FILES} - ${PLUGIN_UI_FILES} - ${PLUGIN_RES_FILES} - ${PLUGIN_META_FILES} - ${PLUGIN_GENERATED_MOC_FILES} - ${PLUGIN_GENERATED_UI_FILES} - ${PLUGIN_GENERATED_QRC_FILES} - ${PLUGIN_GENERATED_QCH_FILES} - ${PLUGIN_CMAKE_FILES} - ${CORRESPONDING__H_FILES} - ${GLOBBED__H_FILES} - ${PLUGIN_FILE_DEPENDENCIES} - ) - - ADD_LIBRARY(${PLUGIN_TARGET} ${_all_target_files}) - SET(PLUGIN_TARGETS ${PLUGIN_TARGETS} ${PLUGIN_TARGET} CACHE INTERNAL "Temporary list of plug-in targets") - SET_TARGET_PROPERTIES(${PLUGIN_TARGET} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}/bin" - LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}/bin" - ARCHIVE_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}/bin" - DEBUG_POSTFIX ${BLUEBERRY_DEBUG_POSTFIX}) - - IF(mbilog_FOUND) - TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} mbilog) - ENDIF() - - # we need to explicitly state the debug versions of the libraries - # we are linking to in the TARGET_LINK_LIBRARIES command. - # Although we set the debug postfix to d, CMake automatically - # appends it in a TARGET_LINK_LIBRARIES(target lib1) command only - # if lib1 has been build within the same project. - # External projects using this macro would therefore always link - # to lib1, instead of lib1d in debug configurations - SET(_debug_linklibs "") - FOREACH(_linklib ${PLUGIN_LINK_LIBRARIES}) - # Use a hack to test if the dependency is a BlueBerry bundle - STRING(REPLACE . _ _symbolic_name ${_linklib}) - IF(EXISTS "${${_symbolic_name}_OUT_DIR}") - SET(_debug_linklibs ${_debug_linklibs} optimized "${_linklib}" debug "${_linklib}${BLUEBERRY_DEBUG_POSTFIX}") - ELSE() - SET(_debug_linklibs ${_debug_linklibs} ${_linklib}) - ENDIF() - ENDFOREACH(_linklib) - - TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ${_debug_linklibs}) - TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} - optimized "PocoFoundation" debug "PocoFoundation${BLUEBERRY_DEBUG_POSTFIX}" - optimized "PocoUtil" debug "PocoUtil${BLUEBERRY_DEBUG_POSTFIX}" - optimized "PocoXML" debug "PocoXML${BLUEBERRY_DEBUG_POSTFIX}") - - # Fix a "bug" in CMake, which does not include all transitive link libraries for a given target - LIST(FIND PLUGIN_LINK_LIBRARIES org_blueberry_test _is_unittest_plugin) - IF(NOT _is_unittest_plugin EQUAL -1) - TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} optimized CppUnit debug CppUnitd) - ENDIF() - - IF(MINGW) - TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ssp) # add stack smash protection lib - ENDIF() - - #SET_TARGET_PROPERTIES(${PLUGIN_TARGET} PROPERTIES PREFIX lib IMPORT_PREFIX lib) - SET_TARGET_PROPERTIES(${PLUGIN_TARGET} PROPERTIES PREFIX lib) - - - #------------------------------------------------------------# - #------------------ Installer support -----------------------# - SET(install_directories "") - IF(NOT MACOSX_BUNDLE_NAMES) - SET(install_directories bin) - ELSE(NOT MACOSX_BUNDLE_NAMES) - FOREACH(bundle_name ${MACOSX_BUNDLE_NAMES}) - LIST(APPEND install_directories ${bundle_name}.app/Contents/MacOS) - ENDFOREACH(bundle_name) - ENDIF(NOT MACOSX_BUNDLE_NAMES) - -FOREACH(install_subdir ${install_directories}) - - FILE(RELATIVE_PATH _toplevel_dir "${PLUGINS_SOURCE_BASE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") - STRING(REGEX REPLACE ".*/(.+)/?$" "\\1" _toplevel_output_dir ${PLUGINS_OUTPUT_BASE_DIR}) - MACRO_INSTALL_PLUGIN("${PLUGINS_OUTPUT_BASE_DIR}/${_toplevel_dir}" - TARGETS ${PLUGIN_TARGET} - DESTINATION "${install_subdir}/${_toplevel_output_dir}") - -ENDFOREACH() - -ENDMACRO(MACRO_CREATE_PLUGIN) - - -# Macro to set specific Qt options, calls CREATE_PLUGIN at the end -MACRO(MACRO_CREATE_QT_PLUGIN) - - IF(QT4_FOUND) - INCLUDE(${QT_USE_FILE}) - - MACRO_CREATE_PLUGIN() - - TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ${QT_LIBRARIES}) - ENDIF(QT4_FOUND) - -ENDMACRO(MACRO_CREATE_QT_PLUGIN) diff --git a/BlueBerry/CMake/MacroCreateQtHelp.cmake b/BlueBerry/CMake/MacroCreateQtHelp.cmake index 28b2acbbf2..4f0d158de2 100644 --- a/BlueBerry/CMake/MacroCreateQtHelp.cmake +++ b/BlueBerry/CMake/MacroCreateQtHelp.cmake @@ -1,62 +1,42 @@ -MACRO(_MACRO_CREATE_QT_COMPRESSED_HELP qch_file) - - CONFIGURE_FILE(${BlueBerry_SOURCE_DIR}/CMake/berryQtHelpDoxygen.conf.in - ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf - ) - - SET(_generated_qch_file "${PLUGIN_DOXYGEN_OUTPUT_DIR}/qch/${BUNDLE-NAME}.qch") - SET(${qch_file} "${PLUGIN_OUTPUT_DIR}/resources/${BUNDLE-SYMBOLICNAME}.qch") - - FILE(GLOB _file_dependencies "${PLUGIN_DOXYGEN_INPUT_DIR}/*.dox") - - ADD_CUSTOM_COMMAND(OUTPUT ${${qch_file}} - COMMAND ${DOXYGEN_EXECUTABLE} ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_generated_qch_file} ${${qch_file}} - DEPENDS ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf ${_file_dependencies} - ) - - #SET_SOURCE_FILES_PROPERTIES(${qch_file} PROPERTIES GENERATED 1) - -ENDMACRO() FUNCTION(_FUNCTION_CREATE_CTK_QT_COMPRESSED_HELP qch_file use_xsl) SET(_manifest_path "${CMAKE_CURRENT_SOURCE_DIR}/manifest_headers.cmake") IF(NOT EXISTS ${_manifest_path}) MESSAGE(FATAL_ERROR "${_manifest_path} not found") ENDIF() INCLUDE(${_manifest_path}) STRING(REPLACE "_" "." Plugin-SymbolicName "${PLUGIN_TARGET}") CONFIGURE_FILE(${BlueBerry_SOURCE_DIR}/CMake/berryCTKQtHelpDoxygen.conf.in ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf ) SET(_qhp_xsl_file "${BlueBerry_SOURCE_DIR}/CMake/qhp_toc.xsl") SET(_generated_qhp_file "${PLUGIN_DOXYGEN_OUTPUT_DIR}/html/index.qhp") SET(_transformed_qhp_file "${PLUGIN_DOXYGEN_OUTPUT_DIR}/html/${PLUGIN_TARGET}.qhp") SET(${qch_file} "${CMAKE_CURRENT_BINARY_DIR}/resources/${PLUGIN_TARGET}.qch") SET(_xsl_command ) IF(use_xsl) SET(_xsl_command COMMAND ${QT_XMLPATTERNS_EXECUTABLE} ${_qhp_xsl_file} ${_generated_qhp_file} -output ${_transformed_qhp_file}) ENDIF() FILE(GLOB _file_dependencies "${PLUGIN_DOXYGEN_INPUT_DIR}/*") ADD_CUSTOM_COMMAND(OUTPUT ${${qch_file}} # Generate a Qt help project (index.qhp) with doxygen COMMAND ${DOXYGEN_EXECUTABLE} ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf # Use a XSL transformation to get rid of the top-level entry ${_xsl_command} # Generate the final Qt compressed help file (.qch) COMMAND ${QT_HELPGENERATOR_EXECUTABLE} ${_transformed_qhp_file} -o ${${qch_file}} DEPENDS ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf ${_file_dependencies} ) #SET_SOURCE_FILES_PROPERTIES(${qch_file} PROPERTIES GENERATED 1) SET(${qch_file} ${${qch_file}} PARENT_SCOPE) ENDFUNCTION() diff --git a/BlueBerry/CMake/MacroInstallPlugin.cmake b/BlueBerry/CMake/MacroInstallPlugin.cmake deleted file mode 100644 index 43c7d4f5a8..0000000000 --- a/BlueBerry/CMake/MacroInstallPlugin.cmake +++ /dev/null @@ -1,84 +0,0 @@ -# Install the given plug-in directory to the desintation directory -# -# MACRO_INSTALL_PLUGIN(plugindir [TARGETS target...] [DESTINATION dest_dir]) -# -MACRO(MACRO_INSTALL_PLUGIN _plugin_dir) - - MACRO_PARSE_ARGUMENTS(_INSTALL "TARGETS;DESTINATION" "" ${ARGN}) - - # Convert _plugin_dir into an absolute path - IF(NOT IS_ABSOLUTE _plugin_dir) - SET(_plugin_dir "${CMAKE_CURRENT_SOURCE_DIR}/${_plugin_dir}") - ENDIF() - - # Check if target names have been specified - IF(NOT _INSTALL_TARGETS) - # no targets specified. get the main target from the plug-ins manifest if it exists - IF(EXISTS "${_plugin_dir}/META-INF/MANIFEST.MF") - MACRO_PARSE_MANIFEST("${_plugin_dir}/META-INF/MANIFEST.MF") - STRING(REPLACE "." "_" _INSTALL_TARGETS ${BUNDLE-SYMBOLICNAME}) - ENDIF() - ENDIF() - - # Only continue if _INSTALL_TARGETS is set - IF(_INSTALL_TARGETS) - - IF(NOT _INSTALL_DESTINATION) - SET(_INSTALL_DESTINATION "bin/") - ELSE() - SET(_INSTALL_DESTINATION "${_INSTALL_DESTINATION}/") - ENDIF() - - STRING(REGEX REPLACE ".*/(.+)/?$" "\\1" _toplevel_plugindir ${_plugin_dir}) - SET(_plugin_install_dir "${_INSTALL_DESTINATION}${_toplevel_plugindir}") - - # Install the directory without shared libraries - INSTALL(DIRECTORY ${_plugin_dir} DESTINATION ${_INSTALL_DESTINATION} CONFIGURATIONS Debug - PATTERN "Release/*" EXCLUDE - PATTERN "bin/*" EXCLUDE - PATTERN "lib/*" EXCLUDE) - - INSTALL(DIRECTORY ${_plugin_dir} DESTINATION ${_INSTALL_DESTINATION} CONFIGURATIONS Release - PATTERN "Debug/*" EXCLUDE - PATTERN "bin/*" EXCLUDE - PATTERN "lib/*" EXCLUDE) - - SET(_target_install_rpath ${CMAKE_INSTALL_RPATH}) - FOREACH(_dep ${_plugin_dependencies}) - SET(_linklib_path "${${_dep}_OUT_DIR}") - IF(_linklib_path) - IF(BLUEBERRY_INSTALL_RPATH_RELATIVE) - #MESSAGE("replace ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} with \".\" in ${_linklib_path} ") - STRING(REPLACE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "." _linklib_path "${_linklib_path}") - ELSE() - STRING(REPLACE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "${CMAKE_INSTALL_PREFIX}/bin" _linklib_path "${_linklib_path}") - ENDIF() - LIST(APPEND _target_install_rpath "${_linklib_path}/bin") - ENDIF() - ENDFOREACH() - SET_TARGET_PROPERTIES(${_INSTALL_TARGETS} - PROPERTIES INSTALL_RPATH "${_target_install_rpath}") - - FOREACH(_install_target ${_INSTALL_TARGETS}) - GET_TARGET_PROPERTY(_is_imported ${_install_target} IMPORTED) - IF(_is_imported) - GET_TARGET_PROPERTY(_import_loc_debug ${_install_target} IMPORTED_LOCATION_DEBUG) - GET_TARGET_PROPERTY(_import_loc_release ${_install_target} IMPORTED_LOCATION_RELEASE) - INSTALL(FILES ${_import_loc_debug} - DESTINATION ${_plugin_install_dir}/bin - CONFIGURATIONS Debug) - INSTALL(FILES ${_import_loc_release} - DESTINATION ${_plugin_install_dir}/bin - CONFIGURATIONS Release) - ELSE() - INSTALL(TARGETS ${_INSTALL_TARGETS} - RUNTIME DESTINATION ${_plugin_install_dir}/bin - LIBRARY DESTINATION ${_plugin_install_dir}/bin - #ARCHIVE DESTINATION ${_plugin_install_dir}/bin - ) - ENDIF() - ENDFOREACH() - - ENDIF() # _INSTALL_TARGETS - -ENDMACRO() diff --git a/BlueBerry/CMake/MacroInstallThirdPartyPlugins.cmake b/BlueBerry/CMake/MacroInstallThirdPartyPlugins.cmake deleted file mode 100644 index 1170aa1a82..0000000000 --- a/BlueBerry/CMake/MacroInstallThirdPartyPlugins.cmake +++ /dev/null @@ -1,26 +0,0 @@ -MACRO(MACRO_INSTALL_THIRDPARTY_PLUGINS plugins_dir install_dir) - - SET(install_directories "") - IF(NOT MACOSX_BUNDLE_NAMES) - SET(install_directories bin) - ELSE() - FOREACH(bundle_name ${MACOSX_BUNDLE_NAMES}) - LIST(APPEND install_directories ${bundle_name}.app/Contents/MacOS) - ENDFOREACH(bundle_name) - ENDIF(NOT MACOSX_BUNDLE_NAMES) - - FILE(GLOB_RECURSE plugins - # glob for all blueberry bundles in this directory - "${plugins_dir}/liborg*${CMAKE_SHARED_LIBRARY_SUFFIX}") - - FOREACH(plugin ${plugins}) - - FILE(RELATIVE_PATH _toplevel_dir "${plugins_dir}" "${plugin}") - STRING(REGEX REPLACE "([^/]+)/.*$" "\\1" _plugin_base_dir ${_toplevel_dir}) - - FOREACH(install_subdir ${install_directories}) - MACRO_INSTALL_PLUGIN("${plugins_dir}/${_plugin_base_dir}" - DESTINATION "${install_subdir}/${install_dir}") - ENDFOREACH() - ENDFOREACH() -ENDMACRO() \ No newline at end of file diff --git a/BlueBerry/CMake/MacroParseManifest.cmake b/BlueBerry/CMake/MacroParseManifest.cmake deleted file mode 100755 index 262c6d2291..0000000000 --- a/BlueBerry/CMake/MacroParseManifest.cmake +++ /dev/null @@ -1,81 +0,0 @@ -# -# MACRO_PARSE_MANIFEST(manifest [GENERATE_CMAKE_FILE]) -# -# parses the file given as an absolute path in and -# optionally writes the key/value pairs as CMake variables in -# the current binary directory with filename _MF.cmake. -# -# The keys in the manifest file are available as upper case CMake -# variables after this macro completes. -# -MACRO(MACRO_PARSE_MANIFEST _manifest_) - - MACRO_PARSE_ARGUMENTS(_PARSE "OUTPUT" "" ${ARGN}) - - # clear all supported manifest headers - SET(BUNDLE-ACTIVATOR "") - SET(BUNDLE-COPYRIGHT "") - SET(BUNDLE-ACTIVATIONPOLICY "") - SET(BUNDLE-NAME "") - SET(BUNDLE-SYMBOLICNAME "") - SET(BUNDLE-VENDOR "") - SET(BUNDLE-VERSION "") - SET(MANIFEST-VERSION "") - SET(BERRY-SYSTEMBUNDLE "") - SET(REQUIRE-BUNDLE "") - - SET(_file "${_manifest_}") - - FILE(STRINGS "${_file}" _mflines LENGTH_MINIMUM 1 REGEX "[^ ]+.*:[]*[^ ]+") - - SET(_mfcontent "SET(BUNDLE-ACTIVATOR ) -SET(BUNDLE-COPYRIGHT ) -SET(BUNDLE-ACTIVATIONPOLICY ) -SET(BUNDLE-NAME ) -SET(BUNDLE-SYMBOLICNAME ) -SET(BUNDLE-VENDOR ) -SET(BUNDLE-VERSION ) -SET(MANIFEST-VERSION ) -SET(BERRY-SYSTEMBUNDLE ) -SET(REQUIRE-BUNDLE )") - - SET(_rbcontent "SET(REQUIRE-BUNDLE )") - - FOREACH(_line ${_mflines}) - STRING(REGEX MATCH "[^ ^:]+" _key "${_line}") - STRING(REGEX REPLACE "^[^:]*[:](.*)" "\\1" _value "${_line}") - - STRING(STRIP "${_value}" _value) - - #MESSAGE(SEND_ERROR "(${_key}, ${_value})") - - STRING(TOUPPER "${_key}" _ukey) - - IF(${_ukey} STREQUAL "REQUIRE-BUNDLE") - # special handling for Require-Bundle - # we generate a proper CMake list out of the comma-separated bundle-ids - STRING(REPLACE "," ";" _value ${_value}) - - FOREACH(_dep ${_value}) - # remove leading and trailing whitespace - STRING(STRIP ${_dep} _trimeddep) - LIST(APPEND ${_ukey} ${_trimeddep}) - ENDFOREACH() - - SET(_rbcontent "SET(REQUIRE-BUNDLE \"${${_ukey}}\")") - ELSE() - SET(${_ukey} "${_value}") - ENDIF() - - SET(_mfcontent "${_mfcontent} - -SET(${_ukey} \"${${_ukey}}\")") - - ENDFOREACH(_line ${_mflines}) - - IF(_PARSE_OUTPUT) - CONFIGURE_FILE("${BLUEBERRY_SOURCE_DIR}/CMake/berryPluginManifest.cmake.in" "${_PARSE_OUTPUT}/Manifest.cmake" @ONLY) - CONFIGURE_FILE("${BLUEBERRY_SOURCE_DIR}/CMake/berryRequireBundle.cmake.in" "${_PARSE_OUTPUT}/RequireBundle.cmake" @ONLY) - ENDIF() - -ENDMACRO(MACRO_PARSE_MANIFEST) \ No newline at end of file diff --git a/BlueBerry/CMake/berryEnablePlugin.cmake.in b/BlueBerry/CMake/berryEnablePlugin.cmake.in deleted file mode 100644 index 8db9aeadc1..0000000000 --- a/BlueBerry/CMake/berryEnablePlugin.cmake.in +++ /dev/null @@ -1 +0,0 @@ -@_enable_plugins_filecontent@ \ No newline at end of file diff --git a/BlueBerry/CMake/berryPluginHelpers.cmake b/BlueBerry/CMake/berryPluginHelpers.cmake deleted file mode 100644 index 5e69bbaa36..0000000000 --- a/BlueBerry/CMake/berryPluginHelpers.cmake +++ /dev/null @@ -1,227 +0,0 @@ -# _MACRO_CREATE_PLUGIN_NAME(output_name -# INPUT dir -# [BASEDIR basedir] -# ) -# -# sets output_name to the plugin-name -# the plugin-name is computed by removing basedir from dir and -# replacing slashes with points -# -# Example: BASEDIR=/root -# INPUT=/root/org/blueberry/ui.qt -# output_name=org.blueberry.ui.qt -# -MACRO(_MACRO_CREATE_PLUGIN_NAME output_name) - - MACRO_PARSE_ARGUMENTS(_CREATE_NAME "INPUT;BASEDIR" "" ${ARGN}) - - STRING(REPLACE "${_CREATE_NAME_BASEDIR}/" "" _name_with_slashes ${_CREATE_NAME_INPUT}) - STRING(REPLACE "/" "." _name_with_points ${_name_with_slashes}) - - SET(${output_name} ${_name_with_points}) - -ENDMACRO() - -MACRO(_MACRO_REQUIRED_BUNDLES_LIST output_list input_file) - - SET(_file "${input_file}") - FILE(STRINGS "${_file}" _mfline LENGTH_MINIMUM 1 REGEX " *Require-Bundle *: *[^ ]+") - STRING(REGEX REPLACE "^[^:]*[:](.*)" "\\1" _reqb_input "${_mfline}") - - SET(_reqb_dependencies ) - IF(_reqb_input) - STRING(REPLACE "," ";" _reqb_dependencies ${_reqb_input}) - ENDIF(_reqb_input) - - FOREACH(_dep ${_reqb_dependencies}) - # remove leading and trailing whitespace - STRING(STRIP ${_dep} _trimeddep) - LIST(APPEND ${output_list} ${_trimeddep}) - ENDFOREACH(_dep ${_reqb_dependencies}) -ENDMACRO() - - - -# _MACRO_SETUP_PLUGIN_DEPENDENCIES( -# _explicit_libs -# PLUGIN_NAME _plugin_name -# ) -# -MACRO(_MACRO_SETUP_PLUGIN_DEPENDENCIES _explicit_libs) - - SET(_plugin_src_dir ${${BUNDLE-SYMBOLICNAME}_SRC_DIR}) - SET(_plugin_dependencies ${REQUIRE-BUNDLE}) - SET(_bundle_id ${BUNDLE-SYMBOLICNAME}) - - FOREACH(_dep ${_plugin_dependencies}) - STRING(REPLACE . _ _dep_target ${_dep}) - SET(${_explicit_libs} ${${_explicit_libs}} ${_dep_target}) - ENDFOREACH() - - SET(_plugin_old_dependencies "") - SET(_dep_error 0) - WHILE(NOT "${_plugin_dependencies}" STREQUAL "${_plugin_old_dependencies}") - SET(_plugin_old_dependencies ${_plugin_dependencies}) - - FOREACH(_dep ${_plugin_dependencies}) - - SET(_plugin_src_dir ${${_dep}_SRC_DIR}) - SET(_is_ctk_dep ) - IF(NOT _plugin_src_dir) # maybe it is a CTK plugin dependency - STRING(REPLACE . _ _dep_target ${_dep}) - #MESSAGE("check if ${_dep_target}_DEPENDENCIES is set: ${${_dep_target}_DEPENDENCIES}") - #MESSAGE("looking if ${_dep_target} is in: ${CTK_PLUGIN_LIBRARIES}") - # Check if it is an external CTK plugin dependency - ctkFunctionGetAllPluginTargets(_all_ctk_plugins) - ctkMacroGetAllNonProjectTargetLibraries("${_all_ctk_plugins}" _external_ctk_plugins) - ctkMacroGetAllProjectTargetLibraries("${_all_ctk_plugins}" _internal_ctk_plugins) - LIST(FIND _external_ctk_plugins ${_dep_target} dep_found) - IF(dep_found GREATER -1) - SET(_BUILD_${_dep} ON) # Mark it as available - SET(_is_ctk_dep 1) - ELSE() - #Check if it is an internal CTK plugin dependency - LIST(FIND _internal_ctk_plugins ${_dep_target} dep_found) - IF(dep_found GREATER -1) - SET(_BUILD_${_dep} ON) - GetMyTargetLibraries("${${_dep_target}_DEPENDENCIES}" _ctk_deps) - #MESSAGE("********** _ctk_deps: ${_ctk_deps}") - FOREACH(_ctk_dep_target ${_ctk_deps}) - STRING(REPLACE _ . _ctk_dep ${_ctk_dep_target}) - LIST(APPEND _plugin_dependencies ${_ctk_dep}) - SET(_BUILD_${_ctk_dep} ON) - ENDFOREACH() - #MESSAGE("******* new dependencies: ${_plugin_dependencies}") - SET(_is_ctk_dep 1) - #MESSAGE("new _plugin_dependencies: ${_plugin_dependencies}") - ENDIF() - ENDIF() - ENDIF() - - IF(NOT _is_ctk_dep) - IF(NOT _plugin_src_dir) - MESSAGE(SEND_ERROR "Plug-in dependency \"${_dep}\" does not seem to exist.") - SET(_dep_error 1) - BREAK() - ENDIF() - - #_MACRO_REQUIRED_BUNDLES_LIST(_plugin_dependencies "${_plugin_src_dir}/META-INF/MANIFEST.MF") - INCLUDE(${${_dep}_BIN_DIR}/RequireBundle.cmake) - LIST(APPEND _plugin_dependencies ${REQUIRE-BUNDLE}) - ENDIF() - - ENDFOREACH() - - LIST(REMOVE_DUPLICATES _plugin_dependencies) - LIST(SORT _plugin_dependencies) - - ENDWHILE() - - IF(NOT _dep_error) - # iterator over all dependencies - SET(_plugins_turned_off ) - SET(PLUGIN_LINK_LIBRARIES ) - FOREACH(_dep ${_plugin_dependencies}) - - # collect the ids of plugins we will have to build - IF(NOT _BUILD_${_dep}) - LIST(APPEND _plugins_turned_off ${_dep}) - ENDIF() - - # set include and link directories - STRING(REPLACE . _ _dep_target ${_dep}) - IF(${_dep}_SRC_DIR) - # This is an external BlueBerry Bundle dependency - #MESSAGE("${_dep} is an external BlueBerry Bundle dependency") - SET(_dep_src_dir ${${_dep}_SRC_DIR}/src) - - IF(EXISTS "${${_dep}_SRC_DIR}/includes.cmake") - INCLUDE(${${_dep}_SRC_DIR}/includes.cmake) - FOREACH(_added_incldir ${ADDITIONAL_INCLUDE_DIRECTORIES}) - LIST(APPEND _dep_src_dir ${${_dep}_SRC_DIR}/${_added_incldir}) - ENDFOREACH() - ENDIF() - ELSEIF(${_dep_target}_INCLUDE_DIRS) - # This is an external CTK Plugin dependency - #MESSAGE("${_dep} is an external CTK Plugin dependency") - SET(_dep_src_dir ${${_dep_target}_INCLUDE_DIRS}) - ELSEIF(${_dep}_SOURCE_DIR) - # This is an internal BlueBerry Bundle dependency - #MESSAGE("${_dep} is an internal BlueBerry Bundle dependency") - SET(_dep_src_dir ${${_dep}_SOURCE_DIR}/src) - - IF(EXISTS "${${_dep}_SOURCE_DIR}/includes.cmake") - INCLUDE(${${_dep}_SOURCE_DIR}/includes.cmake) - FOREACH(_added_incldir ${ADDITIONAL_INCLUDE_DIRECTORIES}) - LIST(APPEND _dep_src_dir ${${_dep}_SOURCE_DIR}/${_added_incldir}) - ENDFOREACH() - ENDIF() - ELSEIF(${_dep_target}_SOURCE_DIR) - # This is an internal CTK plugin dependency - #MESSAGE("${_dep} is an internal CTK plugin dependency") - SET(_dep_src_dir ) - ctkFunctionGetIncludeDirs(_dep_src_dir ${_dep_target}) - - IF(${_dep_target}_INCLUDE_SUFFIXES) - FOREACH(_suffix ${${_dep_target}_INCLUDE_SUFFIXES}) - LIST(APPEND _dep_src_dir ${${_dep_target}_SOURCE_DIR}/${_suffix}) - ENDFOREACH() - ELSE() - LIST(APPEND _dep_src_dir ${${_dep_target}_SOURCE_DIR}) - ENDIF() - ENDIF() - - SET(_dep_out_dir ${${_dep}_OUT_DIR}) - - IF(${_dep}_BIN_DIR) - SET(_dep_bin_dir ${${_dep}_BIN_DIR}) - ELSE() - SET(_dep_bin_dir ${${_dep_target}_BINARY_DIR}) - ENDIF() - - LINK_DIRECTORIES(${_dep_out_dir}/bin) - INCLUDE_DIRECTORIES(${_dep_src_dir}) - INCLUDE_DIRECTORIES(${_dep_bin_dir}) - - LIST(APPEND PLUGIN_LINK_LIBRARIES ${_dep_target}) - - ENDFOREACH(_dep ${_plugin_dependencies}) - - IF(_plugins_turned_off) - MESSAGE(SEND_ERROR "Unmet dependencies: The plugin ${_bundle_id} depends on the following plugins:\n${_plugins_turned_off}.\nSwitch them on in order to build ${_FIND_DEPS_PLUGIN_NAME}.") - ENDIF(_plugins_turned_off) - ENDIF() - -ENDMACRO() - -MACRO(_MACRO_ENABLE_QT4_PLUGINS) - - SET(_enable_qt_plugin ${ARGV0}) - STRING(REGEX MATCH ".*\\.qt.*" _qt_matched ${_enable_qt_plugin}) - IF(_qt_matched) - IF(QT4_FOUND) - SET(ENABLE_PLUGIN 1) - ELSE() - SET(ENABLE_PLUGIN 0) - ENDIF() - ENDIF() - -ENDMACRO() - -MACRO(_MACRO_CREATE_ENABLE_PLUGIN_CODE) - SET(_enable_plugins_file "${CMAKE_CURRENT_BINARY_DIR}/berryEnablePlugin.cmake") - SET(_enable_plugins_filecontent "SET(_enable_bundle 1)") - FOREACH(_macro_name ${ARGN}) - SET(_enable_plugins_filecontent "${_enable_plugins_filecontent} - IF(_enable_bundle) - SET(ENABLE_PLUGIN 1) - ${_macro_name}(\${BUNDLE-SYMBOLICNAME}) - IF(NOT ENABLE_PLUGIN) - SET(_enable_bundle 0) - ENDIF() - ENDIF()") - ENDFOREACH() - CONFIGURE_FILE("${BLUEBERRY_SOURCE_DIR}/CMake/berryEnablePlugin.cmake.in" "${_enable_plugins_file}" @ONLY) -ENDMACRO() - - diff --git a/BlueBerry/CMake/berryPluginManifest.cmake.in b/BlueBerry/CMake/berryPluginManifest.cmake.in deleted file mode 100644 index 33d2709228..0000000000 --- a/BlueBerry/CMake/berryPluginManifest.cmake.in +++ /dev/null @@ -1 +0,0 @@ -@_mfcontent@ \ No newline at end of file diff --git a/BlueBerry/CMake/berryQtHelpDoxygen.conf.in b/BlueBerry/CMake/berryQtHelpDoxygen.conf.in deleted file mode 100644 index 6870f61282..0000000000 --- a/BlueBerry/CMake/berryQtHelpDoxygen.conf.in +++ /dev/null @@ -1,1553 +0,0 @@ -# Doxyfile 1.6.3 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "@BUNDLE-NAME@" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = "@PLUGIN_DOXYGEN_OUTPUT_DIR@" - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = bundlemainpage{1}=\mainpage \ - "isHtml=\if NO_SUCH_THING" \ - "isHtmlend=\endif" - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it parses. -# With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this tag. -# The format is ext=language, where ext is a file extension, and language is one of -# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, -# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat -# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), -# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = NO - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = NO - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = NO - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= NO - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by -# doxygen. The layout file controls the global structure of the generated output files -# in an output format independent way. The create the layout file that represents -# doxygen's defaults, run doxygen with the -l option. You can optionally specify a -# file name after the option, if omitted DoxygenLayout.xml will be used as the name -# of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = "@PLUGIN_DOXYGEN_INPUT_DIR@" - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = *.dox - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = "@PLUGIN_DOXYGEN_INPUT_DIR@" - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = YES - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 3 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER -# are set, an additional index file will be generated that can be used as input for -# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated -# HTML documentation. - -GENERATE_QHP = YES - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = @BUNDLE-SYMBOLICNAME@ - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = bundle - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. -# For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = @PLUGIN_QHP_CUST_FILTER_NAME@ - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = @PLUGIN_QHP_CUST_FILTER_ATTRS@ - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's -# filter section matches. -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = @PLUGIN_QHP_SECT_FILTER_ATTRS@ - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = @QT_HELPGENERATOR_EXECUTABLE@ - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = YES - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = NO - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = "@PLUGIN_DOXYGEN_OUTPUT_DIR@/@BUNDLE-SYMBOLICNAME@.tag" - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = FreeSans - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = YES - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/BlueBerry/CMake/berryRequireBundle.cmake.in b/BlueBerry/CMake/berryRequireBundle.cmake.in deleted file mode 100644 index 197e718974..0000000000 --- a/BlueBerry/CMake/berryRequireBundle.cmake.in +++ /dev/null @@ -1 +0,0 @@ -SET(REQUIRE-BUNDLE "@REQUIRE-BUNDLE@") \ No newline at end of file diff --git a/BlueBerry/CMakeLists.txt b/BlueBerry/CMakeLists.txt index 2eed7731cd..44485faa19 100644 --- a/BlueBerry/CMakeLists.txt +++ b/BlueBerry/CMakeLists.txt @@ -1,311 +1,272 @@ PROJECT(BlueBerry) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMake/") INCLUDE(MacroParseArguments) INCLUDE(MacroConvertSchema) INCLUDE(MacroOrganizeSources) -INCLUDE(berryPluginHelpers) -INCLUDE(MacroCollectPlugins) -INCLUDE(MacroParseManifest) -INCLUDE(MacroCreatePlugin) INCLUDE(MacroCreateCTKPlugin) INCLUDE(MacroCreateQtHelp) -INCLUDE(MacroInstallPlugin) INCLUDE(MacroInstallCTKPlugin) INCLUDE(FunctionCreateProvisioningFile) IF(MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4275 /wd4251 /wd4503") ENDIF() IF (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) ENDIF () FIND_PACKAGE(mbilog REQUIRED) INCLUDE_DIRECTORIES(${mbilog_INCLUDE_DIRS}) -OPTION(BLUEBERRY_USE_QT "Use the Qt GUI toolkit" OFF) -IF(NOT DESIRED_QT_VERSION) - SET(DESIRED_QT_VERSION 4 CACHE STRING "Desired Qt version" FORCE) - MARK_AS_ADVANCED(DESIRED_QT_VERSION) -ENDIF() +FIND_PACKAGE(Qt4 4.6.2 REQUIRED) -IF(BLUEBERRY_USE_QT AND NOT DESIRED_QT_VERSION EQUAL 4) - MESSAGE("Attention: Qt4 GUI libraries are required to build the BlueBerry Qt plug-ins.") +IF(QT_QMAKE_CHANGED) + SET(QT_HELPGENERATOR_EXECUTABLE NOTFOUND) + SET(QT_COLLECTIONGENERATOR_EXECUTABLE NOTFOUND) + SET(QT_ASSISTANT_EXECUTABLE NOTFOUND) + SET(QT_XMLPATTERNS_EXECUTABLE NOTFOUND) ENDIF() -IF(BLUEBERRY_USE_QT AND DESIRED_QT_VERSION EQUAL 4) - SET(BUILD_QT_PLUGINS 1) - FIND_PACKAGE(Qt4 4.6.2 REQUIRED) - - IF(QT_QMAKE_CHANGED) - SET(QT_HELPGENERATOR_EXECUTABLE NOTFOUND) - SET(QT_COLLECTIONGENERATOR_EXECUTABLE NOTFOUND) - SET(QT_ASSISTANT_EXECUTABLE NOTFOUND) - SET(QT_XMLPATTERNS_EXECUTABLE NOTFOUND) - ENDIF() - - FIND_PROGRAM(QT_HELPGENERATOR_EXECUTABLE - NAMES qhelpgenerator qhelpgenerator-qt4 qhelpgenerator4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH - ) +FIND_PROGRAM(QT_HELPGENERATOR_EXECUTABLE + NAMES qhelpgenerator qhelpgenerator-qt4 qhelpgenerator4 + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH +) - FIND_PROGRAM(QT_COLLECTIONGENERATOR_EXECUTABLE - NAMES qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator4 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH - ) +FIND_PROGRAM(QT_COLLECTIONGENERATOR_EXECUTABLE + NAMES qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator4 + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH +) - FIND_PROGRAM(QT_ASSISTANT_EXECUTABLE - NAMES assistant-qt4 assistant4 assistant - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH - ) +FIND_PROGRAM(QT_ASSISTANT_EXECUTABLE + NAMES assistant-qt4 assistant4 assistant + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH +) - FIND_PROGRAM(QT_XMLPATTERNS_EXECUTABLE - NAMES xmlpatterns - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH - ) +FIND_PROGRAM(QT_XMLPATTERNS_EXECUTABLE + NAMES xmlpatterns + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH +) - OPTION(BLUEBERRY_USE_QT_HELP "Enable support for integrating bundle documentation into Qt Help" ON) - - MARK_AS_ADVANCED(BLUEBERRY_USE_QT_HELP - QT_HELPGENERATOR_EXECUTABLE - QT_COLLECTIONGENERATOR_EXECUTABLE - QT_ASSISTANT_EXECUTABLE - QT_XMLPATTERNS_EXECUTABLE) - - SET(_doxygen_too_old 1) - IF(BLUEBERRY_USE_QT_HELP) - FIND_PACKAGE(Doxygen) - IF(DOXYGEN_FOUND) - EXECUTE_PROCESS(COMMAND ${DOXYGEN_EXECUTABLE} --version - OUTPUT_VARIABLE _doxygen_version) - IF(${_doxygen_version} VERSION_GREATER 1.6.0 OR - ${_doxygen_version} VERSION_EQUAL 1.6.0) - SET(_doxygen_too_old 0) - ENDIF() +OPTION(BLUEBERRY_USE_QT_HELP "Enable support for integrating bundle documentation into Qt Help" ON) + +MARK_AS_ADVANCED(BLUEBERRY_USE_QT_HELP + QT_HELPGENERATOR_EXECUTABLE + QT_COLLECTIONGENERATOR_EXECUTABLE + QT_ASSISTANT_EXECUTABLE + QT_XMLPATTERNS_EXECUTABLE) + +SET(_doxygen_too_old 1) +IF(BLUEBERRY_USE_QT_HELP) + FIND_PACKAGE(Doxygen) + IF(DOXYGEN_FOUND) + EXECUTE_PROCESS(COMMAND ${DOXYGEN_EXECUTABLE} --version + OUTPUT_VARIABLE _doxygen_version) + IF(${_doxygen_version} VERSION_GREATER 1.6.0 OR + ${_doxygen_version} VERSION_EQUAL 1.6.0) + SET(_doxygen_too_old 0) ENDIF() - ELSE(BLUEBERRY_USE_QT_HELP) - - CONFIGURE_FILE(../Documentation/pregenerated/MITKBlankPage.qch - ${MITK_BINARY_DIR}/bin/ExtBundles/org.mitk.gui.qt.extapplication/resources/MITKBlankPage.qch - COPYONLY) - - CONFIGURE_FILE(../Documentation/pregenerated/MitkExtQtHelpCollection.qhc - ${MITK_BINARY_DIR}/bin/ExtBundles/org.mitk.gui.qt.extapplication/resources/MitkExtQtHelpCollection.qhc - COPYONLY) - - ENDIF(BLUEBERRY_USE_QT_HELP) + ENDIF() - IF (BLUEBERRY_USE_QT_HELP AND _doxygen_too_old) + IF(_doxygen_too_old) MESSAGE("Doxygen was not found or is too old. Version 1.6.0 or later is needed if BLUEBERRY_USE_QT_HELP is ON") SET(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating bundle documentation into Qt Help" FORCE) ENDIF() - IF(BLUEBERRY_USE_QT_HELP AND NOT QT_HELPGENERATOR_EXECUTABLE) + IF(NOT QT_HELPGENERATOR_EXECUTABLE) MESSAGE("You have enabled Qt Help support, but QT_HELPGENERATOR_EXECUTABLE is empty") SET(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating bundle documentation into Qt Help" FORCE) ENDIF() - IF(BLUEBERRY_USE_QT_HELP AND NOT QT_XMLPATTERNS_EXECUTABLE) + IF(NOT QT_XMLPATTERNS_EXECUTABLE) MESSAGE("You have enabled Qt Help support, but QT_XMLPATTERNS_EXECUTABLE is empty") SET(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating bundle documentation into Qt Help" FORCE) ENDIF() +ENDIF(BLUEBERRY_USE_QT_HELP) - INCLUDE(${QT_USE_FILE}) -ELSE() - FIND_PACKAGE(Qt4 4.6.2 COMPONENTS QtCore REQUIRED) - INCLUDE(${QT_USE_FILE}) -ENDIF() +INCLUDE(${QT_USE_FILE}) # ========= CTK specific CMake stuff ============ CMAKE_POLICY(SET CMP0012 NEW) FIND_PACKAGE(CTK REQUIRED) # Extract all library names starting with org_blueberry_ MACRO(GetMyTargetLibraries all_target_libraries varname) SET(re_ctkplugin "^org_blueberry_[a-zA-Z0-9_]+$") SET(_tmp_list) LIST(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin OUTPUT_VARIABLE ${varname}) ENDMACRO() # ================================================ OPTION(BLUEBERRY_BUILD_ALL_PLUGINS "Build all BlueBerry plugins (overriding selection)" OFF) MARK_AS_ADVANCED(BLUEBERRY_BUILD_ALL_PLUGINS) IF(BLUEBERRY_BUILD_ALL_PLUGINS) SET(BLUEBERRY_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") ENDIF() OPTION(BLUEBERRY_STATIC "Build all plugins as static libraries" OFF) MARK_AS_ADVANCED(BLUEBERRY_STATIC) OPTION(BLUEBERRY_DEBUG_SMARTPOINTER "Enable code for debugging smart pointers" OFF) MARK_AS_ADVANCED(BLUEBERRY_DEBUG_SMARTPOINTER) FIND_PACKAGE(Poco REQUIRED) FIND_PACKAGE(Ant) FIND_PACKAGE(Eclipse) SET(BLUEBERRY_SOURCE_DIR ${BlueBerry_SOURCE_DIR}) SET(BLUEBERRY_BINARY_DIR ${BlueBerry_BINARY_DIR}) SET(BLUEBERRY_PLUGINS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Bundles) SET(BLUEBERRY_PLUGINS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Bundles) SET(OSGI_APP solstice) SET(OSGI_UI_APP solstice_ui) -# Force should be removed after everybody has configured their old binary tree -SET(BLUEBERRY_PLUGINS_OUTPUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlueBerry CACHE PATH "Directory where to build the BlueBerry Bundles" FORCE) -MARK_AS_ADVANCED(BLUEBERRY_PLUGINS_OUTPUT_DIR) - -# Clear the cache variables -SET(BLUEBERRY_PLUGIN_SOURCE_DIRS "" CACHE INTERNAL "List of base plugin source directories" FORCE) -SET(BLUEBERRY_PLUGIN_BINARY_DIRS "" CACHE INTERNAL "List of base plugin binary directories" FORCE) - IF (Eclipse_DIR) SET(BLUEBERRY_DOC_TOOLS_DIR "${Eclipse_DIR}" CACHE PATH "Directory containing additional tools needed for generating the documentation") ELSE () SET(BLUEBERRY_DOC_TOOLS_DIR "" CACHE PATH "Directory containing additional tools needed for generating the documentation") ENDIF () SET(BLUEBERRY_DEBUG_POSTFIX d) # Testing options OPTION(BLUEBERRY_BUILD_TESTING "Build the BlueBerry tests." ${BUILD_TESTING}) IF(WIN32) SET(_gui_testing_default "ON") ELSE() SET(_gui_testing_default "OFF") ENDIF() OPTION(BLUEBERRY_ENABLE_GUI_TESTING "Enable the BlueBerry GUI tests" ${_gui_testing_default}) MARK_AS_ADVANCED(BLUEBERRY_ENABLE_GUI_TESTING) IF(BLUEBERRY_BUILD_TESTING) ENABLE_TESTING() ENDIF() # Add CTK plugins SET(_ctk_plugins Bundles/org.blueberry.osgi:ON Bundles/org.blueberry.compat:OFF Bundles/org.blueberry.core.runtime:OFF Bundles/org.blueberry.core.expressions:OFF Bundles/org.blueberry.solstice.common:OFF Bundles/org.blueberry.core.commands:OFF Bundles/org.blueberry.core.jobs:OFF Bundles/org.blueberry.ui:OFF Bundles/org.blueberry.ui.qt:OFF Bundles/org.blueberry.ui.qt.help:OFF Bundles/org.blueberry.ui.qt.log:OFF Bundles/org.blueberry.ui.qt.objectinspector:OFF ) SET(_ctk_test_plugins ) SET(_ctk_plugins_include_dirs ${Poco_INCLUDE_DIRS} ) SET(_ctk_plugins_link_dirs ${Poco_LIBRARY_DIR} ) INCLUDE_DIRECTORIES(${_ctk_plugins_include_dirs}) LINK_DIRECTORIES(${_ctk_plugins_link_dirs}) IF(BLUEBERRY_BUILD_TESTING) INCLUDE(berryTestingHelpers) SET(BLUEBERRY_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_APP}") GET_TARGET_PROPERTY(_is_macosx_bundle ${OSGI_APP} MACOSX_BUNDLE) IF(APPLE AND _is_macosx_bundle) SET(BLUEBERRY_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_APP}.app/Contents/MacOS/${OSGI_APP}") ENDIF() SET(_ctk_testinfrastructure_plugins Bundles/org.blueberry.test:ON Bundles/org.blueberry.uitest:ON ) SET(_ctk_test_plugins # Testing/org.blueberry.core.runtime.tests:ON # Testing/org.blueberry.osgi.tests:ON ) IF(BLUEBERRY_ENABLE_GUI_TESTING) # LIST(APPEND _ctk_test_plugins Testing/org.blueberry.ui.tests:ON) SET(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_UI_APP}") GET_TARGET_PROPERTY(_is_macosx_bundle ${OSGI_UI_APP} MACOSX_BUNDLE) IF(APPLE AND _is_macosx_bundle) SET(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_UI_APP}.app/Contents/MacOS/${OSGI_UI_APP}") ENDIF() ENDIF() ENDIF() SET(BLUEBERRY_TESTING_PROVISIONING_FILE "${BlueBerry_BINARY_DIR}/BlueBerryTesting.provisioning") ADD_CUSTOM_TARGET(BlueBerry) ctkMacroSetupPlugins(${_ctk_plugins} ${_ctk_testinfrastructure_plugins} ${_ctk_test_plugins} BUILD_OPTION_PREFIX BLUEBERRY_BUILD_ BUILD_ALL ${BLUEBERRY_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) SET(BLUEBERRY_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlueBerry.provisioning") FunctionCreateProvisioningFile( FILE ${BLUEBERRY_PROVISIONING_FILE} PLUGINS ${_ctk_plugins} ) FunctionCreateProvisioningFile( FILE ${BLUEBERRY_TESTING_PROVISIONING_FILE} INCLUDE ${BLUEBERRY_PROVISIONING_FILE} PLUGINS ${_ctk_testinfrastructure_plugins} ${_ctk_test_plugins} ) if(${CMAKE_PROJECT_NAME}_PLUGIN_LIBRARIES) add_dependencies(BlueBerry ${${CMAKE_PROJECT_NAME}_PLUGIN_LIBRARIES}) endif() set_property(TARGET ${${CMAKE_PROJECT_NAME}_PLUGIN_LIBRARIES} PROPERTY LABELS BlueBerry) SET(BB_PLUGIN_USE_FILE "${BlueBerry_BINARY_DIR}/BlueBerryPluginUseFile.cmake") IF(${PROJECT_NAME}_PLUGIN_LIBRARIES) ctkFunctionGeneratePluginUseFile(${BB_PLUGIN_USE_FILE}) ELSE() FILE(REMOVE ${BB_PLUGIN_USE_FILE}) SET(BB_PLUGIN_USE_FILE ) ENDIF() # CTK Plugin Exports SET(BB_PLUGIN_EXPORTS_FILE "${CMAKE_CURRENT_BINARY_DIR}/BlueBerryPluginExports.cmake") GetMyTargetLibraries("${${PROJECT_NAME}_PLUGIN_LIBRARIES}" my_plugin_targets) SET(additional_export_targets mbilog PocoFoundation PocoUtil PocoXML) IF(BLUEBERRY_BUILD_TESTING) LIST(APPEND additional_export_targets CppUnit) ENDIF() export(TARGETS ${my_plugin_targets} ${additional_export_targets} FILE ${BB_PLUGIN_EXPORTS_FILE}) ADD_SUBDIRECTORY(Documentation) CONFIGURE_FILE(BlueBerryConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/BlueBerryConfig.cmake @ONLY) diff --git a/BlueBerry/Testing/org.blueberry.ui.tests/documentation/doxygen/modules.dox b/BlueBerry/Testing/org.blueberry.ui.tests/documentation/doxygen/modules.dox index 359ef6f832..8cbf496b3a 100644 --- a/BlueBerry/Testing/org.blueberry.ui.tests/documentation/doxygen/modules.dox +++ b/BlueBerry/Testing/org.blueberry.ui.tests/documentation/doxygen/modules.dox @@ -1,16 +1,16 @@ /** - \defgroup org_blueberry_ui_tests org.blueberry.ui.tests Plugin + \defgroup org_blueberry_ui_tests org.blueberry.ui.tests \ingroup BlueBerryPlugins \brief Describe your plugin here. */ /** \defgroup org_blueberry_ui_tests_internal Internal \ingroup org_blueberry_ui_tests \brief This subcategory includes the internal classes of the org.blueberry.ui.tests plugin. Other plugins must not rely on these classes. They contain implementation details and their interface may change at any time. We mean it. */ diff --git a/CMake/mitkFunctionCheckMitkCompatibility.cmake b/CMake/mitkFunctionCheckMitkCompatibility.cmake new file mode 100644 index 0000000000..5831f008f5 --- /dev/null +++ b/CMake/mitkFunctionCheckMitkCompatibility.cmake @@ -0,0 +1,40 @@ + +# mitkFunctionCheckMitkCompatibility(VERSIONS [ ]... [REQUIRED]) +# +# Example: +# mitkFunctionCheckMitkCompatibility(VERSIONS MITK_VERSION_PLUGIN_SYSTEM 1 REQUIRED) +# +function(mitkFunctionCheckMitkCompatibility) + + macro_parse_arguments(_COMPAT "VERSIONS" "REQUIRED" ${ARGN}) + + set(_is_version_name 1) + foreach(_item ${_COMPAT_VERSIONS}) + if(_is_version_name) + set(_is_version_name 0) + set(_version_name ${_item}) + if (NOT ${_version_name}) + set(_msg_version_name_not_defined "Your MITK version is too old (${_version_name} not defined)") + if(_COMPAT_REQUIRED) + message(SEND_ERROR "${_msg_version_name_not_defined}") + else() + message(WARNING "${_msg_version_name_not_defined}") + endif() + endif() + else() + set(_is_version_name 1) + if (${_version_name}) + set(_required_version ${_item}) + if(${_version_name} VERSION_LESS ${_required_version}) + set(_msg_version_mismatch "Your MITK version is too old, ${_version_name} version ${_required_version} or higher required, but only version ${${_version_name}} present.") + if(_COMPAT_REQUIRED) + message(SEND_ERROR "${_msg_version_mismatch}") + else() + message(WARNING "${_msg_version_mismatch}") + endif() + endif() + endif() + endif() + endforeach() + +endfunction() diff --git a/CMake/mitkMacroCreatePlugin.cmake b/CMake/mitkMacroCreatePlugin.cmake deleted file mode 100755 index 942855b30a..0000000000 --- a/CMake/mitkMacroCreatePlugin.cmake +++ /dev/null @@ -1,25 +0,0 @@ -MACRO(MACRO_CREATE_MITK_PLUGIN) - MITK_CHECK_MODULE(_MODULE_CHECK_RESULT Mitk ${ARGN}) - IF(NOT _MODULE_CHECK_RESULT) - MITK_USE_MODULE(Mitk ${ARGN}) - - LINK_DIRECTORIES(${ALL_LIBRARY_DIRS}) - INCLUDE_DIRECTORIES(${ALL_INCLUDE_DIRECTORIES}) - MACRO_CREATE_PLUGIN() - - TARGET_LINK_LIBRARIES(${PLUGIN_TARGET} ${ALL_LIBRARIES}) - IF(MITK_DEFAULT_SUBPROJECTS) - SET_PROPERTY(TARGET ${PLUGIN_TARGET} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) - FOREACH(subproject ${MITK_DEFAULT_SUBPROJECTS}) - ADD_DEPENDENCIES(${subproject} ${PLUGIN_TARGET}) - ENDFOREACH() - ENDIF() - ELSE(NOT _MODULE_CHECK_RESULT) - IF(NOT CURRENT_PLUGIN_BUILD_FORCED) - MESSAGE(SEND_ERROR "${BUNDLE-SYMBOLICNAME} is missing requirements and won't be built. Missing: ${_MODULE_CHECK_RESULT}") - ELSE() - MESSAGE(WARNING "${BUNDLE-SYMBOLICNAME} is missing requirements and won't be built. Missing: ${_MODULE_CHECK_RESULT}") - ENDIF() - ENDIF(NOT _MODULE_CHECK_RESULT) -ENDMACRO() - diff --git a/CMake/mitkModuleInit.cpp b/CMake/mitkModuleInit.cpp index 90c174b18f..c83234403b 100644 --- a/CMake/mitkModuleInit.cpp +++ b/CMake/mitkModuleInit.cpp @@ -1,84 +1,80 @@ -/*============================================================================= +/*========================================================================= - Library: CTK +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +=========================================================================*/ #include "mitkStaticInit.h" #include "mitkModuleRegistry.h" #include "mitkModuleContext.h" #include "mitkModule.h" #include "mitkModuleInfo.h" #include "mitkModuleUtils.h" namespace mitk { MITK_GLOBAL_STATIC_WITH_ARGS(ModuleInfo, moduleInfo, ("@MODULE_NAME@", "@MODULE_LIBNAME@", "@MODULE_DEPENDS_STR@", "@MODULE_PACKAGE_DEPENDS_STR@", "@MODULE_VERSION@", @MODULE_QT_BOOL@)) class MITK_LOCAL ModuleInitializer { public: ModuleInitializer() { std::string location = ModuleUtils::GetLibraryPath(moduleInfo()->libName, (void*)moduleInfo); std::string activator_func = "_mitk_module_activator_instance_"; activator_func.append(moduleInfo()->name); moduleInfo()->location = location; if (moduleInfo()->libName.empty()) { // make sure we retrieve symbols from the executable, if "libName" is empty location.clear(); } moduleInfo()->activatorHook = (ModuleInfo::ModuleActivatorHook)ModuleUtils::GetSymbol(location, activator_func.c_str()); Register(); } static void Register() { ModuleRegistry::Register(moduleInfo()); } ~ModuleInitializer() { ModuleRegistry::UnRegister(moduleInfo()); } }; ModuleContext* GetModuleContext() { // make sure the module is registered if (moduleInfo()->id == 0) { ModuleInitializer::Register(); } return ModuleRegistry::GetModule(moduleInfo()->id)->GetModuleContext(); } } static mitk::ModuleInitializer coreModule; diff --git a/CMake/mitkSetupBlueBerry.cmake b/CMake/mitkSetupBlueBerry.cmake deleted file mode 100644 index f3ecc4e5a8..0000000000 --- a/CMake/mitkSetupBlueBerry.cmake +++ /dev/null @@ -1,21 +0,0 @@ - -set(BLUEBERRY_USE_QT ${MITK_USE_QT} CACHE BOOL "Use the Qt GUI toolkit" FORCE) -mark_as_advanced(BLUEBERRY_USE_QT) - -# Clear the cache variables containing plugin base directories -set(MITK_MODULES_PLUGIN_SOURCE_DIRS "" CACHE INTERNAL "List of base plugin source directories" FORCE) -set(MITK_MODULES_PLUGIN_OUTPUT_DIRS "" CACHE INTERNAL "List of base plugin output directories" FORCE) - -set(mbilog_DIR "${mbilog_BINARY_DIR}") - -if(MITK_BUILD_ALL_PLUGINS) - set(BLUEBERRY_BUILD_ALL_PLUGINS ON) -endif() - -add_subdirectory(BlueBerry) - -set(BlueBerry_DIR ${CMAKE_CURRENT_BINARY_DIR}/BlueBerry - CACHE PATH "The directory containing a CMake configuration file for BlueBerry" FORCE) - -include(mitkMacroCreatePlugin) -include(mitkMacroCreateCTKPlugin) diff --git a/CMake/mitkTestPluginGenerator.cmake b/CMake/mitkTestPluginGenerator.cmake index 7fcaca889f..e148dcdd64 100644 --- a/CMake/mitkTestPluginGenerator.cmake +++ b/CMake/mitkTestPluginGenerator.cmake @@ -1,99 +1,99 @@ if(BUILD_TESTING) set(proj GeneratedTestProject) set(test_project_out_dir "${MITK_BINARY_DIR}") set(test_project_source_dir "${MITK_BINARY_DIR}/${proj}") set(test_project_binary_dir "${MITK_BINARY_DIR}/${proj}-bin") add_test(NAME mitkPluginGeneratorCleanTest COMMAND ${CMAKE_COMMAND} -E remove_directory "${test_project_source_dir}" ) set_tests_properties(mitkPluginGeneratorCleanTest PROPERTIES - LABLES "MITK;BlueBerry") + LABELS "MITK;BlueBerry") add_test(NAME mitkPluginGeneratorCleanTest2 COMMAND ${CMAKE_COMMAND} -E remove_directory "${test_project_binary_dir}" ) set_tests_properties(mitkPluginGeneratorCleanTest2 PROPERTIES - LABLES "MITK;BlueBerry") + LABELS "MITK;BlueBerry") add_test(NAME mitkPluginGeneratorCleanTest3 COMMAND ${CMAKE_COMMAND} -E make_directory "${test_project_binary_dir}" ) set_tests_properties(mitkPluginGeneratorCleanTest3 PROPERTIES DEPENDS mitkPluginGeneratorCleanTest2 - LABLES "MITK;BlueBerry") + LABELS "MITK;BlueBerry") add_test(NAME mitkPluginGeneratorCreateTest COMMAND ${exec_target} --project-name "${proj}" --project-app-name "TestApp" -ps org.test.plugin -pn "Test Plugin" -vn "Test View" -o ${test_project_out_dir} -y -n ) set_tests_properties(mitkPluginGeneratorCreateTest PROPERTIES DEPENDS "${exec_target};mitkPluginGeneratorCleanTest;mitkPluginGeneratorCleanTest3" LABELS "MITK;BlueBerry") if(CMAKE_CONFIGURATION_TYPES) foreach(config ${CMAKE_CONFIGURATION_TYPES}) add_test(NAME mitkPluginGeneratorConfigureTest-${config} CONFIGURATIONS ${config} WORKING_DIRECTORY "${test_project_binary_dir}" COMMAND ${CMAKE_COMMAND} -D MITK_DIR:PATH=${MITK_BINARY_DIR} -G ${CMAKE_GENERATOR} "${test_project_source_dir}") set_tests_properties(mitkPluginGeneratorConfigureTest-${config} PROPERTIES DEPENDS mitkPluginGeneratorCreateTest LABELS "MITK;BlueBerry") add_test(NAME mitkPluginGeneratorBuildTest-${config} CONFIGURATIONS ${config} COMMAND ${CMAKE_COMMAND} --build ${test_project_binary_dir} --config ${config}) set_tests_properties(mitkPluginGeneratorBuildTest-${config} PROPERTIES DEPENDS mitkPluginGeneratorConfigureTest-${config} LABELS "MITK;BlueBerry") endforeach() else() add_test(NAME mitkPluginGeneratorConfigureTest-${CMAKE_BUILD_TYPE} WORKING_DIRECTORY "${test_project_binary_dir}" COMMAND ${CMAKE_COMMAND} -D MITK_DIR:PATH=${MITK_BINARY_DIR} -D CMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -G ${CMAKE_GENERATOR} "${test_project_source_dir}") set_tests_properties(mitkPluginGeneratorConfigureTest-${CMAKE_BUILD_TYPE} PROPERTIES DEPENDS mitkPluginGeneratorCreateTest LABELS "MITK;BlueBerry") - add_test(mitkPluginGeneratorBuildTest-${CMAKE_BUILD_TYPE} - ${CMAKE_COMMAND} --build ${test_project_binary_dir} --config ${CMAKE_BUILD_TYPE}) + add_test(NAME mitkPluginGeneratorBuildTest-${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_COMMAND} --build ${test_project_binary_dir} --config ${CMAKE_BUILD_TYPE}) set_tests_properties(mitkPluginGeneratorBuildTest-${CMAKE_BUILD_TYPE} PROPERTIES DEPENDS mitkPluginGeneratorConfigureTest-${CMAKE_BUILD_TYPE} LABELS "MITK;BlueBerry") endif() set(package_test_configurations) if(WIN32) # Only test packaging if build type is "Release" on Windows set(package_test_configurations CONFIGURATIONS Release) endif() if(NOT MITK_FAST_TESTING) if(WIN32) # Only test packaging if build type is "Release" on Windows add_test(NAME mitkPluginGeneratorPackageTest CONFIGURATIONS Release COMMAND ${CMAKE_COMMAND} --build ${test_project_binary_dir}/${proj}-build --config Release --target package) set_tests_properties(mitkPluginGeneratorPackageTest PROPERTIES DEPENDS mitkPluginGeneratorBuildTest-Release TIMEOUT 3600 LABELS "MITK;BlueBerry") elseif(CMAKE_BUILD_TYPE) add_test(mitkPluginGeneratorPackageTest ${CMAKE_COMMAND} --build ${test_project_binary_dir}/${proj}-build --config ${CMAKE_BUILD_TYPE} --target package) set_tests_properties(mitkPluginGeneratorPackageTest PROPERTIES DEPENDS mitkPluginGeneratorBuildTest-${CMAKE_BUILD_TYPE} TIMEOUT 3600 LABELS "MITK;BlueBerry") endif() endif() endif() diff --git a/CMake/mitkTestProjectTemplate.cmake b/CMake/mitkTestProjectTemplate.cmake index 07ccbafbb2..83d390308a 100644 --- a/CMake/mitkTestProjectTemplate.cmake +++ b/CMake/mitkTestProjectTemplate.cmake @@ -1,94 +1,94 @@ if(BUILD_TESTING) include(ExternalProject) set(proj MITK-ProjectTemplate) set(MITK-ProjectTemplate_BINARY_DIR "${MITK_BINARY_DIR}/${proj}-build") ExternalProject_Add(${proj} GIT_REPOSITORY http://git.mitk.org/MITK-ProjectTemplate.git GIT_TAG origin/master SOURCE_DIR "${MITK_BINARY_DIR}/${proj}" BINARY_DIR "${MITK-ProjectTemplate_BINARY_DIR}" PREFIX "${proj}-cmake" BUILD_COMMAND "" INSTALL_COMMAND "" CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DMITK_DIR:PATH=${MITK_BINARY_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DAwesomeProject_BUILD_ALL_PLUGINS:BOOL=ON -DAwesomeProject_BUILD_ALL_APPS:BOOL=ON ) add_test(NAME mitkProjectTemplateCleanTest COMMAND ${CMAKE_COMMAND} -E remove_directory "${MITK-ProjectTemplate_BINARY_DIR}" ) set_tests_properties(mitkProjectTemplateCleanTest PROPERTIES LABELS "MITK;BlueBerry") add_test(NAME mitkProjectTemplateCleanTest2 COMMAND ${CMAKE_COMMAND} -E make_directory "${MITK-ProjectTemplate_BINARY_DIR}" ) set_tests_properties(mitkProjectTemplateCleanTest2 PROPERTIES DEPENDS mitkProjectTemplateCleanTest LABELS "MITK;BlueBerry") if(CMAKE_CONFIGURATION_TYPES) foreach(config ${CMAKE_CONFIGURATION_TYPES}) add_test(NAME mitkProjectTemplateConfigureTest-${config} CONFIGURATIONS ${config} COMMAND ${CMAKE_COMMAND} --build ${MITK_BINARY_DIR} --config ${config} --target ${proj}) set_tests_properties(mitkProjectTemplateConfigureTest-${config} PROPERTIES DEPENDS mitkProjectTemplateCleanTest2 LABELS "MITK;BlueBerry") add_test(NAME mitkProjectTemplateBuildTest-${config} CONFIGURATIONS ${config} COMMAND ${CMAKE_COMMAND} --build ${MITK-ProjectTemplate_BINARY_DIR} --config ${config}) set_tests_properties(mitkProjectTemplateBuildTest-${config} PROPERTIES DEPENDS mitkProjectTemplateConfigureTest-${config} LABELS "MITK;BlueBerry") endforeach() else() - add_test(mitkProjectTemplateConfigureTest-${CMAKE_BUILD_TYPE} - ${CMAKE_COMMAND} --build ${MITK_BINARY_DIR} --config ${CMAKE_BUILD_TYPE} --target ${proj}) + add_test(NAME mitkProjectTemplateConfigureTest-${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_COMMAND} --build ${MITK_BINARY_DIR} --config ${CMAKE_BUILD_TYPE} --target ${proj}) set_tests_properties(mitkProjectTemplateConfigureTest-${CMAKE_BUILD_TYPE} PROPERTIES DEPENDS mitkProjectTemplateCleanTest2 LABELS "MITK;BlueBerry") - add_test(mitkProjectTemplateBuildTest-${CMAKE_BUILD_TYPE} - ${CMAKE_COMMAND} --build ${MITK-ProjectTemplate_BINARY_DIR} --config ${CMAKE_BUILD_TYPE}) + add_test(NAME mitkProjectTemplateBuildTest-${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_COMMAND} --build ${MITK-ProjectTemplate_BINARY_DIR} --config ${CMAKE_BUILD_TYPE}) set_tests_properties(mitkProjectTemplateBuildTest-${CMAKE_BUILD_TYPE} PROPERTIES DEPENDS mitkProjectTemplateConfigureTest-${CMAKE_BUILD_TYPE} LABELS "MITK;BlueBerry") endif() set(package_test_configurations) if(WIN32) # Only test packaging if build type is "Release" on Windows set(package_test_configurations CONFIGURATIONS Release) endif() if(NOT MITK_FAST_TESTING) if(WIN32) # Only test packaging if build type is "Release" on Windows add_test(NAME mitkProjectTemplatePackageTest CONFIGURATIONS Release COMMAND ${CMAKE_COMMAND} --build ${MITK-ProjectTemplate_BINARY_DIR}/AwesomeProject-build --config Release --target package) set_tests_properties(mitkProjectTemplatePackageTest PROPERTIES DEPENDS mitkProjectTemplateBuildTest-Release TIMEOUT 3600 LABELS "MITK;BlueBerry") elseif(CMAKE_BUILD_TYPE) - add_test(mitkProjectTemplatePackageTest - ${CMAKE_COMMAND} --build ${MITK-ProjectTemplate_BINARY_DIR}/AwesomeProject-build --config ${CMAKE_BUILD_TYPE} --target package) + add_test(NAME mitkProjectTemplatePackageTest + COMMAND ${CMAKE_COMMAND} --build ${MITK-ProjectTemplate_BINARY_DIR}/AwesomeProject-build --config ${CMAKE_BUILD_TYPE} --target package) set_tests_properties(mitkProjectTemplatePackageTest PROPERTIES DEPENDS mitkProjectTemplateBuildTest-${CMAKE_BUILD_TYPE} TIMEOUT 3600 LABELS "MITK;BlueBerry") endif() endif() endif() diff --git a/CMakeExternals/CTK.cmake b/CMakeExternals/CTK.cmake index ac09913e87..2e16bf2a12 100644 --- a/CMakeExternals/CTK.cmake +++ b/CMakeExternals/CTK.cmake @@ -1,66 +1,66 @@ #----------------------------------------------------------------------------- # CTK #----------------------------------------------------------------------------- IF(MITK_USE_CTK) # Sanity checks IF(DEFINED CTK_DIR AND NOT EXISTS ${CTK_DIR}) MESSAGE(FATAL_ERROR "CTK_DIR variable is defined but corresponds to non-existing directory") ENDIF() SET(proj CTK) SET(proj_DEPENDENCIES ) SET(CTK_DEPENDS ${proj}) IF(NOT DEFINED CTK_DIR) - SET(revision_tag 34a638b) + SET(revision_tag 3d73e05) IF(${proj}_REVISION_TAG) SET(revision_tag ${${proj}_REVISION_TAG}) ENDIF() SET(ctk_optional_cache_args ) IF(MITK_USE_Python) LIST(APPEND ctk_optional_cache_args -DCTK_LIB_Scripting/Python/Widgets:BOOL=ON ) ENDIF() FOREACH(type RUNTIME ARCHIVE LIBRARY) IF(DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY) LIST(APPEND mitk_optional_cache_args -DCTK_PLUGIN_${type}_OUTPUT_DIRECTORY:PATH=${CTK_PLUGIN_${type}_OUTPUT_DIRECTORY}) ENDIF() ENDFOREACH() ExternalProject_Add(${proj} SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}-src BINARY_DIR ${proj}-build PREFIX ${proj}-cmake GIT_REPOSITORY http://github.com/commontk/CTK.git GIT_TAG ${revision_tag} UPDATE_COMMAND "" INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} ${ctk_optional_cache_args} -DDESIRED_QT_VERSION:STRING=4 -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DGit_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DGIT_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DCTK_LIB_PluginFramework:BOOL=ON -DCTK_LIB_DICOM/Widgets:BOOL=ON -DCTK_PLUGIN_org.commontk.eventadmin:BOOL=ON -DCTK_PLUGIN_org.commontk.configadmin:BOOL=ON -DCTK_USE_GIT_PROTOCOL:BOOL=OFF DEPENDS ${proj_DEPENDENCIES} ) SET(CTK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) ELSE() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") ENDIF() ENDIF() diff --git a/CMakeLists.txt b/CMakeLists.txt index bb417210c0..f35573c3f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,805 +1,797 @@ cmake_minimum_required(VERSION 2.8.4) #----------------------------------------------------------------------------- # 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 ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ set(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) 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) option(MITK_BUILD_TUTORIAL "Build the MITK tutorial" 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}) option(MITK_USE_DCMTK "EXEPERIMENTAL, superbuild only: Use DCMTK in MITK" OFF) option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) option(MITK_USE_Python "Use Python wrapping in MITK" OFF) set(MITK_USE_CableSwig ${MITK_USE_Python}) mark_as_advanced(MITK_BUILD_ALL_APPS MITK_USE_CTK MITK_USE_DCMTK ) 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) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) mark_as_advanced(MITK_BUILD_ALL_PLUGINS) if(NOT MITK_USE_CTK) message("Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY") set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE) endif() endif() if(MITK_USE_CTK AND NOT MITK_USE_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) endif() if(MITK_USE_QT) # find the package at the very beginning, so that QT4_FOUND is available find_package(Qt4 4.6.2 REQUIRED) 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 "" 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_DIMENSIONS) set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") endif() #----------------------------------------------------------------------------- # Additional CXX/C Flags #----------------------------------------------------------------------------- set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags") mark_as_advanced(ADDITIONAL_C_FLAGS) set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags") mark_as_advanced(ADDITIONAL_CXX_FLAGS) #----------------------------------------------------------------------------- # Project.xml #----------------------------------------------------------------------------- # A list of topologically ordered targets set(CTEST_PROJECT_SUBPROJECTS) if(MITK_USE_BLUEBERRY) list(APPEND CTEST_PROJECT_SUBPROJECTS BlueBerry) endif() list(APPEND CTEST_PROJECT_SUBPROJECTS MITK-Core MITK-CoreUI MITK-IGT MITK-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 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(mitkFunctionCreateWindowsBatchScript) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionCompileSnippets) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) #----------------------------------------------------------------------------- # Prerequesites #----------------------------------------------------------------------------- find_package(ITK REQUIRED) find_package(VTK REQUIRED) if(ITK_USE_SYSTEM_GDCM) find_package(GDCM PATHS ${ITK_GDCM_DIR} REQUIRED) endif() #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- # ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and ExtApp option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON) mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW) # TODO: check if necessary option(USE_ITKZLIB "Use the ITK zlib for pic compression." ON) mark_as_advanced(USE_ITKZLIB) 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) #----------------------------------------------------------------------------- # 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(APPLE) if(MITK_BUILD_org.mitk.gui.qt.extapplication) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} ExtApp) endif() if(MITK_BUILD_org.mitk.gui.qt.application) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} CoreApp) endif() endif(APPLE) #----------------------------------------------------------------------------- # Set 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} ${ADDITIONAL_C_FLAGS}") set(MITK_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}") include(mitkSetupC++0xVariables) if(CMAKE_COMPILER_IS_GNUCXX) set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2") mitkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags) mitkFunctionCheckCompilerFlags("-Wl,--as-needed" cflags) if(MITK_USE_C++0x) mitkFunctionCheckCompilerFlags("-std=c++0x" MITK_CXX_FLAGS) endif() mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag. # Doing so should allow to build package made for distribution using older linux distro. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0")) mitkFunctionCheckCompilerFlags("-fstack-protector-all" cflags) endif() if(MINGW) # suppress warnings about auto imported symbols set(MITK_CXX_FLAGS "-Wl,--enable-auto-import ${MITK_CXX_FLAGS}") # we need to define a Windows version set(MITK_CXX_FLAGS "-D_WIN32_WINNT=0x0500 ${MITK_CXX_FLAGS}") endif() set(MITK_C_FLAGS "${cflags} ${MITK_C_FLAGS}") #set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${MITK_CXX_FLAGS}") set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wstrict-null-sentinel ${MITK_CXX_FLAGS}") endif() #----------------------------------------------------------------------------- # MITK Packages #----------------------------------------------------------------------------- set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) option(MITK_ENABLE_GUI_TESTING OFF "Enable the MITK GUI tests") # Setup file for setting custom ctest vars configure_file( CMake/CTestCustom.cmake.in ${MITK_BINARY_DIR}/CTestCustom.cmake @ONLY ) # Configuration for the CMake-generated test driver set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ") set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " try {") set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " } catch( std::exception & excp ) { fprintf(stderr,\"%s\\n\",excp.what()); return EXIT_FAILURE; } catch( ... ) { printf(\"Exception caught in the test driver\\n\"); return EXIT_FAILURE; } ") set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output") if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR}) file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR}) endif() # 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} 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() - include(mitkSetupBlueBerry) + set(mbilog_DIR "${mbilog_BINARY_DIR}") + + if(MITK_BUILD_ALL_PLUGINS) + set(BLUEBERRY_BUILD_ALL_PLUGINS ON) + endif() + + 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 Flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}") if(MITK_USE_QT) add_definitions(-DQWT_DLL) endif() #----------------------------------------------------------------------------- # Add custom targets representing CDash subprojects #----------------------------------------------------------------------------- foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) if(NOT TARGET ${subproject} AND NOT subproject MATCHES "Unlabeled") add_custom_target(${subproject}) endif() endforeach() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- link_directories(${MITK_LINK_DIRECTORIES}) add_subdirectory(Core) - -if(MITK_USE_QT AND QT4_FOUND) - add_subdirectory(CoreUI/Qmitk) -endif() - add_subdirectory(Modules) if(MITK_USE_BLUEBERRY) find_package(BlueBerry REQUIRED) set(MITK_DEFAULT_SUBPROJECTS MITK-Plugins) - include("${CMAKE_CURRENT_SOURCE_DIR}/CoreUI/Bundles/PluginList.cmake") - set(mitk_core_plugins_fullpath ) - foreach(core_plugin ${MITK_CORE_PLUGINS}) - list(APPEND mitk_core_plugins_fullpath CoreUI/Bundles/${core_plugin}) - endforeach() - + # Plug-in testing (needs some work to be enabled again) if(BUILD_TESTING) include(berryTestingHelpers) - include("${CMAKE_CURRENT_SOURCE_DIR}/CoreUI/BundleTesting/PluginList.cmake") - set(mitk_core_test_plugins_fullpath ) - foreach(core_test_plugin ${MITK_CORE_TEST_PLUGINS}) - # list(APPEND mitk_core_test_plugins_fullpath CoreUI/BundleTesting/${core_test_plugin}) - endforeach() - 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.application") + set(BLUEBERRY_TEST_APP_ID "org.mitk.qt.coreapplication") endif() - include("${CMAKE_CURRENT_SOURCE_DIR}/Modules/Bundles/PluginList.cmake") - set(mitk_ext_plugins_fullpath ) - foreach(ext_plugin ${MITK_EXT_PLUGINS}) - list(APPEND mitk_ext_plugins_fullpath Modules/Bundles/${ext_plugin}) + 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(ext_plugin ${MITK_PRIVATE_PLUGINS}) - list(APPEND mitk_ext_plugins_fullpath ${MITK_PRIVATE_MODULES}/${ext_plugin}) + foreach(mitk_plugin ${MITK_PRIVATE_PLUGINS}) + list(APPEND mitk_plugins_fullpath ${MITK_PRIVATE_MODULES}/${mitk_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() - # Add the BlueBerry plugins to the set of core plugins - set(MITK_CORE_ENABLED_PLUGINS ${${CMAKE_PROJECT_NAME}_PLUGIN_LIBRARIES}) - # Get infos about application directories and build options include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") set(mitk_apps_fullpath ) foreach(mitk_app ${MITK_APPS}) list(APPEND mitk_apps_fullpath "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${mitk_app}") endforeach() - ctkMacroSetupPlugins(${mitk_core_plugins_fullpath} ${mitk_core_test_plugins_fullpath} ${mitk_ext_plugins_fullpath} + ctkMacroSetupPlugins(${mitk_plugins_fullpath} BUILD_OPTION_PREFIX MITK_BUILD_ APPS ${mitk_apps_fullpath} BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) - ctkFunctionExtractPluginTargets("${mitk_core_plugins_fullpath}" ON _coreui_plugins) - list(APPEND MITK_CORE_ENABLED_PLUGINS ${_coreui_plugins}) - 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() - # add legacy BlueBerry bundles - add_subdirectory(Modules/Bundles) endif() # Construct a list of paths containing runtime directories # for MITK applications on Windows set(MITK_RUNTIME_PATH "${VTK_LIBRARY_DIRS}/%VS_BUILD_TYPE%;${ITK_LIBRARY_DIRS}/%VS_BUILD_TYPE%;${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/%VS_BUILD_TYPE%" ) + if(QT4_FOUND) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${QT_LIBRARY_DIR}/../bin") endif() + if(MITK_USE_BLUEBERRY) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${CTK_RUNTIME_LIBRARY_DIRS}/%VS_BUILD_TYPE%") if(DEFINED CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY) if(IS_ABSOLUTE "${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}") set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}/%VS_BUILD_TYPE%") else() set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}/%VS_BUILD_TYPE%") endif() else() set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins/%VS_BUILD_TYPE%") endif() endif() + if(GDCM_DIR) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${GDCM_DIR}/bin/%VS_BUILD_TYPE%") endif() + if(OpenCV_DIR) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${OpenCV_DIR}/bin/%VS_BUILD_TYPE%") endif() + # DCMTK is statically build #if(DCMTK_DIR) # set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${DCMTK_DIR}/bin/%VS_BUILD_TYPE%") #endif() + if(MITK_USE_Boost AND MITK_USE_Boost_LIBRARIES AND NOT MITK_USE_SYSTEM_Boost) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${Boost_LIBRARY_DIRS}") endif() - - #----------------------------------------------------------------------------- # Python Wrapping #----------------------------------------------------------------------------- set(MITK_WRAPPING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Wrapping) set(MITK_WRAPPING_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Wrapping) option(MITK_USE_Python "Build cswig Python wrapper support (requires CableSwig)." OFF) if(MITK_USE_Python) add_subdirectory(Wrapping) endif() #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- add_subdirectory(Documentation) #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables include(mitkSetupCPack) if(MITK_BUILD_org.mitk.gui.qt.application) list(APPEND CPACK_CREATE_DESKTOP_LINKS "CoreApp") endif() if(MITK_BUILD_org.mitk.gui.qt.extapplication) list(APPEND CPACK_CREATE_DESKTOP_LINKS "ExtApp") endif() configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake") file(REMOVE ${MITK_EXPORTS_FILE}) if(MITK_USE_BLUEBERRY) # This is for installation support of external projects depending on # MITK plugins. The export file should not be used for linking to MITK # libraries without using LINK_DIRECTORIES, since the exports are incomplete # yet(depending libraries are not exported). if(MITK_PLUGIN_LIBRARIES) export(TARGETS ${MITK_PLUGIN_LIBRARIES} APPEND FILE ${MITK_EXPORTS_FILE}) endif() endif() configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(VECMATH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/vecmath) set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc) set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities) 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) diff --git a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp index 1b8f763fab..ae8c58e11c 100644 --- a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp +++ b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.cpp @@ -1,211 +1,276 @@ #include "mitkClippedSurfaceBoundsCalculator.h" #include "mitkLine.h" -#define ROUND_P(x) ((int)((x)+0.5)) +#define ROUND_P(x) ((x)>=0?(int)((x)+0.5):(int)((x)-0.5)) mitk::ClippedSurfaceBoundsCalculator::ClippedSurfaceBoundsCalculator( const mitk::PlaneGeometry* geometry, - mitk::Image::Pointer image) + mitk::Image::Pointer image): + m_PlaneGeometry(NULL), + m_Geometry3D(NULL), + m_Image(NULL) { // initialize with meaningless slice indices m_MinMaxOutput.clear(); for(int i = 0; i < 3; i++) { m_MinMaxOutput.push_back( OutputType( std::numeric_limits::max() , std::numeric_limits::min() )); } this->SetInput(geometry, image); } +mitk::ClippedSurfaceBoundsCalculator::ClippedSurfaceBoundsCalculator( + const mitk::Geometry3D* geometry, + mitk::Image::Pointer image): + m_PlaneGeometry(NULL), + m_Geometry3D(NULL), + m_Image(NULL) +{ + // initialize with meaningless slice indices + m_MinMaxOutput.clear(); + for(int i = 0; i < 3; i++) + { + m_MinMaxOutput.push_back( + OutputType( std::numeric_limits::max() , + std::numeric_limits::min() )); + } + + + this->SetInput(geometry, image); +} + mitk::ClippedSurfaceBoundsCalculator::~ClippedSurfaceBoundsCalculator() { } void mitk::ClippedSurfaceBoundsCalculator::SetInput( const mitk::PlaneGeometry* geometry, mitk::Image* image) { if(geometry && image) { this->m_PlaneGeometry = geometry; this->m_Image = image; + this->m_Geometry3D = NULL; //Not possible to set both + } +} + +void +mitk::ClippedSurfaceBoundsCalculator::SetInput( + const mitk::Geometry3D* geometry, + mitk::Image* image) +{ + if(geometry && image) + { + this->m_Geometry3D = geometry; + this->m_Image = image; + this->m_PlaneGeometry = NULL; //Not possible to set both } } mitk::ClippedSurfaceBoundsCalculator::OutputType mitk::ClippedSurfaceBoundsCalculator::GetMinMaxSpatialDirectionX() { return this->m_MinMaxOutput[0]; } mitk::ClippedSurfaceBoundsCalculator::OutputType mitk::ClippedSurfaceBoundsCalculator::GetMinMaxSpatialDirectionY() { return this->m_MinMaxOutput[1]; } mitk::ClippedSurfaceBoundsCalculator::OutputType mitk::ClippedSurfaceBoundsCalculator::GetMinMaxSpatialDirectionZ() { return this->m_MinMaxOutput[2]; } void mitk::ClippedSurfaceBoundsCalculator::Update() { - // SEE HEADER DOCUMENTATION for explanation - - typedef std::vector< std::pair > EdgesVector; - this->m_MinMaxOutput.clear(); for(int i = 0; i < 3; i++) { this->m_MinMaxOutput.push_back(OutputType( std::numeric_limits::max() , std::numeric_limits::min() )); } + if(m_PlaneGeometry.IsNotNull()) + { + this->CalculateIntersectionPoints(m_PlaneGeometry); + } + else if(m_Geometry3D.IsNotNull()) + { + // go through all slices of the image, ... + const mitk::SlicedGeometry3D* slicedGeometry3D = dynamic_cast( m_Geometry3D.GetPointer() ); + int allSlices = slicedGeometry3D->GetSlices(); + this->CalculateIntersectionPoints(dynamic_cast(slicedGeometry3D->GetGeometry2D(0))); + this->CalculateIntersectionPoints(dynamic_cast(slicedGeometry3D->GetGeometry2D(allSlices-1))); + } +} + +void mitk::ClippedSurfaceBoundsCalculator::CalculateIntersectionPoints(const mitk::PlaneGeometry* geometry) +{ + // SEE HEADER DOCUMENTATION for explanation + + typedef std::vector< std::pair > EdgesVector; + Point3D origin; Vector3D xDirection, yDirection, zDirection; const Vector3D spacing = m_Image->GetGeometry()->GetSpacing(); origin = m_Image->GetGeometry()->GetOrigin(); //Left, bottom, front //Get axis vector for the spatial directions xDirection = m_Image->GetGeometry()->GetAxisVector(1); yDirection = m_Image->GetGeometry()->GetAxisVector(0); zDirection = m_Image->GetGeometry()->GetAxisVector(2); /* * For the calculation of the intersection points we need as corner points the center-based image coordinates. * With the method GetCornerPoint() of the class Geometry3D we only get the corner-based coordinates. * Therefore we need to calculate the center-based corner points here. For that we add/substract the corner- * based coordinates with the spacing of the geometry3D. */ for( int i = 0; i < 3; i++ ) { if(xDirection[i] < 0) { xDirection[i] += spacing[i]; } else if( xDirection[i] > 0 ) { xDirection[i] -= spacing[i]; } if(yDirection[i] < 0) { yDirection[i] += spacing[i]; } else if( yDirection[i] > 0 ) { yDirection[i] -= spacing[i]; } if(zDirection[i] < 0) { zDirection[i] += spacing[i]; } else if( zDirection[i] > 0 ) { zDirection[i] -= spacing[i]; } } Point3D leftBottomFront, leftTopFront, leftBottomBack, leftTopBack; Point3D rightBottomFront, rightTopFront, rightBottomBack, rightTopBack; leftBottomFront = origin; leftTopFront = origin + yDirection; leftBottomBack = origin + zDirection; leftTopBack = origin + yDirection + zDirection; rightBottomFront = origin + xDirection; rightTopFront = origin + xDirection + yDirection; rightBottomBack = origin + xDirection + zDirection; rightTopBack = origin + xDirection + yDirection + zDirection; EdgesVector edgesOf3DBox; edgesOf3DBox.push_back(std::make_pair(leftBottomBack, // x = left=xfront, y=bottom=yfront, z=front=zfront leftTopFront)); // left, top, front edgesOf3DBox.push_back(std::make_pair(leftBottomFront, // left, bottom, front leftBottomBack)); // left, bottom, back edgesOf3DBox.push_back(std::make_pair(leftBottomFront, // left, bottom, front rightBottomFront)); // right, bottom, front edgesOf3DBox.push_back(std::make_pair(leftTopFront, // left, top, front rightTopFront)); // right, top, front edgesOf3DBox.push_back(std::make_pair(leftTopFront, // left, top, front leftTopBack)); // left, top, back edgesOf3DBox.push_back(std::make_pair(rightTopFront, // right, top, front rightTopBack)); // right, top, back edgesOf3DBox.push_back(std::make_pair(rightTopFront, // right, top, front rightBottomFront)); // right, bottom, front edgesOf3DBox.push_back(std::make_pair(rightBottomFront, // right, bottom, front rightBottomBack)); // right, bottom, back edgesOf3DBox.push_back(std::make_pair(rightBottomBack, // right, bottom, back leftBottomBack)); // left, bottom, back edgesOf3DBox.push_back(std::make_pair(rightBottomBack, // right, bottom, back rightTopBack)); // right, top, back edgesOf3DBox.push_back(std::make_pair(rightTopBack, // right, top, back leftTopBack)); // left, top, back edgesOf3DBox.push_back(std::make_pair(leftTopBack, // left, top, back leftBottomBack)); // left, bottom, back for (EdgesVector::iterator iterator = edgesOf3DBox.begin(); iterator != edgesOf3DBox.end();iterator++) { Point3D startPoint = (*iterator).first; // start point of the line Point3D endPoint = (*iterator).second; // end point of the line Vector3D lineDirection = endPoint - startPoint; mitk::Line3D line(startPoint, lineDirection); Point3D intersectionWorldPoint; intersectionWorldPoint.Fill(std::numeric_limits::min()); // Get intersection point of line and plane geometry - m_PlaneGeometry->IntersectionPoint(line, intersectionWorldPoint); + geometry->IntersectionPoint(line, intersectionWorldPoint); double t = -1.0; - bool isIntersectionPointOnLine; - isIntersectionPointOnLine = m_PlaneGeometry->IntersectionPointParam(line, t); + + bool doesLineIntersectWithPlane(false); + + if(line.GetDirection().GetNorm() < mitk::eps && geometry->Distance(line.GetPoint1()) < mitk::sqrteps) + { + t = 1.0; + doesLineIntersectWithPlane = true; + intersectionWorldPoint = line.GetPoint1(); + } + else + { + geometry->IntersectionPoint(line, intersectionWorldPoint); + doesLineIntersectWithPlane = geometry->IntersectionPointParam(line, t); + } mitk::Point3D intersectionIndexPoint; //Get index point m_Image->GetGeometry()->WorldToIndex(intersectionWorldPoint, intersectionIndexPoint); - if(0.0 <= t && t <= 1.0 && isIntersectionPointOnLine) + if ( doesLineIntersectWithPlane && -mitk::sqrteps <= t && t <= 1.0 + mitk::sqrteps ) { for(int dim = 0; dim < 3; dim++) { // minimum //If new point value is lower than old if( this->m_MinMaxOutput[dim].first > ROUND_P(intersectionIndexPoint[dim]) ) { this->m_MinMaxOutput[dim].first = ROUND_P(intersectionIndexPoint[dim]); //set new value } // maximum //If new point value is higher than old if( this->m_MinMaxOutput[dim].second < ROUND_P(intersectionIndexPoint[dim]) ) { this->m_MinMaxOutput[dim].second = ROUND_P(intersectionIndexPoint[dim]); //set new value } } } } } diff --git a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h index 89201b1520..b5eca2af94 100644 --- a/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h +++ b/Core/Code/Algorithms/mitkClippedSurfaceBoundsCalculator.h @@ -1,102 +1,107 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile: mitkPropertyManager.cpp,v $ Language: C++ Date: $Date: 2005/06/28 12:37:25 $ Version: $Revision: 1.12 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef ClippedSurfaceBoundsCalculator_h_included #define ClippedSurfaceBoundsCalculator_h_included #include "mitkImage.h" #include "mitkPlaneGeometry.h" #include /** * \brief Find image slices visible on a given plane. * * The class name is not helpful in finding this class. Good suggestions welcome. * * Given a PlaneGeometry (e.g. the 2D plane of a render window), this class * calculates which slices of an mitk::Image are visible on this plane. * Calculation is done for X, Y, and Z direction, the result is available in * form of a pair (minimum,maximum) slice index. * * Such calculations are useful if you want to display information about the * currently visible slice (overlays, statistics, ...) and you don't want to * depend on any prior information about hat the renderwindow is currently showing. * * \warning The interface attempts to look like an ITK filter but it is far from being one. */ namespace mitk { class MITK_CORE_EXPORT ClippedSurfaceBoundsCalculator { public: ClippedSurfaceBoundsCalculator(const mitk::PlaneGeometry* geometry = NULL, mitk::Image::Pointer image = NULL); + ClippedSurfaceBoundsCalculator(const mitk::Geometry3D* geometry, + mitk::Image::Pointer image); virtual ~ClippedSurfaceBoundsCalculator(); void SetInput(const mitk::PlaneGeometry* geometry, mitk::Image* image); + void SetInput(const mitk::Geometry3D *geometry, mitk::Image *image); /** \brief Request calculation. How cut/visible slice indices are determined: 1. construct a bounding box of the image. This is the box that connect the outer voxel centers(!). 2. check the edges of this box. 3. intersect each edge with the plane geometry - if the intersection point is within the image box, we update the visible/cut slice indices for all dimensions. - else we ignore the cut */ void Update(); /** \brief Minimum (first) and maximum (second) slice index. */ typedef std::pair OutputType; /** \brief What X coordinates (slice indices) are cut/visible in given plane. */ OutputType GetMinMaxSpatialDirectionX(); /** \brief What Y coordinates (slice indices) are cut/visible in given plane. */ OutputType GetMinMaxSpatialDirectionY(); /** \brief What Z coordinates (slice indices) are cut/visible in given plane. */ OutputType GetMinMaxSpatialDirectionZ(); protected: + void CalculateIntersectionPoints(const mitk::PlaneGeometry* geometry); mitk::PlaneGeometry::ConstPointer m_PlaneGeometry; + mitk::Geometry3D::ConstPointer m_Geometry3D; mitk::Image::Pointer m_Image; std::vector< OutputType > m_MinMaxOutput; }; } //namespace mitk #endif diff --git a/Core/Code/Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp b/Core/Code/Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp index a5fcf95317..0a8293c671 100644 --- a/Core/Code/Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp +++ b/Core/Code/Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp @@ -1,450 +1,450 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkGeometry2DDataToSurfaceFilter.h" #include "mitkSurface.h" #include "mitkGeometry3D.h" #include "mitkGeometry2DData.h" #include "mitkPlaneGeometry.h" #include "mitkAbstractTransformGeometry.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include mitk::Geometry2DDataToSurfaceFilter::Geometry2DDataToSurfaceFilter() : m_UseGeometryParametricBounds( true ), m_XResolution( 10 ), m_YResolution( 10 ), m_PlaceByGeometry( false ), m_UseBoundingBox( false ) { m_PlaneSource = vtkPlaneSource::New(); m_Transform = vtkTransform::New(); m_CubeSource = vtkCubeSource::New(); m_PolyDataTransformer = vtkTransformPolyDataFilter::New(); m_Plane = vtkPlane::New(); m_PlaneCutter = vtkCutter::New(); m_PlaneStripper = vtkStripper::New(); m_PlanePolyData = vtkPolyData::New(); m_NormalsUpdater = vtkPPolyDataNormals::New(); m_PlaneTriangler = vtkTriangleFilter::New(); m_TextureMapToPlane = vtkTextureMapToPlane::New(); m_Box = vtkBox::New(); m_PlaneClipper = vtkClipPolyData::New(); m_VtkTransformPlaneFilter = vtkTransformPolyDataFilter::New(); m_VtkTransformPlaneFilter->SetInput( m_PlaneSource->GetOutput() ); } mitk::Geometry2DDataToSurfaceFilter::~Geometry2DDataToSurfaceFilter() { m_PlaneSource->Delete(); m_Transform->Delete(); m_CubeSource->Delete(); m_PolyDataTransformer->Delete(); m_Plane->Delete(); m_PlaneCutter->Delete(); m_PlaneStripper->Delete(); m_PlanePolyData->Delete(); m_NormalsUpdater->Delete(); m_PlaneTriangler->Delete(); m_TextureMapToPlane->Delete(); m_Box->Delete(); m_PlaneClipper->Delete(); m_VtkTransformPlaneFilter->Delete(); } void mitk::Geometry2DDataToSurfaceFilter::GenerateOutputInformation() { mitk::Geometry2DData::ConstPointer input = this->GetInput(); mitk::Surface::Pointer output = this->GetOutput(); if ( input.IsNull() || (input->GetGeometry2D() == NULL) || (input->GetGeometry2D()->IsValid() == false) || (m_UseBoundingBox && (m_BoundingBox.IsNull() || (m_BoundingBox->GetDiagonalLength2() < mitk::eps))) ) { return; } Point3D origin; Point3D right, bottom; vtkPolyData *planeSurface = NULL; // Does the Geometry2DData contain a PlaneGeometry? if ( dynamic_cast< PlaneGeometry * >( input->GetGeometry2D() ) != NULL ) { mitk::PlaneGeometry *planeGeometry = dynamic_cast< PlaneGeometry * >( input->GetGeometry2D() ); if ( m_PlaceByGeometry ) { // Let the output use the input geometry to appropriately transform the // coordinate system. mitk::AffineGeometryFrame3D::TransformType *affineTransform = planeGeometry->GetIndexToWorldTransform(); mitk::TimeSlicedGeometry *timeGeometry = output->GetTimeSlicedGeometry(); timeGeometry->SetIndexToWorldTransform( affineTransform ); mitk::Geometry3D *g3d = timeGeometry->GetGeometry3D( 0 ); g3d->SetIndexToWorldTransform( affineTransform ); } if ( !m_UseBoundingBox) { // We do not have a bounding box, so no clipping is required. if ( m_PlaceByGeometry ) { // Derive coordinate axes and origin from input geometry extent origin.Fill( 0.0 ); FillVector3D( right, planeGeometry->GetExtent(0), 0.0, 0.0 ); FillVector3D( bottom, 0.0, planeGeometry->GetExtent(1), 0.0 ); } else { // Take the coordinate axes and origin directly from the input geometry. origin = planeGeometry->GetOrigin(); right = planeGeometry->GetCornerPoint( false, true ); bottom = planeGeometry->GetCornerPoint( true, false ); } // Since the plane is planar, there is no need to subdivide the grid // (cf. AbstractTransformGeometry case) m_PlaneSource->SetXResolution( 1 ); m_PlaneSource->SetYResolution( 1 ); m_PlaneSource->SetOrigin( origin[0], origin[1], origin[2] ); m_PlaneSource->SetPoint1( right[0], right[1], right[2] ); m_PlaneSource->SetPoint2( bottom[0], bottom[1], bottom[2] ); planeSurface = m_PlaneSource->GetOutput(); planeSurface->Update(); } else { // Set up a cube with the extent and origin of the bounding box. This // cube will be clipped by a plane later on. The intersection of the // cube and the plane will be the surface we are interested in. Note // that the bounding box needs to be explicitly specified by the user // of this class, since it is not necessarily clear from the data // available herein which bounding box to use. In most cases, this // would be the bounding box of the input geometry's reference // geometry, but this is not an inevitable requirement. mitk::BoundingBox::PointType boundingBoxMin = m_BoundingBox->GetMinimum(); mitk::BoundingBox::PointType boundingBoxMax = m_BoundingBox->GetMaximum(); mitk::BoundingBox::PointType boundingBoxCenter = m_BoundingBox->GetCenter(); m_CubeSource->SetXLength( boundingBoxMax[0] - boundingBoxMin[0] ); m_CubeSource->SetYLength( boundingBoxMax[1] - boundingBoxMin[1] ); m_CubeSource->SetZLength( boundingBoxMax[2] - boundingBoxMin[2] ); m_CubeSource->SetCenter( boundingBoxCenter[0], boundingBoxCenter[1], boundingBoxCenter[2] ); // Now we have to transform the cube, so that it will cut our plane // appropriately. (As can be seen below, the plane corresponds to the // z-plane in the coordinate system and is *not* transformed.) Therefore, // we get the inverse of the plane geometry's transform and concatenate // it with the transform of the reference geometry, if available. m_Transform->Identity(); m_Transform->Concatenate( planeGeometry->GetVtkTransform()->GetLinearInverse() ); Geometry3D *referenceGeometry = planeGeometry->GetReferenceGeometry(); if ( referenceGeometry ) { m_Transform->Concatenate( referenceGeometry->GetVtkTransform() ); } // Transform the cube accordingly (s.a.) m_PolyDataTransformer->SetInput( m_CubeSource->GetOutput() ); m_PolyDataTransformer->SetTransform( m_Transform ); // Initialize the plane to clip the cube with, as lying on the z-plane m_Plane->SetOrigin( 0.0, 0.0, 0.0 ); m_Plane->SetNormal( 0.0, 0.0, 1.0 ); // Cut the plane with the cube. m_PlaneCutter->SetInput( m_PolyDataTransformer->GetOutput() ); m_PlaneCutter->SetCutFunction( m_Plane ); // The output of the cutter must be converted into appropriate poly data. m_PlaneStripper->SetInput( m_PlaneCutter->GetOutput() ); m_PlaneStripper->Update(); if ( m_PlaneStripper->GetOutput()->GetNumberOfPoints() < 3 ) { return; } m_PlanePolyData->SetPoints( m_PlaneStripper->GetOutput()->GetPoints() ); m_PlanePolyData->SetPolys( m_PlaneStripper->GetOutput()->GetLines() ); m_PlaneTriangler->SetInput( m_PlanePolyData ); // Get bounds of the resulting surface and use it to generate the texture // mapping information m_PlaneTriangler->Update(); m_PlaneTriangler->GetOutput()->ComputeBounds(); vtkFloatingPointType *surfaceBounds = m_PlaneTriangler->GetOutput()->GetBounds(); origin[0] = surfaceBounds[0]; origin[1] = surfaceBounds[2]; origin[2] = surfaceBounds[4]; right[0] = surfaceBounds[1]; right[1] = surfaceBounds[2]; right[2] = surfaceBounds[4]; bottom[0] = surfaceBounds[0]; bottom[1] = surfaceBounds[3]; bottom[2] = surfaceBounds[4]; // Now we tell the data how it shall be textured afterwards; // description see above. m_TextureMapToPlane->SetInput( m_PlaneTriangler->GetOutput() ); m_TextureMapToPlane->AutomaticPlaneGenerationOn(); m_TextureMapToPlane->SetOrigin( origin[0], origin[1], origin[2] ); m_TextureMapToPlane->SetPoint1( right[0], right[1], right[2] ); m_TextureMapToPlane->SetPoint2( bottom[0], bottom[1], bottom[2] ); // Need to call update so that output data and bounds are immediately // available m_TextureMapToPlane->Update(); // Return the output of this generation process planeSurface = dynamic_cast< vtkPolyData * >( m_TextureMapToPlane->GetOutput() ); } } // Does the Geometry2DData contain an AbstractTransformGeometry? else if ( mitk::AbstractTransformGeometry *abstractGeometry = dynamic_cast< AbstractTransformGeometry * >( input->GetGeometry2D() ) ) { // In the case of an AbstractTransformGeometry (which holds a possibly // non-rigid transform), we proceed slightly differently: since the // plane can be arbitrarily deformed, we need to transform it by the // abstract transform before clipping it. The setup for this is partially // done in the constructor. origin = abstractGeometry->GetPlane()->GetOrigin(); right = origin + abstractGeometry->GetPlane()->GetAxisVector( 0 ); bottom = origin + abstractGeometry->GetPlane()->GetAxisVector( 1 ); // Define the plane m_PlaneSource->SetOrigin( origin[0], origin[1], origin[2] ); m_PlaneSource->SetPoint1( right[0], right[1], right[2] ); m_PlaneSource->SetPoint2( bottom[0], bottom[1], bottom[2] ); // Set the plane's resolution (unlike for non-deformable planes, the plane // grid needs to have a certain resolution so that the deformation has the // desired effect). if ( m_UseGeometryParametricBounds ) { m_PlaneSource->SetXResolution( (int)abstractGeometry->GetParametricExtent(0) ); m_PlaneSource->SetYResolution( (int)abstractGeometry->GetParametricExtent(1) ); } else { m_PlaneSource->SetXResolution( m_XResolution ); m_PlaneSource->SetYResolution( m_YResolution ); } if ( m_PlaceByGeometry ) { // Let the output use the input geometry to appropriately transform the // coordinate system. mitk::AffineGeometryFrame3D::TransformType *affineTransform = abstractGeometry->GetIndexToWorldTransform(); mitk::TimeSlicedGeometry *timeGeometry = output->GetTimeSlicedGeometry(); timeGeometry->SetIndexToWorldTransform( affineTransform ); mitk::Geometry3D *g3d = timeGeometry->GetGeometry3D( 0 ); g3d->SetIndexToWorldTransform( affineTransform ); vtkGeneralTransform *composedResliceTransform = vtkGeneralTransform::New(); composedResliceTransform->Identity(); composedResliceTransform->Concatenate( abstractGeometry->GetVtkTransform()->GetLinearInverse() ); composedResliceTransform->Concatenate( abstractGeometry->GetVtkAbstractTransform() ); // Use the non-rigid transform for transforming the plane. m_VtkTransformPlaneFilter->SetTransform( composedResliceTransform ); } else { // Use the non-rigid transform for transforming the plane. m_VtkTransformPlaneFilter->SetTransform( abstractGeometry->GetVtkAbstractTransform() ); } if ( m_UseBoundingBox ) { mitk::BoundingBox::PointType boundingBoxMin = m_BoundingBox->GetMinimum(); mitk::BoundingBox::PointType boundingBoxMax = m_BoundingBox->GetMaximum(); - mitk::BoundingBox::PointType boundingBoxCenter = m_BoundingBox->GetCenter(); + //mitk::BoundingBox::PointType boundingBoxCenter = m_BoundingBox->GetCenter(); m_Box->SetXMin( boundingBoxMin[0], boundingBoxMin[1], boundingBoxMin[2] ); m_Box->SetXMax( boundingBoxMax[0], boundingBoxMax[1], boundingBoxMax[2] ); } else { // Plane will not be clipped m_Box->SetXMin( -10000.0, -10000.0, -10000.0 ); m_Box->SetXMax( 10000.0, 10000.0, 10000.0 ); } m_Transform->Identity(); m_Transform->Concatenate( input->GetGeometry2D()->GetVtkTransform() ); m_Transform->PreMultiply(); m_Box->SetTransform( m_Transform ); m_PlaneClipper->SetInput( m_VtkTransformPlaneFilter->GetOutput() ); m_PlaneClipper->SetClipFunction( m_Box ); m_PlaneClipper->GenerateClippedOutputOff(); // important to NOT generate normals data for clipped part m_PlaneClipper->InsideOutOn(); m_PlaneClipper->SetValue( 0.0 ); planeSurface = m_PlaneClipper->GetOutput(); } m_NormalsUpdater->SetInput( planeSurface ); m_NormalsUpdater->AutoOrientNormalsOn(); // that's the trick! Brings consistency between // normals direction and front/back faces direction (see bug 1440) m_NormalsUpdater->ComputePointNormalsOn(); m_NormalsUpdater->Update(); output->SetVtkPolyData( m_NormalsUpdater->GetOutput() ); output->CalculateBoundingBox(); } void mitk::Geometry2DDataToSurfaceFilter::GenerateData() { mitk::Surface::Pointer output = this->GetOutput(); if (output.IsNull()) return; if (output->GetVtkPolyData()==NULL) return; output->GetVtkPolyData()->Update(); } const mitk::Geometry2DData *mitk::Geometry2DDataToSurfaceFilter::GetInput() { if (this->GetNumberOfInputs() < 1) { return 0; } return static_cast ( this->ProcessObject::GetInput(0) ); } const mitk::Geometry2DData * mitk::Geometry2DDataToSurfaceFilter ::GetInput(unsigned int idx) { return static_cast< const mitk::Geometry2DData * > ( this->ProcessObject::GetInput(idx) ); } void mitk::Geometry2DDataToSurfaceFilter ::SetInput(const mitk::Geometry2DData *input) { // Process object is not const-correct so the const_cast is required here this->ProcessObject::SetNthInput( 0, const_cast< mitk::Geometry2DData * >( input ) ); } void mitk::Geometry2DDataToSurfaceFilter ::SetInput(unsigned int index, const mitk::Geometry2DData *input) { if( index+1 > this->GetNumberOfInputs() ) { this->SetNumberOfRequiredInputs( index + 1 ); } // Process object is not const-correct so the const_cast is required here this->ProcessObject::SetNthInput(index, const_cast< mitk::Geometry2DData *>( input ) ); } void mitk::Geometry2DDataToSurfaceFilter ::SetBoundingBox( const mitk::BoundingBox *boundingBox ) { m_BoundingBox = boundingBox; this->UseBoundingBoxOn(); } const mitk::BoundingBox * mitk::Geometry2DDataToSurfaceFilter ::GetBoundingBox() const { return m_BoundingBox.GetPointer(); } diff --git a/Core/Code/CMakeLists.txt b/Core/Code/CMakeLists.txt index 6c9dbb3df6..ab9eb8f67d 100644 --- a/Core/Code/CMakeLists.txt +++ b/Core/Code/CMakeLists.txt @@ -1,54 +1,54 @@ FIND_PACKAGE(OpenGL) IF(NOT OPENGL_FOUND) MESSAGE("GL is required for MITK rendering") ENDIF(NOT OPENGL_FOUND ) SET(TOOL_CPPS "") MITK_CREATE_MODULE( Mitk - INCLUDE_DIRS Algorithms DataManagement Controllers Interactions IO Rendering Service ${MITK_BINARY_DIR} + INCLUDE_DIRS Algorithms DataManagement Controllers Interactions Interfaces IO Rendering Service ${MITK_BINARY_DIR} INTERNAL_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR} ${IPSEGMENTATION_INCLUDE_DIR} ${ANN_INCLUDE_DIR} DEPENDS mbilog tinyxml DEPENDS_INTERNAL IIL4MITK pic2vtk PACKAGE_DEPENDS ITK VTK EXPORT_DEFINE MITK_CORE_EXPORT ) # this is needed for libraries which link to Mitk and need # symbols from explicitly instantiated templates like # mitk::SurfaceVtkWriter which is referenced in # QmitkCommonFunctionality in the QmitkExt library. IF(MINGW) GET_TARGET_PROPERTY(_mitkCore_MINGW_linkflags Mitk LINK_FLAGS) IF(NOT _mitkCore_MINGW_linkflags) SET(_mitkCore_MINGW_linkflags "") ENDIF(NOT _mitkCore_MINGW_linkflags) SET_TARGET_PROPERTIES(Mitk PROPERTIES LINK_FLAGS "${_mitkCore_MINGW_linkflags} -Wl,--export-all-symbols") ENDIF(MINGW) # replacing Mitk by Mitk [due to removing the PROVIDES macro TARGET_LINK_LIBRARIES(Mitk ${LIBRARIES_FOR_${KITNAME}_CORE} ${IPFUNC_LIBRARY} ipSegmentation ann) TARGET_LINK_LIBRARIES(Mitk ${OPENGL_LIBRARIES} ) TARGET_LINK_LIBRARIES(Mitk gdcmCommon gdcmIOD gdcmDSED) IF(MSVC_IDE OR MSVC_VERSION OR MINGW) TARGET_LINK_LIBRARIES(Mitk psapi.lib) ENDIF(MSVC_IDE OR MSVC_VERSION OR MINGW) # verify ITK has been built with GDCM >= 2.0.14 set(GDCM_FULL_VERSION "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}") set(MITK_REQUIRED_GDCM_VERSION "2.0.14") if(GDCM_FULL_VERSION VERSION_LESS MITK_REQUIRED_GDCM_VERSION) message(SEND_ERROR "Mitk: MITK requires ITK with at least GDCM version ${MITK_REQUIRED_GDCM_VERSION}.\nFound version ${GDCM_FULL_VERSION} (GDCM NOT found if you don't see a version here)") else(GDCM_FULL_VERSION VERSION_LESS MITK_REQUIRED_GDCM_VERSION) message(STATUS "Mitk: Found GDCM version ${GDCM_FULL_VERSION}") endif(GDCM_FULL_VERSION VERSION_LESS MITK_REQUIRED_GDCM_VERSION) # build tests? OPTION(BUILD_TESTING "Build the MITK Core tests." ON) IF(BUILD_TESTING) ENABLE_TESTING() ADD_SUBDIRECTORY(Testing) ENDIF(BUILD_TESTING) diff --git a/Core/Code/Controllers/mitkRenderingManager.cpp b/Core/Code/Controllers/mitkRenderingManager.cpp index 8e0c685af4..b2e0a5e9fe 100644 --- a/Core/Code/Controllers/mitkRenderingManager.cpp +++ b/Core/Code/Controllers/mitkRenderingManager.cpp @@ -1,1013 +1,1022 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkRenderingManager.h" #include "mitkRenderingManagerFactory.h" #include "mitkBaseRenderer.h" #include "mitkGlobalInteraction.h" #include #include #include "mitkVector.h" #include #include #include #include namespace mitk { RenderingManager::Pointer RenderingManager::s_Instance = 0; RenderingManagerFactory *RenderingManager::s_RenderingManagerFactory = 0; RenderingManager ::RenderingManager() : m_UpdatePending( false ), m_MaxLOD( 1 ), m_LODIncreaseBlocked( false ), m_LODAbortMechanismEnabled( false ), m_ClippingPlaneEnabled( false ), m_TimeNavigationController( NULL ), m_DataStorage( NULL ), m_ConstrainedPaddingZooming ( true ) { m_ShadingEnabled.assign( 3, false ); m_ShadingValues.assign( 4, 0.0 ); m_GlobalInteraction = mitk::GlobalInteraction::GetInstance(); InitializePropertyList(); } RenderingManager ::~RenderingManager() { // Decrease reference counts of all registered vtkRenderWindows for // proper destruction RenderWindowVector::iterator it; for ( it = m_AllRenderWindows.begin(); it != m_AllRenderWindows.end(); ++it ) { (*it)->UnRegister( NULL ); RenderWindowCallbacksList::iterator callbacks_it = this->m_RenderWindowCallbacksList.find(*it); (*it)->RemoveObserver(callbacks_it->second.commands[0u]); (*it)->RemoveObserver(callbacks_it->second.commands[1u]); (*it)->RemoveObserver(callbacks_it->second.commands[2u]); } } void RenderingManager ::SetFactory( RenderingManagerFactory *factory ) { s_RenderingManagerFactory = factory; } const RenderingManagerFactory * RenderingManager ::GetFactory() { return s_RenderingManagerFactory; } bool RenderingManager ::HasFactory() { if ( RenderingManager::s_RenderingManagerFactory ) { return true; } else { return false; } } RenderingManager::Pointer RenderingManager ::New() { const RenderingManagerFactory* factory = GetFactory(); if(factory == NULL) return NULL; return factory->CreateRenderingManager(); } RenderingManager * RenderingManager ::GetInstance() { if ( !RenderingManager::s_Instance ) { if ( s_RenderingManagerFactory ) { s_Instance = s_RenderingManagerFactory->CreateRenderingManager(); } } return s_Instance; } bool RenderingManager ::IsInstantiated() { if ( RenderingManager::s_Instance ) return true; else return false; } void RenderingManager ::AddRenderWindow( vtkRenderWindow *renderWindow ) { if ( renderWindow && (m_RenderWindowList.find( renderWindow ) == m_RenderWindowList.end()) ) { m_RenderWindowList[renderWindow] = RENDERING_INACTIVE; m_AllRenderWindows.push_back( renderWindow ); if ( m_DataStorage.IsNotNull() ) mitk::BaseRenderer::GetInstance( renderWindow )->SetDataStorage( m_DataStorage.GetPointer() ); // Register vtkRenderWindow instance renderWindow->Register( NULL ); typedef itk::MemberCommand< RenderingManager > MemberCommandType; // Add callbacks for rendering abort mechanism //BaseRenderer *renderer = BaseRenderer::GetInstance( renderWindow ); vtkCallbackCommand *startCallbackCommand = vtkCallbackCommand::New(); startCallbackCommand->SetCallback( RenderingManager::RenderingStartCallback ); renderWindow->AddObserver( vtkCommand::StartEvent, startCallbackCommand ); vtkCallbackCommand *progressCallbackCommand = vtkCallbackCommand::New(); progressCallbackCommand->SetCallback( RenderingManager::RenderingProgressCallback ); renderWindow->AddObserver( vtkCommand::AbortCheckEvent, progressCallbackCommand ); vtkCallbackCommand *endCallbackCommand = vtkCallbackCommand::New(); endCallbackCommand->SetCallback( RenderingManager::RenderingEndCallback ); renderWindow->AddObserver( vtkCommand::EndEvent, endCallbackCommand ); RenderWindowCallbacks callbacks; callbacks.commands[0u] = startCallbackCommand; callbacks.commands[1u] = progressCallbackCommand; callbacks.commands[2u] = endCallbackCommand; this->m_RenderWindowCallbacksList[renderWindow] = callbacks; //Delete vtk variables correctly startCallbackCommand->Delete(); progressCallbackCommand->Delete(); endCallbackCommand->Delete(); } } void RenderingManager ::RemoveRenderWindow( vtkRenderWindow *renderWindow ) { if (m_RenderWindowList.erase( renderWindow )) { RenderWindowCallbacksList::iterator callbacks_it = this->m_RenderWindowCallbacksList.find(renderWindow); renderWindow->RemoveObserver(callbacks_it->second.commands[0u]); renderWindow->RemoveObserver(callbacks_it->second.commands[1u]); renderWindow->RemoveObserver(callbacks_it->second.commands[2u]); this->m_RenderWindowCallbacksList.erase(callbacks_it); RenderWindowVector::iterator rw_it = std::find( m_AllRenderWindows.begin(), m_AllRenderWindows.end(), renderWindow ); // Decrease reference count for proper destruction (*rw_it)->UnRegister(NULL); m_AllRenderWindows.erase( rw_it ); } } const RenderingManager::RenderWindowVector& RenderingManager ::GetAllRegisteredRenderWindows() { return m_AllRenderWindows; } void RenderingManager ::RequestUpdate( vtkRenderWindow *renderWindow ) { + + // do nothing if the renderWindow is not managed by this instance + RenderWindowVector::iterator iter = std::find( m_AllRenderWindows.begin(), m_AllRenderWindows.end(), renderWindow ); + if ( iter == m_AllRenderWindows.end() ) + { + MITK_ERROR << "Update requested for vtkRenderWindow that has not been registered in this instance of mitkRenderingManager"; + return; + } + m_RenderWindowList[renderWindow] = RENDERING_REQUESTED; if ( !m_UpdatePending ) { m_UpdatePending = true; this->GenerateRenderingRequestEvent(); } } void RenderingManager ::ForceImmediateUpdate( vtkRenderWindow *renderWindow ) { // Erase potentially pending requests for this window m_RenderWindowList[renderWindow] = RENDERING_INACTIVE; m_UpdatePending = false; // Immediately repaint this window (implementation platform specific) // If the size is 0 it crahses int *size = renderWindow->GetSize(); if ( 0 != size[0] && 0 != size[1] ) { //prepare the camera etc. before rendering //Note: this is a very important step which should be called before the VTK render! //If you modify the camera anywhere else or after the render call, the scene cannot be seen. mitk::VtkPropRenderer *vPR = dynamic_cast(mitk::BaseRenderer::GetInstance( renderWindow )); if(vPR) vPR->PrepareRender(); // Execute rendering renderWindow->Render(); } } void RenderingManager ::RequestUpdateAll( RequestType type ) { RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { int id = BaseRenderer::GetInstance(it->first)->GetMapperID(); if ( (type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) || ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2)) ) { this->RequestUpdate( it->first ); } } } void RenderingManager ::ForceImmediateUpdateAll( RequestType type ) { RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { int id = BaseRenderer::GetInstance(it->first)->GetMapperID(); if ( (type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) || ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2)) ) { // Immediately repaint this window (implementation platform specific) // If the size is 0, it crashes this->ForceImmediateUpdate(it->first); // int *size = it->first->GetSize(); // if ( 0 != size[0] && 0 != size[1] ) // { // //prepare the camera before rendering // //Note: this is a very important step which should be called before the VTK render! // //If you modify the camera anywhere else or after the render call, the scene cannot be seen. // mitk::VtkPropRenderer *vPR = // dynamic_cast(mitk::BaseRenderer::GetInstance( it->first )); // if(vPR) // vPR->PrepareRender(); // // Execute rendering // it->first->Render(); // } // it->second = RENDERING_INACTIVE; } } //m_UpdatePending = false; } //bool RenderingManager::InitializeViews( const mitk::DataStorage * storage, const DataNode* node = NULL, RequestType type, bool preserveRoughOrientationInWorldSpace ) //{ // mitk::Geometry3D::Pointer geometry; // if ( storage != NULL ) // { // geometry = storage->ComputeVisibleBoundingGeometry3D(node, "visible", NULL, "includeInBoundingBox" ); // // if ( geometry.IsNotNull() ) // { // // let's see if we have data with a limited live-span ... // mitk::TimeBounds timebounds = geometry->GetTimeBounds(); // if ( timebounds[1] < mitk::ScalarTypeNumericTraits::max() ) // { // mitk::ScalarType duration = timebounds[1]-timebounds[0]; // // mitk::TimeSlicedGeometry::Pointer timegeometry = // mitk::TimeSlicedGeometry::New(); // timegeometry->InitializeEvenlyTimed( // geometry, (unsigned int) duration ); // timegeometry->SetTimeBounds( timebounds ); // // timebounds[1] = timebounds[0] + 1.0; // geometry->SetTimeBounds( timebounds ); // // geometry = timegeometry; // } // } // } // // // Use geometry for initialization // return this->InitializeViews( geometry.GetPointer(), type ); //} bool RenderingManager ::InitializeViews( const Geometry3D * dataGeometry, RequestType type, bool preserveRoughOrientationInWorldSpace ) { MITK_DEBUG << "initializing views"; bool boundingBoxInitialized = false; Geometry3D::ConstPointer geometry = dataGeometry; if (dataGeometry && preserveRoughOrientationInWorldSpace) { // clone the input geometry Geometry3D::Pointer modifiedGeometry = dynamic_cast( dataGeometry->Clone().GetPointer() ); assert(modifiedGeometry.IsNotNull()); // construct an affine transform from it AffineGeometryFrame3D::TransformType::Pointer transform = AffineGeometryFrame3D::TransformType::New(); assert( modifiedGeometry->GetIndexToWorldTransform() ); transform->SetMatrix( modifiedGeometry->GetIndexToWorldTransform()->GetMatrix() ); transform->SetOffset( modifiedGeometry->GetIndexToWorldTransform()->GetOffset() ); // get transform matrix AffineGeometryFrame3D::TransformType::MatrixType::InternalMatrixType& oldMatrix = const_cast< AffineGeometryFrame3D::TransformType::MatrixType::InternalMatrixType& > ( transform->GetMatrix().GetVnlMatrix() ); AffineGeometryFrame3D::TransformType::MatrixType::InternalMatrixType newMatrix(oldMatrix); // get offset and bound Vector3D offset = modifiedGeometry->GetIndexToWorldTransform()->GetOffset(); Geometry3D::BoundsArrayType oldBounds = modifiedGeometry->GetBounds(); Geometry3D::BoundsArrayType newBounds = modifiedGeometry->GetBounds(); // get rid of rotation other than pi/2 degree for ( unsigned int i = 0; i < 3; ++i ) { // i-th column of the direction matrix Vector3D currentVector; currentVector[0] = oldMatrix(0,i); currentVector[1] = oldMatrix(1,i); currentVector[2] = oldMatrix(2,i); // matchingRow will store the row that holds the biggest // value in the column unsigned int matchingRow = 0; // maximum value in the column float max = std::numeric_limits::min(); // sign of the maximum value (-1 or 1) int sign = 1; // iterate through the column vector for (unsigned int dim = 0; dim < 3; ++dim) { if ( fabs(currentVector[dim]) > max ) { matchingRow = dim; max = fabs(currentVector[dim]); if(currentVector[dim]<0) sign = -1; else sign = 1; } } // in case we found a negative maximum, // we negate the column and adjust the offset // (in order to run through the dimension in the opposite direction) if(sign == -1) { currentVector *= sign; offset += modifiedGeometry->GetAxisVector(i); } // matchingRow is now used as column index to place currentVector // correctly in the new matrix vnl_vector newMatrixColumn(3); newMatrixColumn[0] = currentVector[0]; newMatrixColumn[1] = currentVector[1]; newMatrixColumn[2] = currentVector[2]; newMatrix.set_column( matchingRow, newMatrixColumn ); // if a column is moved, we also have to adjust the bounding // box accordingly, this is done here newBounds[2*matchingRow ] = oldBounds[2*i ]; newBounds[2*matchingRow+1] = oldBounds[2*i+1]; } // set the newly calculated bounds array modifiedGeometry->SetBounds(newBounds); // set new offset and direction matrix AffineGeometryFrame3D::TransformType::MatrixType newMatrixITK( newMatrix ); transform->SetMatrix( newMatrixITK ); transform->SetOffset( offset ); modifiedGeometry->SetIndexToWorldTransform( transform ); geometry = modifiedGeometry; } int warningLevel = vtkObject::GetGlobalWarningDisplay(); vtkObject::GlobalWarningDisplayOff(); if ( (geometry.IsNotNull() ) && (const_cast< mitk::BoundingBox * >( geometry->GetBoundingBox())->GetDiagonalLength2() > mitk::eps) ) { boundingBoxInitialized = true; } if (geometry.IsNotNull() ) {// make sure bounding box has an extent bigger than zero in any direction // clone the input geometry Geometry3D::Pointer modifiedGeometry = dynamic_cast( dataGeometry->Clone().GetPointer() ); assert(modifiedGeometry.IsNotNull()); Geometry3D::BoundsArrayType newBounds = modifiedGeometry->GetBounds(); for( unsigned int dimension = 0; ( 2 * dimension ) < newBounds.Size() ; dimension++ ) { //check for equality but for an epsilon if( Equal( newBounds[ 2 * dimension ], newBounds[ 2 * dimension + 1 ] ) ) { newBounds[ 2 * dimension + 1 ] += 1; } } // set the newly calculated bounds array modifiedGeometry->SetBounds(newBounds); geometry = modifiedGeometry; } RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance( it->first ); baseRenderer->GetDisplayGeometry()->SetConstrainZoomingAndPanning(m_ConstrainedPaddingZooming); int id = baseRenderer->GetMapperID(); if ( ((type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) || ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2))) ) { this->InternalViewInitialization( baseRenderer, geometry, boundingBoxInitialized, id ); } } if ( m_TimeNavigationController != NULL ) { if ( boundingBoxInitialized ) { m_TimeNavigationController->SetInputWorldGeometry( geometry ); } m_TimeNavigationController->Update(); } this->RequestUpdateAll( type ); vtkObject::SetGlobalWarningDisplay( warningLevel ); // Inform listeners that views have been initialized this->InvokeEvent( mitk::RenderingManagerViewsInitializedEvent() ); return boundingBoxInitialized; } bool RenderingManager ::InitializeViews( RequestType type ) { RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance( it->first ); int id = baseRenderer->GetMapperID(); if ( (type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) || ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2)) ) { mitk::SliceNavigationController *nc = baseRenderer->GetSliceNavigationController(); // Re-initialize view direction nc->SetViewDirectionToDefault(); // Update the SNC nc->Update(); } } this->RequestUpdateAll( type ); return true; } //bool RenderingManager::InitializeView( vtkRenderWindow * renderWindow, const DataStorage* ds, const DataNode node = NULL, bool initializeGlobalTimeSNC ) //{ // mitk::Geometry3D::Pointer geometry; // if ( ds != NULL ) // { // geometry = ds->ComputeVisibleBoundingGeometry3D(node, NULL, "includeInBoundingBox" ); // // if ( geometry.IsNotNull() ) // { // // let's see if we have data with a limited live-span ... // mitk::TimeBounds timebounds = geometry->GetTimeBounds(); // if ( timebounds[1] < mitk::ScalarTypeNumericTraits::max() ) // { // mitk::ScalarType duration = timebounds[1]-timebounds[0]; // // mitk::TimeSlicedGeometry::Pointer timegeometry = // mitk::TimeSlicedGeometry::New(); // timegeometry->InitializeEvenlyTimed( // geometry, (unsigned int) duration ); // timegeometry->SetTimeBounds( timebounds ); // // timebounds[1] = timebounds[0] + 1.0; // geometry->SetTimeBounds( timebounds ); // // geometry = timegeometry; // } // } // } // // // Use geometry for initialization // return this->InitializeView( renderWindow, // geometry.GetPointer(), initializeGlobalTimeSNC ); //} bool RenderingManager::InitializeView( vtkRenderWindow * renderWindow, const Geometry3D * geometry, bool initializeGlobalTimeSNC ) { bool boundingBoxInitialized = false; int warningLevel = vtkObject::GetGlobalWarningDisplay(); vtkObject::GlobalWarningDisplayOff(); if ( (geometry != NULL ) && (const_cast< mitk::BoundingBox * >( geometry->GetBoundingBox())->GetDiagonalLength2() > mitk::eps) ) { boundingBoxInitialized = true; } mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance( renderWindow ); int id = baseRenderer->GetMapperID(); this->InternalViewInitialization( baseRenderer, geometry, boundingBoxInitialized, id ); if ( m_TimeNavigationController != NULL ) { if ( boundingBoxInitialized && initializeGlobalTimeSNC ) { m_TimeNavigationController->SetInputWorldGeometry( geometry ); } m_TimeNavigationController->Update(); } this->RequestUpdate( renderWindow ); vtkObject::SetGlobalWarningDisplay( warningLevel ); return boundingBoxInitialized; } bool RenderingManager::InitializeView( vtkRenderWindow * renderWindow ) { mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance( renderWindow ); mitk::SliceNavigationController *nc = baseRenderer->GetSliceNavigationController(); // Re-initialize view direction nc->SetViewDirectionToDefault(); // Update the SNC nc->Update(); this->RequestUpdate( renderWindow ); return true; } void RenderingManager::InternalViewInitialization(mitk::BaseRenderer *baseRenderer, const mitk::Geometry3D *geometry, bool boundingBoxInitialized, int mapperID ) { mitk::SliceNavigationController *nc = baseRenderer->GetSliceNavigationController(); // Re-initialize view direction nc->SetViewDirectionToDefault(); if ( boundingBoxInitialized ) { // Set geometry for NC nc->SetInputWorldGeometry( geometry ); nc->Update(); if ( mapperID == 1 ) { // For 2D SNCs, steppers are set so that the cross is centered // in the image nc->GetSlice()->SetPos( nc->GetSlice()->GetSteps() / 2 ); } // Fit the render window DisplayGeometry baseRenderer->GetDisplayGeometry()->Fit(); baseRenderer->GetCameraController()->SetViewToAnterior(); } else { nc->Update(); } } void RenderingManager::SetTimeNavigationController( SliceNavigationController *nc ) { m_TimeNavigationController = nc; } const SliceNavigationController* RenderingManager::GetTimeNavigationController() const { return m_TimeNavigationController; } SliceNavigationController* RenderingManager::GetTimeNavigationController() { return m_TimeNavigationController; } void RenderingManager::ExecutePendingRequests() { m_UpdatePending = false; // Satisfy all pending update requests RenderWindowList::iterator it; int i = 0; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it, ++i ) { if ( it->second == RENDERING_REQUESTED ) { this->ForceImmediateUpdate( it->first ); } } } void RenderingManager::RenderingStartCallback( vtkObject *caller, unsigned long , void *, void * ) { vtkRenderWindow *renderWindow = dynamic_cast< vtkRenderWindow * >( caller ); mitk::RenderingManager* renman = mitk::BaseRenderer::GetInstance(renderWindow)->GetRenderingManager(); RenderWindowList &renderWindowList = renman->m_RenderWindowList; if ( renderWindow ) { renderWindowList[renderWindow] = RENDERING_INPROGRESS; } renman->m_UpdatePending = false; } void RenderingManager ::RenderingProgressCallback( vtkObject *caller, unsigned long , void *, void * ) { vtkRenderWindow *renderWindow = dynamic_cast< vtkRenderWindow * >( caller ); mitk::RenderingManager* renman = mitk::BaseRenderer::GetInstance(renderWindow)->GetRenderingManager(); if ( renman->m_LODAbortMechanismEnabled ) { vtkRenderWindow *renderWindow = dynamic_cast< vtkRenderWindow * >( caller ); if ( renderWindow ) { BaseRenderer *renderer = BaseRenderer::GetInstance( renderWindow ); if ( renderer && (renderer->GetNumberOfVisibleLODEnabledMappers() > 0) ) { renman->DoMonitorRendering(); } } } } void RenderingManager ::RenderingEndCallback( vtkObject *caller, unsigned long , void *, void * ) { vtkRenderWindow *renderWindow = dynamic_cast< vtkRenderWindow * >( caller ); mitk::RenderingManager* renman = mitk::BaseRenderer::GetInstance(renderWindow)->GetRenderingManager(); RenderWindowList &renderWindowList = renman->m_RenderWindowList; RendererIntMap &nextLODMap = renman->m_NextLODMap; if ( renderWindow ) { BaseRenderer *renderer = BaseRenderer::GetInstance( renderWindow ); if ( renderer ) { renderWindowList[renderer->GetRenderWindow()] = RENDERING_INACTIVE; // Level-of-Detail handling if ( renderer->GetNumberOfVisibleLODEnabledMappers() > 0 ) { if(nextLODMap[renderer]==0) renman->StartOrResetTimer(); else nextLODMap[renderer] = 0; } } } } bool RenderingManager ::IsRendering() const { RenderWindowList::const_iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { if ( it->second == RENDERING_INPROGRESS ) { return true; } } return false; } void RenderingManager ::AbortRendering() { RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { if ( it->second == RENDERING_INPROGRESS ) { it->first->SetAbortRender( true ); m_RenderingAbortedMap[BaseRenderer::GetInstance(it->first)] = true; } } } int RenderingManager ::GetNextLOD( BaseRenderer *renderer ) { if ( renderer != NULL ) { return m_NextLODMap[renderer]; } else { return 0; } } void RenderingManager ::ExecutePendingHighResRenderingRequest() { RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { BaseRenderer *renderer = BaseRenderer::GetInstance( it->first ); if(renderer->GetNumberOfVisibleLODEnabledMappers()>0) { if(m_NextLODMap[renderer]==0) { m_NextLODMap[renderer]=1; RequestUpdate( it->first ); } } } } void RenderingManager ::SetMaximumLOD( unsigned int max ) { m_MaxLOD = max; } //enable/disable shading void RenderingManager ::SetShading(bool state, unsigned int lod) { if(lod>m_MaxLOD) { itkWarningMacro(<<"LOD out of range requested: " << lod << " maxLOD: " << m_MaxLOD); return; } m_ShadingEnabled[lod] = state; } bool RenderingManager ::GetShading(unsigned int lod) { if(lod>m_MaxLOD) { itkWarningMacro(<<"LOD out of range requested: " << lod << " maxLOD: " << m_MaxLOD); return false; } return m_ShadingEnabled[lod]; } //enable/disable the clipping plane void RenderingManager ::SetClippingPlaneStatus(bool status) { m_ClippingPlaneEnabled = status; } bool RenderingManager ::GetClippingPlaneStatus() { return m_ClippingPlaneEnabled; } void RenderingManager ::SetShadingValues(float ambient, float diffuse, float specular, float specpower) { m_ShadingValues[0] = ambient; m_ShadingValues[1] = diffuse; m_ShadingValues[2] = specular; m_ShadingValues[3] = specpower; } RenderingManager::FloatVector & RenderingManager ::GetShadingValues() { return m_ShadingValues; } void RenderingManager::SetDepthPeelingEnabled( bool enabled ) { RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance( it->first ); baseRenderer->SetDepthPeelingEnabled(enabled); } } void RenderingManager::SetMaxNumberOfPeels( int maxNumber ) { RenderWindowList::iterator it; for ( it = m_RenderWindowList.begin(); it != m_RenderWindowList.end(); ++it ) { mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance( it->first ); baseRenderer->SetMaxNumberOfPeels(maxNumber); } } void RenderingManager::InitializePropertyList() { if (m_PropertyList.IsNull()) { m_PropertyList = PropertyList::New(); } this->SetProperty("coupled-zoom", BoolProperty::New(false)); this->SetProperty("coupled-plane-rotation", BoolProperty::New(false)); this->SetProperty("MIP-slice-rendering", BoolProperty::New(false)); } PropertyList::Pointer RenderingManager::GetPropertyList() const { return m_PropertyList; } BaseProperty* RenderingManager::GetProperty(const char *propertyKey) const { return m_PropertyList->GetProperty(propertyKey); } void RenderingManager::SetProperty(const char *propertyKey, BaseProperty* propertyValue) { m_PropertyList->SetProperty(propertyKey, propertyValue); } void RenderingManager::SetDataStorage( DataStorage* storage ) { if ( storage != NULL ) { m_DataStorage = storage; RenderingManager::RenderWindowVector::iterator iter; for ( iter = m_AllRenderWindows.begin(); iterSetDataStorage( m_DataStorage.GetPointer() ); } } } mitk::DataStorage* RenderingManager::GetDataStorage() { return m_DataStorage; } void RenderingManager::SetGlobalInteraction( mitk::GlobalInteraction* globalInteraction ) { if ( globalInteraction != NULL ) { m_GlobalInteraction = globalInteraction; } } mitk::GlobalInteraction* RenderingManager::GetGlobalInteraction() { return m_GlobalInteraction; } // Create and register generic RenderingManagerFactory. TestingRenderingManagerFactory renderingManagerFactory; } // namespace diff --git a/Core/Code/Controllers/mitkRenderingManager.h b/Core/Code/Controllers/mitkRenderingManager.h index 0666a7a11e..53b5489a9a 100644 --- a/Core/Code/Controllers/mitkRenderingManager.h +++ b/Core/Code/Controllers/mitkRenderingManager.h @@ -1,419 +1,419 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197 #define MITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197 #include #include #include #include #include #include "mitkPropertyList.h" #include "mitkProperties.h" class vtkRenderWindow; class vtkObject; namespace mitk { class RenderingManager; class RenderingManagerFactory; class Geometry3D; class SliceNavigationController; class BaseRenderer; class DataStorage; class GlobalInteraction; /** * \brief Manager for coordinating the rendering process. * * RenderingManager is a central instance retrieving and executing * RenderWindow update requests. Its main purpose is to coordinate * distributed requests which cannot be aware of each other - lacking the * knowledge of whether they are really necessary or not. For example, two * objects might determine that a specific RenderWindow needs to be updated. * This would result in one unnecessary update, if both executed the update * on their own. * * The RenderingManager addresses this by letting each such object * request an update, and waiting for other objects to possibly * issue the same request. The actual update will then only be executed at a * well-defined point in the main event loop (this may be each time after * event processing is done). * * Convinience methods for updating all RenderWindows which have been * registered with the RenderingManager exist. If theses methods are not * used, it is not required to register (add) RenderWindows prior to using * the RenderingManager. * * The methods #ForceImmediateUpdate() and #ForceImmediateUpdateAll() can * be used to force the RenderWindow update execution without any delay, * bypassing the request functionality. * * The interface of RenderingManager is platform independent. Platform * specific subclasses have to be implemented, though, to supply an * appropriate event issueing for controlling the update execution process. * See method documentation for a description of how this can be done. * * \sa TestingRenderingManager An "empty" RenderingManager implementation which * can be used in tests etc. * */ class MITK_CORE_EXPORT RenderingManager : public itk::Object { public: mitkClassMacro(RenderingManager,itk::Object); typedef std::vector< vtkRenderWindow* > RenderWindowVector; typedef std::vector< float > FloatVector; typedef std::vector< bool > BoolVector; typedef itk::SmartPointer< DataStorage > DataStoragePointer; typedef itk::SmartPointer< GlobalInteraction > GlobalInteractionPointer; enum RequestType { REQUEST_UPDATE_ALL = 0, REQUEST_UPDATE_2DWINDOWS, REQUEST_UPDATE_3DWINDOWS }; static Pointer New(); /** Set the object factory which produces the desired platform specific * RenderingManager singleton instance. */ static void SetFactory( RenderingManagerFactory *factory ); /** Get the object factory which produces the platform specific * RenderingManager instances. */ static const RenderingManagerFactory *GetFactory(); /** Returns true if a factory has already been set. */ static bool HasFactory(); /** Get the RenderingManager singleton instance. */ static RenderingManager *GetInstance(); /** Returns true if the singleton instance does already exist. */ static bool IsInstantiated(); /** Adds a RenderWindow. This is required if the methods #RequestUpdateAll * or #ForceImmediateUpdate are to be used. */ void AddRenderWindow( vtkRenderWindow *renderWindow ); /** Removes a RenderWindow. */ void RemoveRenderWindow( vtkRenderWindow *renderWindow ); /** Get a list of all registered RenderWindows */ const RenderWindowVector &GetAllRegisteredRenderWindows(); /** Requests an update for the specified RenderWindow, to be executed as * soon as the main loop is ready for rendering. */ void RequestUpdate( vtkRenderWindow *renderWindow ); /** Immediately executes an update of the specified RenderWindow. */ void ForceImmediateUpdate( vtkRenderWindow *renderWindow ); /** Requests all currently registered RenderWindows to be updated. * If only 2D or 3D windows should be updated, this can be specified * via the parameter requestType. */ void RequestUpdateAll( RequestType type = REQUEST_UPDATE_ALL ); /** Immediately executes an update of all registered RenderWindows. * If only 2D or 3D windows should be updated, this can be specified * via the parameter requestType. */ void ForceImmediateUpdateAll( RequestType type = REQUEST_UPDATE_ALL ); /** Initializes the windows specified by requestType to the geometry of the * given DataStorage. */ //virtual bool InitializeViews( const DataStorage *storage, const DataNode* node = NULL, // RequestType type = REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace = false ); /** Initializes the windows specified by requestType to the given * geometry. PLATFORM SPECIFIC. TODO: HOW IS THIS PLATFORM SPECIFIC? */ virtual bool InitializeViews( const Geometry3D *geometry, RequestType type = REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace = false ); /** Initializes the windows to the default viewing direction * (geomtry information is NOT changed). PLATFORM SPECIFIC. */ virtual bool InitializeViews( RequestType type = REQUEST_UPDATE_ALL ); /** Initializes the specified window to the geometry of the given * DataNode. Set "initializeGlobalTimeSNC" to true in order to use this * geometry as global TimeSlicedGeometry. PLATFORM SPECIFIC. */ //virtual bool InitializeView( vtkRenderWindow *renderWindow, const DataStorage* ds, const DataNode* node = NULL, bool initializeGlobalTimeSNC = false ); /** Initializes the specified window to the given geometry. Set * "initializeGlobalTimeSNC" to true in order to use this geometry as * global TimeSlicedGeometry. PLATFORM SPECIFIC. */ virtual bool InitializeView( vtkRenderWindow *renderWindow, const Geometry3D *geometry, bool initializeGlobalTimeSNC = false); /** Initializes the specified window to the default viewing direction * (geomtry information is NOT changed). PLATFORM SPECIFIC. */ virtual bool InitializeView( vtkRenderWindow *renderWindow ); /** Sets the (global) SliceNavigationController responsible for * time-slicing. */ void SetTimeNavigationController( SliceNavigationController *nc ); /** Gets the (global) SliceNavigationController responsible for * time-slicing. */ const SliceNavigationController *GetTimeNavigationController() const; /** Gets the (global) SliceNavigationController responsible for * time-slicing. */ SliceNavigationController *GetTimeNavigationController(); virtual ~RenderingManager(); /** Executes all pending requests. This method has to be called by the * system whenever a RenderingManager induced request event occurs in * the system pipeline (see concrete RenderingManager implementations). */ virtual void ExecutePendingRequests(); bool IsRendering() const; void AbortRendering(); /** En-/Disable LOD increase globally. */ itkSetMacro( LODIncreaseBlocked, bool ); /** En-/Disable LOD increase globally. */ itkGetMacro( LODIncreaseBlocked, bool ); /** En-/Disable LOD increase globally. */ itkBooleanMacro( LODIncreaseBlocked ); /** En-/Disable LOD abort mechanism. */ itkSetMacro( LODAbortMechanismEnabled, bool ); /** En-/Disable LOD abort mechanism. */ itkGetMacro( LODAbortMechanismEnabled, bool ); /** En-/Disable LOD abort mechanism. */ itkBooleanMacro( LODAbortMechanismEnabled ); /** En-/Disable depth peeling for all renderers */ void SetDepthPeelingEnabled(bool enabled); /** Set maximum number of peels for all renderers */ void SetMaxNumberOfPeels(int maxNumber); /** Force a sub-class to start a timer for a pending hires-rendering request */ virtual void StartOrResetTimer() {}; /** To be called by a sub-class from a timer callback */ void ExecutePendingHighResRenderingRequest(); virtual void DoStartRendering() {}; virtual void DoMonitorRendering() {}; virtual void DoFinishAbortRendering() {}; int GetNextLOD( BaseRenderer* renderer ); /** Set current LOD (NULL means all renderers)*/ void SetMaximumLOD( unsigned int max ); void SetShading( bool state, unsigned int lod ); bool GetShading( unsigned int lod ); void SetClippingPlaneStatus( bool status ); bool GetClippingPlaneStatus(); void SetShadingValues( float ambient, float diffuse, float specular, float specpower ); FloatVector &GetShadingValues(); /** Returns a property list */ PropertyList::Pointer GetPropertyList() const; - /** returns a property from m_PropertyList */ + /** Returns a property from m_PropertyList */ BaseProperty* GetProperty(const char *propertyKey) const; - /** retu"Use flexible zooming and padding"rns sets or adds (if not present) a property in m_PropertyList */ + /** Sets or adds (if not present) a property in m_PropertyList */ void SetProperty(const char *propertyKey, BaseProperty* propertyValue); /** * \brief Setter / Getter for internal DataStorage * * Sets / returns the mitk::DataStorage that is used internally. This instance holds all mitk::DataNodes that are * rendered by the registered BaseRenderers. * * If this DataStorage is changed at runtime by calling SetDataStorage(), * all currently registered BaseRenderers are automatically given the correct instance. * When a new BaseRenderer is added, it is automatically initialized with the currently active DataStorage. */ void SetDataStorage( mitk::DataStorage* storage ); /** * \brief Setter / Getter for internal DataStorage * * Sets / returns the mitk::DataStorage that is used internally. This instance holds all mitk::DataNodes that are * rendered by the registered BaseRenderers. * * If this DataStorage is changed at runtime by calling SetDataStorage(), * all currently registered BaseRenderers are automatically given the correct instance. * When a new BaseRenderer is added, it is automatically initialized with the currently active DataStorage. */ mitk::DataStorage* GetDataStorage(); /** * \brief Setter / Getter for internal GloabInteraction * * Sets / returns the instance of mitk::GlobalInteraction that is internally held. * It'S not actually used by this class but offers it to all registered BaseRenderers. * These need it for their own internal initialization of the FocusManager and the corresponding EventMappers. */ void SetGlobalInteraction( mitk::GlobalInteraction* globalInteraction ); /** * \brief Setter / Getter for internal GloabInteraction * * Sets / returns the instance of mitk::GlobalInteraction that is internally held. * It'S not actually used by this class but offers it to all registered BaseRenderers. * These need it for their own internal initialization of the FocusManager and the corresponding EventMappers. */ mitk::GlobalInteraction* GetGlobalInteraction(); itkSetMacro(ConstrainedPaddingZooming, bool); protected: enum { RENDERING_INACTIVE = 0, RENDERING_REQUESTED, RENDERING_INPROGRESS }; RenderingManager(); /** Abstract method for generating a system specific event for rendering * request. This method is called whenever an update is requested */ virtual void GenerateRenderingRequestEvent() = 0; virtual void InitializePropertyList(); bool m_UpdatePending; typedef std::map< BaseRenderer *, unsigned int > RendererIntMap; typedef std::map< BaseRenderer *, bool > RendererBoolMap; RendererBoolMap m_RenderingAbortedMap; RendererIntMap m_NextLODMap; unsigned int m_MaxLOD; bool m_LODIncreaseBlocked; bool m_LODAbortMechanismEnabled; BoolVector m_ShadingEnabled; bool m_ClippingPlaneEnabled; FloatVector m_ShadingValues; static void RenderingStartCallback( vtkObject *caller, unsigned long eid, void *clientdata, void *calldata ); static void RenderingProgressCallback( vtkObject *caller, unsigned long eid, void *clientdata, void *calldata ); static void RenderingEndCallback( vtkObject *caller, unsigned long eid, void *clientdata, void *calldata ); typedef std::map< vtkRenderWindow *, int > RenderWindowList; RenderWindowList m_RenderWindowList; RenderWindowVector m_AllRenderWindows; struct RenderWindowCallbacks { vtkCallbackCommand* commands[3u]; }; typedef std::map RenderWindowCallbacksList; RenderWindowCallbacksList m_RenderWindowCallbacksList; SliceNavigationController *m_TimeNavigationController; static RenderingManager::Pointer s_Instance; static RenderingManagerFactory *s_RenderingManagerFactory; PropertyList::Pointer m_PropertyList; DataStoragePointer m_DataStorage; GlobalInteractionPointer m_GlobalInteraction; bool m_ConstrainedPaddingZooming; private: void InternalViewInitialization( mitk::BaseRenderer *baseRenderer, const mitk::Geometry3D *geometry, bool boundingBoxInitialized, int mapperID ); }; #pragma GCC visibility push(default) itkEventMacro( RenderingManagerEvent, itk::AnyEvent ); itkEventMacro( RenderingManagerViewsInitializedEvent, RenderingManagerEvent ); #pragma GCC visibility pop /** * Generic RenderingManager implementation for "non-rendering-plattform", * e.g. for tests. Its factory (TestingRenderingManagerFactory) is * automatically on start-up and is used by default if not other * RenderingManagerFactory is instantiated explicitly thereafter. * (see mitkRenderingManager.cpp) */ class MITK_CORE_EXPORT TestingRenderingManager : public RenderingManager { public: mitkClassMacro(TestingRenderingManager,RenderingManager); itkNewMacro(Self); protected: virtual void GenerateRenderingRequestEvent() { }; }; } // namespace mitk #endif /* MITKRenderingManager_H_HEADER_INCLUDED_C135A197 */ diff --git a/Core/Code/Controllers/mitkSlicesRotator.cpp b/Core/Code/Controllers/mitkSlicesRotator.cpp index a6fa1ab274..34221fbf43 100644 --- a/Core/Code/Controllers/mitkSlicesRotator.cpp +++ b/Core/Code/Controllers/mitkSlicesRotator.cpp @@ -1,582 +1,582 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "rotate_cursor.xpm" namespace mitk { SlicesRotator::Pointer SlicesRotator::New() { return SlicesRotator::New("slices-rotator"); } SlicesRotator::SlicesRotator(const char* machine) : SlicesCoordinator(machine) { } SlicesRotator::~SlicesRotator() { } // check if the slices of this SliceNavigationController can be rotated (???) Possible void SlicesRotator::OnSliceControllerAdded(SliceNavigationController* snc) { if (!snc) return; snc->ConnectGeometrySendEvent(this); // connects creation of new world geometry to Self::SetGeometry } void SlicesRotator::OnSliceControllerRemoved(SliceNavigationController* snc) { if (!snc) return; // nothing to do } /// Is called whenever a SliceNavigationController invokes an event. Will update the list /// of SliceNavigationControllers that can handle rotation void SlicesRotator::SetGeometry(const itk::EventObject& /*EventObject*/) { // there is no way to determine the sender? // ==> update whole list of SNCs UpdateRelevantSNCs(); } void SlicesRotator::RotateToPoint( SliceNavigationController *rotationPlaneSNC, SliceNavigationController *rotatedPlaneSNC, const Point3D &point, bool linked ) { SliceNavigationController *thirdSNC = NULL; SNCVector::iterator iter; for ( iter = m_RelevantSNCs.begin(); iter != m_RelevantSNCs.end(); ++iter ) { if ( ((*iter) != rotationPlaneSNC) && ((*iter) != rotatedPlaneSNC) ) { thirdSNC = *iter; break; } } if ( thirdSNC == NULL ) { return; } const PlaneGeometry *rotationPlane = rotationPlaneSNC->GetCurrentPlaneGeometry(); const PlaneGeometry *rotatedPlane = rotatedPlaneSNC->GetCurrentPlaneGeometry(); const PlaneGeometry *thirdPlane = thirdSNC->GetCurrentPlaneGeometry(); if ( (rotationPlane == NULL) || (rotatedPlane == NULL) || (thirdPlane == NULL) ) { return; } if ( rotatedPlane->DistanceFromPlane( point ) < 0.001 ) { // Skip irrelevant rotations return; } Point3D projectedPoint; Line3D intersection; Point3D rotationCenter; if ( !rotationPlane->Project( point, projectedPoint ) || !rotationPlane->IntersectionLine( rotatedPlane, intersection ) || !thirdPlane->IntersectionPoint( intersection, rotationCenter ) ) { return; } // All pre-requirements are met; execute the rotation Point3D referencePoint = intersection.Project( projectedPoint ); Vector3D toProjected = referencePoint - rotationCenter; Vector3D toCursor = projectedPoint - rotationCenter; // cross product: | A x B | = |A| * |B| * sin(angle) Vector3D axisOfRotation; vnl_vector_fixed< ScalarType, 3 > vnlDirection = vnl_cross_3d( toCursor.GetVnlVector(), toProjected.GetVnlVector() ); axisOfRotation.SetVnlVector( vnlDirection ); // scalar product: A * B = |A| * |B| * cos(angle) // tan = sin / cos ScalarType angle = - atan2( (double)(axisOfRotation.GetNorm()), (double)(toCursor * toProjected) ); angle *= 180.0 / vnl_math::pi; // create RotationOperation and apply to all SNCs that should be rotated RotationOperation op(OpROTATE, rotationCenter, axisOfRotation, angle); if ( !linked ) { BaseRenderer *renderer = rotatedPlaneSNC->GetRenderer(); if ( renderer == NULL ) { return; } DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); Point2D point2DWorld, point2DDisplayPre, point2DDisplayPost; displayGeometry->Map( rotationCenter, point2DWorld ); displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPre ); const Geometry3D *geometry3D = rotatedPlaneSNC->GetCreatedWorldGeometry(); const TimeSlicedGeometry *timeSlicedGeometry = dynamic_cast( geometry3D ); if ( !timeSlicedGeometry ) { return; } const_cast< TimeSlicedGeometry * >( timeSlicedGeometry )->ExecuteOperation( &op ); displayGeometry->Map( rotationCenter, point2DWorld ); displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPost ); Vector2D vector2DDisplayDiff = point2DDisplayPost - point2DDisplayPre; - Vector2D origin = displayGeometry->GetOriginInMM(); + //Vector2D origin = displayGeometry->GetOriginInMM(); displayGeometry->MoveBy( vector2DDisplayDiff ); rotatedPlaneSNC->SendCreatedWorldGeometryUpdate(); } else { SNCVector::iterator iter; for ( iter = m_RelevantSNCs.begin(); iter != m_RelevantSNCs.end(); ++iter ) { BaseRenderer *renderer = (*iter)->GetRenderer(); if ( renderer == NULL ) { continue; } DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); Point2D point2DWorld, point2DDisplayPre, point2DDisplayPost; displayGeometry->Map( rotationCenter, point2DWorld ); displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPre ); const Geometry3D* geometry3D = (*iter)->GetCreatedWorldGeometry(); const TimeSlicedGeometry *timeSlicedGeometry = dynamic_cast( geometry3D ); if ( !timeSlicedGeometry ) { continue; } const_cast< TimeSlicedGeometry * >( timeSlicedGeometry )->ExecuteOperation( &op ); displayGeometry->Map( rotationCenter, point2DWorld ); displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPost ); Vector2D vector2DDisplayDiff = point2DDisplayPost - point2DDisplayPre; - Vector2D origin = displayGeometry->GetOriginInMM(); + //Vector2D origin = displayGeometry->GetOriginInMM(); displayGeometry->MoveBy( vector2DDisplayDiff ); (*iter)->SendCreatedWorldGeometryUpdate(); } } } /// Updates the list of SliceNavigationControllers that can handle rotation void SlicesRotator::UpdateRelevantSNCs() { m_RelevantSNCs.clear(); for (SNCVector::iterator iter = m_SliceNavigationControllers.begin(); iter != m_SliceNavigationControllers.end(); ++iter) { const Geometry3D* geometry3D = (*iter)->GetCreatedWorldGeometry(); const TimeSlicedGeometry* timeSlicedGeometry = dynamic_cast( geometry3D ); if (!timeSlicedGeometry) continue; const SlicedGeometry3D* slicedGeometry = dynamic_cast( timeSlicedGeometry->GetGeometry3D(0) ); if (!slicedGeometry) continue; Geometry2D* firstSlice(NULL); - Geometry2D* secondSlice(NULL); + //Geometry2D* secondSlice(NULL); if (slicedGeometry->IsValidSlice(0)) firstSlice = slicedGeometry->GetGeometry2D(0); - if (slicedGeometry->IsValidSlice(1)) secondSlice = slicedGeometry->GetGeometry2D(1); + //if (slicedGeometry->IsValidSlice(1)) secondSlice = slicedGeometry->GetGeometry2D(1); // if the direction vector of these two slices is the same, then accept this slice stack as rotatable Vector3D right1 = firstSlice->GetAxisVector(0); Vector3D up1 = firstSlice->GetAxisVector(1); vnl_vector_fixed< ScalarType, 3 > vnlDirection1 = vnl_cross_3d(right1.GetVnlVector(), up1.GetVnlVector()); Vector3D direction1; direction1.SetVnlVector(vnlDirection1); Vector3D right2 = firstSlice->GetAxisVector(0); Vector3D up2 = firstSlice->GetAxisVector(1); vnl_vector_fixed< ScalarType, 3 > vnlDirection2 = vnl_cross_3d(right2.GetVnlVector(), up2.GetVnlVector()); Vector3D direction2; direction2.SetVnlVector(vnlDirection2); bool equal = true; const ScalarType eps = 0.0001; for (int i = 0; i < 3; ++i) if ( fabs(direction1[i] - direction2[i]) > eps ) equal = false; if (equal) // equal direction vectors { m_RelevantSNCs.push_back( *iter ); } } } bool SlicesRotator::ExecuteAction(Action* action, StateEvent const* stateEvent) { const ScalarType ThreshHoldDistancePixels = 12.0; bool ok = false; switch ( action->GetActionId() ) { case AcMOVE: { // just reach through for (SNCVector::iterator iter = m_RelevantSNCs.begin(); iter != m_RelevantSNCs.end(); ++iter) { if ( !(*iter)->GetSliceLocked() ) { (*iter)->ExecuteAction(action, stateEvent); } } ok = true; break; } case AcROTATE: { const DisplayPositionEvent* posEvent = dynamic_cast(stateEvent->GetEvent()); if (!posEvent) break; Point3D cursor = posEvent->GetWorldPosition(); Vector3D toProjected = m_LastCursorPosition - m_CenterOfRotation; Vector3D toCursor = cursor - m_CenterOfRotation; // cross product: | A x B | = |A| * |B| * sin(angle) Vector3D axisOfRotation; vnl_vector_fixed< ScalarType, 3 > vnlDirection = vnl_cross_3d( toCursor.GetVnlVector(), toProjected.GetVnlVector() ); axisOfRotation.SetVnlVector(vnlDirection); // scalar product: A * B = |A| * |B| * cos(angle) // tan = sin / cos ScalarType angle = - atan2( (double)(axisOfRotation.GetNorm()), (double)(toCursor * toProjected) ); angle *= 180.0 / vnl_math::pi; m_LastCursorPosition = cursor; // create RotationOperation and apply to all SNCs that should be rotated RotationOperation op(OpROTATE, m_CenterOfRotation, axisOfRotation, angle); // TEST int i = 0; for (SNCVector::iterator iter = m_SNCsToBeRotated.begin(); iter != m_SNCsToBeRotated.end(); ++iter) { BaseRenderer *renderer = (*iter)->GetRenderer(); if ( renderer == NULL ) { continue; } DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); // MITK_INFO << i << ":" << std::endl; Point2D point2DWorld, point2DDisplayPre, point2DDisplayPost; displayGeometry->Map( m_CenterOfRotation, point2DWorld ); displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPre ); // MITK_INFO << " WorldPre: " << point2DWorld << " / DisplayPre: " << point2DDisplayPre << std::endl; const Geometry3D* geometry3D = (*iter)->GetCreatedWorldGeometry(); const TimeSlicedGeometry* timeSlicedGeometry = dynamic_cast(geometry3D); if (!timeSlicedGeometry) continue; const_cast(timeSlicedGeometry)->ExecuteOperation(&op); //vtkLinearTransform *inverseTransformVtk = // displayGeometry->GetVtkTransform()->GetLinearInverse(); //ScalarType pvtkCenterOfRotation[3]; //pvtkCenterOfRotation[0] = m_CenterOfRotation[0]; //pvtkCenterOfRotation[1] = m_CenterOfRotation[1]; //pvtkCenterOfRotation[2] = m_CenterOfRotation[2]; //ScalarType scaleFactorMMPerUnitX = // displayGeometry->GetExtentInMM(0) / displayGeometry->GetExtent(0); //ScalarType scaleFactorMMPerUnitY = // displayGeometry->GetExtentInMM(1) / displayGeometry->GetExtent(1); //ScalarType scaleFactorMMPerDisplayUnit = displayGeometry->GetScaleFactorMMPerDisplayUnit(); //Vector2D &originInMM = displayGeometry->GetOriginInMM(); ////displayGeometry->Map( m_CenterOfRotation, point2DWorld ); //ScalarType pvtkDisplayPost[3]; //inverseTransformVtk->TransformPoint( pvtkCenterOfRotation, pvtkDisplayPost ); //pvtkDisplayPost[0] *= scaleFactorMMPerUnitX; //pvtkDisplayPost[1] *= scaleFactorMMPerUnitY; ////displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPost ); //pvtkDisplayPost[0] -= originInMM[0]; //pvtkDisplayPost[1] -= originInMM[1]; //pvtkDisplayPost[0] /= scaleFactorMMPerDisplayUnit; //pvtkDisplayPost[1] /= scaleFactorMMPerDisplayUnit; //point2DDisplayPost[0] = pvtkDisplayPost[0]; //point2DDisplayPost[1] = pvtkDisplayPost[1]; displayGeometry->Map( m_CenterOfRotation, point2DWorld ); displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPost ); Vector2D vector2DDisplayDiff = point2DDisplayPost - point2DDisplayPre; - Vector2D origin = displayGeometry->GetOriginInMM(); + //Vector2D origin = displayGeometry->GetOriginInMM(); // MITK_INFO << " WorldPost: " << point2DWorld << " / DisplayPost: " << point2DDisplayPost << std::endl; // MITK_INFO << " Diff - " << vector2DDisplayDiff << std::endl; // MITK_INFO << " Origin - " << origin << std::endl; ++i; displayGeometry->MoveBy( vector2DDisplayDiff ); (*iter)->SendCreatedWorldGeometryUpdate(); } // MITK_INFO << "--------------------------------" << std::endl; // TEST //BaseRenderer* renderer = stateEvent->GetEvent()->GetSender(); // TODO this is NOT SNC-specific! Should be! // //DisplayGeometry* displayGeometry = renderer->GetDisplayGeometry(); //if (!displayGeometry) break; //Point2D point2DWorld, point2DDisplay; //displayGeometry->Map( m_CenterOfRotation, point2DWorld ); //displayGeometry->WorldToDisplay( point2DWorld, point2DDisplay ); //MITK_INFO << "RotationCenter: " << m_CenterOfRotation << std::endl; //MITK_INFO << "PointWorld: " << point2DWorld << std::endl; //MITK_INFO << "PointDisplay: " << point2DDisplay << std::endl; //MITK_INFO << "--------------------------------------------" << std::endl; RenderingManager::GetInstance()->RequestUpdateAll(); this->InvokeEvent( SliceRotationEvent() ); // notify listeners ok = true; break; } case AcCHECKPOINT: { // decide between moving and rotation // Alle SNCs (Anzahl N) nach dem Abstand von posEvent->GetWorldPosition() zur aktuellen Ebene fragen. // Anzahl der Ebenen zaehlen, die naeher als ein gewisser Schwellwertwert sind -> nNah. // Wenn nNah == N // Generiere ein PointEvent und schicke das an alle SNCs -> bewege den kreuz-mittelpunkt // Wenn nNah == 2 // Streiche stateEvent->Sender aus der Liste der nahen Ebenen // fuer die uebrigen generiere eine RotationOperation und fuehre die aus // sonst // const DisplayPositionEvent* posEvent = dynamic_cast(stateEvent->GetEvent()); if (!posEvent) break; Point3D cursor = posEvent->GetWorldPosition(); //m_LastCursorPosition = cursor; unsigned int numNearPlanes = 0; m_SNCsToBeRotated.clear(); Geometry2D* geometryToBeRotated = NULL; // this one is grabbed Geometry2D* otherGeometry = NULL; // this is also visible (for calculation of intersection) Geometry2D* clickedGeometry = NULL; // the event originates from this one - SlicedGeometry3D* clickedSlicedGeometry; + //SlicedGeometry3D* clickedSlicedGeometry; for (SNCVector::iterator iter = m_RelevantSNCs.begin(); iter != m_RelevantSNCs.end(); ++iter) { unsigned int slice = (*iter)->GetSlice()->GetPos(); unsigned int time = (*iter)->GetTime()->GetPos(); const Geometry3D* geometry3D = (*iter)->GetCreatedWorldGeometry(); const TimeSlicedGeometry* timeSlicedGeometry = dynamic_cast( geometry3D ); if (!timeSlicedGeometry) continue; const SlicedGeometry3D* slicedGeometry = dynamic_cast( timeSlicedGeometry->GetGeometry3D(time) ); if (!slicedGeometry) continue; Geometry2D* geometry2D = slicedGeometry->GetGeometry2D(slice); if (!geometry2D) continue; // this is not necessary? ScalarType distanceMM = geometry2D->Distance( cursor ); BaseRenderer* renderer = stateEvent->GetEvent()->GetSender(); // TODO this is NOT SNC-specific! Should be! DisplayGeometry* displayGeometry = renderer->GetDisplayGeometry(); if (!displayGeometry) continue; ScalarType distancePixels = distanceMM / displayGeometry->GetScaleFactorMMPerDisplayUnit(); if ( distancePixels <= ThreshHoldDistancePixels ) { ++numNearPlanes; // count this one as a plane near to the cursor } if ( *iter == renderer->GetSliceNavigationController() ) // don't rotate the one where the user clicked { clickedGeometry = geometry2D; - clickedSlicedGeometry = const_cast(slicedGeometry); + //clickedSlicedGeometry = const_cast(slicedGeometry); } else { // @TODO here waits some bug to be found - maybe fixed by the || m_LinkPlanes in next line if ( (distancePixels <= ThreshHoldDistancePixels) && !(*iter)->GetSliceRotationLocked() && (m_SNCsToBeRotated.empty() || m_LinkPlanes) ) { // this one is behind the clicked "line" m_SNCsToBeRotated.push_back(*iter); geometryToBeRotated = geometry2D; } else { otherGeometry = geometry2D; if ( m_LinkPlanes ) { // All slices are rotated, i.e. the relative angles between // slices remain fixed m_SNCsToBeRotated.push_back(*iter); } } } } bool move (true); if ( geometryToBeRotated && otherGeometry && clickedGeometry && ( numNearPlanes == 2 ) ) { // assure all three are valid, so calculation of center of rotation can be done move = false; } StateEvent *newStateEvent(NULL); // question in state machine is: "rotate?" if (move) { // move all planes to posEvent->GetWorldPosition() newStateEvent = new StateEvent(EIDNO, stateEvent->GetEvent()); } else { // determine center of rotation TODO requires two plane geometries... PlaneGeometry* planeGeometry = dynamic_cast(clickedGeometry); PlaneGeometry* planeGeometry1 = dynamic_cast(geometryToBeRotated); PlaneGeometry* planeGeometry2 = dynamic_cast(otherGeometry); if (!planeGeometry || !planeGeometry1 || !planeGeometry2) break; Line3D intersection; if (!planeGeometry->IntersectionLine( planeGeometry1, intersection )) break; m_LastCursorPosition = intersection.Project(cursor); if (!planeGeometry2->IntersectionPoint(intersection, m_CenterOfRotation)) break; // everything's fine newStateEvent = new StateEvent(EIDYES, stateEvent->GetEvent()); } if (!newStateEvent) MITK_ERROR << "rotation would be nice but is impossible... " << std::endl; this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; break; } case AcROTATESTART: { this->SetMouseCursor( rotate_cursor_xpm, 0, 0 ); this->InvokeEvent( SliceRotationEvent() ); // notify listeners break; } case AcROTATEEND: { this->ResetMouseCursor(); this->InvokeEvent( SliceRotationEvent() ); // notify listeners break; } default: { break; } } return ok; } } // namespace diff --git a/Core/Code/Controllers/mitkSlicesSwiveller.cpp b/Core/Code/Controllers/mitkSlicesSwiveller.cpp index 0b498474dd..c3e7d82b74 100644 --- a/Core/Code/Controllers/mitkSlicesSwiveller.cpp +++ b/Core/Code/Controllers/mitkSlicesSwiveller.cpp @@ -1,407 +1,407 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 9252 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkSlicesSwiveller.h" #include "mitkSliceNavigationController.h" #include "mitkStateEvent.h" #include "mitkAction.h" #include "mitkInteractionConst.h" #include "mitkDisplayPositionEvent.h" #include "mitkRotationOperation.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "mitkLine.h" #include "mitkGeometry3D.h" #include "mitkGeometry2D.h" #include "mitkPlaneGeometry.h" #include "mitkDisplayGeometry.h" #include "mitkSlicedGeometry3D.h" #include "mitkTimeSlicedGeometry.h" #include namespace mitk { SlicesSwiveller::Pointer SlicesSwiveller::New() { return SlicesSwiveller::New("slices-rotator"); } SlicesSwiveller::SlicesSwiveller(const char* machine) : SlicesCoordinator(machine), m_PreviousRotationAngle( 0.0 ) { } SlicesSwiveller::~SlicesSwiveller() { } // check if the slices of this SliceNavigationController can be rotated (???) Possible void SlicesSwiveller::OnSliceControllerAdded(SliceNavigationController* snc) { if (!snc) return; // connects creation of new world geometry to Self::SetGeometry snc->ConnectGeometrySendEvent(this); } void SlicesSwiveller::OnSliceControllerRemoved(SliceNavigationController* snc) { if (!snc) return; // nothing to do } /// Is called whenever a SliceNavigationController invokes an event. Will // update the list of SliceNavigationControllers that can handle rotation void SlicesSwiveller::SetGeometry(const itk::EventObject& /*EventObject*/) { // there is no way to determine the sender? // ==> update whole list of SNCs UpdateRelevantSNCs(); } /// Updates the list of SliceNavigationControllers that can handle rotation void SlicesSwiveller::UpdateRelevantSNCs() { m_RelevantSNCs.clear(); SNCVector::iterator iter; for ( iter = m_SliceNavigationControllers.begin(); iter != m_SliceNavigationControllers.end(); ++iter) { const Geometry3D* geometry3D = (*iter)->GetCreatedWorldGeometry(); const TimeSlicedGeometry* timeSlicedGeometry = dynamic_cast( geometry3D ); if (!timeSlicedGeometry) continue; const SlicedGeometry3D* slicedGeometry = dynamic_cast( timeSlicedGeometry->GetGeometry3D(0) ); if (!slicedGeometry) continue; Geometry2D *firstSlice( NULL ); - Geometry2D *secondSlice( NULL ); + //Geometry2D *secondSlice( NULL ); if (slicedGeometry->IsValidSlice(0)) { firstSlice = slicedGeometry->GetGeometry2D(0); } - if (slicedGeometry->IsValidSlice(1)) - { - secondSlice = slicedGeometry->GetGeometry2D(1); - } +// if (slicedGeometry->IsValidSlice(1)) +// { +// secondSlice = slicedGeometry->GetGeometry2D(1); +// } // If the direction vector of these two slices is the same, then accept // this slice stack as rotatable Vector3D right1 = firstSlice->GetAxisVector(0); Vector3D up1 = firstSlice->GetAxisVector(1); vnl_vector_fixed< ScalarType, 3 > vnlDirection1 = vnl_cross_3d(right1.GetVnlVector(), up1.GetVnlVector()); Vector3D direction1; direction1.SetVnlVector(vnlDirection1); Vector3D right2 = firstSlice->GetAxisVector(0); Vector3D up2 = firstSlice->GetAxisVector(1); vnl_vector_fixed< ScalarType, 3 > vnlDirection2 = vnl_cross_3d(right2.GetVnlVector(), up2.GetVnlVector()); Vector3D direction2; direction2.SetVnlVector(vnlDirection2); bool equal = true; const ScalarType eps = 0.0001; for (int i = 0; i < 3; ++i) { if ( fabs(direction1[i] - direction2[i]) > eps ) { equal = false; } } if (equal) // equal direction vectors { m_RelevantSNCs.push_back( *iter ); } } } bool SlicesSwiveller ::ExecuteAction(Action* action, StateEvent const* stateEvent) { const ScalarType ThresholdDistancePixels = 6.0; bool ok = false; switch ( action->GetActionId() ) { case AcMOVE: { // just reach through SNCVector::iterator iter; for ( iter = m_RelevantSNCs.begin(); iter != m_RelevantSNCs.end(); ++iter ) { if ( !(*iter)->GetSliceRotationLocked() ) { (*iter)->ExecuteAction(action, stateEvent); } } ok = true; break; } case AcROTATE: { const DisplayPositionEvent *posEvent = dynamic_cast(stateEvent->GetEvent()); if (!posEvent) break; // Determine relative mouse movement projected onto world space Point2D cursor = posEvent->GetDisplayPosition(); Vector2D relativeCursor = cursor - m_ReferenceCursor; Vector3D relativeCursorAxis = m_RotationPlaneXVector * relativeCursor[0] + m_RotationPlaneYVector * relativeCursor[1]; // Determine rotation axis (perpendicular to rotation plane and cursor // movement) Vector3D rotationAxis = itk::CrossProduct( m_RotationPlaneNormal, relativeCursorAxis ); ScalarType rotationAngle = relativeCursor.GetNorm() / 2.0; // Restore the initial plane pose by undoing the previous rotation // operation RotationOperation op( OpROTATE, m_CenterOfRotation, m_PreviousRotationAxis, -m_PreviousRotationAngle ); SNCVector::iterator iter; for ( iter = m_SNCsToBeRotated.begin(); iter != m_SNCsToBeRotated.end(); ++iter ) { if ( !(*iter)->GetSliceRotationLocked() ) { const Geometry3D* geometry3D = (*iter)->GetCreatedWorldGeometry(); const TimeSlicedGeometry* timeSlicedGeometry = dynamic_cast(geometry3D); if (!timeSlicedGeometry) continue; const_cast(timeSlicedGeometry) ->ExecuteOperation(&op); (*iter)->SendCreatedWorldGeometryUpdate(); } } // Apply new rotation operation to all relevant SNCs RotationOperation op2( OpROTATE, m_CenterOfRotation, rotationAxis, rotationAngle ); for ( iter = m_SNCsToBeRotated.begin(); iter != m_SNCsToBeRotated.end(); ++iter) { if ( !(*iter)->GetSliceRotationLocked() ) { //// Map rotation center onto display geometry (will be used as //// pre-rotation vector for compensating a visual shift of the //// rotation center) //BaseRenderer *renderer = (*iter)->GetRenderer(); //DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); //Point2D point2DWorld, point2DDisplayPre, point2DDisplayPost; //displayGeometry->Map( m_CenterOfRotation, point2DWorld ); //displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPre ); // Retrieve the TimeSlicedGeometry of this SliceNavigationController const Geometry3D* geometry3D = (*iter)->GetCreatedWorldGeometry(); const TimeSlicedGeometry* timeSlicedGeometry = dynamic_cast(geometry3D); if (!timeSlicedGeometry) continue; // Execute the new rotation const_cast(timeSlicedGeometry) ->ExecuteOperation(&op2); //// After rotation: map rotation center onto new display geometry... //displayGeometry->Map( m_CenterOfRotation, point2DWorld ); //displayGeometry->WorldToDisplay( point2DWorld, point2DDisplayPost ); //Vector2D vector2DDisplayDiff = point2DDisplayPost - point2DDisplayPre; //// And use the difference between pre- and post-rotation vectors to //// compensate for display geometry shift: //Vector2D origin = displayGeometry->GetOriginInMM(); //displayGeometry->MoveBy( vector2DDisplayDiff ); // Notify listeners (*iter)->SendCreatedWorldGeometryUpdate(); } } m_PreviousRotationAxis = rotationAxis; m_PreviousRotationAngle = rotationAngle; RenderingManager::GetInstance()->RequestUpdateAll(); this->InvokeEvent( SliceRotationEvent() ); // notify listeners ok = true; break; } case AcCHECKPOINT: { // Decide between moving and rotation: if we're close to the crossing // point of the planes, moving mode is entered, otherwise // rotation/swivel mode const DisplayPositionEvent *posEvent = dynamic_cast(stateEvent->GetEvent()); BaseRenderer *renderer = stateEvent->GetEvent()->GetSender(); if ( !posEvent || !renderer ) { break; } const Point3D &cursor = posEvent->GetWorldPosition(); m_SNCsToBeRotated.clear(); const PlaneGeometry *clickedGeometry( NULL ); const PlaneGeometry *otherGeometry1( NULL ); const PlaneGeometry *otherGeometry2( NULL ); SNCVector::iterator iter; for ( iter = m_RelevantSNCs.begin(); iter != m_RelevantSNCs.end(); ++iter ) { //unsigned int slice = (*iter)->GetSlice()->GetPos(); //unsigned int time = (*iter)->GetTime()->GetPos(); const PlaneGeometry *planeGeometry = (*iter)->GetCurrentPlaneGeometry(); if ( !planeGeometry ) continue; if ( *iter == renderer->GetSliceNavigationController() ) { clickedGeometry = planeGeometry; m_SNCsToBeRotated.push_back(*iter); } else { if ( otherGeometry1 == NULL ) { otherGeometry1 = planeGeometry; } else { otherGeometry2 = planeGeometry; } if ( m_LinkPlanes ) { // If planes are linked, apply rotation to all planes m_SNCsToBeRotated.push_back(*iter); } } } StateEvent *newStateEvent( NULL ); mitk::Line3D line; mitk::Point3D point; if ( (clickedGeometry != NULL) && (otherGeometry1 != NULL) && (otherGeometry2 != NULL) && clickedGeometry->IntersectionLine( otherGeometry1, line ) && otherGeometry2->IntersectionPoint( line, point )) { m_CenterOfRotation = point; if ( m_CenterOfRotation.EuclideanDistanceTo( cursor ) < ThresholdDistancePixels ) { newStateEvent = new StateEvent(EIDNO, stateEvent->GetEvent()); } else { m_ReferenceCursor = posEvent->GetDisplayPosition(); // Get main axes of rotation plane and store it for rotation step m_RotationPlaneNormal = clickedGeometry->GetNormal(); ScalarType xVector[] = { 1.0, 0.0, 0.0 }; ScalarType yVector[] = { 0.0, 1.0, 0.0 }; clickedGeometry->Geometry3D::IndexToWorld( Vector3D( xVector), m_RotationPlaneXVector ); clickedGeometry->Geometry3D::IndexToWorld( Vector3D( yVector), m_RotationPlaneYVector ); m_RotationPlaneNormal.Normalize(); m_RotationPlaneXVector.Normalize(); m_RotationPlaneYVector.Normalize(); m_PreviousRotationAxis.Fill( 0.0 ); m_PreviousRotationAxis[2] = 1.0; m_PreviousRotationAngle = 0.0; newStateEvent = new StateEvent(EIDYES, stateEvent->GetEvent()); } } else { newStateEvent = new StateEvent(EIDNO, stateEvent->GetEvent()); } this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; break; } case AcROTATESTART: { this->InvokeEvent( SliceRotationEvent() ); // notify listeners break; } case AcROTATEEND: { this->InvokeEvent( SliceRotationEvent() ); // notify listeners break; } default: { break; } } return ok; } } // namespace diff --git a/Core/Code/DataManagement/mitkBaseData.cpp b/Core/Code/DataManagement/mitkBaseData.cpp index 106d6a0910..0da1b20a84 100644 --- a/Core/Code/DataManagement/mitkBaseData.cpp +++ b/Core/Code/DataManagement/mitkBaseData.cpp @@ -1,362 +1,363 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkBaseData.h" #include #define MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED mitk::BaseData::BaseData() : m_RequestedRegionInitialized(false), m_SmartSourcePointer(NULL), m_SourceOutputIndexDuplicate(0), m_Initialized(true), m_Unregistering(false), m_CalculatingExternalReferenceCount(false), m_ExternalReferenceCount(-1) { m_TimeSlicedGeometry = TimeSlicedGeometry::New(); m_PropertyList = PropertyList::New(); } mitk::BaseData::BaseData( const BaseData &other ): -m_RequestedRegionInitialized(other.m_RequestedRegionInitialized), +itk::DataObject(), +m_RequestedRegionInitialized(other.m_RequestedRegionInitialized), m_SmartSourcePointer(other.m_SmartSourcePointer), m_SourceOutputIndexDuplicate(other.m_SourceOutputIndexDuplicate), m_Initialized(other.m_Initialized), m_Unregistering(other.m_Unregistering), m_CalculatingExternalReferenceCount(other.m_CalculatingExternalReferenceCount), m_ExternalReferenceCount(other.m_ExternalReferenceCount) { m_TimeSlicedGeometry = dynamic_cast(other.m_TimeSlicedGeometry->Clone().GetPointer()); m_PropertyList = other.m_PropertyList->Clone(); } mitk::BaseData::~BaseData() { m_SmartSourcePointer = NULL; } void mitk::BaseData::InitializeTimeSlicedGeometry(unsigned int timeSteps) { mitk::TimeSlicedGeometry::Pointer timeGeometry = this->GetTimeSlicedGeometry(); mitk::Geometry3D::Pointer g3d = mitk::Geometry3D::New(); g3d->Initialize(); if ( timeSteps > 1 ) { mitk::ScalarType timeBounds[] = {0.0, 1.0}; g3d->SetTimeBounds( timeBounds ); } // The geometry is propagated automatically to the other items, // if EvenlyTimed is true... timeGeometry->InitializeEvenlyTimed( g3d.GetPointer(), timeSteps ); } void mitk::BaseData::UpdateOutputInformation() { if ( this->GetSource() ) { this->GetSource()->UpdateOutputInformation(); } if(m_TimeSlicedGeometry.IsNotNull()) m_TimeSlicedGeometry->UpdateInformation(); } const mitk::TimeSlicedGeometry* mitk::BaseData::GetUpdatedTimeSlicedGeometry() { SetRequestedRegionToLargestPossibleRegion(); UpdateOutputInformation(); return GetTimeSlicedGeometry(); } void mitk::BaseData::Expand( unsigned int timeSteps ) { if( m_TimeSlicedGeometry.IsNotNull() ) m_TimeSlicedGeometry->ExpandToNumberOfTimeSteps( timeSteps ); } const mitk::Geometry3D* mitk::BaseData::GetUpdatedGeometry(int t) { SetRequestedRegionToLargestPossibleRegion(); UpdateOutputInformation(); return GetGeometry(t); } void mitk::BaseData::SetGeometry(Geometry3D* aGeometry3D) { if(aGeometry3D!=NULL) { TimeSlicedGeometry::Pointer timeSlicedGeometry = dynamic_cast(aGeometry3D); if ( timeSlicedGeometry.IsNotNull() ) m_TimeSlicedGeometry = timeSlicedGeometry; else { timeSlicedGeometry = TimeSlicedGeometry::New(); m_TimeSlicedGeometry = timeSlicedGeometry; timeSlicedGeometry->InitializeEvenlyTimed(aGeometry3D, 1); } Modified(); } else if( m_TimeSlicedGeometry.IsNotNull() ) { m_TimeSlicedGeometry = NULL; Modified(); } return; } void mitk::BaseData::SetClonedGeometry(const Geometry3D* aGeometry3D) { SetGeometry(static_cast(aGeometry3D->Clone().GetPointer())); } void mitk::BaseData::SetClonedGeometry(const Geometry3D* aGeometry3D, unsigned int time) { if (m_TimeSlicedGeometry) { m_TimeSlicedGeometry->SetGeometry3D(static_cast(aGeometry3D->Clone().GetPointer()), time); } } bool mitk::BaseData::IsEmptyTimeStep(unsigned int) const { return IsInitialized() == false; } bool mitk::BaseData::IsEmpty() const { if(IsInitialized() == false) return true; const TimeSlicedGeometry* timeGeometry = const_cast(this)->GetUpdatedTimeSlicedGeometry(); if(timeGeometry == NULL) return true; unsigned int timeSteps = timeGeometry->GetTimeSteps(); for ( unsigned int t = 0 ; t < timeSteps ; ++t ) { if(IsEmptyTimeStep(t) == false) return false; } return true; } itk::SmartPointer mitk::BaseData::GetSource() const { return static_cast(Superclass::GetSource().GetPointer()); } int mitk::BaseData::GetExternalReferenceCount() const { if(m_CalculatingExternalReferenceCount==false) //this is only needed because a smart-pointer to m_Outputs (private!!) must be created by calling GetOutputs. { m_CalculatingExternalReferenceCount = true; m_ExternalReferenceCount = -1; int realReferenceCount = GetReferenceCount(); if(GetSource().IsNull()) { m_ExternalReferenceCount = realReferenceCount; m_CalculatingExternalReferenceCount = false; return m_ExternalReferenceCount; } mitk::BaseProcess::DataObjectPointerArray outputs = m_SmartSourcePointer->GetOutputs(); unsigned int idx; for (idx = 0; idx < outputs.size(); ++idx) { //references of outputs that are not referenced from someone else (reference additional to the reference from this BaseProcess object) are interpreted as non-existent if(outputs[idx]==this) --realReferenceCount; } m_ExternalReferenceCount = realReferenceCount; if(m_ExternalReferenceCount<0) m_ExternalReferenceCount=0; m_CalculatingExternalReferenceCount = false; } else return -1; return m_ExternalReferenceCount; } void mitk::BaseData::UnRegister() const { #ifdef MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED if(GetReferenceCount()>1) { Superclass::UnRegister(); if((m_Unregistering==false) && (m_SmartSourcePointer.IsNotNull())) { m_Unregistering=true; // the order of the following boolean statement is important: // this->GetSource() returns a SmartPointer, // which increases and afterwards decreases the reference count, // which may result in an ExternalReferenceCount of 0, causing // BaseProcess::UnRegister() to destroy us (also we already // about to do that). if((this->m_SmartSourcePointer->GetExternalReferenceCount()==0) || (this->GetSource().IsNull())) m_SmartSourcePointer=NULL; // now the reference count is zero and this object has been destroyed; thus nothing may be done after this line!! else m_Unregistering=false; } } else #endif Superclass::UnRegister(); // now the reference count is zero and this object has been destroyed; thus nothing may be done after this line!! } void mitk::BaseData::ConnectSource(itk::ProcessObject *arg, unsigned int idx) const { #ifdef MITK_WEAKPOINTER_PROBLEM_WORKAROUND_ENABLED itkDebugMacro( "connecting source " << arg << ", source output index " << idx); if ( GetSource().GetPointer() != arg || m_SourceOutputIndexDuplicate != idx) { m_SmartSourcePointer = dynamic_cast(arg); m_SourceOutputIndexDuplicate = idx; Modified(); } #endif } mitk::PropertyList::Pointer mitk::BaseData::GetPropertyList() const { return m_PropertyList; } mitk::BaseProperty::Pointer mitk::BaseData::GetProperty(const char *propertyKey) const { return m_PropertyList->GetProperty(propertyKey); } void mitk::BaseData::SetProperty(const char *propertyKey, BaseProperty* propertyValue) { m_PropertyList->SetProperty(propertyKey, propertyValue); } void mitk::BaseData::SetPropertyList(PropertyList *pList) { m_PropertyList = pList; } void mitk::BaseData::SetOrigin(const mitk::Point3D& origin) { mitk::TimeSlicedGeometry* timeSlicedGeometry = GetTimeSlicedGeometry(); assert(timeSlicedGeometry!=NULL); mitk::Geometry3D* geometry; unsigned int steps = timeSlicedGeometry->GetTimeSteps(); for(unsigned int timestep = 0; timestep < steps; ++timestep) { geometry = GetGeometry(timestep); if(geometry != NULL) { geometry->SetOrigin(origin); } if(GetTimeSlicedGeometry()->GetEvenlyTimed()) { GetTimeSlicedGeometry()->InitializeEvenlyTimed(geometry, steps); break; } } } unsigned long mitk::BaseData::GetMTime() const { unsigned long time = Superclass::GetMTime(); if(m_TimeSlicedGeometry.IsNotNull()) { if((time < m_TimeSlicedGeometry->GetMTime())) { Modified(); return Superclass::GetMTime(); } //unsigned long geometryTime = m_TimeSlicedGeometry->GetMTime(); //if(time < geometryTime) //{ // return geometryTime; //} } return time; } void mitk::BaseData::CopyInformation( const itk::DataObject* data ) { const Self* bd = dynamic_cast(data); if (bd != NULL) { m_TimeSlicedGeometry = dynamic_cast(bd->GetTimeSlicedGeometry()->Clone().GetPointer()); m_PropertyList = bd->GetPropertyList()->Clone(); } else { // pointer could not be cast back down; this can be the case if your filters input // and output objects differ in type; then you have to write your own GenerateOutputInformation method itkExceptionMacro(<< "mitk::BaseData::CopyInformation() cannot cast " << typeid(data).name() << " to " << typeid(Self*).name() ); } } bool mitk::BaseData::IsInitialized() const { return m_Initialized; } void mitk::BaseData::Clear() { this->ClearData(); this->InitializeEmpty(); } void mitk::BaseData::ClearData() { if(m_Initialized) { ReleaseData(); m_Initialized = false; } } void mitk::BaseData::ExecuteOperation(mitk::Operation* /*operation*/) { //empty by default. override if needed! } void mitk::BaseData::PrintSelf(std::ostream& os, itk::Indent indent) const { os << std::endl; os << indent << " TimeSlicedGeometry: "; if(GetTimeSlicedGeometry() == NULL) os << "NULL" << std::endl; else GetTimeSlicedGeometry()->Print(os, indent); } diff --git a/Core/Code/DataManagement/mitkChannelDescriptor.cpp b/Core/Code/DataManagement/mitkChannelDescriptor.cpp index 459fdade93..93f6299e32 100644 --- a/Core/Code/DataManagement/mitkChannelDescriptor.cpp +++ b/Core/Code/DataManagement/mitkChannelDescriptor.cpp @@ -1,38 +1,38 @@ #include "mitkChannelDescriptor.h" #include "mitkMemoryUtilities.h" -mitk::ChannelDescriptor::ChannelDescriptor( mitk::PixelType type, size_t numOfElements, bool allocate) +mitk::ChannelDescriptor::ChannelDescriptor( mitk::PixelType type, size_t numOfElements, bool /*allocate*/) : m_PixelType(NULL), m_Size(numOfElements), m_Data(NULL) { m_PixelType = new PixelType(type); //MITK_INFO << "Entering ChannelDescriptor constructor."; } /* void mitk::ChannelDescriptor::Initialize(mitk::PixelType &type, size_t numOfElements, bool allocate) { if( m_PixelType.GetPixelTypeId() != type.GetPixelTypeId() ) { MITK_WARN << "Changing pixel type for channel: " << m_PixelType.GetItkTypeAsString() << " -> " << type.GetItkTypeAsString(); } m_PixelType = type; m_Size = numOfElements * m_PixelType.GetSize(); if( allocate ) { this->AllocateData(); } } */ void mitk::ChannelDescriptor::AllocateData() { if( m_Data == NULL) { m_Data = mitk::MemoryUtilities::AllocateElements( m_Size ); } } diff --git a/Core/Code/DataManagement/mitkImageDataItem.cpp b/Core/Code/DataManagement/mitkImageDataItem.cpp index f626b5e3de..df2d0b9b98 100644 --- a/Core/Code/DataManagement/mitkImageDataItem.cpp +++ b/Core/Code/DataManagement/mitkImageDataItem.cpp @@ -1,259 +1,259 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkImageDataItem.h" #include "mitkMemoryUtilities.h" #include #include #include #include #include #include #include #include #include #include #include #include #include mitk::ImageDataItem::ImageDataItem(const ImageDataItem& aParent, const mitk::ImageDescriptor::Pointer desc, unsigned int dimension, void *data, bool manageMemory, size_t offset) : m_Data(NULL), m_ManageMemory(false), m_VtkImageData(NULL), m_Offset(offset), m_IsComplete(false), m_Size(0), m_Parent(&aParent) { m_PixelType = new mitk::PixelType(aParent.GetPixelType()); m_Data = static_cast(aParent.GetData())+offset; // compute size - const unsigned int *dims = desc->GetDimensions(); + //const unsigned int *dims = desc->GetDimensions(); m_Dimension = dimension; for( unsigned int i=0; iGetDimensions()[i]; this->ComputeItemSize(m_Dimensions,dimension); if(data != NULL) { memcpy(m_Data, data, m_Size); if(manageMemory) { delete [] (unsigned char*) data; } } m_ReferenceCountLock.Lock(); m_ReferenceCount = 0; m_ReferenceCountLock.Unlock(); } mitk::ImageDataItem::~ImageDataItem() { if(m_VtkImageData!=NULL) m_VtkImageData->Delete(); if(m_Parent.IsNull()) { if(m_ManageMemory) delete [] m_Data; } delete m_PixelType; } mitk::ImageDataItem::ImageDataItem(const mitk::ImageDescriptor::Pointer desc, void *data, bool manageMemory) : m_Data((unsigned char*)data), m_ManageMemory(manageMemory), m_VtkImageData(NULL), m_Offset(0), m_IsComplete(false), m_Size(0) { m_PixelType = new mitk::PixelType(desc->GetChannelDescriptor(0).GetPixelType()); // compute size const unsigned int *dimensions = desc->GetDimensions(); m_Dimension = desc->GetNumberOfDimensions(); for( unsigned int i=0; iComputeItemSize(m_Dimensions, m_Dimension ); if(m_Data == NULL) { m_Data = mitk::MemoryUtilities::AllocateElements( m_Size ); m_ManageMemory = true; } m_ReferenceCountLock.Lock(); m_ReferenceCount = 0; m_ReferenceCountLock.Unlock(); } mitk::ImageDataItem::ImageDataItem(const mitk::PixelType& type, unsigned int dimension, unsigned int *dimensions, void *data, bool manageMemory) : m_Data((unsigned char*)data), m_ManageMemory(manageMemory), m_VtkImageData(NULL), m_Offset(0), m_IsComplete(false), m_Size(0), m_Parent(NULL) { m_PixelType = new mitk::PixelType(type); m_Dimension = dimension; for( unsigned int i=0; iComputeItemSize(dimensions, dimension); if(m_Data == NULL) { m_Data = mitk::MemoryUtilities::AllocateElements( m_Size ); m_ManageMemory = true; } m_ReferenceCountLock.Lock(); m_ReferenceCount = 0; m_ReferenceCountLock.Unlock(); } mitk::ImageDataItem::ImageDataItem(const ImageDataItem &other) - : m_PixelType(other.m_PixelType), m_ManageMemory(other.m_ManageMemory), m_Offset(other.m_Offset), + : itk::LightObject(), m_PixelType(other.m_PixelType), m_ManageMemory(other.m_ManageMemory), m_Offset(other.m_Offset), m_IsComplete(other.m_IsComplete), m_Size(other.m_Size) { } void mitk::ImageDataItem::ComputeItemSize(const unsigned int *dimensions, unsigned int dimension) { m_Size = m_PixelType->GetSize(); for( unsigned int i=0; iSetDimensions( dims[0] -1, 1, 1); size = dims[0]; inData->SetOrigin( ((float) dims[0]) / 2.0f, 0, 0 ); } else if ( dim == 2 ) { inData->SetDimensions( dims[0] , dims[1] , 1 ); size = dims[0] * dims[1]; inData->SetOrigin( ((float) dims[0]) / 2.0f, ((float) dims[1]) / 2.0f, 0 ); } else if ( dim >= 3 ) { inData->SetDimensions( dims[0], dims[1], dims[2] ); size = dims[0] * dims[1] * dims[2]; // Test //inData->SetOrigin( (float) dims[0] / 2.0f, (float) dims[1] / 2.0f, (float) dims[2] / 2.0f ); inData->SetOrigin( 0, 0, 0 ); } else { inData->Delete () ; return; } inData->SetNumberOfScalarComponents(m_PixelType->GetNumberOfComponents()); /* if ( ( m_PixelType.GetType() == mitkIpPicInt || m_PixelType.GetType() == mitkIpPicUInt ) && m_PixelType.GetBitsPerComponent() == 1 ) { inData->SetScalarType( VTK_BIT ); scalars = vtkBitArray::New(); } else*/ if ( m_PixelType->GetTypeId() == typeid(char) ) { inData->SetScalarType( VTK_CHAR ); scalars = vtkCharArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(unsigned char)) { inData->SetScalarType( VTK_UNSIGNED_CHAR ); scalars = vtkUnsignedCharArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(short) ) { inData->SetScalarType( VTK_SHORT ); scalars = vtkShortArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(unsigned short) ) { inData->SetScalarType( VTK_UNSIGNED_SHORT ); scalars = vtkUnsignedShortArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(int) ) { inData->SetScalarType( VTK_INT ); scalars = vtkIntArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(unsigned int) ) { inData->SetScalarType( VTK_UNSIGNED_INT ); scalars = vtkUnsignedIntArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(long int) ) { inData->SetScalarType( VTK_LONG ); scalars = vtkLongArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(unsigned long int) ) { inData->SetScalarType( VTK_UNSIGNED_LONG ); scalars = vtkUnsignedLongArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(float) ) { inData->SetScalarType( VTK_FLOAT ); scalars = vtkFloatArray::New(); } else if ( m_PixelType->GetTypeId() == typeid(double) ) { inData->SetScalarType( VTK_DOUBLE ); scalars = vtkDoubleArray::New(); } else { inData->Delete(); return; } m_VtkImageData = inData; // allocate the new scalars scalars->SetNumberOfComponents(m_VtkImageData->GetNumberOfScalarComponents()); scalars->SetVoidArray(m_Data, size * m_VtkImageData->GetNumberOfScalarComponents(), 1); m_VtkImageData->GetPointData()->SetScalars(scalars); scalars->Delete(); } void mitk::ImageDataItem::Modified() const { if(m_VtkImageData) m_VtkImageData->Modified(); } diff --git a/Core/Code/DataManagement/mitkLevelWindow.cpp b/Core/Code/DataManagement/mitkLevelWindow.cpp index b5627fac02..49f9aefaf3 100644 --- a/Core/Code/DataManagement/mitkLevelWindow.cpp +++ b/Core/Code/DataManagement/mitkLevelWindow.cpp @@ -1,415 +1,415 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkLevelWindow.h" #include "mitkImageSliceSelector.h" #include "mitkImageStatisticsHolder.h" #include void mitk::LevelWindow::EnsureConsistency() { // Check if total range is ok { if ( m_RangeMin > m_RangeMax ) std::swap(m_RangeMin,m_RangeMax); if (m_RangeMin == m_RangeMax ) m_RangeMin = m_RangeMax - 1; } // Check if current window is ok { if ( m_LowerWindowBound > m_UpperWindowBound ) std::swap(m_LowerWindowBound,m_UpperWindowBound); if ( m_LowerWindowBound < m_RangeMin ) m_LowerWindowBound = m_RangeMin; if ( m_UpperWindowBound < m_RangeMin ) m_UpperWindowBound = m_RangeMin; if ( m_LowerWindowBound > m_RangeMax ) m_LowerWindowBound = m_RangeMax; if ( m_UpperWindowBound > m_RangeMax ) m_UpperWindowBound = m_RangeMax; if (m_LowerWindowBound == m_UpperWindowBound ) { if(m_LowerWindowBound == m_RangeMin ) m_UpperWindowBound++; else m_LowerWindowBound--; } } } mitk::LevelWindow::LevelWindow(mitk::ScalarType level, mitk::ScalarType window) : m_LowerWindowBound( level - window / 2.0 ), m_UpperWindowBound( level + window / 2.0 ), m_RangeMin( -2048.0 ), m_RangeMax( 4096.0 ), m_DefaultLowerBound( -2048.0 ), m_DefaultUpperBound( 4096.0 ), m_Fixed( false ) { SetDefaultLevelWindow(level, window); } mitk::LevelWindow::LevelWindow(const mitk::LevelWindow& levWin) : m_LowerWindowBound( levWin.GetLowerWindowBound() ) , m_UpperWindowBound( levWin.GetUpperWindowBound() ) , m_RangeMin( levWin.GetRangeMin() ) , m_RangeMax( levWin.GetRangeMax() ) , m_DefaultLowerBound( levWin.GetDefaultLowerBound() ) , m_DefaultUpperBound( levWin.GetDefaultUpperBound() ) , m_Fixed( levWin.GetFixed() ) { } mitk::LevelWindow::~LevelWindow() { } mitk::ScalarType mitk::LevelWindow::GetLevel() const { return (m_UpperWindowBound-m_LowerWindowBound) / 2.0 + m_LowerWindowBound; } mitk::ScalarType mitk::LevelWindow::GetWindow() const { return (m_UpperWindowBound-m_LowerWindowBound); } mitk::ScalarType mitk::LevelWindow::GetDefaultLevel() const { return ((m_DefaultUpperBound+m_DefaultLowerBound)/2.0); } mitk::ScalarType mitk::LevelWindow::GetDefaultWindow() const { return ((m_DefaultUpperBound-m_DefaultLowerBound)); } void mitk::LevelWindow::ResetDefaultLevelWindow() { SetLevelWindow(GetDefaultLevel(), GetDefaultWindow()); } mitk::ScalarType mitk::LevelWindow::GetLowerWindowBound() const { return m_LowerWindowBound; } mitk::ScalarType mitk::LevelWindow::GetUpperWindowBound() const { return m_UpperWindowBound; } void mitk::LevelWindow::SetDefaultLevelWindow(mitk::ScalarType level, mitk::ScalarType window) { SetDefaultBoundaries((level-(window/2)), (level+(window/2))); } void mitk::LevelWindow::SetLevelWindow(mitk::ScalarType level, mitk::ScalarType window) { SetWindowBounds((level-(window/2.0)), (level+(window/2.0))); } void mitk::LevelWindow::SetWindowBounds(mitk::ScalarType lowerBound, mitk::ScalarType upperBound) { if ( IsFixed() ) return; m_LowerWindowBound = lowerBound; m_UpperWindowBound = upperBound; EnsureConsistency(); } void mitk::LevelWindow::SetRangeMinMax(mitk::ScalarType min, mitk::ScalarType max) { if ( IsFixed() ) return; m_RangeMin = min; m_RangeMax = max; EnsureConsistency(); } void mitk::LevelWindow::SetDefaultBoundaries(mitk::ScalarType low, mitk::ScalarType up) { if ( IsFixed() ) return; m_DefaultLowerBound = low; m_DefaultUpperBound = up; // Check if default window is ok { if ( m_DefaultLowerBound > m_DefaultUpperBound ) std::swap(m_DefaultLowerBound,m_DefaultUpperBound); if (m_DefaultLowerBound == m_DefaultUpperBound ) m_DefaultLowerBound--; } EnsureConsistency(); } void mitk::LevelWindow::SetToMaxWindowSize() { SetWindowBounds( m_RangeMin , m_RangeMax ); } mitk::ScalarType mitk::LevelWindow::GetRangeMin() const { return m_RangeMin; } mitk::ScalarType mitk::LevelWindow::GetRangeMax() const { return m_RangeMax; } mitk::ScalarType mitk::LevelWindow::GetRange() const { return m_RangeMax - m_RangeMin; } mitk::ScalarType mitk::LevelWindow::GetDefaultUpperBound() const { return m_DefaultUpperBound; } mitk::ScalarType mitk::LevelWindow::GetDefaultLowerBound() const { return m_DefaultLowerBound; } void mitk::LevelWindow::ResetDefaultRangeMinMax() { SetRangeMinMax(m_DefaultLowerBound, m_DefaultUpperBound); } /*! This method initializes a mitk::LevelWindow from an mitk::Image. The algorithm is as follows: Default to taking the central image slice for quick analysis. Compute the smallest (minValue), second smallest (min2ndValue), second largest (max2ndValue), and largest (maxValue) data value by traversing the pixel values only once. In the same scan it also computes the count of minValue values and maxValue values. After that a basic histogram with specific information about the extrems is complete. If minValue == maxValue, the center slice is uniform and the above scan is repeated for the complete image, not just one slice Next, special cases of images with only 1, 2 or 3 distinct data values have hand assigned level window ranges. Next the level window is set relative to the inner range IR = lengthOf([min2ndValue, max2ndValue]) For count(minValue) > 20% the smallest values are frequent and should be distinct from the min2ndValue and larger values (minValue may be std:min, may signify something special) hence the lower end of the level window is set to min2ndValue - 0.5 * IR For count(minValue) <= 20% the smallest values are not so important and can blend with the next ones => min(level window) = min2ndValue And analog for max(level window): count(max2ndValue) > 20%: max(level window) = max2ndValue + 0.5 * IR count(max2ndValue) < 20%: max(level window) = max2ndValue In both 20%+ cases the level window bounds are clamped to the [minValue, maxValue] range In consequence the level window maximizes contrast with minimal amount of computation and does do useful things if the data contains std::min or std:max values or has only 1 or 2 or 3 data values. */ -void mitk::LevelWindow::SetAuto(const mitk::Image* image, bool tryPicTags, bool guessByCentralSlice) +void mitk::LevelWindow::SetAuto(const mitk::Image* image, bool /*tryPicTags*/, bool guessByCentralSlice) { if ( IsFixed() ) return; if ( image == NULL || !image->IsInitialized() ) return; const mitk::Image* wholeImage = image; ScalarType minValue = 0.0; ScalarType maxValue = 0.0; ScalarType min2ndValue = 0.0; ScalarType max2ndValue = 0.0; mitk::ImageSliceSelector::Pointer sliceSelector = mitk::ImageSliceSelector::New(); if ( guessByCentralSlice ) { sliceSelector->SetInput(image); sliceSelector->SetSliceNr(image->GetDimension(2)/2); sliceSelector->SetTimeNr(image->GetDimension(3)/2); sliceSelector->SetChannelNr(image->GetDimension(4)/2); sliceSelector->Update(); image = sliceSelector->GetOutput(); if ( image == NULL || !image->IsInitialized() ) return; minValue = image->GetStatistics()->GetScalarValueMin(); maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute(); min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(); max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(); if ( minValue == maxValue ) { // guessByCentralSlice seems to have failed, lets look at all data image = wholeImage; minValue = image->GetStatistics()->GetScalarValueMin(); maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute(); min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(); max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(); } } else { const_cast(image)->Update(); minValue = image->GetStatistics()->GetScalarValueMin(0); maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute(0); min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(0); max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(0); for (unsigned int i = 1; i < image->GetDimension(3); ++i) { ScalarType minValueTemp = image->GetStatistics()->GetScalarValueMin(i); if (minValue > minValueTemp) minValue = minValueTemp; ScalarType maxValueTemp = image->GetStatistics()->GetScalarValueMaxNoRecompute(i); if (maxValue < maxValueTemp) maxValue = maxValueTemp; ScalarType min2ndValueTemp = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(i); if (min2ndValue > min2ndValueTemp) min2ndValue = min2ndValueTemp; ScalarType max2ndValueTemp = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(i); if (max2ndValue > max2ndValueTemp) max2ndValue = max2ndValueTemp; } } // Fix for bug# 344 Level Window wird bei Eris Cut bildern nicht richtig gesetzt if (image->GetPixelType()== typeid(int) && image->GetPixelType().GetBpe() >= 8) { // the windows compiler complains about ambiguos 'pow' call, therefore static casting to (double, int) if (minValue == -( pow( (double) 2.0, static_cast(image->GetPixelType().GetBpe()/2) ) ) ) { minValue = min2ndValue; } } // End fix //// uniform image if ( minValue == maxValue ) { minValue = maxValue-1; } SetRangeMinMax(minValue, maxValue); SetDefaultBoundaries(minValue, maxValue); /* if ( tryPicTags ) // level and window will be set by informations provided directly by the mitkIpPicDescriptor { if ( SetAutoByPicTags(const_cast(image)->GetPic()) ) { return; } } */ unsigned int numPixelsInDataset = image->GetDimensions()[0]; for ( unsigned int k=0; kGetDimension(); ++k ) numPixelsInDataset *= image->GetDimensions()[k]; unsigned int minCount = image->GetStatistics()->GetCountOfMinValuedVoxelsNoRecompute(); unsigned int maxCount = image->GetStatistics()->GetCountOfMaxValuedVoxelsNoRecompute(); float minCountFraction = minCount/float(numPixelsInDataset); float maxCountFraction = maxCount/float(numPixelsInDataset); //// binary image if ( min2ndValue == maxValue ) { // noop; full range is fine } //// triple value image, put middle value in center of gray level ramp else if ( min2ndValue == max2ndValue ) { ScalarType minDelta = std::min(min2ndValue-minValue, maxValue-min2ndValue); minValue = min2ndValue - minDelta; maxValue = min2ndValue + minDelta; } // now we can assume more than three distict scalar values else { ScalarType innerRange = max2ndValue - min2ndValue; if ( minCountFraction > 0.2 ) //// lots of min values -> make different from rest, but not miles away { ScalarType halfInnerRangeGapMinValue = min2ndValue - innerRange/2.0; minValue = std::max(minValue, halfInnerRangeGapMinValue); } else //// few min values -> focus on innerRange { minValue = min2ndValue; } if ( maxCountFraction > 0.2 ) //// lots of max values -> make different from rest { ScalarType halfInnerRangeGapMaxValue = max2ndValue + innerRange/2.0; maxValue = std::min(maxValue, halfInnerRangeGapMaxValue); } else //// few max values -> focus on innerRange { maxValue = max2ndValue; } } SetWindowBounds(minValue, maxValue); SetDefaultLevelWindow((maxValue - minValue) / 2 + minValue, maxValue - minValue); } void mitk::LevelWindow::SetFixed( bool fixed ) { m_Fixed = fixed; } bool mitk::LevelWindow::GetFixed() const { return m_Fixed; } bool mitk::LevelWindow::IsFixed() const { return m_Fixed; } bool mitk::LevelWindow::operator==(const mitk::LevelWindow& levWin) const { if ( m_RangeMin == levWin.GetRangeMin() && m_RangeMax == levWin.GetRangeMax() && m_LowerWindowBound == levWin.GetLowerWindowBound() && m_UpperWindowBound == levWin.GetUpperWindowBound() && m_DefaultLowerBound == levWin.GetDefaultLowerBound() && m_DefaultUpperBound == levWin.GetDefaultUpperBound() && m_Fixed == levWin.IsFixed() ) { return true; } else { return false; } } bool mitk::LevelWindow::operator!=(const mitk::LevelWindow& levWin) const { return ! ( (*this) == levWin); } mitk::LevelWindow& mitk::LevelWindow::operator=(const mitk::LevelWindow& levWin) { if (this == &levWin) { return *this; } else { m_RangeMin = levWin.GetRangeMin(); m_RangeMax = levWin.GetRangeMax(); m_LowerWindowBound= levWin.GetLowerWindowBound(); m_UpperWindowBound= levWin.GetUpperWindowBound(); m_DefaultLowerBound = levWin.GetDefaultLowerBound(); m_DefaultUpperBound = levWin.GetDefaultUpperBound(); m_Fixed = levWin.GetFixed(); return *this; } } diff --git a/Core/Code/DataManagement/mitkLookupTable.cpp b/Core/Code/DataManagement/mitkLookupTable.cpp index 8edd8739aa..ff98c8d220 100644 --- a/Core/Code/DataManagement/mitkLookupTable.cpp +++ b/Core/Code/DataManagement/mitkLookupTable.cpp @@ -1,298 +1,298 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkLookupTable.h" #include #include #include mitk::LookupTable::LookupTable() { m_LookupTable = vtkLookupTable::New(); this->SetRequestedRegionToLargestPossibleRegion(); } mitk::LookupTable::~LookupTable() { if ( m_LookupTable ) { m_LookupTable->Delete(); m_LookupTable = NULL; } } void mitk::LookupTable::SetVtkLookupTable( vtkLookupTable* lut ) { if(m_LookupTable == lut) { return; } if(m_LookupTable) { m_LookupTable->UnRegister(NULL); m_LookupTable = NULL; } if(lut) { lut->Register(NULL); } m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::ChangeOpacityForAll( float opacity ) { int noValues = m_LookupTable->GetNumberOfTableValues (); vtkFloatingPointType rgba[ 4 ]; for ( int i = 0;i < noValues;i++ ) { m_LookupTable->GetTableValue ( i, rgba ); rgba[ 3 ] = opacity; m_LookupTable->SetTableValue ( i, rgba ); } this->Modified(); // need to call modiefied, since LookupTableProperty seems to be unchanged so no widget-updat is executed } void mitk::LookupTable::ChangeOpacity(int index, float opacity ) { int noValues = m_LookupTable->GetNumberOfTableValues (); if (index>noValues) { MITK_INFO << "could not change opacity. index exceed size of lut ... " << std::endl; return; } vtkFloatingPointType rgba[ 4 ]; m_LookupTable->GetTableValue ( index, rgba ); rgba[ 3 ] = opacity; m_LookupTable->SetTableValue ( index, rgba ); this->Modified(); // need to call modiefied, since LookupTableProperty seems to be unchanged so no widget-updat is executed } vtkLookupTable* mitk::LookupTable::GetVtkLookupTable() const { return m_LookupTable; }; mitk::LookupTable::RawLookupTableType * mitk::LookupTable::GetRawLookupTable() const { if (m_LookupTable==NULL) MITK_INFO << "uuups..." << std::endl; return m_LookupTable->GetPointer( 0 ); }; /*! * \brief equality operator inplementation */ bool mitk::LookupTable::operator==( const mitk::LookupTable& other ) const { if ( m_LookupTable == other.GetVtkLookupTable()) return true; vtkLookupTable* olut = other.GetVtkLookupTable(); if (olut == NULL) return false; bool equal = (m_LookupTable->GetNumberOfColors() == olut->GetNumberOfColors()) && (m_LookupTable->GetTableRange()[0] == olut->GetTableRange()[0]) && (m_LookupTable->GetTableRange()[1] == olut->GetTableRange()[1]) && (m_LookupTable->GetHueRange()[0] == olut->GetHueRange()[0]) && (m_LookupTable->GetHueRange()[1] == olut->GetHueRange()[1]) && (m_LookupTable->GetSaturationRange()[0] == olut->GetSaturationRange()[0]) && (m_LookupTable->GetSaturationRange()[1] == olut->GetSaturationRange()[1]) && (m_LookupTable->GetValueRange()[0] == olut->GetValueRange()[0]) && (m_LookupTable->GetValueRange()[1] == olut->GetValueRange()[1]) && (m_LookupTable->GetAlphaRange()[0] == olut->GetAlphaRange()[0]) && (m_LookupTable->GetAlphaRange()[1] == olut->GetAlphaRange()[1]) && (m_LookupTable->GetRamp() == olut->GetRamp()) && (m_LookupTable->GetScale() == olut->GetScale()) && (m_LookupTable->GetAlpha() == olut->GetAlpha()) && (m_LookupTable->GetTable()->GetNumberOfTuples() == olut->GetTable()->GetNumberOfTuples()); if (equal == false) return false; //for (vtkIdType i=0; i < m_LookupTable->GetTable()->GetNumberOfTuples(); i++) //{ // if (m_LookupTable->GetTable()->GetTuple(i) != olut->GetTable()->GetTuple(i)) // return false; //} for (vtkIdType i=0; i < m_LookupTable->GetNumberOfTableValues(); i++) { - double v0_1 = m_LookupTable->GetTableValue(i)[0]; double v0_2 = olut->GetTableValue(i)[0]; - double v1_1 = m_LookupTable->GetTableValue(i)[1]; double v1_2 = olut->GetTableValue(i)[1]; - double v2_1 = m_LookupTable->GetTableValue(i)[2]; double v2_2 = olut->GetTableValue(i)[2]; - double v3_1 = m_LookupTable->GetTableValue(i)[3]; double v3_2 = olut->GetTableValue(i)[3]; + //double v0_1 = m_LookupTable->GetTableValue(i)[0]; double v0_2 = olut->GetTableValue(i)[0]; + //double v1_1 = m_LookupTable->GetTableValue(i)[1]; double v1_2 = olut->GetTableValue(i)[1]; + //double v2_1 = m_LookupTable->GetTableValue(i)[2]; double v2_2 = olut->GetTableValue(i)[2]; + //double v3_1 = m_LookupTable->GetTableValue(i)[3]; double v3_2 = olut->GetTableValue(i)[3]; bool tvequal = (m_LookupTable->GetTableValue(i)[0] == olut->GetTableValue(i)[0]) && (m_LookupTable->GetTableValue(i)[1] == olut->GetTableValue(i)[1]) && (m_LookupTable->GetTableValue(i)[2] == olut->GetTableValue(i)[2]) && (m_LookupTable->GetTableValue(i)[3] == olut->GetTableValue(i)[3]); if (tvequal == false) return false; } return true; } /*! * \brief un-equality operator implementation */ bool mitk::LookupTable::operator!=( const mitk::LookupTable& other ) const { return !(*this == other); } /*! * \brief assignment operator implementation */ mitk::LookupTable& mitk::LookupTable::operator=( const mitk::LookupTable& LookupTable ) { if ( this == &LookupTable ) { return * this; } else { m_LookupTable = LookupTable.GetVtkLookupTable(); return *this; } } void mitk::LookupTable::UpdateOutputInformation( ) { if ( this->GetSource( ) ) { this->GetSource( ) ->UpdateOutputInformation( ); } } void mitk::LookupTable::SetRequestedRegionToLargestPossibleRegion( ) {} bool mitk::LookupTable::RequestedRegionIsOutsideOfTheBufferedRegion( ) { return false; } bool mitk::LookupTable::VerifyRequestedRegion( ) { //normally we should check if the requested region lies within the //largest possible region. Since for lookup-tables we assume, that the //requested region is always the largest possible region, we can always //return true! return true; } void mitk::LookupTable::SetRequestedRegion( itk::DataObject *) { //not implemented, since we always want to have the RequestedRegion //to be set to LargestPossibleRegion } void mitk::LookupTable::CreateColorTransferFunction(vtkColorTransferFunction*& colorFunction) { if(colorFunction==NULL) colorFunction = vtkColorTransferFunction::New(); mitk::LookupTable::RawLookupTableType *rgba = GetRawLookupTable(); int i, num_of_values=m_LookupTable->GetNumberOfTableValues(); vtkFloatingPointType *cols; vtkFloatingPointType *colsHead; colsHead=cols=(vtkFloatingPointType *)malloc(sizeof(vtkFloatingPointType)*num_of_values*3); for(i=0;iBuildFunctionFromTable(m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values-1, colsHead); free(colsHead); } void mitk::LookupTable::CreateOpacityTransferFunction(vtkPiecewiseFunction*& opacityFunction) { if(opacityFunction==NULL) opacityFunction = vtkPiecewiseFunction::New(); mitk::LookupTable::RawLookupTableType *rgba = GetRawLookupTable(); int i, num_of_values=m_LookupTable->GetNumberOfTableValues(); vtkFloatingPointType *alphas; vtkFloatingPointType *alphasHead; alphasHead=alphas=(vtkFloatingPointType*)malloc(sizeof(vtkFloatingPointType)*num_of_values); rgba+=3; for(i=0;iBuildFunctionFromTable(m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values-1, alphasHead); free(alphasHead); } void mitk::LookupTable::CreateGradientTransferFunction(vtkPiecewiseFunction*& gradientFunction) { if(gradientFunction==NULL) gradientFunction = vtkPiecewiseFunction::New(); mitk::LookupTable::RawLookupTableType *rgba = GetRawLookupTable(); int i, num_of_values=m_LookupTable->GetNumberOfTableValues(); vtkFloatingPointType *alphas; vtkFloatingPointType *alphasHead; alphasHead=alphas=(vtkFloatingPointType*)malloc(sizeof(vtkFloatingPointType)*num_of_values); rgba+=3; for(i=0;iBuildFunctionFromTable(m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values-1, alphasHead); free(alphasHead); } void mitk::LookupTable::PrintSelf(std::ostream &os, itk::Indent indent) const { os << indent; m_LookupTable->PrintHeader(os, vtkIndent()); } diff --git a/Core/Code/DataManagement/mitkNodePredicateDimension.h b/Core/Code/DataManagement/mitkNodePredicateDimension.h index 8ef88bc5a1..0be7f1406f 100644 --- a/Core/Code/DataManagement/mitkNodePredicateDimension.h +++ b/Core/Code/DataManagement/mitkNodePredicateDimension.h @@ -1,65 +1,65 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 11215 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKNODEPREDICATEDIMENSION_H_HEADER_INCLUDED_ #define MITKNODEPREDICATEDIMENSION_H_HEADER_INCLUDED_ #include "mitkNodePredicateBase.h" namespace mitk { class BaseData; //##Documentation //## @brief Predicate that evaluates if the given DataNodes data object //## has the specified dimension, for datasets where dimension is //## applicable. //## //## Evaluates to "false" for unsupported datasets. //## @ingroup DataStorage class MITK_CORE_EXPORT NodePredicateDimension : public NodePredicateBase { public: mitkClassMacro(NodePredicateDimension, NodePredicateBase); mitkNewMacro1Param(NodePredicateDimension, unsigned int); mitkNewMacro2Param(NodePredicateDimension, unsigned int, int); //##Documentation //## @brief Standard Destructor virtual ~NodePredicateDimension(); //##Documentation //## @brief Checks if the nodes data object is of the specified dimension virtual bool CheckNode(const mitk::DataNode* node) const; protected: //##Documentation //## @brief Standard Constructor NodePredicateDimension(unsigned int dimension); //##Documentation //## @brief Standard Constructor NodePredicateDimension(unsigned int dimension, int pixelComponents); unsigned int m_Dimension; - int m_PixelComponents; + std::size_t m_PixelComponents; }; } // namespace mitk #endif /* MITKNodePredicateDimension_H_HEADER_INCLUDED_ */ diff --git a/Core/Code/IO/mitkCoreDataNodeReader.cpp b/Core/Code/IO/mitkCoreDataNodeReader.cpp new file mode 100644 index 0000000000..536d5726df --- /dev/null +++ b/Core/Code/IO/mitkCoreDataNodeReader.cpp @@ -0,0 +1,49 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "mitkCoreDataNodeReader.h" + +#include +#include + +namespace mitk { + +int CoreDataNodeReader::Read(const std::string &fileName, DataStorage &storage) +{ + mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); + + // the ITK Nrrd file reader cannot handle '/' in file path on Win 64bit + std::string name(fileName); + std::replace(name.begin(), name.end(), '\\', '/'); + nodeReader->SetFileName(name); + nodeReader->Update(); + int n = 0; + for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) + { + mitk::DataNode::Pointer node; + node = nodeReader->GetOutput(i); + if ( node->GetData() != NULL ) + { + storage.Add(node); + ++n; + } + } + return n; +} + +} diff --git a/Core/Code/IO/mitkCoreDataNodeReader.h b/Core/Code/IO/mitkCoreDataNodeReader.h new file mode 100644 index 0000000000..1aad362380 --- /dev/null +++ b/Core/Code/IO/mitkCoreDataNodeReader.h @@ -0,0 +1,37 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKCOREDATANODEREADER_H +#define MITKCOREDATANODEREADER_H + +#include + +namespace mitk { + +class CoreDataNodeReader : public itk::LightObject, public mitk::IDataNodeReader +{ +public: + + itkNewMacro(CoreDataNodeReader) + + int Read(const std::string& fileName, mitk::DataStorage& storage); +}; + +} + +#endif // MITKCOREDATANODEREADER_H diff --git a/Core/Code/IO/mitkIOUtil.cpp b/Core/Code/IO/mitkIOUtil.cpp new file mode 100644 index 0000000000..e9cc3ff452 --- /dev/null +++ b/Core/Code/IO/mitkIOUtil.cpp @@ -0,0 +1,87 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "mitkIOUtil.h" + +#include +#include +#include +#include +#include + +namespace mitk { + +int IOUtil::LoadFiles(const std::vector &fileNames, DataStorage &ds) +{ + // Get the set of registered mitk::IDataNodeReader services + ModuleContext* context = GetModuleContext(); + const std::list refs = context->GetServiceReferences(); + std::vector services; + services.reserve(refs.size()); + for (std::list::const_iterator i = refs.begin(); + i != refs.end(); ++i) + { + IDataNodeReader* s = context->GetService(*i); + if (s != 0) + { + services.push_back(s); + } + } + + mitk::ProgressBar::GetInstance()->AddStepsToDo(2*fileNames.size()); + + // Iterate over all file names and use the IDataNodeReader services + // to load them. + int nodesRead = 0; + for (std::vector::const_iterator i = fileNames.begin(); + i != fileNames.end(); ++i) + { + for (std::vector::const_iterator readerIt = services.begin(); + readerIt != services.end(); ++readerIt) + { + try + { + int n = (*readerIt)->Read(*i, ds); + nodesRead += n; + if (n > 0) break; + } + catch (const std::exception& e) + { + MITK_WARN << e.what(); + } + } + mitk::ProgressBar::GetInstance()->Progress(2); + } + + for (std::list::const_iterator i = refs.begin(); + i != refs.end(); ++i) + { + context->UngetService(*i); + } + + return nodesRead; +} + +DataStorage::Pointer IOUtil::LoadFiles(const std::vector& fileNames) +{ + mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); + LoadFiles(fileNames, *ds); + return ds.GetPointer(); +} + +} diff --git a/Core/Code/IO/mitkIOUtil.h b/Core/Code/IO/mitkIOUtil.h new file mode 100644 index 0000000000..c9f087ac09 --- /dev/null +++ b/Core/Code/IO/mitkIOUtil.h @@ -0,0 +1,68 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKIOUTIL_H +#define MITKIOUTIL_H + +#include +#include + +namespace mitk { + +/** + * \ingroup IO + * + * \brief A utility class to load data from the local file system into a mitk::DataStorage. + * + * This class queries the MITK Micro Services registry for registered mitk::IDataNodeReader service + * instances. The service instance with the highest ranking will be asked first to load the + * given file. On error (exception thrown) or if no mitk::DataNode was constructed, the next + * service instance is used. + * + * \see mitk::IDataNodeReader + */ +class MITK_CORE_EXPORT IOUtil +{ + +public: + + /** + * Load a files in fileNames and add the constructed mitk::DataNode instances + * to the mitk::DataStorage storage + * + * \param fileNames A list (vector) of absolute file name paths. + * \param storage The data storage to which the constructed data nodes are added. + * \return The number of added mitk::DataNode instances. + */ + static int LoadFiles(const std::vector&fileNames, DataStorage& storage); + + /** + * This method will create a new mitk::DataStorage instance and pass it to + * LoadFiles(std::vector,DataStorage). + * + * \param fileNames A list (vector) of absolute file name paths. + * \return The new mitk::DataStorage containing the constructed data nodes. + * + * \see LoadFiles(std::vector,DataStorage) + */ + static DataStorage::Pointer LoadFiles(const std::vector& fileNames); +}; + +} + +#endif // MITKIOUTIL_H diff --git a/Core/Code/IO/mitkPixelType.cpp b/Core/Code/IO/mitkPixelType.cpp index 6fde910dd7..045109debd 100644 --- a/Core/Code/IO/mitkPixelType.cpp +++ b/Core/Code/IO/mitkPixelType.cpp @@ -1,150 +1,150 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPixelType.h" #include #include #include #include #include #include "itkDiffusionTensor3D.h" #define HUNDRED_VECS(HUN) \ TEN_VECS(HUN) \ TEN_VECS(HUN+10) \ TEN_VECS(HUN+20) \ TEN_VECS(HUN+30) \ TEN_VECS(HUN+40) \ TEN_VECS(HUN+50) \ TEN_VECS(HUN+60) \ TEN_VECS(HUN+70) \ TEN_VECS(HUN+80) \ TEN_VECS(HUN+90) \ #define TEN_VECS(TEN) \ if(false){} \ N_VEC(TEN+ 1) \ N_VEC(TEN+ 2) \ N_VEC(TEN+ 3) \ N_VEC(TEN+ 4) \ N_VEC(TEN+ 5) \ N_VEC(TEN+ 6) \ N_VEC(TEN+ 7) \ N_VEC(TEN+ 8) \ N_VEC(TEN+ 9) \ N_VEC(TEN+10) \ #define N_VEC(N_DIRS) \ _N_VEC(N_DIRS,double) \ _N_VEC(N_DIRS,float) \ _N_VEC(N_DIRS,short) \ #define _N_VEC(N_DIRS,PIXTYPE) \ else if ( *m_TypeId == typeid( itk::Vector )) \ { \ found = true; \ m_TypeId = & typeid( PIXTYPE ); \ m_NumberOfComponents *= N_DIRS; \ m_Type = mitkIpPicFloat; \ m_Bpe = sizeof(PIXTYPE) * 8 * m_NumberOfComponents; \ m_ItkTypeId = &typeid( itk::Vector ); \ } \ mitk::PixelType::PixelType( const mitk::PixelType& other ) : m_ComponentType( other.m_ComponentType ), m_PixelType( other.m_PixelType), m_ComponentTypeName( other.m_ComponentTypeName ), m_PixelTypeName( other.m_PixelTypeName ), - m_BytesPerComponent( other.m_BytesPerComponent ), - m_NumberOfComponents( other.m_NumberOfComponents ) + m_NumberOfComponents( other.m_NumberOfComponents ), + m_BytesPerComponent( other.m_BytesPerComponent ) { } bool mitk::PixelType::operator==(const mitk::PixelType& rhs) const { MITK_DEBUG << "operator==" << std::endl; MITK_DEBUG << "m_NumberOfComponents = " << m_NumberOfComponents << " " << rhs.m_NumberOfComponents << std::endl; MITK_DEBUG << "m_BytesPerComponent = " << m_BytesPerComponent << " " << rhs.m_BytesPerComponent << std::endl; return ( this->m_PixelType == rhs.m_PixelType && this->m_ComponentType == rhs.m_ComponentType && this->m_NumberOfComponents == rhs.m_NumberOfComponents && this->m_BytesPerComponent == rhs.m_BytesPerComponent ); } bool mitk::PixelType::operator ==(const std::type_info& typeId) const { if( m_NumberOfComponents ==1 ) return (m_ComponentType == typeId); else return (m_PixelType == typeId); } bool mitk::PixelType::operator!=(const mitk::PixelType& rhs) const { return !(this->operator==(rhs)); } bool mitk::PixelType::operator!=(const std::type_info& typeId) const { return !(this->operator==(typeId)); } #define SET_ITK_TYPE_ID(anItkIoPixelType_test, numberOfComponents_test, ITK_TYPE) \ if ( (itk::ImageIOBase::anItkIoPixelType_test == anItkIoPixelType ) && \ (numberOfComponents_test == m_NumberOfComponents) \ ) \ { * \ m_ItkTypeId = &typeid(ITK_TYPE); \ } #define SET_TYPE(TYPE, IPPIC_TYPE) \ if ( *m_TypeId == typeid( TYPE ) ) \ { \ m_Type = IPPIC_TYPE; \ m_Bpe = sizeof(TYPE) * 8 * m_NumberOfComponents; \ \ typedef itk::Vector Vector3Type; \ typedef itk::CovariantVector CovariantVector3Type; \ typedef itk::Point Point3Type; \ typedef itk::Vector Vector2Type; \ typedef itk::CovariantVector CovariantVector2Type; \ typedef itk::Point Point2Type; \ \ SET_ITK_TYPE_ID(UNKNOWNPIXELTYPE, 1, TYPE ) else \ SET_ITK_TYPE_ID(SCALAR, 1, TYPE ) else \ \ SET_ITK_TYPE_ID(VECTOR, 2, Vector2Type ) else \ SET_ITK_TYPE_ID(COVARIANTVECTOR, 2, CovariantVector2Type ) else \ SET_ITK_TYPE_ID(POINT, 2, Point2Type ) else \ \ SET_ITK_TYPE_ID(RGB, 3, itk::RGBPixel ) else \ /*SET_ITK_TYPE_ID(DIFFUSIONTENSOR3D, 6, itk::DiffusionTensor3D ) else */ \ SET_ITK_TYPE_ID(VECTOR, 3, Vector3Type ) else \ SET_ITK_TYPE_ID(COVARIANTVECTOR, 3, CovariantVector3Type ) else \ SET_ITK_TYPE_ID(POINT, 3, Point3Type ) else \ \ SET_ITK_TYPE_ID(RGBA, 4, itk::RGBAPixel ) else \ { \ } \ } \ else diff --git a/Core/Code/Interactions/mitkDisplayInteractor.cpp b/Core/Code/Interactions/mitkDisplayInteractor.cpp index a19babfd90..f927d42a6d 100644 --- a/Core/Code/Interactions/mitkDisplayInteractor.cpp +++ b/Core/Code/Interactions/mitkDisplayInteractor.cpp @@ -1,91 +1,91 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkDisplayInteractor.h" #include #include #include #include #include #include #include #include #include mitk::DisplayInteractor::DisplayInteractor(mitk::BaseRenderer * ren) { m_ParentRenderer = ren; } void mitk::DisplayInteractor::ExecuteOperation(mitk::Operation * operation) { - bool ok;//as return type + //bool ok;//as return type mitk::DisplayCoordinateOperation* dcOperation=dynamic_cast(operation); if ( dcOperation != NULL ) { /****ZOOM & MOVE of the whole volume****/ mitk::BaseRenderer* renderer = dcOperation->GetRenderer(); if( renderer == NULL || (m_ParentRenderer != NULL && m_ParentRenderer != renderer)) return; switch (operation->GetOperationType()) { case OpMOVE : { renderer->GetDisplayGeometry()->MoveBy(dcOperation->GetLastToCurrentDisplayVector()*(-1.0)); renderer->GetRenderingManager()->RequestUpdate(renderer->GetRenderWindow()); - ok = true; + //ok = true; } break; case OpZOOM : { float distance = dcOperation->GetLastToCurrentDisplayVector()[1]; //float factor= 1.0 + distance * 0.05; // stupid because factors from +1 and -1 dont give results that represent inverse zooms float factor = 1.0; if (distance < 0.0) { factor = 1.0 / 1.05; } else if (distance > 0.0) { factor = 1.0 * 1.05; // 5% } else // distance == 0.0 { // nothing to do, factor remains 1.0 } renderer->GetDisplayGeometry()->ZoomWithFixedWorldCoordinates(factor, dcOperation->GetStartDisplayCoordinate(), dcOperation->GetStartCoordinateInMM()); renderer->GetRenderingManager()->RequestUpdate(renderer->GetRenderWindow()); - ok = true; + //ok = true; } break; default: ; } } } diff --git a/Core/Code/Interactions/mitkEventMapper.cpp b/Core/Code/Interactions/mitkEventMapper.cpp index b97bcf57d2..63dcd8e325 100644 --- a/Core/Code/Interactions/mitkEventMapper.cpp +++ b/Core/Code/Interactions/mitkEventMapper.cpp @@ -1,700 +1,700 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * EventMapping: * This class maps the Events, usually given by the OS or here by QT, to a MITK internal EventId. * It loads all information from the xml-file (possible, understandable Events with the mitkEventID). * If an event appears, the method MapEvent is called with the event params. * This Method looks up the event params, and tries to find an mitkEventId to it. * If yes, then sends the event and the found ID to the globalStateMachine, which handles all * further operations of that event. * */ #include "mitkEventMapper.h" #include "mitkInteractionConst.h" #include "mitkStateEvent.h" #include "mitkOperationEvent.h" #include "mitkGlobalInteraction.h" #include #include "mitkStandardFileLocations.h" //#include #include "mitkConfig.h" #include "mitkCoreObjectFactory.h" #include #include #include #include namespace mitk { vtkStandardNewMacro(EventMapper); } #ifdef MBI_INTERNAL_CONFERENCE #include #include #include #include #include #endif //MBI_INTERNAL_CONFERENCE //XML Event const std::string mitk::EventMapper::STYLE = "STYLE"; const std::string mitk::EventMapper::NAME = "NAME"; const std::string mitk::EventMapper::ID = "ID"; const std::string mitk::EventMapper::TYPE = "TYPE"; const std::string mitk::EventMapper::BUTTON = "BUTTON"; const std::string mitk::EventMapper::BUTTONSTATE = "BUTTONSTATE"; const std::string mitk::EventMapper::KEY = "KEY"; const std::string mitk::EventMapper::EVENTS = "events"; const std::string mitk::EventMapper::EVENT = "event"; mitk::EventMapper::EventDescriptionVec mitk::EventMapper::m_EventDescriptions; std::string mitk::EventMapper::m_XmlFileName; mitk::StateEvent mitk::EventMapper::m_StateEvent; std::string mitk::EventMapper::m_StyleName; struct ltstr { bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; } }; mitk::EventMapper::EventMapper() { //map with string to key for mapping string from xml-file to int m_EventConstMap["Type_None"] = mitk::Type_None; // invalid event m_EventConstMap["Type_Timer"] = mitk::Type_Timer; // timer event m_EventConstMap["Type_MouseButtonPress"] = mitk::Type_MouseButtonPress; // mouse button pressed m_EventConstMap["Type_MouseButtonRelease"] = mitk::Type_MouseButtonRelease; // mouse button released m_EventConstMap["Type_MouseButtonDblClick"] = mitk::Type_MouseButtonDblClick; // mouse button double click m_EventConstMap["Type_MouseMove"] = mitk::Type_MouseMove; // mouse move m_EventConstMap["Type_KeyPress"] = mitk::Type_KeyPress; // key pressed m_EventConstMap["Type_KeyRelease"] = mitk::Type_KeyRelease; // key released m_EventConstMap["Type_FocusIn"] = 8; // keyboard focus received m_EventConstMap["Type_FocusOut"] = 9; // keyboard focus lost m_EventConstMap["Type_Enter"] = 10; // mouse enters widget m_EventConstMap["Type_Leave"] = 11; // mouse leaves widget m_EventConstMap["Type_Paint"] = 12; // paint widget m_EventConstMap["Type_Move"] = 13; // move widget m_EventConstMap["Type_Resize"] = 14; // resize widget m_EventConstMap["Type_Create"] = 15; // after object creation m_EventConstMap["Type_Destroy"] = 16; // during object destruction m_EventConstMap["Type_Show"] = 17; // widget is shown m_EventConstMap["Type_Hide"] = 18; // widget is hidden m_EventConstMap["Type_Close"] = 19; // request to close widget m_EventConstMap["Type_Quit"] = 20; // request to quit application m_EventConstMap["Type_Reparent"] = 21; // widget has been reparented m_EventConstMap["Type_ShowMinimized"] = 22; // widget is shown minimized m_EventConstMap["Type_ShowNormal"] = 23; // widget is shown normal m_EventConstMap["Type_WindowActivate"] = 24; // window was activated m_EventConstMap["Type_WindowDeactivate"] = 25; // window was deactivated m_EventConstMap["Type_ShowToParent"] = 26; // widget is shown to parent m_EventConstMap["Type_HideToParent"] = 27; // widget is hidden to parent m_EventConstMap["Type_ShowMaximized"] = 28; // widget is shown maximized m_EventConstMap["Type_ShowFullScreen"] = 29; // widget is shown full-screen m_EventConstMap["Type_Accel"] = 30; // accelerator event m_EventConstMap["Type_Wheel"] = 31; // wheel event m_EventConstMap["Type_AccelAvailable"] = 32; // accelerator available event m_EventConstMap["Type_CaptionChange"] = 33; // caption changed m_EventConstMap["Type_IconChange"] = 34; // icon changed m_EventConstMap["Type_ParentFontChange"] = 35; // parent font changed m_EventConstMap["Type_ApplicationFontChange"] = 36;// application font changed m_EventConstMap["Type_ParentPaletteChange"] = 37; // parent palette changed m_EventConstMap["Type_ApplicationPaletteChange"] = 38;// application palette changed m_EventConstMap["Type_PaletteChange"] = 39; // widget palette changed m_EventConstMap["Type_Clipboard"] = 40; // internal clipboard event m_EventConstMap["Type_Speech"] = 42; // reserved for speech input m_EventConstMap["Type_SockAct"] = 50; // socket activation m_EventConstMap["Type_AccelOverride"] = 51; // accelerator override event m_EventConstMap["Type_DeferredDelete"] = 52; // deferred delete event m_EventConstMap["Type_DragEnter"] = 60; // drag moves into widget m_EventConstMap["Type_DragMove"] = 61; // drag moves in widget m_EventConstMap["Type_DragLeave"] = 62; // drag leaves or is cancelled m_EventConstMap["Type_Drop"] = 63; // actual drop m_EventConstMap["Type_DragResponse"] = 64; // drag accepted/rejected m_EventConstMap["Type_ChildInserted"] = 70; // new child widget m_EventConstMap["Type_ChildRemoved"] = 71; // deleted child widget m_EventConstMap["Type_LayoutHint"] = 72; // child min/max size changed m_EventConstMap["Type_ShowWindowRequest"] = 73; // widget's window should be mapped m_EventConstMap["Type_ActivateControl"] = 80; // ActiveX activation m_EventConstMap["Type_DeactivateControl"] = 81; // ActiveX deactivation m_EventConstMap["Type_ContextMenu"] = 82; // context popup menu m_EventConstMap["Type_IMStart"] = 83; // input method composition start m_EventConstMap["Type_IMCompose"] = 84; // input method composition m_EventConstMap["Type_IMEnd"] = 85; // input method composition end m_EventConstMap["Type_Accessibility"] = 86; // accessibility information is requested m_EventConstMap["Type_TabletMove"] = 87; // Wacom tablet event m_EventConstMap["Type_LocaleChange"] = 88; // the system locale changed m_EventConstMap["Type_LanguageChange"] = 89; // the application language changed m_EventConstMap["Type_LayoutDirectionChange"] = 90; // the layout direction changed m_EventConstMap["Type_Style"] = 91; // internal style event m_EventConstMap["Type_TabletPress"] = 92; // tablet press m_EventConstMap["Type_TabletRelease"] = 93; // tablet release // apparently not necessary, since the IDs can be assigned earlier (in the AddOns after they are generated in the driver) //m_EventConstMap["Type_TDMouseInput"] = mitk::Type_TDMouseInput; // 3D mouse input occured m_EventConstMap["Type_User"] = 1000; // first user event id m_EventConstMap["Type_MaxUser"] = 65535; // last user event id //ButtonState m_EventConstMap["BS_NoButton"] = mitk::BS_NoButton;//0x0000 m_EventConstMap["BS_LeftButton"] = mitk::BS_LeftButton;//0x0001 m_EventConstMap["BS_RightButton"] = mitk::BS_RightButton;//0x0002 m_EventConstMap["BS_MidButton"] = mitk::BS_MidButton;//0x0004 m_EventConstMap["BS_MouseButtonMask"] = mitk::BS_MouseButtonMask;//0x0007 m_EventConstMap["BS_ShiftButton"] = mitk::BS_ShiftButton;//0x0008 m_EventConstMap["BS_ControlButton"] = mitk::BS_ControlButton;//0x0010 m_EventConstMap["BS_AltButton"] = mitk::BS_AltButton;//0x0020 m_EventConstMap["BS_KeyButtonMask"] = mitk::BS_KeyButtonMask;//0x0038 m_EventConstMap["BS_Keypad"] = mitk::BS_Keypad;//0x4000 //Modifier m_EventConstMap["Mod_SHIFT"] = 0x00200000; m_EventConstMap["Mod_CTRL"] = 0x00400000; m_EventConstMap["Mod_ALT"] = 0x00800000; m_EventConstMap["Mod_MODIFIER_MASK"] = 0x00e00000; m_EventConstMap["Mod_UNICODE_ACCEL"] = 0x10000000; m_EventConstMap["Mod_ASCII_ACCEL"] = 0x10000000; //Key m_EventConstMap["Key_Escape"] = 0x1000; m_EventConstMap["Key_Tab"] = 0x1001; m_EventConstMap["Key_Backtab"] = 0x1002; m_EventConstMap["Key_BackTab"] = 0x1002; m_EventConstMap["Key_Backspace"] = 0x1003; m_EventConstMap["Key_BackSpace"] = 0x1003; m_EventConstMap["Key_Return"] = 0x1004; m_EventConstMap["Key_Enter"] = 0x1005; m_EventConstMap["Key_Insert"] = 0x1006; m_EventConstMap["Key_Delete"] = 0x1007; m_EventConstMap["Key_Pause"] = 0x1008; m_EventConstMap["Key_Print"] = 0x1009; m_EventConstMap["Key_SysReq"] = 0x100a; m_EventConstMap["Key_Home"] = 0x1010; m_EventConstMap["Key_End"] = 0x1011; m_EventConstMap["Key_Left"] = 0x1012; m_EventConstMap["Key_Up"] = 0x1013; m_EventConstMap["Key_Right"] = 0x1014; m_EventConstMap["Key_Down"] = 0x1015; m_EventConstMap["Key_Prior"] = 0x1016; m_EventConstMap["Key_PageUp"] = 0x1016; m_EventConstMap["Key_Next"] = 0x1017; m_EventConstMap["Key_PageDown"] = 0x1017; m_EventConstMap["Key_Shift"] = 0x1020; m_EventConstMap["Key_Control"] = 0x1021; m_EventConstMap["Key_Meta"] = 0x1022; m_EventConstMap["Key_Alt"] = 0x1023; m_EventConstMap["Key_CapsLock"] = 0x1024; m_EventConstMap["Key_NumLock"] = 0x1025; m_EventConstMap["Key_ScrollLock"] = 0x1026; m_EventConstMap["Key_F1"] = 0x1030; m_EventConstMap["Key_F2"] = 0x1031; m_EventConstMap["Key_F3"] = 0x1032; m_EventConstMap["Key_F4"] = 0x1033; m_EventConstMap["Key_F5"] = 0x1034; m_EventConstMap["Key_F6"] = 0x1035; m_EventConstMap["Key_F7"] = 0x1036; m_EventConstMap["Key_F8"] = 0x1037; m_EventConstMap["Key_F9"] = 0x1038; m_EventConstMap["Key_F10"] = 0x1039; m_EventConstMap["Key_F11"] = 0x103a; m_EventConstMap["Key_F12"] = 0x103b; m_EventConstMap["Key_F13"] = 0x103c; m_EventConstMap["Key_F14"] = 0x103d; m_EventConstMap["Key_F15"] = 0x103e; m_EventConstMap["Key_F16"] = 0x103f; m_EventConstMap["Key_F17"] = 0x1040; m_EventConstMap["Key_F18"] = 0x1041; m_EventConstMap["Key_F19"] = 0x1042; m_EventConstMap["Key_F20"] = 0x1043; m_EventConstMap["Key_F21"] = 0x1044; m_EventConstMap["Key_F22"] = 0x1045; m_EventConstMap["Key_F23"] = 0x1046; m_EventConstMap["Key_F24"] = 0x1047; m_EventConstMap["Key_F25"] = 0x1048; m_EventConstMap["Key_F26"] = 0x1049; m_EventConstMap["Key_F27"] = 0x104a; m_EventConstMap["Key_F28"] = 0x104b; m_EventConstMap["Key_F29"] = 0x104c; m_EventConstMap["Key_F30"] = 0x104d; m_EventConstMap["Key_F31"] = 0x104e; m_EventConstMap["Key_F32"] = 0x104f; m_EventConstMap["Key_F33"] = 0x1050; m_EventConstMap["Key_F34"] = 0x1051; m_EventConstMap["Key_F35"] = 0x1052; m_EventConstMap["Key_Super_L"] = 0x1053; m_EventConstMap["Key_Super_R"] = 0x1054; m_EventConstMap["Key_Menu"] = 0x1055; m_EventConstMap["Key_Hyper_L"] = 0x1056; m_EventConstMap["Key_Hyper_R"] = 0x1057; m_EventConstMap["Key_Help"] = 0x1058; m_EventConstMap["Key_Muhenkan"] = 0x1122; m_EventConstMap["Key_Henkan"] = 0x1123; m_EventConstMap["Key_Hiragana_Katakana"] = 0x1127; m_EventConstMap["Key_Zenkaku_Hankaku"] = 0x112A; m_EventConstMap["Key_Space"] = 0x20; m_EventConstMap["Key_Any"] = 0x20; m_EventConstMap["Key_Exclam"] = 0x21; m_EventConstMap["Key_QuoteDbl"] = 0x22; m_EventConstMap["Key_NumberSign"] = 0x23; m_EventConstMap["Key_Dollar"] = 0x24; m_EventConstMap["Key_Percent"] = 0x25; m_EventConstMap["Key_Ampersand"] = 0x26; m_EventConstMap["Key_Apostrophe"] = 0x27; m_EventConstMap["Key_ParenLeft"] = 0x28; m_EventConstMap["Key_ParenRight"] = 0x29; m_EventConstMap["Key_Asterisk"] = 0x2a; m_EventConstMap["Key_Plus"] = 0x2b; m_EventConstMap["Key_Comma"] = 0x2c; m_EventConstMap["Key_Minus"] = 0x2d; m_EventConstMap["Key_Period"] = 0x2e; m_EventConstMap["Key_Slash"] = 0x2f; m_EventConstMap["Key_0"] = 0x30; m_EventConstMap["Key_1"] = 0x31; m_EventConstMap["Key_2"] = 0x32; m_EventConstMap["Key_3"] = 0x33; m_EventConstMap["Key_4"] = 0x34; m_EventConstMap["Key_5"] = 0x35; m_EventConstMap["Key_6"] = 0x36; m_EventConstMap["Key_7"] = 0x37; m_EventConstMap["Key_8"] = 0x38; m_EventConstMap["Key_9"] = 0x39; m_EventConstMap["Key_Colon"] = 0x3a; m_EventConstMap["Key_Semicolon"] = 0x3b; m_EventConstMap["Key_Less"] = 0x3c; m_EventConstMap["Key_Equal"] = 0x3d; m_EventConstMap["Key_Greater"] = 0x3e; m_EventConstMap["Key_Question"] = 0x3f; m_EventConstMap["Key_At"] = 0x40; m_EventConstMap["Key_A"] = 0x41; m_EventConstMap["Key_B"] = 0x42; m_EventConstMap["Key_C"] = 0x43; m_EventConstMap["Key_D"] = 0x44; m_EventConstMap["Key_E"] = 0x45; m_EventConstMap["Key_F"] = 0x46; m_EventConstMap["Key_G"] = 0x47; m_EventConstMap["Key_H"] = 0x48; m_EventConstMap["Key_I"] = 0x49; m_EventConstMap["Key_J"] = 0x4a; m_EventConstMap["Key_K"] = 0x4b; m_EventConstMap["Key_L"] = 0x4c; m_EventConstMap["Key_M"] = 0x4d; m_EventConstMap["Key_N"] = 0x4e; m_EventConstMap["Key_O"] = 0x4f; m_EventConstMap["Key_P"] = 0x50; m_EventConstMap["Key_Q"] = 0x51; m_EventConstMap["Key_R"] = 0x52; m_EventConstMap["Key_S"] = 0x53; m_EventConstMap["Key_T"] = 0x54; m_EventConstMap["Key_U"] = 0x55; m_EventConstMap["Key_V"] = 0x56; m_EventConstMap["Key_W"] = 0x57; m_EventConstMap["Key_X"] = 0x58; m_EventConstMap["Key_Y"] = 0x59; m_EventConstMap["Key_Z"] = 0x5a; m_EventConstMap["Key_BracketLeft"] = 0x5b; m_EventConstMap["Key_Backslash"] = 0x5c; m_EventConstMap["Key_BracketRight"] = 0x5d; m_EventConstMap["Key_AsciiCircum"] = 0x5e; m_EventConstMap["Key_Underscore"] = 0x5f; m_EventConstMap["Key_QuoteLeft"] = 0x60; m_EventConstMap["Key_BraceLeft"] = 0x7b; m_EventConstMap["Key_Bar"] = 0x7c; m_EventConstMap["Key_BraceRight"] = 0x7d; m_EventConstMap["Key_AsciiTilde"] = 0x7e; m_EventConstMap["Key_nobreakspace"] = 0x0a0; m_EventConstMap["Key_exclamdown"] = 0x0a1; m_EventConstMap["Key_cent"] = 0x0a2; m_EventConstMap["Key_sterling"] = 0x0a3; m_EventConstMap["Key_currency"] = 0x0a4; m_EventConstMap["Key_yen"] = 0x0a5; m_EventConstMap["Key_brokenbar"] = 0x0a6; m_EventConstMap["Key_section"] = 0x0a7; m_EventConstMap["Key_diaeresis"] = 0x0a8; m_EventConstMap["Key_copyright"] = 0x0a9; m_EventConstMap["Key_ordfeminine"] = 0x0aa; m_EventConstMap["Key_guillemotleft"] = 0x0ab; m_EventConstMap["Key_notsign"] = 0x0ac; m_EventConstMap["Key_hyphen"] = 0x0ad; m_EventConstMap["Key_registered"] = 0x0ae; m_EventConstMap["Key_macron"] = 0x0af; m_EventConstMap["Key_degree"] = 0x0b0; m_EventConstMap["Key_plusminus"] = 0x0b1; m_EventConstMap["Key_twosuperior"] = 0x0b2; m_EventConstMap["Key_threesuperior"] = 0x0b3; m_EventConstMap["Key_acute"] = 0x0b4; m_EventConstMap["Key_mu"] = 0x0b5; m_EventConstMap["Key_paragraph"] = 0x0b6; m_EventConstMap["Key_periodcentered"] = 0x0b7; m_EventConstMap["Key_cedilla"] = 0x0b8; m_EventConstMap["Key_onesuperior"] = 0x0b9; m_EventConstMap["Key_masculine"] = 0x0ba; m_EventConstMap["Key_guillemotright"] = 0x0bb; m_EventConstMap["Key_onequarter"] = 0x0bc; m_EventConstMap["Key_onehalf"] = 0x0bd; m_EventConstMap["Key_threequarters"] = 0x0be; m_EventConstMap["Key_questiondown"] = 0x0bf; m_EventConstMap["Key_Agrave"] = 0x0c0; m_EventConstMap["Key_Aacute"] = 0x0c1; m_EventConstMap["Key_Acircumflex"] = 0x0c2; m_EventConstMap["Key_Atilde"] = 0x0c3; m_EventConstMap["Key_Adiaeresis"] = 0x0c4; m_EventConstMap["Key_Aring"] = 0x0c5; m_EventConstMap["Key_AE"] = 0x0c6; m_EventConstMap["Key_Ccedilla"] = 0x0c7; m_EventConstMap["Key_Egrave"] = 0x0c8; m_EventConstMap["Key_Eacute"] = 0x0c9; m_EventConstMap["Key_Ecircumflex"] = 0x0ca; m_EventConstMap["Key_Ediaeresis"] = 0x0cb; m_EventConstMap["Key_Igrave"] = 0x0cc; m_EventConstMap["Key_Iacute"] = 0x0cd; m_EventConstMap["Key_Icircumflex"] = 0x0ce; m_EventConstMap["Key_Idiaeresis"] = 0x0cf; m_EventConstMap["Key_ETH"] = 0x0d0; m_EventConstMap["Key_Ntilde"] = 0x0d1; m_EventConstMap["Key_Ograve"] = 0x0d2; m_EventConstMap["Key_Oacute"] = 0x0d3; m_EventConstMap["Key_Ocircumflex"] = 0x0d4; m_EventConstMap["Key_Otilde"] = 0x0d5; m_EventConstMap["Key_Odiaeresis"] = 0x0d6; m_EventConstMap["Key_multiply"] = 0x0d7; m_EventConstMap["Key_Ooblique"] = 0x0d8; m_EventConstMap["Key_Ugrave"] = 0x0d9; m_EventConstMap["Key_Uacute"] = 0x0da; m_EventConstMap["Key_Ucircumflex"] = 0x0db; m_EventConstMap["Key_Udiaeresis"] = 0x0dc; m_EventConstMap["Key_Yacute"] = 0x0dd; m_EventConstMap["Key_THORN"] = 0x0de; m_EventConstMap["Key_ssharp"] = 0x0df; m_EventConstMap["Key_agrave"] = 0x0e0; m_EventConstMap["Key_aacute"] = 0x0e1; m_EventConstMap["Key_acircumflex"] = 0x0e2; m_EventConstMap["Key_atilde"] = 0x0e3; m_EventConstMap["Key_adiaeresis"] = 0x0e4; m_EventConstMap["Key_aring"] = 0x0e5; m_EventConstMap["Key_ae"] = 0x0e6; m_EventConstMap["Key_ccedilla"] = 0x0e7; m_EventConstMap["Key_egrave"] = 0x0e8; m_EventConstMap["Key_eacute"] = 0x0e9; m_EventConstMap["Key_ecircumflex"] = 0x0ea; m_EventConstMap["Key_ediaeresis"] = 0x0eb; m_EventConstMap["Key_igrave"] = 0x0ec; m_EventConstMap["Key_iacute"] = 0x0ed; m_EventConstMap["Key_icircumflex"] = 0x0ee; m_EventConstMap["Key_idiaeresis"] = 0x0ef; m_EventConstMap["Key_eth"] = 0x0f0; m_EventConstMap["Key_ntilde"] = 0x0f1; m_EventConstMap["Key_ograve"] = 0x0f2; m_EventConstMap["Key_oacute"] = 0x0f3; m_EventConstMap["Key_ocircumflex"] = 0x0f4; m_EventConstMap["Key_otilde"] = 0x0f5; m_EventConstMap["Key_odiaeresis"] = 0x0f6; m_EventConstMap["Key_division"] = 0x0f7; m_EventConstMap["Key_oslash"] = 0x0f8; m_EventConstMap["Key_ugrave"] = 0x0f9; m_EventConstMap["Key_uacute"] = 0x0fa; m_EventConstMap["Key_ucircumflex"] = 0x0fb; m_EventConstMap["Key_udiaeresis"] = 0x0fc; m_EventConstMap["Key_yacute"] = 0x0fd; m_EventConstMap["Key_thorn"] = 0x0fe; m_EventConstMap["Key_ydiaeresis"] = 0x0ff; m_EventConstMap["Key_unknown"] = 0xffff; m_EventConstMap["Key_none"] = 0xffff; } mitk::EventMapper::~EventMapper() { } //##Documentation //## searches for the event in m_EventDescription and adds the corresponding eventID //## bool mitk::EventMapper::MapEvent(Event* event, GlobalInteraction* globalInteraction, int mitkPostedEventID ) { int eventID = mitkPostedEventID; if( mitkPostedEventID == 0 ) { //search the event in the list of event descriptions, if found, then take the number and produce a stateevent EventDescriptionVecIter iter; for (iter = m_EventDescriptions.begin(); iter!=m_EventDescriptions.end();iter++) { if (*iter == *event) break; } if (iter == m_EventDescriptions.end())//not found return false; eventID = (*iter).GetId(); } //set the Menger_Var m_StateEvent and send to StateMachine, which does everything further! m_StateEvent.Set( eventID, event ); /* Group and Object EventId: then EventMapper has the power to decide which operations hang together; each event causes n (n e N) operations (e.g. StateChanges, data-operations...). Undo must recall all these coherent operations, so all of the same objectId. But Undo has also the power to recall more operationsets, for example a set for building up a new object, so that a newly build up object is deleted after a Undo and not only the latest set point. The StateMachines::ExecuteAction have the power to descide weather a new GroupID has to be calculated (by example after the editing of a new object) A user interaction with the mouse is started by a mousePressEvent, continues with a MouseMove and finishes with a MouseReleaseEvent */ switch (event->GetType()) { case mitk::Type_MouseButtonPress://Increase mitk::OperationEvent::IncCurrObjectEventId(); break; case mitk::Type_MouseMove://same break; case mitk::Type_MouseButtonRelease://same break; case mitk::Type_User://same break; case mitk::Type_KeyPress://Increase mitk::OperationEvent::IncCurrObjectEventId(); break; default://increase mitk::OperationEvent::IncCurrObjectEventId(); } #ifdef MBI_INTERNAL_CONFERENCE //Conference - pass local events through if ( mitkPostedEventID == 0 ) { mitk::CoreObjectFactory::GetInstance()->MapEvent(event,eventID); } #endif //MBI_INTERNAL_CONFERENCE mitk::OperationEvent::ExecuteIncrement(); if ( globalInteraction != NULL ) { return globalInteraction->HandleEvent( &m_StateEvent ); } else { return mitk::GlobalInteraction::GetInstance()->HandleEvent(&m_StateEvent); } } bool mitk::EventMapper::LoadBehavior(std::string fileName) { if ( fileName.empty() ) return false; if (m_XmlFileName.length() > 0) { if (fileName.compare(m_XmlFileName) == 0) return true; // this is nothing bad, we already loaded this file. } this->SetFileName( fileName.c_str() ); m_XmlFileName = fileName.c_str(); return ( this->Parse() ); } bool mitk::EventMapper::LoadBehaviorString(std::string xmlString) { if ( xmlString.empty() ) return false; return ( this->Parse(xmlString.c_str(), xmlString.length()) ); } bool mitk::EventMapper::LoadStandardBehavior() { // Search for StateMachine.xml, bypass relative path in mitkSourceTree for additional search std::string xmlFileName = mitk::StandardFileLocations::GetInstance()->FindFile("StateMachine.xml", "Core/Code/Interactions"); if(xmlFileName != "") return LoadBehavior(xmlFileName); return false; } //##Documentation //## @brief converts the given const String declared in the xml-file //## to the defined const int inline int mitk::EventMapper::convertConstString2ConstInt(std::string input) { ConstMapIter tempIt = m_EventConstMap.find(input.c_str()); if (tempIt != m_EventConstMap.end()) { return (tempIt)->second; } //mitk::StatusBar::GetInstance()->DisplayText("Warning! from mitkEventMapper.cpp: Couldn't find matching Event Int from Event String in XML-File"); return -1;//for didn't find anything } void mitk::EventMapper::StartElement (const char *elementName, const char **atts) { if ( elementName == EVENT ) { // EventDescription(int type, int button, int buttonState,int key, std::string name, int id) EventDescription eventDescr( convertConstString2ConstInt( ReadXMLStringAttribut( TYPE, atts )), convertConstString2ConstInt( ReadXMLStringAttribut( BUTTON, atts )), ReadXMLIntegerAttribut( BUTTONSTATE, atts ), convertConstString2ConstInt( ReadXMLStringAttribut( KEY, atts )), ReadXMLStringAttribut( NAME, atts ), ReadXMLIntegerAttribut( ID, atts )); //check for a double entry unless it is an event for internal usage if (eventDescr.GetType()!= mitk::Type_User) { for (EventDescriptionVecIter iter = m_EventDescriptions.begin(); iter!=m_EventDescriptions.end(); iter++) { if (*iter == eventDescr) { - STATEMACHINE_WARN<<"Event description " << eventDescr.GetName() << " already present! Skipping event description"; + MITK_WARN << "Event description " << eventDescr.GetName() << " already present! Skipping event description"; return; } } } m_EventDescriptions.push_back(eventDescr); } else if ( elementName == EVENTS ) m_StyleName = ReadXMLStringAttribut( STYLE, atts ); } std::string mitk::EventMapper::GetStyleName() const { return m_StyleName; } std::string mitk::EventMapper::ReadXMLStringAttribut( std::string name, const char** atts ) { if(atts) { const char** attsIter = atts; while(*attsIter) { if ( name == *attsIter ) { attsIter++; return *attsIter; } attsIter++; attsIter++; } } return std::string(); } int mitk::EventMapper::ReadXMLIntegerAttribut( std::string name, const char** atts ) { std::string s = ReadXMLStringAttribut( name, atts ); static const std::string hex = "0x"; int result; if ( s[0] == hex[0] && s[1] == hex[1] ) result = strtol( s.c_str(), NULL, 16 ); else result = atoi( s.c_str() ); return result; } void mitk::EventMapper::SetStateEvent(mitk::Event* event) { m_StateEvent.Set( m_StateEvent.GetId(), event ); } bool mitk::EventMapper::RefreshStateEvent(mitk::StateEvent* stateEvent) { //search the event within stateEvent in the list of event descriptions, if found adapt stateEvent ID EventDescriptionVecIter iter; for (iter = m_EventDescriptions.begin(); iter!=m_EventDescriptions.end(); iter++) { if (*iter == *(stateEvent->GetEvent())) break; } if (iter != m_EventDescriptions.end())//found { stateEvent->Set((*iter).GetId(), stateEvent->GetEvent()); return true; } else return false; return false; } void mitk::EventMapper::AddEventMapperAddOn(mitk::EventMapperAddOn* newAddOn) { bool addOnAlreadyAdded = false; for(AddOnVectorType::const_iterator it = this->m_AddOnVector.begin();it != m_AddOnVector.end();it++) { if(*it == newAddOn) { addOnAlreadyAdded = true; break; } } if(!addOnAlreadyAdded) { m_AddOnVector.push_back(newAddOn); MITK_INFO << "AddOn Count: " << m_AddOnVector.size(); } } void mitk::EventMapper::RemoveEventMapperAddOn(mitk::EventMapperAddOn* unusedAddOn) { for(AddOnVectorType::iterator it = this->m_AddOnVector.begin();it != m_AddOnVector.end();it++) { if(*it == unusedAddOn) { m_AddOnVector.erase(it); break; } } } diff --git a/Core/Code/Interactions/mitkPointSetInteractor.cpp b/Core/Code/Interactions/mitkPointSetInteractor.cpp index a350342d58..b726c279a2 100644 --- a/Core/Code/Interactions/mitkPointSetInteractor.cpp +++ b/Core/Code/Interactions/mitkPointSetInteractor.cpp @@ -1,1182 +1,1182 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPointSetInteractor.h" #include "mitkPointOperation.h" #include "mitkPositionEvent.h" #include "mitkPointSet.h" //#include "mitkStatusBar.h" #include "mitkDataNode.h" #include "mitkInteractionConst.h" #include "mitkAction.h" #include "mitkStateEvent.h" #include "mitkOperationEvent.h" #include "mitkUndoController.h" #include "mitkStateMachineFactory.h" #include "mitkStateTransitionOperation.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" //how precise must the user pick the point //default value const int PRECISION = 5; mitk::PointSetInteractor ::PointSetInteractor(const char * type, DataNode* dataNode, int n) :Interactor(type, dataNode), m_Precision(PRECISION), m_N(n) { if (m_N==0) { STATEMACHINE_WARN<<"Instanciation of PointSetInteractor which takes care of 0 points does't make sense!\n"; STATEMACHINE_WARN<<"Setting number of points to 1!\n"; m_N = 1; } m_LastPoint.Fill(0); m_SumVec.Fill(0); this->InitAccordingToNumberOfPoints(); } mitk::PointSetInteractor::~PointSetInteractor() { } //##Documentation //## overwritten cause this class can handle it better! float mitk::PointSetInteractor::CanHandleEvent(StateEvent const* stateEvent) const { float returnValue = 0.0; //if it is a key event that can be handled in the current state, then return 0.5 mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast (stateEvent->GetEvent()); //Key event handling: if (disPosEvent == NULL) { //check, if the current state has a transition waiting for that key event. if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) { return 0.5; } else { return 0; } } //on MouseMove do nothing! if (stateEvent->GetEvent()->GetType() == mitk::Type_MouseMove) { return 0; } //get the time of the sender to look for the right transition. mitk::BaseRenderer* sender = stateEvent->GetEvent()->GetSender(); if (sender != NULL) { unsigned int timeStep = sender->GetTimeStep(m_DataNode->GetData()); //if the event can be understood and if there is a transition waiting for that event mitk::State const* state = this->GetCurrentState(timeStep); if (state!= NULL) if (state->GetTransition(stateEvent->GetId())!=NULL) returnValue = 0.5;//it can be understood mitk::PointSet *pointSet = dynamic_cast(m_DataNode->GetData()); if ( pointSet != NULL ) { //if we have one point or more, then check if the have been picked if ( (pointSet->GetSize( timeStep ) > 0) && (pointSet->SearchPoint( disPosEvent->GetWorldPosition(), m_Precision, timeStep) > -1) ) { returnValue = 1.0; } } } return returnValue; } //TODO: add a new calculation of precision here! Input: StateEvent and Precision //the method does a 2D picking with display coordinates and display geometry. //Here the distance between the mouse position and the point is not as relative anymore! //float mitk::PointSetInteractor::CalculatePrecision(float precision, mitk::StateEvent stateEvent) //{ // mitk::BaseRenderer *renderer = stateEvent->GetEvent()->GetSender(); // if (renderer != NULL) // { // const mitk::DisplayGeometry* displayGeometry = renderer->GetDisplayGeometry(); // if (displayGeometry != NULL) // displayGeometry->WorldToDisplay(, lineFrom); // precision = // } // // return precision; // //} void mitk::PointSetInteractor::UnselectAll( unsigned int timeStep, ScalarType timeInMS ) { mitk::PointSet *pointSet = dynamic_cast( m_DataNode->GetData() ); if ( pointSet == NULL ) { return; } mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet( timeStep ); if ( itkPointSet == NULL ) { return; } mitk::PointSet::PointsContainer::Iterator it, end; end = itkPointSet->GetPoints()->End(); for (it = itkPointSet->GetPoints()->Begin(); it != end; it++) { int position = it->Index(); PointSet::PointDataType pointData = {0, false, PTUNDEFINED}; itkPointSet->GetPointData( position, &pointData ); //then declare an operation which unselects this point; //UndoOperation as well! if ( pointData.selected ) { mitk::Point3D noPoint; noPoint.Fill( 0 ); mitk::PointOperation *doOp = new mitk::PointOperation( OpDESELECTPOINT, timeInMS, noPoint, position); if ( m_UndoEnabled ) { mitk::PointOperation *undoOp = new mitk::PointOperation(OpSELECTPOINT, timeInMS, noPoint, position); OperationEvent *operationEvent = new OperationEvent( pointSet, doOp, undoOp ); m_UndoController->SetOperationEvent( operationEvent ); } pointSet->ExecuteOperation( doOp ); if ( !m_UndoEnabled ) delete doOp; } } } void mitk::PointSetInteractor::SelectPoint( int position, unsigned int timeStep, ScalarType timeInMS ) { mitk::PointSet *pointSet = dynamic_cast< mitk::PointSet * >( m_DataNode->GetData() ); //if List is empty, then no select of a point can be done! if ( (pointSet == NULL) || (pointSet->GetSize( timeStep ) <= 0) ) { return; } //dummyPoint... not needed anyway mitk::Point3D noPoint; noPoint.Fill(0); mitk::PointOperation *doOp = new mitk::PointOperation( OpSELECTPOINT, timeInMS, noPoint, position); if ( m_UndoEnabled ) { mitk::PointOperation* undoOp = new mitk::PointOperation( OpDESELECTPOINT, timeInMS, noPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } pointSet->ExecuteOperation( doOp ); if ( !m_UndoEnabled ) delete doOp; } bool mitk::PointSetInteractor::ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ) { bool ok = false;//for return type bool //checking corresponding Data; has to be a PointSet or a subclass mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); if ( pointSet == NULL ) { return false; } //get the timestep to support 3D+T const mitk::Event *theEvent = stateEvent->GetEvent(); mitk::ScalarType timeInMS = 0.0; //check if the current timestep has to be changed if ( theEvent ) { if (theEvent->GetSender() != NULL) { //additionaly to m_TimeStep we need timeInMS to satisfy the execution of the operations timeInMS = theEvent->GetSender()->GetTime(); } } //for reading on the points, Id's etc mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet( m_TimeStep ); if ( itkPointSet == NULL ) { return false; } mitk::PointSet::PointsContainer *points = itkPointSet->GetPoints(); /*Each case must watch the type of the event!*/ switch (action->GetActionId()) { case AcDONOTHING: ok = true; break; case AcCHECKOPERATION: //to check if the given Event is a DisplayPositionEvent. { mitk::DisplayPositionEvent const *dispPosEvent = dynamic_cast ( stateEvent->GetEvent()); if (dispPosEvent != NULL) { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, stateEvent->GetEvent()); this->HandleEvent( newStateEvent ); delete newStateEvent; } else { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, stateEvent->GetEvent()); this->HandleEvent( newStateEvent ); delete newStateEvent; } ok = true; break; } case AcADDPOINT: // Declare two operations: one for the selected state: deselect the last // one selected and select the new one the other operation is the add // operation: There the first empty place have to be found and the new // point inserted into that space { mitk::DisplayPositionEvent const *posEvent = dynamic_cast < const mitk::DisplayPositionEvent * > (stateEvent->GetEvent()); // Check if it is a DisplayEvent thrown in a 3D window. Then the // z-information is missing. Returning false might end in the state // full, but the last point couldn't be added, so the set wouldn't be // full. So a extra Action that checks the operationtype has been added. if ( posEvent == NULL ) { return false; } mitk::Point3D itkPoint; itkPoint = posEvent->GetWorldPosition(); // undo-supported deselect of all points in the DataList; if List is // empty, then nothing will be unselected this->UnselectAll( m_TimeStep, timeInMS ); // find the position, the point is to be added to: first entry with // empty index. If the Set is empty, then start with 0. if not empty, // then take the first index not occupied int lastPosition = 0; if (!points->empty()) { mitk::PointSet::PointsIterator it, end; it = points->Begin(); end = points->End(); while( it != end ) { if (!points->IndexExists(lastPosition)) break; ++it; ++lastPosition; } } PointOperation* doOp = new mitk::PointOperation( OpINSERT, timeInMS, itkPoint, lastPosition); if (m_UndoEnabled) { // difference between OpDELETE and OpREMOVE is, that OpDELETE deletes // a point at the end, and OpREMOVE deletes it from the given position // remove is better, cause we need the position to add or remove the // point anyway. We can get the last position from size() PointOperation *undoOp = new mitk::PointOperation( OpREMOVE, timeInMS, itkPoint, lastPosition); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp, "Add point"); m_UndoController->SetOperationEvent(operationEvent); } //execute the Operation pointSet->ExecuteOperation(doOp); if ( !m_UndoEnabled ) delete doOp; //the point is added and directly selected in PintSet. So no need to call OpSELECTPOINT ok = true; // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } case AcINITMOVEMENT: { mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent == NULL) return false; // start of the Movement is stored to calculate the undoKoordinate // in FinishMovement m_LastPoint = posEvent->GetWorldPosition(); // initialize a value to calculate the movement through all // MouseMoveEvents from MouseClick to MouseRelease m_SumVec.Fill(0); ok = true; break; } case AcMOVESELECTED://moves all selected Elements { mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent == NULL) return false; mitk::Point3D newPoint, resultPoint; newPoint = posEvent->GetWorldPosition(); // search the elements in the list that are selected then calculate the // vector, because only with the vector we can move several elements in // the same direction // newPoint - lastPoint = vector // then move all selected and set the lastPoint = newPoint. // then add all vectors to a summeryVector (to be able to calculate the // startpoint for undoOperation) mitk::Vector3D dirVector = newPoint - m_LastPoint; //sum up all Movement for Undo in FinishMovement m_SumVec = m_SumVec + dirVector; mitk::PointSet::PointsIterator it, end; it = points->Begin(); end = points->End(); while( it != end ) { int position = it->Index(); if ( pointSet->GetSelectInfo(position, m_TimeStep) )//if selected { PointSet::PointType pt = pointSet->GetPoint(position, m_TimeStep); mitk::Point3D sumVec; sumVec[0] = pt[0]; sumVec[1] = pt[1]; sumVec[2] = pt[2]; resultPoint = sumVec + dirVector; PointOperation* doOp = new mitk::PointOperation(OpMOVE, timeInMS, resultPoint, position); //execute the Operation //here no undo is stored, because the movement-steps aren't interesting. // only the start and the end is interisting to store for undo. pointSet->ExecuteOperation(doOp); delete doOp; } ++it; } m_LastPoint = newPoint;//for calculation of the direction vector ok = true; // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } case AcREMOVEPOINT://remove the given Point from the list { //if the point to be removed is given by the positionEvent: mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent != NULL) { mitk::Point3D itkPoint; itkPoint = posEvent->GetWorldPosition(); //search the point in the list int position = pointSet->SearchPoint(itkPoint, 0.0, m_TimeStep); //distance set to 0, cause we already got the exact point from last //State checkpointbut we also need the position in the list to remove it if (position>=0)//found a point { PointSet::PointType pt = pointSet->GetPoint(position, m_TimeStep); itkPoint[0] = pt[0]; itkPoint[1] = pt[1]; itkPoint[2] = pt[2]; //Undo PointOperation* doOp = new mitk::PointOperation(OpREMOVE, timeInMS, itkPoint, position); if (m_UndoEnabled) //write to UndoMechanism { PointOperation* undoOp = new mitk::PointOperation(OpINSERT, timeInMS, itkPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp, "Remove point"); m_UndoController->SetOperationEvent(operationEvent); } //execute the Operation pointSet->ExecuteOperation(doOp); if ( !m_UndoEnabled ) delete doOp; /*now select the point "position-1", and if it is the first in list, then contine at the last in list*/ //only then a select of a point is possible! if (pointSet->GetSize( m_TimeStep ) > 0) { if (position>0)//not the first in list { this->SelectPoint( position-1, m_TimeStep, timeInMS ); } //it was the first point in list, that was removed, so select //the last in list else { position = pointSet->GetSize( m_TimeStep ) - 1; //last in list this->SelectPoint( position, m_TimeStep, timeInMS ); }//else }//if ok = true; } } else //no position is given so remove all selected elements { //delete all selected points //search for the selected one and then declare the operations! mitk::PointSet::PointsContainer::Iterator it, end; it = points->Begin(); end = points->End(); int position = 0; int previousExistingPosition = -1;//to recognize the last existing position; needed because the iterator gets invalid if the point is deleted! int lastDelPrevExistPosition = -1; //the previous position of the last deleted point while (it != end) { if (points->IndexExists(it->Index())) { //if point is selected if ( pointSet->GetSelectInfo(it->Index(), m_TimeStep) ) { //get the coordinates of that point to be undoable PointSet::PointType selectedPoint = it->Value(); mitk::Point3D itkPoint; itkPoint[0] = selectedPoint[0]; itkPoint[1] = selectedPoint[1]; itkPoint[2] = selectedPoint[2]; position = it->Index(); PointOperation* doOp = new mitk::PointOperation(OpREMOVE, timeInMS, itkPoint, position); //Undo if (m_UndoEnabled) //write to UndoMechanism { PointOperation* undoOp = new mitk::PointOperation(OpINSERT, timeInMS, itkPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp, "Remove point"); m_UndoController->SetOperationEvent(operationEvent); } pointSet->ExecuteOperation(doOp); if ( !m_UndoEnabled ) delete doOp; //after delete the iterator is undefined, so start again //count to the last existing entry if (points->Size()>1 && points->IndexExists(previousExistingPosition)) { for (it = points->Begin(); it != points->End(); it++) { if (it->Index() == (unsigned int) previousExistingPosition) { lastDelPrevExistPosition = previousExistingPosition; break; //return if the iterator on the last existing position is found } } } else // size <= 1 or no previous existing position set { //search for the first existing position for (it = points->Begin(); it != points->End(); it++) if (points->IndexExists(it->Index())) { previousExistingPosition = it->Index(); break; } } //now that we have set the iterator, lets get sure, that the next it++ will not crash! if (it == end) { break; } }//if else { previousExistingPosition = it->Index(); } }//if index exists it++; }//while if (lastDelPrevExistPosition < 0)//the var has not been set because the first element was deleted and there was no prev position lastDelPrevExistPosition = previousExistingPosition; //go to the end /* * now select the point before the point/points that was/were deleted */ if (pointSet->GetSize( m_TimeStep ) > 0) //only then a select of a point is possible! { if (points->IndexExists(lastDelPrevExistPosition)) { this->SelectPoint( lastDelPrevExistPosition, m_TimeStep, timeInMS ); } else { //select the first existing element for (mitk::PointSet::PointsContainer::Iterator it = points->Begin(); it != points->End(); it++) if (points->IndexExists(it->Index())) { this->SelectPoint( it->Index(), m_TimeStep, timeInMS ); break; } } }//if ok = true; }//else }//case // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; // Remove all Points that have been set at once. // TODO: Undo function not supported yet. case AcREMOVEALL: { if ( !points->empty() ) { PointSet::PointType pt; mitk::PointSet::PointsContainer::Iterator it, end; it = points->Begin(); end = points->End(); int position = 0; while ( it != end ) { position = it->Index(); if ( points->IndexExists( position ) ) { pt = pointSet->GetPoint( position, m_TimeStep ); PointOperation* doOp = new mitk::PointOperation( OpREMOVE, timeInMS, pt, position ); ++it; pointSet->ExecuteOperation( doOp ); delete doOp; } else it++; } } ok = true; // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } //Checking if the Point transmitted is close enough to one point. Then //generate a new event with the point and let this statemaschine //handle the event. case AcCHECKELEMENT: { mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent != NULL) { mitk::Point3D worldPoint = posEvent->GetWorldPosition(); int position = pointSet->SearchPoint( worldPoint, m_Precision, m_TimeStep ); if (position>=0)//found a point near enough to the given point { //get that point, the one meant by the user! PointSet::PointType pt = pointSet->GetPoint(position, m_TimeStep); mitk::Point2D displPoint; displPoint[0] = worldPoint[0]; displPoint[1] = worldPoint[1]; //new Event with information YES and with the correct point mitk::PositionEvent const* newPosEvent = new mitk::PositionEvent(posEvent->GetSender(), Type_None, BS_NoButton, BS_NoButton, Key_none, displPoint, pt); mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, newPosEvent); //call HandleEvent to leave the guard-state this->HandleEvent( newStateEvent ); delete newStateEvent; delete newPosEvent; ok = true; } else { //new Event with information NO mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, posEvent); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; } } else { - STATEMACHINE_DEBUG("OperationError")<GetType()<<" AcCHECKELEMENT expected PointOperation."; + MITK_DEBUG("OperationError")<GetType()<<" AcCHECKELEMENT expected PointOperation."; mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast ( stateEvent->GetEvent()); if (disPosEvent != NULL) { //2d Koordinates for 3D Interaction; return false to redo //the last statechange mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, disPosEvent); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; } } break; } case AcCHECKONESELECTED: //check if there is a point that is selected { if (pointSet->GetNumberOfSelected(m_TimeStep)>0) { mitk::StateEvent* newStateEvent = new mitk::StateEvent( EIDYES, theEvent); this->HandleEvent( newStateEvent ); delete newStateEvent; } else //not selected then call event EIDNO { //new Event with information NO mitk::StateEvent* newStateEvent = new mitk::StateEvent( EIDNO, theEvent); this->HandleEvent( newStateEvent ); delete newStateEvent; } ok = true; break; } case AcCHECKSELECTED: /*check, if the given point is selected: if no, then send EIDNO if yes, then send EIDYES*/ // check, if: because of the need to look up the point again, it is // possible, that we grab the wrong point in case there are two same points // so maybe we do have to set a global index for further computation, // as long, as the mouse is moved... { int position = -1; mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent == NULL) return false; mitk::Point3D worldPoint = posEvent->GetWorldPosition(); position = pointSet->SearchPoint(worldPoint, m_Precision, m_TimeStep); if (position>=0) { mitk::PositionEvent const *newPosEvent = new mitk::PositionEvent(posEvent->GetSender(), posEvent->GetType(), posEvent->GetButton(), posEvent->GetButtonState(), posEvent->GetKey(), posEvent->GetDisplayPosition(), posEvent->GetWorldPosition()); //if selected on true, then call Event EIDYES if (pointSet->GetSelectInfo(position, m_TimeStep)) { mitk::StateEvent* newStateEvent = new mitk::StateEvent( EIDYES, newPosEvent ); this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; //saving the spot for calculating the direction vector in moving m_LastPoint = posEvent->GetWorldPosition(); } else //not selected then call event EIDNO { //new Event with information NO mitk::StateEvent* newStateEvent = new mitk::StateEvent( EIDNO, newPosEvent ); this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; } delete newPosEvent; } //the position wasn't set properly. If necessary: search the given //point in list and set var position else { /* mitk::StatusBar::GetInstance()->DisplayText( "Message from mitkPointSetInteractor: Error in Actions! Check Config XML-file", 10000); */ ok = false; } break; } //generate Events if the set will be full after the addition of the // point or not. case AcCHECKNMINUS1: { // number of points not limited->pass on // "Amount of points in Set is smaller then N-1" if (m_N<0) { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDSTSMALERNMINUS1, stateEvent->GetEvent()); this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; } else { if (pointSet->GetSize( m_TimeStep ) < m_N-1 ) //pointset after addition won't be full { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDSTSMALERNMINUS1, stateEvent->GetEvent()); this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; } else //after the addition of a point, the container will be full { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDSTLARGERNMINUS1, stateEvent->GetEvent()); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; }//else }//else } break; case AcCHECKEQUALS1: { //the number of points in the list is 1 (or smaler) if (pointSet->GetSize( m_TimeStep ) <= 1) { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDYES, stateEvent->GetEvent()); this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; } else //more than 1 points in list, so stay in the state! { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDNO, stateEvent->GetEvent()); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; } } break; case AcCHECKNUMBEROFPOINTS: { //the number of points in the list is 1 (or smaler), so will be empty after delete if (pointSet->GetSize( m_TimeStep ) <= 1) { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDEMPTY, stateEvent->GetEvent()); this->HandleEvent( newStateEvent ); delete newStateEvent; ok = true; } else if (pointSet->GetSize( m_TimeStep ) <= m_N || m_N <= -1) //m_N is set to unlimited points allowed or more than 1 points in list, but not full, so stay in the state! { // if the number of points equals m_N and no point of the point set is selected switch to state EIDEQUALSN if ((pointSet->GetSize( m_TimeStep ) == m_N)&&(pointSet->GetNumberOfSelected()==0)) { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDEQUALSN, stateEvent->GetEvent()); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; } // if the number of points is small than or equal m_N and point(s) are selected stay in state else { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDSMALLERN, stateEvent->GetEvent()); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; } } else //pointSet->GetSize( m_TimeStep ) >=m_N. // This can happen if the points were not added // by interaction but by loading a .mps file { mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDEQUALSN, stateEvent->GetEvent()); this->HandleEvent(newStateEvent ); delete newStateEvent; ok = true; } } break; case AcSELECTPICKEDOBJECT://and deselect others { mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent == NULL) return false; mitk::Point3D itkPoint; itkPoint = posEvent->GetWorldPosition(); //search the point in the list int position = pointSet->SearchPoint(itkPoint, 0.0, m_TimeStep); //distance set to 0, cause we already got the exact point from last //State checkpoint but we also need the position in the list to move it if (position>=0)//found a point { //first deselect the other points //undoable deselect of all points in the DataList this->UnselectAll( m_TimeStep, timeInMS); PointOperation* doOp = new mitk::PointOperation(OpSELECTPOINT, timeInMS, itkPoint, position); //Undo if (m_UndoEnabled) //write to UndoMechanism { PointOperation* undoOp = new mitk::PointOperation(OpDESELECTPOINT, timeInMS, itkPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } //execute the Operation pointSet->ExecuteOperation(doOp); if ( !m_UndoEnabled ) delete doOp; ok = true; } // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } case AcDESELECTOBJECT: { mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent == NULL) return false; mitk::Point3D itkPoint; itkPoint = posEvent->GetWorldPosition(); //search the point in the list int position = pointSet->SearchPoint(itkPoint, 0.0, m_TimeStep); //distance set to 0, cause we already got the exact point from last // State checkpoint but we also need the position in the list to move it if (position>=0)//found a point { //Undo PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT, timeInMS, itkPoint, position); if (m_UndoEnabled) //write to UndoMechanism { PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, timeInMS, itkPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } //execute the Operation pointSet->ExecuteOperation(doOp); if ( !m_UndoEnabled ) delete doOp; ok = true; } // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } case AcDESELECTALL: { //undo-supported able deselect of all points in the DataList this->UnselectAll( m_TimeStep, timeInMS ); ok = true; // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } case AcFINISHMOVEMENT: { mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); if (posEvent == NULL) return false; //finish the movement: //the final point is m_LastPoint //m_SumVec stores the movement in a vector //the operation would not be necessary, but we need it for the undo Operation. //m_LastPoint is for the Operation //the point for undoOperation calculates from all selected //elements (point) - m_SumVec //search all selected elements and move them with undo-functionality. mitk::PointSet::PointsIterator it, end; it = points->Begin(); end = points->End(); while( it != end ) { int position = it->Index(); if ( pointSet->GetSelectInfo(position, m_TimeStep) )//if selected { PointSet::PointType pt = pointSet->GetPoint(position, m_TimeStep); Point3D itkPoint; itkPoint[0] = pt[0]; itkPoint[1] = pt[1]; itkPoint[2] = pt[2]; PointOperation* doOp = new mitk::PointOperation(OpMOVE, timeInMS, itkPoint, position); if ( m_UndoEnabled )//&& (posEvent->GetType() == mitk::Type_MouseButtonRelease) { //set the undo-operation, so the final position is undo-able //calculate the old Position from the already moved position - m_SumVec mitk::Point3D undoPoint = ( itkPoint - m_SumVec ); PointOperation* undoOp = new mitk::PointOperation(OpMOVE, timeInMS, undoPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp, "Move point"); m_UndoController->SetOperationEvent(operationEvent); } //execute the Operation pointSet->ExecuteOperation(doOp); if ( !m_UndoEnabled ) delete doOp; } ++it; } //set every variable for movement calculation to zero // commented out: increases usebility in derived classes. /*m_LastPoint.Fill(0); m_SumVec.Fill(0);*/ //increase the GroupEventId, so that the Undo goes to here this->IncCurrGroupEventId(); ok = true; // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } case AcCLEAR: { this->Clear( m_TimeStep, timeInMS ); // Update the display mitk::RenderingManager::GetInstance()->RequestUpdateAll(); break; } default: return Superclass::ExecuteAction( action, stateEvent ); } // indicate modification of data tree node m_DataNode->Modified(); return ok; } void mitk::PointSetInteractor::Clear( unsigned int timeStep, ScalarType timeInMS ) { mitk::Point3D point; point.Fill(0); mitk::PointSet *pointSet = dynamic_cast(m_DataNode->GetData()); if ( pointSet == NULL ) { return; } mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet( timeStep ); if ( itkPointSet == NULL ) { return; } //for reading on the points, Id's etc mitk::PointSet::PointsContainer *points = itkPointSet->GetPoints(); mitk::PointSet::PointsIterator it, end; it = points->Begin(); end = points->End(); while( (it != end) && (pointSet->GetSize( timeStep ) > 0) ) { point = pointSet->GetPoint( it->Index(), timeStep ); PointOperation *doOp = new mitk::PointOperation( OpREMOVE, timeInMS, point, it->Index()); //write to UndoMechanism if ( m_UndoEnabled ) { PointOperation *undoOp = new mitk::PointOperation( OpINSERT, timeInMS, point, it->Index()); OperationEvent *operationEvent = new OperationEvent( pointSet, doOp, undoOp ); m_UndoController->SetOperationEvent( operationEvent ); } //execute the Operation ++it; pointSet->ExecuteOperation( doOp ); if ( !m_UndoEnabled ) delete doOp; } //reset the statemachine this->ResetStatemachineToStartState(timeStep); } void mitk::PointSetInteractor::InitAccordingToNumberOfPoints() { if (m_DataNode == NULL) return; mitk::PointSet *pointSet = dynamic_cast(m_DataNode->GetData()); if ( pointSet != NULL ) { //resize the CurrentStateVector this->ExpandStartStateVector(pointSet->GetPointSetSeriesSize()); for (unsigned int timestep = 0; timestep < pointSet->GetPointSetSeriesSize(); timestep++) { //go to new timestep this->UpdateTimeStep(timestep); int numberOfPoints = pointSet->GetSize( timestep ); if (numberOfPoints == 0) continue; //pointset is empty else { //we have a set of loaded points. Deselect all points, because they are all set to selected when added! this->UnselectAll(timestep); if (numberOfPointsHandleEvent( newStateEvent ); delete newStateEvent; delete nullEvent; } else if (numberOfPoints>=m_N) { if (numberOfPoints>m_N) { STATEMACHINE_WARN<<"Point Set contains more points than needed!\n";//display a warning that there are too many points } //get the currentState to state "Set full" const mitk::Event* nullEvent = new mitk::Event(NULL, Type_User, BS_NoButton, BS_NoButton, Key_none); mitk::StateEvent* newStateEvent = new mitk::StateEvent(EIDEQUALSN, nullEvent); this->HandleEvent( newStateEvent ); delete newStateEvent; delete nullEvent; } } } } return; } void mitk::PointSetInteractor::DataChanged() { this->InitAccordingToNumberOfPoints(); return; } diff --git a/Core/Code/Interactions/mitkStateMachine.cpp b/Core/Code/Interactions/mitkStateMachine.cpp index a3c35cd2a0..bbc70b4857 100644 --- a/Core/Code/Interactions/mitkStateMachine.cpp +++ b/Core/Code/Interactions/mitkStateMachine.cpp @@ -1,316 +1,316 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkStateMachine.h" #include "mitkStateTransitionOperation.h" #include "mitkInteractionConst.h" #include "mitkInteractor.h" #include "mitkTransition.h" #include "mitkOperationEvent.h" #include "mitkStateEvent.h" #include "mitkAction.h" #include "mitkUndoController.h" #include #include "mitkGlobalInteraction.h" #include /** * @brief Constructor * daclares a new StateMachine and connects * it to a StateMachine of Type type; * Also the undo mechanism is instanciated and enabled/disabled **/ mitk::StateMachine::StateMachine(const char * type) : m_UndoController(NULL), m_Type("") { if(type!=NULL) //no need to throw a warning here, because the statemachine yet here doesn't have to be set up. { m_Type = type; //the statemachine doesn't know yet anything about the number of timesteps of the data. So we initialize it with one element. this->InitializeStartStates(1); } if (!m_UndoController) { m_UndoController = new UndoController(UndoController::VERBOSE_LIMITEDLINEARUNDO);//switch to LLU or add LLU /** * here the Undo mechanism is enabled / disabled for all interactors. **/ m_UndoEnabled = true; } m_TimeStep = 0; } mitk::StateMachine::~StateMachine() { //clean up map using deletes for ( mitk::StateMachine::ActionFunctionsMapType::iterator iter = m_ActionFunctionsMap.begin(); iter != m_ActionFunctionsMap.end(); ++iter ) { delete iter->second; } delete m_UndoController; } std::string mitk::StateMachine::GetType() const { return m_Type; } const mitk::State* mitk::StateMachine::GetCurrentState(unsigned int timeStep) const { if (m_CurrentStateVector.size() > timeStep) //the size of the vector has to be one integer higher than the timeStep. return m_CurrentStateVector[timeStep].GetPointer(); return NULL; } void mitk::StateMachine::ResetStatemachineToStartState(unsigned int timeStep) { mitk::State* startState = mitk::GlobalInteraction::GetInstance()->GetStartState((const char *)(&m_Type[0])); if ( m_UndoEnabled ) //write to UndoMechanism if Undo is enabled { //UNDO for this statechange; StateTransitionOperation* doOp = new StateTransitionOperation(OpSTATECHANGE, startState, timeStep); StateTransitionOperation* undoOp = new StateTransitionOperation(OpSTATECHANGE, m_CurrentStateVector[timeStep], timeStep); OperationEvent *operationEvent = new OperationEvent(((mitk::OperationActor*)(this)), doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } //can be done without calling this->ExecuteOperation() m_CurrentStateVector[timeStep] = startState; } bool mitk::StateMachine::HandleEvent(StateEvent const* stateEvent) { if (stateEvent == NULL) return false; if (m_CurrentStateVector.empty()) { STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachine not initialized!\n"; return false;//m_CurrentStateVector needs to be initialized! } if (m_TimeStep >= m_CurrentStateVector.size()) { STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachine not initialized for this time step!\n"; return false; } if (m_CurrentStateVector[m_TimeStep].IsNull()) { STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachine not initialized with the right temporal information!\n"; return false;//m_CurrentState needs to be initialized! } //get the Transition from m_CurrentState which waits for this EventId const Transition *tempTransition = m_CurrentStateVector[m_TimeStep]->GetTransition(stateEvent->GetId()); if (tempTransition == NULL) //no transition in this state for that EventId { return false; } //get next State State *tempNextState = tempTransition->GetNextState(); if (tempNextState == NULL) //wrong built up statemachine! { STATEMACHINE_ERROR << "Error in mitkStateMachine.cpp: StateMachinePattern not defined correctly!\n"; return false; } //and ActionId to execute later on if ( m_CurrentStateVector[m_TimeStep]->GetId() != tempNextState->GetId() )//statechange only if there is a real statechange { if ( m_UndoEnabled ) //write to UndoMechanism if Undo is enabled { //UNDO for this statechange; since we directly change the state, we don't need the do-Operation in case m_UndoEnables == false StateTransitionOperation* doOp = new StateTransitionOperation(OpSTATECHANGE, tempNextState, m_TimeStep); StateTransitionOperation* undoOp = new StateTransitionOperation(OpSTATECHANGE, m_CurrentStateVector[m_TimeStep], m_TimeStep); OperationEvent *operationEvent = new OperationEvent(((mitk::OperationActor*)(this)), doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } - STATEMACHINE_DEBUG("StateChange")<GetType()<<" from " << m_CurrentStateVector[m_TimeStep]->GetId() - << " " << m_CurrentStateVector[m_TimeStep]->GetName() - <<" to " << tempNextState->GetId() <<" "<GetName(); + STATEMACHINE_DEBUG << "from " << m_CurrentStateVector[m_TimeStep]->GetId() + << " " << m_CurrentStateVector[m_TimeStep]->GetName() + << " to " << tempNextState->GetId() <<" "<GetName(); //first following StateChange(or calling ExecuteOperation(tempNextStateOp)), then operation(action) m_CurrentStateVector[m_TimeStep] = tempNextState; } mitk::Transition::ActionVectorIterator actionIdIterator = tempTransition->GetActionBeginIterator(); mitk::Transition::ActionVectorConstIterator actionIdIteratorEnd = tempTransition->GetActionEndIterator(); bool ok = true; while ( actionIdIterator != actionIdIteratorEnd ) { if ( !ExecuteAction(*actionIdIterator, stateEvent) ) { ok = false; } actionIdIterator++; } return ok; } void mitk::StateMachine::EnableUndo(bool enable) { m_UndoEnabled = enable; } void mitk::StateMachine::IncCurrGroupEventId() { mitk::OperationEvent::IncCurrGroupEventId(); } /// look up which object method is associated to the given action and call the method bool mitk::StateMachine::ExecuteAction(Action* action, StateEvent const* stateEvent) { if (!action) return false; int actionId = action->GetActionId(); TStateMachineFunctor* actionFunction = m_ActionFunctionsMap[actionId]; if (!actionFunction) return false; bool retVal = actionFunction->DoAction(action, stateEvent); return retVal; } void mitk::StateMachine::AddActionFunction(int action, mitk::TStateMachineFunctor* functor) { if (!functor) return; // make sure double calls for same action won't cause memory leaks delete m_ActionFunctionsMap[action]; // delete NULL does no harm m_ActionFunctionsMap[action] = functor; } void mitk::StateMachine::ExecuteOperation(Operation* operation) { switch (operation->GetOperationType()) { case OpNOTHING: break; case OpSTATECHANGE: { mitk::StateTransitionOperation* stateTransOp = dynamic_cast(operation); if (stateTransOp == NULL) { STATEMACHINE_WARN<<"Error! see mitkStateMachine.cpp"; return; } unsigned int time = stateTransOp->GetTime(); m_CurrentStateVector[time] = stateTransOp->GetState(); } break; case OpTIMECHANGE: { mitk::StateTransitionOperation* stateTransOp = dynamic_cast(operation); if (stateTransOp == NULL) { STATEMACHINE_WARN<<"Error! see mitkStateMachine.cpp"; return; } m_TimeStep = stateTransOp->GetTime(); } break; case OpDELETE: { //delete this! //before all lower statemachines has to be deleted in a action //this->Delete();//might not work!!!check itk! } case OpUNDELETE: { //now the m_CurrentState has to be set on a special State //that way a delete of a StateMachine can be undone //IMPORTANT: The type has to be the same!!!Done by a higher instance, that creates this! mitk::StateTransitionOperation* stateTransOp = dynamic_cast(operation); if (stateTransOp != NULL) { unsigned int time = stateTransOp->GetTime(); m_CurrentStateVector[time] = stateTransOp->GetState(); } } default: ; } } void mitk::StateMachine::InitializeStartStates(unsigned int timeSteps) { //get the startstate of the pattern State::Pointer startState = mitk::GlobalInteraction::GetInstance()->GetStartState(m_Type.c_str()); if (startState.IsNull()) { STATEMACHINE_FATAL << "Fatal Error in mitkStateMachine.cpp: Initialization of statemachine unsuccessfull! Initialize GlobalInteraction!\n"; } //clear the vector m_CurrentStateVector.clear(); //add n=timesteps pointers pointing to to the startstate for (unsigned int i = 0; i < timeSteps; i++) m_CurrentStateVector.push_back(startState); } // Check if the vector is long enough to contain the new element // at the given position. If not, expand it with sufficient pre-initialized // elements. // // NOTE: This method will never REDUCE the vector size; it should only // be used to make sure that the vector has enough elements to include the // specified time step. void mitk::StateMachine::ExpandStartStateVector(unsigned int timeSteps) { unsigned int oldSize = m_CurrentStateVector.size(); if ( timeSteps > oldSize ) { State::Pointer startState = mitk::GlobalInteraction::GetInstance()->GetStartState(m_Type.c_str()); for ( unsigned int i = oldSize; i < timeSteps; ++i ) m_CurrentStateVector.insert(m_CurrentStateVector.end(), startState); } } void mitk::StateMachine::UpdateTimeStep(unsigned int timeStep) { //don't need to fill up the memory if the time is uptodate if (timeStep == m_TimeStep) return; //create an operation that changes the time and send it to undocontroller StateTransitionOperation* doOp = new StateTransitionOperation(OpTIMECHANGE, NULL, timeStep); if ( m_UndoEnabled ) //write to UndoMechanism if Undo is enabled { StateTransitionOperation* undoOp = new StateTransitionOperation(OpTIMECHANGE, NULL, m_TimeStep); OperationEvent *operationEvent = new OperationEvent(((mitk::OperationActor*)(this)), doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } this->ExecuteOperation(doOp); } diff --git a/Core/Code/Interactions/mitkStateMachine.h b/Core/Code/Interactions/mitkStateMachine.h index 9b0958201e..3099c399b5 100644 --- a/Core/Code/Interactions/mitkStateMachine.h +++ b/Core/Code/Interactions/mitkStateMachine.h @@ -1,292 +1,292 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef STATEMACHINE_H_HEADER_INCLUDED_C18896BD #define STATEMACHINE_H_HEADER_INCLUDED_C18896BD #include #include #include "mitkOperationActor.h" #include #include "mitkState.h" #include "mitkUndoModel.h" namespace mitk { class Action; class StateEvent; class UndoController; // base class of statem machine functors class MITK_CORE_EXPORT TStateMachineFunctor { public: virtual bool DoAction(Action*, const StateEvent*)=0; // call using function virtual ~TStateMachineFunctor() {} }; // the template functor for arbitrary StateMachine derivations template class TSpecificStateMachineFunctor : public TStateMachineFunctor { public: // constructor - takes pointer to an object and pointer to a member and stores // them in two private variables TSpecificStateMachineFunctor(T* object, bool(T::*memberFunctionPointer)(Action*, const StateEvent*)) :m_Object(object), m_MemberFunctionPointer(memberFunctionPointer) { } virtual ~TSpecificStateMachineFunctor() {} // virtual destructor // override function "Call" virtual bool DoAction(Action* action, const StateEvent* stateEvent) { return (*m_Object.*m_MemberFunctionPointer)(action, stateEvent); // execute member function } private: T* m_Object; // pointer to object bool (T::*m_MemberFunctionPointer)(Action*, const StateEvent*); // pointer to member function }; /// Can be uses by derived classes of StateMachine to connect action IDs to methods /// Assumes that there is a typedef Classname Self in classes that use this macro #define CONNECT_ACTION(a, f) \ StateMachine::AddActionFunction(a, new TSpecificStateMachineFunctor(this, &Self::f)); -#define STATEMACHINE_INFO MITK_INFO("StateMachine") -#define STATEMACHINE_WARN MITK_WARN("StateMachine") -#define STATEMACHINE_FATAL MITK_FATAL("StateMachine") -#define STATEMACHINE_ERROR MITK_ERROR("StateMachine") -#define STATEMACHINE_DEBUG MITK_DEBUG("StateMachine") +#define STATEMACHINE_INFO MITK_INFO("StateMachine") << "[type: " << GetType() << "] " +#define STATEMACHINE_WARN MITK_WARN("StateMachine") << "[type: " << GetType() << "] " +#define STATEMACHINE_FATAL MITK_FATAL("StateMachine") << "[type: " << GetType() << "] " +#define STATEMACHINE_ERROR MITK_ERROR("StateMachine") << "[type: " << GetType() << "] " +#define STATEMACHINE_DEBUG MITK_DEBUG("StateMachine") << "[type: " << GetType() << "] " /** @brief Superior statemachine @ingroup Interaction Realizes the methods, that every statemachine has to have. Undo can be enabled and disabled through EnableUndo. To implement your own state machine, you have to derive a class from mitk::StateMachine and either - override ExecuteAction() or - Write bool methods that take (Action*, const StateEvent*) as parameter and use the CONNECT_ACTION macro in your constructor The second version is recommended, since it provides more structured code. The following piece of code demonstrates how to use the CONNECT_ACTION macro. The important detail is to provide a typedef classname Self \code class LightSwitch : public StateMachine { public: mitkClassMacro(LightSwitch, StateMachine); // this creates the Self typedef LightSwitch(const char*); bool DoSwitchOn(Action*, const StateEvent*); bool DoSwitchOff(Action*, const StateEvent*); } LightSwitch::LightSwitch(const char* type) :StateMachine(type) { // make sure that AcSWITCHON and AcSWITCHOFF are defined int constants somewhere (e.g. mitkInteractionConst.h) CONNECT_ACTION( AcSWITCHON, DoSwitchOn ); CONNECT_ACTION( AcSWITCHOFF, DoSwitchOff ); } bool LightSwitch::DoSwitchOn(Action*, const StateEvent*) { std::cout << "Enlightenment" << std::endl; } bool LightSwitch::DoSwitchOff(Action*, const StateEvent*) { std::cout << "Confusion" << std::endl; } \endcode What CONNECT_ACTION does, is call StateMachine::AddActionFunction(...) to add some function pointer wrapping class (functor) to a std::map of StateMachine. Whenever StateMachines ExecuteAction is called, StateMachine will lookup the desired Action in its map and call the appropriate method in your derived class. **/ class MITK_CORE_EXPORT StateMachine : public itk::Object, public mitk::OperationActor { public: mitkClassMacro(StateMachine,itk::Object); /** * @brief New Macro with one parameter for creating this object with static New(..) method **/ mitkNewMacro1Param(Self, const char*); /** * @brief Map to connect action IDs with method calls. Use AddActionFunction or (even better) the CONNECT_ACTION macro to fill the map. **/ typedef std::map ActionFunctionsMapType; /** * @brief Type for a vector of StartStatePointers **/ typedef std::vector StartStateVectorType; /** * @brief Get the name and with this the type of the StateMachine **/ std::string GetType() const; /** * @brief handles an Event accordingly to its current State * * Statechange with Undo functionality; * EventMapper gives each event a new objectEventId * and a StateMachine::ExecuteAction can descide weather it gets a * new GroupEventId or not, depending on its state (e.g. finishedNewObject then new GroupEventId). * Object- and group-EventId can also be accessed through static methods from OperationEvent **/ virtual bool HandleEvent(StateEvent const* stateEvent); /** * @brief Enables or disabled Undo. **/ void EnableUndo(bool enable); /** * @brief A statemachine is also an OperationActor due to the UndoMechanism. * * The statechange is done in ExecuteOperation, so that the statechange can be undone by UndoMechanism. * Is set private here and in superclass it is set public, so UndoController * can reach ist, but it can't be overwritten by a subclass * *ATTENTION*: THIS METHOD SHOULD NOT BE CALLED FROM OTHER CLASSES DIRECTLY! **/ virtual void ExecuteOperation(Operation* operation); /** * @brief Friend so that UndoModel can call ExecuteOperation for Undo. **/ friend class UndoModel; friend class GlobalInteraction; protected: /** * @brief Default Constructor. Obsolete to instanciate it with this method! Use ::New(..) method instead. Set the "type" and with this the pattern of the StateMachine **/ StateMachine(const char * type); /** * @brief Default Destructor **/ ~StateMachine(); /** * @brief Adds the Function to ActionList. **/ void AddActionFunction(int action, TStateMachineFunctor* functor); /** * @brief Method called in HandleEvent after Statechange. * * Each statechange has actions, which can be assigned by it's number. * If you are developing a new statemachine, declare all your operations here and send them to Undo-Controller and to the Data. * Object- and group-EventId can also be accessed through static methods from OperationEvent **/ virtual bool ExecuteAction(Action* action, StateEvent const* stateEvent); /** * @brief returns the current state **/ const State* GetCurrentState(unsigned int timeStep = 0) const; /** * @brief if true, then UndoFunctionality is enabled * * Default value is true; **/ bool m_UndoEnabled; /** * @brief Friend protected function of OperationEvent; that way all StateMachines can set GroupEventId to be incremented! **/ void IncCurrGroupEventId(); /** * @brief holds an UndoController, that can be accessed from all StateMachines. For ExecuteAction **/ UndoController* m_UndoController; /** * @brief Resets the current state from the given timeStep to the StartState with undo functionality! Use carefully! * @param[in] timeStep If the statemachine has several timesteps to take care of, specify the according timestep **/ void ResetStatemachineToStartState(unsigned int timeStep = 0); /** * @brief Check if the number of timeSteps is equal to the number of stored StartStates. Nothing is changed if the number is equal. **/ void ExpandStartStateVector(unsigned int timeSteps); /** * @brief initializes m_CurrentStateVector **/ void InitializeStartStates(unsigned int timeSteps); /** * @brief Update the TimeStep of the statemachine with undo-support if undo enabled **/ virtual void UpdateTimeStep(unsigned int timeStep); /** * @brief Current TimeStep if the data which is to be interacted on, has more than 1 TimeStep **/ unsigned int m_TimeStep; private: /** * @brief The type of the StateMachine. This string specifies the StateMachinePattern that is loaded from the StateMachineFactory. **/ std::string m_Type; /** * @brief Points to the current state. **/ StartStateVectorType m_CurrentStateVector; /** * @brief Map of the added Functions **/ ActionFunctionsMapType m_ActionFunctionsMap; }; } // namespace mitk #endif /* STATEMACHINE_H_HEADER_INCLUDED_C18896BD */ diff --git a/Core/Code/Interactions/mitkStateMachineFactory.cpp b/Core/Code/Interactions/mitkStateMachineFactory.cpp index 0b2a70fa18..d528829f9e 100755 --- a/Core/Code/Interactions/mitkStateMachineFactory.cpp +++ b/Core/Code/Interactions/mitkStateMachineFactory.cpp @@ -1,462 +1,462 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkStateMachineFactory.h" #include "mitkGlobalInteraction.h" #include #include #include #include #include /** * @brief This class builds up all the necessary structures for a statemachine. * and stores one start-state for all built statemachines. **/ //mitk::StateMachineFactory::StartStateMap mitk::StateMachineFactory::m_StartStates; //mitk::StateMachineFactory::AllStateMachineMapType mitk::StateMachineFactory::m_AllStateMachineMap; //std::string mitk::StateMachineFactory::s_LastLoadedBehavior; //XML StateMachine const std::string STYLE = "STYLE"; const std::string NAME = "NAME"; const std::string ID = "ID"; const std::string START_STATE = "START_STATE"; const std::string NEXT_STATE_ID = "NEXT_STATE_ID"; const std::string EVENT_ID = "EVENT_ID"; const std::string SIDE_EFFECT_ID = "SIDE_EFFECT_ID"; const std::string ISTRUE = "TRUE"; const std::string ISFALSE = "FALSE"; const std::string STATE_MACHINE = "stateMachine"; const std::string STATE = "state"; const std::string TRANSITION = "transition"; const std::string STATE_MACHINE_NAME = "stateMachine"; const std::string ACTION = "action"; const std::string BOOL_PARAMETER = "boolParameter"; const std::string INT_PARAMETER = "intParameter"; const std::string FLOAT_PARAMETER = "floatParameter"; const std::string DOUBLE_PARAMETER = "doubleParameter"; const std::string STRING_PARAMETER = "stringParameter"; const std::string VALUE = "VALUE"; #include namespace mitk { vtkStandardNewMacro(StateMachineFactory); } mitk::StateMachineFactory::StateMachineFactory() : m_AktStateMachineName(""), m_SkipStateMachine(false) {} mitk::StateMachineFactory::~StateMachineFactory() { //free memory while (!m_AllStateMachineMap.empty()) { StateMachineMapType* temp = m_AllStateMachineMap.begin()->second; m_AllStateMachineMap.erase(m_AllStateMachineMap.begin()); delete temp; } //should not be necessary due to SmartPointers m_StartStates.clear(); //delete WeakPointer if (m_AktTransition) delete m_AktTransition; } /** * @brief Returns NULL if no entry with string type is found. **/ mitk::State* mitk::StateMachineFactory::GetStartState(const char * type) { StartStateMapIter tempState = m_StartStates.find(type); if( tempState != m_StartStates.end() ) return (tempState)->second.GetPointer(); MITK_ERROR << "Error in StateMachineFactory: StartState for pattern \""<< type<< "\"not found! StateMachine might not work!\n"; return NULL; } /** * @brief Loads the xml file filename and generates the necessary instances. **/ bool mitk::StateMachineFactory::LoadBehavior(std::string fileName) { if ( fileName.empty() ) return false; m_LastLoadedBehavior = fileName; this->SetFileName(fileName.c_str()); return this->Parse(); } /** * @brief Loads the xml string and generates the necessary instances. **/ bool mitk::StateMachineFactory::LoadBehaviorString(std::string xmlString) { if ( xmlString.empty() ) return false; m_LastLoadedBehavior = "String"; return ( this->Parse(xmlString.c_str(), xmlString.length()) ); } bool mitk::StateMachineFactory::LoadStandardBehavior() { std::string xmlFileName( mitk::StandardFileLocations::GetInstance()->FindFile("StateMachine.xml", "Core/Code/Interactions") ); if (!xmlFileName.empty()) return this->LoadBehavior(xmlFileName); else return false; } /** * @brief Recursive method, that parses this brand of * the stateMachine; if the history has the same * size at the end, then the StateMachine is correct **/ bool mitk::StateMachineFactory::RParse(mitk::State::StateMap* states, mitk::State::StateMapIter thisState, HistorySet *history) { history->insert((thisState->second)->GetId());//log our path //or thisState->first. but this seems safer std::set nextStatesSet = (thisState->second)->GetAllNextStates(); //remove loops in nextStatesSet; //nether do we have to go there, nor will it clear a deadlock std::set::iterator position = nextStatesSet.find((thisState->second)->GetId());//look for the same state in nextStateSet if (position != nextStatesSet.end()) {//found the same state we are in! nextStatesSet.erase(position);//delete it, cause, we don't have to go there a second time! } //nextStatesSet is empty, so deadlock! if ( nextStatesSet.empty() ) { MITK_INFO<::iterator i = nextStatesSet.begin(); i != nextStatesSet.end(); i++) { if ( history->find(*i) == history->end() )//if we haven't been in this nextstate { mitk::State::StateMapIter nextState = states->find(*i);//search the iterator for our nextState if (nextState == states->end()) { MITK_INFO<size() > 1)//only one state; don't have to be parsed for deadlocks! { //parse all the given states an check for deadlock or not connected states HistorySet *history = new HistorySet; mitk::State::StateMapIter firstState = states->begin(); //parse through all the given states, log the parsed elements in history bool ok = RParse( states, firstState, history); if ( (states->size() == history->size()) && ok ) { delete history; } else //ether !ok or sizeA!=sizeB { delete history; MITK_INFO<begin(); tempState != states->end(); tempState++) { //searched through the States and Connects all Transitions bool tempbool = ( ( tempState->second )->ConnectTransitions( states ) ); if ( tempbool == false ) { MITK_INFO< ok = m_AllStatesOfOneStateMachine.insert(mitk::State::StateMap::value_type(id , m_AktState)); if ( ok.second == false ) { MITK_INFO<AddTransition( m_AktTransition ); } else if ( name == ACTION ) { int actionId = ReadXMLIntegerAttribut( ID, atts ); m_AktAction = Action::New( actionId ); m_AktTransition->AddAction( m_AktAction ); } else if ( name == BOOL_PARAMETER ) { if ( !m_AktAction ) return; bool value = ReadXMLBooleanAttribut( VALUE, atts ); std::string name = ReadXMLStringAttribut( NAME, atts ); m_AktAction->AddProperty( name.c_str(), BoolProperty::New( value ) ); } else if ( name == INT_PARAMETER ) { if ( !m_AktAction ) return; int value = ReadXMLIntegerAttribut( VALUE, atts ); std::string name = ReadXMLStringAttribut( NAME, atts ); m_AktAction->AddProperty( name.c_str(), IntProperty::New( value ) ); } else if ( name == FLOAT_PARAMETER ) { if ( !m_AktAction ) return; float value = ReadXMLIntegerAttribut( VALUE, atts ); std::string name = ReadXMLStringAttribut( NAME, atts ); m_AktAction->AddProperty( name.c_str(), FloatProperty::New( value ) ); } else if ( name == DOUBLE_PARAMETER ) { if ( !m_AktAction ) return; double value = ReadXMLDoubleAttribut( VALUE, atts ); std::string name = ReadXMLStringAttribut( NAME, atts ); m_AktAction->AddProperty( name.c_str(), DoubleProperty::New( value ) ); } else if ( name == STRING_PARAMETER ) { if ( !m_AktAction ) return; std::string value = ReadXMLStringAttribut( VALUE, atts ); std::string name = ReadXMLStringAttribut( NAME, atts ); m_AktAction->AddProperty( name.c_str(), StringProperty::New( value ) ); } } void mitk::StateMachineFactory::EndElement (const char* elementName) { - bool ok = true; + //bool ok = true; std::string name(elementName); //skip the state machine pattern because the name was not unique! if (m_SkipStateMachine && (name != STATE_MACHINE) ) return; if ( name == STATE_MACHINE_NAME ) { if (m_SkipStateMachine) { m_SkipStateMachine = false; return; } - ok = ConnectStates(&m_AllStatesOfOneStateMachine); + /*ok =*/ ConnectStates(&m_AllStatesOfOneStateMachine); m_AllStatesOfOneStateMachine.clear(); } else if ( name == STATE_MACHINE ) { //doesn't have to be done } else if ( name == TRANSITION ) { m_AktTransition = NULL; //pointer stored in its state. memory will be freed in destructor of class state } else if ( name == ACTION ) { m_AktAction = NULL; } else if ( name == STATE ) { m_AktState = NULL; } } std::string mitk::StateMachineFactory::ReadXMLStringAttribut( std::string name, const char** atts ) { if(atts) { const char** attsIter = atts; while(*attsIter) { if ( name == *attsIter ) { attsIter++; return *attsIter; } attsIter++; attsIter++; } } return std::string(); } int mitk::StateMachineFactory::ReadXMLIntegerAttribut( std::string name, const char** atts ) { std::string s = ReadXMLStringAttribut( name, atts ); return atoi( s.c_str() ); } float mitk::StateMachineFactory::ReadXMLFloatAttribut( std::string name, const char** atts ) { std::string s = ReadXMLStringAttribut( name, atts ); return (float) atof( s.c_str() ); } double mitk::StateMachineFactory::ReadXMLDoubleAttribut( std::string name, const char** atts ) { std::string s = ReadXMLStringAttribut( name, atts ); return atof( s.c_str() ); } bool mitk::StateMachineFactory::ReadXMLBooleanAttribut( std::string name, const char** atts ) { std::string s = ReadXMLStringAttribut( name, atts ); if ( s == ISTRUE ) return true; else return false; } mitk::State* mitk::StateMachineFactory::GetState( const char * type, int StateId ) { //check if the state exists AllStateMachineMapType::iterator i = m_AllStateMachineMap.find( type ); if ( i == m_AllStateMachineMap.end() ) return false; //get the statemachine of the state StateMachineMapType* sm = m_AllStateMachineMap[type]; //get the state from its statemachine if ( sm != NULL ) return (*sm)[StateId].GetPointer(); else return NULL; } bool mitk::StateMachineFactory::AddStateMachinePattern(const char * type, mitk::State* startState, mitk::StateMachineFactory::StateMachineMapType* allStatesOfStateMachine) { if (startState == NULL || allStatesOfStateMachine == NULL) return false; //check if the pattern has already been added StartStateMapIter tempState = m_StartStates.find(type); if( tempState != m_StartStates.end() ) { - STATEMACHINE_WARN << "Pattern " << type << " has already been added!\n"; + MITK_WARN << "Pattern " << type << " has already been added!\n"; return false; } //add the start state m_StartStates.insert(StartStateMap::value_type(type, startState)); //add all states of the new pattern to hold their references m_AllStateMachineMap.insert(AllStateMachineMapType::value_type(type, allStatesOfStateMachine)); return true; } diff --git a/Core/Code/Interactions/mitkVtkInteractorStyle.cxx b/Core/Code/Interactions/mitkVtkInteractorStyle.cxx new file mode 100644 index 0000000000..54d0fc34b6 --- /dev/null +++ b/Core/Code/Interactions/mitkVtkInteractorStyle.cxx @@ -0,0 +1,51 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-07-22 16:41:18 +0200 (Fr, 17 Aug 2007) $ +Version: $Revision: 11618 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkVtkInteractorStyle.h" + +#include +#include + + +vtkCxxRevisionMacro(mitkVtkInteractorStyle, "$Revision: 1.35 $"); +vtkStandardNewMacro(mitkVtkInteractorStyle); + +mitkVtkInteractorStyle::mitkVtkInteractorStyle() +: vtkInteractorStyleUser() +{ +} + +mitkVtkInteractorStyle::~mitkVtkInteractorStyle() +{ +} + +void mitkVtkInteractorStyle::OnMouseWheelForward() +{ + if (this->HasObserver(vtkCommand::MouseWheelForwardEvent)) + { + this->InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL); + } +} + +void mitkVtkInteractorStyle::OnMouseWheelBackward() +{ + if (this->HasObserver(vtkCommand::MouseWheelBackwardEvent)) + { + this->InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL); + } +} + diff --git a/Core/Code/Interactions/mitkVtkInteractorStyle.h b/Core/Code/Interactions/mitkVtkInteractorStyle.h new file mode 100644 index 0000000000..9cba9d82ee --- /dev/null +++ b/Core/Code/Interactions/mitkVtkInteractorStyle.h @@ -0,0 +1,65 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-07-22 16:41:18 +0200 (Fr, 17 Aug 2007) $ +Version: $Revision: 11618 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +/** +* \brief Implements the handling of events that are missing for MITK interaction. +* +* This class inherits from vtkInteractorStyleUser, a class that handles +* VTK-Events and invokes callbacks by means of an observer pattern. +* +* Most event-types needed for typical MITK interaction have already +* been implemented in vtkInteractorStyleUser (Mouse-Buttons + Keyboard). +* However, wheel-events and widgetModifed-events (whatever these are) +* have not been handled so far. This is the purpose of this class. +*/ + +#ifndef __mitkVtkInteractorStyle_h +#define __mitkVtkInteractorStyle_h + +#include "MitkExports.h" +#include + +class MITK_CORE_EXPORT mitkVtkInteractorStyle : public vtkInteractorStyleUser +{ +public: + + // default VTK c'tor + static mitkVtkInteractorStyle *New(); + vtkTypeRevisionMacro(mitkVtkInteractorStyle,vtkInteractorStyleUser); + + /** + * \brief Called when scrolling forwards with the mouse-wheel. + */ + virtual void OnMouseWheelForward(); + + /** + * \brief Called when scrolling backwards with the mouse-wheel. + */ + virtual void OnMouseWheelBackward(); + +protected: + + mitkVtkInteractorStyle(); + ~mitkVtkInteractorStyle(); + + +private: + mitkVtkInteractorStyle(const mitkVtkInteractorStyle&); // Not implemented. + void operator=(const mitkVtkInteractorStyle&); // Not implemented. +}; + +#endif diff --git a/Core/Code/Interfaces/mitkIDataNodeReader.h b/Core/Code/Interfaces/mitkIDataNodeReader.h new file mode 100644 index 0000000000..194622a449 --- /dev/null +++ b/Core/Code/Interfaces/mitkIDataNodeReader.h @@ -0,0 +1,59 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKIDATANODEREADER_H +#define MITKIDATANODEREADER_H + +#include +#include + +namespace mitk { + +class DataStorage; + +/** + * \ingroup MicroServices_Interfaces + * + * This interface provides methods to load data from the local filesystem + * into a given mitk::DataStorage. + */ +struct IDataNodeReader +{ + virtual ~IDataNodeReader() {} + + /** + * Reads the local file given by fileName and constructs one or more + * mitk::DataNode instances which are added to the given mitk::DataStorage storage. + * + * \param fileName The absolute path to a local file. + * \param storage The mitk::DataStorage which will contain the constructed data nodes. + * \return The number of constructed mitk::DataNode instances. + * + * \note Errors during reading the file or constructing the data node should be expressed by + * throwing appropriate exceptions. + * + * \see mitk::DataNodeFactory + */ + virtual int Read(const std::string& fileName, mitk::DataStorage& storage) = 0; +}; + +} + +MITK_DECLARE_SERVICE_INTERFACE(mitk::IDataNodeReader, "org.mitk.IDataNodeReader") + +#endif // MITKIDATANODEREADER_H diff --git a/Core/Code/Rendering/mitkGeometry2DDataMapper2D.cpp b/Core/Code/Rendering/mitkGeometry2DDataMapper2D.cpp index d405e1b9f5..108cef818e 100644 --- a/Core/Code/Rendering/mitkGeometry2DDataMapper2D.cpp +++ b/Core/Code/Rendering/mitkGeometry2DDataMapper2D.cpp @@ -1,666 +1,666 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkGL.h" #include "mitkGeometry2DDataMapper2D.h" #include "mitkBaseRenderer.h" #include "mitkPlaneGeometry.h" #include "mitkColorProperty.h" #include "mitkProperties.h" #include "mitkSmartPointerProperty.h" #include "mitkPlaneOrientationProperty.h" #include "mitkGeometry2DDataToSurfaceFilter.h" #include "mitkSurfaceGLMapper2D.h" #include "mitkLine.h" #include "mitkNodePredicateDataType.h" #include "mitkResliceMethodProperty.h" mitk::Geometry2DDataMapper2D::Geometry2DDataMapper2D() : m_SurfaceMapper( NULL ), m_DataStorage(NULL), m_ParentNode(NULL), m_OtherGeometry2Ds(), m_RenderOrientationArrows( false ), m_ArrowOrientationPositive( true ) { } mitk::Geometry2DDataMapper2D::~Geometry2DDataMapper2D() { } const mitk::Geometry2DData* mitk::Geometry2DDataMapper2D::GetInput(void) { return static_cast ( GetData() ); } void mitk::Geometry2DDataMapper2D::GenerateData() { // collect all Geometry2DDatas accessible from the DataStorage m_OtherGeometry2Ds.clear(); if (m_DataStorage.IsNull()) return; mitk::NodePredicateDataType::Pointer p = mitk::NodePredicateDataType::New("Geometry2DData"); mitk::DataStorage::SetOfObjects::ConstPointer all = m_DataStorage->GetDerivations(m_ParentNode, p, false); for (mitk::DataStorage::SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it) { if(it->Value().IsNull()) continue; BaseData* data = it->Value()->GetData(); if (data == NULL) continue; Geometry2DData* geometry2dData = dynamic_cast(data); if(geometry2dData == NULL) continue; PlaneGeometry* planegeometry = dynamic_cast(geometry2dData->GetGeometry2D()); if (planegeometry != NULL) m_OtherGeometry2Ds.push_back(it->Value()); } } void mitk::Geometry2DDataMapper2D::Paint(BaseRenderer *renderer) { if ( !this->IsVisible(renderer) ) { return; } Geometry2DData::Pointer input = const_cast< Geometry2DData * >(this->GetInput()); // intersecting with ourself? if ( input.IsNull() || (this->GetInput()->GetGeometry2D() == renderer->GetCurrentWorldGeometry2D()) ) { return; // do nothing! } const PlaneGeometry *inputPlaneGeometry = dynamic_cast< const PlaneGeometry * >( input->GetGeometry2D() ); const PlaneGeometry *worldPlaneGeometry = dynamic_cast< const PlaneGeometry* >( renderer->GetCurrentWorldGeometry2D() ); if ( worldPlaneGeometry && inputPlaneGeometry && inputPlaneGeometry->GetReferenceGeometry() ) { DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); assert( displayGeometry ); const Geometry3D *referenceGeometry = inputPlaneGeometry->GetReferenceGeometry(); // calculate intersection of the plane data with the border of the // world geometry rectangle Point2D lineFrom, lineTo; typedef Geometry3D::TransformType TransformType; const TransformType *transform = dynamic_cast< const TransformType * >( referenceGeometry->GetIndexToWorldTransform() ); TransformType::Pointer inverseTransform = TransformType::New(); transform->GetInverse( inverseTransform ); Line3D crossLine, otherCrossLine; // Calculate the intersection line of the input plane with the world plane if ( worldPlaneGeometry->IntersectionLine( inputPlaneGeometry, crossLine ) ) { BoundingBox::PointType boundingBoxMin, boundingBoxMax; boundingBoxMin = referenceGeometry->GetBoundingBox()->GetMinimum(); boundingBoxMax = referenceGeometry->GetBoundingBox()->GetMaximum(); if(referenceGeometry->GetImageGeometry()) { for(unsigned int i = 0; i < 3; ++i) { boundingBoxMin[i]-=0.5; boundingBoxMax[i]-=0.5; } } crossLine.Transform( *inverseTransform ); Point3D point1, point2; // Then, clip this line with the (transformed) bounding box of the // reference geometry. if ( crossLine.BoxLineIntersection( boundingBoxMin[0], boundingBoxMin[1], boundingBoxMin[2], boundingBoxMax[0], boundingBoxMax[1], boundingBoxMax[2], crossLine.GetPoint(), crossLine.GetDirection(), point1, point2 ) == 2 ) { // Transform the resulting line start and end points into display // coordinates. worldPlaneGeometry->Map( transform->TransformPoint( point1 ), lineFrom ); worldPlaneGeometry->Map( transform->TransformPoint( point2 ), lineTo ); Line< ScalarType, 2 > mainLine, otherLine; Line< ScalarType, 2 > primaryHelperLine, secondaryHelperLine; mainLine.SetPoints( lineFrom, lineTo ); primaryHelperLine.SetPoints( lineFrom, lineTo ); secondaryHelperLine.SetPoints( lineFrom, lineTo ); displayGeometry->WorldToDisplay( lineFrom, lineFrom ); displayGeometry->WorldToDisplay( lineTo, lineTo ); ScalarType lengthInDisplayUnits = (lineTo - lineFrom).GetNorm(); Vector2D mainLineDirectionOrthogonal; mainLineDirectionOrthogonal[0] = -mainLine.GetDirection()[1]; mainLineDirectionOrthogonal[1] = mainLine.GetDirection()[0]; // lineParams stores the individual segments of the line, which are // separated by a gap each (to mark the intersection with another // displayed line) std::vector< ScalarType > mainLineParams; std::vector< ScalarType > primaryHelperLineParams; std::vector< ScalarType > secondaryHelperLineParams; mainLineParams.reserve( m_OtherGeometry2Ds.size() + 2 ); mainLineParams.push_back( 0.0 ); mainLineParams.push_back( 1.0 ); primaryHelperLineParams.reserve( m_OtherGeometry2Ds.size() + 2 ); primaryHelperLineParams.push_back( 0.0 ); primaryHelperLineParams.push_back( 1.0 ); secondaryHelperLineParams.reserve( m_OtherGeometry2Ds.size() + 2 ); secondaryHelperLineParams.push_back( 0.0 ); secondaryHelperLineParams.push_back( 1.0 ); // Now iterate through all other lines displayed in this window and // calculate the positions of intersection with the line to be // rendered; these positions will be stored in lineParams to form a // gap afterwards. NodesVectorType::iterator otherPlanesIt = m_OtherGeometry2Ds.begin(); NodesVectorType::iterator otherPlanesEnd = m_OtherGeometry2Ds.end(); - int mainLineThickSlicesMode = 0; + //int mainLineThickSlicesMode = 0; int mainLineThickSlicesNum = 1; DataNode* dataNodeOfInputPlaneGeometry = NULL; // Now we have to find the DataNode that contains the inputPlaneGeometry // in order to determine the state of the thick-slice rendering while ( otherPlanesIt != otherPlanesEnd ) { PlaneGeometry *otherPlane = static_cast< PlaneGeometry * >( static_cast< Geometry2DData * >( (*otherPlanesIt)->GetData() )->GetGeometry2D() ); // if we have found the correct node if ( (otherPlane == inputPlaneGeometry) && worldPlaneGeometry->IntersectionLine( otherPlane, otherCrossLine ) ) { dataNodeOfInputPlaneGeometry = (*otherPlanesIt); - if( dataNodeOfInputPlaneGeometry ) - { - mainLineThickSlicesMode = this->DetermineThickSliceMode(dataNodeOfInputPlaneGeometry, mainLineThickSlicesNum); - } +// if( dataNodeOfInputPlaneGeometry ) +// { +// mainLineThickSlicesMode = this->DetermineThickSliceMode(dataNodeOfInputPlaneGeometry, mainLineThickSlicesNum); +// } break; } otherPlanesIt++; } // if we did not find a dataNode for the inputPlaneGeometry there is nothing we can do from here if ( dataNodeOfInputPlaneGeometry == NULL ) return; // Determine if we should draw the area covered by the thick slicing, default is false. // This will also show the area of slices that do not have thick slice mode enabled bool showAreaOfThickSlicing = false; dataNodeOfInputPlaneGeometry->GetBoolProperty( "reslice.thickslices.showarea", showAreaOfThickSlicing ); // get the normal of the inputPlaneGeometry Vector3D normal = inputPlaneGeometry->GetNormal(); // determine the pixelSpacing in that direction double thickSliceDistance = SlicedGeometry3D::CalculateSpacing( referenceGeometry->GetSpacing(), normal ); // As the inputPlaneGeometry cuts through the center of the slice in the middle // we have to add 0.5 pixel in order to compensate. thickSliceDistance *= mainLineThickSlicesNum+0.5; // not the nicest place to do it, but we have the width of the visible bloc in MM here // so we store it in this fancy property dataNodeOfInputPlaneGeometry->SetFloatProperty( "reslice.thickslices.sizeinmm", thickSliceDistance*2 ); if ( showAreaOfThickSlicing ) { // vectorToHelperLine defines how to reach the helperLine from the mainLine Vector2D vectorToHelperLine; vectorToHelperLine = mainLineDirectionOrthogonal; vectorToHelperLine.Normalize(); // got the right direction, so we multiply the width vectorToHelperLine *= thickSliceDistance; // and create the corresponding points primaryHelperLine.SetPoints( primaryHelperLine.GetPoint1() - vectorToHelperLine, primaryHelperLine.GetPoint2() - vectorToHelperLine ); secondaryHelperLine.SetPoints( secondaryHelperLine.GetPoint1() + vectorToHelperLine, secondaryHelperLine.GetPoint2() + vectorToHelperLine ); } - int otherLineThickSlicesMode = 0; + //int otherLineThickSlicesMode = 0; int otherLineThickSlicesNum = 1; // by default, there is no gap for the helper lines ScalarType gapSize = 0.0; otherPlanesIt = m_OtherGeometry2Ds.begin(); while ( otherPlanesIt != otherPlanesEnd ) { PlaneGeometry *otherPlane = static_cast< PlaneGeometry * >( static_cast< Geometry2DData * >( (*otherPlanesIt)->GetData() )->GetGeometry2D() ); // Just as with the original line, calculate the intersection with // the world geometry... if ( (otherPlane != inputPlaneGeometry) && worldPlaneGeometry->IntersectionLine( otherPlane, otherCrossLine ) ) { - otherLineThickSlicesMode = this->DetermineThickSliceMode((*otherPlanesIt), otherLineThickSlicesNum); + //otherLineThickSlicesMode = this->DetermineThickSliceMode((*otherPlanesIt), otherLineThickSlicesNum); Vector3D normal = otherPlane->GetNormal(); double otherLineThickSliceDistance = SlicedGeometry3D::CalculateSpacing( referenceGeometry->GetSpacing(), normal ); otherLineThickSliceDistance *= (otherLineThickSlicesNum+0.5)*2; Point2D otherLineFrom, otherLineTo; // ... and clip the resulting line segment with the reference // geometry bounding box. otherCrossLine.Transform( *inverseTransform ); if ( otherCrossLine.BoxLineIntersection( boundingBoxMin[0], boundingBoxMin[1], boundingBoxMin[2], boundingBoxMax[0], boundingBoxMax[1], boundingBoxMax[2], otherCrossLine.GetPoint(), otherCrossLine.GetDirection(), point1, point2 ) == 2 ) { worldPlaneGeometry->Map( transform->TransformPoint( point1 ), otherLineFrom ); worldPlaneGeometry->Map( transform->TransformPoint( point2 ), otherLineTo ); otherLine.SetPoints( otherLineFrom, otherLineTo ); // then we have to determine the gap position of the main line // by finding the position at which the two lines cross this->DetermineParametricCrossPositions( mainLine, otherLine, mainLineParams ); // if the other line is also in thick slice mode, we have to determine the // gapsize considering the width of that other line and the spacing in its direction if ( showAreaOfThickSlicing ) { Vector2D otherLineDirection = otherLine.GetDirection(); otherLineDirection.Normalize(); mainLineDirectionOrthogonal.Normalize(); // determine the gapsize gapSize = fabs( otherLineThickSliceDistance / ( otherLineDirection*mainLineDirectionOrthogonal ) ); gapSize = gapSize / displayGeometry->GetScaleFactorMMPerDisplayUnit(); // determine the gap positions for the helper lines as well this->DetermineParametricCrossPositions( primaryHelperLine, otherLine, primaryHelperLineParams ); this->DetermineParametricCrossPositions( secondaryHelperLine, otherLine, secondaryHelperLineParams ); } } } ++otherPlanesIt; } // If we have to draw the helperlines, the mainline will be drawn as a dashed line // with a fixed gapsize of 10 pixels this->DrawLine(renderer, lengthInDisplayUnits, mainLine, mainLineParams, inputPlaneGeometry, showAreaOfThickSlicing, 10.0 ); // If drawn, the helperlines are drawn as a solid line. The gapsize depends on the // width of the crossed line. if ( showAreaOfThickSlicing ) { this->DrawLine(renderer, lengthInDisplayUnits, primaryHelperLine, primaryHelperLineParams, inputPlaneGeometry, false, gapSize ); this->DrawLine(renderer, lengthInDisplayUnits, secondaryHelperLine, secondaryHelperLineParams, inputPlaneGeometry, false, gapSize ); } } } } else { Geometry2DDataToSurfaceFilter::Pointer surfaceCreator; SmartPointerProperty::Pointer surfacecreatorprop; surfacecreatorprop = dynamic_cast< SmartPointerProperty * >( GetDataNode()->GetProperty( "surfacegeometry", renderer)); if( (surfacecreatorprop.IsNull()) || (surfacecreatorprop->GetSmartPointer().IsNull()) || ((surfaceCreator = dynamic_cast< Geometry2DDataToSurfaceFilter * >( surfacecreatorprop->GetSmartPointer().GetPointer())).IsNull()) ) { surfaceCreator = Geometry2DDataToSurfaceFilter::New(); surfacecreatorprop = SmartPointerProperty::New(surfaceCreator); surfaceCreator->PlaceByGeometryOn(); GetDataNode()->SetProperty( "surfacegeometry", surfacecreatorprop ); } surfaceCreator->SetInput( input ); // Clip the Geometry2D with the reference geometry bounds (if available) if ( input->GetGeometry2D()->HasReferenceGeometry() ) { surfaceCreator->SetBoundingBox( input->GetGeometry2D()->GetReferenceGeometry()->GetBoundingBox() ); } int res; bool usegeometryparametricbounds = true; if ( GetDataNode()->GetIntProperty("xresolution", res, renderer)) { surfaceCreator->SetXResolution(res); usegeometryparametricbounds=false; } if (GetDataNode()->GetIntProperty("yresolution", res, renderer)) { surfaceCreator->SetYResolution(res); usegeometryparametricbounds=false; } surfaceCreator->SetUseGeometryParametricBounds(usegeometryparametricbounds); // Calculate the surface of the Geometry2D surfaceCreator->Update(); if (m_SurfaceMapper.IsNull()) { m_SurfaceMapper=SurfaceGLMapper2D::New(); } m_SurfaceMapper->SetSurface(surfaceCreator->GetOutput()); m_SurfaceMapper->SetDataNode(GetDataNode()); m_SurfaceMapper->Paint(renderer); } } void mitk::Geometry2DDataMapper2D::DrawOrientationArrow( mitk::Point2D &outerPoint, mitk::Point2D &innerPoint, const mitk::PlaneGeometry *planeGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, const mitk::DisplayGeometry *displayGeometry, bool positiveOrientation ) { // Draw arrows to indicate plane orientation // Vector along line Vector2D v1 = innerPoint - outerPoint; v1.Normalize(); v1 *= 7.0; // Orthogonal vector Vector2D v2; v2[0] = v1[1]; v2[1] = -v1[0]; // Calculate triangle tip for one side and project it back into world // coordinates to determine whether it is above or below the plane Point2D worldPoint2D; Point3D worldPoint; displayGeometry->DisplayToWorld( outerPoint + v1 + v2, worldPoint2D ); rendererPlaneGeometry->Map( worldPoint2D, worldPoint ); // Initialize remaining triangle coordinates accordingly // (above/below state is XOR'ed with orientation flag) Point2D p1 = outerPoint + v1 * 2.0; Point2D p2 = outerPoint + v1 + ((positiveOrientation ^ planeGeometry->IsAbove( worldPoint )) ? v2 : -v2); // Draw the arrow (triangle) glBegin( GL_TRIANGLES ); glVertex2f( outerPoint[0], outerPoint[1] ); glVertex2f( p1[0], p1[1] ); glVertex2f( p2[0], p2[1] ); glEnd(); } void mitk::Geometry2DDataMapper2D::ApplyProperties( BaseRenderer *renderer ) { Superclass::ApplyProperties(renderer); PlaneOrientationProperty* decorationProperty; this->GetDataNode()->GetProperty( decorationProperty, "decoration", renderer ); if ( decorationProperty != NULL ) { if ( decorationProperty->GetPlaneDecoration() == PlaneOrientationProperty::PLANE_DECORATION_POSITIVE_ORIENTATION ) { m_RenderOrientationArrows = true; m_ArrowOrientationPositive = true; } else if ( decorationProperty->GetPlaneDecoration() == PlaneOrientationProperty::PLANE_DECORATION_NEGATIVE_ORIENTATION ) { m_RenderOrientationArrows = true; m_ArrowOrientationPositive = false; } else { m_RenderOrientationArrows = false; } } } void mitk::Geometry2DDataMapper2D::SetDatastorageAndGeometryBaseNode( mitk::DataStorage::Pointer ds, mitk::DataNode::Pointer parent ) { if (ds.IsNotNull()) { m_DataStorage = ds; } if (parent.IsNotNull()) { m_ParentNode = parent; } } void mitk::Geometry2DDataMapper2D::DrawLine( BaseRenderer* renderer, ScalarType lengthInDisplayUnits, Line &line, std::vector &gapPositions, const PlaneGeometry* inputPlaneGeometry, bool drawDashed, ScalarType gapSizeInPixel ) { DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); const PlaneGeometry *worldPlaneGeometry = dynamic_cast< const PlaneGeometry* >( renderer->GetCurrentWorldGeometry2D() ); // Apply color and opacity read from the PropertyList. this->ApplyProperties( renderer ); ScalarType gapSizeInParamUnits = 1.0 / lengthInDisplayUnits * gapSizeInPixel; std::sort( gapPositions.begin(), gapPositions.end() ); Point2D p1, p2; ScalarType p1Param, p2Param; p1Param = gapPositions[0]; p1 = line.GetPoint( p1Param ); displayGeometry->WorldToDisplay( p1, p1 ); //Workaround to show the crosshair always on top of a 2D render window //The image is usually located at depth = 0 or negative depth values, and thus, //the crosshair with depth = 1 is always on top. float depthPosition = 1.0f; if ( drawDashed ) { glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0xF0F0); } glEnable(GL_DEPTH_TEST); // Iterate over all line segments and display each, with a gap // in between. unsigned int i, preLastLineParam = gapPositions.size() - 1; for ( i = 1; i < preLastLineParam; ++i ) { p2Param = gapPositions[i] - gapSizeInParamUnits * 0.5; p2 = line.GetPoint( p2Param ); if ( p2Param > p1Param ) { // Convert intersection points (until now mm) to display // coordinates (units). displayGeometry->WorldToDisplay( p2, p2 ); // draw glBegin (GL_LINES); glVertex3f(p1[0],p1[1], depthPosition); glVertex3f(p2[0],p2[1], depthPosition); glEnd (); if ( (i == 1) && (m_RenderOrientationArrows) ) { // Draw orientation arrow for first line segment this->DrawOrientationArrow( p1, p2, inputPlaneGeometry, worldPlaneGeometry, displayGeometry, m_ArrowOrientationPositive ); } } p1Param = p2Param + gapSizeInParamUnits; p1 = line.GetPoint( p1Param ); displayGeometry->WorldToDisplay( p1, p1 ); } // Draw last line segment p2Param = gapPositions[i]; p2 = line.GetPoint( p2Param ); displayGeometry->WorldToDisplay( p2, p2 ); glBegin( GL_LINES ); glVertex3f( p1[0], p1[1], depthPosition); glVertex3f( p2[0], p2[1], depthPosition); glEnd(); if ( drawDashed ) { glDisable(GL_LINE_STIPPLE); } // Draw orientation arrows if ( m_RenderOrientationArrows ) { this->DrawOrientationArrow( p2, p1, inputPlaneGeometry, worldPlaneGeometry, displayGeometry, m_ArrowOrientationPositive ); if ( preLastLineParam < 2 ) { // If we only have one line segment, draw other arrow, too this->DrawOrientationArrow( p1, p2, inputPlaneGeometry, worldPlaneGeometry, displayGeometry, m_ArrowOrientationPositive ); } } } int mitk::Geometry2DDataMapper2D::DetermineThickSliceMode( DataNode * dn, int &thickSlicesNum ) { int thickSlicesMode = 0; // determine the state and the extend of the thick-slice mode mitk::ResliceMethodProperty *resliceMethodEnumProperty=0; if( dn->GetProperty( resliceMethodEnumProperty, "reslice.thickslices" ) && resliceMethodEnumProperty ) thickSlicesMode = resliceMethodEnumProperty->GetValueAsId(); IntProperty *intProperty=0; if( dn->GetProperty( intProperty, "reslice.thickslices.num" ) && intProperty ) { thickSlicesNum = intProperty->GetValue(); if(thickSlicesNum < 1) thickSlicesNum=0; if(thickSlicesNum > 10) thickSlicesNum=10; } if ( thickSlicesMode == 0 ) thickSlicesNum = 0; return thickSlicesMode; } void mitk::Geometry2DDataMapper2D::DetermineParametricCrossPositions( Line< mitk::ScalarType, 2 > &mainLine, Line< mitk::ScalarType, 2 > &otherLine, std::vector< mitk::ScalarType > &crossPositions ) { Vector2D direction, dOrth; // By means of the dot product, calculate the gap position as // parametric value in the range [0, 1] direction = otherLine.GetDirection(); dOrth[0] = -direction[1]; dOrth[1] = direction[0]; ScalarType gapPosition = ( otherLine.GetPoint1() - mainLine.GetPoint1() ) * dOrth; ScalarType norm = mainLine.GetDirection() * dOrth; if ( fabs( norm ) > eps ) { gapPosition /= norm; if ( (gapPosition > 0.0) && (gapPosition < 1.0) ) { crossPositions.push_back(gapPosition); } } } diff --git a/Core/Code/Rendering/mitkPointSetVtkMapper3D.cpp b/Core/Code/Rendering/mitkPointSetVtkMapper3D.cpp index 9b987f5408..8ffcb44e28 100644 --- a/Core/Code/Rendering/mitkPointSetVtkMapper3D.cpp +++ b/Core/Code/Rendering/mitkPointSetVtkMapper3D.cpp @@ -1,635 +1,635 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPointSetVtkMapper3D.h" #include "mitkDataNode.h" #include "mitkProperties.h" #include "mitkColorProperty.h" #include "mitkVtkPropRenderer.h" #include "mitkPointSet.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include const mitk::PointSet* mitk::PointSetVtkMapper3D::GetInput() { return static_cast ( GetData() ); } mitk::PointSetVtkMapper3D::PointSetVtkMapper3D() : m_vtkSelectedPointList(NULL), m_vtkUnselectedPointList(NULL), m_VtkSelectedPolyDataMapper(NULL), m_VtkUnselectedPolyDataMapper(NULL), m_vtkTextList(NULL), m_NumberOfSelectedAdded(0), m_NumberOfUnselectedAdded(0), m_PointSize(1.0), m_ContourRadius(0.5) { //propassembly m_PointsAssembly = vtkSmartPointer::New(); //creating actors to be able to set transform m_SelectedActor = vtkSmartPointer::New(); m_UnselectedActor = vtkSmartPointer::New(); m_ContourActor = vtkSmartPointer::New(); } mitk::PointSetVtkMapper3D::~PointSetVtkMapper3D() { } void mitk::PointSetVtkMapper3D::ReleaseGraphicsResources(vtkWindow *renWin) { m_PointsAssembly->ReleaseGraphicsResources(renWin); m_SelectedActor->ReleaseGraphicsResources(renWin); m_UnselectedActor->ReleaseGraphicsResources(renWin); m_ContourActor->ReleaseGraphicsResources(renWin); } void mitk::PointSetVtkMapper3D::CreateVTKRenderObjects() { m_vtkSelectedPointList = vtkSmartPointer::New(); m_vtkUnselectedPointList = vtkSmartPointer::New(); m_PointsAssembly->VisibilityOn(); if(m_PointsAssembly->GetParts()->IsItemPresent(m_SelectedActor)) m_PointsAssembly->RemovePart(m_SelectedActor); if(m_PointsAssembly->GetParts()->IsItemPresent(m_UnselectedActor)) m_PointsAssembly->RemovePart(m_UnselectedActor); if(m_PointsAssembly->GetParts()->IsItemPresent(m_ContourActor)) m_PointsAssembly->RemovePart(m_ContourActor); // exceptional displaying for PositionTracker -> MouseOrientationTool int mapperID; bool isInputDevice=false; if( this->GetDataNode()->GetBoolProperty("inputdevice",isInputDevice) && isInputDevice ) { if( this->GetDataNode()->GetIntProperty("BaseRendererMapperID",mapperID) && mapperID == 2) return; //The event for the PositionTracker came from the 3d widget and not needs to be displayed } // get and update the PointSet mitk::PointSet::Pointer input = const_cast(this->GetInput()); /* only update the input data, if the property tells us to */ bool update = true; this->GetDataNode()->GetBoolProperty("updateDataOnRender", update); if (update == true) input->Update(); int timestep = this->GetTimestep(); mitk::PointSet::DataType::Pointer itkPointSet = input->GetPointSet( timestep ); if ( itkPointSet.GetPointer() == NULL) { m_PointsAssembly->VisibilityOff(); return; } mitk::PointSet::PointsContainer::Iterator pointsIter; mitk::PointSet::PointDataContainer::Iterator pointDataIter; int j; m_NumberOfSelectedAdded = 0; m_NumberOfUnselectedAdded = 0; //create contour bool makeContour = false; this->GetDataNode()->GetBoolProperty("show contour", makeContour); if (makeContour) { this->CreateContour(NULL); } //now fill selected and unselected pointList //get size of Points in Property m_PointSize = 2; mitk::FloatProperty::Pointer pointSizeProp = dynamic_cast(this->GetDataNode()->GetProperty("pointsize")); if ( pointSizeProp.IsNotNull() ) m_PointSize = pointSizeProp->GetValue(); //get the property for creating a label onto every point only once bool showLabel = true; this->GetDataNode()->GetBoolProperty("show label", showLabel); const char * pointLabel=NULL; if(showLabel) { if(dynamic_cast(this->GetDataNode()->GetPropertyList()->GetProperty("label")) != NULL) pointLabel =dynamic_cast(this->GetDataNode()->GetPropertyList()->GetProperty("label"))->GetValue(); else showLabel = false; } //check if the list for the PointDataContainer is the same size as the PointsContainer. Is not, then the points were inserted manually and can not be visualized according to the PointData (selected/unselected) bool pointDataBroken = (itkPointSet->GetPointData()->Size() != itkPointSet->GetPoints()->Size()); //now add an object for each point in data pointDataIter = itkPointSet->GetPointData()->Begin(); for (j=0, pointsIter=itkPointSet->GetPoints()->Begin(); pointsIter!=itkPointSet->GetPoints()->End(); pointsIter++, j++) { //check for the pointtype in data and decide which geom-object to take and then add to the selected or unselected list int pointType; if(itkPointSet->GetPointData()->size() == 0 || pointDataBroken) pointType = mitk::PTUNDEFINED; else pointType = pointDataIter.Value().pointSpec; vtkSmartPointer source; switch (pointType) { case mitk::PTUNDEFINED: { vtkSmartPointer sphere = vtkSmartPointer::New(); sphere->SetRadius(m_PointSize); itk::Point point1 = pointsIter->Value(); sphere->SetCenter(point1[0],point1[1],point1[2]); //sphere->SetCenter(pointsIter.Value()[0],pointsIter.Value()[1],pointsIter.Value()[2]); //MouseOrientation Tool (PositionTracker) if(isInputDevice) { sphere->SetThetaResolution(10); sphere->SetPhiResolution(10); } else { sphere->SetThetaResolution(20); sphere->SetPhiResolution(20); } source = sphere; } break; case mitk::PTSTART: { vtkSmartPointer cube = vtkSmartPointer::New(); cube->SetXLength(m_PointSize/2); cube->SetYLength(m_PointSize/2); cube->SetZLength(m_PointSize/2); itk::Point point1 = pointsIter->Value(); cube->SetCenter(point1[0],point1[1],point1[2]); source = cube; } break; case mitk::PTCORNER: { vtkSmartPointer cone = vtkSmartPointer::New(); cone->SetRadius(m_PointSize); itk::Point point1 = pointsIter->Value(); cone->SetCenter(point1[0],point1[1],point1[2]); cone->SetResolution(20); source = cone; } break; case mitk::PTEDGE: { vtkSmartPointer cylinder = vtkSmartPointer::New(); cylinder->SetRadius(m_PointSize); itk::Point point1 = pointsIter->Value(); cylinder->SetCenter(point1[0],point1[1],point1[2]); cylinder->SetResolution(20); source = cylinder; } break; case mitk::PTEND: { vtkSmartPointer sphere = vtkSmartPointer::New(); sphere->SetRadius(m_PointSize); - itk::Point point1 = pointsIter->Value(); + //itk::Point point1 = pointsIter->Value(); sphere->SetThetaResolution(20); sphere->SetPhiResolution(20); source = sphere; } break; default: { vtkSmartPointer sphere = vtkSmartPointer::New(); sphere->SetRadius(m_PointSize); itk::Point point1 = pointsIter->Value(); sphere->SetCenter(point1[0],point1[1],point1[2]); sphere->SetThetaResolution(20); sphere->SetPhiResolution(20); source = sphere; } break; } if (!pointDataBroken) { if (pointDataIter.Value().selected) { m_vtkSelectedPointList->AddInput(source->GetOutput()); ++m_NumberOfSelectedAdded; } else { m_vtkUnselectedPointList->AddInput(source->GetOutput()); ++m_NumberOfUnselectedAdded; } } else { m_vtkUnselectedPointList->AddInput(source->GetOutput()); ++m_NumberOfUnselectedAdded; } if (showLabel) { char buffer[20]; std::string l = pointLabel; if ( input->GetSize()>1 ) { sprintf(buffer,"%d",j+1); l.append(buffer); } // Define the text for the label vtkSmartPointer label = vtkSmartPointer::New(); label->SetText(l.c_str()); //# Set up a transform to move the label to a new position. vtkSmartPointer aLabelTransform = vtkSmartPointer::New(); aLabelTransform->Identity(); itk::Point point1 = pointsIter->Value(); aLabelTransform->Translate(point1[0]+2,point1[1]+2,point1[2]); aLabelTransform->Scale(5.7,5.7,5.7); //# Move the label to a new position. vtkSmartPointer labelTransform = vtkSmartPointer::New(); labelTransform->SetTransform(aLabelTransform); labelTransform->SetInput(label->GetOutput()); //add it to the wright PointList if (pointType) { m_vtkSelectedPointList->AddInput(labelTransform->GetOutput()); ++m_NumberOfSelectedAdded; } else { m_vtkUnselectedPointList->AddInput(labelTransform->GetOutput()); ++m_NumberOfUnselectedAdded; } } if(pointDataIter != itkPointSet->GetPointData()->End()) pointDataIter++; } // end FOR //now according to number of elements added to selected or unselected, build up the rendering pipeline if (m_NumberOfSelectedAdded > 0) { m_VtkSelectedPolyDataMapper = vtkSmartPointer::New(); m_VtkSelectedPolyDataMapper->SetInput(m_vtkSelectedPointList->GetOutput()); //create a new instance of the actor m_SelectedActor = vtkSmartPointer::New(); m_SelectedActor->SetMapper(m_VtkSelectedPolyDataMapper); m_PointsAssembly->AddPart(m_SelectedActor); } if (m_NumberOfUnselectedAdded > 0) { m_VtkUnselectedPolyDataMapper = vtkSmartPointer::New(); m_VtkUnselectedPolyDataMapper->SetInput(m_vtkUnselectedPointList->GetOutput()); //create a new instance of the actor m_UnselectedActor = vtkSmartPointer::New(); m_UnselectedActor->SetMapper(m_VtkUnselectedPolyDataMapper); m_PointsAssembly->AddPart(m_UnselectedActor); } } void mitk::PointSetVtkMapper3D::GenerateData() { //create new vtk render objects (e.g. sphere for a point) this->CreateVTKRenderObjects(); //apply props this->ApplyProperties(m_ContourActor,NULL); } void mitk::PointSetVtkMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { SetVtkMapperImmediateModeRendering(m_VtkSelectedPolyDataMapper); SetVtkMapperImmediateModeRendering(m_VtkUnselectedPolyDataMapper); mitk::FloatProperty::Pointer pointSizeProp = dynamic_cast(this->GetDataNode()->GetProperty("pointsize")); mitk::FloatProperty::Pointer contourSizeProp = dynamic_cast(this->GetDataNode()->GetProperty("contoursize")); // only create new vtk render objects if property values were changed if ( pointSizeProp.IsNotNull() && contourSizeProp.IsNotNull() ) { if (m_PointSize!=pointSizeProp->GetValue() || m_ContourRadius!= contourSizeProp->GetValue()) { this->CreateVTKRenderObjects(); } } this->ApplyProperties(m_ContourActor,renderer); if(IsVisible(renderer)==false) { m_UnselectedActor->VisibilityOff(); m_SelectedActor->VisibilityOff(); m_ContourActor->VisibilityOff(); return; } bool showPoints = true; this->GetDataNode()->GetBoolProperty("show points", showPoints); if(showPoints) { m_UnselectedActor->VisibilityOn(); m_SelectedActor->VisibilityOn(); } else { m_UnselectedActor->VisibilityOff(); m_SelectedActor->VisibilityOff(); } if(dynamic_cast(this->GetDataNode()->GetProperty("opacity")) != NULL) { mitk::FloatProperty::Pointer pointOpacity =dynamic_cast(this->GetDataNode()->GetProperty("opacity")); float opacity = pointOpacity->GetValue(); m_ContourActor->GetProperty()->SetOpacity(opacity); m_UnselectedActor->GetProperty()->SetOpacity(opacity); m_SelectedActor->GetProperty()->SetOpacity(opacity); } bool makeContour = false; this->GetDataNode()->GetBoolProperty("show contour", makeContour); if (makeContour) { m_ContourActor->VisibilityOn(); } else { m_ContourActor->VisibilityOff(); } } void mitk::PointSetVtkMapper3D::ResetMapper( BaseRenderer* /*renderer*/ ) { m_PointsAssembly->VisibilityOff(); } vtkProp* mitk::PointSetVtkMapper3D::GetVtkProp(mitk::BaseRenderer * /*renderer*/) { return m_PointsAssembly; } void mitk::PointSetVtkMapper3D::UpdateVtkTransform(mitk::BaseRenderer * /*renderer*/) { vtkSmartPointer vtktransform = this->GetDataNode()->GetVtkTransform(this->GetTimestep()); m_SelectedActor->SetUserTransform(vtktransform); m_UnselectedActor->SetUserTransform(vtktransform); m_ContourActor->SetUserTransform(vtktransform); } void mitk::PointSetVtkMapper3D::ApplyProperties(vtkActor* actor, mitk::BaseRenderer* renderer) { Superclass::ApplyProperties(actor,renderer); //check for color props and use it for rendering of selected/unselected points and contour //due to different params in VTK (double/float) we have to convert! //vars to convert to vtkFloatingPointType unselectedColor[4]={1.0f,1.0f,0.0f,1.0f};//yellow vtkFloatingPointType selectedColor[4]={1.0f,0.0f,0.0f,1.0f};//red vtkFloatingPointType contourColor[4]={1.0f,0.0f,0.0f,1.0f};//red //different types for color!!! mitk::Color tmpColor; double opacity = 1.0; //check if there is an unselected property if (dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("unselectedcolor"))->GetValue(); unselectedColor[0] = tmpColor[0]; unselectedColor[1] = tmpColor[1]; unselectedColor[2] = tmpColor[2]; unselectedColor[3] = 1.0f; //!!define a new ColorProp to be able to pass alpha value } else if (dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("unselectedcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("unselectedcolor"))->GetValue(); unselectedColor[0] = tmpColor[0]; unselectedColor[1] = tmpColor[1]; unselectedColor[2] = tmpColor[2]; unselectedColor[3] = 1.0f; //!!define a new ColorProp to be able to pass alpha value } else { //check if the node has a color float unselectedColorTMP[4]={1.0f,1.0f,0.0f,1.0f};//yellow m_DataNode->GetColor(unselectedColorTMP, NULL); unselectedColor[0] = unselectedColorTMP[0]; unselectedColor[1] = unselectedColorTMP[1]; unselectedColor[2] = unselectedColorTMP[2]; //unselectedColor[3] stays 1.0f } //get selected property if (dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor"))->GetValue(); selectedColor[0] = tmpColor[0]; selectedColor[1] = tmpColor[1]; selectedColor[2] = tmpColor[2]; selectedColor[3] = 1.0f; } else if (dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor"))->GetValue(); selectedColor[0] = tmpColor[0]; selectedColor[1] = tmpColor[1]; selectedColor[2] = tmpColor[2]; selectedColor[3] = 1.0f; } //get contour property if (dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor"))->GetValue(); contourColor[0] = tmpColor[0]; contourColor[1] = tmpColor[1]; contourColor[2] = tmpColor[2]; contourColor[3] = 1.0f; } else if (dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor")) != NULL) { tmpColor = dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor"))->GetValue(); contourColor[0] = tmpColor[0]; contourColor[1] = tmpColor[1]; contourColor[2] = tmpColor[2]; contourColor[3] = 1.0f; } if(dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity")) != NULL) { mitk::FloatProperty::Pointer pointOpacity =dynamic_cast(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("opacity")); opacity = pointOpacity->GetValue(); } else if(dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("opacity")) != NULL) { mitk::FloatProperty::Pointer pointOpacity =dynamic_cast(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("opacity")); opacity = pointOpacity->GetValue(); } //finished color / opacity fishing! //check if a contour shall be drawn bool makeContour = false; this->GetDataNode()->GetBoolProperty("show contour", makeContour, renderer); int visibleBefore = m_ContourActor->GetVisibility(); if(makeContour && (m_ContourActor != NULL) ) { if ( visibleBefore == 0) {//was not visible before, so create it. this->CreateContour(renderer); } m_ContourActor->GetProperty()->SetColor(contourColor); m_ContourActor->GetProperty()->SetOpacity(opacity); } m_SelectedActor->GetProperty()->SetColor(selectedColor); m_SelectedActor->GetProperty()->SetOpacity(opacity); m_UnselectedActor->GetProperty()->SetColor(unselectedColor); m_UnselectedActor->GetProperty()->SetOpacity(opacity); } void mitk::PointSetVtkMapper3D::CreateContour(mitk::BaseRenderer* renderer) { vtkSmartPointer vtkContourPolyData = vtkSmartPointer::New(); vtkSmartPointer vtkContourPolyDataMapper = vtkSmartPointer::New(); vtkSmartPointer points = vtkSmartPointer::New(); vtkSmartPointer polys = vtkSmartPointer::New(); mitk::PointSet::PointsContainer::Iterator pointsIter; // mitk::PointSet::PointDataContainer::Iterator pointDataIter; int j; // get and update the PointSet mitk::PointSet::Pointer input = const_cast(this->GetInput()); int timestep = this->GetTimestep(); mitk::PointSet::DataType::Pointer itkPointSet = input->GetPointSet( timestep ); if ( itkPointSet.GetPointer() == NULL) { return; } for (j=0, pointsIter=itkPointSet->GetPoints()->Begin(); pointsIter!=itkPointSet->GetPoints()->End() ; pointsIter++,j++) { vtkIdType cell[2] = {j-1,j}; itk::Point point1 = pointsIter->Value(); points->InsertPoint(j,point1[0],point1[1],point1[2]); if (j>0) polys->InsertNextCell(2,cell); } bool close; if (dynamic_cast(this->GetDataNode()->GetPropertyList()->GetProperty("close contour"), renderer) == NULL) close = false; else close = dynamic_cast(this->GetDataNode()->GetPropertyList()->GetProperty("close contour"), renderer)->GetValue(); if (close) { vtkIdType cell[2] = {j-1,0}; polys->InsertNextCell(2,cell); } vtkSmartPointer contour = vtkSmartPointer::New(); contour->SetPoints(points); contour->SetLines(polys); contour->Update(); vtkSmartPointer tubeFilter = vtkSmartPointer::New(); tubeFilter->SetNumberOfSides( 12 ); tubeFilter->SetInput(contour); //check for property contoursize. m_ContourRadius = 0.5; mitk::FloatProperty::Pointer contourSizeProp = dynamic_cast(this->GetDataNode()->GetProperty("contoursize") ); if (contourSizeProp.IsNotNull()) m_ContourRadius = contourSizeProp->GetValue(); tubeFilter->SetRadius( m_ContourRadius ); tubeFilter->Update(); //add to pipeline vtkContourPolyData->AddInput(tubeFilter->GetOutput()); vtkContourPolyDataMapper->SetInput(vtkContourPolyData->GetOutput()); m_ContourActor->SetMapper(vtkContourPolyDataMapper); m_PointsAssembly->AddPart(m_ContourActor); } void mitk::PointSetVtkMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { node->AddProperty( "line width", mitk::IntProperty::New(2), renderer, overwrite ); node->AddProperty( "pointsize", mitk::FloatProperty::New(1.0), renderer, overwrite); node->AddProperty( "selectedcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite); //red node->AddProperty( "color", mitk::ColorProperty::New(1.0f, 1.0f, 0.0f), renderer, overwrite); //yellow node->AddProperty( "show contour", mitk::BoolProperty::New(false), renderer, overwrite ); node->AddProperty( "contourcolor", mitk::ColorProperty::New(1.0f, 0.0f, 0.0f), renderer, overwrite); node->AddProperty( "contoursize", mitk::FloatProperty::New(0.5), renderer, overwrite ); node->AddProperty( "show points", mitk::BoolProperty::New(true), renderer, overwrite ); node->AddProperty( "updateDataOnRender", mitk::BoolProperty::New(true), renderer, overwrite ); Superclass::SetDefaultProperties(node, renderer, overwrite); } diff --git a/Core/Code/Rendering/mitkRenderWindow.cpp b/Core/Code/Rendering/mitkRenderWindow.cpp index 459aaedde9..7a414fa52d 100644 --- a/Core/Code/Rendering/mitkRenderWindow.cpp +++ b/Core/Code/Rendering/mitkRenderWindow.cpp @@ -1,67 +1,89 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-07-05 09:49:37 +0200 (Mo, 05 Jul 2010) $ Version: $Revision: 24298 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkRenderWindow.h" #include "mitkDisplayPositionEvent.h" #include "mitkVtkLayerController.h" #include "mitkRenderingManager.h" #include "vtkRenderer.h" #include "vtkRenderWindowInteractor.h" #include "mitkVtkEventProvider.h" mitk::RenderWindow::RenderWindow(vtkRenderWindow* renWin, const char* name, mitk::RenderingManager* rm ) : m_vtkRenderWindow(renWin) { if(m_vtkRenderWindow == NULL) m_vtkRenderWindow = vtkRenderWindow::New(); + + if ( m_vtkRenderWindow->GetSize()[0] > 10 + || m_vtkRenderWindow->GetSize()[0] > 10 ) + { + m_vtkRenderWindow->SetSize( 100, 100 ); + } m_vtkRenderWindowInteractor = vtkRenderWindowInteractor::New(); - + m_vtkRenderWindowInteractor->SetRenderWindow(m_vtkRenderWindow); + m_vtkRenderWindowInteractor->Initialize(); + // initialize from RenderWindowBase Initialize(rm,name); m_vtkMitkEventProvider = vtkEventProvider::New(); m_vtkMitkEventProvider->SetInteractor(this->GetVtkRenderWindowInteractor()); m_vtkMitkEventProvider->SetMitkRenderWindow(this); m_vtkMitkEventProvider->SetEnabled(1); - m_vtkRenderWindowInteractor->SetRenderWindow(m_vtkRenderWindow); - m_vtkRenderWindowInteractor->Initialize(); } mitk::RenderWindow::~RenderWindow() { Destroy(); m_vtkRenderWindow->Delete(); m_vtkRenderWindowInteractor->Delete(); m_vtkMitkEventProvider->Delete(); } vtkRenderWindow* mitk::RenderWindow::GetVtkRenderWindow() { return m_vtkRenderWindow; } vtkRenderWindowInteractor* mitk::RenderWindow::GetVtkRenderWindowInteractor() { return m_vtkRenderWindowInteractor; } + +void mitk::RenderWindow::SetSize( int width, int height ) +{ + this->GetVtkRenderWindow()->SetSize( width, height ); + + this->resizeMitkEvent( width, height ); +} + +void mitk::RenderWindow::ReinitEventProvider() +{ + m_vtkMitkEventProvider->SetEnabled(0); + m_vtkMitkEventProvider->SetInteractor(this->GetVtkRenderWindowInteractor()); + m_vtkMitkEventProvider->SetMitkRenderWindow(this); + m_vtkMitkEventProvider->SetEnabled(1); +} + diff --git a/Core/Code/Rendering/mitkRenderWindow.h b/Core/Code/Rendering/mitkRenderWindow.h index ec5dfac5a2..565050075b 100644 --- a/Core/Code/Rendering/mitkRenderWindow.h +++ b/Core/Code/Rendering/mitkRenderWindow.h @@ -1,85 +1,108 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-06-30 15:12:34 +0200 (Mi, 30. Jun 2010) $ Version: $Revision: 24176 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKRENDERWINDOW_H_HEADER_INCLUDED_C1C40D66ASDF #define MITKRENDERWINDOW_H_HEADER_INCLUDED_C1C40D66ASDF #include #include "mitkRenderWindowBase.h" namespace mitk { class vtkEventProvider; /** * \brief mitkRenderWindow integrates the MITK rendering mechanism into VTK and * is NOT QT dependent * * * \ingroup Renderer */ class MITK_CORE_EXPORT RenderWindow: public mitk::RenderWindowBase, public itk::Object { public: mitkClassMacro(RenderWindow, itk::Object); itkNewMacro(Self); mitkNewMacro1Param(Self, vtkRenderWindow*); mitkNewMacro2Param(Self, vtkRenderWindow*, const char*); mitkNewMacro3Param(Self, vtkRenderWindow*, const char*, mitk::RenderingManager*); virtual ~RenderWindow(); virtual vtkRenderWindow* GetVtkRenderWindow(); virtual vtkRenderWindowInteractor* GetVtkRenderWindowInteractor(); // Set Layout Index to define the Layout Type void SetLayoutIndex( unsigned int layoutIndex ); // Get Layout Index to define the Layout Type unsigned int GetLayoutIndex(); //MenuWidget need to update the Layout Design List when Layout had changed void LayoutDesignListChanged( int layoutDesignIndex ); void FullScreenMode( bool state ); + /** + * \brief Convenience method to set the size of an mitkRenderWindow. + * + * This method sets the size of the vtkRenderWindow and tells the + * rendering that the size has changed -> adapts displayGeometry, etc. + */ + void SetSize( int width, int height ); + + /** + * \brief Initializes the mitkVtkEventProvider to listen to the + * currently used vtkInteractorStyle. + * + * This method makes sure that the internal mitkVtkEventProvider + * listens to the correct vtkInteractorStyle. + * This makes sure that VTK-Events are correctly translated into + * MITK-Events. + * + * \warn This method needs to be called MANUALLY as soon as the MapperID + * for this RenderWindow is changed or the vtkInteractorStyle is modified + * somehow else! + */ + void ReinitEventProvider(); + + protected: RenderWindow(vtkRenderWindow * existingRenderWindow = NULL , const char* name = "unnamed renderer", mitk::RenderingManager* rm = NULL ); void ResetView(); - vtkRenderWindow * m_vtkRenderWindow; vtkRenderWindowInteractor * m_vtkRenderWindowInteractor; vtkEventProvider * m_vtkMitkEventProvider; private: }; } //namespace #endif /* MITKRENDERWINDOW_H_HEADER_INCLUDED_C1C40D66ASDF */ diff --git a/Core/Code/Rendering/mitkVtkEventProvider.cpp b/Core/Code/Rendering/mitkVtkEventProvider.cpp index e687c15e78..0df42be5c6 100644 --- a/Core/Code/Rendering/mitkVtkEventProvider.cpp +++ b/Core/Code/Rendering/mitkVtkEventProvider.cpp @@ -1,257 +1,249 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-07-22 16:41:18 +0200 (Fr, 17 Aug 2007) $ Version: $Revision: 11618 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkVtkEventProvider.h" -#include "vtkCallbackCommand.h" -#include "vtkObjectFactory.h" -#include "vtkRenderWindowInteractor.h" #include "mitkVtkEventAdapter.h" - #include +#include +#include +#include +#include + #define VTKEVENTPROVIDER_INFO MBI_INFO("mitk.core.vtkeventprovider") #define VTKEVENTPROVIDER_WARN MBI_WARN("mitk.core.vtkeventprovider") #define VTKEVENTPROVIDER_ERROR MBI_ERROR("mitk.core.vtkeventprovider") #define VTKEVENTPROVIDER_DEBUG MBI_DEBUG("mitk.core.vtkeventprovider") namespace mitk { vtkCxxRevisionMacro(vtkEventProvider, "$Revision: 1.18 $"); vtkStandardNewMacro(vtkEventProvider); } //---------------------------------------------------------------------------- mitk::vtkEventProvider::vtkEventProvider() { // priority of the observer/command; we want MITK events processed in the very beginning this->Priority = 99999.99; //take over the processing of delete and keypress events from the superclass this->EventCallbackCommand->SetCallback( vtkEventProvider::ProcessEvents); // Set/Get the passive observer flag. If this is set to true, this // indicates that this command does not change the state of the // system in any way. Passive observers are processed first, and // are not called even when another command has focus. this->EventCallbackCommand->SetPassiveObserver(1); // get events first // mouse move AddInteractionEvent(vtkCommand::MouseMoveEvent); // mouse press AddInteractionEvent(vtkCommand::LeftButtonPressEvent); AddInteractionEvent(vtkCommand::MiddleButtonPressEvent); AddInteractionEvent(vtkCommand::RightButtonPressEvent); // mouse release AddInteractionEvent(vtkCommand::LeftButtonReleaseEvent); AddInteractionEvent(vtkCommand::MiddleButtonReleaseEvent); AddInteractionEvent(vtkCommand::RightButtonReleaseEvent); // wheel event AddInteractionEvent(vtkCommand::MouseWheelBackwardEvent); AddInteractionEvent(vtkCommand::MouseWheelForwardEvent); // key press event AddInteractionEvent(vtkCommand::KeyPressEvent); - // window resize event - AddInteractionEvent(vtkCommand::WidgetModifiedEvent); } mitk::vtkEventProvider::~vtkEventProvider() { this->SetInteractor(0); } void mitk::vtkEventProvider::SetMitkRenderWindow(mitk::RenderWindow* renWin) { m_RenderWindow = renWin; } mitk::RenderWindow* mitk::vtkEventProvider::GetRenderWindow() { return m_RenderWindow; } void mitk::vtkEventProvider::SetEnabled(int enabling) { if ( ! this->Interactor ) { VTKEVENTPROVIDER_ERROR <<"The interactor must be set prior to enabling/disabling widget"; return; } if ( enabling ) //---------------------------------------------------------- { VTKEVENTPROVIDER_DEBUG << "Enabling widget"; if ( this->Enabled ) //already enabled, just return { return; } this->Enabled = 1; // listen to all event types specified in m_InteractionEventsVector vtkRenderWindowInteractor *i = this->Interactor; InteractionEventsVectorType::iterator it; for(it = m_InteractionEventsVector.begin(); it != m_InteractionEventsVector.end(); it++) { - i->AddObserver((vtkCommand::EventIds) (*it), this->EventCallbackCommand, - this->Priority); + // add observer to interactorStyle + i->GetInteractorStyle()->AddObserver((vtkCommand::EventIds) (*it), this->EventCallbackCommand, + this->Priority); } this->InvokeEvent(vtkCommand::EnableEvent,NULL); } else //disabling----------------------------------------------------------- { VTKEVENTPROVIDER_DEBUG <<"Disabling widget"; if ( ! this->Enabled ) //already disabled, just return { return; } this->Enabled = 0; // don't listen for events any more this->Interactor->RemoveObserver(this->EventCallbackCommand); //this->Interactor->HandleEventLoop = 0; this->InvokeEvent(vtkCommand::DisableEvent,NULL); } } //---------------------------------------------------------------------------- // This adds the keypress event observer and the delete event observer void mitk::vtkEventProvider::SetInteractor(vtkRenderWindowInteractor* i) { if (i == this->Interactor) { return; } // if we already have an Interactor then stop observing it if (this->Interactor) this->SetEnabled(0); //disable the old interactor this->Interactor = i; this->Modified(); } //---------------------------------------------------------------------------- void mitk::vtkEventProvider::ProcessEvents(vtkObject* object, unsigned long event, void* clientData, void* vtkNotUsed(callData)) { vtkEventProvider* self = reinterpret_cast( clientData ); vtkRenderWindowInteractor* rwi = - static_cast( object ); + static_cast( object )->GetInteractor(); // base renderer mitk::BaseRenderer* baseRenderer = mitk::BaseRenderer::GetInstance(self->GetRenderWindow()->GetVtkRenderWindow()); switch(event) { // key press case vtkCommand::KeyPressEvent: { VTKEVENTPROVIDER_DEBUG << "key press event"; mitk::KeyEvent mke(mitk::VtkEventAdapter::AdaptKeyEvent(baseRenderer,event,rwi)); self->GetRenderWindow()->keyPressMitkEvent(&mke); break; } // mouse events case vtkCommand::MouseMoveEvent: { VTKEVENTPROVIDER_DEBUG << "mouse move event"; mitk::MouseEvent me(mitk::VtkEventAdapter::AdaptMouseEvent(baseRenderer,event,rwi)); self->GetRenderWindow()->mouseMoveMitkEvent(&me); break; } case vtkCommand::LeftButtonPressEvent: case vtkCommand::MiddleButtonPressEvent: case vtkCommand::RightButtonPressEvent: { VTKEVENTPROVIDER_DEBUG << "mouse press event"; mitk::MouseEvent me(mitk::VtkEventAdapter::AdaptMouseEvent(baseRenderer,event,rwi)); self->GetRenderWindow()->mousePressMitkEvent(&me); break; } case vtkCommand::LeftButtonReleaseEvent: case vtkCommand::MiddleButtonReleaseEvent: case vtkCommand::RightButtonReleaseEvent: { VTKEVENTPROVIDER_DEBUG << "mouse release event"; mitk::MouseEvent me(mitk::VtkEventAdapter::AdaptMouseEvent(baseRenderer,event,rwi)); self->GetRenderWindow()->mouseReleaseMitkEvent(&me); break; } // mouse WHEEL case vtkCommand::MouseWheelForwardEvent: case vtkCommand::MouseWheelBackwardEvent: { VTKEVENTPROVIDER_DEBUG << "mouse wheel event"; mitk::WheelEvent we(mitk::VtkEventAdapter::AdaptWheelEvent(baseRenderer,event,rwi)); self->GetRenderWindow()->wheelMitkEvent(&we); break; } - // widget resize - case vtkCommand::WidgetModifiedEvent: - { - VTKEVENTPROVIDER_DEBUG << "widget resize event"; - self->GetRenderWindow()->resizeMitkEvent(rwi->GetRenderWindow()->GetSize()[0],rwi->GetRenderWindow()->GetSize()[1]); - break; - } - default: VTKEVENTPROVIDER_INFO << "VTK event not mapped properly."; break; } } void mitk::vtkEventProvider::RemoveInteractionEvent(unsigned long ievent) { InteractionEventsVectorType::iterator it; if(m_InteractionEventsVector.size() > 0) { it = std::find(m_InteractionEventsVector.begin(),m_InteractionEventsVector.end(),ievent); if(it != m_InteractionEventsVector.end()) { m_InteractionEventsVector.erase(it); return; } } } void mitk::vtkEventProvider::AddInteractionEvent(unsigned long ievent) { // Remove event if it already exists RemoveInteractionEvent(ievent); m_InteractionEventsVector.push_back(ievent); } \ No newline at end of file diff --git a/Core/Code/Rendering/mitkVtkPropRenderer.cpp b/Core/Code/Rendering/mitkVtkPropRenderer.cpp index 73378abd11..5ea42204d3 100644 --- a/Core/Code/Rendering/mitkVtkPropRenderer.cpp +++ b/Core/Code/Rendering/mitkVtkPropRenderer.cpp @@ -1,918 +1,931 @@ /*========================================================================= Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkVtkPropRenderer.h" // MAPPERS #include "mitkMapper.h" #include "mitkImageVtkMapper2D.h" #include "mitkVtkMapper2D.h" #include "mitkVtkMapper3D.h" #include "mitkGeometry2DDataVtkMapper3D.h" #include "mitkPointSetGLMapper2D.h" #include "mitkImageSliceSelector.h" #include "mitkRenderingManager.h" #include "mitkGL.h" #include "mitkGeometry3D.h" #include "mitkDisplayGeometry.h" #include "mitkLevelWindow.h" #include "mitkCameraController.h" #include "mitkVtkInteractorCameraController.h" #include "mitkPlaneGeometry.h" #include "mitkProperties.h" #include "mitkSurface.h" #include "mitkNodePredicateDataType.h" +#include "mitkVtkInteractorStyle.h" // VTK #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include mitk::VtkPropRenderer::VtkPropRenderer( const char* name, vtkRenderWindow * renWin, mitk::RenderingManager* rm ) : BaseRenderer(name,renWin, rm), m_VtkMapperPresent(false), m_NewRenderer(true), - m_2DCameraInitialized(false) + m_CameraInitializedForMapperID(0) { didCount=false; m_WorldPointPicker = vtkWorldPointPicker::New(); m_PointPicker = vtkPointPicker::New(); m_PointPicker->SetTolerance( 0.0025 ); m_CellPicker = vtkCellPicker::New(); m_CellPicker->SetTolerance( 0.0025 ); mitk::Geometry2DDataVtkMapper3D::Pointer geometryMapper = mitk::Geometry2DDataVtkMapper3D::New(); m_CurrentWorldGeometry2DMapper = geometryMapper; m_CurrentWorldGeometry2DNode->SetMapper(2, geometryMapper); m_LightKit = vtkLightKit::New(); m_LightKit->AddLightsToRenderer(m_VtkRenderer); m_PickingMode = WorldPointPicking; m_TextRenderer = vtkRenderer::New(); m_TextRenderer->SetRenderWindow(renWin); m_TextRenderer->SetInteractive(0); m_TextRenderer->SetErase(0); } /*! \brief Destructs the VtkPropRenderer. */ mitk::VtkPropRenderer::~VtkPropRenderer() { // Workaround for GLDisplayList Bug { m_MapperID=0; checkState(); } if (m_LightKit != NULL) m_LightKit->Delete(); if (m_VtkRenderer!=NULL) { m_CameraController = NULL; m_VtkRenderer->Delete(); m_VtkRenderer = NULL; } else m_CameraController = NULL; if (m_WorldPointPicker != NULL) m_WorldPointPicker->Delete(); if (m_PointPicker != NULL) m_PointPicker->Delete(); if (m_CellPicker != NULL) m_CellPicker->Delete(); if (m_TextRenderer != NULL) m_TextRenderer->Delete(); } void mitk::VtkPropRenderer::SetDataStorage( mitk::DataStorage* storage ) { if ( storage == NULL ) return; BaseRenderer::SetDataStorage(storage); static_cast(m_CurrentWorldGeometry2DMapper.GetPointer())->SetDataStorageForTexture( m_DataStorage.GetPointer() ); // Compute the geometry from the current data tree bounds and set it as world geometry this->SetWorldGeometryToDataStorageBounds(); } bool mitk::VtkPropRenderer::SetWorldGeometryToDataStorageBounds() { if ( m_DataStorage.IsNull() ) return false; //initialize world geometry mitk::TimeSlicedGeometry::Pointer geometry = m_DataStorage->ComputeVisibleBoundingGeometry3D( NULL, "includeInBoundingBox" ); if ( geometry.IsNull() ) return false; this->SetWorldGeometry(geometry); //this->GetDisplayGeometry()->SetSizeInDisplayUnits( this->m_TextRenderer->GetRenderWindow()->GetSize()[0], this->m_TextRenderer->GetRenderWindow()->GetSize()[1] ); this->GetDisplayGeometry()->Fit(); this->GetVtkRenderer()->ResetCamera(); this->Modified(); return true; } /*! \brief Called by the vtkMitkRenderProp in order to start MITK rendering process. */ int mitk::VtkPropRenderer::Render(mitk::VtkPropRenderer::RenderType type) { // Do we have objects to render? if ( this->GetEmptyWorldGeometry()) return 0; if ( m_DataStorage.IsNull()) return 0; // Update mappers and prepare mapper queue if (type == VtkPropRenderer::Opaque) this->PrepareMapperQueue(); //go through the generated list and let the sorted mappers paint bool lastVtkBased = true; - bool sthVtkBased = false; + //bool sthVtkBased = false; for(MappersMapType::iterator it = m_MappersMap.begin(); it != m_MappersMap.end(); it++) { Mapper * mapper = (*it).second; if((mapper->IsVtkBased() == true) ) { - sthVtkBased = true; + //sthVtkBased = true; mitk::VtkMapper3D::Pointer vtkMapper = dynamic_cast(mapper); if(vtkMapper) { vtkMapper->GetVtkProp(this)->SetAllocatedRenderTime(5000,GetVtkRenderer()); //B/ ToDo: rendering time calculation //vtkMapper->GetVtkProp(this)->PokeMatrix(NULL); //B/ ToDo ??: VtkUserTransform } if(lastVtkBased == false) { Disable2DOpenGL(); lastVtkBased = true; } } else if((mapper->IsVtkBased() == false) && (lastVtkBased == true)) { Enable2DOpenGL(); lastVtkBased = false; } //Workarround for bug GL_TEXTURE_2D (bug #8188) GLboolean mode; GLenum bit = GL_TEXTURE_2D; GLfloat lineWidth; glGetFloatv(GL_LINE_WIDTH, &lineWidth); glGetBooleanv(bit, &mode); switch(type) { case mitk::VtkPropRenderer::Opaque: mapper->MitkRenderOpaqueGeometry(this); break; case mitk::VtkPropRenderer::Translucent: mapper->MitkRenderTranslucentGeometry(this); break; case mitk::VtkPropRenderer::Overlay: mapper->MitkRenderOverlay(this); break; case mitk::VtkPropRenderer::Volumetric: mapper->MitkRenderVolumetricGeometry(this); break; } if(mode) glEnable(bit); else glDisable(bit); glLineWidth(lineWidth); //end Workarround for bug GL_TEXTURE_2D (bug #8188) } if (lastVtkBased == false) Disable2DOpenGL(); // Render text if (type == VtkPropRenderer::Overlay) { if (m_TextCollection.size() > 0) { for (TextMapType::iterator it = m_TextCollection.begin(); it != m_TextCollection.end() ; it++) m_TextRenderer->AddViewProp((*it).second); m_TextRenderer->Render(); } } return 1; } /*! \brief PrepareMapperQueue iterates the datatree PrepareMapperQueue iterates the datatree in order to find mappers which shall be rendered. Also, it sortes the mappers wrt to their layer. */ void mitk::VtkPropRenderer::PrepareMapperQueue() { // variable for counting LOD-enabled mappers m_NumberOfVisibleLODEnabledMappers = 0; // Do we have to update the mappers ? if ( m_LastUpdateTime < GetMTime() || m_LastUpdateTime < GetDisplayGeometry()->GetMTime() ) { Update(); } else if (m_MapperID>=1 && m_MapperID < 6) Update(); // remove all text properties before mappers will add new ones m_TextRenderer->RemoveAllViewProps(); for ( unsigned int i=0; iDelete(); } m_TextCollection.clear(); // clear priority_queue m_MappersMap.clear(); int mapperNo = 0; //DataStorage if( m_DataStorage.IsNull() ) return; DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll(); for (DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it) { DataNode::Pointer node = it->Value(); if ( node.IsNull() ) continue; mitk::Mapper::Pointer mapper = node->GetMapper(m_MapperID); if ( mapper.IsNull() ) continue; // The information about LOD-enabled mappers is required by RenderingManager if ( mapper->IsLODEnabled( this ) && mapper->IsVisible( this ) ) { ++m_NumberOfVisibleLODEnabledMappers; } // mapper without a layer property get layer number 1 int layer = 1; node->GetIntProperty("layer", layer, this); int nr = (layer<<16) + mapperNo; m_MappersMap.insert( std::pair< int, Mapper * >( nr, mapper ) ); mapperNo++; } } /*! \brief Enable2DOpenGL() and Disable2DOpenGL() are used to switch between 2D rendering (orthographic projection) and 3D rendering (perspective projection) */ void mitk::VtkPropRenderer::Enable2DOpenGL() { GLint iViewport[4]; // Get a copy of the viewport glGetIntegerv( GL_VIEWPORT, iViewport ); // Save a copy of the projection matrix so that we can restore it // when it's time to do 3D rendering again. glMatrixMode( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); // Set up the orthographic projection glOrtho( iViewport[0], iViewport[0]+iViewport[2], iViewport[1], iViewport[1]+iViewport[3], -1.0, 1.0 ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); // Make sure depth testing and lighting are disabled for 2D rendering until // we are finished rendering in 2D glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT ); glDisable( GL_DEPTH_TEST ); glDisable( GL_LIGHTING ); } /*! \brief Initialize the VtkPropRenderer Enable2DOpenGL() and Disable2DOpenGL() are used to switch between 2D rendering (orthographic projection) and 3D rendering (perspective projection) */ void mitk::VtkPropRenderer::Disable2DOpenGL() { glPopAttrib(); glMatrixMode( GL_PROJECTION ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); glPopMatrix(); } void mitk::VtkPropRenderer::Update(mitk::DataNode* datatreenode) { if(datatreenode!=NULL) { mitk::Mapper::Pointer mapper = datatreenode->GetMapper(m_MapperID); if(mapper.IsNotNull()) { Mapper2D* mapper2d=dynamic_cast(mapper.GetPointer()); if(mapper2d != NULL) { if(GetDisplayGeometry()->IsValid()) { VtkMapper2D* vtkmapper2d=dynamic_cast(mapper.GetPointer()); if(vtkmapper2d != NULL) { vtkmapper2d->Update(this); m_VtkMapperPresent=true; } else mapper2d->Update(this); } } else { VtkMapper3D* vtkmapper3d=dynamic_cast(mapper.GetPointer()); if(vtkmapper3d != NULL) { vtkmapper3d->Update(this); vtkmapper3d->UpdateVtkTransform(this); m_VtkMapperPresent=true; } } } } } void mitk::VtkPropRenderer::Update() { if( m_DataStorage.IsNull() ) return; m_VtkMapperPresent = false; mitk::DataStorage::SetOfObjects::ConstPointer all = m_DataStorage->GetAll(); for (mitk::DataStorage::SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it) Update(it->Value()); Modified(); m_LastUpdateTime = GetMTime(); } /*! \brief This method is called from the two Constructors */ void mitk::VtkPropRenderer::InitRenderer(vtkRenderWindow* renderWindow) { BaseRenderer::InitRenderer(renderWindow); if(renderWindow == NULL) { m_InitNeeded = false; m_ResizeNeeded = false; return; } m_InitNeeded = true; m_ResizeNeeded = true; m_LastUpdateTime = 0; } /*! \brief Resize the OpenGL Window */ void mitk::VtkPropRenderer::Resize(int w, int h) { BaseRenderer::Resize(w, h); m_RenderingManager->RequestUpdate(this->GetRenderWindow()); } void mitk::VtkPropRenderer::InitSize(int w, int h) { m_RenderWindow->SetSize(w,h); Superclass::InitSize(w, h); Modified(); Update(); if(m_VtkRenderer!=NULL) { int w=vtkObject::GetGlobalWarningDisplay(); vtkObject::GlobalWarningDisplayOff(); m_VtkRenderer->ResetCamera(); vtkObject::SetGlobalWarningDisplay(w); } } void mitk::VtkPropRenderer::SetMapperID(const MapperSlotId mapperId) { if(m_MapperID != mapperId) Superclass::SetMapperID(mapperId); // Workaround for GL Displaylist Bug checkState(); } /*! \brief Activates the current renderwindow. */ void mitk::VtkPropRenderer::MakeCurrent() { if(m_RenderWindow!=NULL) m_RenderWindow->MakeCurrent(); } void mitk::VtkPropRenderer::PickWorldPoint(const mitk::Point2D& displayPoint, mitk::Point3D& worldPoint) const { if(m_VtkMapperPresent) { //m_WorldPointPicker->SetTolerance (0.0001); switch ( m_PickingMode ) { case (WorldPointPicking) : { m_WorldPointPicker->Pick(displayPoint[0], displayPoint[1], 0, m_VtkRenderer); vtk2itk(m_WorldPointPicker->GetPickPosition(), worldPoint); break; } case (PointPicking) : { // create a new vtkRenderer // give it all necessary information (camera position, etc.) // get all surfaces from datastorage, get actors from them // add all those actors to the new renderer // give this new renderer to pointpicker /* vtkRenderer* pickingRenderer = vtkRenderer::New(); pickingRenderer->SetActiveCamera( ); DataStorage* dataStorage = m_DataStorage; TNodePredicateDataType isSurface; DataStorage::SetOfObjects::ConstPointer allSurfaces = dataStorage->GetSubset( isSurface ); MITK_INFO << "in picking: got " << allSurfaces->size() << " surfaces." << std::endl; for (DataStorage::SetOfObjects::const_iterator iter = allSurfaces->begin(); iter != allSurfaces->end(); ++iter) { const DataNode* currentNode = *iter; VtkMapper3D* baseVtkMapper3D = dynamic_cast( currentNode->GetMapper( BaseRenderer::Standard3D ) ); if ( baseVtkMapper3D ) { vtkActor* actor = dynamic_cast( baseVtkMapper3D->GetViewProp() ); if (actor) { MITK_INFO << "a" << std::flush; pickingRenderer->AddActor( actor ); } } } MITK_INFO << ";" << std::endl; */ m_PointPicker->Pick(displayPoint[0], displayPoint[1], 0, m_VtkRenderer); vtk2itk(m_PointPicker->GetPickPosition(), worldPoint); break; } } } else { Superclass::PickWorldPoint(displayPoint, worldPoint); } } mitk::DataNode * mitk::VtkPropRenderer::PickObject( const Point2D &displayPosition, Point3D &worldPosition ) const { if ( m_VtkMapperPresent ) { m_CellPicker->InitializePickList(); // Iterate over all DataStorage objects to determine all vtkProps intended // for picking DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll(); for ( DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it ) { DataNode *node = it->Value(); if ( node == NULL ) continue; bool pickable = false; node->GetBoolProperty( "pickable", pickable ); if ( !pickable ) continue; VtkMapper3D *mapper = dynamic_cast< VtkMapper3D * > ( node->GetMapper( m_MapperID ) ); if ( mapper == NULL ) continue; vtkProp *prop = mapper->GetVtkProp( (mitk::BaseRenderer *)this ); if ( prop == NULL ) continue; m_CellPicker->AddPickList( prop ); } // Do the picking and retrieve the picked vtkProp (if any) m_CellPicker->PickFromListOn(); m_CellPicker->Pick( displayPosition[0], displayPosition[1], 0.0, m_VtkRenderer ); m_CellPicker->PickFromListOff(); vtk2itk( m_CellPicker->GetPickPosition(), worldPosition ); vtkProp *prop = m_CellPicker->GetViewProp(); if ( prop == NULL ) { return NULL; } // Iterate over all DataStorage objects to determine if the retrieved // vtkProp is owned by any associated mapper. for ( DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it) { DataNode::Pointer node = it->Value(); if ( node.IsNull() ) continue; mitk::Mapper::Pointer mapper = node->GetMapper( m_MapperID ); if ( mapper.IsNull() ) continue; if ( mapper->HasVtkProp( prop, const_cast< mitk::VtkPropRenderer * >( this ) ) ) { return node; } } return NULL; } else { return Superclass::PickObject( displayPosition, worldPosition ); } }; /*! \brief Writes some 2D text as overlay. Function returns an unique int Text_ID for each call, which can be used via the GetTextLabelProperty(int text_id) function in order to get a vtkTextProperty. This property enables the setup of font, font size, etc. */ int mitk::VtkPropRenderer::WriteSimpleText(std::string text, double posX, double posY, double color1, double color2, double color3) { if(text.size() > 0) { vtkTextActor* textActor = vtkTextActor::New(); textActor->SetPosition(posX,posY); textActor->SetInput(text.c_str()); textActor->GetTextProperty()->SetColor(color1, color2, color3); //TODO: Read color from node property int text_id = m_TextCollection.size(); m_TextCollection.insert(TextMapType::value_type(text_id,textActor)); return text_id; } return -1; } /*! \brief Can be used in order to get a vtkTextProperty for a specific text_id. This property enables the setup of font, font size, etc. */ vtkTextProperty* mitk::VtkPropRenderer::GetTextLabelProperty(int text_id) { return this->m_TextCollection[text_id]->GetTextProperty(); } void mitk::VtkPropRenderer::InitPathTraversal() { if (m_DataStorage.IsNotNull()) { m_PickingObjects = m_DataStorage->GetAll(); m_PickingObjectsIterator = m_PickingObjects->begin(); } } vtkAssemblyPath* mitk::VtkPropRenderer::GetNextPath() { if (m_DataStorage.IsNull() ) { return NULL; } if ( m_PickingObjectsIterator == m_PickingObjects->end() ) { return NULL; } vtkAssemblyPath* returnPath = vtkAssemblyPath::New(); //returnPath->Register(NULL); bool success = false; while (!success) { // loop until AddNode can be called successfully const DataNode* node = *m_PickingObjectsIterator; if (node) { Mapper* mapper = node->GetMapper( BaseRenderer::Standard3D ); if (mapper) { VtkMapper3D* vtkmapper = dynamic_cast( mapper ); if (vtkmapper) { vtkProp* prop = vtkmapper->GetVtkProp(this); if ( prop && prop->GetVisibility() ) { // add to assembly path returnPath->AddNode( prop, prop->GetMatrix() ); success = true; } } } } ++m_PickingObjectsIterator; if ( m_PickingObjectsIterator == m_PickingObjects->end() ) break; } if ( success ) { return returnPath; } else { return NULL; } } void mitk::VtkPropRenderer::ReleaseGraphicsResources(vtkWindow *renWin) { if( m_DataStorage.IsNull() ) return; DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll(); for (DataStorage::SetOfObjects::const_iterator iter = allObjects->begin(); iter != allObjects->end(); ++iter) { DataNode::Pointer node = *iter; if ( node.IsNull() ) continue; Mapper::Pointer mapper = node->GetMapper(m_MapperID); if(mapper.IsNotNull()) mapper->ReleaseGraphicsResources(renWin); } } const vtkWorldPointPicker *mitk::VtkPropRenderer::GetWorldPointPicker() const { return m_WorldPointPicker; } const vtkPointPicker *mitk::VtkPropRenderer::GetPointPicker() const { return m_PointPicker; } const vtkCellPicker *mitk::VtkPropRenderer::GetCellPicker() const { return m_CellPicker; } mitk::VtkPropRenderer::MappersMapType mitk::VtkPropRenderer::GetMappersMap() const { return m_MappersMap; } // Workaround for GL Displaylist bug static int glWorkAroundGlobalCount = 0; bool mitk::VtkPropRenderer::useImmediateModeRendering() { return glWorkAroundGlobalCount>1; } void mitk::VtkPropRenderer::checkState() { if (m_MapperID == Standard3D) { if (!didCount) { didCount = true; glWorkAroundGlobalCount++; if (glWorkAroundGlobalCount == 2) { MITK_INFO << "Multiple 3D Renderwindows active...: turning Immediate Rendering ON for legacy mappers"; // vtkMapper::GlobalImmediateModeRenderingOn(); } //MITK_INFO << "GLOBAL 3D INCREASE " << glWorkAroundGlobalCount << "\n"; } } else { if(didCount) { didCount=false; glWorkAroundGlobalCount--; if(glWorkAroundGlobalCount==1) { MITK_INFO << "Single 3D Renderwindow active...: turning Immediate Rendering OFF for legacy mappers"; // vtkMapper::GlobalImmediateModeRenderingOff(); } //MITK_INFO << "GLOBAL 3D DECREASE " << glWorkAroundGlobalCount << "\n"; } } } //### Contains all methods which are neceassry before each VTK Render() call void mitk::VtkPropRenderer::PrepareRender() { - // if(!m_2DCameraInitialized) - // { - m_2DCameraInitialized = Initialize2DvtkCamera(); //Set parallel projection etc. TODO: call only once per RW - // } + if ( this->GetMapperID() != m_CameraInitializedForMapperID ) + { + Initialize2DvtkCamera(); //Set parallel projection etc. + } + AdjustCameraToScene(); //Prepare camera for 2D render windows } -bool mitk::VtkPropRenderer::Initialize2DvtkCamera(){ - if(this->GetMapperID() == Standard2D) +bool mitk::VtkPropRenderer::Initialize2DvtkCamera() +{ + if ( this->GetMapperID() == Standard3D ) + { + //activate parallel projection for 2D + this->GetVtkRenderer()->GetActiveCamera()->SetParallelProjection(false); + this->GetRenderWindow()->GetInteractor()->SetInteractorStyle( vtkInteractorStyleTrackballCamera::New() ); + m_CameraInitializedForMapperID = Standard3D; + } + else if( this->GetMapperID() == Standard2D) { //activate parallel projection for 2D this->GetVtkRenderer()->GetActiveCamera()->SetParallelProjection(true); //turn the light out in the scene in order to render correct grey values. //TODO Implement a property for light in the 2D render windows (in another method) this->GetVtkRenderer()->RemoveAllLights(); - //remove the VTK interaction - this->GetVtkRenderer()->GetRenderWindow()->GetInteractor()->Disable(); + + this->GetRenderWindow()->GetInteractor()->SetInteractorStyle( mitkVtkInteractorStyle::New() ); + + m_CameraInitializedForMapperID = Standard2D; } return true; } void mitk::VtkPropRenderer::AdjustCameraToScene(){ if(this->GetMapperID() == Standard2D) { const mitk::DisplayGeometry* displayGeometry = this->GetDisplayGeometry(); double objectHeightInMM = this->GetCurrentWorldGeometry2D()->GetExtentInMM(1);//the height of the current object slice in mm double displayHeightInMM = displayGeometry->GetSizeInMM()[1]; //the display height in mm (gets smaller when you zoom in) double zoomFactor = objectHeightInMM/displayHeightInMM; //displayGeometry->GetScaleFactorMMPerDisplayUnit() //determine how much of the object can be displayed Vector2D displayGeometryOriginInMM = displayGeometry->GetOriginInMM(); //top left of the render window (Origin) Vector2D displayGeometryCenterInMM = displayGeometryOriginInMM + displayGeometry->GetSizeInMM()*0.5; //center of the render window: (Origin + Size/2) //Scale the rendered object: //The image is scaled by a single factor, because in an orthographic projection sizes //are preserved (so you cannot scale X and Y axis with different parameters). The //parameter sets the size of the total display-volume. If you set this to the image //height, the image plus a border with the size of the image will be rendered. //Therefore, the size is imageHeightInMM / 2. this->GetVtkRenderer()->GetActiveCamera()->SetParallelScale(objectHeightInMM*0.5 ); //zooming with the factor calculated by dividing displayHeight through imegeHeight. The factor is inverse, because the VTK zoom method is working inversely. this->GetVtkRenderer()->GetActiveCamera()->Zoom(zoomFactor); //the center of the view-plane double viewPlaneCenter[3]; viewPlaneCenter[0] = displayGeometryCenterInMM[0]; viewPlaneCenter[1] = displayGeometryCenterInMM[1]; viewPlaneCenter[2] = 0.0; //the view-plane is located in the XY-plane with Z=0.0 //define which direction is "up" for the ciamera (like default for vtk (0.0, 1.0, 0.0) double cameraUp[3]; cameraUp[0] = 0.0; cameraUp[1] = 1.0; cameraUp[2] = 0.0; //the position of the camera (center[0], center[1], 900000) double cameraPosition[3]; cameraPosition[0] = viewPlaneCenter[0]; cameraPosition[1] = viewPlaneCenter[1]; cameraPosition[2] = 900000.0; //Reason for 900000: VTK seems to calculate the clipping planes wrong for small values. See VTK bug (id #7823) in VTK bugtracker. //set the camera corresponding to the textured plane vtkSmartPointer camera = this->GetVtkRenderer()->GetActiveCamera(); if (camera) { camera->SetPosition( cameraPosition ); //set the camera position on the textured plane normal (in our case this is the view plane normal) camera->SetFocalPoint( viewPlaneCenter ); //set the focal point to the center of the textured plane camera->SetViewUp( cameraUp ); //set the view-up for the camera // double distance = sqrt((cameraPosition[2]-viewPlaneCenter[2])*(cameraPosition[2]-viewPlaneCenter[2])); // camera->SetClippingRange(distance-50, distance+50); //Reason for huge range: VTK seems to calculate the clipping planes wrong for small values. See VTK bug (id #7823) in VTK bugtracker. camera->SetClippingRange(0.1, 1000000); //Reason for huge range: VTK seems to calculate the clipping planes wrong for small values. See VTK bug (id #7823) in VTK bugtracker. } const PlaneGeometry *planeGeometry = dynamic_cast< const PlaneGeometry * >( this->GetCurrentWorldGeometry2D() ); if ( planeGeometry != NULL ) { //Transform the camera to the current position (transveral, coronal and saggital plane). //This is necessary, because the SetUserTransform() method does not manipulate the vtkCamera. //(Without not all three planes would be visible). vtkSmartPointer trans = vtkSmartPointer::New(); vtkSmartPointer matrix = vtkSmartPointer::New(); Point3D origin; Vector3D right, bottom, normal; origin = planeGeometry->GetOrigin(); right = planeGeometry->GetAxisVector( 0 ); // right = Extent of Image in mm (worldspace) bottom = planeGeometry->GetAxisVector( 1 ); normal = planeGeometry->GetNormal(); right.Normalize(); bottom.Normalize(); normal.Normalize(); matrix->SetElement(0, 0, right[0]); matrix->SetElement(1, 0, right[1]); matrix->SetElement(2, 0, right[2]); matrix->SetElement(0, 1, bottom[0]); matrix->SetElement(1, 1, bottom[1]); matrix->SetElement(2, 1, bottom[2]); matrix->SetElement(0, 2, normal[0]); matrix->SetElement(1, 2, normal[1]); matrix->SetElement(2, 2, normal[2]); matrix->SetElement(0, 3, origin[0]); matrix->SetElement(1, 3, origin[1]); matrix->SetElement(2, 3, origin[2]); matrix->SetElement(3, 0, 0.0); matrix->SetElement(3, 1, 0.0); matrix->SetElement(3, 2, 0.0); matrix->SetElement(3, 3, 1.0); trans->SetMatrix(matrix); //Transform the camera to the current position (transveral, coronal and saggital plane). this->GetVtkRenderer()->GetActiveCamera()->ApplyTransform(trans); } } } diff --git a/Core/Code/Rendering/mitkVtkPropRenderer.h b/Core/Code/Rendering/mitkVtkPropRenderer.h index 588018d05a..79fae29200 100644 --- a/Core/Code/Rendering/mitkVtkPropRenderer.h +++ b/Core/Code/Rendering/mitkVtkPropRenderer.h @@ -1,241 +1,241 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2007-09-22 12:01:41 +0200 (Sa, 22 Sep 2007) $ Version: $Revision: 12241 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKVtkPropRenderer_H_HEADER_INCLUDED_C1C29F6D #define MITKVtkPropRenderer_H_HEADER_INCLUDED_C1C29F6D #include #include "mitkBaseRenderer.h" #include "mitkDataStorage.h" #include "mitkRenderingManager.h" #include #include #include class vtkRenderWindow; class vtkLight; class vtkLightKit; class vtkWorldPointPicker; class vtkPointPicker; class vtkCellPicker; class vtkTextActor; class vtkTextProperty; class vtkAssemblyPath; namespace mitk { class Mapper; /*! \brief VtkPropRenderer VtkPropRenderer organizes the MITK rendering process. The MITK rendering process is completely integrated into the VTK rendering pipeline. The vtkMitkRenderProp is a custom vtkProp derived class, which implements the rendering interface between MITK and VTK. It redirects render() calls to the VtkPropRenderer, which is responsible for rendering of the datatreenodes. VtkPropRenderer replaces the old OpenGLRenderer. \sa rendering \ingroup rendering */ class MITK_CORE_EXPORT VtkPropRenderer : public BaseRenderer { // Workaround for Displaylistbug private: bool didCount; void checkState(); // Workaround END public: mitkClassMacro(VtkPropRenderer,BaseRenderer); mitkNewMacro3Param(VtkPropRenderer, const char*, vtkRenderWindow *, mitk::RenderingManager* ); typedef std::map MappersMapType; // Render - called by vtkMitkRenderProp, returns the number of props rendered enum RenderType{Opaque,Translucent,Overlay,Volumetric}; int Render(RenderType type); /** \brief This methods contains all method neceassary before a VTK Render() call */ virtual void PrepareRender(); // Active current renderwindow virtual void MakeCurrent(); virtual void SetDataStorage( mitk::DataStorage* storage ); ///< set the datastorage that will be used for rendering virtual void InitRenderer(vtkRenderWindow* renderwindow); virtual void Update(mitk::DataNode* datatreenode); virtual void SetMapperID(const MapperSlotId mapperId); // Size virtual void InitSize(int w, int h); virtual void Resize(int w, int h); // Picking enum PickingMode{ WorldPointPicking, PointPicking }; itkSetEnumMacro( PickingMode, PickingMode ); itkGetEnumMacro( PickingMode, PickingMode ); virtual void PickWorldPoint(const Point2D& displayPoint, Point3D& worldPoint) const; virtual mitk::DataNode *PickObject( const Point2D &displayPosition, Point3D &worldPosition ) const; // Simple text rendering method int WriteSimpleText(std::string text, double posX, double posY, double color1 = 0.0, double color2 = 1.0, double color3 = 0.0); vtkTextProperty * GetTextLabelProperty(int text_id); // Initialization / geometry handling /** This method calculates the bounds of the DataStorage (if it contains any * valid data), creates a geometry from these bounds and sets it as world * geometry of the renderer. * * Call this method to re-initialize the renderer to the current DataStorage * (e.g. after loading an additional dataset), to ensure that the view is * aligned correctly. */ virtual bool SetWorldGeometryToDataStorageBounds(); /** * \brief Used by vtkPointPicker/vtkPicker. * This will query a list of all objects in MITK and provide every vtk based mapper to the picker. */ void InitPathTraversal(); /** * \brief Used by vtkPointPicker/vtkPicker. * This will query a list of all objects in MITK and provide every vtk based mapper to the picker. */ vtkAssemblyPath* GetNextPath(); const vtkWorldPointPicker *GetWorldPointPicker() const; const vtkPointPicker *GetPointPicker() const; const vtkCellPicker *GetCellPicker() const; /** * \brief Release vtk-based graphics resources. Called by * vtkMitkRenderProp::ReleaseGraphicsResources. */ virtual void ReleaseGraphicsResources(vtkWindow *renWin); MappersMapType GetMappersMap() const; static bool useImmediateModeRendering(); protected: VtkPropRenderer( const char* name = "VtkPropRenderer", vtkRenderWindow * renWin = NULL, mitk::RenderingManager* rm = NULL ); virtual ~VtkPropRenderer(); virtual void Update(); private: /** \brief This method sets up the camera on the actor (e.g. an image) of all * 2D vtkRenderWindows. The view is centered; zooming and panning of VTK are called inside. * * \image html ImageMapperdisplayGeometry.png * * Similar to the textured plane of an image * (cf. void mitkImageVtkMapper2D::GeneratePlane(mitk::BaseRenderer* renderer, * vtkFloatingPointType planeBounds[6])), the mitkDisplayGeometry defines a view plane (or * projection plane). This plane is used to set the camera parameters. The view plane * center (VC) is important for camera positioning (cf. the image above). * * The following figure shows the combination of the textured plane and the view plane. * * \image html cameraPositioning.png * * The view plane center (VC) is the center of the textured plane (C) and the focal point * (FP) at the same time. The FP defines the direction the camera faces. Since * the textured plane is always in the XY-plane and orthographic projection is applied, the * distance between camera and plane is theoretically irrelevant (because in the orthographic * projection the center of projection is at infinity and the size of objects depends only on * a scaling parameter). As a consequence, the direction of projection (DOP) is (0; 0; -1). * The camera up vector is always defined as (0; 1; 0). * * \warning Due to a VTK clipping bug the distance between textured plane and camera is really huge. * Otherwise, VTK would clip off some slices. Same applies for the clipping range size. * * \note The camera position is defined through the mitkDisplayGeometry. * This facilitates zooming and panning, because the display * geometry changes and the textured plane does not. * * \image html scaling.png * * The textured plane is scaled to fill the render window via * camera->SetParallelScale( imageHeightInMM / 2). In the orthographic projection all extends, * angles and sizes are preserved. Therefore, the image is scaled by one parameter which defines * the size of the rendered image. A higher value will result in smaller images. In order to render * just the whole image, the scale is set to half of the image height in worldcoordinates * (cf. the picture above). * * For zooming purposes, a factor is computed as follows: * factor = image height / display height (in worldcoordinates). * When the display geometry gets smaller (zoom in), the factor becomes bigger. When the display * geometry gets bigger (zoom out), the factor becomes smaller. The used VTK method * camera->Zoom( factor ) also works with an inverse scale. */ void AdjustCameraToScene(); // switch between orthogonal opengl projection (2D rendering via mitk::GLMapper2D) and perspective projection (3D rendering) void Enable2DOpenGL(); void Disable2DOpenGL(); // prepare all mitk::mappers for rendering void PrepareMapperQueue(); /** \brief Set parallel projection, remove the interactor and the lights of VTK. */ bool Initialize2DvtkCamera(); bool m_InitNeeded; bool m_ResizeNeeded; bool m_VtkMapperPresent; bool m_NewRenderer; - bool m_2DCameraInitialized; + MapperSlotId m_CameraInitializedForMapperID; // Picking vtkWorldPointPicker * m_WorldPointPicker; vtkPointPicker * m_PointPicker; vtkCellPicker * m_CellPicker; PickingMode m_PickingMode; // Explicit use of SmartPointer to avoid circular #includes itk::SmartPointer< mitk::Mapper > m_CurrentWorldGeometry2DMapper; vtkLightKit* m_LightKit; // sorted list of mappers MappersMapType m_MappersMap; // rendering of text vtkRenderer * m_TextRenderer; typedef std::map TextMapType; TextMapType m_TextCollection; DataStorage::SetOfObjects::ConstPointer m_PickingObjects; DataStorage::SetOfObjects::const_iterator m_PickingObjectsIterator; }; } // namespace mitk #endif /* MITKVtkPropRenderer_H_HEADER_INCLUDED_C1C29F6D */ diff --git a/Core/Code/Rendering/vtkMitkThickSlicesFilter.cpp b/Core/Code/Rendering/vtkMitkThickSlicesFilter.cpp index 36536b4b9c..cb33dccd71 100644 --- a/Core/Code/Rendering/vtkMitkThickSlicesFilter.cpp +++ b/Core/Code/Rendering/vtkMitkThickSlicesFilter.cpp @@ -1,374 +1,374 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "vtkMitkThickSlicesFilter.h" #include "vtkDataArray.h" #include "vtkImageData.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkStreamingDemandDrivenPipeline.h" #include #include vtkCxxRevisionMacro(vtkMitkThickSlicesFilter, "$Revision: 1.00 $"); vtkStandardNewMacro(vtkMitkThickSlicesFilter); //---------------------------------------------------------------------------- // Construct an instance of vtkMitkThickSlicesFilter fitler. vtkMitkThickSlicesFilter::vtkMitkThickSlicesFilter() { this->HandleBoundaries = 1; this->Dimensionality = 2; this->m_CurrentMode = MIP; // by default process active point scalars this->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, vtkDataSetAttributes::SCALARS); } //---------------------------------------------------------------------------- void vtkMitkThickSlicesFilter::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); os << indent << "HandleBoundaries: " << this->HandleBoundaries << "\n"; os << indent << "Dimensionality: " << this->Dimensionality << "\n"; } //---------------------------------------------------------------------------- int vtkMitkThickSlicesFilter::RequestInformation(vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { // Get input and output pipeline information. vtkInformation* outInfo = outputVector->GetInformationObject(0); vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); // Get the input whole extent. int extent[6]; inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), extent); // Reduce 3D to 2D output extent[4] = extent[5] = 0; // Store the new whole extent for the output. outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), extent, 6); /* // Set the number of point data componets to the number of // components in the gradient vector. vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_DOUBLE, this->Dimensionality); */ return 1; } //---------------------------------------------------------------------------- // This method computes the input extent necessary to generate the output. int vtkMitkThickSlicesFilter::RequestUpdateExtent(vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { // Get input and output pipeline information. vtkInformation* outInfo = outputVector->GetInformationObject(0); vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); // Get the input whole extent. int wholeExtent[6]; inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent); // Get the requested update extent from the output. int inUExt[6]; outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), inUExt); /*inUExt[4] -= 5; inUExt[5] += 5; if (inUExt[4] < wholeExtent[4]) */inUExt[4] = wholeExtent[4]; /*if (inUExt[5] > wholeExtent[5]) */inUExt[5] = wholeExtent[5]; // Store the update extent needed from the intput. inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), inUExt, 6); return 1; } //---------------------------------------------------------------------------- // This execute method handles boundaries. // it handles boundaries. Pixels are just replicated to get values // out of extent. template void vtkMitkThickSlicesFilterExecute(vtkMitkThickSlicesFilter *self, vtkImageData *inData, T *inPtr, vtkImageData *outData, T *outPtr, int outExt[6], int /*id*/) { int idxX, idxY; int maxX, maxY; vtkIdType inIncX, inIncY, inIncZ; vtkIdType outIncX, outIncY, outIncZ; - int axesNum; + //int axesNum; int *inExt = inData->GetExtent(); int *wholeExtent; vtkIdType *inIncs; - int useYMin, useYMax, useXMin, useXMax; + //int useYMin, useYMax, useXMin, useXMax; // find the region to loop over maxX = outExt[1] - outExt[0]; maxY = outExt[3] - outExt[2]; // maxZ = outExt[5] - outExt[4]; // Get the dimensionality of the gradient. - axesNum = self->GetDimensionality(); + //axesNum = self->GetDimensionality(); // Get increments to march through data inData->GetContinuousIncrements(outExt, inIncX, inIncY, inIncZ); outData->GetContinuousIncrements(outExt, outIncX, outIncY, outIncZ); /* // The data spacing is important for computing the gradient. // central differences (2 * ratio). // Negative because below we have (min - max) for dx ... inData->GetSpacing(r); r[0] = -0.5 / r[0]; r[1] = -0.5 / r[1]; r[2] = -0.5 / r[2]; */ // get some other info we need inIncs = inData->GetIncrements(); wholeExtent = inData->GetExtent(); // Move the pointer to the correct starting position. inPtr += (outExt[0]-inExt[0])*inIncs[0] + (outExt[2]-inExt[2])*inIncs[1] + (outExt[4]-inExt[4])*inIncs[2]; // Loop through ouput pixels int _minZ = /*-5 + outExt[4]; if( _minZ < wholeExtent[4]) _minZ=*/wholeExtent[4]; int _maxZ = /* 5 + outExt[4]; if( _maxZ > wholeExtent[5]) _maxZ=*/wholeExtent[5]; if(_maxZ<_minZ) return; double invNum = 1.0 / (_maxZ-_minZ+1) ; switch(self->GetThickSliceMode()) { default: case vtkMitkThickSlicesFilter::MIP: { //MIP for (idxY = 0; idxY <= maxY; idxY++) { - useYMin = ((idxY + outExt[2]) <= wholeExtent[2]) ? 0 : -inIncs[1]; - useYMax = ((idxY + outExt[2]) >= wholeExtent[3]) ? 0 : inIncs[1]; + //useYMin = ((idxY + outExt[2]) <= wholeExtent[2]) ? 0 : -inIncs[1]; + //useYMax = ((idxY + outExt[2]) >= wholeExtent[3]) ? 0 : inIncs[1]; for (idxX = 0; idxX <= maxX; idxX++) { - useXMin = ((idxX + outExt[0]) <= wholeExtent[0]) ? 0 : -inIncs[0]; - useXMax = ((idxX + outExt[0]) >= wholeExtent[1]) ? 0 : inIncs[0]; + //useXMin = ((idxX + outExt[0]) <= wholeExtent[0]) ? 0 : -inIncs[0]; + //useXMax = ((idxX + outExt[0]) >= wholeExtent[1]) ? 0 : inIncs[0]; T mip = inPtr[_minZ*inIncs[2]]; for(int z = _minZ+1; z<= _maxZ;z++) { T value = inPtr[z*inIncs[2]]; if(value > mip) mip=value; } // do X axis *outPtr = mip; outPtr++; inPtr++; } outPtr += outIncY; inPtr += inIncY; } } break; case vtkMitkThickSlicesFilter::SUM: { //MIP for (idxY = 0; idxY <= maxY; idxY++) { - useYMin = ((idxY + outExt[2]) <= wholeExtent[2]) ? 0 : -inIncs[1]; - useYMax = ((idxY + outExt[2]) >= wholeExtent[3]) ? 0 : inIncs[1]; + //useYMin = ((idxY + outExt[2]) <= wholeExtent[2]) ? 0 : -inIncs[1]; + //useYMax = ((idxY + outExt[2]) >= wholeExtent[3]) ? 0 : inIncs[1]; for (idxX = 0; idxX <= maxX; idxX++) { - useXMin = ((idxX + outExt[0]) <= wholeExtent[0]) ? 0 : -inIncs[0]; - useXMax = ((idxX + outExt[0]) >= wholeExtent[1]) ? 0 : inIncs[0]; + //useXMin = ((idxX + outExt[0]) <= wholeExtent[0]) ? 0 : -inIncs[0]; + //useXMax = ((idxX + outExt[0]) >= wholeExtent[1]) ? 0 : inIncs[0]; double sum = 0; for(int z = _minZ; z<= _maxZ;z++) { T value = inPtr[z*inIncs[2]]; sum += value; } // do X axis *outPtr = invNum*sum; outPtr++; inPtr++; } outPtr += outIncY; inPtr += inIncY; } } break; case vtkMitkThickSlicesFilter::WEIGHTED: { const int size = _maxZ-_minZ; std::vector weights(size); double mean = 0.5 * double(_minZ + _maxZ); double sigma_sq = double(size) / 6.0; sigma_sq *= sigma_sq; double sum = 0; int i=0; for(int z = _minZ+1; z<= _maxZ;z++) { double val = exp(-(((double)z-mean)/sigma_sq)); weights[i++] = val; sum += val; } for(i=0; i= wholeExtent[3]) ? 0 : inIncs[1]; + //useYMin = ((idxY + outExt[2]) <= wholeExtent[2]) ? 0 : -inIncs[1]; + //useYMax = ((idxY + outExt[2]) >= wholeExtent[3]) ? 0 : inIncs[1]; for (idxX = 0; idxX <= maxX; idxX++) { - useXMin = ((idxX + outExt[0]) <= wholeExtent[0]) ? 0 : -inIncs[0]; - useXMax = ((idxX + outExt[0]) >= wholeExtent[1]) ? 0 : inIncs[0]; + //useXMin = ((idxX + outExt[0]) <= wholeExtent[0]) ? 0 : -inIncs[0]; + //useXMax = ((idxX + outExt[0]) >= wholeExtent[1]) ? 0 : inIncs[0]; T mip = inPtr[_minZ*inIncs[2]]; i=0; double mymip = 0; for(int z = _minZ+1; z<= _maxZ;z++) { double value = inPtr[z*inIncs[2]]; mymip+=value*weights[i++]; } mip = mymip; // do X axis *outPtr = mip; outPtr++; inPtr++; } outPtr += outIncY; inPtr += inIncY; } } break; } } int vtkMitkThickSlicesFilter::RequestData( vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) { if (!this->Superclass::RequestData(request, inputVector, outputVector)) { return 0; } vtkImageData* output = vtkImageData::GetData(outputVector); vtkDataArray* outArray = output->GetPointData()->GetScalars(); vtksys_ios::ostringstream newname; newname << (outArray->GetName()?outArray->GetName():"") << "Gradient"; outArray->SetName(newname.str().c_str()); // Why not pass the original array? if (this->GetInputArrayToProcess(0, inputVector)) { output->GetPointData()->AddArray( this->GetInputArrayToProcess(0, inputVector)); } return 1; } //---------------------------------------------------------------------------- // This method contains a switch statement that calls the correct // templated function for the input data type. This method does handle // boundary conditions. void vtkMitkThickSlicesFilter::ThreadedRequestData(vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector*, vtkImageData*** inData, vtkImageData** outData, int outExt[6], int threadId) { // Get the input and output data objects. vtkImageData* input = inData[0][0]; vtkImageData* output = outData[0]; // The ouptut scalar type must be double to store proper gradients. /* if(output->GetScalarType() != VTK_DOUBLE) { vtkErrorMacro("Execute: output ScalarType is " << output->GetScalarType() << "but must be double."); return; } */ vtkDataArray* inputArray = this->GetInputArrayToProcess(0, inputVector); if (!inputArray) { vtkErrorMacro("No input array was found. Cannot execute"); return; } // Gradient makes sense only with one input component. This is not // a Jacobian filter. if(inputArray->GetNumberOfComponents() != 1) { vtkErrorMacro( "Execute: input has more than one component. " "The input to gradient should be a single component image. " "Think about it. If you insist on using a color image then " "run it though RGBToHSV then ExtractComponents to get the V " "components. That's probably what you want anyhow."); return; } void* inPtr = inputArray->GetVoidPointer(0); void* outPtr = output->GetScalarPointerForExtent(outExt); switch(inputArray->GetDataType()) { vtkTemplateMacro( vtkMitkThickSlicesFilterExecute(this, input, static_cast(inPtr), output, static_cast(outPtr), outExt, threadId) ); default: vtkErrorMacro("Execute: Unknown ScalarType " << input->GetScalarType()); return; } } diff --git a/Core/Code/Service/mitkCoreActivator.cpp b/Core/Code/Service/mitkCoreActivator.cpp index 3ffb401c84..d7ec1bf446 100644 --- a/Core/Code/Service/mitkCoreActivator.cpp +++ b/Core/Code/Service/mitkCoreActivator.cpp @@ -1,59 +1,59 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkRenderingManager.h" #include "mitkPlanePositionManager.h" +#include "mitkCoreDataNodeReader.h" #include /* * This is the module activator for the "Mitk" module. It registers core services * like ... */ class MitkCoreActivator : public mitk::ModuleActivator { public: void Load(mitk::ModuleContext* context) { //m_RenderingManager = mitk::RenderingManager::New(); //context->RegisterService(renderingManager.GetPointer()); - m_PlanePositionManager = mitk::PlanePositionManagerService::New(); - m_PlanePositionManagerReg = context->RegisterService(m_PlanePositionManager); + m_PlanePositionManager = mitk::PlanePositionManagerService::New(); + context->RegisterService(m_PlanePositionManager); + + m_CoreDataNodeReader = mitk::CoreDataNodeReader::New(); + context->RegisterService(m_CoreDataNodeReader); } void Unload(mitk::ModuleContext* ) { // The mitk::ModuleContext* argument of the Unload() method // will always be 0 for the Mitk library. It makes no sense // to use it at this stage anyway, since all libraries which // know about the module system have already been unloaded. - - m_PlanePositionManagerReg.Unregister(); - m_PlanePositionManager = 0; - } private: - mitk::RenderingManager::Pointer m_RenderingManager; + //mitk::RenderingManager::Pointer m_RenderingManager; mitk::PlanePositionManagerService::Pointer m_PlanePositionManager; - mitk::ServiceRegistration m_PlanePositionManagerReg; + mitk::CoreDataNodeReader::Pointer m_CoreDataNodeReader; }; MITK_EXPORT_MODULE_ACTIVATOR(Mitk, MitkCoreActivator) diff --git a/Core/Code/Service/mitkServiceInterface.h b/Core/Code/Service/mitkServiceInterface.h index 725c61495e..80a059a657 100644 --- a/Core/Code/Service/mitkServiceInterface.h +++ b/Core/Code/Service/mitkServiceInterface.h @@ -1,50 +1,46 @@ -/*============================================================================= +/*========================================================================= - Library: CTK +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +=========================================================================*/ #ifndef MITKSERVICEINTERFACE_H #define MITKSERVICEINTERFACE_H template inline const char* mitk_service_interface_iid() { return 0; } #if defined(QT_DEBUG) || defined(QT_NODEBUG) #include #define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId) \ template <> inline const char* qobject_interface_iid() \ { return IId; } \ template <> inline const char* mitk_service_interface_iid() \ { return IId; } \ template <> inline IFace *qobject_cast(QObject *object) \ { return reinterpret_cast((object ? object->qt_metacast(IId) : 0)); } \ template <> inline IFace *qobject_cast(const QObject *object) \ { return reinterpret_cast((object ? const_cast(object)->qt_metacast(IId) : 0)); } #else #define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId) \ template <> inline const char* mitk_service_interface_iid() \ { return IId; } \ #endif #endif // MITKSERVICEINTERFACE_H diff --git a/Core/Code/Testing/mitkClippedSurfaceBoundsCalculatorTest.cpp b/Core/Code/Testing/mitkClippedSurfaceBoundsCalculatorTest.cpp index b363685972..b9a0d7b22b 100644 --- a/Core/Code/Testing/mitkClippedSurfaceBoundsCalculatorTest.cpp +++ b/Core/Code/Testing/mitkClippedSurfaceBoundsCalculatorTest.cpp @@ -1,388 +1,428 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-02-25 17:27:17 +0100 (Mo, 25 Feb 2008) $ Version: $Revision: 7837 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkTestingMacros.h" #include #include "mitkClippedSurfaceBoundsCalculator.h" #include "mitkGeometry3D.h" #include "mitkGeometry2D.h" #include "mitkVector.h" static void CheckPlanesInsideBoundingBoxOnlyOnOneSlice(mitk::Geometry3D::Pointer geometry3D) { //Check planes which are inside the bounding box mitk::ClippedSurfaceBoundsCalculator* calculator = new mitk::ClippedSurfaceBoundsCalculator(); mitk::Image::Pointer image = mitk::Image::New(); image->SetGeometry(geometry3D); //Check planes which are only on one slice: //Slice 0 mitk::Point3D origin; origin[0] = 511; origin[1] = 0; origin[2] = 0; mitk::Vector3D normal; mitk::FillVector3D(normal, 0, 0, 1); mitk::PlaneGeometry::Pointer planeOnSliceZero = mitk::PlaneGeometry::New(); planeOnSliceZero->InitializePlane(origin, normal); calculator->SetInput( planeOnSliceZero , image); calculator->Update(); mitk::ClippedSurfaceBoundsCalculator::OutputType minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == minMax.second, "Check if plane is only on one slice"); MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 0, "Check if plane is on slice 0"); //Slice 3 origin[2] = 3; mitk::PlaneGeometry::Pointer planeOnSliceThree = mitk::PlaneGeometry::New(); planeOnSliceThree->InitializePlane(origin, normal); planeOnSliceThree->SetImageGeometry(false); calculator->SetInput( planeOnSliceThree , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == minMax.second, "Check if plane is only on one slice"); MITK_TEST_CONDITION(minMax.first == 3 && minMax.second == 3, "Check if plane is on slice 3"); //Slice 17 origin[2] = 17; mitk::PlaneGeometry::Pointer planeOnSliceSeventeen = mitk::PlaneGeometry::New(); planeOnSliceSeventeen->InitializePlane(origin, normal); calculator->SetInput( planeOnSliceSeventeen , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == minMax.second, "Check if plane is only on one slice"); MITK_TEST_CONDITION(minMax.first == 17 && minMax.second == 17, "Check if plane is on slice 17"); //Slice 20 origin[2] = 19; mitk::PlaneGeometry::Pointer planeOnSliceTwenty = mitk::PlaneGeometry::New(); planeOnSliceTwenty->InitializePlane(origin, normal); calculator->SetInput( planeOnSliceTwenty , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == minMax.second, "Check if plane is only on one slice"); MITK_TEST_CONDITION(minMax.first == 19 && minMax.second == 19, "Check if plane is on slice 19"); delete calculator; } static void CheckPlanesInsideBoundingBox(mitk::Geometry3D::Pointer geometry3D) { //Check planes which are inside the bounding box mitk::ClippedSurfaceBoundsCalculator* calculator = new mitk::ClippedSurfaceBoundsCalculator(); mitk::Image::Pointer image = mitk::Image::New(); image->SetGeometry(geometry3D); //Check planes which are only on one slice: //Slice 0 mitk::Point3D origin; origin[0] = 511; // Set to 511.9 so that the intersection point is inside the bounding box origin[1] = 0; origin[2] = 0; mitk::Vector3D normal; mitk::FillVector3D(normal, 1, 0, 0); mitk::PlaneGeometry::Pointer planeSagittalOne = mitk::PlaneGeometry::New(); planeSagittalOne->InitializePlane(origin, normal); calculator->SetInput( planeSagittalOne , image); calculator->Update(); mitk::ClippedSurfaceBoundsCalculator::OutputType minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19, "Check if plane is from slice 0 to slice 19"); //Slice 3 origin[0] = 256; MITK_INFO << "Case1 origin: " << origin; mitk::PlaneGeometry::Pointer planeSagittalTwo = mitk::PlaneGeometry::New(); planeSagittalTwo->InitializePlane(origin, normal); MITK_INFO << "PlaneNormal: " << planeSagittalTwo->GetNormal(); MITK_INFO << "PlaneOrigin: " << planeSagittalTwo->GetOrigin(); calculator->SetInput( planeSagittalTwo , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_INFO << "min: " << minMax.first << " max: " << minMax.second; MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19, "Check if plane is from slice 0 to slice 19"); //Slice 17 origin[0] = 0; // Set to 0.1 so that the intersection point is inside the bounding box mitk::PlaneGeometry::Pointer planeOnSliceSeventeen = mitk::PlaneGeometry::New(); planeOnSliceSeventeen->InitializePlane(origin, normal); calculator->SetInput( planeOnSliceSeventeen , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19, "Check if plane is from slice 0 to slice 19"); //Crooked planes: origin[0] = 0; origin[1] = 507; origin[2] = 0; normal[0] = 1; normal[1] = -1; normal[2] = 1; mitk::PlaneGeometry::Pointer planeCrookedOne = mitk::PlaneGeometry::New(); planeCrookedOne->InitializePlane(origin, normal); calculator->SetInput( planeCrookedOne , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_INFO << "min: " << minMax.first << " max: " << minMax.second; MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 4, "Check if plane is from slice 0 to slice 4 with inclined plane"); origin[0] = 512; origin[1] = 0; origin[2] = 16; mitk::PlaneGeometry::Pointer planeCrookedTwo = mitk::PlaneGeometry::New(); planeCrookedTwo->InitializePlane(origin, normal); calculator->SetInput( planeCrookedTwo , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_INFO << "min: " << minMax.first << " max: " << minMax.second; MITK_TEST_CONDITION(minMax.first == 17 && minMax.second == 19, "Check if plane is from slice 17 to slice 19 with inclined plane"); origin[0] = 511; origin[1] = 0; origin[2] = 0; normal[1] = 0; normal[2] = 0.04; mitk::PlaneGeometry::Pointer planeCrookedThree = mitk::PlaneGeometry::New(); planeCrookedThree->InitializePlane(origin, normal); calculator->SetInput( planeCrookedThree , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_INFO << "min: " << minMax.first << " max: " << minMax.second; MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19, "Check if plane is from slice 0 to slice 19 with inclined plane"); delete calculator; } static void CheckPlanesOutsideOfBoundingBox(mitk::Geometry3D::Pointer geometry3D) { //Check planes which are outside of the bounding box mitk::ClippedSurfaceBoundsCalculator* calculator = new mitk::ClippedSurfaceBoundsCalculator(); mitk::Image::Pointer image = mitk::Image::New(); image->SetGeometry(geometry3D); //In front of the bounding box mitk::Point3D origin; origin[0] = 511; origin[1] = 0; origin[2] = -5; mitk::Vector3D normal; mitk::FillVector3D(normal, 0, 0, 1); mitk::PlaneGeometry::Pointer planeInFront = mitk::PlaneGeometry::New(); planeInFront->InitializePlane(origin, normal); calculator->SetInput( planeInFront , image); calculator->Update(); mitk::ClippedSurfaceBoundsCalculator::OutputType minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == std::numeric_limits::max(), "Check if min value hasn't been set"); MITK_TEST_CONDITION(minMax.second == std::numeric_limits::min(), "Check if max value hasn't been set"); //Behind the bounding box origin[2] = 515; mitk::PlaneGeometry::Pointer planeBehind = mitk::PlaneGeometry::New(); planeBehind->InitializePlane(origin, normal); calculator->SetInput( planeBehind , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == std::numeric_limits::max(), "Check if min value hasn't been set"); MITK_TEST_CONDITION(minMax.second == std::numeric_limits::min(), "Check if max value hasn't been set"); //Above origin[1] = 515; mitk::FillVector3D(normal, 0, 1, 0); mitk::PlaneGeometry::Pointer planeAbove = mitk::PlaneGeometry::New(); planeAbove->InitializePlane(origin, normal); calculator->SetInput( planeAbove , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == std::numeric_limits::max(), "Check if min value hasn't been set"); MITK_TEST_CONDITION(minMax.second == std::numeric_limits::min(), "Check if max value hasn't been set"); //Below origin[1] = -5; mitk::PlaneGeometry::Pointer planeBelow = mitk::PlaneGeometry::New(); planeBelow->InitializePlane(origin, normal); calculator->SetInput( planeBelow , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == std::numeric_limits::max(), "Check if min value hasn't been set"); MITK_TEST_CONDITION(minMax.second == std::numeric_limits::min(), "Check if max value hasn't been set"); //Left side origin[0] = -5; mitk::FillVector3D(normal, 1, 0, 0); mitk::PlaneGeometry::Pointer planeLeftSide = mitk::PlaneGeometry::New(); planeLeftSide->InitializePlane(origin, normal); calculator->SetInput( planeLeftSide , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == std::numeric_limits::max(), "Check if min value hasn't been set"); MITK_TEST_CONDITION(minMax.second == std::numeric_limits::min(), "Check if max value hasn't been set"); //Right side origin[1] = 515; mitk::PlaneGeometry::Pointer planeRightSide = mitk::PlaneGeometry::New(); planeRightSide->InitializePlane(origin, normal); calculator->SetInput( planeRightSide , image); calculator->Update(); minMax = calculator->GetMinMaxSpatialDirectionZ(); MITK_TEST_CONDITION(minMax.first == std::numeric_limits::max(), "Check if min value hasn't been set"); MITK_TEST_CONDITION(minMax.second == std::numeric_limits::min(), "Check if max value hasn't been set"); delete calculator; } +static void CheckIntersectionPointsOfTwoGeometry3D(mitk::Geometry3D::Pointer firstGeometry3D, mitk::Geometry3D::Pointer secondGeometry3D) +{ + mitk::ClippedSurfaceBoundsCalculator* calculator = new mitk::ClippedSurfaceBoundsCalculator(); + mitk::Image::Pointer firstImage = mitk::Image::New(); + firstImage->SetGeometry(firstGeometry3D); + + calculator->SetInput( secondGeometry3D, firstImage); + calculator->Update(); + + mitk::ClippedSurfaceBoundsCalculator::OutputType minMax = calculator->GetMinMaxSpatialDirectionZ(); + minMax = calculator->GetMinMaxSpatialDirectionZ(); + MITK_INFO << "min: " << minMax.first << " max: " << minMax.second; + + MITK_TEST_CONDITION(minMax.first == 0 && minMax.second == 19, "Check if plane is from slice 0 to slice 19"); +} + + int mitkClippedSurfaceBoundsCalculatorTest(int, char* []) { // always start with this! MITK_TEST_BEGIN("ClippedSurfaceBoundsCalculator"); /** The class mitkClippedSurfaceBoundsCalculator calculates the intersection points of a PlaneGeometry and a Geometry3D. * This unittest checks if the correct min and max values for the three spatial directions (x, y, z) * are calculated. To test this we define artifical PlaneGeometries and Geometry3Ds and test different * scenarios: * * 1. planes which are inside the bounding box of a 3D geometry but only on one slice * 2. planes which are outside of the bounding box * 3. planes which are inside the bounding box but over more than one slice * * Note: Currently rotated geometries are not tested! */ /********************* Define Geometry3D ***********************/ //Define origin: mitk::Point3D origin; origin[0] = 511; origin[1] = 0; origin[2] = 0; //Define normal: mitk::Vector3D normal; mitk::FillVector3D(normal, 0, 0, 1); //Initialize PlaneGeometry: mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); planeGeometry->InitializePlane(origin, normal); //Set Bounds: mitk::BoundingBox::BoundsArrayType bounds = planeGeometry->GetBounds(); bounds[0] = 0; bounds[1] = 512; bounds[2] = 0; bounds[3] = 512; bounds[4] = 0; bounds[5] = 1; planeGeometry->SetBounds(bounds); //Initialize SlicedGeometry3D: mitk::SlicedGeometry3D::Pointer slicedGeometry3D = mitk::SlicedGeometry3D::New(); slicedGeometry3D->InitializeEvenlySpaced(dynamic_cast(planeGeometry.GetPointer()), 20); mitk::Geometry3D::Pointer geometry3D = dynamic_cast< mitk::Geometry3D* > ( slicedGeometry3D.GetPointer() ); geometry3D->SetImageGeometry(true); + //Define origin for second Geometry3D; + mitk::Point3D origin2; + origin2[0] = 511; + origin2[1] = 60; + origin2[2] = 0; + + //Define normal: + mitk::Vector3D normal2; + mitk::FillVector3D(normal2, 0, 1, 0); + + //Initialize PlaneGeometry: + mitk::PlaneGeometry::Pointer planeGeometry2 = mitk::PlaneGeometry::New(); + planeGeometry2->InitializePlane(origin2, normal2); + + //Initialize SlicedGeometry3D: + mitk::SlicedGeometry3D::Pointer secondSlicedGeometry3D = mitk::SlicedGeometry3D::New(); + secondSlicedGeometry3D->InitializeEvenlySpaced(dynamic_cast(planeGeometry2.GetPointer()), 20); + mitk::Geometry3D::Pointer secondGeometry3D = dynamic_cast< mitk::Geometry3D* > ( secondSlicedGeometry3D.GetPointer() ); + secondGeometry3D->SetImageGeometry(true); + + /***************************************************************/ CheckPlanesInsideBoundingBoxOnlyOnOneSlice(geometry3D); CheckPlanesOutsideOfBoundingBox(geometry3D); CheckPlanesInsideBoundingBox(geometry3D); + CheckIntersectionPointsOfTwoGeometry3D(geometry3D, secondGeometry3D); + /** ToDo: * test also rotated 3D geometry! */ MITK_TEST_END(); } diff --git a/Core/Code/files.cmake b/Core/Code/files.cmake index d2b5776d37..7e82105172 100644 --- a/Core/Code/files.cmake +++ b/Core/Code/files.cmake @@ -1,335 +1,341 @@ SET(H_FILES Algorithms/itkImportMitkImageContainer.h Algorithms/itkImportMitkImageContainer.txx Algorithms/itkLocalVariationImageFilter.h Algorithms/itkLocalVariationImageFilter.txx Algorithms/itkMITKScalarImageToHistogramGenerator.h Algorithms/itkMITKScalarImageToHistogramGenerator.txx Algorithms/itkTotalVariationDenoisingImageFilter.h Algorithms/itkTotalVariationDenoisingImageFilter.txx Algorithms/itkTotalVariationSingleIterationImageFilter.h Algorithms/itkTotalVariationSingleIterationImageFilter.txx Algorithms/mitkBilateralFilter.h Algorithms/mitkBilateralFilter.cpp Algorithms/mitkImageAccessByItk.h Algorithms/mitkImageCast.h Algorithms/mitkImageToItk.h Algorithms/mitkImageToItk.txx Algorithms/mitkInstantiateAccessFunctions.h Algorithms/mitkITKImageImport.h Algorithms/mitkITKImageImport.txx Algorithms/mitkPixelTypeList.h # Preprocessor macros taken from Boost Algorithms/mitkPPArithmeticDec.h Algorithms/mitkPPArgCount.h Algorithms/mitkPPCat.h Algorithms/mitkPPConfig.h Algorithms/mitkPPControlExprIIf.h Algorithms/mitkPPControlIf.h Algorithms/mitkPPControlIIf.h Algorithms/mitkPPDebugError.h Algorithms/mitkPPDetailAutoRec.h Algorithms/mitkPPDetailDMCAutoRec.h Algorithms/mitkPPExpand.h Algorithms/mitkPPFacilitiesEmpty.h Algorithms/mitkPPFacilitiesExpand.h Algorithms/mitkPPLogicalBool.h Algorithms/mitkPPRepetitionDetailDMCFor.h Algorithms/mitkPPRepetitionDetailEDGFor.h Algorithms/mitkPPRepetitionDetailFor.h Algorithms/mitkPPRepetitionDetailMSVCFor.h Algorithms/mitkPPRepetitionFor.h Algorithms/mitkPPSeqElem.h Algorithms/mitkPPSeqForEach.h Algorithms/mitkPPSeqForEachProduct.h Algorithms/mitkPPSeq.h Algorithms/mitkPPSeqEnum.h Algorithms/mitkPPSeqSize.h Algorithms/mitkPPSeqToTuple.h Algorithms/mitkPPStringize.h Algorithms/mitkPPTupleEat.h Algorithms/mitkPPTupleElem.h Algorithms/mitkPPTupleRem.h Algorithms/mitkClippedSurfaceBoundsCalculator.h + Interfaces/mitkIDataNodeReader.h + IO/mitkPixelTypeTraits.h DataManagement/mitkCommon.h Interactions/mitkEventMapperAddOn.h Service/mitkAny.h Service/mitkGetModuleContext.h Service/mitkItkHashMap.h Service/mitkItkHashSet.h Service/mitkItkHashTable.h Service/mitkModuleAbstractTracked.h Service/mitkModuleAbstractTracked.tpp Service/mitkModuleActivator.h Service/mitkServiceFactory.h + Service/mitkServiceInterface.h Service/mitkServiceTracker.h Service/mitkServiceTracker.tpp Service/mitkServiceTrackerCustomizer.h Service/mitkServiceTrackerPrivate.h Service/mitkServiceTrackerPrivate.tpp Service/mitkServiceUtils.h Service/mitkSharedData.h Service/mitkStaticInit.h Service/mitkTrackedService.h Service/mitkTrackedService.tpp Service/mitkTrackedServiceListener.h ) SET(CPP_FILES Algorithms/mitkBaseDataSource.cpp Algorithms/mitkBaseProcess.cpp Algorithms/mitkCoreObjectFactoryBase.cpp Algorithms/mitkCoreObjectFactory.cpp Algorithms/mitkDataNodeFactory.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkGeometry2DDataToSurfaceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageCaster.cpp Algorithms/mitkImageCastPart1.cpp Algorithms/mitkImageCastPart2.cpp Algorithms/mitkImageCastPart3.cpp Algorithms/mitkImageCastPart4.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkFocusManager.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkSlicesRotator.cpp Controllers/mitkSlicesSwiveller.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkInteractorCameraController.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataStorage.cpp #DataManagement/mitkDataTree.cpp DataManagement/mitkDataNode.cpp #DataManagement/mitkDataTreeStorage.cpp DataManagement/mitkDisplayGeometry.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkGeometry2D.cpp DataManagement/mitkGeometry2DData.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkLandmarkBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModeOperation.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStateTransitionOperation.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTimeSlicedGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkVector.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp DataManagement/mitkShaderProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkMaterial.cpp Interactions/mitkAction.cpp Interactions/mitkAffineInteractor.cpp Interactions/mitkCoordinateSupplier.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkDisplayPositionEvent.cpp Interactions/mitkDisplayVectorInteractor.cpp Interactions/mitkDisplayVectorInteractorLevelWindow.cpp Interactions/mitkDisplayVectorInteractorScroll.cpp Interactions/mitkEvent.cpp Interactions/mitkEventDescription.cpp Interactions/mitkEventMapper.cpp Interactions/mitkGlobalInteraction.cpp Interactions/mitkInteractor.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMovePointSetInteractor.cpp Interactions/mitkMoveSurfaceInteractor.cpp Interactions/mitkNodeDepententPointSetInteractor.cpp Interactions/mitkPointSetInteractor.cpp Interactions/mitkPositionEvent.cpp Interactions/mitkPositionTracker.cpp Interactions/mitkState.cpp Interactions/mitkStateEvent.cpp Interactions/mitkStateMachine.cpp Interactions/mitkStateMachineFactory.cpp Interactions/mitkTransition.cpp Interactions/mitkWheelEvent.cpp Interactions/mitkKeyEvent.cpp Interactions/mitkVtkEventAdapter.cpp + Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkCrosshairPositionEvent.cpp IO/mitkBaseDataIOFactory.cpp + IO/mitkCoreDataNodeReader.cpp IO/mitkDicomSeriesReader.cpp IO/mitkFileReader.cpp IO/mitkFileSeriesReader.cpp IO/mitkFileWriter.cpp #IO/mitkIpPicGet.c IO/mitkImageGenerator.cpp IO/mitkImageWriter.cpp IO/mitkImageWriterFactory.cpp IO/mitkItkImageFileIOFactory.cpp IO/mitkItkImageFileReader.cpp IO/mitkItkPictureWrite.cpp + IO/mitkIOUtil.cpp IO/mitkLookupTableProperty.cpp IO/mitkOperation.cpp #IO/mitkPicFileIOFactory.cpp #IO/mitkPicFileReader.cpp #IO/mitkPicFileWriter.cpp #IO/mitkPicHelper.cpp #IO/mitkPicVolumeTimeSeriesIOFactory.cpp #IO/mitkPicVolumeTimeSeriesReader.cpp IO/mitkPixelType.cpp IO/mitkPointSetIOFactory.cpp IO/mitkPointSetReader.cpp IO/mitkPointSetWriter.cpp IO/mitkPointSetWriterFactory.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSTLFileIOFactory.cpp IO/mitkSTLFileReader.cpp IO/mitkSurfaceVtkWriter.cpp IO/mitkSurfaceVtkWriterFactory.cpp IO/mitkVtiFileIOFactory.cpp IO/mitkVtiFileReader.cpp IO/mitkVtkImageIOFactory.cpp IO/mitkVtkImageReader.cpp IO/mitkVtkSurfaceIOFactory.cpp IO/mitkVtkSurfaceReader.cpp IO/vtkPointSetXMLParser.cpp IO/mitkLog.cpp Rendering/mitkBaseRenderer.cpp Rendering/mitkVtkMapper2D.cpp Rendering/mitkVtkMapper3D.cpp Rendering/mitkRenderWindowFrame.cpp Rendering/mitkGeometry2DDataMapper2D.cpp Rendering/mitkGeometry2DDataVtkMapper3D.cpp Rendering/mitkGLMapper2D.cpp Rendering/mitkGradientBackground.cpp Rendering/mitkManufacturerLogo.cpp Rendering/mitkMapper2D.cpp Rendering/mitkMapper3D.cpp Rendering/mitkMapper.cpp Rendering/mitkPointSetGLMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkPolyDataGLMapper2D.cpp Rendering/mitkSurfaceGLMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVolumeDataVtkMapper3D.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkShaderRepository.cpp Rendering/mitkImageVtkMapper2D.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkMitkApplyLevelWindowToRGBFilter.cpp Service/mitkAny.cpp Service/mitkAtomicInt.cpp Service/mitkCoreActivator.cpp Service/mitkCoreModuleContext.cpp Service/mitkModule.cpp Service/mitkModuleContext.cpp Service/mitkModuleEvent.cpp Service/mitkModuleInfo.cpp Service/mitkModulePrivate.cpp Service/mitkModuleRegistry.cpp Service/mitkModuleUtils.cpp Service/mitkModuleVersion.cpp Service/mitkLDAPExpr.cpp Service/mitkLDAPFilter.cpp Service/mitkServiceEvent.cpp Service/mitkServiceException.cpp Service/mitkServiceListenerEntry.cpp Service/mitkServiceListeners.cpp Service/mitkServiceProperties.cpp Service/mitkServiceReference.cpp Service/mitkServiceReferencePrivate.cpp Service/mitkServiceRegistration.cpp Service/mitkServiceRegistrationPrivate.cpp Service/mitkServiceRegistry.cpp ) diff --git a/CoreUI/BundleTesting/PluginList.cmake b/CoreUI/BundleTesting/PluginList.cmake deleted file mode 100644 index cf83c4ddd7..0000000000 --- a/CoreUI/BundleTesting/PluginList.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(MITK_CORE_TEST_PLUGINS - org.mitk.gui.qt.common.tests:ON - ) diff --git a/CoreUI/Bundles/PluginList.cmake b/CoreUI/Bundles/PluginList.cmake deleted file mode 100644 index 790651077c..0000000000 --- a/CoreUI/Bundles/PluginList.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(MITK_CORE_PLUGINS - org.mitk.core.services:ON - org.mitk.gui.common:ON - org.mitk.gui.qt.common:ON - org.mitk.gui.qt.application:ON - ) diff --git a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageReference.cpp b/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageReference.cpp deleted file mode 100644 index 71a814d569..0000000000 --- a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageReference.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "mitkDataStorageReference.h" - -namespace mitk { - -DataStorageReference::DataStorageReference(DataStorage::Pointer dataStorage, bool isDefault) -: m_Default(isDefault), m_DataStorage(dataStorage) -{ - -} - -DataStorage::Pointer DataStorageReference::GetDataStorage() const -{ - return m_DataStorage; -} - - -bool DataStorageReference::IsDefault() const -{ - return m_Default; -} - -std::string DataStorageReference::GetLabel() const -{ - return m_Label; -} - -void DataStorageReference::SetLabel(const std::string& label) -{ - m_Label = label; -} - -bool DataStorageReference::operator==(const IDataStorageReference* o) const -{ - if (dynamic_cast(o) == 0) return false; - return (m_DataStorage == dynamic_cast(o)->m_DataStorage); -} - -} diff --git a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageReference.h b/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageReference.h deleted file mode 100644 index 0f92d7767f..0000000000 --- a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageReference.h +++ /dev/null @@ -1,50 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKDATASTORAGEREFERENCE_H_ -#define MITKDATASTORAGEREFERENCE_H_ - -#include "../mitkIDataStorageReference.h" - -namespace mitk -{ - -class DataStorageReference : public IDataStorageReference -{ -public: - - DataStorageReference(DataStorage::Pointer dataStorage, bool isDefault = false); - - DataStorage::Pointer GetDataStorage() const; - - bool IsDefault() const; - - std::string GetLabel() const; - void SetLabel(const std::string& label); - - bool operator==(const IDataStorageReference* o) const; - -private: - - bool m_Default; - std::string m_Label; - DataStorage::Pointer m_DataStorage; -}; - -} - -#endif /*MITKDATASTORAGEREFERENCE_H_*/ diff --git a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageService.cpp b/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageService.cpp deleted file mode 100644 index 488245e636..0000000000 --- a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageService.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "mitkDataStorageService.h" - -#include "mitkDataStorageReference.h" -#include "mitkStandaloneDataStorage.h" - -namespace mitk { - -DataStorageService::DataStorageService() -{ - m_DefaultDataStorageRef = this->CreateDataStorage("Default DataStorage"); - m_ActiveDataStorageRef = m_DefaultDataStorageRef; -} - -bool -DataStorageService::IsA(const std::type_info& type) -{ - std::string name(GetType().name()); - return name == type.name() || Service::IsA(type); -} - -const std::type_info& -DataStorageService::GetType() const -{ - return typeid(IDataStorageService); -} - -IDataStorageReference::Pointer DataStorageService::CreateDataStorage(const std::string& label) -{ - - StandaloneDataStorage::Pointer dataStorage = mitk::StandaloneDataStorage::New(); - DataStorageReference::Pointer ref(new DataStorageReference(dataStorage.GetPointer())); - ref->SetLabel(label); - m_DataStorageReferences.push_back(ref); - - return ref; -} - - -std::vector DataStorageService::GetDataStorageReferences() const -{ - return m_DataStorageReferences; -} - -IDataStorageReference::Pointer DataStorageService::GetDefaultDataStorage() const -{ - return m_DefaultDataStorageRef; -} - -IDataStorageReference::Pointer DataStorageService::GetActiveDataStorage() const -{ - return m_ActiveDataStorageRef; -} - -void DataStorageService::SetActiveDataStorage(IDataStorageReference::Pointer dataStorageRef) -{ - if (dataStorageRef.IsNull()) m_ActiveDataStorageRef = m_DefaultDataStorageRef; - else m_ActiveDataStorageRef = dataStorageRef; -} - -} diff --git a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageService.h b/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageService.h deleted file mode 100644 index 57d07363fe..0000000000 --- a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkDataStorageService.h +++ /dev/null @@ -1,56 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKDATASTORAGESERVICE_H_ -#define MITKDATASTORAGESERVICE_H_ - -#include "../mitkIDataStorageService.h" - -namespace mitk { - -class DataStorageService : public QObject, public IDataStorageService -{ - Q_OBJECT - Q_INTERFACES(mitk::IDataStorageService) - -public: - - DataStorageService(); - - bool IsA(const std::type_info& type); - - const std::type_info& GetType() const; - - IDataStorageReference::Pointer CreateDataStorage(const std::string& label); - - std::vector GetDataStorageReferences() const; - - IDataStorageReference::Pointer GetDefaultDataStorage() const; - - IDataStorageReference::Pointer GetActiveDataStorage() const; - void SetActiveDataStorage(IDataStorageReference::Pointer dataStorageRef); - -private: - - IDataStorageReference::Pointer m_ActiveDataStorageRef; - IDataStorageReference::Pointer m_DefaultDataStorageRef; - std::vector m_DataStorageReferences; -}; - -} - -#endif /*MITKDATASTORAGESERVICE_H_*/ diff --git a/CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageReference.h b/CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageReference.h deleted file mode 100644 index 73630284de..0000000000 --- a/CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageReference.h +++ /dev/null @@ -1,48 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKIDATASTORAGEREFERENCE_H_ -#define MITKIDATASTORAGEREFERENCE_H_ - -#include -#include - -#include - -#include - -namespace mitk -{ - -struct MITK_CORE_SERVICES_PLUGIN IDataStorageReference : public berry::Object -{ - berryInterfaceMacro(IDataStorageReference, mitk); - - - virtual DataStorage::Pointer GetDataStorage() const = 0; - - virtual bool IsDefault() const = 0; - - virtual std::string GetLabel() const = 0; - virtual void SetLabel(const std::string& label) = 0; - - virtual bool operator==(const IDataStorageReference* o) const = 0; -}; - -} - -#endif /*MITKIDATASTORAGEREFERENCE_H_*/ diff --git a/CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageService.h b/CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageService.h deleted file mode 100644 index 4bbfcc94ad..0000000000 --- a/CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageService.h +++ /dev/null @@ -1,52 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKIDATASTORAGESERVICE_H_ -#define MITKIDATASTORAGESERVICE_H_ - -#include - -#include -#include "mitkIDataStorageReference.h" - -#include - -#include - -namespace mitk -{ - -struct MITK_CORE_SERVICES_PLUGIN IDataStorageService : public berry::Service -{ - berryInterfaceMacro(IDataStorageService, berry); - - static const std::string ID; - - virtual IDataStorageReference::Pointer CreateDataStorage(const std::string& label) = 0; - virtual std::vector GetDataStorageReferences() const = 0; - - virtual IDataStorageReference::Pointer GetDefaultDataStorage() const = 0; - - virtual IDataStorageReference::Pointer GetActiveDataStorage() const = 0; - virtual void SetActiveDataStorage(IDataStorageReference::Pointer dataStorageRef) = 0; -}; - -} - -Q_DECLARE_INTERFACE(mitk::IDataStorageService, "org.mitk.service.IDataStorageService") - -#endif /*MITKIDATASTORAGESERVICE_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.common/files.cmake b/CoreUI/Bundles/org.mitk.gui.common/files.cmake deleted file mode 100644 index d270d12216..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/files.cmake +++ /dev/null @@ -1,24 +0,0 @@ -SET(MOC_H_FILES - src/internal/mitkPluginActivator.h -) - -SET(SRC_CPP_FILES - mitkDataStorageEditorInput.cpp - mitkDataNodeObject.cpp - mitkDataNodeSelection.cpp -) - -SET(INTERNAL_CPP_FILES - mitkPluginActivator.cpp -) - - -#SET(CPP_FILES manifest.cpp) - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/internal/mitkPluginActivator.cpp b/CoreUI/Bundles/org.mitk.gui.common/src/internal/mitkPluginActivator.cpp deleted file mode 100644 index 7bf92c816e..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/src/internal/mitkPluginActivator.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#include "mitkPluginActivator.h" - -#include - -namespace mitk { - -void org_mitk_gui_common_Activator::start(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -void org_mitk_gui_common_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} - -Q_EXPORT_PLUGIN2(org_mitk_gui_common, mitk::org_mitk_gui_common_Activator) - - diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/internal/mitkPluginActivator.h b/CoreUI/Bundles/org.mitk.gui.common/src/internal/mitkPluginActivator.h deleted file mode 100644 index c1c9e9da95..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/src/internal/mitkPluginActivator.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#ifndef MITKPLUGINACTIVATOR_H -#define MITKPLUGINACTIVATOR_H - -#include - -namespace mitk { - -class org_mitk_gui_common_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; // org_mitk_gui_common_Activator - -typedef org_mitk_gui_common_Activator PluginActivator; - -} - -#endif // MITKPLUGINACTIVATOR_H diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeObject.h b/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeObject.h deleted file mode 100644 index c9bf94da7f..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeObject.h +++ /dev/null @@ -1,55 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef MITKDATATREENODEOBJECT_H_ -#define MITKDATATREENODEOBJECT_H_ - -#include -#include - -#include - -#include - -namespace mitk -{ - -class MITK_GUI_COMMON_PLUGIN DataNodeObject : public berry::Object -{ - -public: - - berryObjectMacro(mitk::DataNodeObject) - - DataNodeObject(); - DataNodeObject(DataNode::Pointer node); - - DataNode::Pointer GetDataNode() const; - - bool operator==(const berry::Object* obj) const; - -private: - - DataNode::Pointer m_Node; - - -}; - -} - -#endif /* MITKDATATREENODEOBJECT_H_ */ diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.cpp b/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.cpp deleted file mode 100644 index d0def44ac3..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "mitkDataNodeSelection.h" - -#include "mitkDataNodeObject.h" - -namespace mitk -{ - -DataNodeSelection::DataNodeSelection() : - m_Selection(new ContainerType()) -{ - -} - -DataNodeSelection::DataNodeSelection(DataNode::Pointer node) : - m_Selection(new ContainerType()) -{ - DataNodeObject::Pointer obj(new DataNodeObject(node)); - m_Selection->push_back(obj); -} - -DataNodeSelection::DataNodeSelection(const std::vector& nodes) : - m_Selection(new ContainerType()) -{ - for (std::vector::const_iterator i = nodes.begin(); i != nodes.end(); ++i) - { - DataNodeObject::Pointer obj(new DataNodeObject(*i)); - m_Selection->push_back(obj); - } -} - -berry::Object::Pointer DataNodeSelection::GetFirstElement() const -{ - if (m_Selection->empty()) - return berry::Object::Pointer(); - - return *(m_Selection->begin()); -} - -berry::IStructuredSelection::iterator DataNodeSelection::Begin() const -{ - return m_Selection->begin(); -} - -berry::IStructuredSelection::iterator DataNodeSelection::End() const -{ - return m_Selection->end(); -} - -int DataNodeSelection::Size() const -{ - return m_Selection->size(); -} - -berry::IStructuredSelection::ContainerType::Pointer DataNodeSelection::ToVector() const -{ - return m_Selection; -} - -bool DataNodeSelection::IsEmpty() const -{ - return m_Selection->empty(); -} - -bool DataNodeSelection::operator==(const berry::Object* obj) const -{ - if (const berry::IStructuredSelection* other = dynamic_cast(obj)) - { - return m_Selection == other->ToVector(); - } - - return false; -} - -} diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.h b/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.h deleted file mode 100644 index be891931a2..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.h +++ /dev/null @@ -1,63 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef MITKDATATREENODESELECTION_H_ -#define MITKDATATREENODESELECTION_H_ - -#include -#include -#include - - -namespace mitk { - -class MITK_GUI_COMMON_PLUGIN DataNodeSelection : public virtual berry::IStructuredSelection -{ - -public: - - berryObjectMacro(DataNodeSelection); - - DataNodeSelection(); - DataNodeSelection(DataNode::Pointer node); - DataNodeSelection(const std::vector& nodes); - - virtual Object::Pointer GetFirstElement() const; - virtual iterator Begin() const; - virtual iterator End() const; - - virtual int Size() const; - - virtual ContainerType::Pointer ToVector() const; - - /** - * @see berry::ISelection::IsEmpty() - */ - bool IsEmpty() const; - - bool operator==(const berry::Object* obj) const; - -protected: - - ContainerType::Pointer m_Selection; -}; - -} - - -#endif /* MITKDATATREENODESELECTION_H_ */ diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataStorageEditorInput.cpp b/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataStorageEditorInput.cpp deleted file mode 100644 index d849f5cb54..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataStorageEditorInput.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "mitkDataStorageEditorInput.h" - -#include -#include - -namespace mitk -{ - -DataStorageEditorInput::DataStorageEditorInput() -{ -} - -DataStorageEditorInput::DataStorageEditorInput(IDataStorageReference::Pointer ref) -{ - m_DataStorageRef = ref; -} - -bool DataStorageEditorInput::Exists() const -{ - return true; -} - -std::string DataStorageEditorInput::GetName() const -{ - return "DataStorage Scene"; -} - -std::string DataStorageEditorInput::GetToolTipText() const -{ - return ""; -} - -bool DataStorageEditorInput::operator==(const berry::Object* o) const -{ - if (const DataStorageEditorInput* input = dynamic_cast(o)) - return this->GetName() == input->GetName(); - - return false; -} - -IDataStorageReference::Pointer -DataStorageEditorInput::GetDataStorageReference() -{ - if (m_DataStorageRef.IsNull()) - { - berry::ServiceRegistry& serviceRegistry = berry::Platform::GetServiceRegistry(); - IDataStorageService::Pointer dataService = serviceRegistry.GetServiceById(IDataStorageService::ID); - if (!dataService) return IDataStorageReference::Pointer(0); - m_DataStorageRef = dataService->GetDefaultDataStorage(); - } - - return m_DataStorageRef; -} - -} diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataStorageEditorInput.h b/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataStorageEditorInput.h deleted file mode 100644 index a208875b76..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataStorageEditorInput.h +++ /dev/null @@ -1,52 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKDATASTORAGEEDITORINPUT_H_ -#define MITKDATASTORAGEEDITORINPUT_H_ - -#include -#include - -#include - -namespace mitk -{ - -class MITK_GUI_COMMON_PLUGIN DataStorageEditorInput : public berry::IEditorInput -{ -public: - berryObjectMacro(DataStorageEditorInput); - - DataStorageEditorInput(); - DataStorageEditorInput(IDataStorageReference::Pointer ref); - - bool Exists() const; - std::string GetName() const; - std::string GetToolTipText() const; - - IDataStorageReference::Pointer GetDataStorageReference(); - - bool operator==(const berry::Object*) const; - -private: - - IDataStorageReference::Pointer m_DataStorageRef; -}; - -} - -#endif /*MITKDATASTORAGEEDITORINPUT_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/files.cmake b/CoreUI/Bundles/org.mitk.gui.qt.application/files.cmake deleted file mode 100644 index 89b1af40f0..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/files.cmake +++ /dev/null @@ -1,32 +0,0 @@ -SET(SRC_CPP_FILES - QmitkApplication.cpp - QmitkActionBarAdvisor.cpp - QmitkDefaultPerspective.cpp - QmitkWorkbenchAdvisor.cpp - QmitkWorkbenchWindowAdvisor.cpp -) - -SET(INTERNAL_CPP_FILES - mitkPluginActivator.cpp -) - -SET(MOC_H_FILES - src/QmitkApplication.h - src/QmitkDefaultPerspective.h - - src/internal/mitkPluginActivator.h -) - -SET(CACHED_RESOURCE_FILES - plugin.xml -) - -SET(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/manifest_headers.cmake b/CoreUI/Bundles/org.mitk.gui.qt.application/manifest_headers.cmake deleted file mode 100644 index 1ea9919816..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "MITK Qt CoreApp application") -set(Plugin-Version "1.0.0") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) - diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/plugin.xml b/CoreUI/Bundles/org.mitk.gui.qt.application/plugin.xml deleted file mode 100644 index d183346352..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/plugin.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkActionBarAdvisor.h b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkActionBarAdvisor.h deleted file mode 100644 index 67e38c2fd6..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkActionBarAdvisor.h +++ /dev/null @@ -1,36 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKACTIONBARADVISOR_H_ -#define QMITKACTIONBARADVISOR_H_ - -#include - -#include - -class MITK_QT_APP QmitkActionBarAdvisor : public berry::ActionBarAdvisor -{ -public: - - QmitkActionBarAdvisor(berry::IActionBarConfigurer::Pointer configurer); - -protected: - - void FillMenuBar(void* menuBar); -}; - -#endif /*QMITKACTIONBARADVISOR_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkApplication.cpp b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkApplication.cpp deleted file mode 100644 index 17e01c3778..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkApplication.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkApplication.h" - -#include - -#include "QmitkWorkbenchAdvisor.h" - -QmitkApplication::QmitkApplication() -{ - -} - -QmitkApplication::QmitkApplication(const QmitkApplication& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -int QmitkApplication::Start() -{ - berry::Display* display = berry::PlatformUI::CreateDisplay(); - - int code = berry::PlatformUI::CreateAndRunWorkbench(display, new QmitkWorkbenchAdvisor()); - - // exit the application with an appropriate return code - return code == berry::PlatformUI::RETURN_RESTART - ? EXIT_RESTART : EXIT_OK; -} - -void QmitkApplication::Stop() -{ - -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkApplication.h b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkApplication.h deleted file mode 100644 index 0261dd633d..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkApplication.h +++ /dev/null @@ -1,41 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKAPPLICATION_H_ -#define QMITKAPPLICATION_H_ - -#include - -#include - -#include - -class MITK_QT_APP QmitkApplication : public QObject, public berry::IApplication -{ - Q_OBJECT - Q_INTERFACES(berry::IApplication) - -public: - - QmitkApplication(); - QmitkApplication(const QmitkApplication& other); - - int Start(); - void Stop(); -}; - -#endif /*QMITKAPPLICATION_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkDefaultPerspective.cpp b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkDefaultPerspective.cpp deleted file mode 100755 index 09096ba8b1..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkDefaultPerspective.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkDefaultPerspective.h" - -QmitkDefaultPerspective::QmitkDefaultPerspective() -{ - -} - -QmitkDefaultPerspective::QmitkDefaultPerspective(const QmitkDefaultPerspective& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -void QmitkDefaultPerspective::CreateInitialLayout(berry::IPageLayout::Pointer /*layout*/) -{ - -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkDefaultPerspective.h b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkDefaultPerspective.h deleted file mode 100755 index 02ecf032eb..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkDefaultPerspective.h +++ /dev/null @@ -1,42 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKDEFAULTPERSPECTIVE_H_ -#define QMITKDEFAULTPERSPECTIVE_H_ - -#include - -#include - -#include - -struct MITK_QT_APP QmitkDefaultPerspective : public QObject, public berry::IPerspectiveFactory -{ - - QmitkDefaultPerspective(); - QmitkDefaultPerspective(const QmitkDefaultPerspective& other); - - void CreateInitialLayout(berry::IPageLayout::Pointer /*layout*/); - -private: - - Q_OBJECT - Q_INTERFACES(berry::IPerspectiveFactory) -}; - -#endif /* QMITKDEFAULTPERSPECTIVE_H_ */ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchAdvisor.h b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchAdvisor.h deleted file mode 100644 index 91832f4aa7..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchAdvisor.h +++ /dev/null @@ -1,47 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKWORKBENCHADVISOR_H_ -#define QMITKWORKBENCHADVISOR_H_ - -#ifdef __MINGW32__ -// We need to inlclude winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -#include - -#include - -class MITK_QT_APP QmitkWorkbenchAdvisor : public berry::QtWorkbenchAdvisor -{ -public: - - static const std::string DEFAULT_PERSPECTIVE_ID; // = org.mitk.coreapp.defaultperspective - - void Initialize(berry::IWorkbenchConfigurer::Pointer configurer); - - berry::WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor( - berry::IWorkbenchWindowConfigurer::Pointer configurer); - - std::string GetInitialWindowPerspectiveId(); - -}; - -#endif /*QMITKWORKBENCHADVISOR_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchWindowAdvisor.cpp b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchWindowAdvisor.cpp deleted file mode 100644 index 3a1fa53271..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchWindowAdvisor.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkWorkbenchWindowAdvisor.h" -#include "QmitkActionBarAdvisor.h" - - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -QmitkWorkbenchWindowAdvisor::QmitkWorkbenchWindowAdvisor(berry::IWorkbenchWindowConfigurer::Pointer configurer) -: berry::WorkbenchWindowAdvisor(configurer) -{ - -} - -berry::ActionBarAdvisor::Pointer -QmitkWorkbenchWindowAdvisor::CreateActionBarAdvisor( - berry::IActionBarConfigurer::Pointer configurer) -{ - berry::ActionBarAdvisor::Pointer actionBarAdvisor(new QmitkActionBarAdvisor(configurer)); - return actionBarAdvisor; -} - -void QmitkWorkbenchWindowAdvisor::PostWindowCreate() -{ - // very bad hack... - berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); - QMainWindow* mainWindow = static_cast(window->GetShell()->GetControl()); - - QMenuBar* menuBar = mainWindow->menuBar(); - - QMenu* fileMenu = menuBar->addMenu("&File"); - - fileMenu->addAction(new QmitkFileOpenAction(window)); - fileMenu->addSeparator(); - fileMenu->addAction(new QmitkFileExitAction(window)); - - berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); - const std::vector& viewDescriptors = viewRegistry->GetViews(); - - QMenu* viewMenu = menuBar->addMenu("Show &View"); - - // sort elements (converting vector to map...) - std::vector::const_iterator iter; - std::map VDMap; - - for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) - { - if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") - continue; - std::pair p((*iter)->GetLabel(), (*iter)); - VDMap.insert(p); - } - - QToolBar* qToolbar = new QToolBar; - - std::map::const_iterator MapIter; - for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) - { - berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); - //m_ViewActions.push_back(viewAction); - viewMenu->addAction(viewAction); - qToolbar->addAction(viewAction); - } - - mainWindow->addToolBar(qToolbar); - - QStatusBar* qStatusBar = new QStatusBar(); - - //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar - QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); - //disabling the SizeGrip in the lower right corner - statusBar->SetSizeGripEnabled(false); - - QmitkProgressBar *progBar = new QmitkProgressBar(); - qStatusBar->addPermanentWidget(progBar, 0); - progBar->hide(); - mainWindow->setStatusBar(qStatusBar); - - QmitkMemoryUsageIndicatorView* memoryIndicator = new QmitkMemoryUsageIndicatorView(); - qStatusBar->addPermanentWidget(memoryIndicator, 0); -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchWindowAdvisor.h b/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchWindowAdvisor.h deleted file mode 100644 index fb8006f65b..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchWindowAdvisor.h +++ /dev/null @@ -1,37 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKWORKBENCHWINDOWADVISOR_H_ -#define QMITKWORKBENCHWINDOWADVISOR_H_ - -#include - -#include - -class MITK_QT_APP QmitkWorkbenchWindowAdvisor : public berry::WorkbenchWindowAdvisor -{ -public: - - QmitkWorkbenchWindowAdvisor(berry::IWorkbenchWindowConfigurer::Pointer configurer); - - berry::ActionBarAdvisor::Pointer CreateActionBarAdvisor( - berry::IActionBarConfigurer::Pointer configurer); - - void PostWindowCreate(); -}; - -#endif /*QMITKWORKBENCHWINDOWADVISOR_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/internal/mitkPluginActivator.cpp b/CoreUI/Bundles/org.mitk.gui.qt.application/src/internal/mitkPluginActivator.cpp deleted file mode 100644 index 0d4255c747..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/internal/mitkPluginActivator.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#include "mitkPluginActivator.h" - -#include "../QmitkApplication.h" -#include "../QmitkDefaultPerspective.h" - -#include - -namespace mitk { - -void org_mitk_gui_qt_application_Activator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(QmitkApplication, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkDefaultPerspective, context) -} - -void org_mitk_gui_qt_application_Activator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} - -Q_EXPORT_PLUGIN2(org_mitk_gui_qt_application, mitk::org_mitk_gui_qt_application_Activator) - - diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/internal/mitkPluginActivator.h b/CoreUI/Bundles/org.mitk.gui.qt.application/src/internal/mitkPluginActivator.h deleted file mode 100644 index 4c633c649c..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.application/src/internal/mitkPluginActivator.h +++ /dev/null @@ -1,43 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#ifndef MITKPLUGINACTIVATOR_H -#define MITKPLUGINACTIVATOR_H - -#include - -namespace mitk { - -class org_mitk_gui_qt_application_Activator : - public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; // org_mitk_gui_common_Activator - -typedef org_mitk_gui_qt_application_Activator PluginActivator; - -} - -#endif // MITKPLUGINACTIVATOR_H diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/files.cmake b/CoreUI/Bundles/org.mitk.gui.qt.common/files.cmake deleted file mode 100755 index af67303c8f..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/files.cmake +++ /dev/null @@ -1,59 +0,0 @@ -SET(SRC_CPP_FILES - QmitkCloseProjectAction.cpp - QmitkDnDFrameWidget.cpp - QmitkDataNodeSelectionProvider.cpp - QmitkFileOpenAction.cpp - QmitkFileExitAction.cpp - QmitkFunctionality.cpp - QmitkFunctionality2.cpp - QmitkStatusBar.cpp - QmitkStdMultiWidgetEditor.cpp - QmitkPreferencesDialog.cpp - QmitkFunctionalityCoordinator.cpp -) - -SET(INTERNAL_CPP_FILES - QmitkDataNodeSelection.cpp - QmitkCommonActivator.cpp - QmitkEditorsPreferencePage.cpp - QmitkFunctionalityUtil.cpp - QmitkGeneralPreferencePage.cpp - QmitkStdMultiWidgetEditorPreferencePage.cpp -) - -SET(MOC_H_FILES - src/QmitkCloseProjectAction.h - src/QmitkFileOpenAction.h - src/QmitkFileExitAction.h - src/QmitkPreferencesDialog.h - src/QmitkStdMultiWidgetEditor.h - src/QmitkDnDFrameWidget.h - - src/internal/QmitkCommonActivator.h - src/internal/QmitkEditorsPreferencePage.h - src/internal/QmitkGeneralPreferencePage.h - src/internal/QmitkStdMultiWidgetEditorPreferencePage.h -) - -SET(UI_FILES - src/QmitkPreferencesDialog.ui -) - -SET(CACHED_RESOURCE_FILES - plugin.xml -) - -# todo: add some qt style sheet resources -SET(QRC_FILES - resources/resources.qrc -) - -SET(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/plugin.xml b/CoreUI/Bundles/org.mitk.gui.qt.common/plugin.xml deleted file mode 100644 index db28e35516..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkCloseProjectAction.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkCloseProjectAction.cpp deleted file mode 100644 index 3537e767df..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkCloseProjectAction.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-10-07 16:14:59 +0200 (Mi, 07 Okt 2009) $ -Version: $Revision: 19343 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkCloseProjectAction.h" - -#include -#include -#include -#include -#include -#include -#include "QmitkStdMultiWidgetEditor.h" - -#include - -QmitkCloseProjectAction::QmitkCloseProjectAction(berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - this->init(window); -} - -QmitkCloseProjectAction::QmitkCloseProjectAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - this->setIcon(icon); - this->init(window); -} - -void QmitkCloseProjectAction::init(berry::IWorkbenchWindow::Pointer window) -{ - m_Window = window; - this->setParent(static_cast(m_Window->GetShell()->GetControl())); - this->setText("&Close Project..."); - this->setToolTip("Close Project will remove all data objects from the application. This will free up the memory that is used by the data."); - m_Window = window; - this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); -} - -void QmitkCloseProjectAction::Run() -{ - - - try - { - /* Get the DataStorage and the MultiWidget */ - mitk::DataStorageEditorInput::Pointer editorInput; - mitk::DataStorage::Pointer storage; - QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; - berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->GetActiveEditor(); - if (editor.Cast().IsNull()) - { - editorInput = new mitk::DataStorageEditorInput(); - storage = editorInput->GetDataStorageReference()->GetDataStorage(); - } - else - { - multiWidgetEditor = editor.Cast(); - storage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); - } - - //check if there is anything else then helper object in the storage - if(storage->GetSubset(mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true))))->empty()) - return; - /* Ask, if the user is sure about that */ - if (QMessageBox::question(NULL, "Remove all data?", "Are you sure that you want to close the current project? This will remove all data objects?", QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) - return; - - /* Remove everything */ - mitk::DataStorage::SetOfObjects::ConstPointer nodesToRemove = storage->GetAll(); - storage->Remove(nodesToRemove); - /* Re-Add 2D renderer planes */ - if (multiWidgetEditor.IsNotNull()) - multiWidgetEditor->GetStdMultiWidget()->AddPlanesToDataStorage(); - } - catch (std::exception& e) - { - MITK_ERROR << "Exception caught during scene saving: " << e.what(); - QMessageBox::warning(NULL, "Error", QString("An error occurred during Close Project: %1").arg(e.what())); - } -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkCloseProjectAction.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkCloseProjectAction.h deleted file mode 100644 index 4d20793606..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkCloseProjectAction.h +++ /dev/null @@ -1,48 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-10-09 16:36:23 +0200 (Fr, 09 Okt 2009) $ -Version: $Revision: 19414 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkCloseProjectAction_H_ -#define QmitkCloseProjectAction_H_ - -#ifdef __MINGW32__ -// We need to include winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -#include - -#include - -#include - -class MITK_QT_COMMON QmitkCloseProjectAction : public QAction -{ - Q_OBJECT - -public: - QmitkCloseProjectAction(berry::IWorkbenchWindow::Pointer window); - QmitkCloseProjectAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window); -protected slots: - void Run(); - -private: - void init(berry::IWorkbenchWindow::Pointer window); - berry::IWorkbenchWindow::Pointer m_Window; -}; -#endif /*QmitkCloseProjectAction_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.h deleted file mode 100644 index ea2f68857f..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.h +++ /dev/null @@ -1,44 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKDATATREENODESELECTIONPROVIDER_H_ -#define QMITKDATATREENODESELECTIONPROVIDER_H_ - -#include - -#include -#include - -class MITK_QT_COMMON QmitkDataNodeSelectionProvider : public berry::QtSelectionProvider -{ -public: - - berryObjectMacro(QmitkDataNodeSelectionProvider) - - QmitkDataNodeSelectionProvider(); - - berry::ISelection::ConstPointer GetSelection() const; - -protected: - - mitk::DataNodeSelection::ConstPointer GetDataNodeSelection() const; - - virtual void FireSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); -}; - -#endif /* QMITKDATATREENODESELECTIONPROVIDER_H_ */ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp deleted file mode 100644 index 2af43c3169..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include -#include - - -// berry Includes -#include - -#include -#include "mitkIDataStorageService.h" -#include "mitkDataStorageEditorInput.h" -#include "mitkRenderingManager.h" - -#include "mitkProperties.h" -#include "mitkNodePredicateData.h" -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" - -#include "mitkProgressBar.h" - -QmitkDnDFrameWidget::QmitkDnDFrameWidget(QWidget *parent) -: QWidget(parent) -{ - setAcceptDrops(true); -} - -void QmitkDnDFrameWidget::dragEnterEvent( QDragEnterEvent *event ) -{ // accept drags - event->accept(); -} -void QmitkDnDFrameWidget::dropEvent( QDropEvent * event ) -{ //open dragged files - - mitk::IDataStorageService::Pointer service = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); - - mitk::DataStorage::Pointer ds; - if (service.IsNotNull()) - ds = service->GetActiveDataStorage()->GetDataStorage(); - else - return; - - QList fileNames = event->mimeData()->urls(); - - bool dsmodified = false; - for (QList::Iterator fileName = fileNames.begin(); - fileName != fileNames.end(); ++fileName) - { - - mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); - try - { - nodeReader->SetFileName(fileName->toLocalFile().toStdString()); - if(event->dropAction()==Qt::LinkAction) - nodeReader->SetImageSerie(true); - nodeReader->Update(); - for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) - { - mitk::DataNode::Pointer node; - node = nodeReader->GetOutput(i); - if ( node->GetData() != NULL ) - { - ds->Add(node); - dsmodified = true; - } - } - } - catch(...) - { - - } - - } - - if(dsmodified) - { - // 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 = ds->GetSubset(pred); - // calculate bounding geometry of these nodes - mitk::TimeSlicedGeometry::Pointer bounds = ds->ComputeBoundingGeometry3D(rs); - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - } -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.h deleted file mode 100644 index 05e0d5795e..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.h +++ /dev/null @@ -1,51 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ -Version: $Revision: 16224 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkDndFrameWidget_h -#define QmitkDndFrameWidget_h - -#ifdef __MINGW32__ -// We need to inlclude winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -#include -#include -//drag&drop -class QDragEnterEvent; -class QDropEvent; -class QMouseEvent; - -class MITK_QT_COMMON QmitkDnDFrameWidget : public QWidget -{ - Q_OBJECT - -public: - QmitkDnDFrameWidget(QWidget *parent); - - -private: - void dragEnterEvent( QDragEnterEvent *event ); - void dropEvent( QDropEvent * event ); - - -}; - - -#endif diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileExitAction.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileExitAction.cpp deleted file mode 100644 index 173520a1aa..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileExitAction.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-08-26 18:11:29 +0200 (Mi, 26 Aug 2009) $ -Version: $Revision: 18726 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkFileExitAction.h" - -#include -#include - -#include -#include -#include -#include - -#include "QmitkStdMultiWidgetEditor.h" -#include - -QmitkFileExitAction::QmitkFileExitAction(berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - m_Window = window.GetPointer(); - - this->setParent(static_cast(m_Window->GetShell()->GetControl())); - this->setText("&Exit"); - - this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); -} - -void QmitkFileExitAction::Run() -{ - berry::PlatformUI::GetWorkbench()->Close(); -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileExitAction.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileExitAction.h deleted file mode 100644 index 73e269eb1e..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileExitAction.h +++ /dev/null @@ -1,45 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-08-04 15:43:53 +0200 (Di, 04 Aug 2009) $ -Version: $Revision: 18435 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKFILEEXITACTION_H_ -#define QMITKFILEEXITACTION_H_ - -#include - -#include - -#include - -class MITK_QT_COMMON QmitkFileExitAction : public QAction -{ - Q_OBJECT - -public: - - QmitkFileExitAction(berry::IWorkbenchWindow::Pointer window); - -protected slots: - - void Run(); - -private: - - berry::IWorkbenchWindow* m_Window; -}; - - -#endif /*QMITKFILEOPENACTION_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileOpenAction.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileOpenAction.cpp deleted file mode 100644 index 6ff8f1b923..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileOpenAction.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkFileOpenAction.h" - -#include -#include -#include - -#include "mitkProgressBar.h" - -#include -#include -#include -#include -#include -#include - -#include "mitkProperties.h" -#include "mitkNodePredicateData.h" -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" - - -#include "QmitkStdMultiWidgetEditor.h" - -QmitkFileOpenAction::QmitkFileOpenAction(berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - this->init(window); -} - -QmitkFileOpenAction::QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - this->setIcon(icon); - - this->init(window); -} - -void QmitkFileOpenAction::init(berry::IWorkbenchWindow::Pointer window) -{ - m_Window = window.GetPointer(); - this->setParent(static_cast(m_Window->GetShell()->GetControl())); - this->setText("&Open..."); - this->setToolTip("Open data files (images, surfaces,...) and project files (.mitk)"); - - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - m_GeneralPreferencesNode = prefService->GetSystemPreferences()->Node("/General"); - - this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); -} - -void QmitkFileOpenAction::Run() -{ - /** - * @brief stores the last path of last opened file - */ - static QString m_LastPath; - - if(m_GeneralPreferencesNode.Lock().IsNotNull()) - { - if(m_LastPath.isEmpty()) - m_LastPath = QString::fromStdString(m_GeneralPreferencesNode.Lock()->Get("LastFileOpenPath", "")); - } - - - //QFileDialog dialog(static_cast(m_Window->GetShell()->GetControl())); - //dialog.setFileMode(QFileDialog::ExistingFiles); - //QStringList filters; - //filters << "Images (*.pic *.pic.gz *.vti *.dcm *.nhdr *.nrrd *.mhd)" - // << "Surfaces (*.stl *.vtk *.vtp)" - // << "MITK Pointset (*.mps)" - // << "All Files (*.*)"; - //dialog.setFilters(filters); - QStringList fileNames = QFileDialog::getOpenFileNames(NULL,"Open",m_LastPath,mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); - - //if (dialog.exec()) - // fileNames = dialog.selectedFiles(); - - if (fileNames.empty()) - return; - - QFileInfo info(fileNames.at(0)); - m_LastPath = info.filePath(); - if(m_GeneralPreferencesNode.Lock().IsNotNull()) - { - m_GeneralPreferencesNode.Lock()->Put("LastFileOpenPath", m_LastPath.toStdString()); - m_GeneralPreferencesNode.Lock()->Flush(); - } - - mitk::DataStorageEditorInput::Pointer editorInput; - mitk::DataStorage::Pointer dataStorage; - QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; - berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->GetActiveEditor(); - if (editor.Cast().IsNull()) - { - editorInput = new mitk::DataStorageEditorInput(); - dataStorage = editorInput->GetDataStorageReference()->GetDataStorage(); - } - else - { - multiWidgetEditor = editor.Cast(); - dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); - } - - if (multiWidgetEditor.IsNull()) - { - berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); - multiWidgetEditor = editor.Cast(); - } - else - { - multiWidgetEditor->GetStdMultiWidget()->RequestUpdate(); - } - - bool dsmodified = false; - for (QStringList::Iterator fileName = fileNames.begin(); - fileName != fileNames.end(); ++fileName) - { - - mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); - try - { - nodeReader->SetFileName(fileName->toStdString()); - nodeReader->Update(); - for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) - { - mitk::DataNode::Pointer node; - node = nodeReader->GetOutput(i); - if ( node->GetData() != NULL ) - { - dataStorage->Add(node); - dsmodified = true; - } - } - } - catch(...) - { - - } - - } - - - if(dsmodified) - { - // 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 = dataStorage->GetSubset(pred); - // calculate bounding geometry of these nodes - mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - } - - -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileOpenAction.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileOpenAction.h deleted file mode 100644 index 24344e0cb8..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFileOpenAction.h +++ /dev/null @@ -1,55 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKFILEOPENACTION_H_ -#define QMITKFILEOPENACTION_H_ - -#ifdef __MINGW32__ -// We need to inlclude winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -#include -#include - -#include - -#include -#include - -class MITK_QT_COMMON QmitkFileOpenAction : public QAction -{ - Q_OBJECT - -public: - QmitkFileOpenAction(berry::IWorkbenchWindow::Pointer window); - QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window); - -protected slots: - - void Run(); - -private: - void init ( berry::IWorkbenchWindow::Pointer window ); - berry::IWorkbenchWindow* m_Window; - berry::IPreferences::WeakPtr m_GeneralPreferencesNode; -}; - - -#endif /*QMITKFILEOPENACTION_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality.cpp deleted file mode 100755 index cae4f3510c..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkFunctionality.h" -#include "internal/QmitkFunctionalityUtil.h" - -// other includes -#include - -// mitk Includes -#include -#include - -// berry Includes -#include -#include -#include - -// Qmitk Includes -#include - -// Qt Includes -#include -#include -#include - -QmitkFunctionality::QmitkFunctionality() - : m_Parent(0) - , m_Active(false) - , m_Visible(false) - , m_SelectionProvider(0) - , m_HandlesMultipleDataStorages(false) - , m_InDataStorageChanged(false) -{ - m_PreferencesService = - berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); -} - -void QmitkFunctionality::SetHandleMultipleDataStorages(bool multiple) -{ - m_HandlesMultipleDataStorages = multiple; -} - -bool QmitkFunctionality::HandlesMultipleDataStorages() const -{ - return m_HandlesMultipleDataStorages; -} - -mitk::DataStorage::Pointer -QmitkFunctionality::GetDataStorage() const -{ - mitk::IDataStorageService::Pointer service = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); - - if (service.IsNotNull()) - { - if (m_HandlesMultipleDataStorages) - return service->GetActiveDataStorage()->GetDataStorage(); - else - return service->GetDefaultDataStorage()->GetDataStorage(); - } - - return 0; -} - -mitk::DataStorage::Pointer QmitkFunctionality::GetDefaultDataStorage() const -{ - mitk::IDataStorageService::Pointer service = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); - - return service->GetDefaultDataStorage()->GetDataStorage(); -} - -void QmitkFunctionality::CreatePartControl(void* parent) -{ - - // scrollArea - QScrollArea* scrollArea = new QScrollArea; - //QVBoxLayout* scrollAreaLayout = new QVBoxLayout(scrollArea); - scrollArea->setFrameShadow(QFrame::Plain); - scrollArea->setFrameShape(QFrame::NoFrame); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - - // m_Parent - m_Parent = new QWidget; - //m_Parent->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); - this->CreateQtPartControl(m_Parent); - - //scrollAreaLayout->addWidget(m_Parent); - //scrollArea->setLayout(scrollAreaLayout); - - // set the widget now - scrollArea->setWidgetResizable(true); - scrollArea->setWidget(m_Parent); - - // add the scroll area to the real parent (the view tabbar) - QWidget* parentQWidget = static_cast(parent); - QVBoxLayout* parentLayout = new QVBoxLayout(parentQWidget); - parentLayout->setMargin(0); - parentLayout->setSpacing(0); - parentLayout->addWidget(scrollArea); - - // finally set the layout containing the scroll area to the parent widget (= show it) - parentQWidget->setLayout(parentLayout); - - this->AfterCreateQtPartControl(); -} - -void QmitkFunctionality::AfterCreateQtPartControl() -{ - // REGISTER DATASTORAGE LISTENER - this->GetDefaultDataStorage()->AddNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeAddedProxy ) ); - this->GetDefaultDataStorage()->ChangedNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeChangedProxy ) ); - this->GetDefaultDataStorage()->RemoveNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeRemovedProxy ) ); - - // REGISTER PREFERENCES LISTENER - berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); - if(prefs.IsNotNull()) - prefs->OnChanged.AddListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); - - // REGISTER FOR WORKBENCH SELECTION EVENTS - m_BlueBerrySelectionListener = berry::ISelectionListener::Pointer(new berry::SelectionChangedAdapter(this - , &QmitkFunctionality::BlueBerrySelectionChanged)); - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_BlueBerrySelectionListener); - - // REGISTER A SELECTION PROVIDER - QmitkFunctionalitySelectionProvider::Pointer _SelectionProvider - = QmitkFunctionalitySelectionProvider::New(this); - m_SelectionProvider = _SelectionProvider.GetPointer(); - this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(m_SelectionProvider)); - - // EMULATE INITIAL SELECTION EVENTS - - // by default a a multi widget is always available - this->StdMultiWidgetAvailable(*this->GetActiveStdMultiWidget()); - - // send datamanager selection - this->OnSelectionChanged(this->GetDataManagerSelection()); - - // send preferences changed event - this->OnPreferencesChanged(this->GetPreferences().Cast().GetPointer()); -} - -void QmitkFunctionality::ClosePart() -{ - -} - -void QmitkFunctionality::ClosePartProxy() -{ - this->GetDefaultDataStorage()->AddNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeAddedProxy ) ); - this->GetDefaultDataStorage()->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeRemovedProxy) ); - this->GetDefaultDataStorage()->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeChangedProxy ) ); - - berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); - if(prefs.IsNotNull()) - { - prefs->OnChanged.RemoveListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); - // flush the preferences here (disabled, everyone should flush them by themselves at the right moment) - // prefs->Flush(); - } - - // REMOVE SELECTION PROVIDER - this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(NULL)); - - berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); - if(s) - { - s->RemovePostSelectionListener(m_BlueBerrySelectionListener); - } - - this->ClosePart(); -} - -QmitkFunctionality::~QmitkFunctionality() -{ - this->Register(); - this->ClosePartProxy(); - - this->UnRegister(false); -} - -void QmitkFunctionality::OnPreferencesChanged( const berry::IBerryPreferences* ) -{ -} - -void QmitkFunctionality::BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection) -{ - if(sourcepart.IsNull() || sourcepart->GetSite()->GetId() != "org.mitk.views.datamanager") - return; - - mitk::DataNodeSelection::ConstPointer _DataNodeSelection - = selection.Cast(); - this->OnSelectionChanged(this->DataNodeSelectionToVector(_DataNodeSelection)); -} - -bool QmitkFunctionality::IsVisible() const -{ - return m_Visible; -} - -void QmitkFunctionality::SetFocus() -{ -} - -void QmitkFunctionality::Activated() -{ -} - -void QmitkFunctionality::Deactivated() -{ -} - -void QmitkFunctionality::StdMultiWidgetAvailable( QmitkStdMultiWidget& /*stdMultiWidget*/ ) -{ -} -void QmitkFunctionality::StdMultiWidgetNotAvailable() -{ -} - -void QmitkFunctionality::DataStorageChanged() -{ - -} - -QmitkStdMultiWidget* QmitkFunctionality::GetActiveStdMultiWidget( bool reCreateWidget ) -{ - QmitkStdMultiWidget* activeStdMultiWidget = 0; - berry::IEditorPart::Pointer editor = - this->GetSite()->GetPage()->GetActiveEditor(); - - if (editor.Cast().IsNotNull()) - { - activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); - } - else if (reCreateWidget) - { - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(); - // open a new multi-widget editor, but do not give it the focus - berry::IEditorPart::Pointer editor = this->GetSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID, false); - activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); - } - - return activeStdMultiWidget; -} - -void QmitkFunctionality::HandleException( const char* str, QWidget* parent, bool showDialog ) const -{ - //itkGenericOutputMacro( << "Exception caught: " << str ); - MITK_ERROR << str; - if ( showDialog ) - { - QMessageBox::critical ( parent, "Exception caught!", str ); - } -} - -void QmitkFunctionality::HandleException( std::exception& e, QWidget* parent, bool showDialog ) const -{ - HandleException( e.what(), parent, showDialog ); -} - -void QmitkFunctionality::StdMultiWidgetClosed( QmitkStdMultiWidget& /*stdMultiWidget*/ ) -{ - -} - -void QmitkFunctionality::WaitCursorOn() -{ - QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); -} - -void QmitkFunctionality::BusyCursorOn() -{ - QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); -} - -void QmitkFunctionality::WaitCursorOff() -{ - this->RestoreOverrideCursor(); -} - -void QmitkFunctionality::BusyCursorOff() -{ - this->RestoreOverrideCursor(); -} - -void QmitkFunctionality::RestoreOverrideCursor() -{ - QApplication::restoreOverrideCursor(); -} - -berry::IPreferences::Pointer QmitkFunctionality::GetPreferences() const -{ - berry::IPreferencesService::Pointer prefService = m_PreferencesService.Lock(); - // const_cast workaround for bad programming: const uncorrectness this->GetViewSite() should be const - std::string id = "/" + (const_cast(this))->GetViewSite()->GetId(); - return prefService.IsNotNull() ? prefService->GetSystemPreferences()->Node(id): berry::IPreferences::Pointer(0); -} - -void QmitkFunctionality::Visible() -{ - -} - -void QmitkFunctionality::Hidden() -{ - -} - -bool QmitkFunctionality::IsExclusiveFunctionality() const -{ - return true; -} - -void QmitkFunctionality::SetVisible( bool visible ) -{ - m_Visible = visible; -} - -void QmitkFunctionality::SetActivated( bool activated ) -{ - m_Active = activated; -} - -bool QmitkFunctionality::IsActivated() const -{ - return m_Active; -} - diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality.h deleted file mode 100755 index 924b5774de..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality.h +++ /dev/null @@ -1,395 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#ifndef QMITKFUNCTIONALITY_H_ -#define QMITKFUNCTIONALITY_H_ - -#ifdef __MINGW32__ -// We need to inlclude winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -//# blueberry stuff -#include -#include -#include - -#include - -//# mitk stuff -#include -#include "mitkDataNodeSelection.h" -#include - -//# forward declarations -class QmitkStdMultiWidget; - -namespace mitk { - class DataNode; -} - -namespace berry { - struct IBerryPreferences; -} - -class QmitkFunctionalitySelectionProvider; - -/// -/// \class QmitkFunctionality -/// -/// \brief The base class of all MITK related blueberry views (~ in the old version of MITK, this was called "Functionality") -/// -/// QmitkFunctionality provides several convenience methods that eases the introduction of a new view: -/// -///
    -///
  1. Access to the DataStorage (~ the shared data repository) -///
  2. Access to the StdMultiWidget (the 2x2 RenderWindow arrangement) -///
  3. Access to and update notification for the functionality/view preferences -///
  4. Access to and update notification for the current DataNode selection / to DataNode selection events send through the SelectionService -///
  5. Methods to send DataNode selections through the SelectionService -///
  6. Some events for unproblematic inter-View communication (e.g. when to add/remove interactors) -///
  7. Some minor important convenience methods (like changing the mouse cursor/exception handling) -///
-/// -/// Please use the Activated/Deactivated method to add/remove interactors, disabling multiwidget crosshair or anything which may -/// "affect" other functionalities. For further reading please have a look at QmitkFunctionality::IsExclusiveFunctionality(). -/// -class MITK_QT_COMMON QmitkFunctionality : public berry::QtViewPart -{ - -//# public virtual methods which can be overwritten -public: - /// - /// Creates smartpointer typedefs - /// - berryObjectMacro(QmitkFunctionality) - /// - /// Nothing to do in the standard ctor. Initiliaze your GUI in CreateQtPartControl(QWidget*) - /// \see berry::QtViewPart::CreateQtPartControl(QWidget*) - /// - QmitkFunctionality(); - /// - /// Disconnects all standard event listeners - /// - virtual ~QmitkFunctionality(); - /// - /// Called, when the WorkbenchPart gets closed - /// by the user directly or by closing the whole - /// app (e.g. for removing event listeners) - /// - virtual void ClosePart(); - /// - /// Called when the selection in the workbench changed - /// - virtual void OnSelectionChanged(std::vector /*nodes*/); - /// - /// Called when the preferences object of this view changed. - /// \see GetPreferences() - /// - virtual void OnPreferencesChanged(const berry::IBerryPreferences*); - /// - /// Make this view manage multiple DataStorage. If set to true GetDataStorage() - /// will return the currently active DataStorage (and not the default one). - /// \see GetDataStorage() - /// - void SetHandleMultipleDataStorages(bool multiple); - /// - /// \return true if this view handles multiple DataStorages, false otherwise - /// - bool HandlesMultipleDataStorages() const; - /// - /// Called when a StdMultiWidget is available. Should not be used anymore, see GetActiveStdMultiWidget() - /// \see GetActiveStdMultiWidget() - /// - virtual void StdMultiWidgetAvailable(QmitkStdMultiWidget& stdMultiWidget); - /// - /// Called when a StdMultiWidget is available. Should not be used anymore, see GetActiveStdMultiWidget() - /// \see GetActiveStdMultiWidget() - /// - virtual void StdMultiWidgetClosed(QmitkStdMultiWidget& stdMultiWidget); - /// - /// Called when no StdMultiWidget is available anymore. Should not be used anymore, see GetActiveStdMultiWidget() - /// \see GetActiveStdMultiWidget() - /// - virtual void StdMultiWidgetNotAvailable(); - /// - /// Only called when IsExclusiveFunctionality() returns true. - /// \see IsExclusiveFunctionality() - /// - virtual void Activated(); - /// - /// \return true if this view is currently activated, false otherwise - /// - bool IsActivated() const; - /// - /// Only called when IsExclusiveFunctionality() returns true. - /// \see IsExclusiveFunctionality() - /// - virtual void Deactivated(); - /// - /// Some functionalities need to add special interactors, removes the crosshair from the stdmultiwidget, etc. - /// In this case the functionality has to tidy up when changing to another functionality - /// which also wants to change the "default configuration". In the old Qt3-based - /// version of MITK, two functionalities could never be opened at the same time so that the - /// methods Activated() and Deactivated() were the right place for the functionalitites to - /// add/remove their interactors, etc. This is still true for the new MITK Workbench, - /// but as there can be several functionalities visible at the same time, the behaviour concerning - /// when Activated() and Deactivated() are called has changed: - /// - /// 1. Activated() and Deactivated() are only called if IsExclusiveFunctionality() returns true - /// - /// 2. If only one standalone functionality is or becomes visible, Activated() will be called on that functionality - /// - /// 3. If two or more standalone functionalities are visible, - /// Activated() will be called on the functionality that receives focus, Deactivated() will be called - /// on the one that looses focus, gets hidden or closed - /// - /// - /// As a consequence of 1. if you overwrite IsExclusiveFunctionality() and let it return false, you - /// signalize the MITK Workbench that this functionality does nothing to the "default configuration" - /// and can easily be visible while other functionalities are also visible. - /// - /// By default the method returns true. - /// - /// \return true if this functionality is meant to work as a standalone view, false otherwise - /// - virtual bool IsExclusiveFunctionality() const; - /// - /// Informs other parts of the workbench that node is selected via the blueberry selection service. - /// - void FireNodeSelected(mitk::DataNode* node); - /// - /// Informs other parts of the workbench that the nodes are selected via the blueberry selection service. - /// - void FireNodesSelected(std::vector nodes); - /// - /// Called when this functionality becomes visible ( no matter what IsExclusiveFunctionality() returns ) - /// - virtual void Visible(); - /// - /// \return true if this view is currently visible, false otherwise - /// - bool IsVisible() const; - /// - /// Called when this functionality is hidden ( no matter what IsExclusiveFunctionality() returns ) - /// - virtual void Hidden(); -//# protected virtual methods which can be overwritten -protected: - /// - /// Called when a DataStorage Add event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeAdded(const mitk::DataNode* node); - /// - /// Called when a DataStorage Changed event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeChanged(const mitk::DataNode* /*node*/); - /// - /// Called when a DataStorage Remove event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeRemoved(const mitk::DataNode* node); - /// - /// Called when a DataStorage add *or* remove *or* change event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void DataStorageChanged(); - /// - /// \return the selection of the currently active part of the workbench or an empty vector - /// if nothing is selected - /// - std::vector GetCurrentSelection() const; - /// - /// Returns the current selection made in the datamanager bundle or an empty vector - /// if nothing`s selected or if the bundle does not exist - /// - std::vector GetDataManagerSelection() const; - /// - /// Returns the Preferences object for this Functionality. - /// Important: When refering to this preferences, e.g. in a PreferencePage: The ID - /// for this preferences object is "/", e.g. "/org.mitk.views.datamanager" - /// - berry::IPreferences::Pointer GetPreferences() const; - /// - /// Returns the default or the currently active DataStorage if m_HandlesMultipleDataStorages - /// is set to true - /// \see SetHandleMultipleDataStorages(bool) - /// \see HandlesMultipleDataStorages() - /// - mitk::DataStorage::Pointer GetDataStorage() const; - /// - /// \return always returns the default DataStorage - /// - mitk::DataStorage::Pointer GetDefaultDataStorage() const; - /// - /// Returns the default and active StdMultiWidget. - /// \param reCreateWidget a boolean flag to en-/disable the attept to re-create the StdWidget - /// If there is not StdMultiWidget yet a new one is - /// created in this method when called with default parameter! - /// - QmitkStdMultiWidget* GetActiveStdMultiWidget( bool reCreateWidget = true); - /// - /// Outputs an error message to the console and displays a message box containing - /// the exception description. - /// \param e the exception which should be handled - /// \param showDialog controls, whether additionally a message box should be - /// displayed to inform the user that something went wrong - /// - void HandleException( std::exception& e, QWidget* parent = NULL, bool showDialog = true ) const; - /// - /// Calls HandleException ( std::exception&, QWidget*, bool ) internally - /// \see HandleException ( std::exception&, QWidget*, bool ) - /// - void HandleException( const char* str, QWidget* parent = NULL, bool showDialog = true ) const; - /// - /// Convenient method to set and reset a wait cursor ("hourglass") - /// - void WaitCursorOn(); - /// - /// Convenient method to restore the standard cursor - /// - void WaitCursorOff(); - /// - /// Convenient method to set and reset a busy cursor - /// - void BusyCursorOn(); - /// - /// Convenient method to restore the standard cursor - /// - void BusyCursorOff(); - /// - /// Convenient method to restore the standard cursor - /// - void RestoreOverrideCursor(); - -//# other public methods which should not be overwritten -public: - /// - /// Creates a scroll area for this view and calls CreateQtPartControl then - /// - void CreatePartControl(void* parent); - /// - /// Called when this view receives the focus. Same as Activated() - /// \see Activated() - /// - void SetFocus(); - /// - /// Called when a DataStorage Add Event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeAdded afterwards. - /// \see m_InDataStorageChanged - /// - void NodeAddedProxy(const mitk::DataNode* node); - /// - /// Called when a DataStorage remove event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeRemoved afterwards. - /// \see m_InDataStorageChanged - /// - void NodeRemovedProxy(const mitk::DataNode* node); - /// - /// Called when a DataStorage changed event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeChanged afterwards. - /// \see m_InDataStorageChanged - /// - void NodeChangedProxy(const mitk::DataNode* node); - /// - /// Toggles the visible flag m_Visible - /// - void SetVisible(bool visible); - /// - /// Toggles the activated flag m_Activated - /// - void SetActivated(bool activated); - /// - /// Called, when the WorkbenchPart gets closed for removing event listeners - /// Internally this method calls ClosePart after it removed the listeners registered - /// by QmitkFunctionality. By having this proxy method the user does not have to - /// call QmitkFunctionality::ClosePart() when overwriting ClosePart() - /// - void ClosePartProxy(); - -//# other protected methods which should not be overwritten (or which are deprecated) -protected: - /// - /// Called immediately after CreateQtPartControl(). - /// Here standard event listeners for a QmitkFunctionality are registered - /// - void AfterCreateQtPartControl(); - /// - /// code to activate the last visible functionality - /// - void ActivateLastVisibleFunctionality(); - /// - /// reactions to selection events from data manager (and potential other senders) - /// - void BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection); - /// - /// Converts a mitk::DataNodeSelection to a std::vector (possibly empty - /// - std::vector DataNodeSelectionToVector(mitk::DataNodeSelection::ConstPointer currentSelection) const; - //# protected fields -protected: - /// - /// helper stuff to observe BlueBerry selections - /// - friend struct berry::SelectionChangedAdapter; - /// - /// Saves the parent of this view (this is the scrollarea created in CreatePartControl(void*) - /// \see CreatePartControl(void*) - /// - QWidget* m_Parent; - /// - /// Saves if this view is the currently active one. - /// - bool m_Active; - /// - /// Saves if this view is visible - /// - bool m_Visible; - -//# private fields: -private: - /// - /// Holds the current selection (selection made by this Functionality !!!) - /// - QmitkFunctionalitySelectionProvider* m_SelectionProvider; - /// - /// object to observe BlueBerry selections - /// - berry::ISelectionListener::Pointer m_BlueBerrySelectionListener; - /// - /// Saves if this view handles multiple datastorages - /// - bool m_HandlesMultipleDataStorages; - /// - /// Saves if this class is currently working on DataStorage changes. - /// This is a protector variable to avoid recursive calls on event listener functions. - bool m_InDataStorageChanged; - /// - /// saves all visible functionalities - /// - std::set m_VisibleFunctionalities; - /// - /// The Preferences Service to retrieve and store preferences. - /// - berry::IPreferencesService::WeakPtr m_PreferencesService; -}; - -#endif /*QMITKFUNCTIONALITY_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionalityCoordinator.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionalityCoordinator.cpp deleted file mode 100644 index ae44992181..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionalityCoordinator.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkFunctionalityCoordinator.h" -#include "QmitkFunctionality.h" -#include -#include -#include - -QmitkFunctionalityCoordinator::QmitkFunctionalityCoordinator() -: m_StandaloneFuntionality(NULL) -{ -} - -void QmitkFunctionalityCoordinator::SetWindow( berry::IWorkbenchWindow::Pointer window ) -{ - m_Window = window; - if(window.IsNotNull()) - { - window->GetWorkbench()->AddWindowListener(berry::IWindowListener::Pointer(this)); - window->GetPartService()->AddPartListener(berry::IPartListener::Pointer(this)); - } -} - -QmitkFunctionalityCoordinator::~QmitkFunctionalityCoordinator() -{ -} - -berry::IPartListener::Events::Types QmitkFunctionalityCoordinator::GetPartEventTypes() const -{ - return berry::IPartListener::Events::ACTIVATED | berry::IPartListener::Events::DEACTIVATED - | berry::IPartListener::Events::CLOSED | berry::IPartListener::Events::HIDDEN - | berry::IPartListener::Events::VISIBLE | berry::IPartListener::Events::OPENED; -} - -void QmitkFunctionalityCoordinator::PartActivated( berry::IWorkbenchPartReference::Pointer partRef ) -{ - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - // change the active standalone functionality - this->ActivateStandaloneFunctionality(_QmitkFunctionality.GetPointer()); -} - -void QmitkFunctionalityCoordinator::PartDeactivated( berry::IWorkbenchPartReference::Pointer /*partRef*/ ) -{ - // nothing to do here: see PartActivated() -} - -void QmitkFunctionalityCoordinator::PartOpened( berry::IWorkbenchPartReference::Pointer partRef ) -{ - // check for multiwidget and inform views that it is available now - if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) - { - for (std::set::iterator it = m_Functionalities.begin() - ; it != m_Functionalities.end(); it++) - { - (*it)->StdMultiWidgetAvailable(*(partRef - ->GetPart(false).Cast()->GetStdMultiWidget())); - } - } - else - { - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - m_Functionalities.insert(_QmitkFunctionality.GetPointer()); // save as opened functionality - } - } -} - -void QmitkFunctionalityCoordinator::PartClosed( berry::IWorkbenchPartReference::Pointer partRef ) -{ - // check for multiwidget and inform views that it not available any more - if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) - { - - QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); - for (std::set::iterator it = m_Functionalities.begin() - ; it != m_Functionalities.end(); it++) - { - (*it)->StdMultiWidgetClosed(*(stdMultiWidgetEditor->GetStdMultiWidget())); - (*it)->StdMultiWidgetNotAvailable(); // deprecated call, provided for consistence - } - } - else - { - // check for functionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - // deactivate on close ( the standalone functionality may still be activated ) - this->DeactivateStandaloneFunctionality(_QmitkFunctionality.GetPointer()); - - // and set pointer to 0 - if(m_StandaloneFuntionality == _QmitkFunctionality.GetPointer()) - m_StandaloneFuntionality = 0; - - m_Functionalities.erase(_QmitkFunctionality.GetPointer()); // remove as opened functionality - - // call PartClosed on the QmitkFunctionality - _QmitkFunctionality->ClosePartProxy(); - //m_VisibleStandaloneFunctionalities.erase(_QmitkFunctionality.GetPointer()); // remove if necessary (should be done before in PartHidden() - } - } -} - -void QmitkFunctionalityCoordinator::PartHidden( berry::IWorkbenchPartReference::Pointer partRef ) -{ - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality != 0) - { - _QmitkFunctionality->SetVisible(false); - _QmitkFunctionality->Hidden(); - - // tracking of Visible Standalone Functionalities - m_VisibleStandaloneFunctionalities.erase(_QmitkFunctionality.GetPointer()); - - // activate Functionality if just one Standalone Functionality is visible - if( m_VisibleStandaloneFunctionalities.size() == 1 ) - this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); - } -} - -void QmitkFunctionalityCoordinator::PartVisible( berry::IWorkbenchPartReference::Pointer partRef ) -{ - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - _QmitkFunctionality->SetVisible(true); - _QmitkFunctionality->Visible(); - - // tracking of Visible Standalone Functionalities - if( _QmitkFunctionality->IsExclusiveFunctionality() ) - { - m_VisibleStandaloneFunctionalities.insert(_QmitkFunctionality.GetPointer()); - - // activate Functionality if just one Standalone Functionality is visible - if( m_VisibleStandaloneFunctionalities.size() == 1 ) - this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); - } - } -} - -void QmitkFunctionalityCoordinator::ActivateStandaloneFunctionality( QmitkFunctionality* functionality ) -{ - if( functionality && !functionality->IsActivated() && functionality->IsExclusiveFunctionality() ) - { - // deactivate old one if necessary - this->DeactivateStandaloneFunctionality(m_StandaloneFuntionality); - m_StandaloneFuntionality = functionality; - - // call activated on this functionality - m_StandaloneFuntionality->SetActivated(true); - m_StandaloneFuntionality->Activated(); - } -} - -void QmitkFunctionalityCoordinator::DeactivateStandaloneFunctionality(QmitkFunctionality* functionality) -{ - if(functionality && functionality->IsActivated()) - { - functionality->SetActivated(false); - functionality->Deactivated(); - } -} - -void QmitkFunctionalityCoordinator::WindowClosed( berry::IWorkbenchWindow::Pointer window ) -{ - if(window.IsNotNull()) - { - window->GetWorkbench()->RemoveWindowListener(berry::IWindowListener::Pointer(this)); - window->GetPartService()->RemovePartListener(berry::IPartListener::Pointer(this)); - } -} - -void QmitkFunctionalityCoordinator::WindowOpened( berry::IWorkbenchWindow::Pointer /*window*/ ) -{ - -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionalityCoordinator.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionalityCoordinator.h deleted file mode 100644 index 2abc3c423a..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionalityCoordinator.h +++ /dev/null @@ -1,116 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#ifndef QmitkFunctionalityCoordinator_h -#define QmitkFunctionalityCoordinator_h - -#include -#include -#include -#include -#include -class QmitkFunctionality; - -/// -/// A class which coordinates active QmitkFunctionalities, e.g. calling activated and hidden on them. -/// -class MITK_QT_COMMON QmitkFunctionalityCoordinator : virtual public berry::IPartListener, virtual public berry::IWindowListener -{ -public: - berryObjectMacro(QmitkFunctionalityCoordinator); - berryNewMacro(QmitkFunctionalityCoordinator); - - /// - /// Add listener - /// - QmitkFunctionalityCoordinator(); - /// - /// Remove listener - /// - virtual ~QmitkFunctionalityCoordinator(); - /// - /// Sets the window to attach the part listener - /// - void SetWindow(berry::IWorkbenchWindow::Pointer window); - //#IPartListener methods (these methods internally call Activated() or other similar methods) - /// - /// \see IPartListener::GetPartEventTypes() - /// - berry::IPartListener::Events::Types GetPartEventTypes() const; - /// - /// \see IPartListener::PartActivated() - /// - virtual void PartActivated (berry::IWorkbenchPartReference::Pointer partRef); - /// - /// \see IPartListener::PartDeactivated() - /// - virtual void PartDeactivated(berry::IWorkbenchPartReference::Pointer /*partRef*/); - /// - /// \see IPartListener::PartOpened() - /// - virtual void PartOpened(berry::IWorkbenchPartReference::Pointer partRef); - /// - /// \see IPartListener::PartClosed() - /// - virtual void PartClosed (berry::IWorkbenchPartReference::Pointer partRef); - /// - /// \see IPartListener::PartHidden() - /// - virtual void PartHidden (berry::IWorkbenchPartReference::Pointer partRef); - /// - /// \see IPartListener::PartVisible() - /// - virtual void PartVisible (berry::IWorkbenchPartReference::Pointer partRef); - - /** - * Notifies this listener that the given window has been closed. - */ - virtual void WindowClosed(berry::IWorkbenchWindow::Pointer window); - - /** - * Notifies this listener that the given window has been opened. - */ - virtual void WindowOpened(berry::IWorkbenchWindow::Pointer /*window*/); -protected: - /// - /// Activates the standalone functionality - /// - void ActivateStandaloneFunctionality(QmitkFunctionality* functionality); - /// - /// Deactivates the standalone functionality - /// - void DeactivateStandaloneFunctionality(QmitkFunctionality* functionality); - /// - /// Saves the workbench window - /// - berry::IWorkbenchWindow::WeakPtr m_Window; - /// - /// Saves the last QmitkFunctionality that added interactors - /// - QmitkFunctionality* m_StandaloneFuntionality; - /// - /// Saves all opened QmitkFunctionalities - /// - std::set m_Functionalities; - /// - /// Saves all visible QmitkFunctionalities - /// - std::set m_VisibleStandaloneFunctionalities; -}; - -#endif // QmitkFunctionalityCoordinator_h diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.cpp deleted file mode 100644 index 0296f35bd2..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/*========================================================================= - Program: BlueBerry Platform - Language: C++ - Date: $Date: 2009-07-08 13:02:46 +0200 (Mi, 08 Jul 2009) $ - Version: $Revision: 18037 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - =========================================================================*/ - -#include "QmitkPreferencesDialog.h" - -#include "berryPlatform.h" -#include "berryIConfigurationElement.h" -#include "berryIExtensionPointService.h" -#include "berryIExtension.h" -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -using namespace std; - -class QmitkPreferencesDialogPrivate : public Ui::QmitkPreferencesDialog -{ -public: - - /// - /// Just a stub class for holding information on prefpages (metadata) - /// - struct PrefPage - { - PrefPage(std::string _id, std::string _name, std::string _category - , std::string _className, std::string _keywords, berry::IConfigurationElement::Pointer _confElem) - : id(_id), name(_name), category(_category), className(_className), keywords(_keywords), - prefPage(0), confElem(_confElem), treeWidgetItem(0) - {} - - bool operator==(const PrefPage& other) - { return id == other.id; } - - bool operator<(const PrefPage& other) - { return name < other.name; } - - std::string id; - std::string name; - std::string category; - std::string className; - std::string keywords; - berry::IQtPreferencePage* prefPage; - berry::IConfigurationElement::Pointer confElem; - QTreeWidgetItem* treeWidgetItem; - }; - - QmitkPreferencesDialogPrivate() - : m_CurrentPage(0) - { - // m_PreferencesService - m_PreferencesService = - berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); - - // m_PrefPages - berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); - berry::IConfigurationElement::vector prefPages(extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.preferencePages")); - berry::IConfigurationElement::vector keywordExts(extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.keywords")); - berry::IConfigurationElement::vector::iterator prefPagesIt; - std::string id; - std::string name; - std::string category; - std::string className; - std::vector keywords; - vector keywordRefs; - berry::IConfigurationElement::vector::iterator keywordRefsIt; - berry::IConfigurationElement::vector::iterator keywordExtsIt; - string keywordRefId; - string keywordId; - string keywordLabels; - - for (prefPagesIt = prefPages.begin(); prefPagesIt != prefPages.end(); ++prefPagesIt) - { - keywords.clear(); - id.clear(); - name.clear(); - className.clear(); - category.clear(); - keywordRefId.clear(); - keywordId.clear(); - keywordLabels.clear(); - - if((*prefPagesIt)->GetAttribute("id", id) - && (*prefPagesIt)->GetAttribute("name", name) - && (*prefPagesIt)->GetAttribute("class", className)) - { - (*prefPagesIt)->GetAttribute("category", category); - //# collect keywords - keywordRefs = (*prefPagesIt)->GetChildren("keywordreference"); // get all keyword references - for (keywordRefsIt = keywordRefs.begin() - ; keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs - { - (*keywordRefsIt)->GetAttribute("id", keywordRefId); // get referenced id - - for (keywordExtsIt = keywordExts.begin(); keywordExtsIt != keywordExts.end(); ++keywordExtsIt) // iterate over all keywords - { - (*keywordExtsIt)->GetAttribute("id", keywordId); // get keyword id - if(keywordId == keywordRefId) // if referenced id is equals the current keyword id - { - //# collect all keywords from label attribute with a tokenizer - std::string currLabel; - (*keywordExtsIt)->GetAttribute("label", currLabel); - std::transform(currLabel.begin(), currLabel.end(), currLabel.begin(), ::tolower); - if (!currLabel.empty()) keywordLabels += std::string(" ") + currLabel; - - //break; // break here; possibly search for other referenced keywords - } - } - } - - // add information as PrefPage - m_PrefPages.push_back(PrefPage(id, name, category, className, keywordLabels, berry::IConfigurationElement::Pointer(*prefPagesIt))); - } - - } - } - - /// - /// The Preferences Service to retrieve and store preferences. - /// - berry::IPreferencesService::WeakPtr m_PreferencesService; - - /// - /// Saves all treewidgetitems in a map, the key is the id of the preferencepage. - /// - std::vector m_PrefPages; - std::size_t m_CurrentPage; -}; - -QmitkPreferencesDialog::QmitkPreferencesDialog(QWidget * parent, Qt::WindowFlags f) - : QDialog(parent, f), d(new QmitkPreferencesDialogPrivate) -{ - d->setupUi(this); - - QObject::connect(d->m_Keyword, SIGNAL(editingFinished()), this, SLOT(OnKeywordEditingFinished())); - QObject::connect(d->m_Keyword, SIGNAL(textChanged(QString)), this, SLOT(OnKeywordTextChanged(QString))); - - QObject::connect(d->m_PreferencesTree, SIGNAL(itemSelectionChanged()), this, SLOT(OnPreferencesTreeItemSelectionChanged())); - - QPushButton* importButton = d->buttonBox->addButton("Import...", QDialogButtonBox::ActionRole); - QObject::connect(importButton, SIGNAL(clicked()), this, SLOT(OnImportButtonClicked())); - - QPushButton* exportButton = d->buttonBox->addButton("Export...", QDialogButtonBox::ActionRole); - QObject::connect(exportButton, SIGNAL(clicked()), this, SLOT(OnExportButtonClicked())); - - QObject::connect(this, SIGNAL(accepted()), this, SLOT(OnDialogAccepted())); - QObject::connect(this, SIGNAL(rejected()), this, SLOT(OnDialogRejected())); - - d->buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true); - - this->UpdateTree(); -} - -QmitkPreferencesDialog::~QmitkPreferencesDialog() -{ -} - -void QmitkPreferencesDialog::SetSelectedPage(const std::string& id) -{ - for(vector::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it) - { - if(it->id == id) - { - d->m_PreferencesTree->setCurrentItem(it->treeWidgetItem); - break; - } - } -} - -void QmitkPreferencesDialog::OnImportButtonClicked() -{ - int answer = QMessageBox::question(this, "Importing Preferences" - , "All existing preferences will be overwritten!\nAre you sure that you want to import other preferences?", QMessageBox::Yes | QMessageBox::No ); - if(answer == QMessageBox::No) - return; - - try - { - berry::IPreferencesService::Pointer prefService = d->m_PreferencesService.Lock(); - if(prefService.IsNotNull()) - { - berry::IBerryPreferencesService::Pointer berryPrefService = prefService.Cast(); - if(berryPrefService != 0) - { - static QString importDir = ""; - QString fileName = QFileDialog::getOpenFileName(this, tr("Choose file to import preferences"), - importDir, tr("XML files (*.xml)")); - - if(!fileName.isEmpty()) - { - importDir = QFileInfo(fileName).absoluteDir().path(); - Poco::File f(fileName.toLocal8Bit().data()); - berryPrefService->ImportPreferences(f, ""); - berry::IQtPreferencePage* prefPage = d->m_PrefPages[d->m_CurrentPage].prefPage; - if(prefPage) - prefPage->Update(); - - MITK_INFO("QmitkPreferencesDialog") << "Preferences successfully imported from " << f.path(); - } - } - } - } - catch (Poco::Exception& pe) - { - QMessageBox::critical(this, "Error Importing", pe.message().c_str()); - MITK_ERROR("QmitkPreferencesDialog") << pe.what(); - } - catch (std::exception& e) - { - QMessageBox::critical(this, "Error Importing", e.what()); - MITK_ERROR("QmitkPreferencesDialog") << e.what(); - } -} - -void QmitkPreferencesDialog::OnExportButtonClicked() -{ - try - { - berry::IPreferencesService::Pointer prefService = d->m_PreferencesService.Lock(); - if(prefService.IsNotNull()) - { - berry::IBerryPreferencesService::Pointer berryPrefService = prefService.Cast(); - if(berryPrefService != 0) - { - SavePreferences(); - static QString exportDir = ""; - QString fileName = QFileDialog::getSaveFileName(this, tr("Choose file to export preferences"), - exportDir, tr("XML files (*.xml)")); - - if(!fileName.isEmpty()) - { - if(QFileInfo(fileName).suffix() != ".xml") - { - fileName += ".xml"; - } - exportDir = QFileInfo(fileName).absoluteDir().path(); - Poco::File f(fileName.toLocal8Bit().data()); - berryPrefService->ExportPreferences(f, ""); - MITK_INFO("QmitkPreferencesDialog") << "Preferences successfully exported to " << f.path(); - } - } - } - } - catch (Poco::Exception& pe) - { - QMessageBox::critical(this, "Error Exporting", pe.message().c_str()); - MITK_ERROR("QmitkPreferencesDialog") << pe.what(); - } - catch (std::exception& e) - { - QMessageBox::critical(this, "Error Exporting", e.what()); - MITK_ERROR("QmitkPreferencesDialog") << e.what(); - } -} - -void QmitkPreferencesDialog::SavePreferences() -{ - berry::IQtPreferencePage* prefPage = 0; - - for(vector::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it) - { - prefPage = it->prefPage; - if(prefPage) { - prefPage->PerformOk(); - } - } - - /** - * Every preference page has its own preferences, which should stay the same after a system restart.
- * Therefore this method flushes all the preferences, every time a change in the preferences is
- * performed and confirmed. - * - */ - berry::IPreferencesService::Pointer prefService = d->m_PreferencesService.Lock(); - if (prefService) - { - prefService->GetSystemPreferences()->Flush(); - } -} - -void QmitkPreferencesDialog::OnDialogAccepted() -{ - this->SavePreferences(); -} - -void QmitkPreferencesDialog::OnDialogRejected() -{ - berry::IQtPreferencePage* prefPage = d->m_PrefPages[d->m_CurrentPage].prefPage; - if(prefPage) - prefPage->PerformCancel(); -} - -void QmitkPreferencesDialog::OnKeywordTextChanged(const QString & /*s*/) -{ - // search for text - this->UpdateTree(); -} - -void QmitkPreferencesDialog::OnKeywordEditingFinished() -{ -} - -//bool QmitkPreferencesDialog::eventFilter( QObject *obj, QEvent *event ) -//{ -// if(obj == d->m_Keyword) -// { -// if(event->type() == QEvent::FocusIn && d->m_Keyword->text() == "search ...") -// { -// d->m_Keyword->setText(""); -// d->m_Keyword->setStyleSheet("color: black;"); -// } -// else if(event->type() == QEvent::FocusOut && d->m_Keyword->text() == "") -// { -// d->m_Keyword->setText("search ..."); -// d->m_Keyword->setStyleSheet("color: gray;"); -// } -// } -// return true; -//} - -void QmitkPreferencesDialog::OnPreferencesTreeItemSelectionChanged() -{ - if(d->m_PreferencesTree == 0) - return; - - // TODO: create page and show it - QList selectedItems = d->m_PreferencesTree->selectedItems(); - if(selectedItems.size()>0) - { - - d->m_CurrentPage = 0; - for(vector::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it, ++d->m_CurrentPage) - { - if(it->treeWidgetItem == selectedItems.at(0)) - { - d->m_Headline->setText(QString::fromStdString(it->name)); - if(it->prefPage == 0) - { - berry::IPreferencePage* page = it->confElem->CreateExecutableExtension("class"); - if (page == 0) - { - // support legacy BlueBerry extensions - page = it->confElem->CreateExecutableExtension("class", berry::IPreferencePage::GetManifestName()); - } - it->prefPage = dynamic_cast(page); - it->prefPage->CreateQtControl(d->m_PreferencesPanel); - d->m_PreferencesPanel->addWidget(it->prefPage->GetQtControl()); - } - d->m_PreferencesPanel->setCurrentWidget(it->prefPage->GetQtControl()); - - break; - } - } - } -} - -void QmitkPreferencesDialog::UpdateTree() -{ - if(d->m_PreferencesTree == 0) - return; - - //m_PreferencesTree->clear(); - string keyword = d->m_Keyword->text().toLower().toStdString(); - - map items; - - for(vector::iterator it = d->m_PrefPages.begin(); - it != d->m_PrefPages.end(); ++it) - { - if(it->treeWidgetItem == 0) - { - - if(it->category.empty()) - { - it->treeWidgetItem = new QTreeWidgetItem(d->m_PreferencesTree); - } - else - { - it->treeWidgetItem = new QTreeWidgetItem(items[it->category]); - } - it->treeWidgetItem->setText(0, QString::fromStdString(it->name)); - items[it->id] = it->treeWidgetItem; - } - - // hide treeWidgetItem if keyword not matches - if(!keyword.empty()) - { - if( it->keywords.find(keyword) == string::npos ) - it->treeWidgetItem->setHidden(true); - else - { - //#make the whole branch visible - QTreeWidgetItem* treeWidgetParent = it->treeWidgetItem->parent(); - while(treeWidgetParent!=0) - { - treeWidgetParent->setHidden(false); - treeWidgetParent->setExpanded(true); - treeWidgetParent = treeWidgetParent->parent(); - } - - it->treeWidgetItem->setHidden(false); - QFont f = it->treeWidgetItem->font(0); - f.setBold(true); - it->treeWidgetItem->setFont(0, f); - } - } - else - { - QFont f = it->treeWidgetItem->font(0); - f.setBold(false); - it->treeWidgetItem->setFont(0, f); - it->treeWidgetItem->setHidden(false); - } - } - - if(d->m_PrefPages.size()>0) - { - if(d->m_PrefPages.front().treeWidgetItem != 0) - d->m_PrefPages.front().treeWidgetItem->setSelected(true); - } - -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.h deleted file mode 100644 index f68beab1c0..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.h +++ /dev/null @@ -1,66 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date: 2009-02-22 15:57:29 +0100 (So, 22 Feb 2009) $ - Version: $Revision: 16375 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef BERRYQMITKPREFERENCESDIALOG_H_ -#define BERRYQMITKPREFERENCESDIALOG_H_ - -#include - -#include -#include - - -class QmitkPreferencesDialogPrivate; - -class MITK_QT_COMMON QmitkPreferencesDialog : public QDialog -{ - Q_OBJECT - -public: - - QmitkPreferencesDialog(QWidget * parent = 0, Qt::WindowFlags f = 0); - ~QmitkPreferencesDialog(); - - void SetSelectedPage(const std::string& id); - -protected slots: - - void OnImportButtonClicked(); - void OnExportButtonClicked(); - void OnDialogAccepted(); - void OnDialogRejected(); - - void OnKeywordTextChanged(const QString & s); - void OnKeywordEditingFinished(); - void OnPreferencesTreeItemSelectionChanged(); - -protected: - - //bool eventFilter(QObject *obj, QEvent *event); - void UpdateTree(); - - /// - /// Saves all preferencepages. - /// - void SavePreferences(); - - QScopedPointer d; - -}; - -#endif /* BERRYQMITKPREFERENCESDIALOG_H_ */ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStatusBar.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStatusBar.h deleted file mode 100755 index 297e8419a0..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStatusBar.h +++ /dev/null @@ -1,82 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#ifndef QMITKSTATUSBAR_H -#define QMITKSTATUSBAR_H -#include -#include -#include -#include -#include - -//##Documentation -//## @brief QT-Toolkit/GUI dependent class that provides to send a Message to the QT's StatusBar -//## -//## A delay time can be set. -//## -//## All mitk-classes will call this class for output: -//## mitk::StatusBar::GetInstance(); -class MITK_QT_COMMON QmitkStatusBar : public mitk::StatusBarImplementation -{ -public: - - mitkClassMacro(QmitkStatusBar, mitk::StatusBarImplementation); - - //##Documentation - //##@brief Constructor; - //## holds param instance internaly and connects this to the mitkStatusBar - QmitkStatusBar(QStatusBar* instance); - - //##Documentation - //##@brief Destructor - virtual ~QmitkStatusBar(); - - - //##Documentation - //## @brief Send a string to the applications StatusBar (QStatusBar). - virtual void DisplayText(const char* t); - virtual void DisplayText(const char* t, int ms); - - //##Documentation - //## @brief Send a string as an error message to StatusBar. - //## The implementation calls DisplayText() - virtual void DisplayErrorText(const char *t) { this->DisplayText(t); }; - virtual void DisplayWarningText(const char *t) { this->DisplayText(t); }; - virtual void DisplayWarningText(const char *t, int ms) { this->DisplayText(t, ms); }; - virtual void DisplayGenericOutputText(const char *t) {this->DisplayText(t);} - virtual void DisplayDebugText(const char *t) { this->DisplayText(t); }; - virtual void DisplayGreyValueText(const char *t); - - //##Documentation - //## @brief removes any temporary message being shown. - virtual void Clear(); - - //##Documentation - //## @brief Set the QSizeGrip of the window - //## (the triangle in the lower right Windowcorner for changing the size) - //## to enabled or disabled - virtual void SetSizeGripEnabled(bool enable); - -private: - //static Pointer m_Instance; - QStatusBar* m_StatusBar; - QLabel* m_GreyValueLabel; - -}; - -#endif /* define QMITKSTATUSBAR_H */ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.cpp deleted file mode 100644 index 1f4d26cd23..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkStdMultiWidgetEditor.h" - -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" - -#include "QmitkMouseModeSwitcher.h" - -const std::string QmitkStdMultiWidgetEditor::EDITOR_ID = "org.mitk.editors.stdmultiwidget"; - -QmitkStdMultiWidgetEditor::QmitkStdMultiWidgetEditor() -:m_StdMultiWidget(NULL) -,m_MouseModeToolbar(NULL) -{ - -} - -QmitkStdMultiWidgetEditor::QmitkStdMultiWidgetEditor(const QmitkStdMultiWidgetEditor& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -QmitkStdMultiWidgetEditor::~QmitkStdMultiWidgetEditor() -{ - // we need to wrap the RemovePartListener call inside a - // register/unregister block to prevent infinite recursion - // due to the destruction of temporary smartpointer to this - this->Register(); - this->GetSite()->GetPage()->RemovePartListener(berry::IPartListener::Pointer(this)); - this->UnRegister(false); -} - -QmitkStdMultiWidget* QmitkStdMultiWidgetEditor::GetStdMultiWidget() -{ - return m_StdMultiWidget; -} - -void QmitkStdMultiWidgetEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) -{ - if (input.Cast().IsNull()) - throw berry::PartInitException("Invalid Input: Must be IFileEditorInput"); - - this->SetSite(site); - this->SetInput(input); -} - -void QmitkStdMultiWidgetEditor::CreateQtPartControl(QWidget* parent) -{ - if (m_StdMultiWidget == 0) - { - m_DndFrameWidget = new QmitkDnDFrameWidget(parent); - QVBoxLayout* layout = new QVBoxLayout(parent); - layout->addWidget(m_DndFrameWidget); - layout->setContentsMargins(0,0,0,0); - - QHBoxLayout* layout2 = new QHBoxLayout(m_DndFrameWidget); - layout2->setContentsMargins(0,0,0,0); - - if (m_MouseModeToolbar == NULL) - { - m_MouseModeToolbar = new QmitkMouseModeSwitcher(m_DndFrameWidget); // delete by Qt via parent - layout2->addWidget(m_MouseModeToolbar); - } - - m_StdMultiWidget = new QmitkStdMultiWidget(m_DndFrameWidget); - - m_MouseModeToolbar->setMouseModeSwitcher( m_StdMultiWidget->GetMouseModeSwitcher() ); - connect( m_MouseModeToolbar, SIGNAL( MouseModeSelected(mitk::MouseModeSwitcher::MouseMode) ), - m_StdMultiWidget, SLOT( MouseModeSelected(mitk::MouseModeSwitcher::MouseMode) ) ); - - layout2->addWidget(m_StdMultiWidget); - - mitk::DataStorage::Pointer ds = this->GetEditorInput().Cast() - ->GetDataStorageReference()->GetDataStorage(); - - // Tell the multiWidget which (part of) the tree to render - m_StdMultiWidget->SetDataStorage(ds); - - // Initialize views as transversal, sagittal, coronar to all data objects in DataStorage - // (from top-left to bottom) - mitk::TimeSlicedGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll()); - mitk::RenderingManager::GetInstance()->InitializeViews(geo); - - // Initialize bottom-right view as 3D view - m_StdMultiWidget->GetRenderWindow4()->GetRenderer()->SetMapperID( - mitk::BaseRenderer::Standard3D ); - - // Enable standard handler for levelwindow-slider - m_StdMultiWidget->EnableStandardLevelWindow(); - - // Add the displayed views to the tree to see their positions - // in 2D and 3D - m_StdMultiWidget->AddDisplayPlaneSubTree(); - - m_StdMultiWidget->EnableNavigationControllerEventListening(); - - this->GetSite()->GetPage()->AddPartListener(berry::IPartListener::Pointer(this)); - - // enable change of logo - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - - berry::IPreferences::Pointer logoPref = prefService->GetSystemPreferences()->Node("DepartmentLogo"); - std::string departmentLogoLocation = logoPref->Get("DepartmentLogo",""); - - //# Preferences - - berry::IBerryPreferences::Pointer prefs - = (prefService->GetSystemPreferences()->Node(EDITOR_ID)) - .Cast(); - assert( prefs ); - - prefs->OnChanged.AddListener( berry::MessageDelegate1( this - , &QmitkStdMultiWidgetEditor::OnPreferencesChanged ) ); - - bool constrainedZooming = prefs->GetBool("Use constrained zooming and padding", false); - - mitk::RenderingManager::GetInstance()->SetConstrainedPaddingZooming(constrainedZooming); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - bool showLevelWindowWidget = prefs->GetBool("Show level/window widget", true); - if (!showLevelWindowWidget) - { - m_StdMultiWidget->DisableStandardLevelWindow(); - } - - m_StdMultiWidget->SetDepartmentLogoPath(departmentLogoLocation.c_str()); - m_StdMultiWidget->DisableDepartmentLogo(); - m_StdMultiWidget->EnableDepartmentLogo(); - - this->OnPreferencesChanged(prefs.GetPointer()); - } -} - -void QmitkStdMultiWidgetEditor::OnPreferencesChanged(const berry::IBerryPreferences* prefs) -{ - // preferences for gradient background - float color = 255.0; - QString firstColorName = QString::fromStdString (prefs->GetByteArray("first background color", "")); - QColor firstColor(firstColorName); - mitk::Color upper; - if (firstColorName=="") // default values - { - upper[0] = 0.1; - upper[1] = 0.1; - upper[2] = 0.1; - } - else - { - upper[0] = firstColor.red() / color; - upper[1] = firstColor.green() / color; - upper[2] = firstColor.blue() / color; - } - - QString secondColorName = QString::fromStdString (prefs->GetByteArray("second background color", "")); - QColor secondColor(secondColorName); - mitk::Color lower; - if (secondColorName=="") // default values - { - lower[0] = 0.5; - lower[1] = 0.5; - lower[2] = 0.5; - } - else - { - lower[0] = secondColor.red() / color; - lower[1] = secondColor.green() / color; - lower[2] = secondColor.blue() / color; - } - m_StdMultiWidget->SetGradientBackgroundColors(upper, lower); - m_StdMultiWidget->EnableGradientBackground(); - - // Set preferences respecting zooming and padding - bool constrainedZooming = prefs->GetBool("Use constrained zooming and padding", false); - - mitk::RenderingManager::GetInstance()->SetConstrainedPaddingZooming(constrainedZooming); - - 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::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible"); - - - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - // level window setting - bool showLevelWindowWidget = prefs->GetBool("Show level/window widget", true); - if (showLevelWindowWidget) - { - m_StdMultiWidget->EnableStandardLevelWindow(); - } - else - { - m_StdMultiWidget->DisableStandardLevelWindow(); - } - - // mouse modes toolbar - bool newMode = prefs->GetBool("PACS like mouse interaction", false); - m_MouseModeToolbar->setVisible( newMode ); - m_StdMultiWidget->GetMouseModeSwitcher()->SetInteractionScheme( newMode ? mitk::MouseModeSwitcher::PACS : mitk::MouseModeSwitcher::MITK ); -} - - -mitk::DataStorage::Pointer QmitkStdMultiWidgetEditor::GetDataStorage() const -{ - mitk::IDataStorageService::Pointer service = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); - - if (service.IsNotNull()) - { - return service->GetDefaultDataStorage()->GetDataStorage(); - } - - return 0; -} - - -berry::IPartListener::Events::Types QmitkStdMultiWidgetEditor::GetPartEventTypes() const -{ - return Events::CLOSED | Events::HIDDEN | Events::VISIBLE; -} - -void QmitkStdMultiWidgetEditor::PartClosed( berry::IWorkbenchPartReference::Pointer partRef ) -{ - if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) - { - QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); - - if (m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) - { - m_StdMultiWidget->RemovePlanesFromDataStorage(); - } - } -} - -void QmitkStdMultiWidgetEditor::PartVisible( berry::IWorkbenchPartReference::Pointer partRef ) -{ - if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) - { - QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); - - if (m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) - { - m_StdMultiWidget->AddPlanesToDataStorage(); - } - } -} - -void QmitkStdMultiWidgetEditor::PartHidden( berry::IWorkbenchPartReference::Pointer partRef ) -{ - if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) - { - QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); - - if (m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) - { - m_StdMultiWidget->RemovePlanesFromDataStorage(); - } - } -} - -void QmitkStdMultiWidgetEditor::SetFocus() -{ - if (m_StdMultiWidget != 0) - m_StdMultiWidget->setFocus(); -} diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.h deleted file mode 100644 index 33554db9ab..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.h +++ /dev/null @@ -1,87 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKSTDMULTIWIDGETEDITOR_H_ -#define QMITKSTDMULTIWIDGETEDITOR_H_ - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -class QmitkMouseModeSwitcher; - -class MITK_QT_COMMON QmitkStdMultiWidgetEditor : - public berry::QtEditorPart, virtual public berry::IPartListener -{ - Q_OBJECT - -public: - berryObjectMacro(QmitkStdMultiWidgetEditor) - - static const std::string EDITOR_ID; - - QmitkStdMultiWidgetEditor(); - QmitkStdMultiWidgetEditor(const QmitkStdMultiWidgetEditor& other); - ~QmitkStdMultiWidgetEditor(); - - QmitkStdMultiWidget* GetStdMultiWidget(); - - void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input); - - void SetFocus(); - - void DoSave() {} - void DoSaveAs() {} - bool IsDirty() const { return false; } - bool IsSaveAsAllowed() const { return false; } - -public slots: - void OnPreferencesChanged(const berry::IBerryPreferences*); - -protected: - - void CreateQtPartControl(QWidget* parent); - // IPartListener - Events::Types GetPartEventTypes() const; - virtual void PartClosed (berry::IWorkbenchPartReference::Pointer partRef); - virtual void PartHidden (berry::IWorkbenchPartReference::Pointer partRef); - virtual void PartVisible (berry::IWorkbenchPartReference::Pointer partRef); - - - mitk::DataStorage::Pointer GetDataStorage() const; - - -private: - - QmitkStdMultiWidget* m_StdMultiWidget; - QmitkMouseModeSwitcher* m_MouseModeToolbar; - QmitkDnDFrameWidget* m_DndFrameWidget; - std::string m_FirstBackgroundColor; - std::string m_SecondBackgroundColor; -}; - -#endif /*QMITKSTDMULTIWIDGETEDITOR_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.cpp deleted file mode 100644 index 624fa0d01e..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkCommonActivator.h" - -#include "../QmitkStdMultiWidgetEditor.h" -#include "QmitkStdMultiWidgetEditorPreferencePage.h" -#include "QmitkGeneralPreferencePage.h" -#include "QmitkEditorsPreferencePage.h" - -#include -#include - - -void -QmitkCommonActivator::start(ctkPluginContext* context) -{ - Q_UNUSED(context) - - BERRY_REGISTER_EXTENSION_CLASS(QmitkStdMultiWidgetEditor, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkStdMultiWidgetEditorPreferencePage, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkGeneralPreferencePage, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkEditorsPreferencePage, context) - - QFile file(":/org.mitk.gui.qt.common/StateMachine.xml"); - if(file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text) ) - { - QByteArray contents = file.readAll(); - QString string(contents); - file.close(); - mitk::GlobalInteraction::GetInstance()->Initialize("global", string.toStdString()); - } - else throw std::exception(); - - QmitkRegisterClasses(); - -} - -void -QmitkCommonActivator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -Q_EXPORT_PLUGIN2(org_mitk_gui_qt_common, QmitkCommonActivator) diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.h deleted file mode 100644 index dae84a9cde..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.h +++ /dev/null @@ -1,48 +0,0 @@ -/*========================================================================= - - Program: MITK Platform - Language: C++ - Date: $Date$ - Version: $Revision: 17020 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKCOMMONACTIVATOR_H_ -#define QMITKCOMMONACTIVATOR_H_ - -#include - -/** - * \ingroup org_mitk_core_ext_internal - * - * \brief The plug-in activator for the StateMachine - * - * When the plug-in is started by the framework, it initializes StateMachine - * specific things. - */ -class QmitkCommonActivator : public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_INTERFACES(ctkPluginActivator) - -public: - - /** - * Sets default StateMachine to EventMapper. - */ - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; - -#endif /* QMITKCOMMONACTIVATOR_H_ */ - diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp deleted file mode 100644 index f7f8fd7b5a..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ - Version: $Revision: 18019 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkStdMultiWidgetEditorPreferencePage.h" -#include "QmitkStdMultiWidgetEditor.h" - -#include -#include -#include -#include -#include - -#include -#include - -QmitkStdMultiWidgetEditorPreferencePage::QmitkStdMultiWidgetEditorPreferencePage() -: m_MainControl(0) -{ - -} - -QmitkStdMultiWidgetEditorPreferencePage::QmitkStdMultiWidgetEditorPreferencePage(const QmitkStdMultiWidgetEditorPreferencePage& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -void QmitkStdMultiWidgetEditorPreferencePage::Init(berry::IWorkbench::Pointer ) -{ - -} - -void QmitkStdMultiWidgetEditorPreferencePage::CreateQtControl(QWidget* parent) -{ - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - - m_StdMultiWidgetEditorPreferencesNode = prefService->GetSystemPreferences()->Node(QmitkStdMultiWidgetEditor::EDITOR_ID); - - m_MainControl = new QWidget(parent); - m_EnableFlexibleZooming = new QCheckBox; - m_ShowLevelWindowWidget = new QCheckBox; - m_PACSLikeMouseMode = new QCheckBox; - - QFormLayout *formLayout = new QFormLayout; - formLayout->addRow("&Use constrained zooming and padding", m_EnableFlexibleZooming); - formLayout->addRow("&Show level/window widget", m_ShowLevelWindowWidget); - formLayout->addRow("&PACS like mouse interactions (select left mouse button action)", m_PACSLikeMouseMode); - - // gradient background - QLabel* gBName = new QLabel; - gBName->setText("Gradient background"); - formLayout->addRow(gBName); - - // color - m_ColorButton1 = new QPushButton; - m_ColorButton1->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); - m_ColorButton2 = new QPushButton; - m_ColorButton2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); - QPushButton* resetButton = new QPushButton; - resetButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); - resetButton->setText("Reset"); - - QLabel* colorLabel1 = new QLabel("first color : "); - colorLabel1->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); - QLabel* colorLabel2 = new QLabel("second color: "); - colorLabel2->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); - - QHBoxLayout* colorWidgetLayout = new QHBoxLayout; - colorWidgetLayout->setContentsMargins(4,4,4,4); - colorWidgetLayout->addWidget(colorLabel1); - colorWidgetLayout->addWidget(m_ColorButton1); - colorWidgetLayout->addWidget(colorLabel2); - colorWidgetLayout->addWidget(m_ColorButton2); - colorWidgetLayout->addWidget(resetButton); - - QWidget* colorWidget = new QWidget; - colorWidget->setLayout(colorWidgetLayout); - - //spacer - QSpacerItem *spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - QVBoxLayout* vBoxLayout = new QVBoxLayout; - vBoxLayout->addLayout(formLayout); - vBoxLayout->addWidget(colorWidget); - vBoxLayout->addSpacerItem(spacer); - - m_MainControl->setLayout(vBoxLayout); - - QObject::connect( m_ColorButton1, SIGNAL( clicked() ) - , this, SLOT( FirstColorChanged() ) ); - - QObject::connect( m_ColorButton2, SIGNAL( clicked() ) - , this, SLOT( SecondColorChanged() ) ); - - QObject::connect( resetButton, SIGNAL( clicked() ) - , this, SLOT( ResetColors() ) ); - - this->Update(); -} - -QWidget* QmitkStdMultiWidgetEditorPreferencePage::GetQtControl() const -{ - return m_MainControl; -} - -bool QmitkStdMultiWidgetEditorPreferencePage::PerformOk() -{ - m_StdMultiWidgetEditorPreferencesNode->Put("first background color style sheet", m_FirstColorStyleSheet.toStdString()); - m_StdMultiWidgetEditorPreferencesNode->Put("second background color style sheet", m_SecondColorStyleSheet.toStdString()); - m_StdMultiWidgetEditorPreferencesNode->PutByteArray("first background color", m_FirstColor); - m_StdMultiWidgetEditorPreferencesNode->PutByteArray("second background color", m_SecondColor); - m_StdMultiWidgetEditorPreferencesNode->PutBool("Use constrained zooming and padding" - , m_EnableFlexibleZooming->isChecked()); - m_StdMultiWidgetEditorPreferencesNode->PutBool("Show level/window widget", m_ShowLevelWindowWidget->isChecked()); - m_StdMultiWidgetEditorPreferencesNode->PutBool("PACS like mouse interaction", m_PACSLikeMouseMode->isChecked()); - - return true; -} - -void QmitkStdMultiWidgetEditorPreferencePage::PerformCancel() -{ - -} - -void QmitkStdMultiWidgetEditorPreferencePage::Update() -{ - m_EnableFlexibleZooming->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("Use constrained zooming and padding", true)); - m_ShowLevelWindowWidget->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("Show level/window widget", true)); - m_PACSLikeMouseMode->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("PACS like mouse interaction", false)); - m_FirstColorStyleSheet = QString::fromStdString(m_StdMultiWidgetEditorPreferencesNode->Get("first background color style sheet", "")); - m_SecondColorStyleSheet = QString::fromStdString(m_StdMultiWidgetEditorPreferencesNode->Get("second background color style sheet", "")); - m_FirstColor = m_StdMultiWidgetEditorPreferencesNode->GetByteArray("first background color", ""); - m_SecondColor = m_StdMultiWidgetEditorPreferencesNode->GetByteArray("second background color", ""); - if (m_FirstColorStyleSheet=="") - { - m_FirstColorStyleSheet = "background-color:rgb(25,25,25)"; - } - if (m_SecondColorStyleSheet=="") - { - m_SecondColorStyleSheet = "background-color:rgb(127,127,127)"; - } - if (m_FirstColor=="") - { - m_FirstColor = "#191919"; - } - if (m_SecondColor=="") - { - m_SecondColor = "#7F7F7F"; - } - m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet); - m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet); -} - -void QmitkStdMultiWidgetEditorPreferencePage::FirstColorChanged() -{ - QColor color = QColorDialog::getColor(); - m_ColorButton1->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb("; - - styleSheet.append(QString::number(color.red())); - styleSheet.append(","); - styleSheet.append(QString::number(color.green())); - styleSheet.append(","); - styleSheet.append(QString::number(color.blue())); - styleSheet.append(")"); - m_ColorButton1->setStyleSheet(styleSheet); - - m_FirstColorStyleSheet = styleSheet; - QStringList firstColor; - firstColor << color.name(); - m_FirstColor = firstColor.replaceInStrings(";","\\;").join(";").toStdString(); - } - -void QmitkStdMultiWidgetEditorPreferencePage::SecondColorChanged() -{ - QColor color = QColorDialog::getColor(); - m_ColorButton2->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb("; - - styleSheet.append(QString::number(color.red())); - styleSheet.append(","); - styleSheet.append(QString::number(color.green())); - styleSheet.append(","); - styleSheet.append(QString::number(color.blue())); - styleSheet.append(")"); - m_ColorButton2->setStyleSheet(styleSheet); - - m_SecondColorStyleSheet = styleSheet; - QStringList secondColor; - secondColor << color.name(); - m_SecondColor = secondColor.replaceInStrings(";","\\;").join(";").toStdString(); - } - -void QmitkStdMultiWidgetEditorPreferencePage::ResetColors() -{ - m_FirstColorStyleSheet = "background-color:rgb(25,25,25)"; - m_SecondColorStyleSheet = "background-color:rgb(127,127,127)"; - m_FirstColor = "#191919"; - m_SecondColor = "#7F7F7F"; - m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet); - m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet); -} - -void QmitkStdMultiWidgetEditorPreferencePage::UseGradientBackgroundSelected() -{ - -} - -void QmitkStdMultiWidgetEditorPreferencePage::ColorActionChanged() -{ - -} - diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkStdMultiWidgetEditorPreferencePage.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkStdMultiWidgetEditorPreferencePage.h deleted file mode 100644 index 7ddc83d9b9..0000000000 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkStdMultiWidgetEditorPreferencePage.h +++ /dev/null @@ -1,87 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ - Version: $Revision: 16224 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKSTDMULTIWIDGETEDITORPREFERENCEPAGE_H_ -#define QMITKSTDMULTIWIDGETEDITORPREFERENCEPAGE_H_ - -#include "berryIQtPreferencePage.h" -#include - -class QWidget; -class QCheckBox; -class QPushButton; -class QWidgetAction; - -struct QmitkStdMultiWidgetEditorPreferencePage : public QObject, public berry::IQtPreferencePage -{ - Q_OBJECT - Q_INTERFACES(berry::IPreferencePage) - -public: - QmitkStdMultiWidgetEditorPreferencePage(); - QmitkStdMultiWidgetEditorPreferencePage(const QmitkStdMultiWidgetEditorPreferencePage& other); - - void Init(berry::IWorkbench::Pointer workbench); - - void CreateQtControl(QWidget* widget); - - QWidget* GetQtControl() const; - - /// - /// \see IPreferencePage::PerformOk() - /// - virtual bool PerformOk(); - - /// - /// \see IPreferencePage::PerformCancel() - /// - virtual void PerformCancel(); - - /// - /// \see IPreferencePage::Update() - /// - virtual void Update(); - -public slots: - void FirstColorChanged(); - - void SecondColorChanged(); - - void UseGradientBackgroundSelected(); - - void ColorActionChanged(); - - void ResetColors(); - -protected: - QWidget* m_MainControl; - QCheckBox* m_EnableFlexibleZooming; - QCheckBox* m_ShowLevelWindowWidget; - QCheckBox* m_UseGradientBackground; - QCheckBox* m_ChangeBackgroundColors; - QCheckBox* m_PACSLikeMouseMode; - QPushButton* m_ColorButton1; - QPushButton* m_ColorButton2; - std::string m_FirstColor; - std::string m_SecondColor; - QString m_FirstColorStyleSheet; - QString m_SecondColorStyleSheet; - berry::IPreferences::Pointer m_StdMultiWidgetEditorPreferencesNode; -}; - -#endif /* QMITKDATAMANAGERPREFERENCEPAGE_H_ */ diff --git a/CoreUI/CMakeLists.txt b/CoreUI/CMakeLists.txt deleted file mode 100644 index 14833942f4..0000000000 --- a/CoreUI/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -SET(MITK_DEFAULT_SUBPROJECTS MITK-CoreUI) - -IF(MITK_USE_QT AND QT4_FOUND) - ADD_SUBDIRECTORY(Qmitk) -ENDIF() - -IF(MITK_USE_BLUEBERRY) - # BlueBerry depends on CTK which depends on Qt, so we - # need the Qt include direcotries - INCLUDE(${QT_USE_FILE}) - - ADD_SUBDIRECTORY(Bundles) - - IF(MITK_ENABLE_GUI_TESTING AND BLUEBERRY_ENABLE_GUI_TESTING) - ADD_SUBDIRECTORY(BundleTesting) - ENDIF() -ENDIF() - diff --git a/CoreUI/Qmitk/QmitkCustomVariants.h b/CoreUI/Qmitk/QmitkCustomVariants.h deleted file mode 100755 index 3aca1aa8a8..0000000000 --- a/CoreUI/Qmitk/QmitkCustomVariants.h +++ /dev/null @@ -1,27 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKCUSTOMVARIANTS_H_ -#define QMITKCUSTOMVARIANTS_H_ - -#include - -Q_DECLARE_METATYPE(mitk::DataNode::Pointer) -Q_DECLARE_METATYPE(mitk::DataNode*) - -#endif /* QMITKCUSTOMVARIANTS_H_ */ diff --git a/CoreUI/Qmitk/QmitkDataStorageTableModel.cpp b/CoreUI/Qmitk/QmitkDataStorageTableModel.cpp deleted file mode 100644 index 495391f157..0000000000 --- a/CoreUI/Qmitk/QmitkDataStorageTableModel.cpp +++ /dev/null @@ -1,525 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkDataStorageTableModel.h" - -//# Own includes -#include "mitkNodePredicateBase.h" -#include "mitkProperties.h" -#include "mitkRenderingManager.h" -#include "QmitkEnums.h" -#include "QmitkCustomVariants.h" -#include - -//# Toolkit includes -#include -#include - -//#CTORS/DTOR -QmitkDataStorageTableModel::QmitkDataStorageTableModel(mitk::DataStorage::Pointer _DataStorage - , mitk::NodePredicateBase* _Predicate - , QObject* parent ) -: QAbstractTableModel(parent) -, m_DataStorage(0) -, m_Predicate(0) -, m_BlockEvents(false) -, m_SortDescending(false) -{ - this->SetPredicate(_Predicate); - this->SetDataStorage(_DataStorage); -} - -QmitkDataStorageTableModel::~QmitkDataStorageTableModel() -{ - // set data storage 0 to remove event listeners - this->SetDataStorage(0); -} - -//# Public GETTER -const mitk::DataStorage::Pointer QmitkDataStorageTableModel::GetDataStorage() const -{ - return m_DataStorage.GetPointer(); -} - -mitk::NodePredicateBase::Pointer QmitkDataStorageTableModel::GetPredicate() const -{ - return m_Predicate; -} - -mitk::DataNode::Pointer QmitkDataStorageTableModel::GetNode( const QModelIndex &index ) const -{ - mitk::DataNode::Pointer node; - - if(index.isValid()) - { - node = m_NodeSet.at(index.row()); - } - - return node; -} - - -QVariant QmitkDataStorageTableModel::headerData(int section, Qt::Orientation orientation, - int role) const -{ - QVariant headerData; - - // show only horizontal header - if ( role == Qt::DisplayRole ) - { - if( orientation == Qt::Horizontal ) - { - // first column: "Name" - if(section == 0) - headerData = "Name"; - else if(section == 1) - headerData = "Data Type"; - else if(section == 2) - headerData = "Visibility"; - } - else if( orientation == Qt::Vertical ) - { - // show numbers for rows - headerData = section+1; - } - } - - return headerData; -} - -Qt::ItemFlags QmitkDataStorageTableModel::flags(const QModelIndex &index) const -{ - Qt::ItemFlags flags = QAbstractItemModel::flags(index); - - // name & visibility is editable - if (index.column() == 0) - { - flags |= Qt::ItemIsEditable; - } - else if (index.column() == 2) - { - flags |= Qt::ItemIsUserCheckable; - } - - return flags; -} - -int QmitkDataStorageTableModel::rowCount(const QModelIndex &) const -{ - return m_NodeSet.size(); -} - -int QmitkDataStorageTableModel::columnCount(const QModelIndex &) const -{ - // show name, type and visible columnn - int columns = 3; - return columns; -} - -QVariant QmitkDataStorageTableModel::data(const QModelIndex &index, int role) const -{ - QVariant data; - - if (index.isValid() && !m_NodeSet.empty()) - { - mitk::DataNode::Pointer node = m_NodeSet.at(index.row()); - - std::string nodeName = node->GetName(); - if(nodeName.empty()) - nodeName = "unnamed"; - - // get name - if(index.column() == 0) - { - // get name of node (may also be edited) - if (role == Qt::DisplayRole || role == Qt::EditRole) - { - data = nodeName.c_str(); - } - else if (role == QmitkDataNodeRole) - { - data = QVariant::fromValue(node); - } - } - else if (index.column() == 1) - { - - QmitkNodeDescriptor* nodeDescriptor - = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(node); - - // get type property of mitk::BaseData - if (role == Qt::DisplayRole) - { - - data = nodeDescriptor->GetClassName(); - } - // show some nice icons for datatype - else if(role == Qt::DecorationRole) - { - data = nodeDescriptor->GetIcon(); - } - } - else if (index.column() == 2) - { - // get visible property of mitk::BaseData - bool visibility = false; - - if(node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole) - { - data = (visibility ? Qt::Checked : Qt::Unchecked); - } // node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole - - } // index.column() == 2 - - } // index.isValid() && !m_NodeSet.empty() - return data; -} - -//# Public SETTERS -void QmitkDataStorageTableModel::SetPredicate( mitk::NodePredicateBase* _Predicate ) -{ - // ensure that a new predicate is set in order to avoid unnecessary changed events - if(m_Predicate != _Predicate) - { - m_Predicate = _Predicate; - this->Reset(); - } -} - -void QmitkDataStorageTableModel::SetDataStorage( mitk::DataStorage::Pointer _DataStorage ) -{ - // only proceed if we have a new datastorage - if(m_DataStorage.GetPointer() != _DataStorage.GetPointer()) - { - // if a data storage was set before remove old event listeners - if(m_DataStorage != 0) - { - this->m_DataStorage->AddNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::AddNode ) ); - - this->m_DataStorage->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::RemoveNode ) ); - } - - // set new data storage - m_DataStorage = _DataStorage.GetPointer(); - - // if new storage is not 0 subscribe for events - if(m_DataStorage != 0) - { - // subscribe for node added/removed events - this->m_DataStorage->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::AddNode ) ); - - this->m_DataStorage->RemoveNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::RemoveNode ) ); - } - - // Reset model (even if datastorage is 0->will be checked in Reset()) - this->Reset(); - } -} - - -void QmitkDataStorageTableModel::AddNode( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown - if(!m_BlockEvents) - { - // if we have a predicate, check node against predicate first - if(m_Predicate.IsNotNull() && !m_Predicate->CheckNode(node)) - return; - - // dont add nodes without data (formerly known as helper objects) - if(node->GetData() == 0) - return; - - // create listener commands to listen to changes in the name or the visibility of the node - itk::MemberCommand::Pointer propertyModifiedCommand - = itk::MemberCommand::New(); - propertyModifiedCommand->SetCallbackFunction(this, &QmitkDataStorageTableModel::PropertyModified); - - mitk::BaseProperty* tempProperty = 0; - - // add listener for properties - tempProperty = node->GetProperty("visible"); - if(tempProperty) - m_VisiblePropertyModifiedObserverTags[tempProperty] - = tempProperty->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); - - tempProperty = node->GetProperty("name"); - if(tempProperty) - m_NamePropertyModifiedObserverTags[tempProperty] - = tempProperty->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); - - // emit beginInsertRows event - beginInsertRows(QModelIndex(), m_NodeSet.size(), m_NodeSet.size()); - - // add node - m_NodeSet.push_back(const_cast(node)); - - // emit endInsertRows event - endInsertRows(); - } -} - -void QmitkDataStorageTableModel::RemoveNode( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown - if(!m_BlockEvents) - { - // find corresponding node - std::vector::iterator nodeIt - = std::find(m_NodeSet.begin(), m_NodeSet.end(), node); - - if(nodeIt != m_NodeSet.end()) - { - // now: remove listeners for name property ... - mitk::BaseProperty* tempProperty = 0; - - tempProperty = (*nodeIt)->GetProperty("visible"); - if(tempProperty) - tempProperty->RemoveObserver(m_VisiblePropertyModifiedObserverTags[tempProperty]); - m_VisiblePropertyModifiedObserverTags.erase(tempProperty); - - // ... and visibility property - tempProperty = (*nodeIt)->GetProperty("name"); - if(tempProperty) - tempProperty->RemoveObserver(m_NamePropertyModifiedObserverTags[tempProperty]); - m_NamePropertyModifiedObserverTags.erase(tempProperty); - - // get an index from iterator - int row = std::distance(m_NodeSet.begin(), nodeIt); - - // emit beginRemoveRows event (QModelIndex is empty because we dont have a tree model) - this->beginRemoveRows(QModelIndex(), row, row); - - // remove node - m_NodeSet.erase(nodeIt); - - // emit endRemoveRows event - endRemoveRows(); - } - } -} - -void QmitkDataStorageTableModel::PropertyModified( const itk::Object *caller, const itk::EventObject & ) -{ - if(!m_BlockEvents) - { - // get modified property - const mitk::BaseProperty* modifiedProperty = dynamic_cast(caller); - - if(modifiedProperty) - { - // find node that holds the modified property - int row = -1; - int column = -1; - - std::vector::iterator it; - mitk::BaseProperty* visibilityProperty = 0; - mitk::BaseProperty* nameProperty = 0; - - // search for property that changed and emit datachanged on the corresponding ModelIndex - for(it=m_NodeSet.begin(); it!=m_NodeSet.end(); it++) - { - // check for the visible property or the name property - visibilityProperty = (*it)->GetProperty("visible"); - if(modifiedProperty == visibilityProperty) - { - column = 2; - break; - } - - nameProperty = (*it)->GetProperty("name"); - if(modifiedProperty == nameProperty) - { - column = 0; - break; - } - } - - // if we have the property we have a valid iterator - if( it != m_NodeSet.end() ) - row = std::distance(m_NodeSet.begin(), it); - - // now emit the dataChanged signal - QModelIndex indexOfChangedProperty = index(row, column); - emit dataChanged(indexOfChangedProperty, indexOfChangedProperty); - } - } -} - -bool QmitkDataStorageTableModel::setData(const QModelIndex &index, const QVariant &value, - int role) -{ - bool noErr = false; - - if (index.isValid() && (role == Qt::EditRole || role == Qt::CheckStateRole)) - { - // any change events produced here should not be caught in this class - // --> set m_BlockEvents to true - m_BlockEvents = true; - - mitk::DataNode::Pointer node = m_NodeSet.at(index.row()); - - if(index.column() == 0) - { - node->SetStringProperty("name", value.toString().toStdString().c_str()); - } - else if(index.column() == 2) - { - node->SetBoolProperty("visible", (value.toInt() == Qt::Checked ? true : false)); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - - // inform listeners about changes - emit dataChanged(index, index); - - m_BlockEvents = false; - noErr = true; - } - - return noErr; -} - -//#Protected SETTER -void QmitkDataStorageTableModel::Reset() -{ - mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet; - - // remove all nodes now (dont use iterators because removing elements - // would invalidate the iterator) - // start at the last element: first in, last out - unsigned int i = m_NodeSet.size(); - while(!m_NodeSet.empty()) - { - --i; - this->RemoveNode(m_NodeSet.at(i)); - } - - // normally now everything should be empty->just to be sure - // erase all arrays again - m_NamePropertyModifiedObserverTags.clear(); - m_VisiblePropertyModifiedObserverTags.clear(); - m_NodeSet.clear(); - - // the whole reset depends on the fact if a data storage is set or not - if(m_DataStorage.IsNotNull()) - { - if(m_Predicate.IsNotNull()) - // get subset - _NodeSet = m_DataStorage->GetSubset(m_Predicate); - // if predicate is NULL, select all nodes - else - { - _NodeSet = m_DataStorage->GetAll(); - // remove ghost root node - } - - // finally add all nodes to the model - for(mitk::DataStorage::SetOfObjects::const_iterator it=_NodeSet->begin(); it!=_NodeSet->end() - ; it++) - { - // save node - this->AddNode(*it); - } - - } -} - -void QmitkDataStorageTableModel::sort( int column, Qt::SortOrder order /*= Qt::AscendingOrder */ ) -{ - bool sortDescending = (order == Qt::DescendingOrder) ? true: false; - - // do not sort twice !!! (dont know why, but qt calls this func twice. STUPID!) -/* - if(sortDescending != m_SortDescending) - {*/ - - //m_SortDescending = sortDescending; - - DataNodeCompareFunction::CompareCriteria _CompareCriteria - = DataNodeCompareFunction::CompareByName; - - DataNodeCompareFunction::CompareOperator _CompareOperator - = sortDescending ? DataNodeCompareFunction::Greater: DataNodeCompareFunction::Less; - - if(column == 1) - _CompareCriteria = DataNodeCompareFunction::CompareByClassName; - - else if(column == 2) - _CompareCriteria = DataNodeCompareFunction::CompareByVisibility; - - - DataNodeCompareFunction compareFunc(_CompareCriteria, _CompareOperator); - std::sort(m_NodeSet.begin(), m_NodeSet.end(), compareFunc); - - QAbstractTableModel::reset(); - //} -} - -std::vector QmitkDataStorageTableModel::GetNodeSet() const -{ - return m_NodeSet; -} - -QmitkDataStorageTableModel::DataNodeCompareFunction::DataNodeCompareFunction( CompareCriteria _CompareCriteria - , CompareOperator _CompareOperator ) - : m_CompareCriteria(_CompareCriteria) - , m_CompareOperator(_CompareOperator) -{ -} - -bool QmitkDataStorageTableModel::DataNodeCompareFunction::operator() -( const mitk::DataNode::Pointer& _Left - , const mitk::DataNode::Pointer& _Right ) const -{ - switch(m_CompareCriteria) - { - case CompareByClassName: - if(m_CompareOperator == Less) - return (_Left->GetData()->GetNameOfClass() < _Right->GetData()->GetNameOfClass() ); - else - return (_Left->GetData()->GetNameOfClass() > _Right->GetData()->GetNameOfClass() ); - break; - - case CompareByVisibility: - { - - bool _LeftVisibility = false; - bool _RightVisibility = false; - _Left->GetVisibility(_LeftVisibility, 0); - _Right->GetVisibility(_RightVisibility, 0); - - if(m_CompareOperator == Less) - return (_LeftVisibility < _RightVisibility); - else - return (_LeftVisibility > _RightVisibility); - } - break; - - // CompareByName: - default: - if(m_CompareOperator == Less) - return (_Left->GetName() < _Right->GetName()); - else - return (_Left->GetName() > _Right->GetName()); - break; - } -} - diff --git a/CoreUI/Qmitk/QmitkDataStorageTreeModel.cpp b/CoreUI/Qmitk/QmitkDataStorageTreeModel.cpp deleted file mode 100644 index f376f19ffd..0000000000 --- a/CoreUI/Qmitk/QmitkDataStorageTreeModel.cpp +++ /dev/null @@ -1,862 +0,0 @@ -/*========================================================================= - - Program: MITK - Language: C++ - Date: $Date: 2008-08-13 16:56:36 +0200 (Mi, 13 Aug 2008) $ - Version: $Revision: 14972 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "QmitkDataStorageTreeModel.h" -#include "QmitkNodeDescriptorManager.h" -#include -#include - -#include -#include -#include - -#include - -QmitkDataStorageTreeModel::QmitkDataStorageTreeModel( mitk::DataStorage* _DataStorage - , bool _PlaceNewNodesOnTop - , bool _ShowHelperObjects - , bool _ShowNodesContainingNoData - , QObject* parent ) -: QAbstractItemModel(parent) -, m_DataStorage(0) -, m_PlaceNewNodesOnTop(_PlaceNewNodesOnTop) -, m_ShowHelperObjects(_ShowHelperObjects) -, m_ShowNodesContainingNoData(_ShowNodesContainingNoData) -, m_Root(0) -{ - this->UpdateNodeVisibility(); - this->SetDataStorage(_DataStorage); -} - -QmitkDataStorageTreeModel::~QmitkDataStorageTreeModel() -{ - // set data storage to 0 = remove all listeners - this->SetDataStorage(0); - m_Root->Delete(); m_Root = 0; - - //Removing all observers - for ( NodeTagMapType::iterator dataIter = m_HelperObjectObserverTags.begin(); dataIter != m_HelperObjectObserverTags.end(); ++dataIter ) - { - (*dataIter).first->GetProperty("helper object")->RemoveObserver( (*dataIter).second ); - } - m_HelperObjectObserverTags.clear(); -} - -mitk::DataNode::Pointer QmitkDataStorageTreeModel::GetNode( const QModelIndex &index ) const -{ - return this->TreeItemFromIndex(index)->GetDataNode(); -} - -const mitk::DataStorage::Pointer QmitkDataStorageTreeModel::GetDataStorage() const -{ - return m_DataStorage.GetPointer(); -} - -QModelIndex QmitkDataStorageTreeModel::index( int row, int column, const QModelIndex & parent ) const -{ - TreeItem* parentItem; - - if (!parent.isValid()) - parentItem = m_Root; - else - parentItem = static_cast(parent.internalPointer()); - - TreeItem *childItem = parentItem->GetChild(row); - if (childItem) - return createIndex(row, column, childItem); - else - return QModelIndex(); - - -} - -int QmitkDataStorageTreeModel::rowCount(const QModelIndex &parent) const -{ - TreeItem *parentTreeItem = this->TreeItemFromIndex(parent); - return parentTreeItem->GetChildCount(); -} - - -Qt::ItemFlags QmitkDataStorageTreeModel::flags( const QModelIndex& index ) const -{ - if (index.isValid()) - return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable - | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; - else - return Qt::ItemIsDropEnabled; -} - -int QmitkDataStorageTreeModel::columnCount( const QModelIndex& /* parent = QModelIndex() */ ) const -{ - return 1; -} - -QModelIndex QmitkDataStorageTreeModel::parent(const QModelIndex &index) const -{ - if (!index.isValid()) - return QModelIndex(); - - TreeItem *childItem = this->TreeItemFromIndex(index); - TreeItem *parentItem = childItem->GetParent(); - - if (parentItem == m_Root) - return QModelIndex(); - - return this->createIndex(parentItem->GetIndex(), 0, parentItem); -} - -QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItemFromIndex( const QModelIndex &index ) const -{ - if (index.isValid()) - return static_cast(index.internalPointer()); - else - return m_Root; -} -Qt::DropActions QmitkDataStorageTreeModel::supportedDropActions() const -{ - return Qt::CopyAction | Qt::MoveAction; -} - -Qt::DropActions QmitkDataStorageTreeModel::supportedDragActions() const -{ - return Qt::CopyAction | Qt::MoveAction; -} - -bool QmitkDataStorageTreeModel::dropMimeData(const QMimeData *data, - Qt::DropAction action, int /*row*/, int /*column*/, const QModelIndex &parent) -{ - // Early exit, returning true, but not actually doing anything (ignoring data). - if (action == Qt::IgnoreAction) - { - return true; - } - - // Note, we are returning true if we handled it, and false otherwise - bool returnValue = false; - - if(data->hasFormat("application/x-qabstractitemmodeldatalist")) - { - returnValue = true; - - // First we extract a Qlist of TreeItem* pointers. - QString arg = QString(data->data("application/x-qabstractitemmodeldatalist").data()); - QStringList listOfTreeItemAddressPointers = arg.split(","); - - QStringList::iterator slIter; - QList listOfItemsToDrop; - - for(slIter = listOfTreeItemAddressPointers.begin(); - slIter != listOfTreeItemAddressPointers.end(); - slIter++) - { - long val = (*slIter).toLong(); - listOfItemsToDrop << static_cast((void*)val); - } - - // Retrieve the TreeItem* where we are dropping stuff, and its parent. - TreeItem* dropItem = this->TreeItemFromIndex(parent); - TreeItem* parentItem = dropItem->GetParent(); - - // If item was dropped onto empty space, we select the root node - if(dropItem == m_Root) - { - parentItem = m_Root; - } - - // Dragging and Dropping is only allowed within the same parent, so use the first item in list to validate. - // (otherwise, you could have a derived image such as a segmentation, and assign it to another image). - // NOTE: We are assuming the input list is valid... i.e. when it was dragged, all the items had the same parent. - - if(listOfItemsToDrop[0] != dropItem && listOfItemsToDrop[0]->GetParent() == parentItem) - { - // Retrieve the index of where we are dropping stuff. - QModelIndex dropItemModelIndex = this->IndexFromTreeItem(dropItem); - QModelIndex parentModelIndex = this->IndexFromTreeItem(parentItem); - - // Iterate through the list of TreeItem (which may be at non-consecutive indexes). - QList::iterator diIter; - for (diIter = listOfItemsToDrop.begin(); - diIter != listOfItemsToDrop.end(); - diIter++) - { - // Here we assume that as you remove items, one at a time, that GetIndex() will be valid. - this->beginRemoveRows(parentModelIndex, (*diIter)->GetIndex(), (*diIter)->GetIndex()); - parentItem->RemoveChild(*diIter); - this->endRemoveRows(); - } - - // Select the target index position, or put it at the end of the list. - int dropIndex = dropItemModelIndex.row(); - if (dropIndex == -1) - { - dropIndex = parentItem->GetChildCount(); - } - - // Now insert items again at the drop item position - this->beginInsertRows(parentModelIndex, dropIndex, dropIndex + listOfItemsToDrop.size() - 1); - - for (diIter = listOfItemsToDrop.begin(); - diIter != listOfItemsToDrop.end(); - diIter++) - { - parentItem->InsertChild( (*diIter), dropIndex ); - dropIndex++; - } - this->endInsertRows(); - - // Change Layers to match. - this->AdjustLayerProperty(); - } - } - else if(data->hasFormat("application/x-mitk-datanodes")) - { - returnValue = true; - - QString arg = QString(data->data("application/x-mitk-datanodes").data()); - QStringList listOfDataNodeAddressPointers = arg.split(","); - int numberOfNodesDropped = 0; - - QStringList::iterator slIter; - for (slIter = listOfDataNodeAddressPointers.begin(); - slIter != listOfDataNodeAddressPointers.end(); - slIter++) - { - long val = (*slIter).toLong(); - mitk::DataNode* node = static_cast((void*)val); - - if(node && m_DataStorage.IsNotNull() && !m_DataStorage->Exists(node)) - { - m_DataStorage->Add( node ); - mitk::BaseData::Pointer basedata = node->GetData(); - - if (basedata.IsNotNull()) - { - mitk::RenderingManager::GetInstance()->InitializeViews( - basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - - numberOfNodesDropped++; - } - } - } - // Only do a rendering update, if we actually dropped anything. - if (numberOfNodesDropped > 0) - { - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - } - - return returnValue; -} - -QStringList QmitkDataStorageTreeModel::mimeTypes() const -{ - QStringList types = QAbstractItemModel::mimeTypes(); - types << "application/x-qabstractitemmodeldatalist"; - types << "application/x-mitk-datanodes"; - return types; -} - -QMimeData * QmitkDataStorageTreeModel::mimeData(const QModelIndexList & indexes) const{ - - QMimeData * ret = new QMimeData; - - QString treeItemAddresses(""); - QString dataNodeAddresses(""); - - for (int i = 0; i < indexes.size(); i++) - { - TreeItem* treeItem = static_cast(indexes.at(i).internalPointer()); - long treeItemAddress = reinterpret_cast(treeItem); - long dataNodeAddress = reinterpret_cast(treeItem->GetDataNode().GetPointer()); - QTextStream(&treeItemAddresses) << treeItemAddress; - QTextStream(&dataNodeAddresses) << dataNodeAddress; - - if (i != indexes.size() - 1) - { - QTextStream(&treeItemAddresses) << ","; - QTextStream(&dataNodeAddresses) << ","; - } - } - - ret->setData("application/x-qabstractitemmodeldatalist", QByteArray(treeItemAddresses.toAscii())); - ret->setData("application/x-mitk-datanodes", QByteArray(dataNodeAddresses.toAscii())); - - return ret; -} - -QVariant QmitkDataStorageTreeModel::data( const QModelIndex & index, int role ) const -{ - mitk::DataNode* dataNode = this->TreeItemFromIndex(index)->GetDataNode(); - - // get name of treeItem (may also be edited) - QString nodeName = QString::fromStdString(dataNode->GetName()); - if(nodeName.isEmpty()) - nodeName = "unnamed"; - - if (role == Qt::DisplayRole) - return nodeName; - else if(role == Qt::ToolTipRole) - return nodeName; - else if(role == Qt::DecorationRole) - { - QmitkNodeDescriptor* nodeDescriptor - = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(dataNode); - return nodeDescriptor->GetIcon(); - } - else if(role == Qt::CheckStateRole) - { - return dataNode->IsVisible(0); - } - else if(role == QmitkDataNodeRole) - { - return QVariant::fromValue(mitk::DataNode::Pointer(dataNode)); - } - - return QVariant(); -} - -QVariant QmitkDataStorageTreeModel::headerData(int /*section*/, - Qt::Orientation orientation, - int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole && m_Root) - return QString::fromStdString(m_Root->GetDataNode()->GetName()); - - return QVariant(); -} - -void QmitkDataStorageTreeModel::SetDataStorage( mitk::DataStorage* _DataStorage ) -{ - if(m_DataStorage != _DataStorage) // dont take the same again - { - if(m_DataStorage.IsNotNull()) - { - // remove Listener for the data storage itself - m_DataStorage.ObjectDelete.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetDataStorageDeleted ) ); - - // remove listeners for the nodes - m_DataStorage->AddNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::AddNode ) ); - - m_DataStorage->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetNodeModified ) ); - - m_DataStorage->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::RemoveNode ) ); - - } - - // take over the new data storage - m_DataStorage = _DataStorage; - - // delete the old root (if necessary, create new) - if(m_Root) - m_Root->Delete(); - mitk::DataNode::Pointer rootDataNode = mitk::DataNode::New(); - rootDataNode->SetName("Data Manager"); - m_Root = new TreeItem(rootDataNode, 0); - this->reset(); - - if(m_DataStorage.IsNotNull()) - { - // add Listener for the data storage itself - m_DataStorage.ObjectDelete.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetDataStorageDeleted ) ); - - // add listeners for the nodes - m_DataStorage->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::AddNode ) ); - - m_DataStorage->ChangedNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetNodeModified ) ); - - m_DataStorage->RemoveNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::RemoveNode ) ); - - mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = m_DataStorage->GetSubset(m_Predicate); - - // finally add all nodes to the model - this->Update(); - } - } -} - -void QmitkDataStorageTreeModel::SetDataStorageDeleted( const itk::Object* /*_DataStorage*/ ) -{ - this->SetDataStorage(0); -} - -void QmitkDataStorageTreeModel::AddNodeInternal(const mitk::DataNode *node) -{ - if(node == 0 - || m_DataStorage.IsNull() - || !m_DataStorage->Exists(node) - || !m_Predicate->CheckNode(node) - || m_Root->Find(node) != 0) - return; - - // find out if we have a root node - TreeItem* parentTreeItem = m_Root; - QModelIndex index; - mitk::DataNode* parentDataNode = this->GetParentNode(node); - - if(parentDataNode) // no top level data node - { - parentTreeItem = m_Root->Find(parentDataNode); // find the corresponding tree item - if(!parentTreeItem) - { - this->AddNode(parentDataNode); - parentTreeItem = m_Root->Find(parentDataNode); - if(!parentTreeItem) - return; - } - - // get the index of this parent with the help of the grand parent - index = this->createIndex(parentTreeItem->GetIndex(), 0, parentTreeItem); - } - - // add node - if(m_PlaceNewNodesOnTop) - { - // emit beginInsertRows event - beginInsertRows(index, 0, 0); - parentTreeItem->InsertChild(new TreeItem( - const_cast(node)), 0); - } - else - { - beginInsertRows(index, parentTreeItem->GetChildCount() - , parentTreeItem->GetChildCount()); - new TreeItem(const_cast(node), parentTreeItem); - } - - // emit endInsertRows event - endInsertRows(); - - this->AdjustLayerProperty(); -} - -void QmitkDataStorageTreeModel::AddNode( const mitk::DataNode* node ) -{ - if(node == 0 - || m_DataStorage.IsNull() - || !m_DataStorage->Exists(node) - || !m_Predicate->CheckNode(node) - || m_Root->Find(node) != 0) - return; - - bool isHelperObject (false); - NodeTagMapType::iterator searchIter = m_HelperObjectObserverTags.find( const_cast(node) ); - if (node->GetBoolProperty("helper object", isHelperObject) && searchIter == m_HelperObjectObserverTags.end()) { - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); - command->SetCallbackFunction(this, &QmitkDataStorageTreeModel::UpdateNodeVisibility); - m_HelperObjectObserverTags.insert( std::pair( const_cast(node), node->GetProperty("helper object")->AddObserver( itk::ModifiedEvent(), command ) ) ); - } - - this->AddNodeInternal(node); -} - - -void QmitkDataStorageTreeModel::SetPlaceNewNodesOnTop(bool _PlaceNewNodesOnTop) -{ - m_PlaceNewNodesOnTop = _PlaceNewNodesOnTop; -} - -void QmitkDataStorageTreeModel::RemoveNodeInternal( const mitk::DataNode* node ) -{ - if(!m_Root) return; - - TreeItem* treeItem = m_Root->Find(node); - if(!treeItem) - return; // return because there is no treeitem containing this node - - TreeItem* parentTreeItem = treeItem->GetParent(); - QModelIndex parentIndex = this->IndexFromTreeItem(parentTreeItem); - - // emit beginRemoveRows event (QModelIndex is empty because we dont have a tree model) - this->beginRemoveRows(parentIndex, treeItem->GetIndex(), treeItem->GetIndex()); - - // remove node - std::vector children = treeItem->GetChildren(); - delete treeItem; - - // emit endRemoveRows event - endRemoveRows(); - - // move all children of deleted node into its parent - for ( std::vector::iterator it = children.begin() - ; it != children.end(); it++) - { - // emit beginInsertRows event - beginInsertRows(parentIndex, parentTreeItem->GetChildCount(), parentTreeItem->GetChildCount()); - - // add nodes again - parentTreeItem->AddChild(*it); - - // emit endInsertRows event - endInsertRows(); - } - - this->AdjustLayerProperty(); -} - -void QmitkDataStorageTreeModel::RemoveNode( const mitk::DataNode* node ) -{ - if (node == 0) - return; - - //Removing Observer - bool isHelperObject (false); - NodeTagMapType::iterator searchIter = m_HelperObjectObserverTags.find( const_cast(node) ); - if (node->GetBoolProperty("helper object", isHelperObject) && searchIter != m_HelperObjectObserverTags.end()) { - (*searchIter).first->GetProperty("helper object")->RemoveObserver( (*searchIter).second ); - m_HelperObjectObserverTags.erase(const_cast(node)); - } - - this->RemoveNodeInternal(node); -} - -void QmitkDataStorageTreeModel::SetNodeModified( const mitk::DataNode* node ) -{ - TreeItem* treeItem = m_Root->Find(node); - if(!treeItem) - return; - - TreeItem* parentTreeItem = treeItem->GetParent(); - // as the root node should not be removed one should always have a parent item - if(!parentTreeItem) - return; - QModelIndex index = this->createIndex(treeItem->GetIndex(), 0, treeItem); - - // now emit the dataChanged signal - emit dataChanged(index, index); -} - -mitk::DataNode* QmitkDataStorageTreeModel::GetParentNode( const mitk::DataNode* node ) const -{ - mitk::DataNode* dataNode = 0; - - mitk::DataStorage::SetOfObjects::ConstPointer _Sources = m_DataStorage->GetSources(node); - - if(_Sources->Size() > 0) - dataNode = _Sources->front(); - - return dataNode; -} - -bool QmitkDataStorageTreeModel::setData( const QModelIndex &index, const QVariant &value, int role ) -{ - mitk::DataNode* dataNode = this->TreeItemFromIndex(index)->GetDataNode(); - if(!dataNode) - return false; - - if(role == Qt::EditRole && !value.toString().isEmpty()) - { - dataNode->SetStringProperty("name", value.toString().toStdString().c_str()); - } - else if(role == Qt::CheckStateRole) - { - // Please note: value.toInt() returns 2, independentely from the actual checkstate of the index element. - // Therefore the checkstate is being estimated again here. - - QVariant qcheckstate = index.data(Qt::CheckStateRole); - int checkstate = qcheckstate.toInt(); - bool isVisible = bool(checkstate); - dataNode->SetVisibility(!isVisible); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - // inform listeners about changes - emit dataChanged(index, index); - return true; -} - -bool QmitkDataStorageTreeModel::setHeaderData( int /*section*/, Qt::Orientation /*orientation*/, const QVariant& /* value */, int /*role = Qt::EditRole*/ ) -{ - return false; -} - -void QmitkDataStorageTreeModel::AdjustLayerProperty() -{ - /// transform the tree into an array and set the layer property descending - std::vector vec; - this->TreeToVector(m_Root, vec); - - int i = vec.size()-1; - for(std::vector::const_iterator it = vec.begin(); it != vec.end(); ++it) - { - (*it)->GetDataNode()->SetIntProperty("layer", i); - --i; - } - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkDataStorageTreeModel::TreeToVector(TreeItem* parent, std::vector& vec) const -{ - TreeItem* current; - for(int i = 0; iGetChildCount(); ++i) - { - current = parent->GetChild(i); - this->TreeToVector(current, vec); - vec.push_back(current); - } -} - -QModelIndex QmitkDataStorageTreeModel::IndexFromTreeItem( TreeItem* item ) const -{ - if(item == m_Root) - return QModelIndex(); - else - return this->createIndex(item->GetIndex(), 0, item); -} - -std::vector QmitkDataStorageTreeModel::GetNodeSet() const -{ - std::vector vec; - if(m_Root) - this->TreeToNodeSet(m_Root, vec); - - return vec; -} - -void QmitkDataStorageTreeModel::TreeToNodeSet( TreeItem* parent, std::vector& vec ) const -{ - TreeItem* current; - for(int i = 0; iGetChildCount(); ++i) - { - current = parent->GetChild(i); - vec.push_back(current->GetDataNode()); - this->TreeToNodeSet(current, vec); - } -} - -QModelIndex QmitkDataStorageTreeModel::GetIndex( const mitk::DataNode* node ) const -{ - if(m_Root) - { - TreeItem* item = m_Root->Find(node); - if(item) - return this->IndexFromTreeItem(item); - } - return QModelIndex(); -} - -QmitkDataStorageTreeModel::TreeItem::TreeItem( mitk::DataNode* _DataNode, TreeItem* _Parent ) -: m_Parent(_Parent) -, m_DataNode(_DataNode) -{ - if(m_Parent) - m_Parent->AddChild(this); -} - -QmitkDataStorageTreeModel::TreeItem::~TreeItem() -{ - if(m_Parent) - m_Parent->RemoveChild(this); -} - -void QmitkDataStorageTreeModel::TreeItem::Delete() -{ - while(m_Children.size() > 0) - delete m_Children.back(); - - delete this; -} - -QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::Find( const mitk::DataNode* _DataNode ) const -{ - QmitkDataStorageTreeModel::TreeItem* item = 0; - if(_DataNode) - { - if(m_DataNode == _DataNode) - item = const_cast(this); - else - { - for(std::vector::const_iterator it = m_Children.begin(); it != m_Children.end(); ++it) - { - if(item) - break; - item = (*it)->Find(_DataNode); - } - } - } - return item; -} - -int QmitkDataStorageTreeModel::TreeItem::IndexOfChild( const TreeItem* item ) const -{ - std::vector::const_iterator it = std::find(m_Children.begin(), m_Children.end(), item); - return it != m_Children.end() ? std::distance(m_Children.begin(), it): -1; -} - -QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::GetChild( int index ) const -{ - return (m_Children.size() > 0 && index >= 0 && index < (int)m_Children.size())? m_Children.at(index): 0; -} - -void QmitkDataStorageTreeModel::TreeItem::AddChild( TreeItem* item ) -{ - this->InsertChild(item); -} - -void QmitkDataStorageTreeModel::TreeItem::RemoveChild( TreeItem* item ) -{ - std::vector::iterator it = std::find(m_Children.begin(), m_Children.end(), item); - if(it != m_Children.end()) - { - m_Children.erase(it); - item->SetParent(0); - } -} - -int QmitkDataStorageTreeModel::TreeItem::GetChildCount() const -{ - return m_Children.size(); -} - -int QmitkDataStorageTreeModel::TreeItem::GetIndex() const -{ - if (m_Parent) - return m_Parent->IndexOfChild(this); - - return 0; -} - -QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::GetParent() const -{ - return m_Parent; -} - -mitk::DataNode::Pointer QmitkDataStorageTreeModel::TreeItem::GetDataNode() const -{ - return m_DataNode; -} - -void QmitkDataStorageTreeModel::TreeItem::InsertChild( TreeItem* item, int index ) -{ - std::vector::iterator it = std::find(m_Children.begin(), m_Children.end(), item); - if(it == m_Children.end()) - { - if(m_Children.size() > 0 && index >= 0 && index < (int)m_Children.size()) - { - it = m_Children.begin(); - std::advance(it, index); - m_Children.insert(it, item); - } - else - m_Children.push_back(item); - - // add parent if necessary - if(item->GetParent() != this) - item->SetParent(this); - } -} - -std::vector QmitkDataStorageTreeModel::TreeItem::GetChildren() const -{ - return m_Children; -} - -void QmitkDataStorageTreeModel::TreeItem::SetParent( TreeItem* _Parent ) -{ - m_Parent = _Parent; - if(m_Parent) - m_Parent->AddChild(this); -} - -void QmitkDataStorageTreeModel::SetShowHelperObjects(bool _ShowHelperObjects) -{ - m_ShowHelperObjects = _ShowHelperObjects; - this->UpdateNodeVisibility(); -} - -void QmitkDataStorageTreeModel::SetShowNodesContainingNoData(bool _ShowNodesContainingNoData) -{ - m_ShowNodesContainingNoData = _ShowNodesContainingNoData; - this->UpdateNodeVisibility(); -} - -void QmitkDataStorageTreeModel::UpdateNodeVisibility() -{ - mitk::NodePredicateData::Pointer dataIsNull = mitk::NodePredicateData::New(0); - mitk::NodePredicateNot::Pointer dataIsNotNull = mitk::NodePredicateNot::New(dataIsNull);// Show only nodes that really contain dat - - if (m_ShowHelperObjects) - { - if (m_ShowNodesContainingNoData) - { - // Show every node - m_Predicate = mitk::NodePredicateOr::New(dataIsNull, dataIsNotNull); - } - else - { - // Show helper objects but not nodes containing no data - m_Predicate = dataIsNotNull; - } - } - else - { - mitk::NodePredicateProperty::Pointer isHelperObject = mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true)); - mitk::NodePredicateNot::Pointer isNotHelperObject = mitk::NodePredicateNot::New(isHelperObject);// Show only nodes that are not helper objects - if (m_ShowNodesContainingNoData) - { - // Don't show helper objects but nodes containing no data - m_Predicate = isNotHelperObject; - } - else - { - // Don't show helper objects and nodes containing no data - m_Predicate = mitk::NodePredicateAnd::New(isNotHelperObject, dataIsNotNull); - } - } - this->Update(); -} - -void QmitkDataStorageTreeModel::Update() -{ - if (m_DataStorage.IsNotNull()) - { - this->reset(); - - mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = m_DataStorage->GetSubset(m_Predicate); - - for(mitk::DataStorage::SetOfObjects::const_iterator it=_NodeSet->begin(); it!=_NodeSet->end(); it++) - { - // save node - this->AddNodeInternal(*it); - } - - mitk::DataStorage::SetOfObjects::ConstPointer _NotNodeSet = m_DataStorage->GetSubset(mitk::NodePredicateNot::New(m_Predicate)); - - for(mitk::DataStorage::SetOfObjects::const_iterator it=_NotNodeSet->begin(); it!=_NotNodeSet->end(); it++) - { - // remove node - this->RemoveNodeInternal(*it); - } - - } -} - diff --git a/CoreUI/Qmitk/QmitkDataStorageTreeModel.h b/CoreUI/Qmitk/QmitkDataStorageTreeModel.h deleted file mode 100644 index 0f5cdac06d..0000000000 --- a/CoreUI/Qmitk/QmitkDataStorageTreeModel.h +++ /dev/null @@ -1,289 +0,0 @@ -/*========================================================================= - - Program: MITK - Language: C++ - Date: $Date: 2008-08-13 16:56:36 +0200 (Mi, 13 Aug 2008) $ - Version: $Revision: 14972 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKDATASTORAGETREEMODEL_H_ -#define QMITKDATASTORAGETREEMODEL_H_ - -#include - -#include -#include -#include - -#include - -#include "QmitkEnums.h" -#include "QmitkCustomVariants.h" - -#include -#include -#include - -class QMITK_EXPORT QmitkDataStorageTreeModel : public QAbstractItemModel -{ -//# CONSTANTS,TYPEDEFS -public: - static const std::string COLUMN_NAME; - static const std::string COLUMN_TYPE; - static const std::string COLUMN_VISIBILITY; - -//# CTORS,DTOR -public: - QmitkDataStorageTreeModel(mitk::DataStorage* _DataStorage - , bool _PlaceNewNodesOnTop=false - , bool _ShowHelperObjects=false - , bool _ShowNodesContainingNoData=false - , QObject* parent = 0); - ~QmitkDataStorageTreeModel(); - -//# GETTER -public: - - typedef std::map NodeTagMapType; - /// - /// Get node at a specific model index. - /// This function is used to get a node from a QModelIndex - /// - mitk::DataNode::Pointer GetNode(const QModelIndex &index) const; - /// - /// Returns a copy of the node-vector that is shown by this model - /// - virtual std::vector GetNodeSet() const; - /// - /// Get the DataStorage. - /// - const mitk::DataStorage::Pointer GetDataStorage() const; - - /// - /// Get the top placement flag - /// - bool GetPlaceNewNodesOnTopFlag() - { - return m_PlaceNewNodesOnTop; - } - - /// - /// Get the helper object visibility flag - /// - bool GetShowHelperObjectsFlag() - { - return m_ShowHelperObjects; - } - - /// - /// Get the visibility flag for showing nodes that contain no data - /// - bool GetShowNodesContainingNoDataFlag() - { - return m_ShowNodesContainingNoData; - } - - /// - /// Set the top placement flag - /// - void SetPlaceNewNodesOnTop(bool _PlaceNewNodesOnTop); - - //# (Re-)implemented from QAbstractItemModel - //# Read model - Qt::ItemFlags flags(const QModelIndex& index) const; - QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - int rowCount ( const QModelIndex & parent = QModelIndex() ) const; - int columnCount ( const QModelIndex & parent = QModelIndex() ) const; - //# hierarchical model - /// - /// called whenever the model or the view needs to create a QModelIndex for a particular - /// child item (or a top-level item if parent is an invalid QModelIndex) - /// - QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; - QModelIndex parent ( const QModelIndex & index ) const; - //# editable model - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); - bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - Qt::DropActions supportedDropActions() const; - Qt::DropActions supportedDragActions() const; - QStringList mimeTypes() const; - QMimeData * mimeData(const QModelIndexList & indexes) const; - - //# End of QAbstractItemModel - -//# SETTER -public: - /// - /// Sets the DataStorage. The whole model will be resetted. - /// - void SetDataStorage(mitk::DataStorage* _DataStorage); - /// - /// Notify that the DataStorage was deleted. The whole model will be resetted. - /// - void SetDataStorageDeleted(const itk::Object* _DataStorage); - /// - /// Adds a node to this model. - /// If a predicate is set (not null) the node will be checked against it.The node has to have a data object (no one wants to see empty nodes). - /// - virtual void AddNode(const mitk::DataNode* node); - /// - /// Removes a node from this model. Also removes any event listener from the node. - /// - virtual void RemoveNode(const mitk::DataNode* node); - /// - /// Sets a node to modfified. Called by the DataStorage - /// - virtual void SetNodeModified(const mitk::DataNode* node); - - /// - /// \return an index for the given datatreenode in the tree. If the node is not found - /// - QModelIndex GetIndex(const mitk::DataNode*) const; - - /// - /// Show or hide helper objects - /// - void SetShowHelperObjects(bool _ShowHelperObjects); - - /// - /// Show or hide objects that contain no data - /// - void SetShowNodesContainingNoData(bool _ShowNodesContainingNoData); - - /// - /// Update the visibility of data nodes according to the preference settings - /// - void UpdateNodeVisibility(); - -//# MISC -protected: - /// - /// Helper class to represent a tree structure of DataNodes - /// - class TreeItem - { - public: - /// - /// Constructs a new TreeItem with the given DataNode (must not be 0) - /// - TreeItem(mitk::DataNode* _DataNode, TreeItem* _Parent=0); - /// - /// Removes itself as child from its parent-> Does not delete its children - /// \sa Delete() - /// - virtual ~TreeItem(); - /// - /// Find the index of an item - /// - int IndexOfChild(const TreeItem* item) const; - /// - /// \child The child at pos index or 0 if it not exists - /// - TreeItem* GetChild(int index) const; - /// - /// Find the TreeItem containing a special tree node (recursive tree function) - /// - TreeItem* Find( const mitk::DataNode* _DataNode) const; - /// - /// Get the amount of children - /// - int GetChildCount() const; - /// - /// \return the index of this node in its parent list - /// - int GetIndex() const; - /// - /// \return the parent of this tree item - /// - TreeItem* GetParent() const; - /// - /// Return the DataNode associated with this node - /// - mitk::DataNode::Pointer GetDataNode() const; - /// - /// Get all children as vector - /// - std::vector GetChildren() const; - - /// - /// add another item as a child of this (only if not already in that list) - /// - void AddChild( TreeItem* item); - /// - /// remove another item as child from this - /// - void RemoveChild( TreeItem* item); - /// - /// inserts a child at the given position. if pos is not in range - /// the element is added at the end - /// - void InsertChild( TreeItem* item, int index=-1 ); - /// Sets the parent on the treeitem - void SetParent(TreeItem* _Parent); - /// - /// Deletes the whole tree branch - /// - void Delete(); - protected: - TreeItem* m_Parent; - std::vector m_Children; - mitk::DataNode::Pointer m_DataNode; - }; - /// - /// Adjusts the LayerProperty according to the nodes position - /// - void AdjustLayerProperty(); - /// - /// invoked after m_DataStorage or m_Predicate changed - /// - TreeItem* TreeItemFromIndex(const QModelIndex &index) const; - /// - /// Gives a ModelIndex for the Tree Item - /// - QModelIndex IndexFromTreeItem(TreeItem*) const; - /// - /// Returns the first element in the nodes sources list (if available) or 0 - /// - mitk::DataNode* GetParentNode(const mitk::DataNode* node) const; - /// - /// Adds all Childs in parent to vec. Before a child is added the function is called recursively - /// - void TreeToVector(TreeItem* parent, std::vector& vec) const; - /// - /// Adds all Childs in parent to vec. Before a child is added the function is called recursively - /// - void TreeToNodeSet(TreeItem* parent, std::vector& vec) const; - /// - /// Update Tree Model according to predicates - /// - void Update(); - - //# ATTRIBUTES -protected: - mitk::WeakPointer m_DataStorage; - mitk::NodePredicateBase::Pointer m_Predicate; - bool m_PlaceNewNodesOnTop; - bool m_ShowHelperObjects; - bool m_ShowNodesContainingNoData; - TreeItem* m_Root; - - NodeTagMapType m_HelperObjectObserverTags; - -private: - void AddNodeInternal(const mitk::DataNode*); - void RemoveNodeInternal(const mitk::DataNode*); -}; - -#endif /* QMITKDATASTORAGETREEMODEL_H_ */ diff --git a/CoreUI/Qmitk/QmitkEnums.h b/CoreUI/Qmitk/QmitkEnums.h deleted file mode 100755 index 892ea88158..0000000000 --- a/CoreUI/Qmitk/QmitkEnums.h +++ /dev/null @@ -1,27 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKENUMS_H_ -#define QMITKENUMS_H_ - -enum QmitkItemModelRole -{ - QmitkDataNodeRole = 64 -}; - -#endif /* QMITKENUMS_H_ */ diff --git a/CoreUI/Qmitk/QmitkNodeDescriptorManager.cpp b/CoreUI/Qmitk/QmitkNodeDescriptorManager.cpp deleted file mode 100644 index 6977c34f79..0000000000 --- a/CoreUI/Qmitk/QmitkNodeDescriptorManager.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkNodeDescriptorManager.h" -#include -#include -#include -#include -#include -#include -#include - - -QmitkNodeDescriptorManager* QmitkNodeDescriptorManager::GetInstance() -{ - static QmitkNodeDescriptorManager _Instance; - return &_Instance; -/* - static std::auto_ptr instance; - if(instance.get() == 0) - { - instance.reset(new QmitkNodeDescriptorManager()); - instance->Initialize(); - } - return instance.get();*/ - -} - -void QmitkNodeDescriptorManager::Initialize() -{ - // Adding "Images" - mitk::NodePredicateDataType::Pointer isImage = mitk::NodePredicateDataType::New("Image"); - this->AddDescriptor(new QmitkNodeDescriptor(tr("Image"), QString(":/Qmitk/Images_48.png"), isImage, this)); - - // Adding "Image Masks" - mitk::NodePredicateProperty::Pointer isBinary = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)); - mitk::NodePredicateAnd::Pointer isBinaryImage = mitk::NodePredicateAnd::New(isBinary, isImage); - this->AddDescriptor(new QmitkNodeDescriptor(tr("ImageMask"), QString(":/Qmitk/Binaerbilder_48.png"), isBinaryImage, this)); - - // Adding "PointSet" - mitk::NodePredicateDataType::Pointer isPointSet = mitk::NodePredicateDataType::New("PointSet"); - this->AddDescriptor(new QmitkNodeDescriptor(tr("PointSet"), QString(":/Qmitk/PointSet_48.png"), isPointSet, this)); - - // Adding "Surface" - mitk::NodePredicateDataType::Pointer isSurface = mitk::NodePredicateDataType::New("Surface"); - this->AddDescriptor(new QmitkNodeDescriptor(tr("Surface"), QString(":/Qmitk/Surface_48.png"), isSurface, this)); - - // Adding "NoneBinaryImages" - mitk::NodePredicateNot::Pointer isNotBinary = mitk::NodePredicateNot::New(isBinary); - mitk::NodePredicateAnd::Pointer isNoneBinaryImage = mitk::NodePredicateAnd::New(isImage, isNotBinary); - this->AddDescriptor(new QmitkNodeDescriptor(tr("NoneBinaryImage"), QString(":/Qmitk/Images_48.png"), isNoneBinaryImage, this)); - -} - -void QmitkNodeDescriptorManager::AddDescriptor( QmitkNodeDescriptor* _Descriptor ) -{ - _Descriptor->setParent(this); - m_NodeDescriptors.push_back(_Descriptor); -} - -void QmitkNodeDescriptorManager::RemoveDescriptor( QmitkNodeDescriptor* _Descriptor ) -{ - int index = m_NodeDescriptors.indexOf(_Descriptor); - - if(index != -1) - { - m_NodeDescriptors.removeAt(index); - _Descriptor->setParent(0); - delete _Descriptor; - } - -} - -QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetDescriptor( const mitk::DataNode* _Node ) const -{ - QmitkNodeDescriptor* _Descriptor = m_UnknownDataNodeDescriptor; - - for(QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it) - { - if((*it)->CheckNode(_Node)) - _Descriptor = *it; - } - - return _Descriptor; -} - -QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetDescriptor( const QString& _ClassName ) const -{ - QmitkNodeDescriptor* _Descriptor = 0; - - for(QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it) - { - if((*it)->GetClassName() == _ClassName) - _Descriptor = *it; - } - - return _Descriptor; -} -QList QmitkNodeDescriptorManager::GetActions( const mitk::DataNode* _Node ) const -{ - QList actions = m_UnknownDataNodeDescriptor->GetBatchActions(); - actions.append(m_UnknownDataNodeDescriptor->GetActions()); - QmitkNodeDescriptor* lastDescriptor = m_UnknownDataNodeDescriptor; - - for(QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it) - { - if((*it)->CheckNode(_Node)) - { - actions.append(lastDescriptor->GetSeparator()); - lastDescriptor = *it; - actions.append(lastDescriptor->GetBatchActions()); - actions.append(lastDescriptor->GetActions()); - } - } - - return actions; -} - -QList QmitkNodeDescriptorManager::GetActions( const std::vector& _Nodes ) const -{ - QList actions = m_UnknownDataNodeDescriptor->GetBatchActions(); - std::vector nodeDescriptors; - QmitkNodeDescriptor* lastDescriptor; - - // find all descriptors for the nodes (unique) - for( std::vector::const_iterator it = _Nodes.begin() - ; it != _Nodes.end(); ++it) - { - lastDescriptor = this->GetDescriptor(*it); - if(std::find(nodeDescriptors.begin(), nodeDescriptors.end(), lastDescriptor) == nodeDescriptors.end()) - nodeDescriptors.push_back(lastDescriptor); - } - // add all actions for the found descriptors - lastDescriptor = m_UnknownDataNodeDescriptor; - for( std::vector::const_iterator it = nodeDescriptors.begin() - ; it != nodeDescriptors.end(); ++it) - { - actions.append(lastDescriptor->GetSeparator()); - lastDescriptor = *it; - actions.append(lastDescriptor->GetBatchActions()); - } - - return actions; -} - -QmitkNodeDescriptorManager::QmitkNodeDescriptorManager() -: m_UnknownDataNodeDescriptor(new QmitkNodeDescriptor("Unknown", QString(":/Qmitk/DataTypeUnknown_48.png"), 0, this)) -{ - this->Initialize(); -} - -QmitkNodeDescriptorManager::~QmitkNodeDescriptorManager() -{ - //delete m_UnknownDataNodeDescriptor; - //qDeleteAll(m_NodeDescriptors); -} - -QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetUnknownDataNodeDescriptor() const -{ - return m_UnknownDataNodeDescriptor; -} diff --git a/CoreUI/Qmitk/QmitkNodeDescriptorManager.h b/CoreUI/Qmitk/QmitkNodeDescriptorManager.h deleted file mode 100644 index 5506aee32a..0000000000 --- a/CoreUI/Qmitk/QmitkNodeDescriptorManager.h +++ /dev/null @@ -1,117 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkNodeDescriptorManager_h -#define QmitkNodeDescriptorManager_h - -#include - -#include "QmitkNodeDescriptor.h" - -/// -/// \class QmitkNodeDescriptorManager -/// \brief QmitkNodeDescriptorManager manages a set of QmitkNodeDescriptors -/// -/// \sa QmitkNodeDescriptor -/// -class QMITK_EXPORT QmitkNodeDescriptorManager : public QObject -{ - Q_OBJECT -public: - /// - /// \return the solely instance of QmitkNodeDescriptorManager - /// - static QmitkNodeDescriptorManager* GetInstance(); - - /// - /// Initializes the QmitkNodeDescriptorManager. - /// Adds a few standard Descriptors. - /// This Descriptors are added: - /// - A QmitkNodeDescriptor for the class of "Image" DataNodes - /// - A QmitkNodeDescriptor for the class of "Image Mask" DataNodes - /// - A QmitkNodeDescriptor for the class of "Surface" DataNodes - /// - A QmitkNodeDescriptor for the class of "PointSet" DataNodes - /// - virtual void Initialize(); - - /// - /// Adds a new descriptor to the manager. The manager takes the ownership. - /// - void AddDescriptor(QmitkNodeDescriptor* _Descriptor); - - /// - /// Removes and deletes a descriptor from the manager - /// - void RemoveDescriptor(QmitkNodeDescriptor* _Descriptor); - - /// - /// Get the last descriptor in the descriptors list that matches the given node. - /// *Attention*: More specialized Descriptors should therefore be appended at - /// the end of the list, e.g. first add "Image", then add "Image Mask" - /// - /// \return a QmitkNodeDescriptor for the given node or a QmitkNodeDescriptor describing unknown nodes (never 0) - /// \sa AddDescriptor() - /// - QmitkNodeDescriptor* GetDescriptor(const mitk::DataNode* _Node) const; - - /// - /// Get the last QmitkNodeDescriptor for the given class name - /// - /// \return a QmitkNodeDescriptor for the given class name or 0 if there is no QmitkNodeDescriptor for _ClassName - /// - QmitkNodeDescriptor* GetDescriptor(const QString& _ClassName) const; - - /// - /// \return The UnknownDataNodeDescriptor, which is the default Descriptor for all Nodes. - /// - QmitkNodeDescriptor* GetUnknownDataNodeDescriptor() const; - - /// - /// Returns a list of all actions that are associated with the given node. - /// If there are more than one Descriptors for this node all actions - /// will be merged together. - /// E.g. all actions from the "unknown" DataNodes will be added to - /// this list. Generic Actions like Save, Load, etc. are stored there. - /// - QList GetActions(const mitk::DataNode* _Node) const; - /// - /// \return a list of actions associated with the given nodes - /// - QList GetActions( const std::vector& _Nodes ) const; - /// - /// Deletes all Descriptors in the list - /// - virtual ~QmitkNodeDescriptorManager(); -protected: - /// - /// Creates the m_UnknownDataNodeDescriptor - /// Calls Initialize - /// - QmitkNodeDescriptorManager(); -protected: - /// - /// This is the standard QmitkNodeDescriptor matching every node - /// - QmitkNodeDescriptor* m_UnknownDataNodeDescriptor; - /// - /// Holds all user defined descriptors - /// - QList m_NodeDescriptors; - -}; - -#endif // QmitkNodeDescriptorManager_h diff --git a/CoreUI/Qmitk/QmitkRenderWindow.cpp b/CoreUI/Qmitk/QmitkRenderWindow.cpp deleted file mode 100644 index 2ec8dc03ce..0000000000 --- a/CoreUI/Qmitk/QmitkRenderWindow.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#include "QmitkRenderWindow.h" - -#include -#include -#include -#include -#include -#include - -#include "QmitkEventAdapter.h" - -#include "QmitkRenderWindowMenu.h" - -QmitkRenderWindow::QmitkRenderWindow(QWidget *parent, QString name, mitk::VtkPropRenderer* /*renderer*/, mitk::RenderingManager* renderingManager ) -: QVTKWidget(parent) -, m_ResendQtEvents(true) -, m_MenuWidget(NULL) -, m_MenuWidgetActivated(false) -, m_LayoutIndex(0) -{ - Initialize( renderingManager, name.toStdString().c_str() ); // Initialize mitkRenderWindowBase - - setFocusPolicy(Qt::StrongFocus); - setMouseTracking(true); - - } - -QmitkRenderWindow::~QmitkRenderWindow() -{ - Destroy(); // Destroy mitkRenderWindowBase - -} - -void QmitkRenderWindow::SetResendQtEvents(bool resend) -{ - m_ResendQtEvents = resend; -} - -void QmitkRenderWindow::SetLayoutIndex( unsigned int layoutIndex ) -{ - m_LayoutIndex = layoutIndex; - if( m_MenuWidget ) - m_MenuWidget->SetLayoutIndex(layoutIndex); -} - -unsigned int QmitkRenderWindow::GetLayoutIndex() -{ - if( m_MenuWidget ) - return m_MenuWidget->GetLayoutIndex(); - else - return NULL; -} - -void QmitkRenderWindow::LayoutDesignListChanged( int layoutDesignIndex ) -{ - if( m_MenuWidget ) - m_MenuWidget->UpdateLayoutDesignList( layoutDesignIndex ); -} - -void QmitkRenderWindow::mousePressEvent(QMouseEvent *me) -{ - mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); - this->mousePressMitkEvent(&myevent); - - QVTKWidget::mousePressEvent(me); - - if (m_ResendQtEvents) me->ignore(); -} - -void QmitkRenderWindow::mouseReleaseEvent(QMouseEvent *me) -{ - mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); - this->mouseReleaseMitkEvent(&myevent); - - QVTKWidget::mouseReleaseEvent(me); - - if (m_ResendQtEvents) me->ignore(); -} - -void QmitkRenderWindow::mouseMoveEvent(QMouseEvent *me) -{ - this->AdjustRenderWindowMenuVisibility( me->pos() ); - - - mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); - this->mouseMoveMitkEvent(&myevent); - - QVTKWidget::mouseMoveEvent(me); - - //if (m_ResendQtEvents) me->ignore(); - ////Show/Hide Menu Widget - //if( m_MenuWidgetActivated ) - //{ - // //Show Menu Widget when mouse is inside of the define region of the top right corner - // if( m_MenuWidget->GetLayoutIndex() <= QmitkRenderWindowMenu::CORONAL - // && me->pos().x() >= 0 - // && me->pos().y() <= m_MenuWidget->height() + 20 ) - // { - // m_MenuWidget->MoveWidgetToCorrectPos(1.0); - // m_MenuWidget->show(); - // m_MenuWidget->update(); - // } - // else if( m_MenuWidget->GetLayoutIndex() == QmitkRenderWindowMenu::THREE_D - // && me->pos().x() >= this->width() - m_MenuWidget->width() - 20 - // && me->pos().y() <= m_MenuWidget->height() + 20 ) - // { - // m_MenuWidget->MoveWidgetToCorrectPos(1.0); - // m_MenuWidget->show(); - // m_MenuWidget->update(); - // } - // //Hide Menu Widget when mouse is outside of the define region of the the right corner - // else if( !m_MenuWidget->GetSettingsMenuVisibilty() ) - // { - // m_MenuWidget->hide(); - // } - //} -} - -void QmitkRenderWindow::wheelEvent(QWheelEvent *we) -{ - mitk::WheelEvent myevent(QmitkEventAdapter::AdaptWheelEvent(m_Renderer, we)); - this->wheelMitkEvent(&myevent); - - QVTKWidget::wheelEvent(we); - - if (m_ResendQtEvents) - we->ignore(); -} - -void QmitkRenderWindow::keyPressEvent(QKeyEvent *ke) -{ - QPoint cp = mapFromGlobal(QCursor::pos()); - mitk::KeyEvent mke(QmitkEventAdapter::AdaptKeyEvent(m_Renderer, ke, cp)); - this->keyPressMitkEvent(&mke); - ke->accept(); - - QVTKWidget::keyPressEvent(ke); - - if (m_ResendQtEvents) ke->ignore(); -} - -void QmitkRenderWindow::enterEvent( QEvent *e ) -{ -MITK_DEBUG << "rw enter Event"; - - QVTKWidget::enterEvent(e); -} - -void QmitkRenderWindow::DeferredHideMenu( ) -{ - MITK_DEBUG << "QmitkRenderWindow::DeferredHideMenu"; - - if( m_MenuWidget ) - m_MenuWidget->HideMenu(); -} - -void QmitkRenderWindow::leaveEvent( QEvent *e ) -{ - MITK_DEBUG << "QmitkRenderWindow::leaveEvent"; - - if( m_MenuWidget ) - m_MenuWidget->smoothHide(); - - QVTKWidget::leaveEvent(e); -} - -void QmitkRenderWindow::paintEvent(QPaintEvent* /*event*/) -{ - //We are using our own interaction and thus have to call the rendering manually. - mitk::RenderingManager::GetInstance()->RequestUpdate(GetRenderWindow()); -} - -void QmitkRenderWindow::resizeEvent(QResizeEvent* event) -{ - this->resizeMitkEvent(event->size().width(), event->size().height()); - - QVTKWidget::resizeEvent(event); - - emit resized(); -} - - -void QmitkRenderWindow::moveEvent( QMoveEvent* event ) -{ - QVTKWidget::moveEvent( event ); - - // after a move the overlays need to be positioned - emit moved(); -} - - -void QmitkRenderWindow::showEvent( QShowEvent* event ) -{ - QVTKWidget::showEvent( event ); - - // this singleshot is necessary to have the overlays positioned correctly after initial show - // simple call of moved() is no use here!! - QTimer::singleShot(0, this ,SIGNAL( moved() ) ); -} - -void QmitkRenderWindow::ActivateMenuWidget( bool state ) -{ - m_MenuWidgetActivated = state; - - if(!m_MenuWidgetActivated && m_MenuWidget) - { - //disconnect Signal/Slot Connection - disconnect( m_MenuWidget, SIGNAL( SignalChangeLayoutDesign(int) ), this, SLOT(OnChangeLayoutDesign(int)) ); - disconnect( m_MenuWidget, SIGNAL( ResetView() ), this, SIGNAL( ResetView()) ); - disconnect( m_MenuWidget, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SIGNAL( ChangeCrosshairRotationMode(int)) ); - - delete m_MenuWidget; - m_MenuWidget = 0; - } - else if(m_MenuWidgetActivated && !m_MenuWidget ) - { - //create render window MenuBar for split, close Window or set new setting. - m_MenuWidget = new QmitkRenderWindowMenu(this,0,m_Renderer); - m_MenuWidget->SetLayoutIndex( m_LayoutIndex ); - - //create Signal/Slot Connection - connect( m_MenuWidget, SIGNAL( SignalChangeLayoutDesign(int) ), this, SLOT(OnChangeLayoutDesign(int)) ); - connect( m_MenuWidget, SIGNAL( ResetView() ), this, SIGNAL( ResetView()) ); - connect( m_MenuWidget, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SIGNAL( ChangeCrosshairRotationMode(int)) ); - } -} - -void QmitkRenderWindow::AdjustRenderWindowMenuVisibility( const QPoint& /*pos*/ ) -{ - if( m_MenuWidget ) - { - m_MenuWidget->ShowMenu(); - m_MenuWidget->MoveWidgetToCorrectPos(1.0f); - } -} - -void QmitkRenderWindow::HideRenderWindowMenu( ) -{ - // DEPRECATED METHOD -} - - -void QmitkRenderWindow::OnChangeLayoutDesign( int layoutDesignIndex ) -{ - emit SignalLayoutDesignChanged( layoutDesignIndex ); -} - -void QmitkRenderWindow::OnWidgetPlaneModeChanged( int mode ) -{ - if( m_MenuWidget ) - m_MenuWidget->NotifyNewWidgetPlanesMode( mode ); -} - -void QmitkRenderWindow::FullScreenMode(bool state) -{ - if( m_MenuWidget ) - m_MenuWidget->ChangeFullScreenMode( state ); -} diff --git a/CoreUI/Qmitk/QmitkStdMultiWidget.cpp b/CoreUI/Qmitk/QmitkStdMultiWidget.cpp deleted file mode 100644 index 08700c87d8..0000000000 --- a/CoreUI/Qmitk/QmitkStdMultiWidget.cpp +++ /dev/null @@ -1,2147 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#define SMW_INFO MITK_INFO("widget.stdmulti") - -#include "QmitkStdMultiWidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mitkProperties.h" -#include "mitkGeometry2DDataMapper2D.h" -#include "mitkGlobalInteraction.h" -#include "mitkDisplayInteractor.h" -#include "mitkPointSet.h" -#include "mitkPositionEvent.h" -#include "mitkStateEvent.h" -#include "mitkLine.h" -#include "mitkInteractionConst.h" -#include "mitkDataStorage.h" - -#include "mitkNodePredicateBase.h" -#include "mitkNodePredicateDataType.h" - -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" -#include "mitkStatusBar.h" -#include "mitkImage.h" - -#include "mitkVtkLayerController.h" - -QmitkStdMultiWidget::QmitkStdMultiWidget(QWidget* parent, Qt::WindowFlags f) -: QWidget(parent, f), -mitkWidget1(NULL), -mitkWidget2(NULL), -mitkWidget3(NULL), -mitkWidget4(NULL), -m_GradientBackgroundFlag(true), -m_PlaneNode1(NULL), -m_PlaneNode2(NULL), -m_PlaneNode3(NULL), -m_Node(NULL), -m_PendingCrosshairPositionEvent(false) -{ - /*******************************/ - //Create Widget manually - /*******************************/ - - //create Layouts - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - QmitkStdMultiWidgetLayout->setContentsMargins(0,0,0,0); - - //Set Layout to widget - this->setLayout(QmitkStdMultiWidgetLayout); - -// QmitkNavigationToolBar* toolBar = new QmitkNavigationToolBar(); -// QmitkStdMultiWidgetLayout->addWidget( toolBar ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - //creae Widget Container - mitkWidget1Container = new QWidget(m_SubSplit1); - mitkWidget2Container = new QWidget(m_SubSplit1); - mitkWidget3Container = new QWidget(m_SubSplit2); - mitkWidget4Container = new QWidget(m_SubSplit2); - - mitkWidget1Container->setContentsMargins(0,0,0,0); - mitkWidget2Container->setContentsMargins(0,0,0,0); - mitkWidget3Container->setContentsMargins(0,0,0,0); - mitkWidget4Container->setContentsMargins(0,0,0,0); - - //create Widget Layout - QHBoxLayout *mitkWidgetLayout1 = new QHBoxLayout(mitkWidget1Container); - QHBoxLayout *mitkWidgetLayout2 = new QHBoxLayout(mitkWidget2Container); - QHBoxLayout *mitkWidgetLayout3 = new QHBoxLayout(mitkWidget3Container); - QHBoxLayout *mitkWidgetLayout4 = new QHBoxLayout(mitkWidget4Container); - - mitkWidgetLayout1->setMargin(0); - mitkWidgetLayout2->setMargin(0); - mitkWidgetLayout3->setMargin(0); - mitkWidgetLayout4->setMargin(0); - - //set Layout to Widget Container - mitkWidget1Container->setLayout(mitkWidgetLayout1); - mitkWidget2Container->setLayout(mitkWidgetLayout2); - mitkWidget3Container->setLayout(mitkWidgetLayout3); - mitkWidget4Container->setLayout(mitkWidgetLayout4); - - //set SizePolicy - mitkWidget1Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); - mitkWidget2Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); - mitkWidget3Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); - mitkWidget4Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); - - - //insert Widget Container into the splitters - m_SubSplit1->addWidget( mitkWidget1Container ); - m_SubSplit1->addWidget( mitkWidget2Container ); - - m_SubSplit2->addWidget( mitkWidget3Container ); - m_SubSplit2->addWidget( mitkWidget4Container ); - -// mitk::RenderingManager::GetInstance()->SetGlobalInteraction( mitk::GlobalInteraction::GetInstance() ); - - //Create RenderWindows 1 - mitkWidget1 = new QmitkRenderWindow(mitkWidget1Container, "stdmulti.widget1"); - mitkWidget1->setMaximumSize(2000,2000); - mitkWidget1->SetLayoutIndex( TRANSVERSAL ); - mitkWidgetLayout1->addWidget(mitkWidget1); - - //Create RenderWindows 2 - mitkWidget2 = new QmitkRenderWindow(mitkWidget2Container, "stdmulti.widget2"); - mitkWidget2->setMaximumSize(2000,2000); - mitkWidget2->setEnabled( TRUE ); - mitkWidget2->SetLayoutIndex( SAGITTAL ); - mitkWidgetLayout2->addWidget(mitkWidget2); - - //Create RenderWindows 3 - mitkWidget3 = new QmitkRenderWindow(mitkWidget3Container, "stdmulti.widget3"); - mitkWidget3->setMaximumSize(2000,2000); - mitkWidget3->SetLayoutIndex( CORONAL ); - mitkWidgetLayout3->addWidget(mitkWidget3); - - //Create RenderWindows 4 - mitkWidget4 = new QmitkRenderWindow(mitkWidget4Container, "stdmulti.widget4"); - mitkWidget4->setMaximumSize(2000,2000); - mitkWidget4->SetLayoutIndex( THREE_D ); - mitkWidgetLayout4->addWidget(mitkWidget4); - - //create SignalSlot Connection - connect( mitkWidget1, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); - connect( mitkWidget1, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); - connect( mitkWidget1, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); - connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget1, SLOT(OnWidgetPlaneModeChanged(int)) ); - - connect( mitkWidget2, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); - connect( mitkWidget2, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); - connect( mitkWidget2, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); - connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget2, SLOT(OnWidgetPlaneModeChanged(int)) ); - - connect( mitkWidget3, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); - connect( mitkWidget3, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); - connect( mitkWidget3, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); - connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget3, SLOT(OnWidgetPlaneModeChanged(int)) ); - - connect( mitkWidget4, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); - connect( mitkWidget4, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); - connect( mitkWidget4, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); - connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget4, SLOT(OnWidgetPlaneModeChanged(int)) ); - - //Create Level Window Widget - levelWindowWidget = new QmitkLevelWindowWidget( m_MainSplit ); //this - levelWindowWidget->setObjectName(QString::fromUtf8("levelWindowWidget")); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(levelWindowWidget->sizePolicy().hasHeightForWidth()); - levelWindowWidget->setSizePolicy(sizePolicy); - levelWindowWidget->setMaximumSize(QSize(50, 2000)); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //resize Image. - this->resize( QSize(364, 477).expandedTo(minimumSizeHint()) ); - - //Initialize the widgets. - this->InitializeWidget(); - - //Activate Widget Menu - this->ActivateMenuWidget( true ); -} - -void QmitkStdMultiWidget::InitializeWidget() -{ - m_PositionTracker = NULL; - - // transfer colors in WorldGeometry-Nodes of the associated Renderer - QColor qcolor; - //float color[3] = {1.0f,1.0f,1.0f}; - mitk::DataNode::Pointer planeNode; - mitk::IntProperty::Pointer layer; - - // of widget 1 - planeNode = mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); - planeNode->SetColor(1.0,0.0,0.0); - layer = mitk::IntProperty::New(1000); - planeNode->SetProperty("layer",layer); - - // ... of widget 2 - planeNode = mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); - planeNode->SetColor(0.0,1.0,0.0); - layer = mitk::IntProperty::New(1000); - planeNode->SetProperty("layer",layer); - - // ... of widget 3 - planeNode = mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); - planeNode->SetColor(0.0,0.0,1.0); - layer = mitk::IntProperty::New(1000); - planeNode->SetProperty("layer",layer); - - // ... of widget 4 - planeNode = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); - planeNode->SetColor(1.0,1.0,0.0); - layer = mitk::IntProperty::New(1000); - planeNode->SetProperty("layer",layer); - - mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->SetMapperID(mitk::BaseRenderer::Standard3D); - // Set plane mode (slicing/rotation behavior) to slicing (default) - m_PlaneMode = PLANE_MODE_SLICING; - - // Set default view directions for SNCs - mitkWidget1->GetSliceNavigationController()->SetDefaultViewDirection( - mitk::SliceNavigationController::Transversal ); - mitkWidget2->GetSliceNavigationController()->SetDefaultViewDirection( - mitk::SliceNavigationController::Sagittal ); - mitkWidget3->GetSliceNavigationController()->SetDefaultViewDirection( - mitk::SliceNavigationController::Frontal ); - mitkWidget4->GetSliceNavigationController()->SetDefaultViewDirection( - mitk::SliceNavigationController::Original ); - - /*************************************************/ - //Write Layout Names into the viewers -- hardCoded - - //Info for later: - //int view = this->GetRenderWindow1()->GetSliceNavigationController()->GetDefaultViewDirection(); - //QString layoutName; - //if( view == mitk::SliceNavigationController::Transversal ) - // layoutName = "Transversal"; - //else if( view == mitk::SliceNavigationController::Sagittal ) - // layoutName = "Sagittal"; - //else if( view == mitk::SliceNavigationController::Frontal ) - // layoutName = "Coronal"; - //else if( view == mitk::SliceNavigationController::Original ) - // layoutName = "Original"; - //if( view >= 0 && view < 4 ) - // //write LayoutName --> Viewer 3D shoudn't write the layoutName. - - //Render Window 1 == transversal - m_CornerAnnotaions[0].cornerText = vtkCornerAnnotation::New(); - m_CornerAnnotaions[0].cornerText->SetText(0, "Transversal"); - m_CornerAnnotaions[0].cornerText->SetMaximumFontSize(12); - m_CornerAnnotaions[0].textProp = vtkTextProperty::New(); - m_CornerAnnotaions[0].textProp->SetColor( 1.0, 0.0, 0.0 ); - m_CornerAnnotaions[0].cornerText->SetTextProperty( m_CornerAnnotaions[0].textProp ); - m_CornerAnnotaions[0].ren = vtkRenderer::New(); - m_CornerAnnotaions[0].ren->AddActor(m_CornerAnnotaions[0].cornerText); - m_CornerAnnotaions[0].ren->InteractiveOff(); - mitk::VtkLayerController::GetInstance(this->GetRenderWindow1()->GetRenderWindow())->InsertForegroundRenderer(m_CornerAnnotaions[0].ren,true); - - //Render Window 2 == sagittal - m_CornerAnnotaions[1].cornerText = vtkCornerAnnotation::New(); - m_CornerAnnotaions[1].cornerText->SetText(0, "Sagittal"); - m_CornerAnnotaions[1].cornerText->SetMaximumFontSize(12); - m_CornerAnnotaions[1].textProp = vtkTextProperty::New(); - m_CornerAnnotaions[1].textProp->SetColor( 0.0, 1.0, 0.0 ); - m_CornerAnnotaions[1].cornerText->SetTextProperty( m_CornerAnnotaions[1].textProp ); - m_CornerAnnotaions[1].ren = vtkRenderer::New(); - m_CornerAnnotaions[1].ren->AddActor(m_CornerAnnotaions[1].cornerText); - m_CornerAnnotaions[1].ren->InteractiveOff(); - mitk::VtkLayerController::GetInstance(this->GetRenderWindow2()->GetRenderWindow())->InsertForegroundRenderer(m_CornerAnnotaions[1].ren,true); - - //Render Window 3 == coronal - m_CornerAnnotaions[2].cornerText = vtkCornerAnnotation::New(); - m_CornerAnnotaions[2].cornerText->SetText(0, "Coronal"); - m_CornerAnnotaions[2].cornerText->SetMaximumFontSize(12); - m_CornerAnnotaions[2].textProp = vtkTextProperty::New(); - m_CornerAnnotaions[2].textProp->SetColor( 0.295, 0.295, 1.0 ); - m_CornerAnnotaions[2].cornerText->SetTextProperty( m_CornerAnnotaions[2].textProp ); - m_CornerAnnotaions[2].ren = vtkRenderer::New(); - m_CornerAnnotaions[2].ren->AddActor(m_CornerAnnotaions[2].cornerText); - m_CornerAnnotaions[2].ren->InteractiveOff(); - mitk::VtkLayerController::GetInstance(this->GetRenderWindow3()->GetRenderWindow())->InsertForegroundRenderer(m_CornerAnnotaions[2].ren,true); - - /*************************************************/ - - - // create a slice rotator - // m_SlicesRotator = mitk::SlicesRotator::New(); - // @TODO next line causes sure memory leak - // rotator will be created nonetheless (will be switched on and off) - m_SlicesRotator = mitk::SlicesRotator::New("slices-rotator"); - m_SlicesRotator->AddSliceController( - mitkWidget1->GetSliceNavigationController() ); - m_SlicesRotator->AddSliceController( - mitkWidget2->GetSliceNavigationController() ); - m_SlicesRotator->AddSliceController( - mitkWidget3->GetSliceNavigationController() ); - - // create a slice swiveller (using the same state-machine as SlicesRotator) - m_SlicesSwiveller = mitk::SlicesSwiveller::New("slices-rotator"); - m_SlicesSwiveller->AddSliceController( - mitkWidget1->GetSliceNavigationController() ); - m_SlicesSwiveller->AddSliceController( - mitkWidget2->GetSliceNavigationController() ); - m_SlicesSwiveller->AddSliceController( - mitkWidget3->GetSliceNavigationController() ); - - //initialize m_TimeNavigationController: send time via sliceNavigationControllers - m_TimeNavigationController = mitk::SliceNavigationController::New("dummy"); - m_TimeNavigationController->ConnectGeometryTimeEvent( - mitkWidget1->GetSliceNavigationController() , false); - m_TimeNavigationController->ConnectGeometryTimeEvent( - mitkWidget2->GetSliceNavigationController() , false); - m_TimeNavigationController->ConnectGeometryTimeEvent( - mitkWidget3->GetSliceNavigationController() , false); - m_TimeNavigationController->ConnectGeometryTimeEvent( - mitkWidget4->GetSliceNavigationController() , false); - mitkWidget1->GetSliceNavigationController() - ->ConnectGeometrySendEvent(mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); - - // Set TimeNavigationController to RenderingManager - // (which uses it internally for views initialization!) - mitk::RenderingManager::GetInstance()->SetTimeNavigationController( - m_TimeNavigationController ); - - //reverse connection between sliceNavigationControllers and m_TimeNavigationController - mitkWidget1->GetSliceNavigationController() - ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); - mitkWidget2->GetSliceNavigationController() - ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); - mitkWidget3->GetSliceNavigationController() - ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); - mitkWidget4->GetSliceNavigationController() - ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); - - m_MouseModeSwitcher = mitk::MouseModeSwitcher::New( mitk::GlobalInteraction::GetInstance() ); - - m_LastLeftClickPositionSupplier = - mitk::CoordinateSupplier::New("navigation", NULL); - mitk::GlobalInteraction::GetInstance()->AddListener( - m_LastLeftClickPositionSupplier - ); - // setup gradient background - m_GradientBackground1 = mitk::GradientBackground::New(); - m_GradientBackground1->SetRenderWindow( - mitkWidget1->GetRenderWindow() ); - m_GradientBackground1->Disable(); - - m_GradientBackground2 = mitk::GradientBackground::New(); - m_GradientBackground2->SetRenderWindow( - mitkWidget2->GetRenderWindow() ); - m_GradientBackground2->Disable(); - - m_GradientBackground3 = mitk::GradientBackground::New(); - m_GradientBackground3->SetRenderWindow( - mitkWidget3->GetRenderWindow() ); - m_GradientBackground3->Disable(); - - m_GradientBackground4 = mitk::GradientBackground::New(); - m_GradientBackground4->SetRenderWindow( - mitkWidget4->GetRenderWindow() ); - m_GradientBackground4->SetGradientColors(0.1,0.1,0.1,0.5,0.5,0.5); - m_GradientBackground4->Enable(); - - // setup the department logo rendering - m_LogoRendering1 = mitk::ManufacturerLogo::New(); - m_LogoRendering1->SetRenderWindow( - mitkWidget1->GetRenderWindow() ); - m_LogoRendering1->Disable(); - - m_LogoRendering2 = mitk::ManufacturerLogo::New(); - m_LogoRendering2->SetRenderWindow( - mitkWidget2->GetRenderWindow() ); - m_LogoRendering2->Disable(); - - m_LogoRendering3 = mitk::ManufacturerLogo::New(); - m_LogoRendering3->SetRenderWindow( - mitkWidget3->GetRenderWindow() ); - m_LogoRendering3->Disable(); - - m_LogoRendering4 = mitk::ManufacturerLogo::New(); - m_LogoRendering4->SetRenderWindow( - mitkWidget4->GetRenderWindow() ); - m_LogoRendering4->Enable(); - - m_RectangleRendering1 = mitk::RenderWindowFrame::New(); - m_RectangleRendering1->SetRenderWindow( - mitkWidget1->GetRenderWindow() ); - m_RectangleRendering1->Enable(1.0,0.0,0.0); - - m_RectangleRendering2 = mitk::RenderWindowFrame::New(); - m_RectangleRendering2->SetRenderWindow( - mitkWidget2->GetRenderWindow() ); - m_RectangleRendering2->Enable(0.0,1.0,0.0); - - m_RectangleRendering3 = mitk::RenderWindowFrame::New(); - m_RectangleRendering3->SetRenderWindow( - mitkWidget3->GetRenderWindow() ); - m_RectangleRendering3->Enable(0.0,0.0,1.0); - - m_RectangleRendering4 = mitk::RenderWindowFrame::New(); - m_RectangleRendering4->SetRenderWindow( - mitkWidget4->GetRenderWindow() ); - m_RectangleRendering4->Enable(1.0,1.0,0.0); -} - -QmitkStdMultiWidget::~QmitkStdMultiWidget() -{ - DisablePositionTracking(); - DisableNavigationControllerEventListening(); - - mitk::VtkLayerController::GetInstance(this->GetRenderWindow1()->GetRenderWindow())->RemoveRenderer( m_CornerAnnotaions[0].ren ); - mitk::VtkLayerController::GetInstance(this->GetRenderWindow2()->GetRenderWindow())->RemoveRenderer( m_CornerAnnotaions[1].ren ); - mitk::VtkLayerController::GetInstance(this->GetRenderWindow3()->GetRenderWindow())->RemoveRenderer( m_CornerAnnotaions[2].ren ); - - //Delete CornerAnnotation - m_CornerAnnotaions[0].cornerText->Delete(); - m_CornerAnnotaions[0].textProp->Delete(); - m_CornerAnnotaions[0].ren->Delete(); - - m_CornerAnnotaions[1].cornerText->Delete(); - m_CornerAnnotaions[1].textProp->Delete(); - m_CornerAnnotaions[1].ren->Delete(); - - m_CornerAnnotaions[2].cornerText->Delete(); - m_CornerAnnotaions[2].textProp->Delete(); - m_CornerAnnotaions[2].ren->Delete(); -} - -void QmitkStdMultiWidget::RemovePlanesFromDataStorage() -{ - if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_Node.IsNotNull()) - { - if(m_DataStorage.IsNotNull()) - { - m_DataStorage->Remove(m_PlaneNode1); - m_DataStorage->Remove(m_PlaneNode2); - m_DataStorage->Remove(m_PlaneNode3); - m_DataStorage->Remove(m_Node); - } - } -} - -void QmitkStdMultiWidget::AddPlanesToDataStorage() -{ - if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_Node.IsNotNull()) - { - if (m_DataStorage.IsNotNull()) - { - m_DataStorage->Add(m_Node); - m_DataStorage->Add(m_PlaneNode1, m_Node); - m_DataStorage->Add(m_PlaneNode2, m_Node); - m_DataStorage->Add(m_PlaneNode3, m_Node); - static_cast(m_PlaneNode1->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); - static_cast(m_PlaneNode2->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); - static_cast(m_PlaneNode3->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); - } - } -} - -void QmitkStdMultiWidget::changeLayoutTo2DImagesUp() -{ - SMW_INFO << "changing layout to 2D images up... " << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //Set Layout to widget - this->setLayout(QmitkStdMultiWidgetLayout); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - //insert Widget Container into splitter top - m_SubSplit1->addWidget( mitkWidget1Container ); - m_SubSplit1->addWidget( mitkWidget2Container ); - m_SubSplit1->addWidget( mitkWidget3Container ); - - //set SplitterSize for splitter top - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_SubSplit1->setSizes( splitterSize ); - - //insert Widget Container into splitter bottom - m_SubSplit2->addWidget( mitkWidget4Container ); - - //set SplitterSize for splitter m_LayoutSplit - splitterSize.clear(); - splitterSize.push_back(400); - splitterSize.push_back(1000); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt - m_MainSplit->show(); - - //show Widget if hidden - if ( mitkWidget1->isHidden() ) mitkWidget1->show(); - if ( mitkWidget2->isHidden() ) mitkWidget2->show(); - if ( mitkWidget3->isHidden() ) mitkWidget3->show(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - //Change Layout Name - m_Layout = LAYOUT_2D_IMAGES_UP; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutTo2DImagesLeft() -{ - SMW_INFO << "changing layout to 2D images left... " << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - //insert Widget into the splitters - m_SubSplit1->addWidget( mitkWidget1Container ); - m_SubSplit1->addWidget( mitkWidget2Container ); - m_SubSplit1->addWidget( mitkWidget3Container ); - - //set splitterSize of SubSplit1 - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_SubSplit1->setSizes( splitterSize ); - - m_SubSplit2->addWidget( mitkWidget4Container ); - - //set splitterSize of Layout Split - splitterSize.clear(); - splitterSize.push_back(400); - splitterSize.push_back(1000); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show Widget if hidden - if ( mitkWidget1->isHidden() ) mitkWidget1->show(); - if ( mitkWidget2->isHidden() ) mitkWidget2->show(); - if ( mitkWidget3->isHidden() ) mitkWidget3->show(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - //update Layout Name - m_Layout = LAYOUT_2D_IMAGES_LEFT; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToDefault() -{ - SMW_INFO << "changing layout to default... " << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - //insert Widget container into the splitters - m_SubSplit1->addWidget( mitkWidget1Container ); - m_SubSplit1->addWidget( mitkWidget2Container ); - - m_SubSplit2->addWidget( mitkWidget3Container ); - m_SubSplit2->addWidget( mitkWidget4Container ); - - //set splitter Size - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_SubSplit1->setSizes( splitterSize ); - m_SubSplit2->setSizes( splitterSize ); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show Widget if hidden - if ( mitkWidget1->isHidden() ) mitkWidget1->show(); - if ( mitkWidget2->isHidden() ) mitkWidget2->show(); - if ( mitkWidget3->isHidden() ) mitkWidget3->show(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_DEFAULT; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_DEFAULT ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_DEFAULT ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_DEFAULT ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_DEFAULT ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToBig3D() -{ - SMW_INFO << "changing layout to big 3D ..." << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //add widget Splitter to main Splitter - m_MainSplit->addWidget( mitkWidget4Container ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - mitkWidget1->hide(); - mitkWidget2->hide(); - mitkWidget3->hide(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_BIG_3D; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_BIG_3D ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_BIG_3D ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_BIG_3D ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_BIG_3D ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToWidget1() -{ - SMW_INFO << "changing layout to big Widget1 ..." << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //add widget Splitter to main Splitter - m_MainSplit->addWidget( mitkWidget1Container ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - if ( mitkWidget1->isHidden() ) mitkWidget1->show(); - mitkWidget2->hide(); - mitkWidget3->hide(); - mitkWidget4->hide(); - - m_Layout = LAYOUT_WIDGET1; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_WIDGET1 ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_WIDGET1 ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_WIDGET1 ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_WIDGET1 ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToWidget2() -{ - SMW_INFO << "changing layout to big Widget2 ..." << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //add widget Splitter to main Splitter - m_MainSplit->addWidget( mitkWidget2Container ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - mitkWidget1->hide(); - if ( mitkWidget2->isHidden() ) mitkWidget2->show(); - mitkWidget3->hide(); - mitkWidget4->hide(); - - m_Layout = LAYOUT_WIDGET2; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_WIDGET2 ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_WIDGET2 ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_WIDGET2 ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_WIDGET2 ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToWidget3() -{ - SMW_INFO << "changing layout to big Widget3 ..." << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //add widget Splitter to main Splitter - m_MainSplit->addWidget( mitkWidget3Container ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - mitkWidget1->hide(); - mitkWidget2->hide(); - if ( mitkWidget3->isHidden() ) mitkWidget3->show(); - mitkWidget4->hide(); - - m_Layout = LAYOUT_WIDGET3; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_WIDGET3 ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_WIDGET3 ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_WIDGET3 ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_WIDGET3 ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToRowWidget3And4() -{ - SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //add Widgets to splitter - m_LayoutSplit->addWidget( mitkWidget3Container ); - m_LayoutSplit->addWidget( mitkWidget4Container ); - - //set Splitter Size - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - mitkWidget1->hide(); - mitkWidget2->hide(); - if ( mitkWidget3->isHidden() ) mitkWidget3->show(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_ROW_WIDGET_3_AND_4; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToColumnWidget3And4() -{ - SMW_INFO << "changing layout to Widget3 and 4 in one Column..." << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //add Widgets to splitter - m_LayoutSplit->addWidget( mitkWidget3Container ); - m_LayoutSplit->addWidget( mitkWidget4Container ); - - //set SplitterSize - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - mitkWidget1->hide(); - mitkWidget2->hide(); - if ( mitkWidget3->isHidden() ) mitkWidget3->show(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_COLUMN_WIDGET_3_AND_4; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutToRowWidgetSmall3andBig4() -{ - SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; - - this->changeLayoutToRowWidget3And4(); - - m_Layout = LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4; -} - - -void QmitkStdMultiWidget::changeLayoutToSmallUpperWidget2Big3and4() -{ - SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - //insert Widget into the splitters - m_SubSplit1->addWidget( mitkWidget2Container ); - - m_SubSplit2->addWidget( mitkWidget3Container ); - m_SubSplit2->addWidget( mitkWidget4Container ); - - //set Splitter Size - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_SubSplit2->setSizes( splitterSize ); - splitterSize.clear(); - splitterSize.push_back(500); - splitterSize.push_back(1000); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt - m_MainSplit->show(); - - //show Widget if hidden - mitkWidget1->hide(); - if ( mitkWidget2->isHidden() ) mitkWidget2->show(); - if ( mitkWidget3->isHidden() ) mitkWidget3->show(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - - -void QmitkStdMultiWidget::changeLayoutTo2x2Dand3DWidget() -{ - SMW_INFO << "changing layout to 2 x 2D and 3D Widget" << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - //add Widgets to splitter - m_SubSplit1->addWidget( mitkWidget1Container ); - m_SubSplit1->addWidget( mitkWidget2Container ); - m_SubSplit2->addWidget( mitkWidget4Container ); - - //set Splitter Size - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_SubSplit1->setSizes( splitterSize ); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - if ( mitkWidget1->isHidden() ) mitkWidget1->show(); - if ( mitkWidget2->isHidden() ) mitkWidget2->show(); - mitkWidget3->hide(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_2X_2D_AND_3D_WIDGET; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - - -void QmitkStdMultiWidget::changeLayoutToLeft2Dand3DRight2D() -{ - SMW_INFO << "changing layout to 2D and 3D left, 2D right Widget" << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - - //add Widgets to splitter - m_SubSplit1->addWidget( mitkWidget1Container ); - m_SubSplit1->addWidget( mitkWidget4Container ); - m_SubSplit2->addWidget( mitkWidget2Container ); - - //set Splitter Size - QList splitterSize; - splitterSize.push_back(1000); - splitterSize.push_back(1000); - m_SubSplit1->setSizes( splitterSize ); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt and add to Layout - m_MainSplit->show(); - - //show/hide Widgets - if ( mitkWidget1->isHidden() ) mitkWidget1->show(); - if ( mitkWidget2->isHidden() ) mitkWidget2->show(); - mitkWidget3->hide(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); - - //update Alle Widgets - this->UpdateAllWidgets(); -} - -void QmitkStdMultiWidget::changeLayoutTo2DUpAnd3DDown() -{ - SMW_INFO << "changing layout to 2D up and 3D down" << std::endl; - - //Hide all Menu Widgets - this->HideAllWidgetToolbars(); - - delete QmitkStdMultiWidgetLayout ; - - //create Main Layout - QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); - - //Set Layout to widget - this->setLayout(QmitkStdMultiWidgetLayout); - - //create main splitter - m_MainSplit = new QSplitter( this ); - QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); - - //create m_LayoutSplit and add to the mainSplit - m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); - m_MainSplit->addWidget( m_LayoutSplit ); - - //add LevelWindow Widget to mainSplitter - m_MainSplit->addWidget( levelWindowWidget ); - - //create m_SubSplit1 and m_SubSplit2 - m_SubSplit1 = new QSplitter( m_LayoutSplit ); - m_SubSplit2 = new QSplitter( m_LayoutSplit ); - - //insert Widget Container into splitter top - m_SubSplit1->addWidget( mitkWidget1Container ); - - //set SplitterSize for splitter top - QList splitterSize; -// splitterSize.push_back(1000); -// splitterSize.push_back(1000); -// splitterSize.push_back(1000); -// m_SubSplit1->setSizes( splitterSize ); - - //insert Widget Container into splitter bottom - m_SubSplit2->addWidget( mitkWidget4Container ); - - //set SplitterSize for splitter m_LayoutSplit - splitterSize.clear(); - splitterSize.push_back(700); - splitterSize.push_back(700); - m_LayoutSplit->setSizes( splitterSize ); - - //show mainSplitt - m_MainSplit->show(); - - //show/hide Widgets - if ( mitkWidget1->isHidden() ) mitkWidget1->show(); - mitkWidget2->hide(); - mitkWidget3->hide(); - if ( mitkWidget4->isHidden() ) mitkWidget4->show(); - - m_Layout = LAYOUT_2D_UP_AND_3D_DOWN; - - //update Layout Design List - mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); - mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); - mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); - mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); - - //update all Widgets - this->UpdateAllWidgets(); -} - - - -void QmitkStdMultiWidget::SetDataStorage( mitk::DataStorage* ds ) -{ - mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->SetDataStorage(ds); - mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->SetDataStorage(ds); - mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->SetDataStorage(ds); - mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->SetDataStorage(ds); - m_DataStorage = ds; -} - - -void QmitkStdMultiWidget::Fit() -{ - vtkRenderer * vtkrenderer; - mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetDisplayGeometry()->Fit(); - mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetDisplayGeometry()->Fit(); - mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetDisplayGeometry()->Fit(); - mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetDisplayGeometry()->Fit(); - - int w = vtkObject::GetGlobalWarningDisplay(); - vtkObject::GlobalWarningDisplayOff(); - - vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetVtkRenderer(); - if ( vtkrenderer!= NULL ) - vtkrenderer->ResetCamera(); - - vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetVtkRenderer(); - if ( vtkrenderer!= NULL ) - vtkrenderer->ResetCamera(); - - vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetVtkRenderer(); - if ( vtkrenderer!= NULL ) - vtkrenderer->ResetCamera(); - - vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetVtkRenderer(); - if ( vtkrenderer!= NULL ) - vtkrenderer->ResetCamera(); - - vtkObject::SetGlobalWarningDisplay(w); -} - - -void QmitkStdMultiWidget::InitPositionTracking() -{ - //PoinSetNode for MouseOrientation - m_PositionTrackerNode = mitk::DataNode::New(); - m_PositionTrackerNode->SetProperty("name", mitk::StringProperty::New("Mouse Position")); - m_PositionTrackerNode->SetData( mitk::PointSet::New() ); - m_PositionTrackerNode->SetColor(1.0,0.33,0.0); - m_PositionTrackerNode->SetProperty("layer", mitk::IntProperty::New(1001)); - m_PositionTrackerNode->SetVisibility(true); - m_PositionTrackerNode->SetProperty("inputdevice", mitk::BoolProperty::New(true) ); - m_PositionTrackerNode->SetProperty("BaseRendererMapperID", mitk::IntProperty::New(0) );//point position 2D mouse - m_PositionTrackerNode->SetProperty("baserenderer", mitk::StringProperty::New("N/A")); -} - - -void QmitkStdMultiWidget::AddDisplayPlaneSubTree() -{ - // add the displayed planes of the multiwidget to a node to which the subtree - // @a planesSubTree points ... - - float white[3] = {1.0f,1.0f,1.0f}; - mitk::Geometry2DDataMapper2D::Pointer mapper; - - // ... of widget 1 - m_PlaneNode1 = (mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow()))->GetCurrentWorldGeometry2DNode(); - m_PlaneNode1->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); - m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true)); - m_PlaneNode1->SetProperty("name", mitk::StringProperty::New("widget1Plane")); - m_PlaneNode1->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); - m_PlaneNode1->SetProperty("helper object", mitk::BoolProperty::New(true)); - mapper = mitk::Geometry2DDataMapper2D::New(); - m_PlaneNode1->SetMapper(mitk::BaseRenderer::Standard2D, mapper); - - // ... of widget 2 - m_PlaneNode2 =( mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow()))->GetCurrentWorldGeometry2DNode(); - m_PlaneNode2->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); - m_PlaneNode2->SetProperty("visible", mitk::BoolProperty::New(true)); - m_PlaneNode2->SetProperty("name", mitk::StringProperty::New("widget2Plane")); - m_PlaneNode2->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); - m_PlaneNode2->SetProperty("helper object", mitk::BoolProperty::New(true)); - mapper = mitk::Geometry2DDataMapper2D::New(); - m_PlaneNode2->SetMapper(mitk::BaseRenderer::Standard2D, mapper); - - // ... of widget 3 - m_PlaneNode3 = (mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow()))->GetCurrentWorldGeometry2DNode(); - m_PlaneNode3->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); - m_PlaneNode3->SetProperty("visible", mitk::BoolProperty::New(true)); - m_PlaneNode3->SetProperty("name", mitk::StringProperty::New("widget3Plane")); - m_PlaneNode3->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); - m_PlaneNode3->SetProperty("helper object", mitk::BoolProperty::New(true)); - mapper = mitk::Geometry2DDataMapper2D::New(); - m_PlaneNode3->SetMapper(mitk::BaseRenderer::Standard2D, mapper); - - m_Node = mitk::DataNode::New(); - m_Node->SetProperty("name", mitk::StringProperty::New("Widgets")); - m_Node->SetProperty("helper object", mitk::BoolProperty::New(true)); -} - - -mitk::SliceNavigationController* QmitkStdMultiWidget::GetTimeNavigationController() -{ - return m_TimeNavigationController.GetPointer(); -} - - -void QmitkStdMultiWidget::EnableStandardLevelWindow() -{ - levelWindowWidget->disconnect(this); - levelWindowWidget->SetDataStorage(mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetDataStorage()); - levelWindowWidget->show(); -} - - -void QmitkStdMultiWidget::DisableStandardLevelWindow() -{ - levelWindowWidget->disconnect(this); - levelWindowWidget->hide(); -} - - -// CAUTION: Legacy code for enabling Qt-signal-controlled view initialization. -// Use RenderingManager::InitializeViews() instead. -bool QmitkStdMultiWidget::InitializeStandardViews( const mitk::Geometry3D * geometry ) -{ - return mitk::RenderingManager::GetInstance()->InitializeViews( geometry ); -} - - -void QmitkStdMultiWidget::RequestUpdate() -{ - mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget1->GetRenderWindow()); - mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget2->GetRenderWindow()); - mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget3->GetRenderWindow()); - mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget4->GetRenderWindow()); -} - - -void QmitkStdMultiWidget::ForceImmediateUpdate() -{ - mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget1->GetRenderWindow()); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget2->GetRenderWindow()); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget3->GetRenderWindow()); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget4->GetRenderWindow()); -} - - -void QmitkStdMultiWidget::wheelEvent( QWheelEvent * e ) -{ - emit WheelMoved( e ); -} - -void QmitkStdMultiWidget::mousePressEvent(QMouseEvent * e) -{ - if (e->button() == Qt::LeftButton) { - mitk::Point3D pointValue = this->GetLastLeftClickPosition(); - emit LeftMouseClicked(pointValue); - } -} - -void QmitkStdMultiWidget::moveEvent( QMoveEvent* e ) -{ - QWidget::moveEvent( e ); - - // it is necessary to readjust the position of the overlays as the StdMultiWidget has moved - // unfortunately it's not done by QmitkRenderWindow::moveEvent -> must be done here - emit Moved(); -} - -void QmitkStdMultiWidget::leaveEvent ( QEvent * /*e*/ ) -{ - //set cursor back to initial state - m_SlicesRotator->ResetMouseCursor(); -} - -QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow1() const -{ - return mitkWidget1; -} - - -QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow2() const -{ - return mitkWidget2; -} - - -QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow3() const -{ - return mitkWidget3; -} - - -QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow4() const -{ - return mitkWidget4; -} - - -const mitk::Point3D& QmitkStdMultiWidget::GetLastLeftClickPosition() const -{ - return m_LastLeftClickPositionSupplier->GetCurrentPoint(); -} - - -const mitk::Point3D QmitkStdMultiWidget::GetCrossPosition() const -{ - const mitk::PlaneGeometry *plane1 = - mitkWidget1->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - const mitk::PlaneGeometry *plane2 = - mitkWidget2->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - const mitk::PlaneGeometry *plane3 = - mitkWidget3->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - - mitk::Line3D line; - if ( (plane1 != NULL) && (plane2 != NULL) - && (plane1->IntersectionLine( plane2, line )) ) - { - mitk::Point3D point; - if ( (plane3 != NULL) - && (plane3->IntersectionPoint( line, point )) ) - { - return point; - } - } - return m_LastLeftClickPositionSupplier->GetCurrentPoint(); -} - - -void QmitkStdMultiWidget::EnablePositionTracking() -{ - if (!m_PositionTracker) - { - m_PositionTracker = mitk::PositionTracker::New("PositionTracker", NULL); - } - mitk::GlobalInteraction* globalInteraction = mitk::GlobalInteraction::GetInstance(); - if (globalInteraction) - { - if(m_DataStorage.IsNotNull()) - m_DataStorage->Add(m_PositionTrackerNode); - globalInteraction->AddListener(m_PositionTracker); - } -} - - -void QmitkStdMultiWidget::DisablePositionTracking() -{ - mitk::GlobalInteraction* globalInteraction = - mitk::GlobalInteraction::GetInstance(); - - if(globalInteraction) - { - if (m_DataStorage.IsNotNull()) - m_DataStorage->Remove(m_PositionTrackerNode); - globalInteraction->RemoveListener(m_PositionTracker); - } -} - - -void QmitkStdMultiWidget::EnsureDisplayContainsPoint( - mitk::DisplayGeometry* displayGeometry, const mitk::Point3D& p) -{ - mitk::Point2D pointOnPlane; - displayGeometry->Map( p, pointOnPlane ); - - // point minus origin < width or height ==> outside ? - mitk::Vector2D pointOnRenderWindow_MM; - pointOnRenderWindow_MM = pointOnPlane.GetVectorFromOrigin() - - displayGeometry->GetOriginInMM(); - - mitk::Vector2D sizeOfDisplay( displayGeometry->GetSizeInMM() ); - - if ( sizeOfDisplay[0] < pointOnRenderWindow_MM[0] - || 0 > pointOnRenderWindow_MM[0] - || sizeOfDisplay[1] < pointOnRenderWindow_MM[1] - || 0 > pointOnRenderWindow_MM[1] ) - { - // point is not visible -> move geometry - mitk::Vector2D offset( (pointOnRenderWindow_MM - sizeOfDisplay / 2.0) - / displayGeometry->GetScaleFactorMMPerDisplayUnit() ); - - displayGeometry->MoveBy( offset ); - } -} - - -void QmitkStdMultiWidget::MoveCrossToPosition(const mitk::Point3D& newPosition) -{ - // create a PositionEvent with the given position and - // tell the slice navigation controllers to move there - - mitk::Point2D p2d; - mitk::PositionEvent event( mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow()), 0, 0, 0, - mitk::Key_unknown, p2d, newPosition ); - mitk::StateEvent stateEvent(mitk::EIDLEFTMOUSEBTN, &event); - mitk::StateEvent stateEvent2(mitk::EIDLEFTMOUSERELEASE, &event); - - switch ( m_PlaneMode ) - { - default: - case PLANE_MODE_SLICING: - mitkWidget1->GetSliceNavigationController()->HandleEvent( &stateEvent ); - mitkWidget2->GetSliceNavigationController()->HandleEvent( &stateEvent ); - mitkWidget3->GetSliceNavigationController()->HandleEvent( &stateEvent ); - - // just in case SNCs will develop something that depends on the mouse - // button being released again - mitkWidget1->GetSliceNavigationController()->HandleEvent( &stateEvent2 ); - mitkWidget2->GetSliceNavigationController()->HandleEvent( &stateEvent2 ); - mitkWidget3->GetSliceNavigationController()->HandleEvent( &stateEvent2 ); - break; - - case PLANE_MODE_ROTATION: - m_SlicesRotator->HandleEvent( &stateEvent ); - - // just in case SNCs will develop something that depends on the mouse - // button being released again - m_SlicesRotator->HandleEvent( &stateEvent2 ); - break; - - case PLANE_MODE_SWIVEL: - m_SlicesSwiveller->HandleEvent( &stateEvent ); - - // just in case SNCs will develop something that depends on the mouse - // button being released again - m_SlicesSwiveller->HandleEvent( &stateEvent2 ); - break; - } - - // determine if cross is now out of display - // if so, move the display window - EnsureDisplayContainsPoint( mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow()) - ->GetDisplayGeometry(), newPosition ); - EnsureDisplayContainsPoint( mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow()) - ->GetDisplayGeometry(), newPosition ); - EnsureDisplayContainsPoint( mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow()) - ->GetDisplayGeometry(), newPosition ); - - // update displays - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkStdMultiWidget::HandleCrosshairPositionEvent() -{ - if(!m_PendingCrosshairPositionEvent) - { - m_PendingCrosshairPositionEvent=true; - QTimer::singleShot(0,this,SLOT( HandleCrosshairPositionEventDelayed() ) ); - } -} - -void QmitkStdMultiWidget::HandleCrosshairPositionEventDelayed() -{ - m_PendingCrosshairPositionEvent = false; - - // find image with highest layer - mitk::Point3D crosshairPos = this->GetCrossPosition(); - - mitk::TNodePredicateDataType::Pointer isImageData = mitk::TNodePredicateDataType::New(); - - mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->m_DataStorage->GetSubset(isImageData).GetPointer(); - std::string statusText; - mitk::Image::Pointer image3D; - int maxlayer = -32768; - - mitk::BaseRenderer* baseRenderer = this->mitkWidget1->GetSliceNavigationController()->GetRenderer(); - // find image with largest layer, that is the image shown on top in the render window - for (unsigned int x = 0; x < nodes->size(); x++) - { - if(nodes->at(x)->GetData()->GetGeometry()->IsInside(crosshairPos)) - { - int layer = 0; - if(!(nodes->at(x)->GetIntProperty("layer", layer))) continue; - if(layer > maxlayer) - { - if( static_cast(nodes->at(x))->IsVisible( baseRenderer ) ) - { - image3D = dynamic_cast(nodes->at(x)->GetData()); - maxlayer = layer; - } - } - } - } - - std::stringstream stream; - - mitk::Index3D p; - if(image3D.IsNotNull()) - { - image3D->GetGeometry()->WorldToIndex(crosshairPos, p); - stream.precision(2); - stream<<"Position: <" << std::fixed < mm"; - stream<<"; Index: <"< "; - mitk::ScalarType pixelValue = image3D->GetPixelValueByIndex(p, baseRenderer->GetTimeStep()); - if (fabs(pixelValue)>1000000) - { - stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: "<GetPixelValueByIndex(p, baseRenderer->GetTimeStep())<<" "; - } - else - { - stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: "<GetPixelValueByIndex(p, baseRenderer->GetTimeStep())<<" "; - } - } - else - { - stream << "No image information at this position!"; - } - - statusText = stream.str(); - mitk::StatusBar::GetInstance()->DisplayGreyValueText(statusText.c_str()); - - -} - -void QmitkStdMultiWidget::EnableNavigationControllerEventListening() -{ - // Let NavigationControllers listen to GlobalInteraction - mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); - - // Listen for SliceNavigationController - mitkWidget1->GetSliceNavigationController()->crosshairPositionEvent.AddListener( mitk::MessageDelegate( this, &QmitkStdMultiWidget::HandleCrosshairPositionEvent ) ); - mitkWidget2->GetSliceNavigationController()->crosshairPositionEvent.AddListener( mitk::MessageDelegate( this, &QmitkStdMultiWidget::HandleCrosshairPositionEvent ) ); - mitkWidget3->GetSliceNavigationController()->crosshairPositionEvent.AddListener( mitk::MessageDelegate( this, &QmitkStdMultiWidget::HandleCrosshairPositionEvent ) ); - - switch ( m_PlaneMode ) - { - default: - case PLANE_MODE_SLICING: - gi->AddListener( mitkWidget1->GetSliceNavigationController() ); - gi->AddListener( mitkWidget2->GetSliceNavigationController() ); - gi->AddListener( mitkWidget3->GetSliceNavigationController() ); - gi->AddListener( mitkWidget4->GetSliceNavigationController() ); - break; - - case PLANE_MODE_ROTATION: - gi->AddListener( m_SlicesRotator ); - break; - - case PLANE_MODE_SWIVEL: - gi->AddListener( m_SlicesSwiveller ); - break; - } - - gi->AddListener( m_TimeNavigationController ); -} - -void QmitkStdMultiWidget::DisableNavigationControllerEventListening() -{ - // Do not let NavigationControllers listen to GlobalInteraction - mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); - - switch ( m_PlaneMode ) - { - default: - case PLANE_MODE_SLICING: - gi->RemoveListener( mitkWidget1->GetSliceNavigationController() ); - gi->RemoveListener( mitkWidget2->GetSliceNavigationController() ); - gi->RemoveListener( mitkWidget3->GetSliceNavigationController() ); - gi->RemoveListener( mitkWidget4->GetSliceNavigationController() ); - break; - - case PLANE_MODE_ROTATION: - m_SlicesRotator->ResetMouseCursor(); - gi->RemoveListener( m_SlicesRotator ); - break; - - case PLANE_MODE_SWIVEL: - m_SlicesSwiveller->ResetMouseCursor(); - gi->RemoveListener( m_SlicesSwiveller ); - break; - } - - gi->RemoveListener( m_TimeNavigationController ); -} - - -int QmitkStdMultiWidget::GetLayout() const -{ - return m_Layout; -} - -bool QmitkStdMultiWidget::GetGradientBackgroundFlag() const -{ - return m_GradientBackgroundFlag; -} - -void QmitkStdMultiWidget::EnableGradientBackground() -{ - // gradient background is by default only in widget 4, otherwise - // interferences between 2D rendering and VTK rendering may occur. - //m_GradientBackground1->Enable(); - //m_GradientBackground2->Enable(); - //m_GradientBackground3->Enable(); - m_GradientBackground4->Enable(); - m_GradientBackgroundFlag = true; -} - - -void QmitkStdMultiWidget::DisableGradientBackground() -{ - //m_GradientBackground1->Disable(); - //m_GradientBackground2->Disable(); - //m_GradientBackground3->Disable(); - m_GradientBackground4->Disable(); - m_GradientBackgroundFlag = false; -} - - -void QmitkStdMultiWidget::EnableDepartmentLogo() -{ - m_LogoRendering4->Enable(); -} - - -void QmitkStdMultiWidget::DisableDepartmentLogo() -{ - m_LogoRendering4->Disable(); -} - - -mitk::SlicesRotator * QmitkStdMultiWidget::GetSlicesRotator() const -{ - return m_SlicesRotator; -} - - -mitk::SlicesSwiveller * QmitkStdMultiWidget::GetSlicesSwiveller() const -{ - return m_SlicesSwiveller; -} - - -void QmitkStdMultiWidget::SetWidgetPlaneVisibility(const char* widgetName, bool visible, mitk::BaseRenderer *renderer) -{ - if (m_DataStorage.IsNotNull()) - { - mitk::DataNode* n = m_DataStorage->GetNamedNode(widgetName); - if (n != NULL) - n->SetVisibility(visible, renderer); - } -} - - -void QmitkStdMultiWidget::SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer) -{ - SetWidgetPlaneVisibility("widget1Plane", visible, renderer); - SetWidgetPlaneVisibility("widget2Plane", visible, renderer); - SetWidgetPlaneVisibility("widget3Plane", visible, renderer); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - - -void QmitkStdMultiWidget::SetWidgetPlanesLocked(bool locked) -{ - //do your job and lock or unlock slices. - GetRenderWindow1()->GetSliceNavigationController()->SetSliceLocked(locked); - GetRenderWindow2()->GetSliceNavigationController()->SetSliceLocked(locked); - GetRenderWindow3()->GetSliceNavigationController()->SetSliceLocked(locked); -} - - -void QmitkStdMultiWidget::SetWidgetPlanesRotationLocked(bool locked) -{ - //do your job and lock or unlock slices. - GetRenderWindow1()->GetSliceNavigationController()->SetSliceRotationLocked(locked); - GetRenderWindow2()->GetSliceNavigationController()->SetSliceRotationLocked(locked); - GetRenderWindow3()->GetSliceNavigationController()->SetSliceRotationLocked(locked); -} - - -void QmitkStdMultiWidget::SetWidgetPlanesRotationLinked( bool link ) -{ - m_SlicesRotator->SetLinkPlanes( link ); - m_SlicesSwiveller->SetLinkPlanes( link ); - emit WidgetPlanesRotationLinked( link ); -} - - -void QmitkStdMultiWidget::SetWidgetPlaneMode( int userMode ) -{ - MITK_DEBUG << "Changing crosshair mode to " << userMode; - - // first of all reset left mouse button interaction to default if PACS interaction style is active - m_MouseModeSwitcher->SelectMouseMode( mitk::MouseModeSwitcher::MousePointer ); - - emit WidgetNotifyNewCrossHairMode( userMode ); - - int mode = m_PlaneMode; - bool link = false; - - // Convert user interface mode to actual mode - { - switch(userMode) - { - case 0: - mode = PLANE_MODE_SLICING; - link = false; - break; - - case 1: - mode = PLANE_MODE_ROTATION; - link = false; - break; - - case 2: - mode = PLANE_MODE_ROTATION; - link = true; - break; - - case 3: - mode = PLANE_MODE_SWIVEL; - link = false; - break; - } - } - - // Slice rotation linked - m_SlicesRotator->SetLinkPlanes( link ); - m_SlicesSwiveller->SetLinkPlanes( link ); - - // Do nothing if mode didn't change - if ( m_PlaneMode == mode ) - { - return; - } - - mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); - - // Remove listeners of previous mode - switch ( m_PlaneMode ) - { - default: - case PLANE_MODE_SLICING: - // Notify MainTemplate GUI that this mode has been deselected - emit WidgetPlaneModeSlicing( false ); - - gi->RemoveListener( mitkWidget1->GetSliceNavigationController() ); - gi->RemoveListener( mitkWidget2->GetSliceNavigationController() ); - gi->RemoveListener( mitkWidget3->GetSliceNavigationController() ); - gi->RemoveListener( mitkWidget4->GetSliceNavigationController() ); - break; - - case PLANE_MODE_ROTATION: - // Notify MainTemplate GUI that this mode has been deselected - emit WidgetPlaneModeRotation( false ); - - m_SlicesRotator->ResetMouseCursor(); - gi->RemoveListener( m_SlicesRotator ); - break; - - case PLANE_MODE_SWIVEL: - // Notify MainTemplate GUI that this mode has been deselected - emit WidgetPlaneModeSwivel( false ); - - m_SlicesSwiveller->ResetMouseCursor(); - gi->RemoveListener( m_SlicesSwiveller ); - break; - } - - // Set new mode and add corresponding listener to GlobalInteraction - m_PlaneMode = mode; - switch ( m_PlaneMode ) - { - default: - case PLANE_MODE_SLICING: - // Notify MainTemplate GUI that this mode has been selected - emit WidgetPlaneModeSlicing( true ); - - // Add listeners - gi->AddListener( mitkWidget1->GetSliceNavigationController() ); - gi->AddListener( mitkWidget2->GetSliceNavigationController() ); - gi->AddListener( mitkWidget3->GetSliceNavigationController() ); - gi->AddListener( mitkWidget4->GetSliceNavigationController() ); - - mitk::RenderingManager::GetInstance()->InitializeViews(); - break; - - case PLANE_MODE_ROTATION: - // Notify MainTemplate GUI that this mode has been selected - emit WidgetPlaneModeRotation( true ); - - // Add listener - gi->AddListener( m_SlicesRotator ); - break; - - case PLANE_MODE_SWIVEL: - // Notify MainTemplate GUI that this mode has been selected - emit WidgetPlaneModeSwivel( true ); - - // Add listener - gi->AddListener( m_SlicesSwiveller ); - break; - } - // Notify MainTemplate GUI that mode has changed - emit WidgetPlaneModeChange(m_PlaneMode); -} - - -void QmitkStdMultiWidget::SetGradientBackgroundColors( const mitk::Color & upper, const mitk::Color & lower ) -{ - m_GradientBackground1->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); - m_GradientBackground2->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); - m_GradientBackground3->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); - m_GradientBackground4->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); - m_GradientBackgroundFlag = true; -} - - -void QmitkStdMultiWidget::SetDepartmentLogoPath( const char * path ) -{ - m_LogoRendering1->SetLogoSource(path); - m_LogoRendering2->SetLogoSource(path); - m_LogoRendering3->SetLogoSource(path); - m_LogoRendering4->SetLogoSource(path); -} - - -void QmitkStdMultiWidget::SetWidgetPlaneModeToSlicing( bool activate ) -{ - if ( activate ) - { - this->SetWidgetPlaneMode( PLANE_MODE_SLICING ); - } -} - - -void QmitkStdMultiWidget::SetWidgetPlaneModeToRotation( bool activate ) -{ - if ( activate ) - { - this->SetWidgetPlaneMode( PLANE_MODE_ROTATION ); - } -} - - -void QmitkStdMultiWidget::SetWidgetPlaneModeToSwivel( bool activate ) -{ - if ( activate ) - { - this->SetWidgetPlaneMode( PLANE_MODE_SWIVEL ); - } -} - -void QmitkStdMultiWidget::OnLayoutDesignChanged( int layoutDesignIndex ) -{ - switch( layoutDesignIndex ) - { - case LAYOUT_DEFAULT: - { - this->changeLayoutToDefault(); - break; - } - case LAYOUT_2D_IMAGES_UP: - { - this->changeLayoutTo2DImagesUp(); - break; - } - case LAYOUT_2D_IMAGES_LEFT: - { - this->changeLayoutTo2DImagesLeft(); - break; - } - case LAYOUT_BIG_3D: - { - this->changeLayoutToBig3D(); - break; - } - case LAYOUT_WIDGET1: - { - this->changeLayoutToWidget1(); - break; - } - case LAYOUT_WIDGET2: - { - this->changeLayoutToWidget2(); - break; - } - case LAYOUT_WIDGET3: - { - this->changeLayoutToWidget3(); - break; - } - case LAYOUT_2X_2D_AND_3D_WIDGET: - { - this->changeLayoutTo2x2Dand3DWidget(); - break; - } - case LAYOUT_ROW_WIDGET_3_AND_4: - { - this->changeLayoutToRowWidget3And4(); - break; - } - case LAYOUT_COLUMN_WIDGET_3_AND_4: - { - this->changeLayoutToColumnWidget3And4(); - break; - } - case LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4: - { - this->changeLayoutToRowWidgetSmall3andBig4(); - break; - } - case LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4: - { - this->changeLayoutToSmallUpperWidget2Big3and4(); - break; - } - case LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET: - { - this->changeLayoutToLeft2Dand3DRight2D(); - break; - } - - }; - - -} - -void QmitkStdMultiWidget::UpdateAllWidgets() -{ - mitkWidget1->resize( mitkWidget1Container->frameSize().width()-1, mitkWidget1Container->frameSize().height() ); - mitkWidget1->resize( mitkWidget1Container->frameSize().width(), mitkWidget1Container->frameSize().height() ); - - mitkWidget2->resize( mitkWidget2Container->frameSize().width()-1, mitkWidget2Container->frameSize().height() ); - mitkWidget2->resize( mitkWidget2Container->frameSize().width(), mitkWidget2Container->frameSize().height() ); - - mitkWidget3->resize( mitkWidget3Container->frameSize().width()-1, mitkWidget3Container->frameSize().height() ); - mitkWidget3->resize( mitkWidget3Container->frameSize().width(), mitkWidget3Container->frameSize().height() ); - - mitkWidget4->resize( mitkWidget4Container->frameSize().width()-1, mitkWidget4Container->frameSize().height() ); - mitkWidget4->resize( mitkWidget4Container->frameSize().width(), mitkWidget4Container->frameSize().height() ); - -} - - -void QmitkStdMultiWidget::HideAllWidgetToolbars() -{ - mitkWidget1->HideRenderWindowMenu(); - mitkWidget2->HideRenderWindowMenu(); - mitkWidget3->HideRenderWindowMenu(); - mitkWidget4->HideRenderWindowMenu(); -} - -void QmitkStdMultiWidget::ActivateMenuWidget( bool state ) -{ - mitkWidget1->ActivateMenuWidget( state ); - mitkWidget2->ActivateMenuWidget( state ); - mitkWidget3->ActivateMenuWidget( state ); - mitkWidget4->ActivateMenuWidget( state ); -} - -void QmitkStdMultiWidget::ResetCrosshair() -{ - if (m_DataStorage.IsNotNull()) - { - mitk::NodePredicateNot::Pointer pred - = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" - , mitk::BoolProperty::New(false))); - - mitk::NodePredicateNot::Pointer pred2 - = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" - , mitk::BoolProperty::New(true))); - - mitk::DataStorage::SetOfObjects::ConstPointer rs = m_DataStorage->GetSubset(pred); - mitk::DataStorage::SetOfObjects::ConstPointer rs2 = m_DataStorage->GetSubset(pred2); - // calculate bounding geometry of these nodes - mitk::TimeSlicedGeometry::Pointer bounds = m_DataStorage->ComputeBoundingGeometry3D(rs, "visible"); - - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - //mitk::RenderingManager::GetInstance()->InitializeViews( m_DataStorage->ComputeVisibleBoundingGeometry3D() ); - // reset interactor to normal slicing - this->SetWidgetPlaneMode(PLANE_MODE_SLICING); - } -} - -void QmitkStdMultiWidget::EnableColoredRectangles() -{ - m_RectangleRendering1->Enable(1.0, 0.0, 0.0); - m_RectangleRendering2->Enable(0.0, 1.0, 0.0); - m_RectangleRendering3->Enable(0.0, 0.0, 1.0); - m_RectangleRendering4->Enable(1.0, 1.0, 0.0); -} - -void QmitkStdMultiWidget::DisableColoredRectangles() -{ - m_RectangleRendering1->Disable(); - m_RectangleRendering2->Disable(); - m_RectangleRendering3->Disable(); - m_RectangleRendering4->Disable(); -} - - -mitk::MouseModeSwitcher* QmitkStdMultiWidget::GetMouseModeSwitcher() -{ - return m_MouseModeSwitcher; -} - -void QmitkStdMultiWidget::MouseModeSelected( mitk::MouseModeSwitcher::MouseMode mouseMode ) -{ - if ( mouseMode == 0 ) - { - this->EnableNavigationControllerEventListening(); - } - else - { - this->DisableNavigationControllerEventListening(); - } -} - diff --git a/CoreUI/Qmitk/QmitkStdMultiWidget.h b/CoreUI/Qmitk/QmitkStdMultiWidget.h deleted file mode 100644 index 37039cf8cc..0000000000 --- a/CoreUI/Qmitk/QmitkStdMultiWidget.h +++ /dev/null @@ -1,322 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKSTDMULTIWIDGET_H_ -#define QMITKSTDMULTIWIDGET_H_ - -#include - -#include "mitkPositionTracker.h" -#include "mitkSlicesRotator.h" -#include "mitkSlicesSwiveller.h" -#include "mitkRenderWindowFrame.h" -#include "mitkManufacturerLogo.h" -#include "mitkGradientBackground.h" -#include "mitkCoordinateSupplier.h" -#include "mitkDataStorage.h" - -#include "mitkMouseModeSwitcher.h" - -#include -#include -#include - -#include -#include - -#include "vtkTextProperty.h" -#include "vtkCornerAnnotation.h" - -class QHBoxLayout; -class QVBoxLayout; -class QGridLayout; -class QSpacerItem; -class QmitkLevelWindowWidget; -class QmitkRenderWindow; - -class QMITK_EXPORT QmitkStdMultiWidget : public QWidget -{ - Q_OBJECT - -public: - - QmitkStdMultiWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - virtual ~QmitkStdMultiWidget(); - - mitk::SliceNavigationController* - GetTimeNavigationController(); - - void RequestUpdate(); - - void ForceImmediateUpdate(); - - mitk::MouseModeSwitcher* GetMouseModeSwitcher(); - - - QmitkRenderWindow* GetRenderWindow1() const; - - QmitkRenderWindow* GetRenderWindow2() const; - - QmitkRenderWindow* GetRenderWindow3() const; - - QmitkRenderWindow* GetRenderWindow4() const; - - const mitk::Point3D & - GetLastLeftClickPosition() const; - - const mitk::Point3D - GetCrossPosition() const; - - void EnablePositionTracking(); - - void DisablePositionTracking(); - - int GetLayout() const; - - mitk::SlicesRotator * GetSlicesRotator() const; - - mitk::SlicesSwiveller * GetSlicesSwiveller() const; - - bool GetGradientBackgroundFlag() const; - - void InitializeWidget(); - - /// called when the StdMultiWidget is closed to remove the 3 widget planes and the helper node from the DataStorage - void RemovePlanesFromDataStorage(); - - void AddPlanesToDataStorage(); - - void SetDataStorage( mitk::DataStorage* ds ); - - /** \brief Listener to the CrosshairPositionEvent - - Ensures the CrosshairPositionEvent is handled only once and at the end of the Qt-Event loop - */ - void HandleCrosshairPositionEvent(); - - /// activate Menu Widget. true: activated, false: deactivated - void ActivateMenuWidget( bool state ); - -protected: - - void UpdateAllWidgets(); - - void HideAllWidgetToolbars(); - -public slots: - - /// Receives the signal from HandleCrosshairPositionEvent, executes the StatusBar update - void HandleCrosshairPositionEventDelayed(); - - void changeLayoutTo2DImagesUp(); - - void changeLayoutTo2DImagesLeft(); - - void changeLayoutToDefault(); - - void changeLayoutToBig3D(); - - void changeLayoutToWidget1(); - - void changeLayoutToWidget2(); - - void changeLayoutToWidget3(); - - void changeLayoutToRowWidget3And4(); - - void changeLayoutToColumnWidget3And4(); - - void changeLayoutToRowWidgetSmall3andBig4(); - - void changeLayoutToSmallUpperWidget2Big3and4(); - - void changeLayoutTo2x2Dand3DWidget(); - - void changeLayoutToLeft2Dand3DRight2D(); - - void changeLayoutTo2DUpAnd3DDown(); - - void Fit(); - - void InitPositionTracking(); - - void AddDisplayPlaneSubTree(); - - void EnableStandardLevelWindow(); - - void DisableStandardLevelWindow(); - - bool InitializeStandardViews( const mitk::Geometry3D * geometry ); - - void wheelEvent( QWheelEvent * e ); - - void mousePressEvent(QMouseEvent * e); - - void moveEvent( QMoveEvent* e ); - - void leaveEvent ( QEvent * e ); - - void EnsureDisplayContainsPoint( - mitk::DisplayGeometry* displayGeometry, const mitk::Point3D& p); - - void MoveCrossToPosition(const mitk::Point3D& newPosition); - - void EnableNavigationControllerEventListening(); - - void DisableNavigationControllerEventListening(); - - void EnableGradientBackground(); - - void DisableGradientBackground(); - - void EnableDepartmentLogo(); - - void DisableDepartmentLogo(); - - void EnableColoredRectangles(); - - void DisableColoredRectangles(); - - void SetWidgetPlaneVisibility(const char* widgetName, bool visible, mitk::BaseRenderer *renderer=NULL); - - void SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer=NULL); - - void SetWidgetPlanesLocked(bool locked); - - void SetWidgetPlanesRotationLocked(bool locked); - - void SetWidgetPlanesRotationLinked( bool link ); - - void SetWidgetPlaneMode( int mode ); - - void SetGradientBackgroundColors( const mitk::Color & upper, const mitk::Color & lower ); - - void SetDepartmentLogoPath( const char * path ); - - void SetWidgetPlaneModeToSlicing( bool activate ); - - void SetWidgetPlaneModeToRotation( bool activate ); - - void SetWidgetPlaneModeToSwivel( bool activate ); - - void OnLayoutDesignChanged( int layoutDesignIndex ); - - void ResetCrosshair(); - - void MouseModeSelected( mitk::MouseModeSwitcher::MouseMode mouseMode ); - - -signals: - - void LeftMouseClicked(mitk::Point3D pointValue); - void WheelMoved(QWheelEvent*); - void WidgetPlanesRotationLinked(bool); - void WidgetPlanesRotationEnabled(bool); - void ViewsInitialized(); - void WidgetPlaneModeSlicing(bool); - void WidgetPlaneModeRotation(bool); - void WidgetPlaneModeSwivel(bool); - void WidgetPlaneModeChange(int); - void WidgetNotifyNewCrossHairMode(int); - void Moved(); - -public: - - /** Define RenderWindow (public)*/ - QmitkRenderWindow* mitkWidget1; - QmitkRenderWindow* mitkWidget2; - QmitkRenderWindow* mitkWidget3; - QmitkRenderWindow* mitkWidget4; - QmitkLevelWindowWidget* levelWindowWidget; - /********************************/ - - enum { PLANE_MODE_SLICING = 0, PLANE_MODE_ROTATION, PLANE_MODE_SWIVEL }; - enum { LAYOUT_DEFAULT = 0, LAYOUT_2D_IMAGES_UP, LAYOUT_2D_IMAGES_LEFT, - LAYOUT_BIG_3D, LAYOUT_WIDGET1, LAYOUT_WIDGET2, LAYOUT_WIDGET3, - LAYOUT_2X_2D_AND_3D_WIDGET, LAYOUT_ROW_WIDGET_3_AND_4, - LAYOUT_COLUMN_WIDGET_3_AND_4, LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4 , - LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4,LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET, - LAYOUT_2D_UP_AND_3D_DOWN}; - - enum { - TRANSVERSAL, - SAGITTAL, - CORONAL, - THREE_D - }; - - -protected: - - QHBoxLayout* QmitkStdMultiWidgetLayout; - - int m_Layout; - int m_PlaneMode; - - mitk::RenderWindowFrame::Pointer m_RectangleRendering3; - mitk::RenderWindowFrame::Pointer m_RectangleRendering2; - mitk::RenderWindowFrame::Pointer m_RectangleRendering1; - mitk::RenderWindowFrame::Pointer m_RectangleRendering4; - - mitk::ManufacturerLogo::Pointer m_LogoRendering1; - mitk::ManufacturerLogo::Pointer m_LogoRendering2; - mitk::ManufacturerLogo::Pointer m_LogoRendering3; - mitk::ManufacturerLogo::Pointer m_LogoRendering4; - - mitk::GradientBackground::Pointer m_GradientBackground1; - mitk::GradientBackground::Pointer m_GradientBackground2; - mitk::GradientBackground::Pointer m_GradientBackground4; - mitk::GradientBackground::Pointer m_GradientBackground3; - bool m_GradientBackgroundFlag; - - - mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher; - mitk::CoordinateSupplier::Pointer m_LastLeftClickPositionSupplier; - mitk::PositionTracker::Pointer m_PositionTracker; - mitk::SliceNavigationController::Pointer m_TimeNavigationController; - mitk::SlicesRotator::Pointer m_SlicesRotator; - mitk::SlicesSwiveller::Pointer m_SlicesSwiveller; - - mitk::DataNode::Pointer m_PositionTrackerNode; - mitk::DataStorage::Pointer m_DataStorage; - - mitk::DataNode::Pointer m_PlaneNode1; - mitk::DataNode::Pointer m_PlaneNode2; - mitk::DataNode::Pointer m_PlaneNode3; - mitk::DataNode::Pointer m_Node; - - QSplitter *m_MainSplit; - QSplitter *m_LayoutSplit; - QSplitter *m_SubSplit1; - QSplitter *m_SubSplit2; - - QWidget *mitkWidget1Container; - QWidget *mitkWidget2Container; - QWidget *mitkWidget3Container; - QWidget *mitkWidget4Container; - - struct - { - vtkCornerAnnotation *cornerText; - vtkTextProperty *textProp; - vtkRenderer *ren; - } m_CornerAnnotaions[3]; - - bool m_PendingCrosshairPositionEvent; - -}; -#endif /*QMITKSTDMULTIWIDGET_H_*/ diff --git a/CoreUI/Qmitk/files.cmake b/CoreUI/Qmitk/files.cmake deleted file mode 100644 index cdd8d24f56..0000000000 --- a/CoreUI/Qmitk/files.cmake +++ /dev/null @@ -1,61 +0,0 @@ -SET(CPP_FILES -QmitkApplicationCursor.cpp -QmitkDataStorageComboBox.cpp -QmitkDataStorageListModel.cpp -QmitkDataStorageTableModel.cpp -QmitkDataStorageTreeModel.cpp -QmitkEventAdapter.cpp -QmitkLevelWindowPresetDefinitionDialog.cpp -QmitkLevelWindowRangeChangeDialog.cpp -QmitkLevelWindowWidgetContextMenu.cpp -QmitkLevelWindowWidget.cpp -QmitkLineEditLevelWindowWidget.cpp -QmitkMemoryUsageIndicatorView.cpp -QmitkNodeDescriptor.cpp -QmitkNodeDescriptorManager.cpp -QmitkRenderWindowMenu.cpp -QmitkProgressBar.cpp -QmitkPropertiesTableEditor.cpp -QmitkPropertiesTableModel.cpp -QmitkPropertyDelegate.cpp -QmitkRegisterClasses.cpp -QmitkRenderingManager.cpp -QmitkRenderingManagerFactory.cpp -QmitkRenderWindow.cpp -QmitkSliderLevelWindowWidget.cpp -QmitkStdMultiWidget.cpp -QmitkMouseModeSwitcher.cpp -) - -SET(MOC_H_FILES -QmitkDataStorageComboBox.h -QmitkDataStorageTableModel.h -QmitkLevelWindowPresetDefinitionDialog.h -QmitkLevelWindowRangeChangeDialog.h -QmitkLevelWindowWidgetContextMenu.h -QmitkLevelWindowWidget.h -QmitkLineEditLevelWindowWidget.h -QmitkMemoryUsageIndicatorView.h -QmitkNodeDescriptor.h -QmitkNodeDescriptorManager.h -QmitkRenderWindowMenu.h -QmitkProgressBar.h -QmitkPropertiesTableEditor.h -QmitkPropertyDelegate.h -QmitkRenderingManager.h -QmitkRenderWindow.h -QmitkSliderLevelWindowWidget.h -QmitkStdMultiWidget.h -QmitkMouseModeSwitcher.h -) - -SET(UI_FILES -QmitkLevelWindowPresetDefinition.ui -QmitkLevelWindowWidget.ui -QmitkLevelWindowRangeChange.ui -QmitkMemoryUsageIndicator.ui -) - -SET(QRC_FILES - Qmitk.qrc -) diff --git a/Documentation/Doxygen/Modules/ModuleMicroServices.dox b/Documentation/Doxygen/Modules/ModuleMicroServices.dox index 3abc0e1aee..f68e8eeccb 100644 --- a/Documentation/Doxygen/Modules/ModuleMicroServices.dox +++ b/Documentation/Doxygen/Modules/ModuleMicroServices.dox @@ -1,29 +1,44 @@ /** \defgroup MicroServices Micro Services Classes \ingroup Core \brief This category includes classes related to the MITK Micro Services component. The MITK Micro Services component provides a dynamic service registry based on the service layer as specified in the OSGi R4.2 specifications. For further information, see the separate \ref MicroServices_Overview page. */ /** +\defgroup MicroServices_Interfaces Micro Services Interfaces +\ingroup Core + +\brief Classes (interfaces) in this category are explicitely designed for usage with the MITK Micro Services. + +All classes in this category are structs with no non-static members and only pure virtual functions +(except for an inlined virtual destructor). Such a class will be called a \e interface. + +These interfaces are meant to be implemented by MITK module developers to enhance or overwrite certain +aspects of the MITK toolkit. All implementations must be registered in the implementing module's +\e activator (see mitk::ModuleActivator) using the module's mitk::ModuleContext instance. +*/ + +/** + \page MicroServices_Overview The MITK Micro Services The MITK Micro Services component provides a dynamic service registry based on the service layer as specified in the OSGi R4.2 specifications. It enables users to realize a service oriented approach within their software stack. The advantages include higher reuse of components, looser coupling, better organization of responsibilities, cleaner API contracts, etc. Following is a list of use cases and common patterns - \subpage MicroServices_EmulateSingleton */ diff --git a/MITKConfig.cmake.in b/MITKConfig.cmake.in index c9e74fb5e5..3253856822 100644 --- a/MITKConfig.cmake.in +++ b/MITKConfig.cmake.in @@ -1,150 +1,140 @@ # Update the CMake module path SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "@MITK_SOURCE_DIR@/CMake") # Include MITK macros include(MacroParseArguments) +include(mitkFunctionCheckMitkCompatibility) include(mitkFunctionOrganizeSources) include(mitkFunctionCreateWindowsBatchScript) include(mitkFunctionInstallProvisioningFiles) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) include(mitkMacroCreateCTKPlugin) # The MITK version number SET(MITK_VERSION_MAJOR "@MITK_VERSION_MAJOR@") SET(MITK_VERSION_MINOR "@MITK_VERSION_MINOR@") SET(MITK_VERSION_PATCH "@MITK_VERSION_PATCH@") SET(MITK_VERSION_STRING "@MITK_VERSION_STRING@") +# Internal version numbers, used for approximate compatibility checks +# of a MITK development version (non-release). +SET(MITK_VERSION_PLUGIN_SYSTEM 2) # dropped legacy BlueBerry plug-in CMake support + # MITK specific variables SET(MITK_SOURCE_DIR "@MITK_SOURCE_DIR@") SET(MITK_BINARY_DIR "@MITK_BINARY_DIR@") SET(UTILITIES_DIR "@UTILITIES_DIR@") SET(REGISTER_QFUNCTIONALITY_CPP_IN "@REGISTER_QFUNCTIONALITY_CPP_IN@") SET(MITK_MODULES_PACKAGE_DEPENDS_DIR "@MITK_MODULES_PACKAGE_DEPENDS_DIR@") SET(MODULES_PACKAGE_DEPENDS_DIRS "@MODULES_PACKAGE_DEPENDS_DIRS@") SET(MITK_DOXYGEN_TAGFILE_NAME "@MITK_DOXYGEN_TAGFILE_NAME@") IF(MODULES_CONF_DIRS) LIST(APPEND MODULES_CONF_DIRS "@MODULES_CONF_DIRS@") LIST(REMOVE_DUPLICATES MODULES_CONF_DIRS) ELSE() SET(MODULES_CONF_DIRS "@MODULES_CONF_DIRS@") ENDIF() SET(MODULES_CONF_DIRNAME "@MODULES_CONF_DIRNAME@") FOREACH(_module @MITK_MODULE_NAMES@) SET(${_module}_CONFIG_FILE "@MITK_BINARY_DIR@/@MODULES_CONF_DIRNAME@/${_module}Config.cmake") ENDFOREACH() # Include directory variables SET(MITK_INCLUDE_DIRS "@MITK_INCLUDE_DIRS@") SET(QMITK_INCLUDE_DIRS "@QMITK_INCLUDE_DIRS@") SET(ANN_INCLUDE_DIR "@ANN_INCLUDE_DIR@") SET(IPSEGMENTATION_INCLUDE_DIR "@IPSEGMENTATION_INCLUDE_DIR@") SET(VECMATH_INCLUDE_DIR "@VECMATH_INCLUDE_DIR@") SET(IPFUNC_INCLUDE_DIR "@IPFUNC_INCLUDE_DIR@") SET(MITK_IGT_INCLUDE_DIRS "@MITK_IGT_INCLUDE_DIRS@") # Library variables SET(MITK_LIBRARIES "@MITK_LIBRARIES@") SET(QMITK_LIBRARIES "@QMITK_LIBRARIES@") # Link directory variables SET(MITK_LINK_DIRECTORIES "@MITK_LINK_DIRECTORIES@") SET(QMITK_LINK_DIRECTORIES "@QMITK_LINK_DIRECTORIES@") SET(MITK_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@/plugins") SET(MITK_VTK_LIBRARY_DIRS "@MITK_VTK_LIBRARY_DIRS@") SET(MITK_ITK_LIBRARY_DIRS "@MITK_ITK_LIBRARY_DIRS@") # External projects SET(ITK_DIR "@ITK_DIR@") SET(VTK_DIR "@VTK_DIR@") SET(DCMTK_DIR "@DCMTK_DIR@") SET(GDCM_DIR "@GDCM_DIR@") SET(BOOST_ROOT "@BOOST_ROOT@") SET(OpenCV_DIR "@OpenCV_DIR@") SET(MITK_QMAKE_EXECUTABLE "@QT_QMAKE_EXECUTABLE@") SET(MITK_DATA_DIR "@MITK_DATA_DIR@") SET(MITK_RUNTIME_PATH "@MITK_RUNTIME_PATH@") # MITK use variables SET(MITK_USE_QT @MITK_USE_QT@) SET(MITK_USE_BLUEBERRY @MITK_USE_BLUEBERRY@) SET(MITK_USE_SYSTEM_Boost @MITK_USE_SYSTEM_Boost@) SET(MITK_USE_Boost @MITK_USE_Boost@) SET(MITK_USE_Boost_LIBRARIES @MITK_USE_Boost_LIBRARIES@) SET(MITK_USE_CTK @MITK_USE_CTK@) SET(MITK_USE_DCMTK @MITK_USE_DCMTK@) SET(MITK_USE_OpenCV @MITK_USE_OpenCV@) SET(MITK_USE_Python @MITK_USE_Python@) # There is no PocoConfig.cmake, so we set Poco specific CMake variables # here. This way the call to FIND_PACKAGE(Poco) in BlueBerryConfig.cmake # finds the Poco distribution supplied by MITK SET(Poco_INCLUDE_DIR "@MITK_SOURCE_DIR@/Utilities/Poco") SET(Poco_LIBRARY_DIR "@MITK_BINARY_DIR@/bin") IF(MITK_USE_IGT) #INCLUDE(${MITK_DIR}/mitkIGTConfig.cmake) ENDIF() IF(NOT MITK_EXPORTS_FILE_INCLUDED) IF(EXISTS "@MITK_EXPORTS_FILE@") SET(MITK_EXPORTS_FILE_INCLUDED 1) INCLUDE("@MITK_EXPORTS_FILE@") ENDIF(EXISTS "@MITK_EXPORTS_FILE@") ENDIF() # BlueBerry support IF(MITK_USE_BLUEBERRY) SET(BlueBerry_DIR "@MITK_BINARY_DIR@/BlueBerry") - - INCLUDE(mitkMacroCreatePlugin) - - IF(NOT MITK_SKIP_BUNDLELIST) - IF(MITK_USE_EXT) - INCLUDE("@MITK_BINARY_DIR@/Bundles/MITKModulesBundleList.cmake") - ENDIF() - ENDIF(NOT MITK_SKIP_BUNDLELIST) # Don't include the BlueBerry exports file, since the targets are # also exported in the MITK exports file SET(BB_PLUGIN_EXPORTS_FILE_INCLUDED 1) FIND_PACKAGE(BlueBerry) IF(NOT BlueBerry_FOUND) MESSAGE(SEND_ERROR "MITK does not seem to be configured with BlueBerry support. Set MITK_USE_BLUEBERRY to ON in your MITK build configuration.") ENDIF(NOT BlueBerry_FOUND) - SET(MITK_PLUGIN_SOURCE_DIRS "@MITK_SOURCE_DIR@/Bundles") - - SET(MITK_PLUGIN_OUTPUT_DIRS ) - IF(MITK_USE_EXT) - LIST(APPEND MITK_PLUGIN_OUTPUT_DIRS @MITK_MODULES_PLUGIN_OUTPUT_DIRS@) - ENDIF() - SET(MITK_PLUGIN_USE_FILE @MITK_PLUGIN_USE_FILE@) IF(MITK_PLUGIN_USE_FILE) IF(EXISTS ${MITK_PLUGIN_USE_FILE}) INCLUDE(${MITK_PLUGIN_USE_FILE}) ENDIF() ENDIF() SET(MITK_PLUGIN_PROVISIONING_FILE "@MITK_EXTAPP_PROVISIONING_FILE@") SET(MITK_PROVISIONING_FILES "${BLUEBERRY_PLUGIN_PROVISIONING_FILE}" "${MITK_PLUGIN_PROVISIONING_FILE}") ENDIF(MITK_USE_BLUEBERRY) diff --git a/Modules/Bundles/BundleList.cmake.in b/Modules/Bundles/BundleList.cmake.in deleted file mode 100755 index 5da4b28d4b..0000000000 --- a/Modules/Bundles/BundleList.cmake.in +++ /dev/null @@ -1 +0,0 @@ -@BLUEBERRY_BUNDLE_VARIABLES@ \ No newline at end of file diff --git a/Modules/Bundles/CMakeLists.txt b/Modules/Bundles/CMakeLists.txt deleted file mode 100644 index 60ce214121..0000000000 --- a/Modules/Bundles/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ - -IF(MITK_USE_BLUEBERRY) - - SET(MITK_DEFAULT_SUBPROJECTS MITK-Plugins) - - SET(_mitk_bundles_default - - ) - - IF(MITK_USE_Python) - LIST(APPEND _mitk_bundles_default org.mitk.gui.qt.python.console) - ENDIF() - - IF(QT4_FOUND) - LIST(APPEND _mitk_bundles_default "org.mitk.gui.qt.imagenavigator") - - # BlueBerry depends on CTK which depends on Qt, so we - # need the Qt include direcotries - INCLUDE(${QT_USE_FILE}) - ENDIF() - - SET(PLUGIN_EXCLUDE_LIST - org.mitk.core.ext - org.mitk.core.jobs - org.mitk.diffusionimaging - org.mitk.gui.qt.diffusionimaging - org.mitk.gui.qt.dtiatlasapp - org.mitk.gui.qt.diffusionimagingapp - org.mitk.gui.qt.examples - org.mitk.gui.qt.examplesopencv - org.mitk.gui.qt.ext - org.mitk.gui.qt.extapplication - org.mitk.gui.qt.datamanager - org.mitk.gui.qt.segmentation - org.mitk.planarfigure - org.mitk.gui.qt.igttracking - org.mitk.gui.qt.igtnavigation - org.mitk.gui.qt.igtexamples - org.mitk.gui.qt.basicimageprocessing - org.mitk.gui.qt.navigationdataplayer - # bug-8977 Deactivating ToF for testing purposes - # org.mitk.gui.qt.tofutil - # org.mitk.gui.qt.toftutorial - org.mitk.gui.qt.imagenavigator - org.mitk.gui.qt.moviemaker - org.mitk.gui.qt.materialeditor - org.mitk.gui.qt.ugvisualization - org.mitk.gui.qt.measurementtoolbox - org.mitk.gui.qt.imagecropper - org.mitk.gui.qt.volumevisualization - org.mitk.gui.qt.pointsetinteraction - org.mitk.gui.qt.python.console - org.mitk.gui.qt.registration - ) - - MACRO_COLLECT_PLUGINS(OUTPUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ExtBundles - CACHE_PLUGIN_SOURCE_DIRS MITK_MODULES_PLUGIN_SOURCE_DIRS - CACHE_PLUGIN_OUTPUT_DIRS MITK_MODULES_PLUGIN_OUTPUT_DIRS - CACHE_PLUGIN_TARGETS MITK_MODULES_ENABLED_PLUGINS - BUNDLE_LIST_PATH "${MITK_BINARY_DIR}/Bundles/MITKModulesBundleList.cmake" - CMAKE_CACHE_PREFIX "MITK" - PLUGIN_DEFAULT_ON ${_mitk_bundles_default} - PLUGIN_EXCLUDES ${PLUGIN_EXCLUDE_LIST} - ${MITK_BUILD_ALL_PLUGINS_OPTION}) - -ENDIF(MITK_USE_BLUEBERRY) diff --git a/Modules/Bundles/PluginList.cmake b/Modules/Bundles/PluginList.cmake deleted file mode 100644 index 66327e7420..0000000000 --- a/Modules/Bundles/PluginList.cmake +++ /dev/null @@ -1,31 +0,0 @@ -SET(MITK_EXT_PLUGINS - org.mitk.core.ext:OFF - org.mitk.core.jobs:OFF - org.mitk.planarfigure:ON - org.mitk.diffusionimaging:OFF - org.mitk.gui.qt.examples:OFF - org.mitk.gui.qt.examplesopencv:OFF - org.mitk.gui.qt.ext:OFF - org.mitk.gui.qt.extapplication:OFF - org.mitk.gui.qt.datamanager:ON - org.mitk.gui.qt.segmentation:OFF - org.mitk.gui.qt.diffusionimaging:OFF - org.mitk.gui.qt.dtiatlasapp:OFF - org.mitk.gui.qt.diffusionimagingapp:OFF - org.mitk.gui.qt.igtnavigation:OFF - org.mitk.gui.qt.igttracking:OFF - org.mitk.gui.qt.igtexamples:OFF - org.mitk.gui.qt.basicimageprocessing:OFF - org.mitk.gui.qt.tofutil:OFF - org.mitk.gui.qt.toftutorial:OFF - org.mitk.gui.qt.imagenavigator:ON - org.mitk.gui.qt.moviemaker:OFF - org.mitk.gui.qt.materialeditor:OFF - org.mitk.gui.qt.ugvisualization:OFF - org.mitk.gui.qt.measurementtoolbox:OFF - org.mitk.gui.qt.imagecropper:OFF - org.mitk.gui.qt.volumevisualization:OFF - org.mitk.gui.qt.pointsetinteraction:OFF - org.mitk.gui.qt.python.console:OFF - org.mitk.gui.qt.registration:OFF - ) diff --git a/Modules/Bundles/org.mitk.core.ext/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.core.ext/documentation/doxygen/modules.dox deleted file mode 100755 index f6956f5b19..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/documentation/doxygen/modules.dox +++ /dev/null @@ -1,19 +0,0 @@ -/** - \defgroup org_mitk_core_ext org.mitk.core.ext Plugin - \ingroup MITKPlugins - - \brief This small plug-in is responsible for initializing the MBI CoreExt module. - - It is started with an "eager" Bundle-ActivationPolicy, sucht that the plug-ins - activator is executed before any other (non-eager) plug-ins. - -*/ - -/** - \defgroup org_mitk_core_ext_internal Internal - \ingroup org_mitk_core_ext - - \brief This subcategory includes the internal classes of the org.mitk.core.ext plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.cpp b/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.cpp deleted file mode 100644 index 86e4e3e7e7..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include - -#include "mitkIInputDeviceRegistry.h" - -const std::string mitk::CoreExtConstants::INPUTDEVICE_SERVICE = "org.mitk.core.ext.services.inputdeviceregistry"; -const std::string mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES = "org.mitk.core.ext.preferences.inputdevices"; -const std::string mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME = "org.mitk.core.ext.inputdevices"; -const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS = "class"; -const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION = "description"; -const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_NAME = "name"; -const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_ID = "id"; -const std::string mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION = "Surface Interaction"; -const std::string mitk::CoreExtConstants::WIIMOTE_HEADTRACKING = "Headtracking"; -const std::string mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME = "org.mitk.inputdevices.wiimote"; diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.h b/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.h deleted file mode 100644 index ef6526b139..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.h +++ /dev/null @@ -1,54 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKCOREEXTCONSTANTS_H_ -#define MITKCOREEXTCONSTANTS_H_ - -#include - -#include - -namespace mitk -{ - /** - * The CoreExt Constants contains a list of unique ids in the following form:
- * "org.mitk.mybundle.mytype.propername"
- * - * This ids have the purpose of connecting the plugin.xml of each bundle to the - * appropriate classes. - * - * Additionally it includes names of tags, which are used in XML files
- * regarding any input device. - * - * @ingroup org_mitk_core_ext - */ - struct MITKCOREEXT_EXPORT CoreExtConstants - { - static const std::string INPUTDEVICE_SERVICE; - static const std::string INPUTDEVICE_PREFERENCES; - static const std::string INPUTDEVICE_EXTENSION_NAME; - static const std::string INPUTDEVICE_XMLATTRIBUTE_CLASS; - static const std::string INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION; - static const std::string INPUTDEVICE_XMLATTRIBUTE_NAME; - static const std::string INPUTDEVICE_XMLATTRIBUTE_ID; - static const std::string WIIMOTE_SURFACEINTERACTION; - static const std::string WIIMOTE_HEADTRACKING; - static const std::string WIIMOTE_XMLATTRIBUTE_NAME; - }; -} - -#endif /*MITKCOREEXTCONSTANTS_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDevice.h b/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDevice.h deleted file mode 100644 index f89e3901e3..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDevice.h +++ /dev/null @@ -1,57 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKIINPUTDEVICE_H_ -#define MITKIINPUTDEVICE_H_ - -#include -#include - -#include - -namespace mitk -{ - /** - * An input device provides a method to register and unregister itself. Meaning
- * for example adding listeners and instianciate classes necessary to use the input device. - * - * @noimplement This interface is not intended to be implemented by clients. - * @ingroup org_mitk_core_ext - */ - struct IInputDevice : public berry::Object - { - - berryInterfaceMacro(IInputDevice, mitk) - - /** - * Register the input device at one or more instances. - */ - virtual bool RegisterInputDevice() = 0; - - /** - * Unregister the input device at one or more instances. - */ - virtual bool UnRegisterInputDevice() = 0; - - virtual ~IInputDevice() {} - - }; // end struct IInputDevice -} // end namespace mitk - -Q_DECLARE_INTERFACE(mitk::IInputDevice, "org.mitk.IInputDevice") - -#endif /*MITKIINPUTDEVICE_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h b/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h deleted file mode 100644 index 71dc02fe16..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h +++ /dev/null @@ -1,77 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKIINPUTDEVICEREGISTRY_H_ -#define MITKIINPUTDEVICEREGISTRY_H_ - -#include - -#include - -#include -#include - -#include - -#include "mitkIInputDeviceDescriptor.h" - -namespace mitk -{ - /** - * - * The input device registry maintains a list of input devices explicitly registered - * against the view extension point. - *

- * The description of a given input device is kept in a IInputDeviceDescriptor. - *

- *

- * This interface is not intended to be implemented by clients. - *

- * - * @see mitk::IInputDeviceDescriptor - * @noimplement This interface is not intended to be implemented by clients. - * @ingroup org_mitk_core_ext - */ - struct MITKCOREEXT_EXPORT IInputDeviceRegistry: public berry::Service - { - berryInterfaceMacro(IInputDeviceRegistry, mitk) - - /** - * Return an input device descriptor with the given extension id. If no input device exists, - * with the id return null. - * - * @param id - * the id to search for - * @return the descriptor or null - */ - virtual IInputDeviceDescriptor::Pointer Find(const std::string& id) const = 0; - - /** - * Return a list of input devices defined in the registry. - * - * @return the input devices. - */ - virtual std::vector GetInputDevices() const = 0; - - virtual ~IInputDeviceRegistry() {} - - }; // end struct IInputDeviceRegistry -} // end namespace mitk - -Q_DECLARE_INTERFACE(mitk::IInputDeviceRegistry, "org.mitk.service.IInputDeviceRegistry") - -#endif /*MITKIINPUTDEVICEREGISTRY_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp deleted file mode 100644 index 170a44c470..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "mitkInputDeviceDescriptor.h" -#include "mitkCoreExtConstants.h" - - -mitk::InputDeviceDescriptor::InputDeviceDescriptor(berry::IConfigurationElement::Pointer inputDeviceExtensionPoint) -: IInputDeviceDescriptor(), m_InputDeviceExtensionPoint(inputDeviceExtensionPoint) -{ -} - -mitk::InputDeviceDescriptor::~InputDeviceDescriptor() -{ -} - -mitk::IInputDevice::Pointer mitk::InputDeviceDescriptor::CreateInputDevice() -{ - if(this->m_InputDevice == 0) - { - // "class" refers to xml attribute in a xml tag - this->m_InputDevice = this->m_InputDeviceExtensionPoint - ->CreateExecutableExtension(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS); - if (this->m_InputDevice == 0) - { - // support legacy BlueBerry extensions - this->m_InputDevice = this->m_InputDeviceExtensionPoint - ->CreateExecutableExtension( - mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS, - IInputDevice::GetManifestName()); - } - } - return this->m_InputDevice; -} - -std::string mitk::InputDeviceDescriptor::GetID() const -{ - std::string idOfExtensionPoint; - this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_ID,idOfExtensionPoint); - return idOfExtensionPoint; -} - -std::string mitk::InputDeviceDescriptor::GetDescription() const -{ - std::vector - descriptions(this->m_InputDeviceExtensionPoint->GetChildren(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION)); - - if(!descriptions.empty()) - { - return descriptions[0]->GetValue(); - } - return ""; -} - -std::string mitk::InputDeviceDescriptor::GetName() const -{ - std::string name; - this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_NAME,name); - return name; -} - -bool mitk::InputDeviceDescriptor::operator==(const Object* object) const -{ - if (const InputDeviceDescriptor* other = dynamic_cast(object)) - { - return this->GetID() == other->GetID(); - } - return false; -} - diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h deleted file mode 100644 index d91fe09689..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h +++ /dev/null @@ -1,88 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKINPUTDEVICEDESCRIPTOR_H_ -#define MITKINPUTDEVICEDESCRIPTOR_H_ - -#include - -#include - -#include "mitkIInputDeviceDescriptor.h" -#include "mitkIInputDevice.h" - -namespace mitk -{ - /** - * Documentation in the interface. - * - * @see mitk::IInputDeviceDescriptor - * @ingroup org_mitk_core_ext - */ - class InputDeviceDescriptor : public IInputDeviceDescriptor - { - - public: - - /** - * Initialize the Input Device Descriptor with the given extension point. - * - * @param inputDeviceExtensionPoint - * element, that refers to a extension point (type, id, name, class) - */ - InputDeviceDescriptor(berry::IConfigurationElement::Pointer inputDeviceExtensionPoint); - - /** - * Default destructor - */ - ~InputDeviceDescriptor(); - - /** - * @see mitk::IInputDeviceDescriptor::CreateInputDevice() - */ - mitk::IInputDevice::Pointer CreateInputDevice(); - - /** - * @see mitk::IInputDeviceDescriptor::GetDescription() - */ - std::string GetDescription() const; - - /** - * @see mitk::IInputDeviceDescriptor::GetID() - */ - std::string GetID() const; - - /** - * @see mitk::IInputDeviceDescriptor::GetName() - */ - std::string GetName() const; - - /** - * @see mitk::IInputDeviceDescriptor::operator==(const Object* object) - */ - bool operator==(const Object* object) const; - - private: - - // IConfigurationElements are used to access xml files (here: plugin.xml) - berry::IConfigurationElement::Pointer m_InputDeviceExtensionPoint; - mitk::IInputDevice::Pointer m_InputDevice; - - }; // end class -} // end namespace - -#endif /*MITKINPUTDEVICEDESCRIPTOR_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp deleted file mode 100644 index a129200f32..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include -#include -#include -#include -#include -#include "mitkCoreExtConstants.h" - -mitk::InputDeviceRegistry::InputDeviceRegistry() -{ - //initialize the registry by copying all available extension points into a local variable - berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); - std::vector allExtensionsInputDevices - = extensionPointService->GetConfigurationElementsFor(mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME); - - for(std::vector::const_iterator it = allExtensionsInputDevices.begin(); - it != allExtensionsInputDevices.end();++it) - { - InputDeviceDescriptorPtr temp(new mitk::InputDeviceDescriptor(*it)); - - // The equation with the end means, that if there is no such element and - // the pointer will be at end (not the last element, actually after it) - if(this->m_ListRegisteredDevices.find(temp->GetID()) == this->m_ListRegisteredDevices.end()) - { - m_ListRegisteredDevices.insert(std::make_pair(temp->GetID(),temp)); - } - else - { - throw std::runtime_error("The Input Device ID: "+temp->GetID()+" is already registered."); - } - } -} - -mitk::InputDeviceRegistry::~InputDeviceRegistry() -{ -} - -mitk::InputDeviceRegistry::InputDeviceDescriptorPtr mitk::InputDeviceRegistry::Find(const std::string &id) const -{ - Poco::HashMap::ConstIterator result = this->m_ListRegisteredDevices.find(id); - - // first = key, second = element or vice versa, if inserted different in the hash map - if(result != this->m_ListRegisteredDevices.end()) return result->second; - - return InputDeviceDescriptorPtr(0); -} - -std::vector mitk::InputDeviceRegistry::GetInputDevices() const -{ - std::vector temp; - for(Poco::HashMap::ConstIterator it = m_ListRegisteredDevices.begin(); - it != m_ListRegisteredDevices.end();++it) - { - // first = key, second = element or vice versa, if inserted different in the hash map - temp.push_back(it->second); - } - return temp; -} - -bool mitk::InputDeviceRegistry::IsA(const std::type_info& type) const -{ - std::string name(GetType().name()); - return name == type.name() || berry::Service::IsA(type); -} - -const std::type_info& mitk::InputDeviceRegistry::GetType() const -{ - return typeid(IInputDeviceRegistry); -} - diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.h b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.h deleted file mode 100644 index a758dd010d..0000000000 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.h +++ /dev/null @@ -1,67 +0,0 @@ -/*========================================================================= - -Program: BlueBerry Platform -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKSPACENAVIGATORREGISTRY_H_ -#define MITKSPACENAVIGATORREGISTRY_H_ - -#include -#include -#include - -#include -#include - -namespace mitk -{ - /** - * Documentation in the interface. - * - * @see mitk::IInputDeviceRegistry - * @ingroup org_mitk_core_ext - */ - class InputDeviceRegistry : public IInputDeviceRegistry - { - public: - - bool IsA(const std::type_info& type) const; - const std::type_info& GetType() const; - - // easier maintenance - typedef IInputDeviceDescriptor::Pointer InputDeviceDescriptorPtr; - - InputDeviceRegistry(); - ~InputDeviceRegistry(); - - /** - * @see mitk::IInputDeviceRegistry::Find(const std::string& id) - */ - InputDeviceDescriptorPtr Find(const std::string& id) const; - - /** - * @see mitk::IInputDeviceRegistry´::GetInputDevices() - */ - std::vector GetInputDevices() const; - - protected: - - private: - Poco::HashMap m_ListRegisteredDevices; - - }; // end class InputDeviceRegistry -} // end namespace mitk - -#endif /*MITKSPACENAVIGATORREGISTRY_H_*/ diff --git a/Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/modules.dox deleted file mode 100644 index f864b787c1..0000000000 --- a/Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_core_jobs org.mitk.core.jobs Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_core_jobs_internal Internal - \ingroup org_mitk_core_jobs - - \brief This subcategory includes the internal classes of the org.mitk.core.jobs plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h b/Modules/Bundles/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h deleted file mode 100644 index 61fff1824c..0000000000 --- a/Modules/Bundles/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h +++ /dev/null @@ -1,159 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision: 15350 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#ifndef MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ -#define MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ - -#include - -#include "berryISchedulingRule.h" -#include "berryObject.h" -#include "mitkDataNode.h" -#include "mitkDataStorage.h" -#include "mitkStandaloneDataStorage.h" - -namespace mitk { - - /** - *@class DataStorageAccessRule - * - *@brief The DataStorageAccessRule inherits from the ISchedulingRule class. DataStorageAccessRule are used to restrict the adding and - * removing of DataStorage nodes in multi-threaded scenarios. Only DataStorageNodes within different branches can be modified - * concurrently. The idea and its restrictions is explained in the sections and diagrams below. - * - *

the IsScheduling(...) method :

- * returns true or false depending if conflictions with another rule are found - * - *

- * - *

- *

the rule behavior if jobs holing add rules of an DataTree node

- * - * two add rules are always allowed since there are no conflictions when adding nodes concurrently. The final order the nodes are finally added has - * to be checked by the programmer of the particular job - * - * - *

the rule behavior when two jobs holding remove rules of a DataNode

- * - * two jobs holding remove rules can be executed concurrently since all removing scenarios do not cause conflictions. If two jobs are - * trying to remove the same DataTree node the job by itself needs to check if the node is still available before executing the removing - * command - * - * - *

the rule behavior of a jobs that is holding an add rule compared with a job that is holding a remove rule on a - * DataNode

- * - * adding and removing of DataTree nodes concurrently can cause serious errors and needs to be restricted. Performing add and remove - * operations on different DataStorage branches can be done concurrently since no conflictions are expected. - * the performing of add and remove operation on the same DataNode, its parent nodes or child nodes of the same branch - * by different jobs is not allowed. Jobs holding rules that are trying to perform such operations are blocked until the running job is done. - * - *

- * - *

- *

the Contains method (...) method :

- * only necessary for a specific type of scheduling rules. Has to be used if IScheduling rules are composed into hierarchies. - * In such scenarios the contains(...) method specifies the hierarchical relationships among the locks. For example if a method tries to acquire a specific * rule to lock a specific directory it needs to check if no job is holding a rule for one or more subdirectories. For all cases in which no composing of - * IScheduling rules is needed the Contains(...) method only needs to check if two jobs are holding exactly the same IScheduling rule on the same object. - * Normally this can be achieved by just calling the IsConflicting(...) method. - *

- * - *@author Jan Woerner - */ - - - - - class MITK_JOBS_EXPORT DataStorageAccessRule : public berry::ISchedulingRule { - - public: - - - enum RuleType {ADD_RULE = 0, REMOVE_RULE} ; - - RuleType m_Rule; - - berryObjectMacro(DataStorageAccessRule) - - DataStorageAccessRule (mitk::DataStorage::Pointer myDataStorage, mitk::DataNode::Pointer myDataNode, - DataStorageAccessRule::RuleType myRule) ; - - bool Contains (berry::ISchedulingRule::Pointer otherISchedulingRule) ; - bool IsConflicting (berry::ISchedulingRule::Pointer otherISchedulingRule) ; - - - - - - -private: - - - /** - * Returns false, identifying no conflictions between two DataStorageAccessRules. - * Two add and remove rules do work together. From importance is that jobs using this rule need to check if the - * node operating on is still available or already deleted by another job. The DataStorageAccessRule only checks if conflictions could - * occur if the removing or adding of nodes is performed currently. - */ - bool CompareTwoAddorRemoveRules() const ; - /** - * searches for conflictions of an add DataStorageAccessRule with a remove DataStorageAccess rule - * if the add and remove rule do operate in different branches, no conflictions are expected and false is returned - */ - bool CompareAddandRemoveRules(mitk::DataStorageAccessRule::Pointer sptr_otherDataStorageAccessRule) const; - /** - * for internal use only, - * checks if the jobs that are to be compared do hold DataStorageAccessRule on the same - * DataStorage. Jobs that do operate on different DataStorage do not conflict and false is returned - */ - bool CompareDataStorages(mitk::DataStorage::Pointer otherDataStorage) const; - /** - * for internal use only - * validates if the DataTree node of a particular DataStorageAccess rule belongs to the DataStorage specified within the particular rule. - * if not the rule is invalid and false is returned. No conflictions can be expected - */ - bool TestDataNode(mitk::DataNode::Pointer dataTreeToBeStored) const; - - /** - * returns a pointer to the specified DataStorage node - */ - mitk::DataNode::Pointer GetDataNode() const; - - /** - * returns a pointer to the specified DataStorage - */ - mitk::DataStorage::Pointer GetDataStorage() const; - - mitk::DataStorageAccessRule::RuleType GetRuleType() const; - - - - - DataStorage::Pointer m_sptrMyDataStorage ; - DataNode::Pointer m_sptrMyDataNode ; - - - }; - - } - -#endif /*MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ */ diff --git a/Modules/Bundles/org.mitk.diffusionimaging/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.diffusionimaging/documentation/doxygen/modules.dox deleted file mode 100644 index 40a19ecab5..0000000000 --- a/Modules/Bundles/org.mitk.diffusionimaging/documentation/doxygen/modules.dox +++ /dev/null @@ -1,19 +0,0 @@ -/** - \defgroup org_mitk_diffusionimaging org.mitk.diffusionimaging Plugin - \ingroup MITKPlugins - - \brief This small plug-in is responsible for initializing the mitkDiffusionImaging module. - - It is started with an "eager" Bundle-ActivationPolicy, sucht that the plug-ins - activator is executed before any other (non-eager) plug-ins. - -*/ - -/** - \defgroup org_mitk_diffusionimaging_internal Internal - \ingroup org_mitk_diffusionimaging - - \brief This subcategory includes the internal classes of the org.mitk.diffusionimaging plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/doxygen/modules.dox deleted file mode 100644 index 12b7c25955..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_basicimageprocessing org.mitk.gui.qt.basicimageprocessing Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_basicimageprocessing_internal Internal - \ingroup org_mitk_gui_qt_basicimageprocessing - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.basicimageprocessing plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/manifest_headers.cmake deleted file mode 100644 index 1276fbfbfe..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Basic Image Processing") -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) diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Image_properties.bmp b/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Image_properties.bmp deleted file mode 100644 index bd3aa51c22..0000000000 Binary files a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Image_properties.bmp and /dev/null differ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Parent-Child.bmp b/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Parent-Child.bmp deleted file mode 100644 index 36c19ae569..0000000000 Binary files a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Parent-Child.bmp and /dev/null differ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Preferences.bmp b/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Preferences.bmp deleted file mode 100644 index 1148d3abb6..0000000000 Binary files a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Preferences.bmp and /dev/null differ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/QmitkDatamanager.dox b/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/QmitkDatamanager.dox deleted file mode 100644 index 81008fe249..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/QmitkDatamanager.dox +++ /dev/null @@ -1,108 +0,0 @@ -/** - -\bundlemainpage{org_datamanager} The DataManager - -\image html DataManager_48.png "Icon of the Module" - -\section QmitkDataManagerIntroduction Introduction - -The Datamanager is the central componenent to manage medical data like images, surfaces, etc.. -After loading one or more data into the Datamanager the data are shown in the four-view window, the so called Standard View. -The user can now start working on the data by just clicking into the standard view or by using the MITK-modules such as "Segmentation" or "Basic Image Processing". - -Available sections: - - \ref QmitkDataManagerIntroduction - - \ref QmitkDataManagerLoading - - \ref QmitkDataManagerSaving - - \ref QmitkDataManagerProperties - - \ref QmitkDataManagerPropertiesList - - \ref QmitkDataManagerPropertiesVisibility - - \ref QmitkDataManagerPropertiesRepresentation - - \ref QmitkDataManagerPropertiesPreferences - - \ref QmitkDataManagerPropertyList - - -\image html Overview.png "How MITK looks when starting" - - -\section QmitkDataManagerLoading Loading Data - -There are three ways of loading data into the Datamanager as so called Data-Elements. - -The user can just drag and drop data into the Datamanager or directly into one of the four parts of the Standard View. -He can as well use the Open-Button in the right upper corner. Or he can use the standard "File->Open"-Dialog on the top. - -A lot of file-formats can be loaded into MITK, for example - -
    -
  • 2D-images/3D-volumes with or without several timesteps (*.dcm, *.ima, *.pic, ...) -
  • Surfaces (*.stl, *.vtk, ...) -
  • Pointsets (*.mps) -
  • ... -
- -The user can also load a series of 2D images (e.g. image001.bmp, image002.bmp ...) to a MITK 3D volume. -To do this, just drag and drop one of those 2D data files into the Datamanager by holding the ALT key. - -After loading one or more data into the Datamanager they appear as Data-Elements in a sorted list inside the Datamanager. -Data-Elements can also be sorted hierarchically as a parent-child-relation. -For example after using the Segmentation-Module on Data-Element1 the result is created as Data-Element2, which is a child of Data-Element1 (see Screenshot1). -The order can be changed by drag and drop. - -\image html Parent-Child.bmp "Screenshot1" - -The listed Data-Elements are shown in the standard view. -Here the user can scale or rotate the medical objects or he can change the cutting planes of the object by just using the mouse inside this view. - -\section QmitkDataManagerSaving Saving Data - -There are two ways of saving data from the Datamanger. The user can either save the whole project with all Data-Elements by clicking on "File"->"Save Project" -or he can save single Data-Elements by right-clicking->"Save", directly on a Data-Element. -When saving the whole project, the sorting of Data-Elements is saved as well. By contrast the sorting is lost, when saving a single Data-Element. - -\section QmitkDataManagerProperties Working with the Datamanager - -\subsection QmitkDataManagerPropertiesList List of Data-Elements - -The Data-Elements are listed in the Datamanager. -As described above the elements can be sorted hierarchically as a parent-child-relation. -For example after using the Segmentation-Module on Data-Element1 the result is created as Data-Element2, which is a child of Data-Element1 (see Screenshot1). -By drag and drop the sorting of Data-Elements and their hierarchical relation can be changed. - -\subsection QmitkDataManagerPropertiesVisibility Visibility of Data-Elements - -By default all loaded Data-Elements are visible in the standard view. -The visibility can be changed by right-clicking on the Data-Element and then choosing "Toogle visibility". -The box in front of the Data-Element in the Datamanager shows the visibility. -A green-filled box means a visible Data-Element, an empty box means an invisible Data-Element (see Screenshot1). - -\subsection QmitkDataManagerPropertiesRepresentation Representation of Data-Elements - -There are different types of representations how to show the Data-Element inside the standard view. By right-clicking on the Data-Element all options are listed (see Screenshot2 and Screenshot 3). - -
    -
  • An arbitrary color can be chosen -
  • The opacity can be changed with a slide control -
  • In case of images a texture interpolation can be switched on or off. The texture interpolation smoothes the image, so that no single pixels are visible anymore. -
  • In case of surfaces the surface representation can be changed between points, wireframe or surface. -
  • Global reinit updates all windows to contain all the current data. Reinit updates a single data item fits the windows to contain this data item. -
- -\image html Image_properties.bmp "Screenshot2: Properties for images" -\image html Surface_Properties.bmp "Screenshot3: Properties for surfaces" - - -\subsection QmitkDataManagerPropertiesPreferences Preferences - -For the datamanager there are already some default hotkeys like the del-key for deleting a Data-Element. The whole list is seen in Screenshot4. -From here the Hotkeys can also be changed. The preference page is found in "Window"->"Preferences". - -\image html Preferences.bmp "Screenshot4" - -\section QmitkDataManagerPropertyList Property List - -The Property List displays all the properties the currently selected Data-Element has. Which properties these are depends on the Data-Element. Examples are opacity, shader, visibility. These properties can be changed by clicking on the appropriate field in the "value" column. - -\image html PropertyList.png "Screenshot5: Property List" - -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Surface_Properties.bmp b/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Surface_Properties.bmp deleted file mode 100644 index c2a6861def..0000000000 Binary files a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Surface_Properties.bmp and /dev/null differ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/doxygen/modules.dox deleted file mode 100755 index 28433135a2..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_datamanager org.mitk.gui.qt.datamanager Plugin - \ingroup MITKPlugins - - \brief This is the datamanager plugin. It provides means to query mitk::DataStorage objects and to change properties of the contained nodes. - -*/ - -/** - \defgroup org_mitk_gui_qt_datamanager_internal Internal - \ingroup org_mitk_gui_qt_datamanager - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.datamanager plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.cpp b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.cpp deleted file mode 100644 index 867406c18b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ - Version: $Revision: 18019 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkDataManagerHotkeysPrefPage.h" -#include - -#include "berryIPreferencesService.h" -#include "berryPlatform.h" - -#include -#include -#include -#include -#include -#include - -#include - -using namespace berry; - -QmitkDataManagerHotkeysPrefPage::QmitkDataManagerHotkeysPrefPage() -: m_MainControl(0) -{ - -} - -QmitkDataManagerHotkeysPrefPage::QmitkDataManagerHotkeysPrefPage(const QmitkDataManagerHotkeysPrefPage& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemelnted"); -} - -void QmitkDataManagerHotkeysPrefPage::Init(berry::IWorkbench::Pointer ) -{ - -} - -void QmitkDataManagerHotkeysPrefPage::CreateQtControl(QWidget* parent) -{ - IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID); - berry::IPreferences::Pointer _DataManagerHotkeysPreferencesNode = prefService->GetSystemPreferences()->Node("/DataManager/Hotkeys"); - m_DataManagerHotkeysPreferencesNode = _DataManagerHotkeysPreferencesNode; - - m_HotkeyEditors["Make all nodes invisible"] = new QmitkHotkeyLineEdit("Ctrl+, V"); - - m_HotkeyEditors["Toggle visibility of selected nodes"] = new QmitkHotkeyLineEdit("V"); - - m_HotkeyEditors["Delete selected nodes"] = new QmitkHotkeyLineEdit("Del"); - - m_HotkeyEditors["Reinit selected nodes"] = new QmitkHotkeyLineEdit("R"); - - m_HotkeyEditors["Global Reinit"] = new QmitkHotkeyLineEdit("Ctrl+, R"); - - m_HotkeyEditors["Save selected nodes"] = new QmitkHotkeyLineEdit("Ctrl+, S"); - - m_HotkeyEditors["Load"] = new QmitkHotkeyLineEdit("Ctrl+, L"); - - m_HotkeyEditors["Show Node Information"] = new QmitkHotkeyLineEdit("Ctrl+, I"); - - m_MainControl = new QWidget(parent); - - QGridLayout* layout = new QGridLayout; - int i = 0; - for (std::map::iterator it = m_HotkeyEditors.begin() - ; it != m_HotkeyEditors.end(); ++it) - { - layout->addWidget(new QLabel(it->first), i,0); - layout->addWidget(it->second, i,1); - layout->setRowStretch(i,0); - ++i; - } - layout->setRowStretch(i+1,10); - - m_MainControl->setLayout(layout); - this->Update(); -} - -QWidget* QmitkDataManagerHotkeysPrefPage::GetQtControl() const -{ - return m_MainControl; -} - -bool QmitkDataManagerHotkeysPrefPage::PerformOk() -{ - IPreferences::Pointer _DataManagerHotkeysPreferencesNode = m_DataManagerHotkeysPreferencesNode.Lock(); - if(_DataManagerHotkeysPreferencesNode.IsNotNull()) - { - bool duplicate = false; - QString keyString; - QString errString; - for (std::map::iterator it = m_HotkeyEditors.begin() - ; it != m_HotkeyEditors.end(); ++it) - { - keyString = it->second->GetKeySequenceAsString(); - - if(keyString.isEmpty()) - errString = QString("No valid key sequence for \"%1\"").arg(it->first); - - if(errString.isEmpty()) - { - std::map::iterator it2; - // search for duplicated key - for (it2 = m_HotkeyEditors.begin(); it2 != m_HotkeyEditors.end(); ++it2) - { - if(it->first != it2->first && keyString == it2->second->GetKeySequenceAsString()) - { - duplicate = true; - break; - } - } - if(duplicate == true) - errString = QString("Duplicate hot key for \"%1\" and \"%2\"").arg(it->first).arg(it2->first); - } - - if(!errString.isEmpty()) - { - QMessageBox::critical(QApplication::activeWindow(), "Error", errString); - return false; - } - } - - //# no errors -> save all values and flush to file - for (std::map::iterator it = m_HotkeyEditors.begin() - ; it != m_HotkeyEditors.end(); ++it) - _DataManagerHotkeysPreferencesNode->Put(it->first.toStdString() - , it->second->GetKeySequenceAsString().toStdString()); - - _DataManagerHotkeysPreferencesNode->Flush(); - - return true; - } - return false; -} - -void QmitkDataManagerHotkeysPrefPage::PerformCancel() -{ - -} - -void QmitkDataManagerHotkeysPrefPage::Update() -{ - IPreferences::Pointer _DataManagerHotkeysPreferencesNode = m_DataManagerHotkeysPreferencesNode.Lock(); - if(_DataManagerHotkeysPreferencesNode.IsNotNull()) - { - for (std::map::iterator it = m_HotkeyEditors.begin() - ; it != m_HotkeyEditors.end(); ++it) - { - it->second->setText(QString::fromStdString(_DataManagerHotkeysPreferencesNode->Get(it->first.toStdString() - , it->second->text().toStdString()))); - } - } -} diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.h b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.h deleted file mode 100644 index d58c75a35b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.h +++ /dev/null @@ -1,74 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ - Version: $Revision: 16224 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKDATAMANAGERHOTKEYSPREFPAGE_H_ -#define QMITKDATAMANAGERHOTKEYSPREFPAGE_H_ - -#include "berryIQtPreferencePage.h" -#include - -#include -#include - -class QmitkHotkeyLineEdit; - -struct MITK_QT_DATAMANAGER QmitkDataManagerHotkeysPrefPage : public QObject, public berry::IQtPreferencePage -{ - Q_OBJECT - Q_INTERFACES(berry::IPreferencePage) - -public: - QmitkDataManagerHotkeysPrefPage(); - QmitkDataManagerHotkeysPrefPage(const QmitkDataManagerHotkeysPrefPage& other); - - void Init(berry::IWorkbench::Pointer workbench); - - void CreateQtControl(QWidget* parent); - - QWidget* GetQtControl() const; - - /// - /// \see IPreferencePage::PerformOk() - /// - virtual bool PerformOk(); - - /// - /// \see IPreferencePage::PerformCancel() - /// - virtual void PerformCancel(); - - /// - /// \see IPreferencePage::Update() - /// - virtual void Update(); - -protected: - /// - /// The node from which the properties are taken (will be catched from the preferences service in ctor) - /// - berry::IPreferences::WeakPtr m_DataManagerHotkeysPreferencesNode; - - /// - /// Maps a label to hotkey lineedit, e.g. "Toggle Visibility of selected nodes" => QmitkHotkeyLineEdit - /// - std::map m_HotkeyEditors; - - QWidget* m_MainControl; -}; - -#endif /* QMITKDATAMANAGERHOTKEYSPREFPAGE_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.cpp b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.cpp deleted file mode 100644 index 8921300d1b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ - Version: $Revision: 18019 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkDataManagerPreferencePage.h" -#include "QmitkDataManagerView.h" - -#include -#include -#include -#include - -#include -#include - -QmitkDataManagerPreferencePage::QmitkDataManagerPreferencePage() -: m_MainControl(0) -{ - -} - -QmitkDataManagerPreferencePage::QmitkDataManagerPreferencePage(const QmitkDataManagerPreferencePage& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -void QmitkDataManagerPreferencePage::Init(berry::IWorkbench::Pointer ) -{ - -} - -void QmitkDataManagerPreferencePage::CreateQtControl(QWidget* parent) -{ - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - - m_DataManagerPreferencesNode = prefService->GetSystemPreferences()->Node(QmitkDataManagerView::VIEW_ID); - - m_MainControl = new QWidget(parent); - m_EnableSingleEditing = new QCheckBox; - m_PlaceNewNodesOnTop = new QCheckBox; - m_ShowHelperObjects = new QCheckBox; - m_ShowNodesContainingNoData = new QCheckBox; - m_UseSurfaceDecimation = new QCheckBox; - - QFormLayout *formLayout = new QFormLayout; - formLayout->addRow("&Single click property editing:", m_EnableSingleEditing); - formLayout->addRow("&Place new nodes on top:", m_PlaceNewNodesOnTop); - formLayout->addRow("&Show helper objects:", m_ShowHelperObjects); - formLayout->addRow("&Show nodes containing no data", m_ShowNodesContainingNoData); - formLayout->addRow("&Use surface decimation:", m_UseSurfaceDecimation); - - m_MainControl->setLayout(formLayout); - this->Update(); -} - -QWidget* QmitkDataManagerPreferencePage::GetQtControl() const -{ - return m_MainControl; -} - -bool QmitkDataManagerPreferencePage::PerformOk() -{ - m_DataManagerPreferencesNode->PutBool("Single click property editing" - , m_EnableSingleEditing->isChecked()); - m_DataManagerPreferencesNode->PutBool("Place new nodes on top" - , m_PlaceNewNodesOnTop->isChecked()); - m_DataManagerPreferencesNode->PutBool("Show helper objects" - , m_ShowHelperObjects->isChecked()); - m_DataManagerPreferencesNode->PutBool("Show nodes containing no data" - , m_ShowNodesContainingNoData->isChecked()); - m_DataManagerPreferencesNode->PutBool("Use surface decimation" - , m_UseSurfaceDecimation->isChecked()); - return true; -} - -void QmitkDataManagerPreferencePage::PerformCancel() -{ - -} - -void QmitkDataManagerPreferencePage::Update() -{ - m_EnableSingleEditing->setChecked(m_DataManagerPreferencesNode->GetBool("Single click property editing", true)); - m_PlaceNewNodesOnTop->setChecked(m_DataManagerPreferencesNode->GetBool("Place new nodes on top", true)); - m_ShowHelperObjects->setChecked(m_DataManagerPreferencesNode->GetBool("Show helper objects", false)); - m_ShowNodesContainingNoData->setChecked(m_DataManagerPreferencesNode->GetBool("Show nodes containing no data", false)); - m_UseSurfaceDecimation->setChecked(m_DataManagerPreferencesNode->GetBool("Use surface decimation", true)); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.h b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.h deleted file mode 100644 index e43bafa74d..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.h +++ /dev/null @@ -1,69 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ - Version: $Revision: 16224 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKDATAMANAGERPREFERENCEPAGE_H_ -#define QMITKDATAMANAGERPREFERENCEPAGE_H_ - -#include "berryIQtPreferencePage.h" -#include -#include - -class QWidget; -class QCheckBox; - -struct MITK_QT_DATAMANAGER QmitkDataManagerPreferencePage : public QObject, public berry::IQtPreferencePage -{ - Q_OBJECT - Q_INTERFACES(berry::IPreferencePage) - -public: - QmitkDataManagerPreferencePage(); - QmitkDataManagerPreferencePage(const QmitkDataManagerPreferencePage& other); - - void Init(berry::IWorkbench::Pointer workbench); - - void CreateQtControl(QWidget* widget); - - QWidget* GetQtControl() const; - - /// - /// \see IPreferencePage::PerformOk() - /// - virtual bool PerformOk(); - - /// - /// \see IPreferencePage::PerformCancel() - /// - virtual void PerformCancel(); - - /// - /// \see IPreferencePage::Update() - /// - virtual void Update(); - -protected: - QWidget* m_MainControl; - QCheckBox* m_EnableSingleEditing; - QCheckBox* m_PlaceNewNodesOnTop; - QCheckBox* m_ShowHelperObjects; - QCheckBox* m_ShowNodesContainingNoData; - QCheckBox* m_UseSurfaceDecimation; - berry::IPreferences::Pointer m_DataManagerPreferencesNode; -}; - -#endif /* QMITKDATAMANAGERPREFERENCEPAGE_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp deleted file mode 100644 index 9e7f3b01e7..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp +++ /dev/null @@ -1,1037 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkDataManagerView.h" - -#include - -//# Own Includes -//## mitk -#include "mitkDataStorageEditorInput.h" -#include "mitkIDataStorageReference.h" -#include "mitkNodePredicateDataType.h" -#include "mitkCoreObjectFactory.h" -#include "mitkPACSPlugin.h" -#include "mitkDataNodeFactory.h" -#include "mitkColorProperty.h" -#include "mitkCommon.h" -#include "mitkDelegateManager.h" -#include "mitkNodePredicateData.h" -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" -#include "mitkEnumerationProperty.h" -#include "mitkProperties.h" -#include -#include -#include -//## Qmitk -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/internal/QmitkNodeTableViewKeyFilter.h" -#include "src/internal/QmitkInfoDialog.h" -//## Berry -#include -#include -#include -#include - -//# Toolkit Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mitkDataNodeObject.h" -#include "mitkIContextMenuAction.h" -#include "berryIExtensionPointService.h" - -const std::string QmitkDataManagerView::VIEW_ID = "org.mitk.views.datamanager"; - -QmitkDataManagerView::QmitkDataManagerView() -{ -} - -QmitkDataManagerView::QmitkDataManagerView(const QmitkDataManagerView& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - - -QmitkDataManagerView::~QmitkDataManagerView() -{ - berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); - if(s) - s->RemoveSelectionListener(m_SelectionListener); - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - - berry::IBerryPreferences::Pointer prefs - = (prefService->GetSystemPreferences()->Node(VIEW_ID)) - .Cast(); - prefs->OnChanged.RemoveListener( berry::MessageDelegate1( this - , &QmitkDataManagerView::OnPreferencesChanged ) ); -} - -void QmitkDataManagerView::CreateQtPartControl(QWidget* parent) -{ - m_CurrentRowCount = 0; - m_Parent = parent; - //# Preferences - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - - berry::IBerryPreferences::Pointer prefs - = (prefService->GetSystemPreferences()->Node(VIEW_ID)) - .Cast(); - assert( prefs ); - prefs->OnChanged.AddListener( berry::MessageDelegate1( this - , &QmitkDataManagerView::OnPreferencesChanged ) ); - - //# GUI - m_NodeTreeModel = new QmitkDataStorageTreeModel(this->GetDataStorage()); - m_NodeTreeModel->setParent( parent ); - m_NodeTreeModel->SetPlaceNewNodesOnTop( - prefs->GetBool("Place new nodes on top", true) ); - m_NodeTreeModel->SetShowHelperObjects( - prefs->GetBool("Show helper objects", false) ); - m_NodeTreeModel->SetShowNodesContainingNoData( - prefs->GetBool("Show nodes containing no data", false) ); - m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); - - //# Tree View (experimental) - m_NodeTreeView = new QTreeView; - m_NodeTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection ); - m_NodeTreeView->setSelectionBehavior( QAbstractItemView::SelectRows ); - m_NodeTreeView->setAlternatingRowColors(true); - m_NodeTreeView->setDragEnabled(true); - m_NodeTreeView->setDropIndicatorShown(true); - m_NodeTreeView->setAcceptDrops(true); - m_NodeTreeView->setContextMenuPolicy(Qt::CustomContextMenu); - m_NodeTreeView->setModel(m_NodeTreeModel); - m_NodeTreeView->installEventFilter(new QmitkNodeTableViewKeyFilter(this)); - QObject::connect( m_NodeTreeView, SIGNAL(customContextMenuRequested(const QPoint&)) - , this, SLOT(NodeTableViewContextMenuRequested(const QPoint&)) ); - QObject::connect( m_NodeTreeModel, SIGNAL(rowsInserted (const QModelIndex&, int, int)) - , this, SLOT(NodeTreeViewRowsInserted ( const QModelIndex&, int, int )) ); - QObject::connect( m_NodeTreeModel, SIGNAL(rowsRemoved (const QModelIndex&, int, int)) - , this, SLOT(NodeTreeViewRowsRemoved( const QModelIndex&, int, int )) ); - QObject::connect( m_NodeTreeView->selectionModel() - , SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection & ) ) - , this - , SLOT( NodeSelectionChanged ( const QItemSelection &, const QItemSelection & ) ) ); - - //# m_NodeMenu - m_NodeMenu = new QMenu(m_NodeTreeView); - - //# m_SelectionProvider - m_SelectionProvider = new QmitkDataNodeSelectionProvider(); - m_SelectionProvider->SetItemSelectionModel(m_NodeTreeView->selectionModel()); - this->GetSite()->SetSelectionProvider(m_SelectionProvider); - - // # Actions - QmitkNodeDescriptor* unknownDataNodeDescriptor = - QmitkNodeDescriptorManager::GetInstance()->GetUnknownDataNodeDescriptor(); - - QmitkNodeDescriptor* imageDataNodeDescriptor = - QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Image"); - - QmitkNodeDescriptor* surfaceDataNodeDescriptor = - QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Surface"); - - m_GlobalReinitAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"), "Global Reinit", this); - QObject::connect( m_GlobalReinitAction, SIGNAL( triggered(bool) ) - , this, SLOT( GlobalReinit(bool) ) ); - unknownDataNodeDescriptor->AddAction(m_GlobalReinitAction); - - m_SaveAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Save_48.png"), "Save...", this); - QObject::connect( m_SaveAction, SIGNAL( triggered(bool) ) - , this, SLOT( SaveSelectedNodes(bool) ) ); - unknownDataNodeDescriptor->AddAction(m_SaveAction); - - m_RemoveAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Remove_48.png"), "Remove", this); - QObject::connect( m_RemoveAction, SIGNAL( triggered(bool) ) - , this, SLOT( RemoveSelectedNodes(bool) ) ); - unknownDataNodeDescriptor->AddAction(m_RemoveAction); - - m_ReinitAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"), "Reinit", this); - QObject::connect( m_ReinitAction, SIGNAL( triggered(bool) ) - , this, SLOT( ReinitSelectedNodes(bool) ) ); - unknownDataNodeDescriptor->AddAction(m_ReinitAction); - - // find contextMenuAction extension points and add them to the node descriptor - berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); - berry::IConfigurationElement::vector cmActions( - extensionPointService->GetConfigurationElementsFor("org.mitk.gui.qt.datamanager.contextMenuActions") ); - berry::IConfigurationElement::vector::iterator cmActionsIt; - - std::string cmNodeDescriptorName; - std::string cmLabel; - std::string cmIcon; - std::string cmClass; - - QmitkNodeDescriptor* tmpDescriptor; - QAction* contextMenuAction; - QVariant cmActionDataIt; - m_ConfElements.clear(); - - int i=1; - for (cmActionsIt = cmActions.begin() - ; cmActionsIt != cmActions.end() - ; ++cmActionsIt) - { - cmIcon.erase(); - if((*cmActionsIt)->GetAttribute("nodeDescriptorName", cmNodeDescriptorName) - && (*cmActionsIt)->GetAttribute("label", cmLabel) - && (*cmActionsIt)->GetAttribute("class", cmClass)) - { - (*cmActionsIt)->GetAttribute("icon", cmIcon); - // create context menu entry here - tmpDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(QString::fromStdString(cmNodeDescriptorName)); - if(!tmpDescriptor) - { - MITK_WARN << "cannot add action \"" << cmLabel << "\" because descriptor " << cmNodeDescriptorName << " does not exist"; - continue; - } - contextMenuAction = new QAction( QString::fromStdString(cmLabel), parent); - tmpDescriptor->AddAction(contextMenuAction); - m_ConfElements[contextMenuAction] = *cmActionsIt; - - cmActionDataIt.setValue(i); - contextMenuAction->setData( cmActionDataIt ); - connect( contextMenuAction, SIGNAL( triggered(bool) ) , this, SLOT( ContextMenuActionTriggered(bool) ) ); - ++i; - } - } - - m_OpacitySlider = new QSlider; - m_OpacitySlider->setMinimum(0); - m_OpacitySlider->setMaximum(100); - m_OpacitySlider->setOrientation(Qt::Horizontal); - QObject::connect( m_OpacitySlider, SIGNAL( valueChanged(int) ) - , this, SLOT( OpacityChanged(int) ) ); - - QLabel* _OpacityLabel = new QLabel("Opacity: "); - QHBoxLayout* _OpacityWidgetLayout = new QHBoxLayout; - _OpacityWidgetLayout->setContentsMargins(4,4,4,4); - _OpacityWidgetLayout->addWidget(_OpacityLabel); - _OpacityWidgetLayout->addWidget(m_OpacitySlider); - QWidget* _OpacityWidget = new QWidget; - _OpacityWidget->setLayout(_OpacityWidgetLayout); - - m_OpacityAction = new QWidgetAction(this); - m_OpacityAction->setDefaultWidget(_OpacityWidget); - QObject::connect( m_OpacityAction, SIGNAL( changed() ) - , this, SLOT( OpacityActionChanged() ) ); - unknownDataNodeDescriptor->AddAction(m_OpacityAction, false); - - m_ColorButton = new QPushButton; - m_ColorButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); - //m_ColorButton->setText("Change color"); - QObject::connect( m_ColorButton, SIGNAL( clicked() ) - , this, SLOT( ColorChanged() ) ); - - QLabel* _ColorLabel = new QLabel("Color: "); - _ColorLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); - QHBoxLayout* _ColorWidgetLayout = new QHBoxLayout; - _ColorWidgetLayout->setContentsMargins(4,4,4,4); - _ColorWidgetLayout->addWidget(_ColorLabel); - _ColorWidgetLayout->addWidget(m_ColorButton); - QWidget* _ColorWidget = new QWidget; - _ColorWidget->setLayout(_ColorWidgetLayout); - - m_ColorAction = new QWidgetAction(this); - m_ColorAction->setDefaultWidget(_ColorWidget); - QObject::connect( m_ColorAction, SIGNAL( changed() ) - , this, SLOT( ColorActionChanged() ) ); - unknownDataNodeDescriptor->AddAction(m_ColorAction, false); - - m_TextureInterpolation = new QAction("Texture Interpolation", this); - m_TextureInterpolation->setCheckable ( true ); - QObject::connect( m_TextureInterpolation, SIGNAL( changed() ) - , this, SLOT( TextureInterpolationChanged() ) ); - QObject::connect( m_TextureInterpolation, SIGNAL( toggled(bool) ) - , this, SLOT( TextureInterpolationToggled(bool) ) ); - imageDataNodeDescriptor->AddAction(m_TextureInterpolation, false); - - m_SurfaceRepresentation = new QAction("Surface Representation", this); - m_SurfaceRepresentation->setMenu(new QMenu); - - QObject::connect( m_SurfaceRepresentation->menu(), SIGNAL( aboutToShow() ) - , this, SLOT( SurfaceRepresentationMenuAboutToShow() ) ); - surfaceDataNodeDescriptor->AddAction(m_SurfaceRepresentation, false); - - m_ShowOnlySelectedNodes - = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/ShowSelectedNode_48.png") - , "Show only selected nodes", this); - QObject::connect( m_ShowOnlySelectedNodes, SIGNAL( triggered(bool) ) - , this, SLOT( ShowOnlySelectedNodes(bool) ) ); - unknownDataNodeDescriptor->AddAction(m_ShowOnlySelectedNodes); - - m_ToggleSelectedVisibility - = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/InvertShowSelectedNode_48.png") - , "Toggle visibility", this); - QObject::connect( m_ToggleSelectedVisibility, SIGNAL( triggered(bool) ) - , this, SLOT( ToggleVisibilityOfSelectedNodes(bool) ) ); - unknownDataNodeDescriptor->AddAction(m_ToggleSelectedVisibility); - - m_ActionShowInfoDialog - = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/ShowDataInfo_48.png") - , "Details...", this); - QObject::connect( m_ActionShowInfoDialog, SIGNAL( triggered(bool) ) - , this, SLOT( ShowInfoDialogForSelectedNodes(bool) ) ); - unknownDataNodeDescriptor->AddAction(m_ActionShowInfoDialog); - - m_OtsuFilterAction = new QAction("Apply Otsu Filter", this); - QObject::connect( m_OtsuFilterAction, SIGNAL( triggered(bool) ) - , this, SLOT( OtsuFilter(bool) ) ); - // Otsu filter does not work properly, remove it temporarily - // imageDataNodeDescriptor->AddAction(m_OtsuFilterAction); - - QGridLayout* _DndFrameWidgetLayout = new QGridLayout; - _DndFrameWidgetLayout->addWidget(m_NodeTreeView, 0, 0); - _DndFrameWidgetLayout->setContentsMargins(0,0,0,0); - - m_DndFrameWidget = new QmitkDnDFrameWidget(m_Parent); - m_DndFrameWidget->setLayout(_DndFrameWidgetLayout); - - QVBoxLayout* layout = new QVBoxLayout(parent); - layout->addWidget(m_DndFrameWidget); - layout->setContentsMargins(0,0,0,0); - - m_Parent->setLayout(layout); - - m_SelectionListener = new berry::SelectionChangedAdapter - (this, &QmitkDataManagerView::SelectionChanged); - - berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); - s->AddSelectionListener(m_SelectionListener); - -} - -void QmitkDataManagerView::SetFocus() -{ -} - -void QmitkDataManagerView::ContextMenuActionTriggered( bool ) -{ - QAction* action = qobject_cast ( sender() ); - - std::map::iterator it - = m_ConfElements.find( action ); - if( it == m_ConfElements.end() ) - { - MITK_WARN << "associated conf element for action " << action->text().toStdString() << " not found"; - return; - } - berry::IConfigurationElement::Pointer confElem = it->second; - mitk::IContextMenuAction* contextMenuAction = confElem->CreateExecutableExtension("class"); - if (contextMenuAction == 0) - { - // support legacy BlueBerry extensions - contextMenuAction = confElem->CreateExecutableExtension("class", mitk::IContextMenuAction::GetManifestName()); - } - std::string className; - std::string smoothed; - confElem->GetAttribute("class", className); - confElem->GetAttribute("smoothed", smoothed); - if(className == "QmitkThresholdAction") - { - contextMenuAction->SetDataStorage(this->GetDataStorage()); - } - if(className == "QmitkCreatePolygonModelAction") - { - contextMenuAction->SetDataStorage(this->GetDataStorage()); - QmitkStdMultiWidget* activeStdMultiWidget = 0; - berry::IEditorPart::Pointer editor = - this->GetSite()->GetPage()->GetActiveEditor(); - - if (editor.Cast().IsNotNull()) - { - activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); - } - else - { - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(); - // open a new multi-widget editor, but do not give it the focus - berry::IEditorPart::Pointer editor = this->GetSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID, false); - activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); - } - - contextMenuAction->SetStdMultiWidget(activeStdMultiWidget); - if(smoothed == "false") - { - contextMenuAction->SetSmoothed(false); - } - else - { - contextMenuAction->SetSmoothed(true); - } - contextMenuAction->SetDecimated(m_SurfaceDecimation); - } - if(className == "QmitkStatisticsAction") - { - contextMenuAction->SetFunctionality(this); - } - contextMenuAction->Run( this->GetSelectedNodes() ); // run the action -} - -mitk::DataStorage::Pointer QmitkDataManagerView::GetDataStorage() const -{ - mitk::IDataStorageService::Pointer service = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); - - if (service.IsNotNull()) - { - return service->GetDefaultDataStorage()->GetDataStorage(); - } - - return 0; -} - -void QmitkDataManagerView::OnPreferencesChanged(const berry::IBerryPreferences* prefs) -{ - if( m_NodeTreeModel->GetPlaceNewNodesOnTopFlag() != prefs->GetBool("Place new nodes on top", true) ) - m_NodeTreeModel->SetPlaceNewNodesOnTop( !m_NodeTreeModel->GetPlaceNewNodesOnTopFlag() ); - - if( m_NodeTreeModel->GetShowHelperObjectsFlag()!= prefs->GetBool("Show helper objects", false) ) - m_NodeTreeModel->SetShowHelperObjects( !m_NodeTreeModel->GetShowHelperObjectsFlag() ); - - if( m_NodeTreeModel->GetShowNodesContainingNoDataFlag()!= prefs->GetBool("Show nodes containing no data", false) ) - m_NodeTreeModel->SetShowNodesContainingNoData( !m_NodeTreeModel->GetShowNodesContainingNoDataFlag() ); - - m_NodeTreeView->expandAll(); - - m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); - - this->GlobalReinit(); - - -} - -void QmitkDataManagerView::NodeTableViewContextMenuRequested( const QPoint & pos ) -{ - QModelIndex selected = m_NodeTreeView->indexAt ( pos ); - mitk::DataNode::Pointer node = m_NodeTreeModel->GetNode(selected); - std::vector selectedNodes = this->GetSelectedNodes(); - - if(!selectedNodes.empty()) - { - m_NodeMenu->clear(); - QList actions; - if(selectedNodes.size() == 1 ) - { - actions = QmitkNodeDescriptorManager::GetInstance()->GetActions(node); - - for(QList::iterator it = actions.begin(); it != actions.end(); ++it) - { - (*it)->setData(QVariant::fromValue(node.GetPointer())); - } - } - else - actions = QmitkNodeDescriptorManager::GetInstance()->GetActions(selectedNodes); - - m_NodeMenu->addActions(actions); - m_NodeMenu->popup(QCursor::pos()); - } -} - -void QmitkDataManagerView::OpacityChanged(int value) -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(node) - { - float opacity = static_cast(value)/100.0f; - node->SetFloatProperty("opacity", opacity); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - - MITK_INFO << "slider changed"; -} - -void QmitkDataManagerView::OpacityActionChanged() -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(node) - { - float opacity = 0.0; - if(node->GetFloatProperty("opacity", opacity)) - { - m_OpacitySlider->setValue(static_cast(opacity*100)); - } - } - MITK_INFO << "changed"; -} - -void QmitkDataManagerView::ColorChanged() -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(node) - { - QColor color = QColorDialog::getColor(); - m_ColorButton->setAutoFillBackground(true); - node->SetProperty("color",mitk::ColorProperty::New(color.red()/255.0,color.green()/255.0,color.blue()/255.0)); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - - MITK_INFO << "slider changed"; -} - -void QmitkDataManagerView::ColorActionChanged() -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(node) - { - mitk::Color color; - mitk::ColorProperty::Pointer colorProp; - node->GetProperty(colorProp,"color"); - if(colorProp.IsNull()) - return; - color = colorProp->GetValue(); - - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color[0]*255)); - styleSheet.append(","); - styleSheet.append(QString::number(color[1]*255)); - styleSheet.append(","); - styleSheet.append(QString::number(color[2]*255)); - styleSheet.append(")"); - m_ColorButton->setStyleSheet(styleSheet); - } - MITK_INFO << "changed"; -} - -void QmitkDataManagerView::TextureInterpolationChanged() -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(node) - { - bool textureInterpolation = false; - node->GetBoolProperty("texture interpolation", textureInterpolation); - m_TextureInterpolation->setChecked(textureInterpolation); - } -} - -void QmitkDataManagerView::TextureInterpolationToggled( bool checked ) -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(node) - { - node->SetBoolProperty("texture interpolation", checked); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - -} - -void QmitkDataManagerView::SurfaceRepresentationMenuAboutToShow() -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(!node) - return; - - mitk::EnumerationProperty* representationProp = - dynamic_cast (node->GetProperty("material.representation")); - if(!representationProp) - return; - - // clear menu - m_SurfaceRepresentation->menu()->clear(); - QAction* tmp; - - // create menu entries - for(mitk::EnumerationProperty::EnumConstIterator it=representationProp->Begin(); it!=representationProp->End() - ; it++) - { - tmp = m_SurfaceRepresentation->menu()->addAction(QString::fromStdString(it->second)); - tmp->setCheckable(true); - - if(it->second == representationProp->GetValueAsString()) - { - tmp->setChecked(true); - } - - QObject::connect( tmp, SIGNAL( triggered(bool) ) - , this, SLOT( SurfaceRepresentationActionToggled(bool) ) ); - } -} - -void QmitkDataManagerView::SurfaceRepresentationActionToggled( bool /*checked*/ ) -{ - mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); - if(!node) - return; - - mitk::EnumerationProperty* representationProp = - dynamic_cast (node->GetProperty("material.representation")); - if(!representationProp) - return; - - QAction* senderAction = qobject_cast ( QObject::sender() ); - - if(!senderAction) - return; - - std::string activatedItem = senderAction->text().toStdString(); - - if ( activatedItem != representationProp->GetValueAsString() ) - { - if ( representationProp->IsValidEnumerationValue( activatedItem ) ) - { - representationProp->SetValue( activatedItem ); - representationProp->InvokeEvent( itk::ModifiedEvent() ); - representationProp->Modified(); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - } - -} - -void QmitkDataManagerView::SaveSelectedNodes( bool ) -{ - QModelIndexList indexesOfSelectedRows = m_NodeTreeView->selectionModel()->selectedRows(); - - mitk::DataNode* node = 0; - unsigned int indexesOfSelectedRowsSize = indexesOfSelectedRows.size(); - for (unsigned int i = 0; iGetNode(indexesOfSelectedRows.at(i)); - // if node is not defined or if the node contains geometry data do not remove it - if ( node != 0 ) - { - mitk::BaseData::Pointer data = node->GetData(); - if (data.IsNotNull()) - { - QString error; - try - { - CommonFunctionality::SaveBaseData( data.GetPointer(), node->GetName().c_str() ); - } - catch(std::exception& e) - { - error = e.what(); - } - catch(...) - { - error = "Unknown error occured"; - } - if( !error.isEmpty() ) - QMessageBox::critical( m_Parent, "Error saving...", error ); - } - } - } -} - -void QmitkDataManagerView::ReinitSelectedNodes( bool ) -{ - this->ReinitMultiWidgetEditor(); - std::vector selectedNodes = this->GetSelectedNodes(); - - mitk::DataNode* node = 0; - for (std::vector::iterator it = selectedNodes.begin() - ; it != selectedNodes.end(); it++) - { - node = *it; - mitk::BaseData::Pointer basedata = node->GetData(); - if (basedata.IsNotNull()) - { - mitk::RenderingManager::GetInstance()->InitializeViews( - basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - } -} - -void QmitkDataManagerView::RemoveSelectedNodes( bool ) -{ - QModelIndexList indexesOfSelectedRows = m_NodeTreeView->selectionModel()->selectedRows(); - if(indexesOfSelectedRows.size() < 1) - { - return; - } - std::vector selectedNodes; - - mitk::DataNode* node = 0; - QString question = tr("Do you really want to remove "); - - for (QModelIndexList::iterator it = indexesOfSelectedRows.begin() - ; it != indexesOfSelectedRows.end(); it++) - { - node = m_NodeTreeModel->GetNode(*it); - // if node is not defined or if the node contains geometry data do not remove it - if ( node != 0 /*& strcmp(node->GetData()->GetNameOfClass(), "Geometry2DData") != 0*/ ) - { - selectedNodes.push_back(node); - question.append(QString::fromStdString(node->GetName())); - question.append(", "); - } - } - // remove the last two characters = ", " - question = question.remove(question.size()-2, 2); - question.append(" from data storage?"); - - QMessageBox::StandardButton answerButton = QMessageBox::question( m_Parent - , tr("DataManager") - , question - , QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - - if(answerButton == QMessageBox::Yes) - { - for (std::vector::iterator it = selectedNodes.begin() - ; it != selectedNodes.end(); it++) - { - node = *it; - this->GetDataStorage()->Remove(node); - this->GlobalReinit(false); - } - } -} - -void QmitkDataManagerView::MakeAllNodesInvisible( bool ) -{ - std::vector nodes = m_NodeTreeModel->GetNodeSet(); - - for (std::vector::iterator it = nodes.begin() - ; it != nodes.end(); it++) - { - (*it)->SetVisibility(false); - } - //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkDataManagerView::ShowOnlySelectedNodes( bool ) -{ - std::vector selectedNodes = this->GetSelectedNodes(); - std::vector allNodes = m_NodeTreeModel->GetNodeSet(); - mitk::DataNode* node = 0; - - for (std::vector::iterator it = allNodes.begin() - ; it != allNodes.end(); it++) - { - node = *it; - if(std::find(selectedNodes.begin(), selectedNodes.end(), node) == selectedNodes.end()) - node->SetVisibility(false); - else - node->SetVisibility(true); - } - //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkDataManagerView::ToggleVisibilityOfSelectedNodes( bool ) -{ - std::vector selectedNodes = this->GetSelectedNodes(); - - bool isVisible = false; - mitk::DataNode* node = 0; - for (std::vector::iterator it = selectedNodes.begin() - ; it != selectedNodes.end(); it++) - { - isVisible = false; - node = *it; - node->GetBoolProperty("visible", isVisible); - node->SetVisibility(!isVisible); - } - //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkDataManagerView::ShowInfoDialogForSelectedNodes( bool ) -{ - std::vector selectedNodes = this->GetSelectedNodes(); - - QmitkInfoDialog _QmitkInfoDialog(selectedNodes, this->m_Parent); - _QmitkInfoDialog.exec(); -} - -void QmitkDataManagerView::Load( bool ) -{ - QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Load data", "", mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); - for ( QStringList::Iterator it = fileNames.begin(); it != fileNames.end(); ++it ) - { - FileOpen((*it).toAscii(), 0); - } -} - -void QmitkDataManagerView::FileOpen( const char * fileName, mitk::DataNode* parentNode ) -{ - mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); - - try - { - factory->SetFileName( fileName ); - - QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); - - factory->Update(); - - for ( unsigned int i = 0 ; i < factory->GetNumberOfOutputs( ); ++i ) - { - mitk::DataNode::Pointer node = factory->GetOutput( i ); - if ( ( node.IsNotNull() ) && ( node->GetData() != NULL ) ) - { - this->GetDataStorage()->Add(node, parentNode); - mitk::BaseData::Pointer basedata = node->GetData(); - mitk::RenderingManager::GetInstance()->InitializeViews( - basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } - } - } - catch ( itk::ExceptionObject & ex ) - { - itkGenericOutputMacro( << "Exception during file open: " << ex ); - } - - QApplication::restoreOverrideCursor(); -} - -void QmitkDataManagerView::GlobalReinit( bool ) -{ - this->ReinitMultiWidgetEditor(); - // 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::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible"); - - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); -} - -std::vector QmitkDataManagerView::GetSelectedNodes() const -{ - QModelIndexList indexesOfSelectedRows = m_NodeTreeView->selectionModel()->selectedRows(); - std::vector selectedNodes; - - mitk::DataNode* node = 0; - for (QModelIndexList::iterator it = indexesOfSelectedRows.begin() - ; it != indexesOfSelectedRows.end(); it++) - { - node = 0; - node = m_NodeTreeModel->GetNode(*it); - // if node is not defined or if the node contains geometry data do not remove it - if ( node != 0 ) - selectedNodes.push_back(node); - } - - return selectedNodes; -} - -void QmitkDataManagerView::SelectionChanged( berry::IWorkbenchPart::Pointer part , berry::ISelection::ConstPointer selection ) -{ - if(part.GetPointer() == this) - return; - mitk::DataNodeSelection::ConstPointer _DataNodeSelection - = selection.Cast(); - - if(_DataNodeSelection.IsNull()) - return; - - std::vector selectedNodes; - mitk::DataNodeObject* _DataNodeObject = 0; - mitk::DataNode* _DataNode = 0; - QItemSelection newSelection; - - m_NodeTreeView->selectionModel()->reset(); - - for(mitk::DataNodeSelection::iterator it = _DataNodeSelection->Begin(); - it != _DataNodeSelection->End(); ++it) - { - _DataNodeObject = dynamic_cast((*it).GetPointer()); - if(_DataNodeObject) - _DataNode = _DataNodeObject->GetDataNode(); - QModelIndex treeIndex = m_NodeTreeModel->GetIndex(_DataNode); - if(treeIndex.isValid()) - newSelection.select(treeIndex, treeIndex); - } - m_NodeTreeView->selectionModel()->select(newSelection, QItemSelectionModel::SelectCurrent); -} - -void QmitkDataManagerView::OtsuFilter( bool ) -{ - std::vector selectedNodes = this->GetSelectedNodes(); - - mitk::DataNode* _DataNode = 0; - mitk::Image::Pointer mitkImage = 0; - for (std::vector::iterator it = selectedNodes.begin() - ; it != selectedNodes.end(); it++) - { - _DataNode = *it; - mitkImage = dynamic_cast( _DataNode->GetData() ); - - if(mitkImage.IsNull()) - continue; - - try - { - // get selected mitk image - const unsigned short dim = 3; - typedef short InputPixelType; - typedef unsigned char OutputPixelType; - - typedef itk::Image< InputPixelType, dim > InputImageType; - typedef itk::Image< OutputPixelType, dim > OutputImageType; - - typedef itk::OtsuThresholdImageFilter< InputImageType, OutputImageType > FilterType; - FilterType::Pointer filter = FilterType::New(); - - filter->SetOutsideValue( 1 ); - filter->SetInsideValue( 0 ); - - InputImageType::Pointer itkImage; - mitk::CastToItkImage(mitkImage, itkImage); - - filter->SetInput( itkImage ); - - filter->Update(); - - mitk::DataNode::Pointer resultNode = mitk::DataNode::New(); - std::string nameOfResultImage = _DataNode->GetName(); - nameOfResultImage.append("Otsu"); - resultNode->SetProperty("name", mitk::StringProperty::New(nameOfResultImage) ); - resultNode->SetProperty("binary", mitk::BoolProperty::New(true) ); - resultNode->SetData( mitk::ImportItkImage ( filter->GetOutput() ) ); - - this->GetDataStorage()->Add(resultNode, _DataNode); - - } - catch( std::exception& err ) - { - MITK_ERROR(this->GetClassName()) << err.what(); - } - - } -} -void QmitkDataManagerView::NodeTreeViewRowsRemoved ( - const QModelIndex & parent, int start, int end ) -{ - m_CurrentRowCount = m_NodeTreeModel->rowCount(); -} -void QmitkDataManagerView::NodeTreeViewRowsInserted( const QModelIndex & parent, int, int ) -{ - m_NodeTreeView->setExpanded(parent, true); - - // a new row was inserted - if( m_CurrentRowCount == 0 && m_NodeTreeModel->rowCount() == 1 ) - { - this->ReinitMultiWidgetEditor(); - m_CurrentRowCount = m_NodeTreeModel->rowCount(); - /* - std::vector nodes = m_NodeTreeModel->GetNodeSet(); - if(nodes.size() == 1) - { - QModelIndex treeIndex = m_NodeTreeModel->GetIndex(nodes.front()); - m_NodeTreeView->selectionModel()->setCurrentIndex( treeIndex, QItemSelectionModel::ClearAndSelect ); - } - */ - } -} - -void QmitkDataManagerView::NodeSelectionChanged( const QItemSelection & /*selected*/, const QItemSelection & /*deselected*/ ) -{ - std::vector nodes = m_NodeTreeModel->GetNodeSet(); - mitk::DataNode* node = 0; - - for (std::vector::iterator it = nodes.begin() - ; it != nodes.end(); it++) - { - node = *it; - if ( node ) - node->SetBoolProperty("selected", false); - } - - nodes.clear(); - nodes = this->GetSelectedNodes(); - - for (std::vector::iterator it = nodes.begin() - ; it != nodes.end(); it++) - { - node = *it; - if ( node ) - node->SetBoolProperty("selected", true); - } - //changing the selection does NOT require any rendering processes! - //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkDataManagerView::ReinitMultiWidgetEditor() -{ - berry::IEditorPart::Pointer editor; - std::vector editors = - this->GetSite()->GetPage()->GetEditors(); - for (size_t i=0; i().IsNotNull() ) - { - editor = editors.at(i); - break; - } - } - - if ( editor.IsNull() ) - { - mitk::IDataStorageService::Pointer service = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); - - mitk::IDataStorageReference::Pointer DataStorageReference; - if (service.IsNotNull()) - { - DataStorageReference = service->GetDefaultDataStorage(); - } - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(DataStorageReference); - // open a new multi-widget editor, but do not give it the focus - berry::IEditorPart::Pointer editor = this->GetSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID, false); - } - else - this->GetSite()->GetPage()->OpenEditor(editor->GetEditorInput() - , QmitkStdMultiWidgetEditor::EDITOR_ID, true); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h deleted file mode 100644 index 0d941cb85c..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h +++ /dev/null @@ -1,272 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKDATAMANAGERVIEW_H_ -#define QMITKDATAMANAGERVIEW_H_ - -// Own includes -#include -#include -#include -#include -#include -#include - -/// Qmitk -#include -#include -#include - -#include -#include -#include - -#include -#include - -// Forward declarations -class QMenu; -class QAction; -class QComboBox; -class QWidgetAction; -class QSlider; -class QModelIndex; -class QTreeView; -class QPushButton; -class QToolBar; -class QMenu; - -class QmitkDataStorageTreeModel; -/// -/// \ingroup org_mitk_gui_qt_datamanager_internal -/// -/// \brief A View class that can show all data tree nodes of a certain DataStorage -/// -/// \TODO: complete PACS support, in save dialog show regular filename -/// -class MITK_QT_DATAMANAGER QmitkDataManagerView : public berry::QtViewPart -{ - Q_OBJECT - -public: - - static const std::string VIEW_ID; // = "org.mitk.extapp.defaultperspective" - /// - /// \brief Standard ctor. - /// - QmitkDataManagerView(); - - QmitkDataManagerView(const QmitkDataManagerView& other); - - /// - /// \brief Standard dtor. - /// - virtual ~QmitkDataManagerView(); - /// - /// \brief Returns all selected nodes in a vector - /// - std::vector GetSelectedNodes() const; - -public slots: - /// - /// Invoked when the opacity slider changed - /// - void OpacityChanged(int value); - /// - /// Invoked when the opacity action changed - /// In this function the the opacity slider is set to the selected nodes opacity value - /// - void OpacityActionChanged(); - /// - /// Invoked when the color button is pressed - /// - void ColorChanged(); - /// - /// Invoked when the color action changed - /// - void ColorActionChanged(); - /// - /// Invoked when the color button is pressed - /// - void TextureInterpolationChanged(); - /// - /// Invoked when the color action changed - /// - void TextureInterpolationToggled ( bool checked ); - /// - /// SurfaceRepresentationActionToggled - /// - void SurfaceRepresentationMenuAboutToShow (); - ///public - /// SurfaceRepresentationActionToggled - /// - void SurfaceRepresentationActionToggled ( bool checked ); - /// - /// \brief Shows a node context menu. - /// - void NodeTableViewContextMenuRequested( const QPoint & index ); - /// - /// \brief Invoked when an element should be saved. - /// - void SaveSelectedNodes( bool checked = false ); - /// - /// \brief Invoked when an element should be removed. - /// - void RemoveSelectedNodes( bool checked = false ); - /// - /// \brief Invoked when an element should be reinitiliased. - /// - void ReinitSelectedNodes( bool checked = false ); - /// - /// \brief Invoked when the visibility of the selected nodes should be toggled. - /// - void MakeAllNodesInvisible ( bool checked = false ); - /// - /// \brief Makes all selected nodes visible, all other nodes invisible. - /// - void ShowOnlySelectedNodes ( bool checked = false ); - /// - /// \brief Invoked when the visibility of the selected nodes should be toggled. - /// - void ToggleVisibilityOfSelectedNodes ( bool checked = false ); - /// - /// \brief Invoked when infos of the selected nodes should be shown in a dialog. - /// - void ShowInfoDialogForSelectedNodes ( bool checked = false ); - /// - /// \brief Shows a load dialog. - /// - void Load ( bool checked = false ); - /// - /// \brief Reinits everything. - /// - void GlobalReinit ( bool checked = false ); - /// - /// Invoked when the preferences were changed - /// - void OnPreferencesChanged(const berry::IBerryPreferences*); - /// - /// \brief will be toggled when a extension point context menu action is toggled - /// this is a proxy method which will load the corresponding extension class - /// and run IContextMenuAction - /// - void ContextMenuActionTriggered( bool ); - - /// - /// Invoked when the DataManager selection changed - /// - virtual void SelectionChanged(berry::IWorkbenchPart::Pointer part - , berry::ISelection::ConstPointer selection); - - /// Invoked when the median action is invoked - void OtsuFilter( bool checked = false ); - - /// When rows are inserted auto expand them - void NodeTreeViewRowsInserted ( const QModelIndex & parent, int start, int end ); - - /// will setup m_CurrentRowCount - void NodeTreeViewRowsRemoved ( const QModelIndex & parent, int start, int end ); - - /// Whenever the selection changes set the "selected" property respectively - void NodeSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ); - -protected: - /// - /// \brief Create the view here. - /// - virtual void CreateQtPartControl(QWidget* parent); - void SetFocus(); - mitk::DataStorage::Pointer GetDataStorage() const; - /// - /// \brief Shows a file open dialog. - /// - void FileOpen( const char * fileName, mitk::DataNode* parentNode ); -protected: - QWidget* m_Parent; - QmitkDnDFrameWidget* m_DndFrameWidget; - - /// - /// \brief A plain widget as the base pane. - /// - QmitkDataStorageTreeModel* m_NodeTreeModel; - /// - /// \brief The BlueBerry selection provider - /// - QmitkDataNodeSelectionProvider::Pointer m_SelectionProvider; - /// - /// Holds the preferences for the datamanager. - /// - berry::IBerryPreferences::Pointer m_DataManagerPreferencesNode; - /// - /// saves the configuration elements for the context menu actions from extension points - /// - std::map m_ConfElements; - /// - /// \brief The Table view to show the selected nodes. - /// - QTreeView* m_NodeTreeView; - /// - /// \brief The context menu that shows up when right clicking on a node. - /// - QMenu* m_NodeMenu; - /// - /// \brief flag indicating whether a surface created from a selected decimation is decimated with vtkQuadricDecimation or not - /// - bool m_SurfaceDecimation; - - ///# Actions for the Context Menu - /// Global Reinit Action - QAction* m_GlobalReinitAction; - /// Save Action - QAction* m_SaveAction; - /// Remove Action - QAction* m_RemoveAction; - /// Reinit Action - QAction* m_ReinitAction; - /// A Slider widget to change the opacity of a node - QSlider* m_OpacitySlider; - /// Opacity action - QWidgetAction* m_OpacityAction; - /// button to change the color of a node - QPushButton* m_ColorButton; - /// Color action - QWidgetAction* m_ColorAction; - /// TextureInterpolation action - QAction* m_TextureInterpolation; - /// TextureInterpolation action - QAction* m_SurfaceRepresentation; - /// Show only selected nodes - QAction* m_ShowOnlySelectedNodes; - /// Toggles visibility of selected nodes - QAction* m_ToggleSelectedVisibility; - /// Shows infos for selected nodes - QAction* m_ActionShowInfoDialog; - - /// Special filter action for images - QAction* m_OtsuFilterAction; - /// A selection listener for datatreenode events - berry::ISelectionListener::Pointer m_SelectionListener; - /// berry::SelectionChangedAdapter must be a friend to call - friend struct berry::SelectionChangedAdapter; - /// saves the current amount of rows shown in the datamanager - size_t m_CurrentRowCount; -private: - /// Reopen multi widget editor if it has been closed - void ReinitMultiWidgetEditor(); -}; - -#endif /*QMITKDATAMANAGERVIEW_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp deleted file mode 100644 index 0b1a7ce057..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkInfoDialog.h" - -#include "QmitkDataStorageComboBox.h" - -#include - -#include -#include -#include -#include -#include -#include - -QmitkInfoDialog::QmitkInfoDialog( std::vector _Nodes, QWidget * parent /*= 0*/, Qt::WindowFlags f /*= 0 */ ) -: QDialog(parent, f) -{ - // DIM - QGridLayout* parentLayout = new QGridLayout; - QmitkDataStorageComboBox* _QmitkDataStorageComboBox = new QmitkDataStorageComboBox(this, true); - m_KeyWord = new QLineEdit; - m_KeyWord->installEventFilter(this); - m_SearchButton = new QPushButton("Search (F3)", this); - m_SearchButton->installEventFilter(this); - m_TextBrowser = new QTextBrowser(this); - QPushButton* _CancelButton = new QPushButton("Cancel", this); - - // SET - this->setMinimumSize(512, 512); - this->setLayout(parentLayout); - this->setSizeGripEnabled(true); - this->setModal(true); - - parentLayout->addWidget(_QmitkDataStorageComboBox, 0, 0, 1, 2); - parentLayout->addWidget(m_KeyWord, 1, 0); - parentLayout->addWidget(m_SearchButton, 1, 1); - parentLayout->addWidget(m_TextBrowser, 2, 0, 1, 2); - parentLayout->addWidget(_CancelButton, 3, 0, 1, 2); - - QObject::connect( _QmitkDataStorageComboBox, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ) - , this, SLOT( OnSelectionChanged( const mitk::DataNode* ) ) ); - - for (std::vector::iterator it = _Nodes.begin() - ; it != _Nodes.end(); it++) - { - _QmitkDataStorageComboBox->AddNode(*it); - } - - QObject::connect( m_KeyWord, SIGNAL( textChanged ( const QString & ) ) - , this, SLOT( KeyWordTextChanged(const QString &) ) ); - - QObject::connect( m_SearchButton, SIGNAL( clicked ( bool ) ) - , this, SLOT( OnSearchButtonClicked( bool ) ) ); - - QObject::connect( _CancelButton, SIGNAL( clicked ( bool ) ) - , this, SLOT( OnCancelButtonClicked( bool ) ) ); - - _CancelButton->setDefault(true); - -} - -void QmitkInfoDialog::OnSelectionChanged( const mitk::DataNode* node ) -{ - std::ostringstream s; - itk::Indent i(2); - mitk::BaseData* _BaseData = node->GetData(); - if(_BaseData) - _BaseData->Print(s, i); - m_TextBrowser->setPlainText(QString::fromStdString(s.str())); -} - -void QmitkInfoDialog::OnSearchButtonClicked( bool /*checked*/ /*= false */ ) -{ - QString keyWord = m_KeyWord->text(); - QString text = m_TextBrowser->toPlainText(); - - if(keyWord.isEmpty() || text.isEmpty()) - return; - - m_TextBrowser->find(keyWord); - m_SearchButton->setText("Search Next(F3)"); -} - -void QmitkInfoDialog::OnCancelButtonClicked( bool /*checked*/ /*= false */ ) -{ - this->done(0); -} - -bool QmitkInfoDialog::eventFilter( QObject *obj, QEvent *event ) -{ - if (event->type() == QEvent::KeyPress) - { - QKeyEvent *keyEvent = static_cast(event); - if(keyEvent->key() == Qt::Key_F3 || keyEvent->key() == Qt::Key_Return) - { - // trigger deletion of selected node(s) - this->OnSearchButtonClicked(true); - // return true: this means the delete key event is not send to the table - return true; - } - } - // standard event processing - return QObject::eventFilter(obj, event); -} - -void QmitkInfoDialog::KeyWordTextChanged(const QString & /*text*/) -{ - QTextCursor textCursor = m_TextBrowser->textCursor(); - textCursor.setPosition(0); - m_TextBrowser->setTextCursor(textCursor); - m_SearchButton->setText("Search (F3)"); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h deleted file mode 100644 index bfdd1cbdb1..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h +++ /dev/null @@ -1,56 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKINFODIALOG_H_ -#define QMITKINFODIALOG_H_ - -#include - -#include - -//class QmitkDataStorageComboBox; -namespace mitk -{ - class DataNode; -} -class QTextBrowser; -class QLineEdit; - -/// -/// A small class which "eats" all Del-Key-pressed events on the node table. -/// When the Del Key is pressed selected nodes should be removed. -/// -class QmitkInfoDialog : public QDialog -{ - Q_OBJECT - - public: - QmitkInfoDialog( std::vector _Nodes, QWidget * parent = 0, Qt::WindowFlags f = 0 ); - public slots: - void OnSelectionChanged(const mitk::DataNode*); - void OnSearchButtonClicked ( bool checked = false ); - void OnCancelButtonClicked ( bool checked = false ); - void KeyWordTextChanged(const QString & text); - protected: - bool eventFilter(QObject *obj, QEvent *event); - protected: - QLineEdit* m_KeyWord; - QPushButton* m_SearchButton; - QTextBrowser* m_TextBrowser; -}; - -#endif // QMITKINFODIALOG_H_ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.cpp b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.cpp deleted file mode 100644 index f8546b9e91..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include -#include -#include -#include -#include "QmitkPropertyListView.h" -#include -#include -#include -#include - -const std::string QmitkPropertyListView::VIEW_ID = "org.mitk.views.propertylistview"; - -QmitkPropertyListView::QmitkPropertyListView() -{ -} - -QmitkPropertyListView::QmitkPropertyListView(const QmitkPropertyListView& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -QmitkPropertyListView::~QmitkPropertyListView() -{ -} - -void QmitkPropertyListView::CreateQtPartControl( QWidget* parent ) -{ - m_NodePropertiesTableEditor = new QmitkPropertiesTableEditor; - - QVBoxLayout* layout = new QVBoxLayout; - layout->addWidget(m_NodePropertiesTableEditor); - - parent->setLayout(layout); -} - -void QmitkPropertyListView::OnSelectionChanged( std::vector nodes ) -{ - if (nodes.empty() || (nodes.front() == NULL)) return; - - m_NodePropertiesTableEditor->SetPropertyList(nodes.front()->GetPropertyList()); -} - -bool QmitkPropertyListView::IsExclusiveFunctionality() const -{ - return false; -} diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.h b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.h deleted file mode 100644 index 640aaf8db3..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.h +++ /dev/null @@ -1,79 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkPropertyListView_h_ -#define QmitkPropertyListView_h_ - -// Own includes - -#include -#include -#include -#include - -class QmitkPropertiesTableEditor; - -/// -/// A view to show -/// -class MITK_QT_DATAMANAGER QmitkPropertyListView : public QmitkFunctionality -{ - Q_OBJECT - -public: - berryObjectMacro(QmitkPropertyListView) - - /// - /// The unique ID of this view - /// - static const std::string VIEW_ID; - /// - /// \brief Standard ctor. - /// - QmitkPropertyListView(); - - QmitkPropertyListView(const QmitkPropertyListView& other); - - /// - /// \brief Standard dtor. - /// - virtual ~QmitkPropertyListView(); - /// - /// \brief Create the view here. - /// - void CreateQtPartControl(QWidget* parent); - - /// - /// This is not a standalone functionality (can be easily used with other functionalities open) -> return false - /// - virtual bool IsExclusiveFunctionality() const; - - /// - /// Invoked when the DataManager selection changed - /// - virtual void OnSelectionChanged(std::vector nodes); - -private: - /// - /// \brief The properties table editor. - /// - QmitkPropertiesTableEditor* m_NodePropertiesTableEditor; - - friend struct berry::SelectionChangedAdapter; -}; - -#endif /*QmitkPropertyListView_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h b/Modules/Bundles/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h deleted file mode 100644 index 5ed494012d..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef mitkIContextMenuAction_H_ -#define mitkIContextMenuAction_H_ - -#include -#include - -#include -#include -#include "mitkDataStorage.h" - -class QmitkStdMultiWidget; - -namespace mitk -{ - /** - * A context menu action, which is linked to the context menu
- * through an extension point. For an example check the
- * plugin.xml and the connected classes of
- * the the segmentation bundle and also the QmitkDataManagerView.cpp
- * in this bundle. - */ - struct IContextMenuAction - { - berryInterfaceMacro(IContextMenuAction, mitk) - - /** - * @brief Executes the action, that linked to the context menu entry. - */ - virtual void Run( const std::vector& selectedNodes ) = 0; - - // Setters - virtual void SetDataStorage(mitk::DataStorage* dataStorage) = 0; - virtual void SetStdMultiWidget(QmitkStdMultiWidget *stdMultiWidget) = 0; - virtual void SetSmoothed(bool smoothed) = 0; - virtual void SetDecimated(bool decimated) = 0; - virtual void SetFunctionality(berry::QtViewPart* functionality) = 0; - }; -} - -Q_DECLARE_INTERFACE(mitk::IContextMenuAction, "org.mitk.datamanager.IContextMenuAction") - -#endif // mitkIContextMenuAction_H_ diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkDiffusionImagingUserManual.dox~ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkDiffusionImagingUserManual.dox~ deleted file mode 100644 index 4d9808760a..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkDiffusionImagingUserManual.dox~ +++ /dev/null @@ -1,104 +0,0 @@ -/** -\bundlemainpage{org_diffusion} MITK Diffusion Imaging (MITK-DI) - -This module provides means to diffusion weighted image reconstruction, visualization and quantification. Diffusion tensors as well as different q-ball reconstruction schemes are supported. Q-ball imaging aims at recovering more detailed information about the orientations of fibers from diffusion MRI measurements and, in particular, to resolve the orientations of crossing fibers. - -Available sections: - - \ref QmitkDiffusionImagingUserManualIssues - - \ref QmitkDiffusionImagingUserManualTensorReconstruction - - \ref QmitkDiffusionImagingUserManualQBallReconstruction - - \ref QmitkDiffusionImagingUserManualDicomImport - - \ref QmitkDiffusionImagingUserManualQuantification - - \ref QmitkDiffusionImagingUserManualVisualizationSettings - - \ref QmitkDiffusionImagingUserManualReferences - - \ref QmitkDiffusionImagingUserManualTechnicalDetail - -\image html overview.png The MITK Diffusion Imaging Module - -\section QmitkDiffusionImagingUserManualIssues Known Issues - -\li Dicom Import: The dicom import has so far only been implemented for Siemens dicom images. MITK-DI is capable of reading the nrrd format, which is documented elsewhere [1, 2]. These files can be created by combining the raw image data with a corresponding textual header file. The file extension should be changed from *.nrrd to *.dwi or from *.nhdr to *.hdwi respectively in order to let MITK-DI recognize the diffusion related header information provided in the files. - -\section QmitkDiffusionImagingUserManualTensorReconstruction Tensor Reconstruction - -The tensor reconstruction view allows ITK based tensor reconstruction [3]. - -\image html tensor1.png ITK tensor reconstruction - -The advanced settings for ITK reconstruction let you configure the number of threads to be used and a manual threshold on the non-diffusion weighted image. All voxels below this threshold will not be reconstructed and left blank. - -\image html tensor2.png Advanced settings for ITK tensor reconstruction - -A few seconds (depending on the image size) after the reconstruction button is hit, a colored image should appear in the main window. - -\image html tensor4.png Tensor image after reconstruction - -\section QmitkDiffusionImagingUserManualQBallReconstruction Q-Ball Reconstruction - -The q-ball reonstruction bundle implements a variety of reconstruction methods. The different reconstruction methods are described in the following: -\li Numerical: The original, numerical q-ball reconstruction presented by Tuch et al. [5] -\li Standard (SH): Descoteaux's reconstruction based on spherical harmonic basis functions [6] -\li Solid Angle (SH): Aganj's reconstruction with solid angle consideration [7] -\li ADC-profile only: The ADC-profile reconstructed with spherical harmonic basis functions -\li Raw signal only: The raw signal reconstructed with spherical harmonic basis functions - -\image html qballs1.png The q-ball resonstruction view - -B0 threshold works the same as in tensor reconstruction. The maximum l-level configures the size of the spherical harmonics basis. Larger l-values (e.g. l=8) allow higher levels of detail, lower levels are more stable against noise (e.g. l=4). Lambda is a regularisation parameter. Set it to 0 for no regularisation. lambda = 0.006 has proven to be a stable choice under various settings. - -\image html qballs2.png Advanced q-ball reconstruction settings - -This is how a q-ball image should initially look after reconstruction. Standard q-balls feature a relatively low GFA and thus appear rather dark. Adjust the level-window to solve this. - -\image html qballs3.png q-ball image after reconstruction - -\section QmitkDiffusionImagingUserManualDicomImport Dicom Import - -The dicom import does not cover all hardware manufacturers but only Siemens dicom images. MITK-DI is also capable of reading the nrrd format, which is documented elsewhere [1, 2]. These files can be created by combining the raw image data with a corresponding textual header file. The file extension should be changed from *.nrrd to *.dwi or from *.nhdr to *.hdwi respectively in order to let MITK-DI recognize the diffusion related header information provided in the files. - -In case your dicom images are readable by MITK-DI, select one or more input dicom folders and click import. Each input folder must only contain DICOM-images that can be combined into one vector-valued 3D output volume. Different patients must be loaded from different input-folders. The folders must not contain other acquisitions (e.g. T1,T2,localizer). - -In case many imports are performed at once, it is recommended to set the the optional output folder argument. This prevents the images from being kept in memory. - -\image html dicom1.png Dicom import - -The option "Average duplicate gradients" accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "blur radius" > 0 is configured. - -\section QmitkDiffusionImagingUserManualQuantification Quantification - -The quantification view allows the derivation of different scalar anisotropy measures for the reconstructed tensors (Fractional Anisotropy, Relative Anisotropy, Axial Diffusivity, Radial Diffusivity) or q-balls (Generalized Fractional Anisotropy). - -\image html quantification.png Anisotropy quantification - -\section QmitkDiffusionImagingUserManualVisualizationSettings ODF Visualization Setting - -In this small view, the visualization of ODFs and diffusion images can be configured. Depending on the selected image in the data storage, different options are shown here. - -For tensor or q-ball images, the visibility of glyphs in the different render windows (T)ransversal, (S)agittal, and (C)oronal can be configured here. The maximal number of glyphs to display can also be configured here for. This is usefull to keep the system response time during rendering feasible. The other options configure normalization and scaling of the glyphs. - -In diffusion images, a slider lets you choose the desired image channel from the vector of images (each gradient direction one image) for rendering. Furthermore reinit can be performed and texture interpolation toggled. - -This is how a visualization with activated glyphs should look like: - -\image html visualization3.png Q-ball image with ODF glyph visibility toggled ON - -\section QmitkDiffusionImagingUserManualReferences References - -1. http://teem.sourceforge.net/nrrd/format.html - -2. http://www.cmake.org/Wiki/Getting_Started_with_the_NRRD_Format - -3. C.F.Westin, S.E.Maier, H.Mamata, A.Nabavi, F.A.Jolesz, R.Kikinis, "Processing and visualization for Diffusion tensor MRI", Medical image Analysis, 2002, pp 93-108 - -5. Tuch, D.S., 2004. Q-ball imaging. Magn Reson Med 52, 1358-1372. - -6. Descoteaux, M., Angelino, E., Fitzgibbons, S., Deriche, R., 2007. Regularized, fast, and robust analytical Q-ball imaging. Magn Reson Med 58, 497-510. - -7. Aganj, I., Lenglet, C., Sapiro, G., 2009. ODF reconstruction in q-ball imaging with solid angle consideration. Proceedings of the Sixth IEEE International Symposium on Biomedical Imaging Boston, MA. - -8. Goh, A., Lenglet, C., Thompson, P.M., Vidal, R., 2009. Estimating Orientation Distribution Functions with Probability Density Constraints and Spatial Regularity. Med Image Comput Comput Assist Interv Int Conf Med Image Comput Comput Assist Interv LNCS 5761, 877 ff. - -\section QmitkDiffusionImagingUserManualTechnicalDetail Technical Information for Developers - -The diffusion imaging module uses additional properties beside the ones in use in other modules, for further information see \subpage DiffusionImagingPropertiesPage . -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/doxygen/modules.dox deleted file mode 100644 index 0ff155ff5b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_diffusionimaging org.mitk.gui.qt.diffusionimaging Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_diffusionimaging_internal Internal - \ingroup org_mitk_gui_qt_diffusionimaging - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.diffusionimaging plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake deleted file mode 100644 index 273bd24879..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake +++ /dev/null @@ -1,110 +0,0 @@ -SET(SRC_CPP_FILES - QmitkODFDetailsWidget.cpp - QmitkODFRenderWidget.cpp - QmitkPartialVolumeAnalysisWidget.cpp - QmitkIVIMWidget.cpp - QmitkTbssRoiAnalysisWidget.cpp -) - -SET(INTERNAL_CPP_FILES - mitkPluginActivator.cpp - QmitkQBallReconstructionView.cpp - QmitkPreprocessingView.cpp - QmitkDiffusionDicomImportView.cpp - QmitkDiffusionQuantificationView.cpp - QmitkTensorReconstructionView.cpp - QmitkDiffusionImagingPublicPerspective.cpp - QmitkControlVisualizationPropertiesView.cpp - QmitkODFDetailsView.cpp - QmitkGibbsTrackingView.cpp - QmitkStochasticFiberTrackingView.cpp - QmitkFiberProcessingView.cpp - QmitkFiberBundleDeveloperView.cpp - QmitkPartialVolumeAnalysisView.cpp - QmitkIVIMView.cpp - QmitkTractbasedSpatialStatisticsView.cpp - QmitkTbssTableModel.cpp - QmitkTbssMetaTableModel.cpp - QmitkTbssSkeletonizationView.cpp -) - -SET(UI_FILES - src/internal/QmitkQBallReconstructionViewControls.ui - src/internal/QmitkPreprocessingViewControls.ui - src/internal/QmitkDiffusionDicomImportViewControls.ui - src/internal/QmitkDiffusionQuantificationViewControls.ui - src/internal/QmitkTensorReconstructionViewControls.ui - src/internal/QmitkControlVisualizationPropertiesViewControls.ui - src/internal/QmitkODFDetailsViewControls.ui - src/internal/QmitkGibbsTrackingViewControls.ui - src/internal/QmitkStochasticFiberTrackingViewControls.ui - src/internal/QmitkFiberProcessingViewControls.ui - src/internal/QmitkFiberBundleDeveloperViewControls.ui - src/internal/QmitkPartialVolumeAnalysisViewControls.ui - src/internal/QmitkIVIMViewControls.ui - src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui - src/internal/QmitkTbssSkeletonizationViewControls.ui -) - -SET(MOC_H_FILES - src/internal/mitkPluginActivator.h - src/internal/QmitkQBallReconstructionView.h - src/internal/QmitkPreprocessingView.h - src/internal/QmitkDiffusionDicomImportView.h - src/internal/QmitkDiffusionImagingPublicPerspective.h - src/internal/QmitkDiffusionQuantificationView.h - src/internal/QmitkTensorReconstructionView.h - src/internal/QmitkControlVisualizationPropertiesView.h - src/internal/QmitkODFDetailsView.h - src/QmitkODFRenderWidget.h - src/QmitkODFDetailsWidget.h - src/internal/QmitkGibbsTrackingView.h - src/internal/QmitkStochasticFiberTrackingView.h - src/internal/QmitkFiberProcessingView.h - src/internal/QmitkFiberBundleDeveloperView.h - src/internal/QmitkPartialVolumeAnalysisView.h - src/QmitkPartialVolumeAnalysisWidget.h - src/internal/QmitkIVIMView.h - src/internal/QmitkTractbasedSpatialStatisticsView.h - src/internal/QmitkTbssSkeletonizationView.h - src/QmitkTbssRoiAnalysisWidget.h -) - -SET(CACHED_RESOURCE_FILES -# list of resource files which can be used by the plug-in -# system without loading the plug-ins shared library, -# for example the icon used in the menu and tabs for the -# plug-in views in the workbench - plugin.xml - - resources/preprocessing.png - resources/dwiimport.png - resources/quantification.png - resources/reconodf.png - resources/recontensor.png - resources/vizControls.png - resources/OdfDetails.png - resources/GibbsTracking.png - resources/FiberBundleOperations.png - resources/PartialVolumeAnalysis_24.png - resources/IVIM_48.png - resources/stochFB.png - resources/tbss.png -) - -SET(QRC_FILES -# uncomment the following line if you want to use Qt resources - resources/QmitkDiffusionImaging.qrc - #resources/QmitkTractbasedSpatialStatisticsView.qrc -) - -SET(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake~ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake~ deleted file mode 100644 index 0f89c67f7b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake~ +++ /dev/null @@ -1,115 +0,0 @@ -SET(SRC_CPP_FILES - QmitkODFDetailsWidget.cpp - QmitkODFRenderWidget.cpp - QmitkPartialVolumeAnalysisWidget.cpp - QmitkIVIMWidget.cpp - QmitkTbssRoiAnalysisWidget.cpp -) - -SET(INTERNAL_CPP_FILES - mitkPluginActivator.cpp - QmitkQBallReconstructionView.cpp - QmitkPreprocessingView.cpp - QmitkDiffusionDicomImportView.cpp - QmitkDiffusionQuantificationView.cpp - QmitkTensorReconstructionView.cpp - QmitkDiffusionImagingPublicPerspective.cpp - QmitkControlVisualizationPropertiesView.cpp - QmitkODFDetailsView.cpp - QmitkGibbsTrackingView.cpp - QmitkStochasticFiberTrackingView.cpp - QmitkFiberProcessingView.cpp - QmitkFiberBundleDeveloperView.cpp - QmitkPartialVolumeAnalysisView.cpp - QmitkIVIMView.cpp - QmitkScreenshotMaker.cpp - QmitkTractbasedSpatialStatisticsView.cpp - QmitkTbssTableModel.cpp - QmitkTbssMetaTableModel.cpp - QmitkTbssSkeletonizationView.cpp -) - -SET(UI_FILES - src/internal/QmitkQBallReconstructionViewControls.ui - src/internal/QmitkPreprocessingViewControls.ui - src/internal/QmitkDiffusionDicomImportViewControls.ui - src/internal/QmitkDiffusionQuantificationViewControls.ui - src/internal/QmitkTensorReconstructionViewControls.ui - src/internal/QmitkControlVisualizationPropertiesViewControls.ui - src/internal/QmitkODFDetailsViewControls.ui - src/internal/QmitkGibbsTrackingViewControls.ui - src/internal/QmitkStochasticFiberTrackingViewControls.ui - src/internal/QmitkFiberProcessingViewControls.ui - src/internal/QmitkFiberBundleDeveloperViewControls.ui - src/internal/QmitkPartialVolumeAnalysisViewControls.ui - src/internal/QmitkIVIMViewControls.ui - src/internal/QmitkScreenshotMakerControls.ui - src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui - src/internal/QmitkTbssSkeletonizationViewControls.ui -) - -SET(MOC_H_FILES - src/internal/mitkPluginActivator.h - src/internal/QmitkQBallReconstructionView.h - src/internal/QmitkPreprocessingView.h - src/internal/QmitkDiffusionDicomImportView.h - src/internal/QmitkDiffusionImagingPublicPerspective.h - src/internal/QmitkDiffusionQuantificationView.h - src/internal/QmitkTensorReconstructionView.h - src/internal/QmitkControlVisualizationPropertiesView.h - src/internal/QmitkODFDetailsView.h - src/QmitkODFRenderWidget.h - src/QmitkODFDetailsWidget.h - src/internal/QmitkGibbsTrackingView.h - src/internal/QmitkStochasticFiberTrackingView.h - src/internal/QmitkFiberProcessingView.h - src/internal/QmitkFiberBundleDeveloperView.h - src/internal/QmitkPartialVolumeAnalysisView.h - src/QmitkPartialVolumeAnalysisWidget.h - src/internal/QmitkIVIMView.h - src/internal/QmitkScreenshotMaker.h - src/internal/QmitkTractbasedSpatialStatisticsView.h - src/internal/QmitkTbssSkeletonizationView.h - src/QmitkTbssRoiAnalysisWidget.h -) - -SET(CACHED_RESOURCE_FILES -# list of resource files which can be used by the plug-in -# system without loading the plug-ins shared library, -# for example the icon used in the menu and tabs for the -# plug-in views in the workbench - plugin.xml - - resources/preprocessing.png - resources/dwiimport.png - resources/quantification.png - resources/reconodf.png - resources/recontensor.png - resources/vizControls.png - resources/OdfDetails.png - resources/GibbsTracking.png - resources/FiberBundleOperations.png - resources/PartialVolumeAnalysis_24.png - resources/IVIM_48.png - resources/screenshot_maker.png - resources/stochFB.png - resources/tbss.png - resources/tbss2.png -) - -SET(QRC_FILES -# uncomment the following line if you want to use Qt resources - resources/QmitkDiffusionImaging.qrc - #resources/QmitkTractbasedSpatialStatisticsView.qrc -) - -SET(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/manifest_headers.cmake deleted file mode 100644 index 4150a434d0..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Diffusion Imaging") -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 org.mitk.diffusionimaging) diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml~ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml~ deleted file mode 100644 index dea3a8b59b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml~ +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.cpp deleted file mode 100644 index 19948c8b89..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.cpp +++ /dev/null @@ -1,759 +0,0 @@ -/*========================================================================= -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkDiffusionDicomImportView.h" - -// qt includes -#include - -// itk includes -#include "itkTimeProbesCollectorBase.h" -#include "itkGDCMSeriesFileNames.h" -#include "itksys/SystemTools.hxx" - -// mitk includes -#include "mitkProgressBar.h" -#include "mitkStatusBar.h" -#include "mitkProperties.h" -#include "mitkRenderingManager.h" -#include "mitkMemoryUtilities.h" - -// diffusion module includes -#include "mitkDicomDiffusionImageHeaderReader.h" -#include "mitkGroupDiffusionHeadersFilter.h" -#include "mitkDicomDiffusionImageReader.h" -#include "mitkDiffusionImage.h" -#include "mitkNrrdDiffusionImageWriter.h" - -#include "gdcmDirectory.h" -#include "gdcmScanner.h" -#include "gdcmSorter.h" -#include "gdcmIPPSorter.h" -#include "gdcmAttribute.h" -#include "gdcmVersion.h" - -#include - -const std::string QmitkDiffusionDicomImport::VIEW_ID = "org.mitk.views.diffusiondicomimport"; - - -QmitkDiffusionDicomImport::QmitkDiffusionDicomImport(QObject* /*parent*/, const char* /*name*/) - : QmitkFunctionality(), m_Controls(NULL), m_MultiWidget(NULL), - m_OutputFolderName(""), m_OutputFolderNameSet(false) -{ -} - -QmitkDiffusionDicomImport::QmitkDiffusionDicomImport(const QmitkDiffusionDicomImport& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -QmitkDiffusionDicomImport::~QmitkDiffusionDicomImport() -{} - -void QmitkDiffusionDicomImport::CreateQtPartControl(QWidget *parent) -{ - m_Parent = parent; - if (m_Controls == NULL) - { - m_Controls = new Ui::QmitkDiffusionDicomImportControls; - m_Controls->setupUi(parent); - this->CreateConnections(); - - m_Controls->m_DicomLoadRecursiveCheckbox->setChecked(true); - m_Controls->m_DicomLoadAverageDuplicatesCheckbox->setChecked(false); - - m_Controls->m_DicomLoadRecursiveCheckbox->setVisible(false); - - AverageClicked(); - AdvancedCheckboxClicked(); - } -} - - - -void QmitkDiffusionDicomImport::CreateConnections() -{ - if ( m_Controls ) - { - connect( m_Controls->m_AddFoldersButton, SIGNAL(clicked()), this, SLOT(DicomLoadAddFolderNames()) ); - connect( m_Controls->m_DeleteFoldersButton, SIGNAL(clicked()), this, SLOT(DicomLoadDeleteFolderNames()) ); - connect( m_Controls->m_DicomLoadStartLoadButton, SIGNAL(clicked()), this, SLOT(DicomLoadStartLoad()) ); - connect( m_Controls->m_DicomLoadAverageDuplicatesCheckbox, SIGNAL(clicked()), this, SLOT(AverageClicked()) ); - connect( m_Controls->m_OutputSetButton, SIGNAL(clicked()), this, SLOT(OutputSet()) ); - connect( m_Controls->m_OutputClearButton, SIGNAL(clicked()), this, SLOT(OutputClear()) ); - connect( m_Controls->m_Advanced, SIGNAL(clicked()), this, SLOT(AdvancedCheckboxClicked()) ); - connect( m_Controls->m_Remove, SIGNAL(clicked()), this, SLOT(Remove()) ); - } -} - - -void QmitkDiffusionDicomImport::Remove() -{ - int i = m_Controls->listWidget->currentRow(); - m_Controls->listWidget->takeItem(i); -} - -void QmitkDiffusionDicomImport::AdvancedCheckboxClicked() -{ - bool check = m_Controls-> - m_Advanced->isChecked(); - - m_Controls->m_AdvancedFrame->setVisible(check); -} - -void QmitkDiffusionDicomImport::OutputSet() -{ - // SELECT FOLDER DIALOG - QFileDialog* w = new QFileDialog( m_Parent, QString("Select folders containing DWI data") ); - w->setFileMode( QFileDialog::Directory ); - - // RETRIEVE SELECTION - if ( w->exec() != QDialog::Accepted ) - return; - - m_OutputFolderName = w->selectedFiles()[0]; - m_OutputFolderNameSet = true; - m_Controls->m_OutputLabel->setText(m_OutputFolderName); -} - -void QmitkDiffusionDicomImport::OutputClear() -{ - m_OutputFolderName = ""; - m_OutputFolderNameSet = false; - m_Controls->m_OutputLabel->setText("... optional out-folder ..."); -} - -void QmitkDiffusionDicomImport::AverageClicked() -{ - m_Controls->m_Blur->setEnabled(m_Controls->m_DicomLoadAverageDuplicatesCheckbox->isChecked()); -} - -void QmitkDiffusionDicomImport::Activated() -{ - QmitkFunctionality::Activated(); -} - -void QmitkDiffusionDicomImport::DicomLoadDeleteFolderNames() -{ - m_Controls->listWidget->clear(); -} - -void QmitkDiffusionDicomImport::DicomLoadAddFolderNames() -{ - // SELECT FOLDER DIALOG - QFileDialog* w = new QFileDialog( m_Parent, QString("Select folders containing DWI data") ); - w->setFileMode( QFileDialog::Directory ); - - // RETRIEVE SELECTION - if ( w->exec() != QDialog::Accepted ) - return; - - m_Controls->listWidget->addItems(w->selectedFiles()); -} - -bool SortBySeriesUID(gdcm::DataSet const & ds1, gdcm::DataSet const & ds2 ) -{ - gdcm::Attribute<0x0020,0x000e> at1; - at1.Set( ds1 ); - gdcm::Attribute<0x0020,0x000e> at2; - at2.Set( ds2 ); - return at1 < at2; -} - -bool SortByAcquisitionNumber(gdcm::DataSet const & ds1, gdcm::DataSet const & ds2 ) -{ - gdcm::Attribute<0x0020,0x0012> at1; - at1.Set( ds1 ); - gdcm::Attribute<0x0020,0x0012> at2; - at2.Set( ds2 ); - return at1 < at2; -} - -bool SortBySeqName(gdcm::DataSet const & ds1, gdcm::DataSet const & ds2 ) -{ - gdcm::Attribute<0x0018, 0x0024> at1; - at1.Set( ds1 ); - gdcm::Attribute<0x0018, 0x0024> at2; - at2.Set( ds2 ); - - std::string str1 = at1.GetValue().Trim(); - std::string str2 = at2.GetValue().Trim(); - return std::lexicographical_compare(str1.begin(), str1.end(), - str2.begin(), str2.end() ); -} - -void QmitkDiffusionDicomImport::Status(QString status) -{ - mitk::StatusBar::GetInstance()->DisplayText(status.toAscii()); - MITK_INFO << status.toStdString().c_str(); -} - -void QmitkDiffusionDicomImport::Status(std::string status) -{ - mitk::StatusBar::GetInstance()->DisplayText(status.c_str()); - MITK_INFO << status.c_str(); -} - -void QmitkDiffusionDicomImport::Status(const char* status) -{ - mitk::StatusBar::GetInstance()->DisplayText(status); - MITK_INFO << status; -} - -void QmitkDiffusionDicomImport::Error(QString status) -{ - mitk::StatusBar::GetInstance()->DisplayErrorText(status.toAscii()); - MITK_ERROR << status.toStdString().c_str(); -} - -void QmitkDiffusionDicomImport::Error(std::string status) -{ - mitk::StatusBar::GetInstance()->DisplayErrorText(status.c_str()); - MITK_ERROR << status.c_str(); -} - -void QmitkDiffusionDicomImport::Error(const char* status) -{ - mitk::StatusBar::GetInstance()->DisplayErrorText(status); - MITK_ERROR << status; -} - -void QmitkDiffusionDicomImport::PrintMemoryUsage() -{ - size_t processSize = mitk::MemoryUtilities::GetProcessMemoryUsage(); - size_t totalSize = mitk::MemoryUtilities::GetTotalSizeOfPhysicalRam(); - float percentage = ( (float) processSize / (float) totalSize ) * 100.0; - MITK_INFO << "Current memory usage: " << GetMemoryDescription( processSize, percentage ); -} - -std::string QmitkDiffusionDicomImport::FormatMemorySize( size_t size ) -{ - double val = size; - std::string descriptor("B"); - if ( val >= 1000.0 ) - { - val /= 1024.0; - descriptor = "KB"; - } - if ( val >= 1000.0 ) - { - val /= 1024.0; - descriptor = "MB"; - } - if ( val >= 1000.0 ) - { - val /= 1024.0; - descriptor = "GB"; - } - std::ostringstream str; - str << std::fixed << std::setprecision(2) << val << " " << descriptor; - return str.str(); -} - -std::string QmitkDiffusionDicomImport::FormatPercentage( double val ) -{ - std::ostringstream str; - str << std::fixed << std::setprecision(2) << val << " " << "%"; - return str.str(); -} - -std::string QmitkDiffusionDicomImport::GetMemoryDescription( size_t processSize, float percentage ) -{ - std::ostringstream str; - str << FormatMemorySize(processSize) << " (" << FormatPercentage( percentage ) <<")" ; - return str.str(); -} - -void QmitkDiffusionDicomImport::DicomLoadStartLoad() -{ - itk::TimeProbesCollectorBase clock; - bool imageSuccessfullySaved = true; - - try - { - const std::string& locale = "C"; - const std::string& currLocale = setlocale( LC_ALL, NULL ); - - if ( locale.compare(currLocale)!=0 ) - { - try - { - MITK_INFO << " ** Changing locale from " << setlocale(LC_ALL, NULL) << " to '" << locale << "'"; - setlocale(LC_ALL, locale.c_str()); - } - catch(...) - { - MITK_INFO << "Could not set locale " << locale; - } - } - - int nrFolders = m_Controls->listWidget->count(); - - if(!nrFolders) - { - Error(QString("No input folders were selected. ABORTING.")); - return; - } - - Status(QString("GDCM %1 used for DICOM parsing and sorting!").arg(gdcm::Version::GetVersion())); - - PrintMemoryUsage(); - QString status; - mitk::DataNode::Pointer node; - mitk::ProgressBar::GetInstance()->AddStepsToDo(2*nrFolders); - - - std::string folder = m_Controls->m_OutputLabel->text().toStdString(); - - - if(berry::Platform::IsWindows()) - { - folder.append("\\import.log"); - } - else - { - folder.append("/import.log"); - } - - ofstream logfile; - if(m_OutputFolderNameSet) logfile.open(folder.c_str()); - - while(m_Controls->listWidget->count()) - { - // RETREIVE FOLDERNAME - QListWidgetItem * item = m_Controls->listWidget->takeItem(0); - QString folderName = item->text(); - - - - - if(m_OutputFolderNameSet) logfile << "Reading " << folderName.toStdString() << '\n'; - - // PARSING DIRECTORY - PrintMemoryUsage(); - clock.Start(folderName.toAscii()); - std::vector seriesUIDs(0); - std::vector > seriesFilenames(0); - - Status("== Initial Directory Scan =="); - if(m_OutputFolderNameSet) logfile << "== Initial Directory Scan ==\n"; - - gdcm::Directory d; - d.Load( folderName.toStdString().c_str(), true ); // recursive ! - const gdcm::Directory::FilenamesType &l1 = d.GetFilenames(); - const unsigned int ntotalfiles = l1.size(); - Status(QString(" ... found %1 different files").arg(ntotalfiles)); - if(m_OutputFolderNameSet)logfile << "...found " << ntotalfiles << " different files\n"; - - Status("Scanning Headers"); - if(m_OutputFolderNameSet) logfile << "Scanning Headers\n"; - - gdcm::Scanner s; - const gdcm::Tag t1(0x0020,0x000d); // Study Instance UID - const gdcm::Tag t2(0x0020,0x000e); // Series Instance UID - const gdcm::Tag t5(0x0028, 0x0010); // number rows - const gdcm::Tag t6(0x0028, 0x0011); // number cols - s.AddTag( t1 ); - s.AddTag( t2 ); - s.AddTag( t5 ); - s.AddTag( t6 ); - - bool b = s.Scan( d.GetFilenames() ); - if( !b ) - { - Error("Scanner failed"); - if(m_OutputFolderNameSet )logfile << "ERROR: scanner failed\n"; - continue; - } - - // Only get the DICOM files: - gdcm::Directory::FilenamesType l2 = s.GetKeys(); - const int nfiles = l2.size(); - if(nfiles < 1) - { - Error("No DICOM files found"); - if(m_OutputFolderNameSet)logfile << "ERROR: No DICOM files found\n"; - continue; - } - Status(QString(" ... successfully scanned %1 headers.").arg(nfiles)); - if(m_OutputFolderNameSet) logfile << "...succesfully scanned " << nfiles << " headers\n"; - - Status("Sorting"); - if(m_OutputFolderNameSet) logfile << "Sorting\n"; - - const gdcm::Scanner::ValuesType &values1 = s.GetValues(t1); - - int nvalues; - if(m_Controls->m_DuplicateID->isChecked()) - { - nvalues = 1; - } - else - { - nvalues = values1.size(); - } - - if(nvalues>1) - { - Error("Multiple sSeries tudies found. Please limit to 1 study per folder"); - if(m_OutputFolderNameSet) logfile << "Multiple series found. Limit to one. If you are convinced this is an error use the merge duplicate study IDs option \n"; - continue; - } - - const gdcm::Scanner::ValuesType &values5 = s.GetValues(t5); - const gdcm::Scanner::ValuesType &values6 = s.GetValues(t6); - if(values5.size()>1 || values6.size()>1) - { - Error("Folder contains images of unequal dimensions that cannot be combined in one 3d volume. ABORTING."); - if(m_OutputFolderNameSet) logfile << "Folder contains images of unequal dimensions that cannot be combined in one 3d volume. ABORTING\n."; - continue; - } - - const gdcm::Scanner::ValuesType &values2 = s.GetValues(t2); - - - int nSeries; - if(m_Controls->m_DuplicateID->isChecked()) - { - nSeries = 1; - } - else - { - nSeries = values1.size(); - } - - gdcm::Directory::FilenamesType files; - if(nSeries > 1) - { - gdcm::Sorter sorter; - sorter.SetSortFunction( SortBySeriesUID ); - sorter.StableSort( l2 ); - files = sorter.GetFilenames(); - } - else - { - files = l2; - } - - unsigned int nTotalAcquis = 0; - - if(nfiles % nSeries != 0) - { - Error("Number of files in series not equal, ABORTING"); - if(m_OutputFolderNameSet) logfile << "Number of files in series not equal, Some volumes are probably incomplete. ABORTING \n"; - continue; - } - - int filesPerSeries = nfiles / nSeries; - - - gdcm::Scanner::ValuesType::const_iterator it2 = values2.begin(); - for(int i=0; i & list = ippsorter.GetFilenames(); - seriesFilenames.push_back(list); - seriesUIDs.push_back(identifier.c_str()); - } - ++it2; - } - - if(nfiles % nTotalAcquis != 0) - { - Error("Number of files per acquisition differs between series, ABORTING"); - if(m_OutputFolderNameSet) logfile << "Number of files per acquisition differs between series, ABORTING \n"; - continue; - } - - int slices = nfiles/nTotalAcquis; - Status(QString("Series is composed of %1 different 3D volumes with %2 slices.").arg(nTotalAcquis).arg(slices)); - if(m_OutputFolderNameSet) logfile << "Series is composed of " << nTotalAcquis << " different 3D volumes with " << slices << " slices\n"; - - // READING HEADER-INFOS - PrintMemoryUsage(); - Status(QString("Reading Headers %1").arg(folderName)); - if(m_OutputFolderNameSet) logfile << "Reading Headers "<< folderName.toStdString() << "\n"; - - mitk::DicomDiffusionImageHeaderReader::Pointer headerReader; - mitk::GroupDiffusionHeadersFilter::InputType inHeaders; - unsigned int size2 = seriesUIDs.size(); - for ( unsigned int i = 0 ; i < size2 ; ++i ) - { - Status(QString("Reading header image #%1/%2").arg(i+1).arg(size2)); - headerReader = mitk::DicomDiffusionImageHeaderReader::New(); - headerReader->SetSeriesDicomFilenames(seriesFilenames[i]); - headerReader->Update(); - inHeaders.push_back(headerReader->GetOutput()); - //Status(std::endl; - } - mitk::ProgressBar::GetInstance()->Progress(); - - // // GROUP HEADERS - // mitk::GroupDiffusionHeadersFilter::Pointer grouper - // = mitk::GroupDiffusionHeadersFilter::New(); - // mitk::GroupDiffusionHeadersFilter::OutputType outHeaders; - // grouper->SetInput(inHeaders); - // grouper->Update(); - // outHeaders = grouper->GetOutput(); - - // READ VOLUMES - PrintMemoryUsage(); - if(m_OutputFolderNameSet) logfile << "Loading volumes\n"; - Status(QString("Loading Volumes %1").arg(folderName)); - typedef short PixelValueType; - typedef mitk::DicomDiffusionImageReader< PixelValueType, 3 > VolumesReader; - VolumesReader::Pointer vReader = VolumesReader::New(); - VolumesReader::HeaderContainer hc = inHeaders; - - // hc.insert(hc.end(), outHeaders[1].begin(), outHeaders[1].end() ); - // hc.insert(hc.end(), outHeaders[2].begin(), outHeaders[2].end() ); - if(hc.size()>1) - { - vReader->SetHeaders(hc); - vReader->Update(); - VolumesReader::OutputImageType::Pointer vecImage; - vecImage = vReader->GetOutput(); - Status(QString("Volumes Loaded (%1)").arg(folderName)); - - // CONSTRUCT CONTAINER WITH DIRECTIONS - typedef vnl_vector_fixed< double, 3 > GradientDirectionType; - typedef itk::VectorContainer< unsigned int, - GradientDirectionType > GradientDirectionContainerType; - GradientDirectionContainerType::Pointer directions = - GradientDirectionContainerType::New(); - std::vector b_vals; - double maxb = 0; - for(unsigned int i=0; ibValue; - if(maxb vect = hc[i]->DiffusionVector; - vect.normalize(); - vect *= sqrt(b_vals[i]/maxb); - directions->push_back(vect); - } - - // DWI TO DATATREE - PrintMemoryUsage(); - Status(QString("Initializing Diffusion Image")); - if(m_OutputFolderNameSet) logfile << "Initializing Diffusion Image\n"; - typedef mitk::DiffusionImage DiffVolumesType; - DiffVolumesType::Pointer diffImage = DiffVolumesType::New(); - diffImage->SetDirections(directions); - diffImage->SetOriginalDirections(directions); - if(m_Controls->m_DicomLoadDKFZ->isChecked()) - { - diffImage->CorrectDKFZBrokenGradientScheme(m_Controls->m_Blur->value()); - } - diffImage->SetVectorImage(vecImage); - diffImage->SetB_Value(maxb); - diffImage->InitializeFromVectorImage(); - Status(QString("Diffusion Image initialized")); - if(m_OutputFolderNameSet) logfile << "Diffusion Image initialized\n"; - - if(m_Controls->m_DicomLoadAverageDuplicatesCheckbox->isChecked()) - { - PrintMemoryUsage(); - Status(QString("Averaging gradient directions")); - logfile << "Averaging gradient directions\n"; - diffImage->AverageRedundantGradients(m_Controls->m_Blur->value()); - } - - //if(m_Controls->m_DicomLoadDuplicateIfSingleSliceCheckbox->isChecked()) - // diffVolumes->DuplicateIfSingleSlice(); - - QString descr = QString("%1_%2_%3") - .arg(((inHeaders)[0])->seriesDescription.c_str()) - .arg(((inHeaders)[0])->seriesNumber) - .arg(((inHeaders)[0])->patientName.c_str()); - descr = descr.trimmed(); - descr = descr.replace(" ", "_"); - - if(!m_OutputFolderNameSet) - { - node=mitk::DataNode::New(); - node->SetData( diffImage ); - GetDefaultDataStorage()->Add(node); - SetDwiNodeProperties(node, descr.toStdString().c_str()); - Status(QString("Image %1 added to datastorage").arg(descr)); - } - else - { - typedef mitk::NrrdDiffusionImageWriter WriterType; - WriterType::Pointer writer = WriterType::New(); - QString fullpath = QString("%1/%2.dwi") - .arg(m_OutputFolderName) - .arg(descr); - //std::string pathstring = itksys::SystemTools::ConvertToOutputPath(fullpath.toStdString().c_str()); - - writer->SetFileName(fullpath.toStdString()); - writer->SetInput(diffImage); - try - { - writer->Update(); - } - catch (itk::ExceptionObject &ex) - { - imageSuccessfullySaved = false; - Error(QString("%1\n%2\n%3\n%4\n%5\n%6").arg(ex.GetNameOfClass()).arg(ex.GetFile()).arg(ex.GetLine()).arg(ex.GetLocation()).arg(ex.what()).arg(ex.GetDescription())); - logfile << QString("%1\n%2\n%3\n%4\n%5\n%6").arg(ex.GetNameOfClass()).arg(ex.GetFile()).arg(ex.GetLine()).arg(ex.GetLocation()).arg(ex.what()).arg(ex.GetDescription()).toStdString() << "\n"; - - node=mitk::DataNode::New(); - node->SetData( diffImage ); - GetDefaultDataStorage()->Add(node); - SetDwiNodeProperties(node, descr.toStdString().c_str()); - Status(QString("Image %1 added to datastorage").arg(descr)); - logfile << "Image " << descr.toStdString() << " added to datastorage\n"; - continue ; - } - Status(QString("Image %1 written to disc (%1)").arg(fullpath.toStdString().c_str())); - logfile << "Image " << fullpath.toStdString() << "\n"; - } - } - else - { - Status(QString("No diffusion information found (%1)").arg(folderName)); - if(m_OutputFolderNameSet) logfile << "No diffusion information found "<< folderName.toStdString(); - } - - Status(QString("Finished processing %1 with memory:").arg(folderName)); - if(m_OutputFolderNameSet) logfile << "Finished processing " << folderName.toStdString() << "\n"; - PrintMemoryUsage(); - clock.Stop(folderName.toAscii()); - mitk::ProgressBar::GetInstance()->Progress(); - int lwidget = m_Controls->listWidget->count(); - std::cout << lwidget <GetData(); - if (basedata.IsNotNull()) - { - mitk::RenderingManager::GetInstance()->InitializeViews( - basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - } - } - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - try - { - MITK_INFO << " ** Changing locale back from " << setlocale(LC_ALL, NULL) << " to '" << currLocale << "'"; - setlocale(LC_ALL, currLocale.c_str()); - } - catch(...) - { - MITK_INFO << "Could not reset locale " << currLocale; - } - } - catch (itk::ExceptionObject &ex) - { - Error(QString("%1\n%2\n%3\n%4\n%5\n%6").arg(ex.GetNameOfClass()).arg(ex.GetFile()).arg(ex.GetLine()).arg(ex.GetLocation()).arg(ex.what()).arg(ex.GetDescription())); - return ; - } - - if (!imageSuccessfullySaved) - QMessageBox::warning(NULL,"WARNING","One or more files could not be saved! The according files where moved to the datastorage."); - Status(QString("Finished import with memory:")); - - PrintMemoryUsage(); -} - -void QmitkDiffusionDicomImport::SetDwiNodeProperties(mitk::DataNode::Pointer node, std::string name) -{ - - node->SetProperty( "IsDWIRawVolume", mitk::BoolProperty::New( true ) ); - - // set foldername as string property - mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New( name ); - node->SetProperty( "name", nameProp ); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.cpp deleted file mode 100644 index 38f8f488c5..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.cpp +++ /dev/null @@ -1,535 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Module: $RCSfile$ -Language: C++ -Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $ -Version: $Revision: 17495 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -//#define MBILOG_ENABLE_DEBUG - -#include "QmitkPreprocessingView.h" -#include "mitkDiffusionImagingConfigure.h" - -// qt includes -#include - -// itk includes -#include "itkTimeProbe.h" -#include "itkB0ImageExtractionImageFilter.h" -#include "itkBrainMaskExtractionImageFilter.h" -#include "itkCastImageFilter.h" -#include "itkVectorContainer.h" -#include - -// mitk includes -#include "QmitkDataStorageComboBox.h" -#include "QmitkStdMultiWidget.h" -#include "mitkProgressBar.h" -#include "mitkStatusBar.h" -#include "mitkNodePredicateDataType.h" -#include "mitkProperties.h" -#include "mitkVtkResliceInterpolationProperty.h" -#include "mitkLookupTable.h" -#include "mitkLookupTableProperty.h" -#include "mitkTransferFunction.h" -#include "mitkTransferFunctionProperty.h" -#include "mitkDataNodeObject.h" -#include "mitkOdfNormalizationMethodProperty.h" -#include "mitkOdfScaleByProperty.h" -#include - -#include "berryIStructuredSelection.h" -#include "berryIWorkbenchWindow.h" -#include "berryISelectionService.h" - -#include -#include - -const std::string QmitkPreprocessingView::VIEW_ID = -"org.mitk.views.preprocessing"; - -#define DI_INFO MITK_INFO("DiffusionImaging") - - -typedef float TTensorPixelType; - -using namespace berry; - -struct PrpSelListener : ISelectionListener -{ - - berryObjectMacro(PrpSelListener); - - PrpSelListener(QmitkPreprocessingView* view) - { - m_View = view; - } - - void DoSelectionChanged(ISelection::ConstPointer selection) - { - // save current selection in member variable - m_View->m_CurrentSelection = selection.Cast(); - - // do something with the selected items - if(m_View->m_CurrentSelection) - { - bool foundDwiVolume = false; - m_View->m_DiffusionImage = NULL; - - // iterate selection - for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); - i != m_View->m_CurrentSelection->End(); ++i) - { - - // extract datatree node - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - - // only look at interesting types - if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) - { - foundDwiVolume = true; - m_View->m_DiffusionImage = dynamic_cast*>(node->GetData()); - } - } - } - - m_View->m_Controls->m_ButtonBrainMask->setEnabled(foundDwiVolume); - m_View->m_Controls->m_ButtonAverageGradients->setEnabled(foundDwiVolume); - m_View->m_Controls->m_ButtonExtractB0->setEnabled(foundDwiVolume); - m_View->m_Controls->m_ModifyMeasurementFrame->setEnabled(foundDwiVolume); - m_View->m_Controls->m_MeasurementFrameTable->setEnabled(foundDwiVolume); - m_View->m_Controls->m_ReduceGradientsButton->setEnabled(foundDwiVolume); - - if (foundDwiVolume) - { - vnl_matrix_fixed< double, 3, 3 > mf = m_View->m_DiffusionImage->GetMeasurementFrame(); - for (int r=0; r<3; r++) - for (int c=0; c<3; c++) - { - QTableWidgetItem* item = m_View->m_Controls->m_MeasurementFrameTable->item(r,c); - delete item; - item = new QTableWidgetItem(); - item->setTextAlignment(Qt::AlignCenter | Qt::AlignVCenter); - item->setText(QString::number(mf.get(r,c))); - m_View->m_Controls->m_MeasurementFrameTable->setItem(r,c,item); - } - m_View->m_Controls->m_GradientsLabel->setText(QString::number(m_View->m_DiffusionImage->GetNumDirections())); - - if (m_View->m_DiffusionImage->IsMultiBval()) - m_View->m_Controls->m_BvalLabel->setText("Acquisition with multiple b-values!"); - else - m_View->m_Controls->m_BvalLabel->setText(QString::number(m_View->m_DiffusionImage->GetB_Value())); - } - else - { - for (int r=0; r<3; r++) - for (int c=0; c<3; c++) - { - QTableWidgetItem* item = m_View->m_Controls->m_MeasurementFrameTable->item(r,c); - delete item; - item = new QTableWidgetItem(); - m_View->m_Controls->m_MeasurementFrameTable->setItem(r,c,item); - } - m_View->m_Controls->m_GradientsLabel->setText("-"); - m_View->m_Controls->m_BvalLabel->setText("-"); - } - } - } - - void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) - { - // check, if selection comes from datamanager - if (part) - { - QString partname(part->GetPartName().c_str()); - if(partname.compare("Datamanager")==0) - { - - // apply selection - DoSelectionChanged(selection); - - } - } - } - - QmitkPreprocessingView* m_View; -}; - -QmitkPreprocessingView::QmitkPreprocessingView() -: QmitkFunctionality(), -m_Controls(NULL), -m_MultiWidget(NULL), -m_DiffusionImage(NULL) -{ -} - -QmitkPreprocessingView::QmitkPreprocessingView(const QmitkPreprocessingView& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -QmitkPreprocessingView::~QmitkPreprocessingView() -{ - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); -} - -void QmitkPreprocessingView::CreateQtPartControl(QWidget *parent) -{ - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkPreprocessingViewControls; - m_Controls->setupUi(parent); - this->CreateConnections(); - - m_Controls->m_MeasurementFrameTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); - m_Controls->m_MeasurementFrameTable->verticalHeader()->setResizeMode(QHeaderView::Stretch); - } - - m_SelListener = berry::ISelectionListener::Pointer(new PrpSelListener(this)); - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); -} - -void QmitkPreprocessingView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) -{ - m_MultiWidget = &stdMultiWidget; -} - -void QmitkPreprocessingView::StdMultiWidgetNotAvailable() -{ - m_MultiWidget = NULL; -} - -void QmitkPreprocessingView::CreateConnections() -{ - if ( m_Controls ) - { - connect( (QObject*)(m_Controls->m_ButtonAverageGradients), SIGNAL(clicked()), this, SLOT(AverageGradients()) ); - connect( (QObject*)(m_Controls->m_ButtonExtractB0), SIGNAL(clicked()), this, SLOT(ExtractB0()) ); - connect( (QObject*)(m_Controls->m_ButtonBrainMask), SIGNAL(clicked()), this, SLOT(BrainMask()) ); - connect( (QObject*)(m_Controls->m_ModifyMeasurementFrame), SIGNAL(clicked()), this, SLOT(DoApplyMesurementFrame()) ); - connect( (QObject*)(m_Controls->m_ReduceGradientsButton), SIGNAL(clicked()), this, SLOT(DoReduceGradientDirections()) ); - } -} - -void QmitkPreprocessingView::Activated() -{ - QmitkFunctionality::Activated(); - - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); -} - -void QmitkPreprocessingView::Deactivated() -{ - QmitkFunctionality::Deactivated(); -} - -void QmitkPreprocessingView::DoApplyMesurementFrame() -{ - if (m_DiffusionImage.IsNull()) - return; - vnl_matrix_fixed< double, 3, 3 > mf; - for (int r=0; r<3; r++) - for (int c=0; c<3; c++) - { - QTableWidgetItem* item = m_Controls->m_MeasurementFrameTable->item(r,c); - if (!item) - return; - mf[r][c] = item->text().toDouble(); - } - m_DiffusionImage->SetMeasurementFrame(mf); -} - -void QmitkPreprocessingView::DoReduceGradientDirections() -{ - if (m_DiffusionImage.IsNull()) - return; - - typedef vnl_vector_fixed< double, 3 > GradientDirectionType; - typedef itk::VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType; - - typedef mitk::DiffusionImage DiffusionImageType; - typedef itk::ReduceDirectionGradientsFilter FilterType; - - GradientDirectionContainerType::Pointer gradientContainer = m_DiffusionImage->GetOriginalDirections(); - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(m_DiffusionImage->GetVectorImage()); - filter->SetOriginalGradientDirections(gradientContainer); - filter->SetNumGradientDirections(m_Controls->m_ReduceGradientsBox->value()); - filter->Update(); - - DiffusionImageType::Pointer image = DiffusionImageType::New(); - image->SetVectorImage( filter->GetOutput() ); - image->SetB_Value(m_DiffusionImage->GetB_Value()); - image->SetDirections(filter->GetGradientDirections()); - image->SetOriginalDirections(filter->GetGradientDirections()); - image->SetMeasurementFrame(m_DiffusionImage->GetMeasurementFrame()); - image->InitializeFromVectorImage(); - mitk::DataNode::Pointer imageNode = mitk::DataNode::New(); - imageNode->SetData( image ); - imageNode->SetName("reduced_image"); - this->GetDefaultDataStorage()->Add(imageNode); - - std::vector< int > gradients = filter->GetUsedGradientIndices(); - mitk::PointSet::Pointer points = mitk::PointSet::New(); - int ind = 0; - for (std::vector::iterator it = gradients.begin(); it!=gradients.end(); ++it) - { - mitk::Point3D p; - vnl_vector_fixed< double, 3 > v = gradientContainer->at(*it); - p[0] = v[0]; - p[1] = v[1]; - p[2] = v[2]; - points->InsertPoint(ind, p); - ind++; - } - mitk::DataNode::Pointer node = mitk::DataNode::New(); - node->SetData(points); - node->SetName("reduced_shell"); - node->SetProperty("pointsize", mitk::FloatProperty::New(0.05)); - node->SetProperty("color", mitk::ColorProperty::New(0,1,0)); - - mitk::PointSet::Pointer originalP = mitk::PointSet::New(); - for (int j=0; jSize(); j++) - { - mitk::Point3D p; - vnl_vector_fixed< double, 3 > v = gradientContainer->at(j); - p[0] = v[0]; - p[1] = v[1]; - p[2] = v[2]; - originalP->InsertPoint(j, p); - } - mitk::DataNode::Pointer originalN = mitk::DataNode::New(); - originalN->SetData(originalP); - originalN->SetName("original_shell"); - originalN->SetProperty("pointsize", mitk::FloatProperty::New(0.04)); - originalN->SetProperty("color", mitk::ColorProperty::New(1,0,0)); - - this->GetDefaultDataStorage()->Add(originalN); - this->GetDefaultDataStorage()->Add(node); -} - -void QmitkPreprocessingView::ExtractB0() -{ - - if (m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - int at = 0; - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) - { - - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) - { - set->InsertElement(at++, node); - } - } - } - - DoExtractB0(set); - - } -} - -void QmitkPreprocessingView::DoExtractB0 -(mitk::DataStorage::SetOfObjects::Pointer inImages) -{ - typedef mitk::DiffusionImage DiffusionImageType; - typedef DiffusionImageType::GradientDirectionContainerType GradientContainerType; - - int nrFiles = inImages->size(); - if (!nrFiles) return; - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); - - std::vector nodes; - while ( itemiter != itemiterend ) // for all items - { - - DiffusionImageType* vols = - static_cast( - (*itemiter)->GetData()); - - std::string nodename; - (*itemiter)->GetStringProperty("name", nodename); - - // Extract image using found index - typedef itk::B0ImageExtractionImageFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(vols->GetVectorImage()); - filter->SetDirections(vols->GetDirections()); - filter->Update(); - - mitk::Image::Pointer mitkImage = mitk::Image::New(); - mitkImage->InitializeByItk( filter->GetOutput() ); - mitkImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); - mitk::DataNode::Pointer node=mitk::DataNode::New(); - node->SetData( mitkImage ); - node->SetProperty( "name", mitk::StringProperty::New(nodename + "_B0")); - - GetDefaultDataStorage()->Add(node); - - ++itemiter; - } - - -} - -void QmitkPreprocessingView::AverageGradients() -{ - - if (m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - int at = 0; - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) - { - - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) - { - set->InsertElement(at++, node); - } - } - } - - DoAverageGradients(set); - - } - -} - -void QmitkPreprocessingView::DoAverageGradients -(mitk::DataStorage::SetOfObjects::Pointer inImages) -{ - int nrFiles = inImages->size(); - if (!nrFiles) return; - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); - - std::vector nodes; - while ( itemiter != itemiterend ) // for all items - { - - mitk::DiffusionImage* vols = - static_cast*>( - (*itemiter)->GetData()); - - vols->AverageRedundantGradients(m_Controls->m_Blur->value()); - - ++itemiter; - } -} - -void QmitkPreprocessingView::BrainMask() -{ - - if (m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - int at = 0; - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) - { - - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) - { - set->InsertElement(at++, node); - } - } - } - - DoBrainMask(set); - - } - -} - -void QmitkPreprocessingView::DoBrainMask -(mitk::DataStorage::SetOfObjects::Pointer inImages) -{ - int nrFiles = inImages->size(); - if (!nrFiles) return; - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); - - while ( itemiter != itemiterend ) // for all items - { - - mitk::DiffusionImage* vols = - static_cast*>( - (*itemiter)->GetData()); - - std::string nodename; - (*itemiter)->GetStringProperty("name", nodename); - - // Extract image using found index - typedef itk::B0ImageExtractionImageFilter FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput(vols->GetVectorImage()); - filter->SetDirections(vols->GetDirections()); - - typedef itk::CastImageFilter, itk::Image > CastFilterType; - CastFilterType::Pointer castfilter = CastFilterType::New(); - castfilter->SetInput(filter->GetOutput()); - - typedef itk::BrainMaskExtractionImageFilter MaskFilterType; - MaskFilterType::Pointer maskfilter = MaskFilterType::New(); - maskfilter->SetInput(castfilter->GetOutput()); - maskfilter->Update(); - - mitk::Image::Pointer mitkImage = mitk::Image::New(); - mitkImage->InitializeByItk( maskfilter->GetOutput() ); - mitkImage->SetVolume( maskfilter->GetOutput()->GetBufferPointer() ); - mitk::DataNode::Pointer node=mitk::DataNode::New(); - node->SetData( mitkImage ); - node->SetProperty( "name", mitk::StringProperty::New(nodename + "_Mask")); - - GetDefaultDataStorage()->Add(node); - - ++itemiter; - } -} diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.h b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.h deleted file mode 100644 index a3e200efb9..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.h +++ /dev/null @@ -1,109 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Module: $RCSfile$ -Language: C++ -Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $ -Version: $Revision: 17495 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef _QMITKPREPROCESSINGVIEW_H_INCLUDED -#define _QMITKPREPROCESSINGVIEW_H_INCLUDED - -#include - -#include - -#include "ui_QmitkPreprocessingViewControls.h" - -#include "mitkDiffusionImage.h" - -#include -#include -#include - -typedef short DiffusionPixelType; - -struct PrpSelListener; - -/*! - * \ingroup org_mitk_gui_qt_preprocessing_internal - * - * \brief QmitkPreprocessingView - * - * Document your class here. - * - * \sa QmitkFunctionality - */ -class QmitkPreprocessingView : public QmitkFunctionality -{ - - friend struct PrpSelListener; - - // 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; - - QmitkPreprocessingView(); - QmitkPreprocessingView(const QmitkPreprocessingView& other); - virtual ~QmitkPreprocessingView(); - - 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(); - - static const int nrconvkernels; - -protected slots: - - void AverageGradients(); - void DoAverageGradients(mitk::DataStorage::SetOfObjects::Pointer inImages); - - void ExtractB0(); - void DoExtractB0(mitk::DataStorage::SetOfObjects::Pointer inImages); - - void BrainMask(); - void DoBrainMask(mitk::DataStorage::SetOfObjects::Pointer inImages); - - void DoApplyMesurementFrame(); - void DoReduceGradientDirections(); - -protected: - - Ui::QmitkPreprocessingViewControls* m_Controls; - - QmitkStdMultiWidget* m_MultiWidget; - - void SetDefaultNodeProperties(mitk::DataNode::Pointer node, std::string name); - - berry::ISelectionListener::Pointer m_SelListener; - berry::IStructuredSelection::ConstPointer m_CurrentSelection; - mitk::DiffusionImage::Pointer m_DiffusionImage; -}; - - - - -#endif // _QMITKPREPROCESSINGVIEW_H_INCLUDED - diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingViewControls.ui b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingViewControls.ui deleted file mode 100644 index fad61e7d65..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingViewControls.ui +++ /dev/null @@ -1,439 +0,0 @@ - - - QmitkPreprocessingViewControls - - - - 0 - 0 - 398 - 685 - - - - - 0 - 0 - - - - true - - - QmitkPreprocessingViewControls - - - - - - Info - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Number of Gradients: - - - - - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - b-Value: - - - - - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Reduce size - - - - - - - 0 - 70 - - - - Multiple acquistions of one gradient direction can be averaged. Due to rounding errors, similar gradients often differ in the last decimal positions. The Merge radius allows to average them anyway by taking into account all directions within a certain radius. - - - true - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - - - Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. - - - Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. - - - Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. - - - 6 - - - 2.000000000000000 - - - 0.000100000000000 - - - 0.001000000000000 - - - - - - - Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. - - - Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. - - - Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. - - - Merge radius - - - - - - - - - - false - - - - - - - - - - - - Average redundant gradients - - - - - - - - - - Non diffusion weighted image - - - - - - - 0 - 30 - - - - Average and extract all images that were acquired without diffusion weighting. - - - true - - - - - - - false - - - - - - - - - - - - Extract B0 - - - - - - - - - - Brain mask - - - - - - false - - - - - - - - - - - - Estimate binary brain mask - - - - - - - - - - - 0 - 0 - - - - Measurment frame - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - 0 - 0 - - - - - 10 - 10 - - - - IBeamCursor - - - true - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - false - - - false - - - true - - - true - - - false - - - true - - - true - - - - New Row - - - - - New Row - - - - - New Row - - - - - New Column - - - - - New Column - - - - - New Column - - - - - - - - false - - - - - - - - - - - - Apply new mesurement frame - - - - - - - - - - Reduce number of direction gradients - - - - - - 1 - - - 30 - - - - - - - New number of gradients: - - - - - - - false - - - - - - - - - - - - Reduce Gradients - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.cpp deleted file mode 100644 index b6cfc94d16..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.cpp +++ /dev/null @@ -1,979 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Module: $RCSfile$ -Language: C++ -Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $ -Version: $Revision: 17495 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkTensorReconstructionView.h" -#include "mitkDiffusionImagingConfigure.h" - -// qt includes -#include - -// itk includes -#include "itkTimeProbe.h" -//#include "itkTensor.h" - -// mitk includes -#include "mitkProgressBar.h" -#include "mitkStatusBar.h" - -#include "mitkNodePredicateDataType.h" -#include "QmitkDataStorageComboBox.h" -#include "QmitkStdMultiWidget.h" - -#include "mitkTeemDiffusionTensor3DReconstructionImageFilter.h" -#include "itkDiffusionTensor3DReconstructionImageFilter.h" -#include "itkTensorImageToDiffusionImageFilter.h" -#include "itkPointShell.h" -#include "itkVector.h" - -#include "mitkProperties.h" -#include "mitkDataNodeObject.h" -#include "mitkOdfNormalizationMethodProperty.h" -#include "mitkOdfScaleByProperty.h" -#include "mitkDiffusionImageMapper.h" - -#include "berryIStructuredSelection.h" -#include "berryIWorkbenchWindow.h" -#include "berryISelectionService.h" - -#include -#include - -const std::string QmitkTensorReconstructionView::VIEW_ID = -"org.mitk.views.tensorreconstruction"; - -#define DI_INFO MITK_INFO("DiffusionImaging") - -typedef float TTensorPixelType; - -using namespace berry; - -struct TrSelListener : ISelectionListener -{ - - berryObjectMacro(TrSelListener); - - TrSelListener(QmitkTensorReconstructionView* view) - { - m_View = view; - } - - void DoSelectionChanged(ISelection::ConstPointer selection) - { - // if(!m_View->IsVisible()) - // return; - // save current selection in member variable - m_View->m_CurrentSelection = selection.Cast(); - - // do something with the selected items - if(m_View->m_CurrentSelection) - { - bool foundDwiVolume = false; - bool foundTensorVolume = false; - - // iterate selection - for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); - i != m_View->m_CurrentSelection->End(); ++i) - { - - // extract datatree node - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - - // only look at interesting types - if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) - { - foundDwiVolume = true; - } - - // only look at interesting types - if(QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0) - { - foundTensorVolume = true; - } - } - } - - m_View->m_Controls->m_ItkReconstruction->setEnabled(foundDwiVolume); - m_View->m_Controls->m_TeemReconstruction->setEnabled(foundDwiVolume); - - m_View->m_Controls->m_TensorsToDWIButton->setEnabled(foundTensorVolume); - m_View->m_Controls->m_TensorsToQbiButton->setEnabled(foundTensorVolume); - - m_View->m_Controls->m_ResidualButton->setEnabled(foundDwiVolume && foundTensorVolume); - - - } - } - - void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) - { - // check, if selection comes from datamanager - if (part) - { - QString partname(part->GetPartName().c_str()); - if(partname.compare("Datamanager")==0) - { - - // apply selection - DoSelectionChanged(selection); - - } - } - } - - QmitkTensorReconstructionView* m_View; -}; - -QmitkTensorReconstructionView::QmitkTensorReconstructionView() -: QmitkFunctionality(), -m_Controls(NULL), -m_MultiWidget(NULL) -{ -} - -QmitkTensorReconstructionView::QmitkTensorReconstructionView(const QmitkTensorReconstructionView& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -QmitkTensorReconstructionView::~QmitkTensorReconstructionView() -{ - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); -} - -void QmitkTensorReconstructionView::CreateQtPartControl(QWidget *parent) -{ - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkTensorReconstructionViewControls; - m_Controls->setupUi(parent); - this->CreateConnections(); - - QStringList items; - items << "LLS (Linear Least Squares)" - << "MLE (Maximum Likelihood)" - << "NLS (Nonlinear Least Squares)" - << "WLS (Weighted Least Squares)"; - m_Controls->m_TensorEstimationTeemEstimationMethodCombo->addItems(items); - m_Controls->m_TensorEstimationTeemEstimationMethodCombo->setCurrentIndex(0); - - m_Controls->m_TensorEstimationManualThreashold->setChecked(false); - m_Controls->m_TensorEstimationTeemSigmaEdit->setText("NaN"); - m_Controls->m_TensorEstimationTeemNumItsSpin->setValue(1); - m_Controls->m_TensorEstimationTeemFuzzyEdit->setText("0.0"); - m_Controls->m_TensorEstimationTeemMinValEdit->setText("1.0"); - - m_Controls->m_TensorEstimationTeemNumItsLabel_2->setEnabled(true); - m_Controls->m_TensorEstimationTeemNumItsSpin->setEnabled(true); - - m_Controls->m_TensorsToDWIBValueEdit->setText("1000"); - - Advanced1CheckboxClicked(); - Advanced2CheckboxClicked(); - TeemCheckboxClicked(); - -#ifndef DIFFUSION_IMAGING_EXTENDED - m_Controls->m_TeemToggle->setVisible(false); -#endif - - // define data type for combobox - //m_Controls->m_ImageSelector->SetDataStorage( this->GetDefaultDataStorage() ); - //m_Controls->m_ImageSelector->SetPredicate( mitk::NodePredicateDataType::New("DiffusionImage") ); - } - - m_SelListener = berry::ISelectionListener::Pointer(new TrSelListener(this)); - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); -} - -void QmitkTensorReconstructionView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) -{ - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); - m_MultiWidget = &stdMultiWidget; -} - -void QmitkTensorReconstructionView::StdMultiWidgetNotAvailable() -{ - m_MultiWidget = NULL; -} - -void QmitkTensorReconstructionView::CreateConnections() -{ - if ( m_Controls ) - { - connect( (QObject*)(m_Controls->m_TeemToggle), SIGNAL(clicked()), this, SLOT(TeemCheckboxClicked()) ); - connect( (QObject*)(m_Controls->m_ItkReconstruction), SIGNAL(clicked()), this, SLOT(ItkReconstruction()) ); - connect( (QObject*)(m_Controls->m_TeemReconstruction), SIGNAL(clicked()), this, SLOT(TeemReconstruction()) ); - connect( (QObject*)(m_Controls->m_TensorEstimationTeemEstimationMethodCombo), SIGNAL(currentIndexChanged(int)), this, SLOT(MethodChoosen(int)) ); - connect( (QObject*)(m_Controls->m_Advanced1), SIGNAL(clicked()), this, SLOT(Advanced1CheckboxClicked()) ); - connect( (QObject*)(m_Controls->m_Advanced2), SIGNAL(clicked()), this, SLOT(Advanced2CheckboxClicked()) ); - connect( (QObject*)(m_Controls->m_TensorEstimationManualThreashold), SIGNAL(clicked()), this, SLOT(ManualThresholdClicked()) ); - connect( (QObject*)(m_Controls->m_TensorsToDWIButton), SIGNAL(clicked()), this, SLOT(TensorsToDWI()) ); - connect( (QObject*)(m_Controls->m_TensorsToQbiButton), SIGNAL(clicked()), this, SLOT(TensorsToQbi()) ); - connect( (QObject*)(m_Controls->m_ResidualButton), SIGNAL(clicked()), this, SLOT(ResidualCalculation()) ); - } -} - -void QmitkTensorReconstructionView::TeemCheckboxClicked() -{ - m_Controls->groupBox_3->setVisible(m_Controls-> - m_TeemToggle->isChecked()); -} - -void QmitkTensorReconstructionView::Advanced1CheckboxClicked() -{ - bool check = m_Controls-> - m_Advanced1->isChecked(); - - m_Controls->frame->setVisible(check); -} - -void QmitkTensorReconstructionView::Advanced2CheckboxClicked() -{ - bool check = m_Controls-> - m_Advanced2->isChecked(); - - m_Controls->frame_2->setVisible(check); -} - -void QmitkTensorReconstructionView::ManualThresholdClicked() -{ - m_Controls->m_TensorReconstructionThreasholdEdit_2->setEnabled( - m_Controls->m_TensorEstimationManualThreashold->isChecked()); -} - -void QmitkTensorReconstructionView::Activated() -{ - QmitkFunctionality::Activated(); -} - -void QmitkTensorReconstructionView::Deactivated() -{ - QmitkFunctionality::Deactivated(); -} - -void QmitkTensorReconstructionView::MethodChoosen(int method) -{ - m_Controls->m_TensorEstimationTeemNumItsLabel_2->setEnabled(method==3); - m_Controls->m_TensorEstimationTeemNumItsSpin->setEnabled(method==3); -} - -void QmitkTensorReconstructionView::ResidualCalculation() -{ - // Extract dwi and dti from current selection - // In case of multiple selections, take the first one, since taking all combinations is not meaningful - if(m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - mitk::DiffusionImage::Pointer diffImage - = mitk::DiffusionImage::New(); - - typedef float TTensorPixelType; - typedef itk::DiffusionTensor3D< TTensorPixelType > TensorPixelType; - typedef itk::Image< TensorPixelType, 3 > TensorImageType; - - TensorImageType::Pointer tensorImage; - - std::string nodename; - - - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) - { - - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) - { - diffImage = static_cast*>((node)->GetData()); - } - else if((QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0)) - { - mitk::TensorImage* mitkVol; - mitkVol = static_cast((node)->GetData()); - mitk::CastToItkImage(mitkVol, tensorImage); - node->GetStringProperty("name", nodename); - } - } - } - - - - typedef itk::TensorImageToDiffusionImageFilter< - TTensorPixelType, DiffusionPixelType > FilterType; - - FilterType::GradientListType gradientList; - mitk::DiffusionImage::GradientDirectionContainerType* gradients - = diffImage->GetDirections(); - - // Copy gradients vectors from gradients to gradientList - for(int i=0; iSize(); i++) - { - mitk::DiffusionImage::GradientDirectionType vec = gradients->at(i); - itk::Vector grad; - - grad[0] = vec[0]; - grad[1] = vec[1]; - grad[2] = vec[2]; - - gradientList.push_back(grad); - } - - - - //Initialize filter that calculates the modeled diffusion weighted signals - FilterType::Pointer filter = FilterType::New(); - filter->SetInput( tensorImage ); - filter->SetBValue(diffImage->GetB_Value()); - filter->SetGradientList(gradientList); - filter->Update(); - - - // TENSORS TO DATATREE - mitk::DiffusionImage::Pointer image = mitk::DiffusionImage::New(); - image->SetVectorImage( filter->GetOutput() ); - image->SetB_Value(diffImage->GetB_Value()); - image->SetDirections(gradientList); - image->SetOriginalDirections(gradientList); - image->InitializeFromVectorImage(); - mitk::DataNode::Pointer node=mitk::DataNode::New(); - node->SetData( image ); - - - QString newname; - newname = newname.append(nodename.c_str()); - newname = newname.append("_dwi"); - node->SetName(newname.toAscii()); - - - GetDefaultDataStorage()->Add(node); - - - typedef itk::ResidualImageFilter ResidualImageFilterType; - - ResidualImageFilterType::Pointer residualFilter = ResidualImageFilterType::New(); - residualFilter->SetInput(diffImage->GetVectorImage()); - residualFilter->SetSecondDiffusionImage(image->GetVectorImage()); - residualFilter->Update(); - - itk::Image::Pointer residualImage = itk::Image::New(); - residualImage = residualFilter->GetOutput(); - - mitk::Image::Pointer mitkResImg = mitk::Image::New(); - - mitk::CastToMitkImage(residualImage, mitkResImg); - // mitkResImg->InitializeByItk(residualImage.GetPointer()); - // image->SetVolume( residualImage->GetBufferPointer() ); - - // mitk::CastToMitkImage(residualImage, mitkResImg); - mitk::DataNode::Pointer resNode=mitk::DataNode::New(); - resNode->SetData( mitkResImg ); - resNode->SetName("Residual Image"); - GetDefaultDataStorage()->Add(resNode); - - m_MultiWidget->RequestUpdate(); - - - } -} - -void QmitkTensorReconstructionView::ItkReconstruction() -{ - Reconstruct(0); -} - -void QmitkTensorReconstructionView::TeemReconstruction() -{ - Reconstruct(1); -} - -void QmitkTensorReconstructionView::Reconstruct(int method) -{ - if (m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - int at = 0; - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) - { - - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) - { - set->InsertElement(at++, node); - } - } - } - - if(method == 0) - { - ItkTensorReconstruction(set); - } - - if(method == 1) - { - TeemTensorReconstruction(set); - } - - } -} - -void QmitkTensorReconstructionView::ItkTensorReconstruction -(mitk::DataStorage::SetOfObjects::Pointer inImages) -{ - try - { - itk::TimeProbe clock; - - int nrFiles = inImages->size(); - if (!nrFiles) return; - - QString status; - mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles); - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); - - std::vector nodes; - while ( itemiter != itemiterend ) // for all items - { - - mitk::DiffusionImage* vols = - static_cast*>( - (*itemiter)->GetData()); - - std::string nodename; - (*itemiter)->GetStringProperty("name", nodename); - ++itemiter; - - // TENSOR RECONSTRUCTION - clock.Start(); - MBI_INFO << "Tensor reconstruction "; - mitk::StatusBar::GetInstance()->DisplayText(status.sprintf( - "Tensor reconstruction for %s", nodename.c_str()).toAscii()); - typedef itk::DiffusionTensor3DReconstructionImageFilter< - DiffusionPixelType, DiffusionPixelType, TTensorPixelType > TensorReconstructionImageFilterType; - TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter = - TensorReconstructionImageFilterType::New(); - tensorReconstructionFilter->SetGradientImage( vols->GetDirections(), vols->GetVectorImage() ); - tensorReconstructionFilter->SetBValue(vols->GetB_Value()); - tensorReconstructionFilter->SetThreshold( m_Controls->m_TensorReconstructionThreasholdEdit->text().toFloat() ); - tensorReconstructionFilter->Update(); - clock.Stop(); - MBI_DEBUG << "took " << clock.GetMeanTime() << "s."; - - // TENSORS TO DATATREE - mitk::TensorImage::Pointer image = mitk::TensorImage::New(); - - - typedef itk::Image, 3> TensorImageType; - - TensorImageType::Pointer tensorImage; - tensorImage = tensorReconstructionFilter->GetOutput(); - - - - - // Check the tensor for negative eigenvalues - if(m_Controls->m_CheckNegativeEigenvalues->isChecked()) - { - typedef itk::ImageRegionIterator TensorImageIteratorType; - TensorImageIteratorType tensorIt(tensorImage, tensorImage->GetRequestedRegion()); - tensorIt.GoToBegin(); - - while(!tensorIt.IsAtEnd()) - { - - typedef itk::DiffusionTensor3D TensorType; - //typedef itk::Tensor TensorType2; - - TensorType tensor = tensorIt.Get(); - // TensorType2 tensor2; - - /* - for(int i=0; i SymEigenSystemType; - SymEigenSystemType eig (tensor2.GetVnlMatrix()); - for(unsigned int i=0; iInitializeByItk( tensorImage.GetPointer() ); - image->SetVolume( tensorReconstructionFilter->GetOutput()->GetBufferPointer() ); - mitk::DataNode::Pointer node=mitk::DataNode::New(); - node->SetData( image ); - - QString newname; - newname = newname.append(nodename.c_str()); - newname = newname.append("_dti"); - - SetDefaultNodeProperties(node, newname.toStdString()); - nodes.push_back(node); - - mitk::ProgressBar::GetInstance()->Progress(); - - } - - std::vector::iterator nodeIt; - for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt) - GetDefaultDataStorage()->Add(*nodeIt); - - mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii()); - m_MultiWidget->RequestUpdate(); - - } - catch (itk::ExceptionObject &ex) - { - MBI_INFO << ex ; - return ; - } -} - - - -void QmitkTensorReconstructionView::TeemTensorReconstruction -(mitk::DataStorage::SetOfObjects::Pointer inImages) -{ - try - { - itk::TimeProbe clock; - - int nrFiles = inImages->size(); - if (!nrFiles) return; - - QString status; - mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles); - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); - - std::vector nodes; - while ( itemiter != itemiterend ) // for all items - { - - mitk::DiffusionImage* vols = - static_cast*>( - (*itemiter)->GetData()); - - std::string nodename; - (*itemiter)->GetStringProperty("name", nodename); - ++itemiter; - - // TENSOR RECONSTRUCTION - clock.Start(); - MBI_INFO << "Teem Tensor reconstruction "; - mitk::StatusBar::GetInstance()->DisplayText(status.sprintf( - "Teem Tensor reconstruction for %s", nodename.c_str()).toAscii()); - typedef mitk::TeemDiffusionTensor3DReconstructionImageFilter< - DiffusionPixelType, TTensorPixelType > TensorReconstructionImageFilterType; - TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter = - TensorReconstructionImageFilterType::New(); - tensorReconstructionFilter->SetInput( vols ); - if(!m_Controls->m_TensorEstimationTeemSigmaEdit->text().contains(QString("NaN"))) - tensorReconstructionFilter->SetSigma( m_Controls->m_TensorEstimationTeemSigmaEdit->text().toFloat() ); - switch(m_Controls->m_TensorEstimationTeemEstimationMethodCombo->currentIndex()) - { - // items << "LLS (Linear Least Squares)" - //<< "MLE (Maximum Likelihood)" - //<< "NLS (Nonlinear Least Squares)" - //<< "WLS (Weighted Least Squares)"; - case 0: - tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsLLS); - break; - case 1: - tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsMLE); - break; - case 2: - tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsNLS); - break; - case 3: - tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsWLS); - break; - default: - tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsLLS); - } - tensorReconstructionFilter->SetNumIterations( m_Controls->m_TensorEstimationTeemNumItsSpin->value() ); - if(m_Controls->m_TensorEstimationManualThreashold->isChecked()) - tensorReconstructionFilter->SetConfidenceThreshold( m_Controls->m_TensorReconstructionThreasholdEdit_2->text().toDouble() ); - tensorReconstructionFilter->SetConfidenceFuzzyness( m_Controls->m_TensorEstimationTeemFuzzyEdit->text().toFloat() ); - tensorReconstructionFilter->SetMinPlausibleValue( m_Controls->m_TensorEstimationTeemMinValEdit->text().toDouble() ); - tensorReconstructionFilter->Update(); - clock.Stop(); - MBI_DEBUG << "took " << clock.GetMeanTime() << "s." ; - - // TENSORS TO DATATREE - mitk::DataNode::Pointer node2=mitk::DataNode::New(); - node2->SetData( tensorReconstructionFilter->GetOutputItk() ); - - QString newname; - newname = newname.append(nodename.c_str()); - newname = newname.append("_dtix"); - - SetDefaultNodeProperties(node2, newname.toStdString()); - nodes.push_back(node2); - - mitk::ProgressBar::GetInstance()->Progress(); - - } - - std::vector::iterator nodeIt; - for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt) - GetDefaultDataStorage()->Add(*nodeIt); - - mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii()); - m_MultiWidget->RequestUpdate(); - - } - catch (itk::ExceptionObject &ex) - { - MBI_INFO << ex ; - return ; - } -} - -void QmitkTensorReconstructionView::SetDefaultNodeProperties(mitk::DataNode::Pointer node, std::string name) -{ - node->SetProperty( "ShowMaxNumber", mitk::IntProperty::New( 500 ) ); - node->SetProperty( "Scaling", mitk::FloatProperty::New( 1.0 ) ); - node->SetProperty( "Normalization", mitk::OdfNormalizationMethodProperty::New()); - node->SetProperty( "ScaleBy", mitk::OdfScaleByProperty::New()); - node->SetProperty( "IndexParam1", mitk::FloatProperty::New(2)); - node->SetProperty( "IndexParam2", mitk::FloatProperty::New(1)); - node->SetProperty( "visible", mitk::BoolProperty::New( true ) ); - node->SetProperty( "VisibleOdfs", mitk::BoolProperty::New( false ) ); - node->SetProperty ("layer", mitk::IntProperty::New(100)); - node->SetProperty( "DoRefresh", mitk::BoolProperty::New( true ) ); - //node->SetProperty( "opacity", mitk::FloatProperty::New(1.0f) ); - - node->SetProperty( "name", mitk::StringProperty::New(name) ); -} - - -//node->SetProperty( "volumerendering", mitk::BoolProperty::New( false ) ); -//node->SetProperty( "use color", mitk::BoolProperty::New( true ) ); -//node->SetProperty( "texture interpolation", mitk::BoolProperty::New( true ) ); -//node->SetProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ); -//node->SetProperty( "layer", mitk::IntProperty::New(0)); -//node->SetProperty( "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ); -//node->SetOpacity(1.0f); -//node->SetColor(1.0,1.0,1.0); -//node->SetVisibility(true); -//node->SetProperty( "IsTensorVolume", mitk::BoolProperty::New( true ) ); - -//mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); -//mitk::LevelWindow levelwindow; -//// levelwindow.SetAuto( image ); -//levWinProp->SetLevelWindow( levelwindow ); -//node->GetPropertyList()->SetProperty( "levelwindow", levWinProp ); - -//// add a default rainbow lookup table for color mapping -//if(!node->GetProperty("LookupTable")) -//{ -// mitk::LookupTable::Pointer mitkLut = mitk::LookupTable::New(); -// vtkLookupTable* vtkLut = mitkLut->GetVtkLookupTable(); -// vtkLut->SetHueRange(0.6667, 0.0); -// vtkLut->SetTableRange(0.0, 20.0); -// vtkLut->Build(); -// mitk::LookupTableProperty::Pointer mitkLutProp = mitk::LookupTableProperty::New(); -// mitkLutProp->SetLookupTable(mitkLut); -// node->SetProperty( "LookupTable", mitkLutProp ); -//} -//if(!node->GetProperty("binary")) -// node->SetProperty( "binary", mitk::BoolProperty::New( false ) ); - -//// add a default transfer function -//mitk::TransferFunction::Pointer tf = mitk::TransferFunction::New(); -//node->SetProperty ( "TransferFunction", mitk::TransferFunctionProperty::New ( tf.GetPointer() ) ); - -//// set foldername as string property -//mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New( name ); -//node->SetProperty( "name", nameProp ); - -void QmitkTensorReconstructionView::TensorsToDWI() -{ - if (m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - int at = 0; - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) - { - - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0) - { - set->InsertElement(at++, node); - } - } - } - - DoTensorsToDWI(set); - } -} - -void QmitkTensorReconstructionView::TensorsToQbi() -{ - std::vector nodes = this->GetDataManagerSelection(); - for (int i=0; i TensorPixelType; - typedef itk::Image< TensorPixelType, 3 > TensorImageType; - - TensorImageType::Pointer itkvol = TensorImageType::New(); - mitk::CastToItkImage(dynamic_cast(tensorImageNode->GetData()), itkvol); - - typedef itk::TensorImageToQBallImageFilter< TTensorPixelType, TTensorPixelType > FilterType; - FilterType::Pointer filter = FilterType::New(); - filter->SetInput( itkvol ); - filter->Update(); - - typedef itk::Vector OutputPixelType; - typedef itk::Image OutputImageType; - - mitk::QBallImage::Pointer image = mitk::QBallImage::New(); - OutputImageType::Pointer outimg = filter->GetOutput(); - image->InitializeByItk( outimg.GetPointer() ); - image->SetVolume( outimg->GetBufferPointer() ); - mitk::DataNode::Pointer node = mitk::DataNode::New(); - node->SetData( image ); - QString newname; - newname = newname.append(tensorImageNode->GetName().c_str()); - newname = newname.append("_qbi"); - node->SetName(newname.toAscii()); - GetDefaultDataStorage()->Add(node); - } -} - -void QmitkTensorReconstructionView::OnSelectionChanged( std::vector nodes ) -{ - if ( !this->IsVisible() ) - return; - -} - -template -std::vector > QmitkTensorReconstructionView::MakeGradientList() -{ - std::vector > retval; - vnl_matrix_fixed* U = - itk::PointShell >::DistributePointShell(); - - for(int i=0; i v; - v[0] = U->get(0,i); v[1] = U->get(1,i); v[2] = U->get(2,i); - retval.push_back(v); - } - // Add 0 vector for B0 - itk::Vector v; - v.Fill(0.0); - retval.push_back(v); - - return retval; -} - -void QmitkTensorReconstructionView::DoTensorsToDWI -(mitk::DataStorage::SetOfObjects::Pointer inImages) -{ - try - { - itk::TimeProbe clock; - - int nrFiles = inImages->size(); - if (!nrFiles) return; - - QString status; - mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles); - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); - - std::vector nodes; - while ( itemiter != itemiterend ) // for all items - { - - std::string nodename; - (*itemiter)->GetStringProperty("name", nodename); - - mitk::TensorImage* vol = - static_cast((*itemiter)->GetData()); - - ++itemiter; - - typedef float TTensorPixelType; - typedef itk::DiffusionTensor3D< TTensorPixelType > TensorPixelType; - typedef itk::Image< TensorPixelType, 3 > TensorImageType; - - - TensorImageType::Pointer itkvol = TensorImageType::New(); - mitk::CastToItkImage(vol, itkvol); - - typedef itk::TensorImageToDiffusionImageFilter< - TTensorPixelType, DiffusionPixelType > FilterType; - - FilterType::GradientListType gradientList; - - switch(m_Controls->m_TensorsToDWINumDirsSelect->currentIndex()) - { - case 0: - gradientList = MakeGradientList<12>(); - break; - case 1: - gradientList = MakeGradientList<42>(); - break; - case 2: - gradientList = MakeGradientList<92>(); - break; - case 3: - gradientList = MakeGradientList<162>(); - break; - case 4: - gradientList = MakeGradientList<252>(); - break; - case 5: - gradientList = MakeGradientList<362>(); - break; - case 6: - gradientList = MakeGradientList<492>(); - break; - case 7: - gradientList = MakeGradientList<642>(); - break; - case 8: - gradientList = MakeGradientList<812>(); - break; - case 9: - gradientList = MakeGradientList<1002>(); - break; - default: - gradientList = MakeGradientList<92>(); - - } - - double bVal = m_Controls->m_TensorsToDWIBValueEdit->text().toDouble(); - - // DWI ESTIMATION - clock.Start(); - MBI_INFO << "DWI Estimation "; - mitk::StatusBar::GetInstance()->DisplayText(status.sprintf( - "DWI Estimation for %s", nodename.c_str()).toAscii()); - FilterType::Pointer filter = FilterType::New(); - filter->SetInput( itkvol ); - filter->SetBValue(bVal); - filter->SetGradientList(gradientList); - //filter->SetNumberOfThreads(1); - filter->Update(); - clock.Stop(); - MBI_DEBUG << "took " << clock.GetMeanTime() << "s."; - - itk::Vector v; - v[0] = 0; v[1] = 0; v[2] = 0; - gradientList.push_back(v); - - // TENSORS TO DATATREE - mitk::DiffusionImage::Pointer image = mitk::DiffusionImage::New(); - image->SetVectorImage( filter->GetOutput() ); - image->SetB_Value(bVal); - image->SetDirections(gradientList); - image->SetOriginalDirections(gradientList); - image->InitializeFromVectorImage(); - mitk::DataNode::Pointer node=mitk::DataNode::New(); - node->SetData( image ); - - mitk::DiffusionImageMapper::SetDefaultProperties(node); - - QString newname; - newname = newname.append(nodename.c_str()); - newname = newname.append("_dwi"); - node->SetName(newname.toAscii()); - - nodes.push_back(node); - - mitk::ProgressBar::GetInstance()->Progress(); - - } - - std::vector::iterator nodeIt; - for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt) - GetDefaultDataStorage()->Add(*nodeIt); - - mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii()); - m_MultiWidget->RequestUpdate(); - - } - catch (itk::ExceptionObject &ex) - { - MBI_INFO << ex ; - return ; - } -} diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionViewControls.ui b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionViewControls.ui deleted file mode 100644 index 7a1956d5d4..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionViewControls.ui +++ /dev/null @@ -1,552 +0,0 @@ - - - QmitkTensorReconstructionViewControls - - - - 0 - 0 - 345 - 836 - - - - - 0 - 0 - - - - true - - - QmitkTensorReconstructionViewControls - - - - - - ITK Reconstruction - - - - - - Advanced Settings - - - false - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - B0 Threshold - - - false - - - - - - - 0 - - - - - - - Check for negative eigenvalues - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - false - - - - - - - - - - - - ITK Tensor Reconstruction - - - - - - - - - - Estimate Diffusion Image from Tensors - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - QFormLayout::AllNonFixedFieldsGrow - - - 6 - - - 6 - - - 9 - - - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - B-Value - - - false - - - - - - - - 0 - 0 - - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - - - - - # Gradient Directions - - - - - - - 3 - - - - 12 - - - - - 42 - - - - - 92 - - - - - 162 - - - - - 252 - - - - - 362 - - - - - 492 - - - - - 642 - - - - - 812 - - - - - 1002 - - - - - - - - - - - false - - - - - - - - - - - - Diffusion Image Estimation - - - - - - - - - - Estimate Q-Ball Image from Tensors - - - - - - false - - - Calculate ODF value as tensor value in the according direction - - - - - - - - - Q-Ball Image Estimation - - - - - - - - - - true - - - Teem Reconstruction - - - true - - - - - - - Teem Reconstruction - - - - - - Advanced Settings - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - important in case of method wls - - - # Iterations - - - false - - - - - - - - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - Fuzzy confidence - - - false - - - - - - - - 0 - 0 - - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" - - - - - - - minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" - - - minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" - - - minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" - - - Min plausible value - - - false - - - - - - - Rician noise parameter (float) - - - Rician noise parameter (float) - - - Rician noise parameter (float) - - - Sigma - - - false - - - - - - - - 0 - 0 - - - - minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" - - - minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" - - - minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" - - - - - - - - 0 - 0 - - - - Rician noise parameter (float) - - - Rician noise parameter (float) - - - Rician noise parameter (float) - - - - - - - - - - Method - - - - - - - B0-Threshold - - - - - - - false - - - 0 - - - - - - - - - - false - - - Teem Tensor Reconstruction - - - - - - - - - - Residuals - - - - - - false - - - Calculate the residual from a dti and a dwi iimage - - - - - - - - - Residual Image Calculation - - - - - - - - - - Qt::Vertical - - - - 20 - 1150 - - - - - - - - - - diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp~ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp~ deleted file mode 100644 index 988aa100a2..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp~ +++ /dev/null @@ -1,54 +0,0 @@ -#include "mitkPluginActivator.h" - -#include - - -#include "src/internal/QmitkDiffusionImagingPublicPerspective.h" - -#include "src/internal/QmitkQBallReconstructionView.h" -#include "src/internal/QmitkPreprocessingView.h" -#include "src/internal/QmitkDiffusionDicomImportView.h" -#include "src/internal/QmitkDiffusionQuantificationView.h" -#include "src/internal/QmitkTensorReconstructionView.h" -#include "src/internal/QmitkControlVisualizationPropertiesView.h" -#include "src/internal/QmitkODFDetailsView.h" -#include "src/internal/QmitkGibbsTrackingView.h" -#include "src/internal/QmitkStochasticFiberTrackingView.h" -#include "src/internal/QmitkFiberProcessingView.h" -#include "src/internal/QmitkFiberBundleDeveloperView.h" -#include "src/internal/QmitkPartialVolumeAnalysisView.h" -#include "src/internal/QmitkIVIMView.h" -#include "src/internal/QmitkScreenshotMaker.h" -#include "src/internal/QmitkTractbasedSpatialStatisticsView.h" - -namespace mitk { - -void PluginActivator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionImagingPublicPerspective, context) - - BERRY_REGISTER_EXTENSION_CLASS(QmitkQBallReconstructionView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkPreprocessingView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionDicomImport, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionQuantificationView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkTensorReconstructionView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkControlVisualizationPropertiesView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkODFDetailsView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkGibbsTrackingView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkStochasticFiberTrackingView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkFiberProcessingView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkFiberBundleDeveloperView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkPartialVolumeAnalysisView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkIVIMView, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkScreenshotMaker, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkTractbasedSpatialStatisticsView, context) -} - -void PluginActivator::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) -} - -} - -Q_EXPORT_PLUGIN2(org_mitk_gui_qt_diffusionimaging, mitk::PluginActivator) diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/doxygen/modules.dox deleted file mode 100644 index 1c0369f27b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_diffusionimagingapp org.mitk.diffusionimagingapp Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_diffusionimagingapp_internal Internal - \ingroup org_mitk_diffusionimagingapp - - \brief This subcategory includes the internal classes of the org.mitk.diffusionimagingapp plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/manifest_headers.cmake deleted file mode 100644 index 6f2d820686..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/manifest_headers.cmake +++ /dev/null @@ -1,8 +0,0 @@ -set(Plugin-Name "MITK Diffusion") -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.ext) -set(Plugin-Activator QmitkDiffusionImagingAppApplicationPlugin) - - diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp deleted file mode 100644 index 649370ea3b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkDiffusionImagingAppIntroPart.h" - -#include "mitkNodePredicateDataType.h" -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#ifdef QT_WEBKIT -#include -#include -#endif -#include -#include -#include -#include -#include -#include - - -#include "QmitkStdMultiWidgetEditor.h" -#include "mitkPluginActivator.h" -#include "mitkDataStorageEditorInput.h" - -#include "mitkBaseDataIOFactory.h" -#include "mitkSceneIO.h" -#include "mitkProgressBar.h" -#include "mitkDataNodeFactory.h" -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" - -QmitkDiffusionImagingAppIntroPart::QmitkDiffusionImagingAppIntroPart() - : m_Controls(NULL) -{ - berry::IPreferences::Pointer workbenchPrefs = mitkPluginActivator::GetDefault()->GetPreferencesService()->GetSystemPreferences(); - workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); - workbenchPrefs->Flush(); -} - -QmitkDiffusionImagingAppIntroPart::~QmitkDiffusionImagingAppIntroPart() -{ - // if the workbench is not closing (that means, welcome screen was closed explicitly), set "Show_intro" false - if (!this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) - { - berry::IPreferences::Pointer workbenchPrefs = mitkPluginActivator::GetDefault()->GetPreferencesService()->GetSystemPreferences(); - workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); - workbenchPrefs->Flush(); - } - else - { - berry::IPreferences::Pointer workbenchPrefs = mitkPluginActivator::GetDefault()->GetPreferencesService()->GetSystemPreferences(); - workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); - workbenchPrefs->Flush(); - } - - // if workbench is not closing (Just welcome screen closing), open last used perspective - if (this->GetIntroSite()->GetPage()->GetPerspective()->GetId() - == "org.mitk.diffusionimagingapp.perspectives.welcome" && !this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) - { - berry::IPerspectiveDescriptor::Pointer perspective = this->GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->GetPerspectiveRegistry()->FindPerspectiveWithId("org.mitk.diffusionimagingapp.perspectives.diffusionimagingapp"); - if (perspective) - { - this->GetIntroSite()->GetPage()->SetPerspective(perspective); - } - } - -} - - -void QmitkDiffusionImagingAppIntroPart::CreateQtPartControl(QWidget* parent) -{ - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkWelcomeScreenViewControls; - m_Controls->setupUi(parent); -#ifdef QT_WEBKIT - - // create a QWebView as well as a QWebPage and QWebFrame within the QWebview - m_view = new QWebView(parent); - m_view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); - - QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/mitkdiffusionimagingappwelcomeview.html"), QUrl::TolerantMode ); - m_view->load( urlQtResource ); - - // adds the webview as a widget - parent->layout()->addWidget(m_view); - this->CreateConnections(); -#else - parent->layout()->addWidget(new QLabel("

Please install Qt with the WebKit option to see cool pictures!

")); -#endif - } -} - -#ifdef QT_WEBKIT -void QmitkDiffusionImagingAppIntroPart::CreateConnections() -{ - if ( m_Controls ) - { - connect( (QObject*)(m_view->page()), SIGNAL(linkClicked(const QUrl& )), this, SLOT(DelegateMeTo(const QUrl& )) ); - } -} - - -void QmitkDiffusionImagingAppIntroPart::DelegateMeTo(const QUrl& showMeNext) -{ - QString scheme = showMeNext.scheme(); - QByteArray urlHostname = showMeNext.encodedHost(); - QByteArray urlPath = showMeNext.encodedPath(); - QByteArray dataset = showMeNext.encodedQueryItemValue("dataset"); - QByteArray clear = showMeNext.encodedQueryItemValue("clear"); - - if (scheme.isEmpty()) MITK_INFO << " empty scheme of the to be delegated link" ; - - // if the scheme is set to mitk, it is to be tested which action should be applied - if (scheme.contains(QString("mitk")) ) - { - if(urlPath.isEmpty() ) MITK_INFO << " mitk path is empty " ; - - // searching for the perspective keyword within the host name - if(urlHostname.contains(QByteArray("perspectives")) ) - { - // the simplified method removes every whitespace - // ( whitespace means any character for which the standard C++ isspace() method returns true) - urlPath = urlPath.simplified(); - QString tmpPerspectiveId(urlPath.data()); - tmpPerspectiveId.replace(QString("/"), QString("") ); - std::string perspectiveId = tmpPerspectiveId.toStdString(); - - // is working fine as long as the perspective id is valid, if not the application crashes - GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); - - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(); - berry::IEditorPart::Pointer editor = GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); - - - QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; - mitk::DataStorage::Pointer dataStorage; - - if (editor.Cast().IsNull()) - { - editorInput = new mitk::DataStorageEditorInput(); - dataStorage = editorInput->GetDataStorageReference()->GetDataStorage(); - } - else - { - multiWidgetEditor = editor.Cast(); - multiWidgetEditor->GetStdMultiWidget()->RequestUpdate(); - dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); - } - - bool dsmodified = false; - if(dataStorage.IsNotNull() && dsmodified) - { - // 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 = dataStorage->GetSubset(pred); - - if(rs->Size() > 0) - { - // calculate bounding geometry of these nodes - mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - } - } - - } - // searching for the load - if(urlHostname.contains(QByteArray("perspectives")) ) - { - // the simplified method removes every whitespace - // ( whitespace means any character for which the standard C++ isspace() method returns true) - urlPath = urlPath.simplified(); - QString tmpPerspectiveId(urlPath.data()); - tmpPerspectiveId.replace(QString("/"), QString("") ); - std::string perspectiveId = tmpPerspectiveId.toStdString(); - - // is working fine as long as the perspective id is valid, if not the application crashes - GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); - - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(); - GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); - } - else - { - MITK_INFO << "Unkown mitk action keyword (see documentation for mitk links)" ; - } - } - // if the scheme is set to http, by default no action is performed, if an external webpage needs to be - // shown it should be implemented below - else if (scheme.contains(QString("http")) ) - { - QDesktopServices::openUrl(showMeNext); -// m_view->load( ) ; - } - else if(scheme.contains("qrc")) - { - m_view->load(showMeNext); - } - -} - -#endif - -void QmitkDiffusionImagingAppIntroPart::StandbyStateChanged(bool standby) -{ - -} - - -void QmitkDiffusionImagingAppIntroPart::SetFocus() -{ - -} diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/doxygen/modules.dox deleted file mode 100644 index 4afd7b3e69..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_dtiatlasapp org.mitk.dtiatlasapp Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_dtiatlasapp_internal Internal - \ingroup org_mitk_dtiatlasapp - - \brief This subcategory includes the internal classes of the org.mitk.dtiatlasapp plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/manifest_headers.cmake deleted file mode 100644 index 0c8d7d5dd8..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/manifest_headers.cmake +++ /dev/null @@ -1,8 +0,0 @@ -set(Plugin-Name "DTI Atlas") -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.ext) -set(Plugin-Activator QmitkDTIAtlasAppApplicationPlugin) - - diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.cpp b/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.cpp deleted file mode 100644 index 77bed8dc62..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkDTIAtlasAppIntroPart.h" - -#include "mitkNodePredicateDataType.h" -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#ifdef QT_WEBKIT -#include -#include -#endif -#include -#include -#include -#include -#include -#include - - -#include "QmitkStdMultiWidgetEditor.h" -#include "QmitkDTIAtlasAppApplicationPlugin.h" -#include "mitkDataStorageEditorInput.h" - -#include "mitkBaseDataIOFactory.h" -#include "mitkSceneIO.h" -#include "mitkProgressBar.h" -#include "mitkDataNodeFactory.h" -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" - -QmitkDTIAtlasAppIntroPart::QmitkDTIAtlasAppIntroPart() - : m_Controls(NULL) -{ - berry::IPreferences::Pointer workbenchPrefs = QmitkDTIAtlasAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); - workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); - workbenchPrefs->Flush(); -} - -QmitkDTIAtlasAppIntroPart::~QmitkDTIAtlasAppIntroPart() -{ - // if the workbench is not closing (that means, welcome screen was closed explicitly), set "Show_intro" false - if (!this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) - { - berry::IPreferences::Pointer workbenchPrefs = QmitkDTIAtlasAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); - workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); - workbenchPrefs->Flush(); - } - else - { - berry::IPreferences::Pointer workbenchPrefs = QmitkDTIAtlasAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); - workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); - workbenchPrefs->Flush(); - } - - // if workbench is not closing (Just welcome screen closing), open last used perspective - if (this->GetIntroSite()->GetPage()->GetPerspective()->GetId() - == "org.mitk.dtiatlasapp.perspectives.welcome" && !this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) - { - berry::IPerspectiveDescriptor::Pointer perspective = this->GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->GetPerspectiveRegistry()->FindPerspectiveWithId("org.mitk.dtiatlasapp.perspectives.dtiatlasapp"); - if (perspective) - { - this->GetIntroSite()->GetPage()->SetPerspective(perspective); - } - } - -} - - -void QmitkDTIAtlasAppIntroPart::CreateQtPartControl(QWidget* parent) -{ - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkWelcomeScreenViewControls; - m_Controls->setupUi(parent); -#ifdef QT_WEBKIT - - // create a QWebView as well as a QWebPage and QWebFrame within the QWebview - m_view = new QWebView(parent); - m_view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); - - QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/mitkdtiatlasappwelcomeview.html"), QUrl::TolerantMode ); - m_view->load( urlQtResource ); - - // adds the webview as a widget - parent->layout()->addWidget(m_view); - this->CreateConnections(); -#else - parent->layout()->addWidget(new QLabel("

Please install Qt with the WebKit option to see cool pictures!

")); -#endif - } -} - -#ifdef QT_WEBKIT -void QmitkDTIAtlasAppIntroPart::CreateConnections() -{ - if ( m_Controls ) - { - connect( (QObject*)(m_view->page()), SIGNAL(linkClicked(const QUrl& )), this, SLOT(DelegateMeTo(const QUrl& )) ); - } -} - - -void QmitkDTIAtlasAppIntroPart::DelegateMeTo(const QUrl& showMeNext) -{ - QString scheme = showMeNext.scheme(); - QByteArray urlHostname = showMeNext.encodedHost(); - QByteArray urlPath = showMeNext.encodedPath(); - QByteArray dataset = showMeNext.encodedQueryItemValue("dataset"); - QByteArray clear = showMeNext.encodedQueryItemValue("clear"); - - if (scheme.isEmpty()) MITK_INFO << " empty scheme of the to be delegated link" ; - - // if the scheme is set to mitk, it is to be tested which action should be applied - if (scheme.contains(QString("mitk")) ) - { - if(urlPath.isEmpty() ) MITK_INFO << " mitk path is empty " ; - - // searching for the perspective keyword within the host name - if(urlHostname.contains(QByteArray("perspectives")) ) - { - // the simplified method removes every whitespace - // ( whitespace means any character for which the standard C++ isspace() method returns true) - urlPath = urlPath.simplified(); - QString tmpPerspectiveId(urlPath.data()); - tmpPerspectiveId.replace(QString("/"), QString("") ); - std::string perspectiveId = tmpPerspectiveId.toStdString(); - - // is working fine as long as the perspective id is valid, if not the application crashes - GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); - - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(); - berry::IEditorPart::Pointer editor = GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); - - - QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; - mitk::DataStorage::Pointer dataStorage; - - if (editor.Cast().IsNull()) - { - editorInput = new mitk::DataStorageEditorInput(); - dataStorage = editorInput->GetDataStorageReference()->GetDataStorage(); - } - else - { - multiWidgetEditor = editor.Cast(); - multiWidgetEditor->GetStdMultiWidget()->RequestUpdate(); - dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); - } - - bool dsmodified = false; - - QString *fileName = new QString(dataset.data()); - - if ( fileName->right(5) == ".mitk" ) - { - mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); - - bool clearDataStorageFirst(false); - QString *sClear = new QString(clear.data()); - if ( sClear->right(4) == "true" ) - { - clearDataStorageFirst = true; - } - - mitk::ProgressBar::GetInstance()->AddStepsToDo(2); - dataStorage = sceneIO->LoadScene( fileName->toLocal8Bit().constData(), dataStorage, clearDataStorageFirst ); - dsmodified = true; - mitk::ProgressBar::GetInstance()->Progress(2); - } - else - { - mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); - try - { - nodeReader->SetFileName(fileName->toLocal8Bit().data()); - nodeReader->Update(); - for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) - { - mitk::DataNode::Pointer node; - node = nodeReader->GetOutput(i); - if ( node->GetData() != NULL ) - { - dataStorage->Add(node); - dsmodified = true; - } - } - } - catch(...) - { - MITK_INFO << "Could not open file!"; - } - } - - - - if(dataStorage.IsNotNull() && dsmodified) - { - // 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 = dataStorage->GetSubset(pred); - - if(rs->Size() > 0) - { - // calculate bounding geometry of these nodes - mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - } - } - - - - - - } - // searching for the load - if(urlHostname.contains(QByteArray("perspectives")) ) - { - // the simplified method removes every whitespace - // ( whitespace means any character for which the standard C++ isspace() method returns true) - urlPath = urlPath.simplified(); - QString tmpPerspectiveId(urlPath.data()); - tmpPerspectiveId.replace(QString("/"), QString("") ); - std::string perspectiveId = tmpPerspectiveId.toStdString(); - - // is working fine as long as the perspective id is valid, if not the application crashes - GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); - - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(); - GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); - } - else - { - MITK_INFO << "Unkown mitk action keyword (see documentation for mitk links)" ; - } - } - // if the scheme is set to http, by default no action is performed, if an external webpage needs to be - // shown it should be implemented below - else if (scheme.contains(QString("http")) ) - { - QDesktopServices::openUrl(showMeNext); -// m_view->load( ) ; - } - else if(scheme.contains("qrc")) - { - m_view->load(showMeNext); - } - -} - -#endif - -void QmitkDTIAtlasAppIntroPart::StandbyStateChanged(bool standby) -{ - -} - - -void QmitkDTIAtlasAppIntroPart::SetFocus() -{ - -} diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox deleted file mode 100644 index 2f71416e75..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_examples org.mitk.gui.qt.examples Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_examples_internal Internal - \ingroup org_mitk_gui_qt_examples - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.examples plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.examples/manifest_headers.cmake deleted file mode 100644 index efe77111d3..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.examples/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -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) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox deleted file mode 100644 index 3a07ada07d..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_examplesopencv org.mitk.gui.qt.examplesopencv Plugin - \ingroup MITKPlugins - - \brief This is the examplesopencv plugin. - -*/ - -/** - \defgroup org_mitk_gui_qt_examplesopencv_internal Internal - \ingroup org_mitk_gui_qt_examplesopencv - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.examplesopencv plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake deleted file mode 100644 index ff2f19d47b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -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) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.ext/documentation/doxygen/modules.dox deleted file mode 100644 index 8ce314328a..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_ext org.mitk.gui.qt.ext Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_ext_internal Internal - \ingroup org_mitk_gui_qt_ext - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.ext plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/files.cmake b/Modules/Bundles/org.mitk.gui.qt.ext/files.cmake deleted file mode 100644 index 06c28a6161..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/files.cmake +++ /dev/null @@ -1,56 +0,0 @@ -SET(SRC_CPP_FILES - QmitkCommonWorkbenchWindowAdvisor.cpp - QmitkExtActionBarAdvisor.cpp - QmitkExtWorkbenchWindowAdvisor.cpp - QmitkExtFileOpenAction.cpp - QmitkExtDnDFrameWidget.cpp - QmitkExtFileSaveProjectAction.cpp -) - -SET(INTERNAL_CPP_FILES - QmitkAppInstancesPreferencePage.cpp - QmitkCommonExtPlugin.cpp - QmitkInputDevicesPrefPage.cpp - QmitkModuleView.cpp -) - -SET(UI_FILES - src/internal/QmitkAppInstancesPreferencePage.ui -) - -SET(MOC_H_FILES - src/QmitkExtFileOpenAction.h - src/QmitkExtFileSaveProjectAction.h - src/QmitkExtDnDFrameWidget.h - src/QmitkExtWorkbenchWindowAdvisor.h - - src/internal/QmitkAppInstancesPreferencePage.h - src/internal/QmitkCommonExtPlugin.h - src/internal/QmitkExtWorkbenchWindowAdvisorHack.h - src/internal/QmitkInputDevicesPrefPage.h - src/internal/QmitkModuleView.h -) - -SET(CACHED_RESOURCE_FILES -# list of resource files which can be used by the plug-in -# system without loading the plug-ins shared library, -# for example the icon used in the menu and tabs for the -# plug-in views in the workbench - plugin.xml - resources/ModuleView.png -) - -SET(QRC_FILES -# uncomment the following line if you want to use Qt resources - resources/org_mitk_gui_qt_ext.qrc -) - -SET(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.ext/manifest_headers.cmake deleted file mode 100644 index 7b96659458..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "Common Qt Ext Plugin") -set(Plugin-Version "0.1") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.core.ext org.mitk.gui.qt.common) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.cpp deleted file mode 100644 index aab460bacd..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2010-02-25 08:28:53 +0100 (Do, 25 Feb 2010) $ - Version: $Revision: 21469 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkCommonWorkbenchWindowAdvisor.h" - -QmitkCommonWorkbenchWindowAdvisor::QmitkCommonWorkbenchWindowAdvisor( berry::IWorkbenchWindowConfigurer::Pointer configurer ) -: berry::WorkbenchWindowAdvisor(configurer) -{ - m_FunctionalityCoordinator = QmitkFunctionalityCoordinator::New(); - m_FunctionalityCoordinator->SetWindow(configurer->GetWindow()); -} - -void QmitkCommonWorkbenchWindowAdvisor::PostWindowCreate() -{ - -} \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.h deleted file mode 100644 index 8f6f8bc35b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkCommonWorkbenchWindowAdvisor.h +++ /dev/null @@ -1,42 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkCommonWorkbenchWindowAdvisor_h -#define QmitkCommonWorkbenchWindowAdvisor_h - -#include - -#include -#include - -/// -/// \brief a WorkbenchWindowAdvisor that does common stuff when opening a MITK Workbench (e.g adding a -/// QmitkFunctionalityCoordinator instance) -/// \see QmitkFunctionalityCoordinator -/// -class MITK_QT_COMMON_EXT_EXPORT QmitkCommonWorkbenchWindowAdvisor : public berry::WorkbenchWindowAdvisor -{ -public: - QmitkCommonWorkbenchWindowAdvisor( berry::IWorkbenchWindowConfigurer::Pointer configurer ); - void PostWindowCreate(); - -private: - QmitkFunctionalityCoordinator::Pointer m_FunctionalityCoordinator; - -}; - -#endif /*QMITKEXTWORKBENCHWINDOWADVISOR_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.cpp deleted file mode 100644 index 0dcacedda9..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ -Version: $Revision: 18127 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include -#include - - -// berry Includes -#include - -#include -#include "mitkIDataStorageService.h" -#include "mitkDataStorageEditorInput.h" -#include "mitkRenderingManager.h" - -#include "mitkProperties.h" -#include "mitkNodePredicateData.h" -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" - - -#include "mitkSceneIO.h" -#include "mitkProgressBar.h" - -QmitkExtDnDFrameWidget::QmitkExtDnDFrameWidget(QWidget *parent) - : QWidget(parent) -{ - setAcceptDrops(true); -} - -void QmitkExtDnDFrameWidget::dragEnterEvent( QDragEnterEvent *event ) -{ // accept drags - event->accept(); -} -void QmitkExtDnDFrameWidget::dropEvent( QDropEvent * event ) -{ //open dragged files - - mitk::IDataStorageService::Pointer service = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); - - mitk::DataStorage::Pointer ds; - if (service.IsNotNull()) - ds = service->GetActiveDataStorage()->GetDataStorage(); - else - return; - - QList fileNames = event->mimeData()->urls(); - - bool dsmodified = false; - for (QList::Iterator fileName = fileNames.begin(); - fileName != fileNames.end(); ++fileName) - { - if ( fileName->toLocalFile().right(5) == ".mitk" ) - { - mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); - - bool clearDataStorageFirst(false); - mitk::ProgressBar::GetInstance()->AddStepsToDo(2); - ds = sceneIO->LoadScene( fileName->toLocalFile().toLocal8Bit().constData(), ds, clearDataStorageFirst ); - dsmodified = true; - mitk::ProgressBar::GetInstance()->Progress(2); - } - else - { - mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); - try - { - nodeReader->SetFileName(fileName->toLocalFile().toLatin1().data()); - nodeReader->Update(); - for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) - { - mitk::DataNode::Pointer node; - node = nodeReader->GetOutput(i); - if ( node->GetData() != NULL ) - { - ds->Add(node); - dsmodified = true; - } - } - } - catch(...) - { - - } - } - } - - if(dsmodified) - { - // 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 = ds->GetSubset(pred); - // calculate bounding geometry of these nodes - mitk::TimeSlicedGeometry::Pointer bounds = ds->ComputeBoundingGeometry3D(rs); - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - } -} \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.h deleted file mode 100644 index 19d245ac67..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtDnDFrameWidget.h +++ /dev/null @@ -1,51 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ -Version: $Revision: 16224 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkExtDndFrameWidget_h -#define QmitkExtDndFrameWidget_h - -#ifdef __MINGW32__ -// We need to inlclude winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -#include -#include -//drag&drop -class QDragEnterEvent; -class QDropEvent; -class QMouseEvent; - -class MITK_QT_COMMON_EXT_EXPORT QmitkExtDnDFrameWidget : public QWidget -{ - Q_OBJECT - -public: - QmitkExtDnDFrameWidget(QWidget *parent); - - -private: - void dragEnterEvent( QDragEnterEvent *event ); - void dropEvent( QDropEvent * event ); - - -}; - - -#endif diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.cpp deleted file mode 100644 index 6e1fcca883..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkExtFileOpenAction.h" - -#include -#include -#include - -#include "mitkCoreObjectFactory.h" -#include "mitkSceneIO.h" -#include "mitkProgressBar.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "mitkProperties.h" -#include "mitkNodePredicateData.h" -#include "mitkNodePredicateNot.h" -#include "mitkNodePredicateProperty.h" - - -#include "QmitkStdMultiWidgetEditor.h" - -QmitkExtFileOpenAction::QmitkExtFileOpenAction(berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - this->init(window); -} - -QmitkExtFileOpenAction::QmitkExtFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - this->setIcon(icon); - - this->init(window); -} - -void QmitkExtFileOpenAction::init(berry::IWorkbenchWindow::Pointer window) -{ - m_Window = window; - this->setParent(static_cast(m_Window->GetShell()->GetControl())); - this->setText("&Open..."); - this->setToolTip("Open data files (images, surfaces,...) and project files (.mitk)"); - - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - - m_GeneralPreferencesNode = prefService->GetSystemPreferences()->Node("/General"); - - this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); -} - -void QmitkExtFileOpenAction::Run() -{ - /** - * @brief stores the last path of last opened file - */ - static QString m_LastPath; - - if(m_GeneralPreferencesNode.Lock().IsNotNull()) - { - if(m_LastPath.isEmpty()) - m_LastPath = QString::fromStdString(m_GeneralPreferencesNode.Lock()->Get("LastFileOpenPath", "")); - } - - - //QFileDialog dialog(static_cast(m_Window->GetShell()->GetControl())); - //dialog.setFileMode(QFileDialog::ExistingFiles); - //QStringList filters; - //filters << "Images (*.pic *.pic.gz *.vti *.dcm *.nhdr *.nrrd *.mhd)" - // << "Surfaces (*.stl *.vtk *.vtp)" - // << "MITK Pointset (*.mps)" - // << "All Files (*.*)"; - //dialog.setFilters(filters); - - std::stringstream ss; - ss << mitk::CoreObjectFactory::GetInstance()->GetFileExtensions(); - - std::string fileExtensions = ss.str(); - fileExtensions.append(";;MITK Scene Files (*.mitk)"); - fileExtensions.insert( fileExtensions.find("all (") + 5, "*.mitk " ); - - QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Open", m_LastPath, fileExtensions.c_str() ); - - //if (dialog.exec()) - // fileNames = dialog.selectedFiles(); - - if (fileNames.empty()) - return; - - // check if there is an open perspective, if not open the default perspective - if (m_Window->GetActivePage().IsNull()) - { - std::string defaultPerspId = m_Window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective(); - m_Window->GetWorkbench()->ShowPerspective(defaultPerspId, m_Window); - } - - QFileInfo info(fileNames.at(0)); - m_LastPath = info.filePath(); - - if(m_GeneralPreferencesNode.Lock().IsNotNull()) - { - m_GeneralPreferencesNode.Lock()->Put("LastFileOpenPath", m_LastPath.toStdString()); - m_GeneralPreferencesNode.Lock()->Flush(); - } - - mitk::DataStorageEditorInput::Pointer editorInput; - mitk::DataStorage::Pointer dataStorage; - QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; - berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->GetActiveEditor(); - - if (editor.Cast().IsNull()) - { - editorInput = new mitk::DataStorageEditorInput(); - dataStorage = editorInput->GetDataStorageReference()->GetDataStorage(); - } - else - { - multiWidgetEditor = editor.Cast(); - dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); - } - - if (multiWidgetEditor.IsNull()) - { - berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); - multiWidgetEditor = editor.Cast(); - } - else - { - multiWidgetEditor->GetStdMultiWidget()->RequestUpdate(); - } - - bool dsmodified = false; - - for (QStringList::Iterator fileName = fileNames.begin(); - fileName != fileNames.end(); ++fileName) - { - if ( fileName->right(5) == ".mitk" ) - { - mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); - - bool clearDataStorageFirst(false); - mitk::ProgressBar::GetInstance()->AddStepsToDo(2); - dataStorage = sceneIO->LoadScene( fileName->toLocal8Bit().constData(), dataStorage, clearDataStorageFirst ); - dsmodified = true; - mitk::ProgressBar::GetInstance()->Progress(2); - } - else - { - mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); - try - { - // the ITK Nrrd file reader cannot handle '/' in file path on Win 64bit - nodeReader->SetFileName(QDir::fromNativeSeparators(*fileName).toStdString()); - nodeReader->Update(); - for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) - { - mitk::DataNode::Pointer node; - node = nodeReader->GetOutput(i); - if ( node->GetData() != NULL ) - { - dataStorage->Add(node); - dsmodified = true; - } - } - } - catch(...) - { - - } - } - } - - - if(dsmodified) - { - // 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 = dataStorage->GetSubset(pred); - // calculate bounding geometry of these nodes - mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - } -} diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.h deleted file mode 100644 index 7bffaaca62..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileOpenAction.h +++ /dev/null @@ -1,55 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKEXTFILEOPENACTION_H_ -#define QMITKEXTFILEOPENACTION_H_ - -#ifdef __MINGW32__ -// We need to inlclude winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -#include -#include - -#include - -#include -#include - -class MITK_QT_COMMON_EXT_EXPORT QmitkExtFileOpenAction : public QAction -{ - Q_OBJECT - -public: - QmitkExtFileOpenAction(berry::IWorkbenchWindow::Pointer window); - QmitkExtFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window); - -protected slots: - - void Run(); - -private: - void init ( berry::IWorkbenchWindow::Pointer window ); - berry::IWorkbenchWindow::Pointer m_Window; - berry::IPreferences::WeakPtr m_GeneralPreferencesNode; -}; - - -#endif /*QMITKEXTFILEOPENACTION_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.cpp deleted file mode 100644 index 254db84be1..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-10-07 16:14:59 +0200 (Mi, 07 Okt 2009) $ -Version: $Revision: 19343 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkExtFileSaveProjectAction.h" - -#include -#include - -#include "mitkSceneIO.h" -#include "mitkProgressBar.h" -#include -#include -#include - -#include -#include -#include -#include - -#include "QmitkStdMultiWidgetEditor.h" - -QmitkExtFileSaveProjectAction::QmitkExtFileSaveProjectAction(berry::IWorkbenchWindow::Pointer window) -: QAction(0) -{ - m_Window = window; - this->setParent(static_cast(m_Window->GetShell()->GetControl())); - this->setText("&Save Project..."); - this->setToolTip("Save content of Data Manager as a .mitk project file"); - m_Window = window; - - this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); -} - -void QmitkExtFileSaveProjectAction::Run() -{ - try - { - /** - * @brief stores the last path of last opened file - */ - static QString m_LastPath; - - QString fileName = QFileDialog::getSaveFileName(NULL, "Save MITK scene", m_LastPath, "MITK scene files (*.mitk)", NULL ); - - if (fileName.isEmpty() ) - return; - - m_LastPath = fileName; - - - if ( fileName.right(5) != ".mitk" ) - fileName += ".mitk"; - - mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); - - mitk::DataStorageEditorInput::Pointer editorInput; - mitk::DataStorage::Pointer storage; - QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; - berry::IEditorPart::Pointer editor = m_Window->GetActivePage()->GetActiveEditor(); - if (editor.Cast().IsNull()) - { - editorInput = new mitk::DataStorageEditorInput(); - storage = editorInput->GetDataStorageReference()->GetDataStorage(); - } - else - { - multiWidgetEditor = editor.Cast(); - storage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); - } - - mitk::ProgressBar::GetInstance()->AddStepsToDo(2); - - /* Build list of nodes that should be saved */ - - mitk::NodePredicateNot::Pointer isNotHelperObject = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true))); - - mitk::DataStorage::SetOfObjects::ConstPointer nodesToBeSaved = storage->GetSubset(isNotHelperObject); - if ( !sceneIO->SaveScene( nodesToBeSaved, storage, fileName.toLocal8Bit().constData() ) ) - { - QMessageBox::information(NULL, - "Scene saving", - "Scene could not be written completely. Please check the log.", - QMessageBox::Ok); - - } - mitk::ProgressBar::GetInstance()->Progress(2); - - mitk::SceneIO::FailedBaseDataListType::ConstPointer failedNodes = sceneIO->GetFailedNodes(); - if (!failedNodes->empty()) - { - std::stringstream ss; - ss << "The following nodes could not be serialized:" << std::endl; - for ( mitk::SceneIO::FailedBaseDataListType::const_iterator iter = failedNodes->begin(); - iter != failedNodes->end(); - ++iter ) - { - ss << " - "; - if ( mitk::BaseData* data =(*iter)->GetData() ) - { - ss << data->GetNameOfClass(); - } - else - { - ss << "(NULL)"; - } - - ss << " contained in node '" << (*iter)->GetName() << "'" << std::endl; - } - - MITK_WARN << ss.str(); - } - - mitk::PropertyList::ConstPointer failedProperties = sceneIO->GetFailedProperties(); - if (!failedProperties->GetMap()->empty()) - { - std::stringstream ss; - ss << "The following properties could not be serialized:" << std::endl; - const mitk::PropertyList::PropertyMap* propmap = failedProperties->GetMap(); - for ( mitk::PropertyList::PropertyMap::const_iterator iter = propmap->begin(); - iter != propmap->end(); - ++iter ) - { - ss << " - " << iter->second->GetNameOfClass() << " associated to key '" << iter->first << "'" << std::endl; - } - - MITK_WARN << ss.str(); - } - } - catch (std::exception& e) - { - MITK_ERROR << "Exception caught during scene saving: " << e.what(); - } -} diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp deleted file mode 100644 index 6e3cc7b68b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp +++ /dev/null @@ -1,1144 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkExtWorkbenchWindowAdvisor.h" -#include "QmitkExtActionBarAdvisor.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// UGLYYY -#include "internal/QmitkExtWorkbenchWindowAdvisorHack.h" -#include "internal/QmitkCommonExtPlugin.h" -#include "mitkUndoController.h" -#include "mitkVerboseLimitedLinearUndo.h" -#include -#include -#include -#include - -QmitkExtWorkbenchWindowAdvisorHack -* QmitkExtWorkbenchWindowAdvisorHack::undohack = -new QmitkExtWorkbenchWindowAdvisorHack(); - -QString QmitkExtWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME = "QtSettings.ini"; - -class PartListenerForTitle: public berry::IPartListener -{ -public: - - PartListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : - windowAdvisor(wa) - { - } - - Events::Types GetPartEventTypes() const - { - return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED - | Events::HIDDEN | Events::VISIBLE; - } - - void PartActivated(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref.Cast ()) - { - windowAdvisor->UpdateTitle(false); - } - } - - void PartBroughtToTop(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref.Cast ()) - { - windowAdvisor->UpdateTitle(false); - } - } - - void PartClosed(berry::IWorkbenchPartReference::Pointer /*ref*/) - { - windowAdvisor->UpdateTitle(false); - } - - void PartHidden(berry::IWorkbenchPartReference::Pointer ref) - { - if (!windowAdvisor->lastActiveEditor.Expired() && - ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) - { - windowAdvisor->UpdateTitle(true); - } - } - - void PartVisible(berry::IWorkbenchPartReference::Pointer ref) - { - if (!windowAdvisor->lastActiveEditor.Expired() && - ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) - { - windowAdvisor->UpdateTitle(false); - } - } - -private: - QmitkExtWorkbenchWindowAdvisor* windowAdvisor; - -}; - -class PartListenerForImageNavigator: public berry::IPartListener -{ -public: - - PartListenerForImageNavigator(QAction* act) : - imageNavigatorAction(act) - { - } - - Events::Types GetPartEventTypes() const - { - return Events::OPENED | Events::CLOSED | Events::HIDDEN | - Events::VISIBLE; - } - - void PartOpened(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") - { - imageNavigatorAction->setChecked(true); - } - } - - void PartClosed(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") - { - imageNavigatorAction->setChecked(false); - } - } - - void PartVisible(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") - { - imageNavigatorAction->setChecked(true); - } - } - - void PartHidden(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") - { - imageNavigatorAction->setChecked(false); - } - } - -private: - QAction* imageNavigatorAction; - -}; - -class PerspectiveListenerForTitle: public berry::IPerspectiveListener -{ -public: - - PerspectiveListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : - windowAdvisor(wa), perspectivesClosed(false) - { - } - - Events::Types GetPerspectiveEventTypes() const - { - return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED - // remove the following line when command framework is finished - | Events::CLOSED | Events::OPENED; - } - - void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - windowAdvisor->UpdateTitle(false); - } - - void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/, - berry::IPerspectiveDescriptor::Pointer /*newPerspective*/) - { - windowAdvisor->UpdateTitle(false); - } - - void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - windowAdvisor->UpdateTitle(false); - } - - void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - if (perspectivesClosed) - { - QListIterator i(windowAdvisor->viewActions); - while (i.hasNext()) - { - i.next()->setEnabled(true); - } - - windowAdvisor->fileSaveProjectAction->setEnabled(true); - windowAdvisor->closeProjectAction->setEnabled(true); - windowAdvisor->undoAction->setEnabled(true); - windowAdvisor->redoAction->setEnabled(true); - windowAdvisor->imageNavigatorAction->setEnabled(true); - windowAdvisor->resetPerspAction->setEnabled(true); - if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) - { - windowAdvisor->closePerspAction->setEnabled(true); - } - } - - perspectivesClosed = false; - } - - void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow(); - bool allClosed = true; - if (wnd->GetActivePage()) - { - std::vector perspectives(wnd->GetActivePage()->GetOpenPerspectives()); - allClosed = perspectives.empty(); - } - - if (allClosed) - { - perspectivesClosed = true; - - QListIterator i(windowAdvisor->viewActions); - while (i.hasNext()) - { - i.next()->setEnabled(false); - } - - windowAdvisor->fileSaveProjectAction->setEnabled(false); - windowAdvisor->closeProjectAction->setEnabled(false); - windowAdvisor->undoAction->setEnabled(false); - windowAdvisor->redoAction->setEnabled(false); - windowAdvisor->imageNavigatorAction->setEnabled(false); - windowAdvisor->resetPerspAction->setEnabled(false); - if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) - { - windowAdvisor->closePerspAction->setEnabled(false); - } - } - } - -private: - QmitkExtWorkbenchWindowAdvisor* windowAdvisor; - bool perspectivesClosed; -}; - -class PerspectiveListenerForMenu: public berry::IPerspectiveListener -{ -public: - - PerspectiveListenerForMenu(QmitkExtWorkbenchWindowAdvisor* wa) : - windowAdvisor(wa) - { - } - - Events::Types GetPerspectiveEventTypes() const - { - return Events::ACTIVATED | Events::DEACTIVATED; - } - - void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer perspective) - { - QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; - if (action) - { - action->setChecked(true); - } - } - - void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer perspective) - { - QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; - if (action) - { - action->setChecked(false); - } - } - -private: - QmitkExtWorkbenchWindowAdvisor* windowAdvisor; -}; - - - -QmitkExtWorkbenchWindowAdvisor::QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, - berry::IWorkbenchWindowConfigurer::Pointer configurer) : -QmitkCommonWorkbenchWindowAdvisor(configurer), -lastInput(0), -wbAdvisor(wbAdvisor), -showViewToolbar(true), -showPerspectiveToolbar(false), -showVersionInfo(true), -showMitkVersionInfo(true), -showViewMenuItem(true), -showNewWindowMenuItem(true), -showClosePerspectiveMenuItem(true) -{ - productName = berry::Platform::GetConfiguration().getString("application.baseName"); -} - -berry::ActionBarAdvisor::Pointer QmitkExtWorkbenchWindowAdvisor::CreateActionBarAdvisor( - berry::IActionBarConfigurer::Pointer configurer) -{ - berry::ActionBarAdvisor::Pointer actionBarAdvisor( - new QmitkExtActionBarAdvisor(configurer)); - return actionBarAdvisor; -} - -void* QmitkExtWorkbenchWindowAdvisor::CreateEmptyWindowContents(void* parent) -{ - QWidget* parentWidget = static_cast(parent); - QLabel* label = new QLabel(parentWidget); - label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu."); - label->setContentsMargins(10,10,10,10); - label->setAlignment(Qt::AlignTop); - label->setEnabled(false); - parentWidget->layout()->addWidget(label); - return label; -} - -void QmitkExtWorkbenchWindowAdvisor::ShowClosePerspectiveMenuItem(bool show) -{ - showClosePerspectiveMenuItem = show; -} - -bool QmitkExtWorkbenchWindowAdvisor::GetShowClosePerspectiveMenuItem() -{ - return showClosePerspectiveMenuItem; -} - -void QmitkExtWorkbenchWindowAdvisor::ShowNewWindowMenuItem(bool show) -{ - showNewWindowMenuItem = show; -} - -void QmitkExtWorkbenchWindowAdvisor::ShowViewToolbar(bool show) -{ - showViewToolbar = show; -} - -void QmitkExtWorkbenchWindowAdvisor::ShowViewMenuItem(bool show) -{ - showViewMenuItem = show; -} - -void QmitkExtWorkbenchWindowAdvisor::ShowPerspectiveToolbar(bool show) -{ - showPerspectiveToolbar = show; -} - -void QmitkExtWorkbenchWindowAdvisor::ShowVersionInfo(bool show) -{ - showVersionInfo = show; -} - -void QmitkExtWorkbenchWindowAdvisor::ShowMitkVersionInfo(bool show) -{ - showMitkVersionInfo = show; -} - -void QmitkExtWorkbenchWindowAdvisor::SetProductName(const std::string& product) -{ - productName = product; -} - -void QmitkExtWorkbenchWindowAdvisor::SetWindowIcon(const std::string& wndIcon) -{ - windowIcon = wndIcon; -} - -void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() -{ - QmitkCommonWorkbenchWindowAdvisor::PostWindowCreate(); - // very bad hack... - berry::IWorkbenchWindow::Pointer window = - this->GetWindowConfigurer()->GetWindow(); - QMainWindow* mainWindow = - static_cast (window->GetShell()->GetControl()); - - if (!windowIcon.empty()) - { - mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon))); - } - mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); - - /*mainWindow->setStyleSheet("color: white;" - "background-color: #808080;" - "selection-color: #659EC7;" - "selection-background-color: #808080;" - " QMenuBar {" - "background-color: #808080; }");*/ - - // ==== Application menu ============================ - QMenuBar* menuBar = mainWindow->menuBar(); - menuBar->setContextMenuPolicy(Qt::PreventContextMenu); - - QMenu* fileMenu = menuBar->addMenu("&File"); - fileMenu->setObjectName("FileMenu"); - - QAction* fileOpenAction = new QmitkExtFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window); - fileMenu->addAction(fileOpenAction); - fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); - fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png")); - fileMenu->addAction(fileSaveProjectAction); - closeProjectAction = new QmitkCloseProjectAction(window); - closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png")); - fileMenu->addAction(closeProjectAction); - fileMenu->addSeparator(); - QAction* fileExitAction = new QmitkFileExitAction(window); - fileExitAction->setObjectName("QmitkFileExitAction"); - fileMenu->addAction(fileExitAction); - - berry::IViewRegistry* viewRegistry = - berry::PlatformUI::GetWorkbench()->GetViewRegistry(); - const std::vector& viewDescriptors = - viewRegistry->GetViews(); - - // another bad hack to get an edit/undo menu... - QMenu* editMenu = menuBar->addMenu("&Edit"); - undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"), - "&Undo", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), - QKeySequence("CTRL+Z")); - undoAction->setToolTip("Undo the last action (not supported by all modules)"); - redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png") - , "&Redo", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), - QKeySequence("CTRL+Y")); - redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); - - imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL); - bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); - if (imageNavigatorViewFound) - { - QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); - imageNavigatorAction->setCheckable(true); - - // add part listener for image navigator - imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction); - window->GetPartService()->AddPartListener(imageNavigatorPartListener); - berry::IViewPart::Pointer imageNavigatorView = - window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); - imageNavigatorAction->setChecked(false); - if (imageNavigatorView) - { - bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); - if (isImageNavigatorVisible) - imageNavigatorAction->setChecked(true); - } - imageNavigatorAction->setToolTip("Open image navigator for navigating through image"); - } - - // toolbar for showing file open, undo, redo and other main actions - QToolBar* mainActionsToolBar = new QToolBar; - mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); -#ifdef __APPLE__ - mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); -#else - mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); -#endif - - mainActionsToolBar->addAction(fileOpenAction); - mainActionsToolBar->addAction(fileSaveProjectAction); - mainActionsToolBar->addAction(closeProjectAction); - mainActionsToolBar->addAction(undoAction); - mainActionsToolBar->addAction(redoAction); - if (imageNavigatorViewFound) - { - mainActionsToolBar->addAction(imageNavigatorAction); - } - mainWindow->addToolBar(mainActionsToolBar); - -#ifdef __APPLE__ - mainWindow->setUnifiedTitleAndToolBarOnMac(true); -#endif - - // ==== Window Menu ========================== - QMenu* windowMenu = menuBar->addMenu("Window"); - if (showNewWindowMenuItem) - { - windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); - windowMenu->addSeparator(); - } - - QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); - - QMenu* viewMenu; - if (showViewMenuItem) - { - viewMenu = windowMenu->addMenu("Show &View"); - viewMenu->setObjectName("Show View"); - } - windowMenu->addSeparator(); - resetPerspAction = windowMenu->addAction("&Reset Perspective", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); - - if(showClosePerspectiveMenuItem) - closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); - - windowMenu->addSeparator(); - windowMenu->addAction("&Preferences...", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), - QKeySequence("CTRL+P")); - - // fill perspective menu - berry::IPerspectiveRegistry* perspRegistry = - window->GetWorkbench()->GetPerspectiveRegistry(); - QActionGroup* perspGroup = new QActionGroup(menuBar); - - std::vector perspectives( - perspRegistry->GetPerspectives()); - - bool skip = false; - for (std::vector::iterator perspIt = - perspectives.begin(); perspIt != perspectives.end(); ++perspIt) - { - - // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which - // should not appear as an menu-entry in the perspective menu - if (perspectiveExcludeList.size() > 0) - { - for (unsigned int i=0; iGetId()) - { - skip = true; - break; - } - } - if (skip) - { - skip = false; - continue; - } - } - - QAction* perspAction = new berry::QtOpenPerspectiveAction(window, - *perspIt, perspGroup); - mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction)); - } - perspMenu->addActions(perspGroup->actions()); - - // sort elements (converting vector to map...) - std::vector::const_iterator iter; - std::map VDMap; - - skip = false; - for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) - { - - // if viewExcludeList is set, it contains the id-strings of view, which - // should not appear as an menu-entry in the menu - if (viewExcludeList.size() > 0) - { - for (unsigned int i=0; iGetId()) - { - skip = true; - break; - } - } - if (skip) - { - skip = false; - continue; - } - } - - if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") - continue; - if ((*iter)->GetId() == "org.mitk.views.imagenavigator") - continue; - - std::pair p( - (*iter)->GetLabel(), (*iter)); - VDMap.insert(p); - } - // ================================================== - - // ==== Perspective Toolbar ================================== - QToolBar* qPerspectiveToolbar = new QToolBar; - - if (showPerspectiveToolbar) - { - qPerspectiveToolbar->addActions(perspGroup->actions()); - mainWindow->addToolBar(qPerspectiveToolbar); - } - else - delete qPerspectiveToolbar; - - // ==== View Toolbar ================================== - QToolBar* qToolbar = new QToolBar; - - std::map::const_iterator - MapIter; - for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) - { - berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, - (*MapIter).second); - viewActions.push_back(viewAction); - if(showViewMenuItem) - viewMenu->addAction(viewAction); - if (showViewToolbar) - { - qToolbar->addAction(viewAction); - } - } - - if (showViewToolbar) - { - mainWindow->addToolBar(qToolbar); - } - else - delete qToolbar; - - QSettings settings(GetQSettingsFile(), QSettings::IniFormat); - mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); - - - // ==================================================== - - // ===== Help menu ==================================== - QMenu* helpMenu = menuBar->addMenu("Help"); - helpMenu->addAction("&Welcome",this, SLOT(onIntro())); - helpMenu->addAction("&Contents", this, SLOT(onHelpContents())); - helpMenu->addAction("Context &Help",this, SLOT(onHelp()), QKeySequence("F1")); - helpMenu->addAction("&About",this, SLOT(onAbout())); - // ===================================================== - - - QStatusBar* qStatusBar = new QStatusBar(); - - //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar - QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); - //disabling the SizeGrip in the lower right corner - statusBar->SetSizeGripEnabled(false); - - - - QmitkProgressBar *progBar = new QmitkProgressBar(); - - qStatusBar->addPermanentWidget(progBar, 0); - progBar->hide(); -// progBar->AddStepsToDo(2); -// progBar->Progress(1); - - mainWindow->setStatusBar(qStatusBar); - - QmitkMemoryUsageIndicatorView* memoryIndicator = - new QmitkMemoryUsageIndicatorView(); - qStatusBar->addPermanentWidget(memoryIndicator, 0); -} - -void QmitkExtWorkbenchWindowAdvisor::PreWindowOpen() -{ - berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); - - // show the shortcut bar and progress indicator, which are hidden by - // default - //configurer->SetShowPerspectiveBar(true); - //configurer->SetShowFastViewBars(true); - //configurer->SetShowProgressIndicator(true); - - // // add the drag and drop support for the editor area - // configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); - // configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); - // configurer.addEditorAreaTransfer(FileTransfer.getInstance()); - // configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); - // configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( - // configurer.getWindow())); - - this->HookTitleUpdateListeners(configurer); - - menuPerspectiveListener = new PerspectiveListenerForMenu(this); - configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener); -} - -void QmitkExtWorkbenchWindowAdvisor::onIntro() -{ - QmitkExtWorkbenchWindowAdvisorHack::undohack->onIntro(); -} - -void QmitkExtWorkbenchWindowAdvisor::onHelp() -{ - QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelp(); -} - -void QmitkExtWorkbenchWindowAdvisor::onHelpContents() -{ - QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelpContents(); -} - -void QmitkExtWorkbenchWindowAdvisor::onAbout() -{ - QmitkExtWorkbenchWindowAdvisorHack::undohack->onAbout(); -} - -//-------------------------------------------------------------------------------- -// Ugly hack from here on. Feel free to delete when command framework -// and undo buttons are done. -//-------------------------------------------------------------------------------- - -QmitkExtWorkbenchWindowAdvisorHack::QmitkExtWorkbenchWindowAdvisorHack() : QObject() -{ - -} - -QmitkExtWorkbenchWindowAdvisorHack::~QmitkExtWorkbenchWindowAdvisorHack() -{ - -} - -void QmitkExtWorkbenchWindowAdvisorHack::onUndo() -{ - mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); - if (model) - { - if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) - { - mitk::VerboseLimitedLinearUndo::StackDescription descriptions = - verboseundo->GetUndoDescriptions(); - if (descriptions.size() >= 1) - { - MITK_INFO << "Undo " << descriptions.front().second; - } - } - model->Undo(); - } - else - { - MITK_ERROR << "No undo model instantiated"; - } -} - -void QmitkExtWorkbenchWindowAdvisorHack::onRedo() -{ - mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); - if (model) - { - if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) - { - mitk::VerboseLimitedLinearUndo::StackDescription descriptions = - verboseundo->GetRedoDescriptions(); - if (descriptions.size() >= 1) - { - MITK_INFO << "Redo " << descriptions.front().second; - } - } - model->Redo(); - } - else - { - MITK_ERROR << "No undo model instantiated"; - } -} - -void QmitkExtWorkbenchWindowAdvisorHack::onImageNavigator() -{ - // get ImageNavigatorView - berry::IViewPart::Pointer imageNavigatorView = - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); - if (imageNavigatorView) - { - bool isImageNavigatorVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(imageNavigatorView); - if (isImageNavigatorVisible) - { - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->HideView(imageNavigatorView); - return; - } - } - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagenavigator"); - //berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); -} - -void QmitkExtWorkbenchWindowAdvisorHack::onEditPreferences() -{ - QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow()); - _PreferencesDialog.exec(); -} - -void QmitkExtWorkbenchWindowAdvisorHack::onQuit() -{ - berry::PlatformUI::GetWorkbench()->Close(); -} - -void QmitkExtWorkbenchWindowAdvisorHack::onResetPerspective() -{ - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); -} - -void QmitkExtWorkbenchWindowAdvisorHack::onClosePerspective() -{ - berry::IWorkbenchPage::Pointer - page = - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); - page->ClosePerspective(page->GetPerspective(), true, true); -} - -void QmitkExtWorkbenchWindowAdvisorHack::onNewWindow() -{ - berry::PlatformUI::GetWorkbench()->OpenWorkbenchWindow(0); -} - -void QmitkExtWorkbenchWindowAdvisorHack::onIntro() -{ - bool hasIntro = - berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro(); - if (!hasIntro) - { - - QRegExp reg("(.*)(\\n)*"); - QRegExp reg2("(\\n)*(.*)"); - QFile file(":/org.mitk.gui.qt.ext/index.html"); - file.open(QIODevice::ReadOnly | QIODevice::Text); // Als Text-Datei nur zum Lesen öffnen - - QString text = QString(file.readAll()); - - file.close(); - - QString title = text; - title.replace(reg, ""); - title.replace(reg2, ""); - - std::cout << title.toStdString() << std::endl; - - QMessageBox::information(NULL, title, - text, "Close"); - - } - else - { - berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false); - } -} - -void QmitkExtWorkbenchWindowAdvisorHack::onHelp() -{ - ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); - if (context == 0) - { - MITK_WARN << "Plugin context not set, unable to open context help"; - return; - } - - // Check if the org.blueberry.ui.qt.help plug-in is installed and started - QList > plugins = context->getPlugins(); - foreach(QSharedPointer p, plugins) - { - if (p->getSymbolicName() == "org.blueberry.ui.qt.help") - { - if (p->getState() != ctkPlugin::ACTIVE) - { - // try to activate the plug-in explicitly - try - { - p->start(ctkPlugin::START_TRANSIENT); - } - catch (const ctkPluginException& pe) - { - MITK_ERROR << "Activating org.blueberry.ui.qt.help failed: " << pe.what(); - return; - } - } - } - } - - ctkServiceReference eventAdminRef = context->getServiceReference(); - ctkEventAdmin* eventAdmin = 0; - if (eventAdminRef) - { - eventAdmin = context->getService(eventAdminRef); - } - if (eventAdmin == 0) - { - MITK_WARN << "ctkEventAdmin service not found. Unable to open context help"; - } - else - { - ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); - eventAdmin->postEvent(ev); - } -} - -void QmitkExtWorkbenchWindowAdvisorHack::onHelpContents() -{ - berry::PlatformUI::GetWorkbench()->ShowPerspective("org.blueberry.perspectives.help", - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); -} - -void QmitkExtWorkbenchWindowAdvisorHack::onAbout() -{ - QmitkAboutDialog* aboutDialog = new QmitkAboutDialog(QApplication::activeWindow(),NULL); - aboutDialog->open(); -} - -void QmitkExtWorkbenchWindowAdvisor::HookTitleUpdateListeners( - berry::IWorkbenchWindowConfigurer::Pointer configurer) -{ - // hook up the listeners to update the window title - titlePartListener = new PartListenerForTitle(this); - titlePerspectiveListener = new PerspectiveListenerForTitle(this); - editorPropertyListener = new berry::PropertyChangeIntAdapter< - QmitkExtWorkbenchWindowAdvisor>(this, - &QmitkExtWorkbenchWindowAdvisor::PropertyChange); - - // configurer.getWindow().addPageListener(new IPageListener() { - // public void pageActivated(IWorkbenchPage page) { - // updateTitle(false); - // } - // - // public void pageClosed(IWorkbenchPage page) { - // updateTitle(false); - // } - // - // public void pageOpened(IWorkbenchPage page) { - // // do nothing - // } - // }); - - configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener); - configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener); -} - -std::string QmitkExtWorkbenchWindowAdvisor::ComputeTitle() -{ - berry::IWorkbenchWindowConfigurer::Pointer configurer = - GetWindowConfigurer(); - berry::IWorkbenchPage::Pointer currentPage = - configurer->GetWindow()->GetActivePage(); - berry::IEditorPart::Pointer activeEditor; - if (currentPage) - { - activeEditor = lastActiveEditor.Lock(); - } - - std::string title; - //TODO Product - // IProduct product = Platform.getProduct(); - // if (product != null) { - // title = product.getName(); - // } - // instead of the product name, we use a custom variable for now - title = productName; - - if(showMitkVersionInfo) - { - title += std::string(" ") + MITK_VERSION_STRING; - } - - if (showVersionInfo) - { - // add version informatioin - QString versions = QString(" (ITK %1.%2.%3 VTK %4.%5.%6 Qt %7 MITK %8)") - .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH) - .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION) - .arg(QT_VERSION_STR) - .arg(MITK_VERSION_STRING); - - title += versions.toStdString(); - } - - if (currentPage) - { - if (activeEditor) - { - lastEditorTitle = activeEditor->GetTitleToolTip(); - if (!lastEditorTitle.empty()) - title = lastEditorTitle + " - " + title; - } - berry::IPerspectiveDescriptor::Pointer persp = - currentPage->GetPerspective(); - std::string label = ""; - if (persp) - { - label = persp->GetLabel(); - } - berry::IAdaptable* input = currentPage->GetInput(); - if (input && input != wbAdvisor->GetDefaultPageInput()) - { - label = currentPage->GetLabel(); - } - if (!label.empty()) - { - title = label + " - " + title; - } - } - - title += " (Not for use in diagnosis or treatment of patients)"; - - return title; -} - -void QmitkExtWorkbenchWindowAdvisor::RecomputeTitle() -{ - berry::IWorkbenchWindowConfigurer::Pointer configurer = - GetWindowConfigurer(); - std::string oldTitle = configurer->GetTitle(); - std::string newTitle = ComputeTitle(); - if (newTitle != oldTitle) - { - configurer->SetTitle(newTitle); - } -} - -void QmitkExtWorkbenchWindowAdvisor::UpdateTitle(bool editorHidden) -{ - berry::IWorkbenchWindowConfigurer::Pointer configurer = - GetWindowConfigurer(); - berry::IWorkbenchWindow::Pointer window = configurer->GetWindow(); - berry::IEditorPart::Pointer activeEditor; - berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage(); - berry::IPerspectiveDescriptor::Pointer persp; - berry::IAdaptable* input = 0; - - if (currentPage) - { - activeEditor = currentPage->GetActiveEditor(); - persp = currentPage->GetPerspective(); - input = currentPage->GetInput(); - } - - if (editorHidden) - { - activeEditor = 0; - } - - // Nothing to do if the editor hasn't changed - if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock() - && persp == lastPerspective.Lock() && input == lastInput) - { - return; - } - - if (!lastActiveEditor.Expired()) - { - lastActiveEditor.Lock()->RemovePropertyListener(editorPropertyListener); - } - - lastActiveEditor = activeEditor; - lastActivePage = currentPage; - lastPerspective = persp; - lastInput = input; - - if (activeEditor) - { - activeEditor->AddPropertyListener(editorPropertyListener); - } - - RecomputeTitle(); -} - -void QmitkExtWorkbenchWindowAdvisor::PropertyChange(berry::Object::Pointer /*source*/, int propId) -{ - if (propId == berry::IWorkbenchPartConstants::PROP_TITLE) - { - if (!lastActiveEditor.Expired()) - { - std::string newTitle = lastActiveEditor.Lock()->GetPartName(); - if (lastEditorTitle != newTitle) - { - RecomputeTitle(); - } - } - } -} - - -void QmitkExtWorkbenchWindowAdvisor::SetPerspectiveExcludeList(std::vector v) -{ - this->perspectiveExcludeList = v; -} - -std::vector QmitkExtWorkbenchWindowAdvisor::GetPerspectiveExcludeList() -{ - return this->perspectiveExcludeList; -} - -void QmitkExtWorkbenchWindowAdvisor::SetViewExcludeList(std::vector v) -{ - this->viewExcludeList = v; -} - -std::vector QmitkExtWorkbenchWindowAdvisor::GetViewExcludeList() -{ - return this->viewExcludeList; -} - -void QmitkExtWorkbenchWindowAdvisor::PostWindowClose() -{ - berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); - QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); - - QSettings settings(GetQSettingsFile(), QSettings::IniFormat); - settings.setValue("ToolbarPosition", mainWindow->saveState()); -} - -QString QmitkExtWorkbenchWindowAdvisor::GetQSettingsFile() const -{ - QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME); - return settingsInfo.canonicalFilePath(); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h deleted file mode 100644 index 0757ff5344..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h +++ /dev/null @@ -1,161 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKEXTWORKBENCHWINDOWADVISOR_H_ -#define QMITKEXTWORKBENCHWINDOWADVISOR_H_ - -#include - -#include -#include -#include -#include -#include -#include "QmitkCommonWorkbenchWindowAdvisor.h" - -#include -class QAction; -class QMenu; - -class MITK_QT_COMMON_EXT_EXPORT QmitkExtWorkbenchWindowAdvisor : public QObject, public QmitkCommonWorkbenchWindowAdvisor -{ - Q_OBJECT - -public: - - QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, - berry::IWorkbenchWindowConfigurer::Pointer configurer); - - berry::ActionBarAdvisor::Pointer CreateActionBarAdvisor( - berry::IActionBarConfigurer::Pointer configurer); - - void* CreateEmptyWindowContents(void* parent); - - void PostWindowCreate(); - - void PreWindowOpen(); - - void PostWindowClose(); - - void ShowViewToolbar(bool show); - - void ShowPerspectiveToolbar(bool show); - - void ShowVersionInfo(bool show); - - void ShowMitkVersionInfo(bool show); - - void ShowViewMenuItem(bool show); - - void ShowNewWindowMenuItem(bool show); - - void ShowClosePerspectiveMenuItem(bool show); - - bool GetShowClosePerspectiveMenuItem(); - - //TODO should be removed when product support is here - void SetProductName(const std::string& product); - void SetWindowIcon(const std::string& wndIcon); - - void SetPerspectiveExcludeList(std::vector v); - std::vector GetPerspectiveExcludeList(); - - void SetViewExcludeList(std::vector v); - std::vector GetViewExcludeList(); - -protected slots: - - virtual void onIntro(); - virtual void onHelp(); - virtual void onHelpContents(); - virtual void onAbout(); - -private: - - /** - * Hooks the listeners needed on the window - * - * @param configurer - */ - void HookTitleUpdateListeners(berry::IWorkbenchWindowConfigurer::Pointer configurer); - - std::string ComputeTitle(); - - void RecomputeTitle(); - - QString GetQSettingsFile() const; - - /** - * Updates the window title. Format will be: [pageInput -] - * [currentPerspective -] [editorInput -] [workspaceLocation -] productName - * @param editorHidden TODO - */ - void UpdateTitle(bool editorHidden); - - void PropertyChange(berry::Object::Pointer /*source*/, int propId); - - static QString QT_SETTINGS_FILENAME; - - berry::IPartListener::Pointer titlePartListener; - berry::IPerspectiveListener::Pointer titlePerspectiveListener; - berry::IPerspectiveListener::Pointer menuPerspectiveListener; - berry::IPartListener::Pointer imageNavigatorPartListener; - berry::IPropertyChangeListener::Pointer editorPropertyListener; - friend struct berry::PropertyChangeIntAdapter; - friend class PartListenerForTitle; - friend class PerspectiveListenerForTitle; - friend class PerspectiveListenerForMenu; - friend class PartListenerForImageNavigator; - - berry::IEditorPart::WeakPtr lastActiveEditor; - berry::IPerspectiveDescriptor::WeakPtr lastPerspective; - berry::IWorkbenchPage::WeakPtr lastActivePage; - std::string lastEditorTitle; - berry::IAdaptable* lastInput; - - berry::WorkbenchAdvisor* wbAdvisor; - bool showViewToolbar; - bool showPerspectiveToolbar; - bool showVersionInfo; - bool showMitkVersionInfo; - bool showViewMenuItem; - bool showNewWindowMenuItem; - bool showClosePerspectiveMenuItem; - std::string productName; - std::string windowIcon; - - // stringlist for excluding perspectives from the perspective menu entry (e.g. Welcome Perspective) - std::vector perspectiveExcludeList; - - // stringlist for excluding views from the menu entry - std::vector viewExcludeList; - - // maps perspective ids to QAction objects - std::map mapPerspIdToAction; - - // actions which will be enabled/disabled depending on the application state - QList viewActions; - QAction* fileSaveProjectAction; - QAction* closeProjectAction; - QAction* undoAction; - QAction* redoAction; - QAction* imageNavigatorAction; - QAction* resetPerspAction; - QAction* closePerspAction; -}; - -#endif /*QMITKEXTWORKBENCHWINDOWADVISOR_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp deleted file mode 100644 index 5a9ff7813b..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkCommonExtPlugin.h" - -#include - -#include "QmitkAppInstancesPreferencePage.h" -#include "QmitkInputDevicesPrefPage.h" - -#include "QmitkModuleView.h" - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -ctkPluginContext* QmitkCommonExtPlugin::_context = 0; - -void QmitkCommonExtPlugin::start(ctkPluginContext* context) -{ - this->_context = context; - - QmitkExtRegisterClasses(); - - BERRY_REGISTER_EXTENSION_CLASS(QmitkAppInstancesPreferencePage, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkInputDevicesPrefPage, context) - - BERRY_REGISTER_EXTENSION_CLASS(QmitkModuleView, context) - - if (qApp->metaObject()->indexOfSignal("messageReceived(QByteArray)") > -1) - { - connect(qApp, SIGNAL(messageReceived(QByteArray)), this, SLOT(handleIPCMessage(QByteArray))); - } - - std::vector args = berry::Platform::GetApplicationArgs(); - QStringList qargs; - for (std::vector::const_iterator it = args.begin(); it != args.end(); ++it) - { - qargs << QString::fromStdString(*it); - } - // This is a potentially long running operation. - loadDataFromDisk(qargs, true); -} - -void QmitkCommonExtPlugin::stop(ctkPluginContext* context) -{ - Q_UNUSED(context) - - this->_context = 0; -} - -ctkPluginContext* QmitkCommonExtPlugin::getContext() -{ - return _context; -} - -void QmitkCommonExtPlugin::loadDataFromDisk(const QStringList &arguments, bool globalReinit) -{ - if (!arguments.empty()) - { - ctkServiceReference serviceRef = _context->getServiceReference(); - if (serviceRef) - { - mitk::IDataStorageService* dataStorageService = _context->getService(serviceRef); - mitk::DataStorage::Pointer dataStorage = dataStorageService->GetDefaultDataStorage()->GetDataStorage(); - - int argumentsAdded = 0; - for (int i = 0; i < arguments.size(); ++i) - { - if (arguments[i].right(5) == ".mitk") - { - mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); - - bool clearDataStorageFirst(false); - mitk::ProgressBar::GetInstance()->AddStepsToDo(2); - dataStorage = sceneIO->LoadScene( arguments[i].toLocal8Bit().constData(), dataStorage, clearDataStorageFirst ); - mitk::ProgressBar::GetInstance()->Progress(2); - argumentsAdded++; - } - else - { - mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); - try - { - nodeReader->SetFileName(arguments[i].toStdString()); - nodeReader->Update(); - for (unsigned int j = 0 ; j < nodeReader->GetNumberOfOutputs( ); ++j) - { - mitk::DataNode::Pointer node = nodeReader->GetOutput(j); - if (node->GetData() != 0) - { - dataStorage->Add(node); - argumentsAdded++; - } - } - } - catch(...) - { - MITK_WARN << "Failed to load command line argument: " << arguments[i].toStdString(); - } - } - } // end for each command line argument - - if (argumentsAdded > 0 && globalReinit) - { - // calculate bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(dataStorage->ComputeBoundingGeometry3D()); - } - } - else - { - MITK_ERROR << "A service reference for mitk::IDataStorageService does not exist"; - } - } -} - -void QmitkCommonExtPlugin::startNewInstance(const QStringList &args, const QStringList& files) -{ - QStringList newArgs(args); -#ifdef Q_OS_UNIX - newArgs << QString("--") + QString::fromStdString(berry::Platform::ARG_NEWINSTANCE); -#else - newArgs << QString("/") + QString::fromStdString(berry::Platform::ARG_NEWINSTANCE); -#endif - newArgs << files; - QProcess::startDetached(qApp->applicationFilePath(), newArgs); -} - -void QmitkCommonExtPlugin::handleIPCMessage(const QByteArray& msg) -{ - QDataStream ds(msg); - QString msgType; - ds >> msgType; - - // we only handle messages containing command line arguments - if (msgType != "$cmdLineArgs") return; - - // activate the current workbench window - berry::IWorkbenchWindow::Pointer window = - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(); - - QMainWindow* mainWindow = - static_cast (window->GetShell()->GetControl()); - - mainWindow->setWindowState(mainWindow->windowState() & ~Qt::WindowMinimized); - mainWindow->raise(); - mainWindow->activateWindow(); - - // Get the preferences for the instantiation behavior - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - berry::IPreferences::Pointer prefs = prefService->GetSystemPreferences()->Node("/General"); - bool newInstanceAlways = prefs->GetBool("newInstance.always", false); - bool newInstanceScene = prefs->GetBool("newInstance.scene", true); - - QStringList args; - ds >> args; - - QStringList fileArgs; - QStringList sceneArgs; - - Poco::Util::OptionSet os; - berry::Platform::GetOptionSet(os); - Poco::Util::OptionProcessor processor(os); -#if !defined(POCO_OS_FAMILY_UNIX) - processor.setUnixStyle(false); -#endif - args.pop_front(); - QStringList::Iterator it = args.begin(); - while (it != args.end()) - { - std::string name; - std::string value; - if (processor.process(it->toStdString(), name, value)) - { - ++it; - } - else - { - if (it->endsWith(".mitk")) - { - sceneArgs << *it; - } - else - { - fileArgs << *it; - } - it = args.erase(it); - } - } - - if (newInstanceAlways) - { - if (newInstanceScene) - { - startNewInstance(args, fileArgs); - - foreach(QString sceneFile, sceneArgs) - { - startNewInstance(args, QStringList(sceneFile)); - } - } - else - { - fileArgs.append(sceneArgs); - startNewInstance(args, fileArgs); - } - } - else - { - loadDataFromDisk(fileArgs, false); - if (newInstanceScene) - { - foreach(QString sceneFile, sceneArgs) - { - startNewInstance(args, QStringList(sceneFile)); - } - } - else - { - loadDataFromDisk(sceneArgs, false); - } - } - -} - -Q_EXPORT_PLUGIN2(org_mitk_gui_qt_ext, QmitkCommonExtPlugin) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h deleted file mode 100644 index 2e7ccab06f..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h +++ /dev/null @@ -1,51 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKCOMMONEXTPLUGIN_H_ -#define QMITKCOMMONEXTPLUGIN_H_ - -#include - -class QmitkCommonExtPlugin : public QObject, public ctkPluginActivator -{ - Q_OBJECT - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - - static ctkPluginContext* getContext(); - -private: - - void loadDataFromDisk(const QStringList& args, bool globalReinit); - void startNewInstance(const QStringList& args, const QStringList &files); - -private Q_SLOTS: - - void handleIPCMessage(const QByteArray &msg); - -private: - - static ctkPluginContext* _context; - -}; - -#endif /* QMITKCOMMONEXTPLUGIN_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.cpp deleted file mode 100644 index f9ebdd90bc..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ -Version: $Revision: 18019 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkInputDevicesPrefPage.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -QmitkInputDevicesPrefPage::QmitkInputDevicesPrefPage() -: m_MainControl(0) -{ - // gets the old setting of the preferences and loads them into the preference node - berry::IPreferencesService::Pointer prefService - = berry::Platform::GetServiceRegistry() - .GetServiceById(berry::IPreferencesService::ID); - this->m_InputDevicesPrefNode = prefService->GetSystemPreferences()->Node(mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES); -} - -QmitkInputDevicesPrefPage::QmitkInputDevicesPrefPage(const QmitkInputDevicesPrefPage& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -void QmitkInputDevicesPrefPage::Init(berry::IWorkbench::Pointer ) -{ -} - -void QmitkInputDevicesPrefPage::CreateQtControl(QWidget* parent) -{ - m_MainControl = new QWidget(parent); - QVBoxLayout *layout = new QVBoxLayout; - - mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry = - berry::Platform::GetServiceRegistry().GetServiceById(mitk::CoreExtConstants::INPUTDEVICE_SERVICE); - std::vector temp(inputDeviceRegistry->GetInputDevices()); - - for(std::vector::const_iterator it = temp.begin(); it != temp.end();++it) - { - QString inputDeviceName(QString::fromStdString((*it)->GetName())); - QCheckBox* checkBox = new QCheckBox((inputDeviceName),m_MainControl); - layout->addWidget(checkBox); - m_InputDevices.insert(checkBox,(*it)->GetID()); - - if(inputDeviceName == "WiiMote") - { - m_WiiMoteModes = new QGroupBox("WiiMote Modus"); - - m_WiiMoteHeadTracking = new QRadioButton - (QString::fromStdString(mitk::CoreExtConstants::WIIMOTE_HEADTRACKING)); - m_WiiMoteSurfaceInteraction = new QRadioButton - (QString::fromStdString(mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION)); - m_WiiMoteHeadTracking->setChecked(true); - - QVBoxLayout* vBoxLayout = new QVBoxLayout; - - vBoxLayout->addWidget(m_WiiMoteHeadTracking); - vBoxLayout->addWidget(m_WiiMoteSurfaceInteraction); - - m_WiiMoteModes->setLayout(vBoxLayout); - - layout->addWidget(m_WiiMoteModes); - } - - } - - layout->addStretch(); - m_MainControl->setLayout(layout); - this->Update(); -} - -QWidget* QmitkInputDevicesPrefPage::GetQtControl() const -{ - return m_MainControl; -} - -bool QmitkInputDevicesPrefPage::PerformOk() -{ - bool result = true; - - mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry = - berry::Platform::GetServiceRegistry(). - GetServiceById(mitk::CoreExtConstants::INPUTDEVICE_SERVICE); - - QHashIterator it(m_InputDevices); - while (it.hasNext()) - { - it.next(); - mitk::IInputDeviceDescriptor::Pointer inputdevice(inputDeviceRegistry->Find(it.value())); - - if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) - { - QString headTracking(m_WiiMoteHeadTracking->text()); - QString surfaceInteraction(m_WiiMoteSurfaceInteraction->text()); - - this->m_InputDevicesPrefNode->PutBool - (headTracking.toStdString(),m_WiiMoteHeadTracking->isChecked()); - this->m_InputDevicesPrefNode->PutBool - (surfaceInteraction.toStdString(),m_WiiMoteSurfaceInteraction->isChecked()); - - // forced flush of the preferences is needed - // because otherwise the mitk::WiiMoteActivator class - // cannot distinguish the two different modes without - // changing the interface for all input devices - berry::IPreferencesService::Pointer prefService = - berry::Platform::GetServiceRegistry(). - GetServiceById(berry::IPreferencesService::ID); - - if (prefService) - { - prefService->GetSystemPreferences()->Flush(); - } - } - - if(it.key()->isChecked()) - { - result &= inputdevice->CreateInputDevice()->RegisterInputDevice(); - } - else - { - result &= inputdevice->CreateInputDevice()->UnRegisterInputDevice(); - - // temporary fix, unclean solution: - // e.g. user activates SpaceNavigator and leaves the - // the wiimote deactivated, the user will get the warning - // despite the fact that it has never been activated - if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) - { - // until now 2010-09-06 there were some unfixed problems - // with reconnecting the wiimote after disconnecting it. - // It was suggested that it might have something to do - // with the type of stack, that is used for the pairing. - // MS-Stack for example does not work properly. - QMessageBox::information(NULL,"WiiMote supportproblem", - "A reconnect of the WiiMote is not yet supported! " - "Please restart the application, if you want to " - "activate the Wii remote/s again."); - } - } - - if(result) - { - this->m_InputDevicesPrefNode->PutBool(it.value(),it.key()->isChecked()); - } - } - return result; -} - -void QmitkInputDevicesPrefPage::PerformCancel() -{ - -} - -void QmitkInputDevicesPrefPage::Update() -{ - QHashIterator it(m_InputDevices); - while (it.hasNext()) - { - it.next(); - it.key()->setChecked(this->m_InputDevicesPrefNode->GetBool(it.value(), false)); - if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) - { - m_WiiMoteHeadTracking->setChecked( - this->m_InputDevicesPrefNode->GetBool(mitk::CoreExtConstants::WIIMOTE_HEADTRACKING,false)); - m_WiiMoteSurfaceInteraction->setChecked - (this->m_InputDevicesPrefNode->GetBool(mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION,false)); - } - } -} diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.h deleted file mode 100644 index eb9f87cfa9..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.h +++ /dev/null @@ -1,92 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ -Version: $Revision: 16224 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - - -#ifndef QMITK_INPUTDEVICESPREFPAGE_H_ -#define QMITK_INPUTDEVICESPREFPAGE_H_ - -#include "berryIQtPreferencePage.h" -#include - -#include -#include -#include - -class QWidget; -class QCheckBox; - -class QmitkInputDevicesPrefPage : public QObject, public berry::IQtPreferencePage -{ - Q_OBJECT - Q_INTERFACES(berry::IPreferencePage) - -public: - - /** - * Default constructor - */ - QmitkInputDevicesPrefPage(); - - QmitkInputDevicesPrefPage(const QmitkInputDevicesPrefPage& other); - - /** - * @see berry::IPreferencePage::Init(berry::IWorkbench::Pointer workbench) - */ - void Init(berry::IWorkbench::Pointer workbench); - - - /** - * @see berry::IPreferencePage::CreateQtControl(void* parent) - */ - void CreateQtControl(QWidget* widget); - - /** - * @see berry::IPreferencePage::CreateQtControl() - */ - QWidget* GetQtControl() const; - - /** - * @see berry::IPreferencePage::PerformOk() - */ - virtual bool PerformOk(); - - /** - * @see berry::IPreferencePage::PerformCancel() - */ - virtual void PerformCancel(); - - /** - * @see berry::IPreferencePage::Update() - */ - virtual void Update(); - -protected: - - QWidget* m_MainControl; - - QHash m_InputDevices; - - // specific for Wiimote - QGroupBox* m_WiiMoteModes; - QRadioButton* m_WiiMoteHeadTracking; - QRadioButton* m_WiiMoteSurfaceInteraction; - - berry::IPreferences::Pointer m_InputDevicesPrefNode; - -}; - -#endif // QMITK_INPUTDEVICESPREFPAGE_H_ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/doxygen/modules.dox deleted file mode 100644 index c1ffe16e1d..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_extapplication org.mitk.gui.qt.extapplication Plugin - \ingroup MITKPlugins - - \brief This plug-in is responsible for initializing the "ExtApp". - -*/ - -/** - \defgroup org_mitk_gui_qt_extapplication_internal Internal - \ingroup org_mitk_gui_qt_extapplication - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.extapplication plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/files.cmake b/Modules/Bundles/org.mitk.gui.qt.extapplication/files.cmake deleted file mode 100644 index 51203dd5d9..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/files.cmake +++ /dev/null @@ -1,40 +0,0 @@ -SET(SRC_CPP_FILES - QmitkExtApplication.cpp - QmitkExtAppWorkbenchAdvisor.cpp -) - -SET(INTERNAL_CPP_FILES - QmitkExtApplicationPlugin.cpp - QmitkExtDefaultPerspective.cpp -) - -SET(MOC_H_FILES - src/QmitkExtApplication.h - src/internal/QmitkExtApplicationPlugin.h - src/internal/QmitkExtDefaultPerspective.h -) - -SET(CACHED_RESOURCE_FILES -# list of resource files which can be used by the plug-in -# system without loading the plug-ins shared library, -# for example the icon used in the menu and tabs for the -# plug-in views in the workbench - plugin.xml - resources/icon_research.xpm -) - -SET(QRC_FILES -# uncomment the following line if you want to use Qt resources -# resources/QmitkExtApplication.qrc -) - -SET(CPP_FILES ) - -foreach(file ${SRC_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/${file}) -endforeach(file ${SRC_CPP_FILES}) - -foreach(file ${INTERNAL_CPP_FILES}) - SET(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach(file ${INTERNAL_CPP_FILES}) - diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.h deleted file mode 100644 index b12d636d0f..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.h +++ /dev/null @@ -1,47 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#ifndef QMITKEXTAPPWORKBENCHADVISOR_H_ -#define QMITKEXTAPPWORKBENCHADVISOR_H_ - -#ifdef __MINGW32__ -// We need to inlclude winbase.h here in order to declare -// atomic intrinsics like InterlockedIncrement correctly. -// Otherwhise, they would be declared wrong within qatomic_windows.h . -#include -#endif - -#include - -#include "mitkQtExtAppDll.h" - -class MITK_QT_EXTAPP QmitkExtAppWorkbenchAdvisor: public berry::QtWorkbenchAdvisor -{ -public: - - static const std::string DEFAULT_PERSPECTIVE_ID; // = "org.mitk.extapp.defaultperspective" - - void Initialize(berry::IWorkbenchConfigurer::Pointer configurer); - - berry::WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor( - berry::IWorkbenchWindowConfigurer::Pointer configurer); - - std::string GetInitialWindowPerspectiveId(); - -}; - -#endif /*QMITKEXTAPPWORKBENCHADVISOR_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.cpp deleted file mode 100644 index fc458628d9..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkExtApplication.h" - -#include - -#include "QmitkExtAppWorkbenchAdvisor.h" - -QmitkExtApplication::QmitkExtApplication() -{ - -} - -QmitkExtApplication::QmitkExtApplication(const QmitkExtApplication& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -int QmitkExtApplication::Start() -{ - berry::Display* display = berry::PlatformUI::CreateDisplay(); - - int code = berry::PlatformUI::CreateAndRunWorkbench(display, new QmitkExtAppWorkbenchAdvisor()); - - // exit the application with an appropriate return code - return code == berry::PlatformUI::RETURN_RESTART - ? EXIT_RESTART : EXIT_OK; -} - -void QmitkExtApplication::Stop() -{ - -} diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.h deleted file mode 100644 index 6d645d75bd..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtApplication.h +++ /dev/null @@ -1,39 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITKEXTAPPLICATION_H_ -#define QMITKEXTAPPLICATION_H_ - -#include - -#include "mitkQtExtAppDll.h" - -class MITK_QT_EXTAPP QmitkExtApplication : public QObject, public berry::IApplication -{ - Q_OBJECT - Q_INTERFACES(berry::IApplication) - -public: - - QmitkExtApplication(); - QmitkExtApplication(const QmitkExtApplication& other); - - int Start(); - void Stop(); -}; - -#endif /*QMITKEXTAPPLICATION_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp deleted file mode 100644 index 235e635ba4..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkExtApplicationPlugin.h" -#include "QmitkExtDefaultPerspective.h" -#include "../QmitkExtApplication.h" - -#include -#include - -#include -#include - -#include -#include -#include - -QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::inst = 0; - -QmitkExtApplicationPlugin::QmitkExtApplicationPlugin() -{ - inst = this; -} - -QmitkExtApplicationPlugin::~QmitkExtApplicationPlugin() -{ -} - -QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::GetDefault() -{ - return inst; -} - -void QmitkExtApplicationPlugin::start(ctkPluginContext* context) -{ - berry::AbstractUICTKPlugin::start(context); - - this->context = context; - - BERRY_REGISTER_EXTENSION_CLASS(QmitkExtDefaultPerspective, context); - BERRY_REGISTER_EXTENSION_CLASS(QmitkExtApplication, context); - - - ctkServiceReference cmRef = context->getServiceReference(); - ctkConfigurationAdmin* configAdmin = 0; - if (cmRef) - { - configAdmin = context->getService(cmRef); - } - - // Use the CTK Configuration Admin service to configure the BlueBerry help system - if (configAdmin) - { - ctkConfigurationPtr conf = configAdmin->getConfiguration("org.blueberry.services.help", QString()); - ctkDictionary helpProps; - helpProps.insert("homePage", "qthelp://org.mitk.gui.qt.extapplication/bundle/index.html"); - conf->update(helpProps); - context->ungetService(cmRef); - } - else - { - MITK_WARN << "Configuration Admin service unavailable, cannot set home page url."; - } -} - -ctkPluginContext* QmitkExtApplicationPlugin::GetPluginContext() const -{ - return context; -} - -Q_EXPORT_PLUGIN2(org_mitk_gui_qt_extapplication, QmitkExtApplicationPlugin) diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h deleted file mode 100644 index 657d450496..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h +++ /dev/null @@ -1,53 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKEXTAPPLICATIONPLUGIN_H_ -#define QMITKEXTAPPLICATIONPLUGIN_H_ - -#include - -#include - -#include - -class QmitkExtApplicationPlugin : public QObject, public berry::AbstractUICTKPlugin -{ - Q_OBJECT - Q_INTERFACES(ctkPluginActivator) - -public: - - QmitkExtApplicationPlugin(); - ~QmitkExtApplicationPlugin(); - - static QmitkExtApplicationPlugin* GetDefault(); - - ctkPluginContext* GetPluginContext() const; - - void start(ctkPluginContext*); - - QString GetQtHelpCollectionFile() const; - -private: - - static QmitkExtApplicationPlugin* inst; - - ctkPluginContext* context; -}; - -#endif /* QMITKEXTAPPLICATIONPLUGIN_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp deleted file mode 100755 index 0dc572ab61..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "QmitkExtDefaultPerspective.h" -#include "berryIViewLayout.h" - -QmitkExtDefaultPerspective::QmitkExtDefaultPerspective() -{ -} - -QmitkExtDefaultPerspective::QmitkExtDefaultPerspective(const QmitkExtDefaultPerspective& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -void QmitkExtDefaultPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) -{ - std::string editorArea = layout->GetEditorArea(); - - layout->AddView("org.mitk.views.datamanager", - berry::IPageLayout::LEFT, 0.3f, editorArea); - - berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.datamanager"); - lo->SetCloseable(false); - - layout->AddView("org.mitk.views.imagenavigator", - berry::IPageLayout::BOTTOM, 0.5f, "org.mitk.views.datamanager"); - - berry::IFolderLayout::Pointer bottomFolder = layout->CreateFolder("bottom", berry::IPageLayout::BOTTOM, 0.7f, editorArea); - bottomFolder->AddView("org.mitk.views.propertylistview"); - bottomFolder->AddView("org.blueberry.views.logview"); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h deleted file mode 100755 index 7410a50c58..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h +++ /dev/null @@ -1,38 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QMITKEXTDEFAULTPERSPECTIVE_H_ -#define QMITKEXTDEFAULTPERSPECTIVE_H_ - -#include - -class QmitkExtDefaultPerspective : public QObject, public berry::IPerspectiveFactory -{ - Q_OBJECT - Q_INTERFACES(berry::IPerspectiveFactory) - -public: - - QmitkExtDefaultPerspective(); - QmitkExtDefaultPerspective(const QmitkExtDefaultPerspective& other); - - void CreateInitialLayout(berry::IPageLayout::Pointer layout); - -}; - -#endif /* QMITKEXTDEFAULTPERSPECTIVE_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/mitkQtExtAppDll.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/mitkQtExtAppDll.h deleted file mode 100644 index 5e33f74de7..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/mitkQtExtAppDll.h +++ /dev/null @@ -1,41 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef MITKQTEXTAPPDLL_H_ -#define MITKQTEXTAPPDLL_H_ - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the org_mitk_gui_qt_application_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// MITK_QT_APP functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && !defined(BERRY_STATIC) - #if defined(org_mitk_gui_qt_extapplication_EXPORTS) - #define MITK_QT_EXTAPP __declspec(dllexport) - #else - #define MITK_QT_EXTAPP __declspec(dllimport) - #endif -#endif - -#if !defined(MITK_QT_EXTAPP) - #define MITK_QT_EXTAPP -#endif - -#endif /*MITKQTEXTAPPDLL_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/doxygen/modules.dox deleted file mode 100644 index cd4f267740..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/doxygen/modules.dox +++ /dev/null @@ -1,24 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_igtexamples org.mitk.gui.qt.igtexamples Plugin - \ingroup MITKPlugins - - \brief QmitkIGTExamples shows a small typically navigation MITK functionality. - - Any kind of navigation application will start with the connection to a tracking system - and as we do image guided procedures we want to show something on the screen. In this - tutorial we connect to the NDI Polaris tracking system (or alternatively use a virtual tracking device) - and we will show the movement of a tool as cone in the StdMultiWidget editor. - - -*/ - -/** - \defgroup org_mitk_gui_qt_igtexamples_internal Internal - \ingroup org_mitk_gui_qt_igtexamples - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.igtexamples plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. - - QmitkIGTExamples does not contain any internal classes. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.igtexamples/manifest_headers.cmake deleted file mode 100644 index dd0a165937..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.igtexamples/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "IGT 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) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.igtnavigation/documentation/doxygen/modules.dox deleted file mode 100644 index a605fbf50c..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_igtnavigation org.mitk.gui.qt.igtnavigation Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_igtnavigation_internal Internal - \ingroup org_mitk_gui_qt_igtnavigation - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.igtnavigation plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.igtnavigation/manifest_headers.cmake deleted file mode 100644 index 7fd4493e93..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "Igtnavigation") -set(Plugin-Version "0.1") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "") -set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/doxygen/modules.dox deleted file mode 100644 index b17cba7b6c..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_igttracking org.mitk.gui.qt.igttracking Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_igttracking_internal Internal - \ingroup org_mitk_gui_qt_igttracking - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.igttracking plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.igttracking/manifest_headers.cmake deleted file mode 100644 index bdbd9bd0d4..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.igttracking/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "IGT Tracking") -set(Plugin-Version "0.1") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/doxygen/modules.dox deleted file mode 100755 index 1284e8071a..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_imagecropper org.mitk.gui.qt.imagecropper Plugin - \ingroup MITKPlugins - - \brief This is the image cropper plugin. It can crop images. - -*/ - -/** - \defgroup org_mitk_gui_qt_imagecropper_internal Internal - \ingroup org_mitk_gui_qt_imagecropper - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.imagecropper plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.imagecropper/manifest_headers.cmake deleted file mode 100644 index 7caa5b0638..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.imagecropper/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Image Cropper") -set(Plugin-Version "1.0.0") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/doxygen/modules.dox deleted file mode 100644 index 23ec64393f..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_imagenavigator org.mitk.gui.qt.imagenavigator Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_imagenavigator_internal Internal - \ingroup org_mitk_gui_qt_imagenavigator - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.imagenavigator plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.imagenavigator/manifest_headers.cmake deleted file mode 100644 index 218d55ad61..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Image Navigator") -set(Plugin-Version "0.9") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.cpp b/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.cpp deleted file mode 100644 index ad8399c33c..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/*========================================================================= -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkImageNavigatorView.h" - -#include "mitkNodePredicateDataType.h" - -#include "QmitkDataStorageComboBox.h" -#include "QmitkStdMultiWidget.h" - -#include "mitkDataStorageEditorInput.h" - -// berry Includes -#include -#include -#include - -#include - - - -const std::string QmitkImageNavigatorView::VIEW_ID = "org.mitk.views.imagenavigator"; - - -class ImageNavigatorPartListener : public berry::IPartListener -{ -public: - - ImageNavigatorPartListener(QmitkImageNavigatorView* view) - : m_View(view) - {} - - berry::IPartListener::Events::Types GetPartEventTypes() const - { - return berry::IPartListener::Events::OPENED | - berry::IPartListener::Events::CLOSED; - } - - void PartClosed(berry::IWorkbenchPartReference::Pointer partRef) - { - if((partRef->GetId() == QmitkImageNavigatorView::VIEW_ID) || (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID)) - { - m_View->SetMultiWidget(0); - } - } - - void PartOpened(berry::IWorkbenchPartReference::Pointer partRef) - { - if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) - { - if (QmitkStdMultiWidgetEditor::Pointer multiWidgetPart = - partRef->GetPart(false).Cast()) - { - m_View->SetMultiWidget(multiWidgetPart->GetStdMultiWidget()); - } - else - { - m_View->SetMultiWidget(0); - } - } - } - -private: - - QmitkImageNavigatorView* m_View; -}; - - -QmitkImageNavigatorView::QmitkImageNavigatorView() - : m_MultiWidget(NULL) -{ - multiWidgetListener = new ImageNavigatorPartListener(this); -} - -QmitkImageNavigatorView::~QmitkImageNavigatorView() -{ - this->GetSite()->GetPage()->RemovePartListener(multiWidgetListener); -} - -void QmitkImageNavigatorView::CreateQtPartControl(QWidget *parent) -{ - - // create GUI widgets - m_Controls.setupUi(parent); - m_MultiWidget = this->GetActiveStdMultiWidget(); - m_Controls.m_SliceNavigatorTransversal->SetInverseDirection(true); - m_TransversalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorTransversal, m_MultiWidget->mitkWidget1->GetSliceNavigationController()->GetSlice() , "sliceNavigatorTransversalFromSimpleExample"); - m_SagittalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorSagittal, m_MultiWidget->mitkWidget2->GetSliceNavigationController()->GetSlice(), "sliceNavigatorSagittalFromSimpleExample"); - m_FrontalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorFrontal, m_MultiWidget->mitkWidget3->GetSliceNavigationController()->GetSlice(), "sliceNavigatorFrontalFromSimpleExample"); - m_TimeStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorTime, m_MultiWidget->GetTimeNavigationController()->GetTime(), "sliceNavigatorTimeFromSimpleExample"); - - this->GetSite()->GetPage()->AddPartListener(multiWidgetListener); - - connect(m_Controls.m_XWorldCoordinateSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnMillimetreCoordinateValueChanged())); - connect(m_Controls.m_YWorldCoordinateSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnMillimetreCoordinateValueChanged())); - connect(m_Controls.m_ZWorldCoordinateSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnMillimetreCoordinateValueChanged())); - - connect(m_TransversalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); - connect(m_SagittalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); - connect(m_FrontalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); -} - -void QmitkImageNavigatorView::SetFocus () -{ - -} - -void QmitkImageNavigatorView::SetMultiWidget(QmitkStdMultiWidget* multiWidget) -{ - m_MultiWidget = multiWidget; - if (m_MultiWidget) - { - m_TransversalStepper->deleteLater(); - m_SagittalStepper->deleteLater(); - m_FrontalStepper->deleteLater(); - m_TimeStepper->deleteLater(); - - m_TransversalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorTransversal, m_MultiWidget->mitkWidget1->GetSliceNavigationController()->GetSlice() , "sliceNavigatorTransversalFromSimpleExample"); - m_SagittalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorSagittal, m_MultiWidget->mitkWidget2->GetSliceNavigationController()->GetSlice(), "sliceNavigatorSagittalFromSimpleExample"); - m_FrontalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorFrontal, m_MultiWidget->mitkWidget3->GetSliceNavigationController()->GetSlice(), "sliceNavigatorFrontalFromSimpleExample"); - m_TimeStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorTime, m_MultiWidget->GetTimeNavigationController()->GetTime(), "sliceNavigatorTimeFromSimpleExample"); - } - else - { - m_TransversalStepper->SetStepper(0); - m_SagittalStepper->SetStepper(0); - m_FrontalStepper->SetStepper(0); - m_TimeStepper->SetStepper(0); - } -} - -QmitkStdMultiWidget* QmitkImageNavigatorView::GetActiveStdMultiWidget() -{ - QmitkStdMultiWidget* activeStdMultiWidget = 0; - berry::IEditorPart::Pointer editor = - this->GetSite()->GetPage()->GetActiveEditor(); - - if (editor.Cast().IsNotNull()) - { - activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); - } - else - { - mitk::DataStorageEditorInput::Pointer editorInput; - editorInput = new mitk::DataStorageEditorInput(); - berry::IEditorPart::Pointer editor = this->GetSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID, false); - activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); - } - - return activeStdMultiWidget; -} - -int QmitkImageNavigatorView::GetSizeFlags(bool width) -{ - if(!width) - { - return berry::Constants::MIN | berry::Constants::MAX | berry::Constants::FILL; - } - else - { - return 0; - } -} - -int QmitkImageNavigatorView::ComputePreferredSize(bool width, int /*availableParallel*/, int /*availablePerpendicular*/, int preferredResult) -{ - if(width==false) - { - return 160; - } - else - { - return preferredResult; - } -} - -int QmitkImageNavigatorView::GetClosestAxisIndex(mitk::Vector3D normal) -{ - // cos(theta) = normal . axis - // cos(theta) = (a, b, c) . (d, e, f) - // cos(theta) = (a, b, c) . (1, 0, 0) = a - // cos(theta) = (a, b, c) . (0, 1, 0) = b - // cos(theta) = (a, b, c) . (0, 0, 1) = c - double absCosThetaWithAxis[3]; - - for (int i = 0; i < 3; i++) - { - absCosThetaWithAxis[i] = fabs(normal[i]); - } - int largestIndex = 0; - double largestValue = absCosThetaWithAxis[0]; - for (int i = 1; i < 3; i++) - { - if (absCosThetaWithAxis[i] > largestValue) - { - largestValue = absCosThetaWithAxis[i]; - largestIndex = i; - } - } - return largestIndex; -} - -void QmitkImageNavigatorView::SetBorderColors() -{ - if (m_MultiWidget) - { - mitk::PlaneGeometry::ConstPointer geometry = m_MultiWidget->mitkWidget1->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - - if (geometry.IsNotNull()) - { - mitk::Vector3D normal = geometry->GetNormal(); - int axis = this->GetClosestAxisIndex(normal); - this->SetBorderColor(axis, QString("red")); - } - - geometry = m_MultiWidget->mitkWidget2->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - - if (geometry.IsNotNull()) - { - mitk::Vector3D normal = geometry->GetNormal(); - int axis = this->GetClosestAxisIndex(normal); - this->SetBorderColor(axis, QString("green")); - } - - geometry = m_MultiWidget->mitkWidget3->GetSliceNavigationController()->GetCurrentPlaneGeometry(); - - if (geometry.IsNotNull()) - { - mitk::Vector3D normal = geometry->GetNormal(); - int axis = this->GetClosestAxisIndex(normal); - this->SetBorderColor(axis, QString("blue")); - } - - } -} - -void QmitkImageNavigatorView::SetBorderColor(int axis, QString colorAsStyleSheetString) -{ - if (axis == 0) - { - this->SetBorderColor(m_Controls.m_XWorldCoordinateSpinBox, colorAsStyleSheetString); - } - else if (axis == 1) - { - this->SetBorderColor(m_Controls.m_YWorldCoordinateSpinBox, colorAsStyleSheetString); - } - else if (axis == 2) - { - this->SetBorderColor(m_Controls.m_ZWorldCoordinateSpinBox, colorAsStyleSheetString); - } -} - -void QmitkImageNavigatorView::SetBorderColor(QDoubleSpinBox *spinBox, QString colorAsStyleSheetString) -{ - assert(spinBox); - spinBox->setStyleSheet(QString("border: 2px solid ") + colorAsStyleSheetString + ";"); -} - -void QmitkImageNavigatorView::SetStepSizes() -{ - this->SetStepSize(0); - this->SetStepSize(1); - this->SetStepSize(2); -} - -void QmitkImageNavigatorView::SetStepSize(int axis) -{ - if (m_MultiWidget) - { - mitk::Geometry3D::ConstPointer geometry = m_MultiWidget->mitkWidget1->GetSliceNavigationController()->GetInputWorldGeometry(); - - if (geometry.IsNotNull()) - { - mitk::Point3D crossPositionInIndexCoordinates; - mitk::Point3D crossPositionInIndexCoordinatesPlus1; - mitk::Point3D crossPositionInMillimetresPlus1; - mitk::Vector3D transformedAxisDirection; - - mitk::Point3D crossPositionInMillimetres = m_MultiWidget->GetCrossPosition(); - geometry->WorldToIndex(crossPositionInMillimetres, crossPositionInIndexCoordinates); - - crossPositionInIndexCoordinatesPlus1 = crossPositionInIndexCoordinates; - crossPositionInIndexCoordinatesPlus1[axis] += 1; - - geometry->IndexToWorld(crossPositionInIndexCoordinatesPlus1, crossPositionInMillimetresPlus1); - - transformedAxisDirection = crossPositionInMillimetresPlus1 - crossPositionInMillimetres; - - int closestAxisInMillimetreSpace = this->GetClosestAxisIndex(transformedAxisDirection); - double stepSize = transformedAxisDirection.GetNorm(); - this->SetStepSize(closestAxisInMillimetreSpace, stepSize); - } - } -} - -void QmitkImageNavigatorView::SetStepSize(int axis, double stepSize) -{ - if (axis == 0) - { - m_Controls.m_XWorldCoordinateSpinBox->setSingleStep(stepSize); - } - else if (axis == 1) - { - m_Controls.m_YWorldCoordinateSpinBox->setSingleStep(stepSize); - } - else if (axis == 2) - { - m_Controls.m_ZWorldCoordinateSpinBox->setSingleStep(stepSize); - } -} - -void QmitkImageNavigatorView::OnMillimetreCoordinateValueChanged() -{ - if (m_MultiWidget) - { - mitk::Geometry3D::ConstPointer geometry = m_MultiWidget->mitkWidget1->GetSliceNavigationController()->GetInputWorldGeometry(); - - if (geometry.IsNotNull()) - { - mitk::Point3D positionInWorldCoordinates; - positionInWorldCoordinates[0] = m_Controls.m_XWorldCoordinateSpinBox->value(); - positionInWorldCoordinates[1] = m_Controls.m_YWorldCoordinateSpinBox->value(); - positionInWorldCoordinates[2] = m_Controls.m_ZWorldCoordinateSpinBox->value(); - - m_MultiWidget->MoveCrossToPosition(positionInWorldCoordinates); - } - } -} - -void QmitkImageNavigatorView::OnRefetch() -{ - if (m_MultiWidget) - { - mitk::Geometry3D::ConstPointer geometry = m_MultiWidget->mitkWidget1->GetSliceNavigationController()->GetInputWorldGeometry(); - - if (geometry.IsNotNull()) - { - mitk::Geometry3D::BoundsArrayType bounds = geometry->GetBounds(); - - mitk::Point3D cornerPoint1InIndexCoordinates; - cornerPoint1InIndexCoordinates[0] = bounds[0]; - cornerPoint1InIndexCoordinates[1] = bounds[2]; - cornerPoint1InIndexCoordinates[2] = bounds[4]; - - mitk::Point3D cornerPoint2InIndexCoordinates; - cornerPoint2InIndexCoordinates[0] = bounds[1]; - cornerPoint2InIndexCoordinates[1] = bounds[3]; - cornerPoint2InIndexCoordinates[2] = bounds[5]; - - if (!geometry->GetImageGeometry()) - { - cornerPoint1InIndexCoordinates[0] += 0.5; - cornerPoint1InIndexCoordinates[1] += 0.5; - cornerPoint1InIndexCoordinates[2] += 0.5; - cornerPoint2InIndexCoordinates[0] -= 0.5; - cornerPoint2InIndexCoordinates[1] -= 0.5; - cornerPoint2InIndexCoordinates[2] -= 0.5; - } - - mitk::Point3D crossPositionInWorldCoordinates = m_MultiWidget->GetCrossPosition(); - - mitk::Point3D cornerPoint1InWorldCoordinates; - mitk::Point3D cornerPoint2InWorldCoordinates; - - geometry->IndexToWorld(cornerPoint1InIndexCoordinates, cornerPoint1InWorldCoordinates); - geometry->IndexToWorld(cornerPoint2InIndexCoordinates, cornerPoint2InWorldCoordinates); - - m_Controls.m_XWorldCoordinateSpinBox->blockSignals(true); - m_Controls.m_YWorldCoordinateSpinBox->blockSignals(true); - m_Controls.m_ZWorldCoordinateSpinBox->blockSignals(true); - - m_Controls.m_XWorldCoordinateSpinBox->setMinimum(std::min(cornerPoint1InWorldCoordinates[0], cornerPoint2InWorldCoordinates[0])); - m_Controls.m_YWorldCoordinateSpinBox->setMinimum(std::min(cornerPoint1InWorldCoordinates[1], cornerPoint2InWorldCoordinates[1])); - m_Controls.m_ZWorldCoordinateSpinBox->setMinimum(std::min(cornerPoint1InWorldCoordinates[2], cornerPoint2InWorldCoordinates[2])); - m_Controls.m_XWorldCoordinateSpinBox->setMaximum(std::max(cornerPoint1InWorldCoordinates[0], cornerPoint2InWorldCoordinates[0])); - m_Controls.m_YWorldCoordinateSpinBox->setMaximum(std::max(cornerPoint1InWorldCoordinates[1], cornerPoint2InWorldCoordinates[1])); - m_Controls.m_ZWorldCoordinateSpinBox->setMaximum(std::max(cornerPoint1InWorldCoordinates[2], cornerPoint2InWorldCoordinates[2])); - - m_Controls.m_XWorldCoordinateSpinBox->setValue(crossPositionInWorldCoordinates[0]); - m_Controls.m_YWorldCoordinateSpinBox->setValue(crossPositionInWorldCoordinates[1]); - m_Controls.m_ZWorldCoordinateSpinBox->setValue(crossPositionInWorldCoordinates[2]); - - m_Controls.m_XWorldCoordinateSpinBox->blockSignals(false); - m_Controls.m_YWorldCoordinateSpinBox->blockSignals(false); - m_Controls.m_ZWorldCoordinateSpinBox->blockSignals(false); - } - - this->SetBorderColors(); - - } -} diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.h b/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.h deleted file mode 100644 index fafa6a8179..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.h +++ /dev/null @@ -1,109 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 17495 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef _QMITKIMAGENAVIGATORVIEW_H_INCLUDED -#define _QMITKIMAGENAVIGATORVIEW_H_INCLUDED - -#include -#include "berryISizeProvider.h" - -#include -#include -#include -#include "QmitkStepperAdapter.h" - -#include - -#include "ui_QmitkImageNavigatorViewControls.h" -#include "berryISizeProvider.h" - - -/*! - * \ingroup org_mitk_gui_qt_imagenavigator_internal - * - * \class QmitkImageNavigatorView - * - * \brief Provides a means to scan quickly through a dataset via Transversal, - * Coronal and Sagittal sliders, displaying millimetre location and stepper position. - * - * For images, the stepper position corresponds to a voxel index. For other datasets - * such as a surface, it corresponds to a sub-division of the bounding box. - * - * \sa QmitkFunctionality - */ -class QmitkImageNavigatorView : public berry::QtViewPart, public berry::ISizeProvider -{ - - // 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; - - QmitkImageNavigatorView(); - QmitkImageNavigatorView(const QmitkImageNavigatorView& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - - virtual ~QmitkImageNavigatorView(); - - virtual void CreateQtPartControl(QWidget *parent); - - QmitkStdMultiWidget* GetActiveStdMultiWidget(); - - void SetFocus(); - - virtual int GetSizeFlags(bool width); - virtual int ComputePreferredSize(bool width, int /*availableParallel*/, int /*availablePerpendicular*/, int preferredResult); - -protected slots: - - void OnMillimetreCoordinateValueChanged(); - void OnRefetch(); - -protected: - - friend class ImageNavigatorPartListener; - - void SetMultiWidget(QmitkStdMultiWidget* multiWidget); - void SetBorderColors(); - void SetBorderColor(QDoubleSpinBox *spinBox, QString colorAsStyleSheetString); - void SetBorderColor(int axis, QString colorAsStyleSheetString); - void SetStepSizes(); - void SetStepSize(int axis); - void SetStepSize(int axis, double stepSize); - int GetClosestAxisIndex(mitk::Vector3D normal); - - Ui::QmitkImageNavigatorViewControls m_Controls; - - QmitkStdMultiWidget* m_MultiWidget; - QmitkStepperAdapter* m_TransversalStepper; - QmitkStepperAdapter* m_SagittalStepper; - QmitkStepperAdapter* m_FrontalStepper; - QmitkStepperAdapter* m_TimeStepper; - - berry::IPartListener::Pointer multiWidgetListener; -}; - - - - -#endif // _QMITKIMAGENAVIGATORVIEW_H_INCLUDED - diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/doxygen/modules.dox deleted file mode 100644 index 9c54f66708..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_materialeditor org.mitk.gui.qt.materialeditor Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_materialeditor_internal Internal - \ingroup org_mitk_gui_qt_materialeditor - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.materialeditor plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.materialeditor/manifest_headers.cmake deleted file mode 100644 index 8f72fc2fe3..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.materialeditor/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Material Editor") -set(Plugin-Version "0.9") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/doxygen/modules.dox deleted file mode 100644 index ddd7d25af9..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_measurementtoolbox org.mitk.gui.qt.measurementtoolbox Plugin - \ingroup MITKPlugins - - \brief This is the measurementtoolbox plugin. - -*/ - -/** - \defgroup org_mitk_gui_qt_measurementtoolbox_internal Internal - \ingroup org_mitk_gui_qt_measurementtoolbox - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.measurementtoolbox plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/manifest_headers.cmake deleted file mode 100644 index 90079fa306..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Measurement") -set(Plugin-Version "1.0.0") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp deleted file mode 100644 index 6bbda74c2f..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp +++ /dev/null @@ -1,783 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-05-22 11:00:35 +0200 (Fr, 22 Mai 2009) $ -Version: $Revision: 10185 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkImageStatisticsView.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - - -#include "QmitkStdMultiWidget.h" -#include "QmitkSliderNavigatorWidget.h" - -#include "mitkNodePredicateDataType.h" -#include "mitkImageTimeSelector.h" -#include "mitkProperties.h" - -#include "mitkProgressBar.h" - -// Includes for image processing -#include "mitkImageCast.h" -#include "mitkITKImageImport.h" - -#include "mitkDataNodeObject.h" -#include "mitkNodePredicateData.h" -#include "mitkPlanarFigureInteractor.h" - -#include - -const std::string QmitkImageStatisticsView::VIEW_ID = -"org.mitk.views.imagestatistics"; - -class QmitkRequestStatisticsUpdateEvent : public QEvent -{ -public: - enum Type - { - StatisticsUpdateRequest = QEvent::MaxUser - 1025 - }; - - QmitkRequestStatisticsUpdateEvent() - : QEvent( (QEvent::Type) StatisticsUpdateRequest ) {}; -}; - - - -typedef itk::Image ImageType; -typedef itk::Image FloatImageType; -typedef itk::Image, 3> VectorImageType; - -inline bool my_isnan(float x) - { - volatile float d = x; - - if(d!=d) - return true; - - if(d==d) - return false; - return d != d; - - } - -QmitkImageStatisticsView::QmitkImageStatisticsView(QObject* /*parent*/, const char* /*name*/) -: QmitkFunctionality(), - m_Controls( NULL ), - m_TimeStepperAdapter( NULL ), - m_SelectedImageNode( NULL ), - m_SelectedImage( NULL ), - m_SelectedMaskNode( NULL ), - m_SelectedImageMask( NULL ), - m_SelectedPlanarFigure( NULL ), - m_ImageObserverTag( -1 ), - m_ImageMaskObserverTag( -1 ), - m_PlanarFigureObserverTag( -1 ), - m_CurrentStatisticsValid( false ), - m_StatisticsUpdatePending( false ) -{ -} - - -QmitkImageStatisticsView::~QmitkImageStatisticsView() -{ - if ( m_SelectedImage != NULL ) - m_SelectedImage->RemoveObserver( m_ImageObserverTag ); - if ( m_SelectedImageMask != NULL ) - m_SelectedImageMask->RemoveObserver( m_ImageMaskObserverTag ); - if ( m_SelectedPlanarFigure != NULL ) - m_SelectedPlanarFigure->RemoveObserver( m_PlanarFigureObserverTag ); -} - - -void QmitkImageStatisticsView::CreateQtPartControl(QWidget *parent) -{ - if (m_Controls == NULL) - { - m_Controls = new Ui::QmitkImageStatisticsViewControls; - m_Controls->setupUi(parent); - this->CreateConnections(); - - m_Controls->m_ErrorMessageLabel->hide(); - - m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 0 ); - m_Controls->m_LineProfileWidget->SetPathModeToPlanarFigure(); - } -} - - - -void QmitkImageStatisticsView::CreateConnections() -{ - if ( m_Controls ) - { - connect( (QObject*)(m_Controls->m_ButtonCopyHistogramToClipboard), SIGNAL(clicked()),(QObject*) this, SLOT(ClipboardHistogramButtonClicked())); - connect( (QObject*)(m_Controls->m_ButtonCopyStatisticsToClipboard), SIGNAL(clicked()),(QObject*) this, SLOT(ClipboardStatisticsButtonClicked())); - connect( (QObject*)(m_Controls->m_IgnoreZerosCheckbox), SIGNAL(clicked()),(QObject*) this, SLOT(IgnoreZerosCheckboxClicked())); - } -} - -void QmitkImageStatisticsView::IgnoreZerosCheckboxClicked( ) -{ - UpdateStatistics(); -} - -void QmitkImageStatisticsView::StdMultiWidgetAvailable( QmitkStdMultiWidget& stdMultiWidget ) -{ - QmitkFunctionality::StdMultiWidgetAvailable(stdMultiWidget); -} - - -void QmitkImageStatisticsView::ClipboardHistogramButtonClicked() -{ - if ( m_CurrentStatisticsValid && (m_CurrentStatisticsCalculator.IsNotNull()) ) - { - typedef mitk::ImageStatisticsCalculator::HistogramType HistogramType; - const HistogramType *histogram = m_CurrentStatisticsCalculator->GetHistogram(); - - QString clipboard( "Measurement \t Frequency\n" ); - for ( HistogramType::ConstIterator it = histogram->Begin(); - it != histogram->End(); - ++it ) - { - clipboard = clipboard.append( "%L1 \t %L2\n" ) - .arg( it.GetMeasurementVector()[0], 0, 'f', 2 ) - .arg( it.GetFrequency() ); - } - - QApplication::clipboard()->setText( - clipboard, QClipboard::Clipboard ); - } - else - { - QApplication::clipboard()->clear(); - } -} - - -void QmitkImageStatisticsView::ClipboardStatisticsButtonClicked() -{ - if ( m_CurrentStatisticsValid && (m_CurrentStatisticsCalculator.IsNotNull()) ) - { - const mitk::ImageStatisticsCalculator::Statistics &statistics = - m_CurrentStatisticsCalculator->GetStatistics(); - - // Copy statistics to clipboard ("%Ln" will use the default locale for - // number formatting) - QString clipboard( "Mean \t StdDev \t RMS \t Max \t Min \t N \t V (mm³)\n" ); - clipboard = clipboard.append( "%L1 \t %L2 \t %L3 \t %L4 \t %L5 \t %L6 \t %L7" ) - .arg( statistics.Mean, 0, 'f', 10 ) - .arg( statistics.Sigma, 0, 'f', 10 ) - .arg( statistics.RMS, 0, 'f', 10 ) - .arg( statistics.Max, 0, 'f', 10 ) - .arg( statistics.Min, 0, 'f', 10 ) - .arg( statistics.N ) - .arg( m_Controls->m_StatisticsTable->item( 0, 6 )->text() ); - - QApplication::clipboard()->setText( - clipboard, QClipboard::Clipboard ); - } - else - { - QApplication::clipboard()->clear(); - } -} - - -void QmitkImageStatisticsView::FillStatisticsTableView( - const mitk::ImageStatisticsCalculator::Statistics &s, - const mitk::Image *image ) -{ - m_Controls->m_StatisticsTable->setItem( 0, 0, new QTableWidgetItem( - QString("%1").arg(s.Mean, 0, 'f', 2) ) ); - - m_Controls->m_StatisticsTable->setItem( 0, 1, new QTableWidgetItem( - QString("%1").arg(s.Sigma, 0, 'f', 2) ) ); - - m_Controls->m_StatisticsTable->setItem( 0, 2, new QTableWidgetItem( - QString("%1").arg(s.RMS, 0, 'f', 2) ) ); - - m_Controls->m_StatisticsTable->setItem( 0, 3, new QTableWidgetItem( - QString("%1").arg(s.Max, 0, 'f', 2) ) ); - - m_Controls->m_StatisticsTable->setItem( 0, 4, new QTableWidgetItem( - QString("%1").arg(s.Min, 0, 'f', 2) ) ); - - m_Controls->m_StatisticsTable->setItem( 0, 5, new QTableWidgetItem( - QString("%1").arg(s.N) ) ); - - const mitk::Geometry3D *geometry = image->GetGeometry(); - if ( geometry != NULL ) - { - const mitk::Vector3D &spacing = image->GetGeometry()->GetSpacing(); - double volume = spacing[0] * spacing[1] * spacing[2] * (double) s.N; - m_Controls->m_StatisticsTable->setItem( 0, 6, new QTableWidgetItem( - QString("%1").arg(volume, 0, 'f', 2) ) ); - } - else - { - m_Controls->m_StatisticsTable->setItem( 0, 6, new QTableWidgetItem( - "NA" ) ); - } -} - - -void QmitkImageStatisticsView::InvalidateStatisticsTableView() -{ - for ( unsigned int i = 0; i < 7; ++i ) - { - m_Controls->m_StatisticsTable->setItem( 0, i, new QTableWidgetItem( "NA" ) ); - } -} - - -void QmitkImageStatisticsView::OnSelectionChanged( std::vector nodes ) -{ - // Clear any unreferenced images - this->RemoveOrphanImages(); - - if ( !this->IsVisible() ) - { - return; - } - - // Check if selection makeup consists only of valid nodes: - // One image, segmentation or planarFigure - // One image and one of the other two - bool tooManyNodes( true ); - bool invalidNodes( true ); - - if ( nodes.size() < 3 ) - { - tooManyNodes = false; - } - - if( !tooManyNodes ) - { - unsigned int numberImages = 0; - unsigned int numberSegmentations = 0; - unsigned int numberPlanarFigures = 0; - - for ( unsigned int index = 0; index < nodes.size(); index++ ) - { - m_SelectedImageMask = dynamic_cast< mitk::Image * >( nodes[ index ]->GetData() ); - m_SelectedPlanarFigure = dynamic_cast< mitk::PlanarFigure * >( nodes[ index ]->GetData() ); - - if ( m_SelectedImageMask != NULL ) - { - bool isMask( false ); - nodes[ index ]->GetPropertyValue("binary", isMask); - if ( !isMask ) - { - numberImages++; - } - else - { - numberSegmentations++; - if ( numberImages != 0 ) // image should be last element - { - std::swap( nodes[ index ], nodes[ index - 1 ] ); - } - } - } - else if ( m_SelectedPlanarFigure != NULL ) - { - numberPlanarFigures++; - if ( numberImages != 0 ) // image should be last element - { - std::swap( nodes[ index ], nodes[ index - 1 ] ); - } - } - } - - if ( ( numberPlanarFigures + numberSegmentations + numberImages ) == nodes.size() && //No invalid nodes - ( numberPlanarFigures + numberSegmentations ) < 2 && numberImages < 2 - // maximum of one image and/or one of either planar figure or segmentation - ) - { - invalidNodes = false; - } - } - - if ( nodes.empty() || tooManyNodes || invalidNodes ) - { - // Nothing to do: invalidate image, clear statistics, histogram, and GUI - m_SelectedImage = NULL; - this->InvalidateStatisticsTableView() ; - m_Controls->m_HistogramWidget->ClearItemModel(); - m_Controls->m_LineProfileWidget->ClearItemModel(); - - m_CurrentStatisticsValid = false; - m_Controls->m_ErrorMessageLabel->hide(); - m_Controls->m_SelectedMaskLabel->setText( "None" ); - return; - } - - // Get selected element - - mitk::DataNode *selectedNode = nodes.front(); - mitk::Image *selectedImage = dynamic_cast< mitk::Image * >( selectedNode->GetData() ); - - // Find the next parent/grand-parent node containing an image, if any - mitk::DataStorage::SetOfObjects::ConstPointer parentObjects; - mitk::DataNode *parentNode = NULL; - mitk::Image *parentImage = NULL; - - // Possibly previous change listeners - if ( (m_SelectedPlanarFigure != NULL) && (m_PlanarFigureObserverTag >= 0) ) - { - m_SelectedPlanarFigure->RemoveObserver( m_PlanarFigureObserverTag ); - m_PlanarFigureObserverTag = -1; - } - if ( (m_SelectedImage != NULL) && (m_ImageObserverTag >= 0) ) - { - m_SelectedImage->RemoveObserver( m_ImageObserverTag ); - m_ImageObserverTag = -1; - } - if ( (m_SelectedImageMask != NULL) && (m_ImageMaskObserverTag >= 0) ) - { - m_SelectedImageMask->RemoveObserver( m_ImageMaskObserverTag ); - m_ImageMaskObserverTag = -1; - } - - // Deselect all images and masks by default - m_SelectedImageNode = NULL; - m_SelectedImage = NULL; - m_SelectedMaskNode = NULL; - m_SelectedImageMask = NULL; - m_SelectedPlanarFigure = NULL; - - { - unsigned int parentObjectIndex = 0; - parentObjects = this->GetDefaultDataStorage()->GetSources( selectedNode ); - while( parentObjectIndex < parentObjects->Size() ) - { - // Use first parent object (if multiple parents are present) - parentNode = parentObjects->ElementAt( parentObjectIndex ); - parentImage = dynamic_cast< mitk::Image * >( parentNode->GetData() ); - if( parentImage != NULL ) - { - break; - } - parentObjectIndex++; - } - } - - if ( nodes.size() == 2 ) - { - parentNode = nodes.back(); - parentImage = dynamic_cast< mitk::Image * >( parentNode->GetData() ); - } - - if ( parentImage != NULL ) - { - m_SelectedImageNode = parentNode; - m_SelectedImage = parentImage; - - // Check if a valid mask has been selected (Image or PlanarFigure) - m_SelectedImageMask = dynamic_cast< mitk::Image * >( selectedNode->GetData() ); - m_SelectedPlanarFigure = dynamic_cast< mitk::PlanarFigure * >( selectedNode->GetData() ); - - // Check whether ImageMask is a binary segmentation - - if ( (m_SelectedImageMask != NULL) ) - { - bool isMask( false ); - selectedNode->GetPropertyValue("binary", isMask); - if ( !isMask ) - { - m_SelectedImageNode = selectedNode; - m_SelectedImage = selectedImage; - m_SelectedImageMask = NULL; - } - else - { - m_SelectedMaskNode = selectedNode; - } - } - else if ( (m_SelectedPlanarFigure != NULL) ) - { - m_SelectedMaskNode = selectedNode; - } - } - else if ( selectedImage != NULL ) - { - m_SelectedImageNode = selectedNode; - m_SelectedImage = selectedImage; - } - - - typedef itk::SimpleMemberCommand< QmitkImageStatisticsView > ITKCommandType; - ITKCommandType::Pointer changeListener; - changeListener = ITKCommandType::New(); - changeListener->SetCallbackFunction( this, &QmitkImageStatisticsView::RequestStatisticsUpdate ); - - // Add change listeners to selected objects - if ( m_SelectedImage != NULL ) - { - m_ImageObserverTag = m_SelectedImage->AddObserver( - itk::ModifiedEvent(), changeListener ); - } - - if ( m_SelectedImageMask != NULL ) - { - m_ImageMaskObserverTag = m_SelectedImageMask->AddObserver( - itk::ModifiedEvent(), changeListener ); - } - - if ( m_SelectedPlanarFigure != NULL ) - { - m_PlanarFigureObserverTag = m_SelectedPlanarFigure->AddObserver( - mitk::EndInteractionPlanarFigureEvent(), changeListener ); - } - - - // Clear statistics / histogram GUI if nothing is selected - if ( m_SelectedImage == NULL ) - { - // Clear statistics, histogram, and GUI - this->InvalidateStatisticsTableView(); - m_Controls->m_HistogramWidget->ClearItemModel(); - m_Controls->m_LineProfileWidget->ClearItemModel(); - m_CurrentStatisticsValid = false; - m_Controls->m_ErrorMessageLabel->hide(); - m_Controls->m_SelectedMaskLabel->setText( "None" ); - } - else - { - // Else, request statistics and GUI update - this->RequestStatisticsUpdate(); - } -} - - -void QmitkImageStatisticsView::UpdateStatistics() -{ - - // Remove any cached images that are no longer referenced elsewhere - this->RemoveOrphanImages(); - - QmitkStdMultiWidget *multiWidget = this->GetActiveStdMultiWidget(); - if ( multiWidget == NULL ) - { - return; - } - - unsigned int timeStep = multiWidget->GetTimeNavigationController()->GetTime()->GetPos(); - - if ( m_SelectedImage != NULL ) - { - // Check if a the selected image is a multi-channel image. If yes, statistics - // cannot be calculated currently. - if ( m_SelectedImage->GetPixelType().GetNumberOfComponents() > 1 ) - { - std::stringstream message; - message << "Multi-component images not supported."; - m_Controls->m_ErrorMessageLabel->setText( message.str().c_str() ); - m_Controls->m_ErrorMessageLabel->show(); - - this->InvalidateStatisticsTableView(); - m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 0 ); - m_Controls->m_HistogramWidget->ClearItemModel(); - m_CurrentStatisticsValid = false; - return; - } - - // Retrieve ImageStatisticsCalculator from has map (or create a new one - // for this image if non-existant) - ImageStatisticsMapType::iterator it = - m_ImageStatisticsMap.find( m_SelectedImage ); - - if ( it != m_ImageStatisticsMap.end() ) - { - m_CurrentStatisticsCalculator = it->second; - MITK_INFO << "Retrieving StatisticsCalculator"; - } - else - { - m_CurrentStatisticsCalculator = mitk::ImageStatisticsCalculator::New(); - m_CurrentStatisticsCalculator->SetImage( m_SelectedImage ); - m_ImageStatisticsMap[m_SelectedImage] = m_CurrentStatisticsCalculator; - MITK_INFO << "Creating StatisticsCalculator"; - } - - std::string maskName; - std::string maskType; - unsigned int maskDimension; - - if ( m_SelectedImageMask != NULL ) - { - m_CurrentStatisticsCalculator->SetImageMask( m_SelectedImageMask ); - m_CurrentStatisticsCalculator->SetMaskingModeToImage(); - - maskName = m_SelectedMaskNode->GetName(); - maskType = m_SelectedImageMask->GetNameOfClass(); - maskDimension = 3; - } - else if ( m_SelectedPlanarFigure != NULL ) - { - m_CurrentStatisticsCalculator->SetPlanarFigure( m_SelectedPlanarFigure ); - m_CurrentStatisticsCalculator->SetMaskingModeToPlanarFigure(); - - maskName = m_SelectedMaskNode->GetName(); - maskType = m_SelectedPlanarFigure->GetNameOfClass(); - maskDimension = 2; - } - else - { - m_CurrentStatisticsCalculator->SetMaskingModeToNone(); - - maskName = "None"; - maskType = ""; - maskDimension = 0; - } - - if(m_Controls->m_IgnoreZerosCheckbox->isChecked()) - { - m_CurrentStatisticsCalculator->SetIgnorePixelValue(0); - m_CurrentStatisticsCalculator->SetDoIgnorePixelValue(true); - } - else - { - m_CurrentStatisticsCalculator->SetDoIgnorePixelValue(false); - } - - std::stringstream maskLabel; - maskLabel << maskName; - if ( maskDimension > 0 ) - { - maskLabel << " [" << maskDimension << "D " << maskType << "]"; - } - - m_Controls->m_SelectedMaskLabel->setText( maskLabel.str().c_str() ); - - bool statisticsChanged = false; - bool statisticsCalculationSuccessful = false; - - // Initialize progress bar - mitk::ProgressBar::GetInstance()->AddStepsToDo( 100 ); - - // Install listener for progress events and initialize progress bar - typedef itk::SimpleMemberCommand< QmitkImageStatisticsView > ITKCommandType; - ITKCommandType::Pointer progressListener; - progressListener = ITKCommandType::New(); - progressListener->SetCallbackFunction( this, &QmitkImageStatisticsView::UpdateProgressBar ); - unsigned long progressObserverTag = m_CurrentStatisticsCalculator - ->AddObserver( itk::ProgressEvent(), progressListener ); - - // show wait cursor - this->WaitCursorOn(); - - try - { - // Compute statistics - statisticsChanged = - m_CurrentStatisticsCalculator->ComputeStatistics( timeStep ); - - statisticsCalculationSuccessful = true; - } - catch ( const std::runtime_error &e ) - { - // In case of exception, print error message on GUI - std::stringstream message; - message << "" << e.what() << ""; - m_Controls->m_ErrorMessageLabel->setText( message.str().c_str() ); - m_Controls->m_ErrorMessageLabel->show(); - } - catch ( const std::exception &e ) - { - MITK_ERROR << "Caught exception: " << e.what(); - - // In case of exception, print error message on GUI - std::stringstream message; - message << "Error! Unequal Dimensions of Image and Segmentation. No recompute possible "; - m_Controls->m_ErrorMessageLabel->setText( message.str().c_str() ); - m_Controls->m_ErrorMessageLabel->show(); - } - - m_CurrentStatisticsCalculator->RemoveObserver( progressObserverTag ); - - // Make sure that progress bar closes - mitk::ProgressBar::GetInstance()->Progress( 100 ); - - // remove wait cursor - this->WaitCursorOff(); - - if ( statisticsCalculationSuccessful ) - { - if ( statisticsChanged ) - { - // Do not show any error messages - m_Controls->m_ErrorMessageLabel->hide(); - - m_CurrentStatisticsValid = true; - } - - m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 0 ); - m_Controls->m_HistogramWidget->SetHistogramModeToDirectHistogram(); - m_Controls->m_HistogramWidget->SetHistogram( - m_CurrentStatisticsCalculator->GetHistogram( timeStep ) ); - m_Controls->m_HistogramWidget->UpdateItemModelFromHistogram(); - - MITK_INFO << "UpdateItemModelFromHistogram()"; - - this->FillStatisticsTableView( - m_CurrentStatisticsCalculator->GetStatistics( timeStep ), - m_SelectedImage ); - } - else - { - m_Controls->m_SelectedMaskLabel->setText( "None" ); - - // Clear statistics and histogram - this->InvalidateStatisticsTableView(); - m_Controls->m_HistogramWidget->ClearItemModel(); - m_CurrentStatisticsValid = false; - - - // If a (non-closed) PlanarFigure is selected, display a line profile widget - if ( m_SelectedPlanarFigure != NULL ) - { - // check whether PlanarFigure is initialized - const mitk::Geometry2D *planarFigureGeometry2D = m_SelectedPlanarFigure->GetGeometry2D(); - if ( planarFigureGeometry2D == NULL ) - { - // Clear statistics, histogram, and GUI - this->InvalidateStatisticsTableView(); - m_Controls->m_HistogramWidget->ClearItemModel(); - m_Controls->m_LineProfileWidget->ClearItemModel(); - m_CurrentStatisticsValid = false; - m_Controls->m_ErrorMessageLabel->hide(); - m_Controls->m_SelectedMaskLabel->setText( "None" ); - return; - } - // TODO: enable line profile widget - m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 1 ); - m_Controls->m_LineProfileWidget->SetImage( m_SelectedImage ); - m_Controls->m_LineProfileWidget->SetPlanarFigure( m_SelectedPlanarFigure ); - m_Controls->m_LineProfileWidget->UpdateItemModelFromPath(); - } - } - } -} - -void QmitkImageStatisticsView::UpdateProgressBar() -{ - mitk::ProgressBar::GetInstance()->Progress(); -} - - -void QmitkImageStatisticsView::RequestStatisticsUpdate() -{ - if ( !m_StatisticsUpdatePending ) - { - QApplication::postEvent( this, new QmitkRequestStatisticsUpdateEvent ); - m_StatisticsUpdatePending = true; - } -} - - -void QmitkImageStatisticsView::RemoveOrphanImages() -{ - ImageStatisticsMapType::iterator it = m_ImageStatisticsMap.begin(); - - while ( it != m_ImageStatisticsMap.end() ) - { - mitk::Image *image = it->first; - mitk::ImageStatisticsCalculator *calculator = it->second; - ++it; - - mitk::NodePredicateData::Pointer hasImage = mitk::NodePredicateData::New( image ); - if ( this->GetDefaultDataStorage()->GetNode( hasImage ) == NULL ) - { - if ( m_SelectedImage == image ) - { - m_SelectedImage = NULL; - m_SelectedImageNode = NULL; - } - if ( m_CurrentStatisticsCalculator == calculator ) - { - m_CurrentStatisticsCalculator = NULL; - } - m_ImageStatisticsMap.erase( image ); - it = m_ImageStatisticsMap.begin(); - } - } -} - - -bool QmitkImageStatisticsView::event( QEvent *event ) -{ - if ( event->type() == (QEvent::Type) QmitkRequestStatisticsUpdateEvent::StatisticsUpdateRequest ) - { - // Update statistics - - m_StatisticsUpdatePending = false; - - this->UpdateStatistics(); - return true; - } - - return false; -} - -void QmitkImageStatisticsView::ComputeIntensityProfile( mitk::PlanarLine* line ) -{ - double sampling = 300; - QmitkVtkHistogramWidget::HistogramType::Pointer histogram = QmitkVtkHistogramWidget::HistogramType::New(); - itk::Size<1> siz; - siz[0] = sampling; - itk::FixedArray lower, higher; - lower.Fill(0); - mitk::Point3D begin = line->GetWorldControlPoint(0); - mitk::Point3D end = line->GetWorldControlPoint(1); - itk::Vector direction = (end - begin); - higher.Fill(direction.GetNorm()); - histogram->Initialize(siz, lower, higher); - for(int i = 0; i < sampling; i++) - { - mitk::Point3D location = begin + double(i)/sampling * direction; - double d = m_SelectedImage->GetPixelValueByWorldCoordinate(begin + double(i)/sampling * direction); - histogram->SetFrequency(i,d); - } - m_Controls->m_HistogramWidget->SetHistogramModeToDirectHistogram(); - m_Controls->m_HistogramWidget->SetHistogram( histogram ); - m_Controls->m_HistogramWidget->UpdateItemModelFromHistogram(); - -} - -bool QmitkImageStatisticsView::IsExclusiveFunctionality() const -{ - return false; -} - -void QmitkImageStatisticsView::Visible() -{ - this->OnSelectionChanged( this->GetDataManagerSelection() ); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.h b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.h deleted file mode 100644 index ec296caf6f..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.h +++ /dev/null @@ -1,169 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date: 2009-05-28 20:08:26 +0200 (Do, 28 Mai 2009) $ -Version: $Revision: 10185 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkImageStatisticsView_H__INCLUDED -#define QmitkImageStatisticsView_H__INCLUDED - -#include "QmitkFunctionality.h" -#include "ui_QmitkImageStatisticsViewControls.h" - -#include "QmitkStepperAdapter.h" - -#include "mitkImageStatisticsCalculator.h" - -#include -#include - -#include -#include "mitkPlanarLine.h" - - - -/*! -\brief QmitkImageStatisticsView - -\sa QmitkFunctionality -\ingroup Functionalities -*/ -class QmitkImageStatisticsView : public QmitkFunctionality -{ - Q_OBJECT - -public: - - /*! - \ Convenient typedefs - */ - typedef mitk::DataStorage::SetOfObjects ConstVector; - typedef ConstVector::ConstPointer ConstVectorPointer; - typedef ConstVector::ConstIterator ConstVectorIterator; - - /*! - \brief default constructor - */ - QmitkImageStatisticsView(QObject *parent=0, const char *name=0); - QmitkImageStatisticsView(const QmitkImageStatisticsView& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - - /*! - \brief default destructor - */ - virtual ~QmitkImageStatisticsView(); - - /*! - \brief method for creating the widget containing the application controls, like sliders, buttons etc. - */ - virtual void CreateQtPartControl(QWidget *parent); - - /*! - \brief method for creating the connections of main and control widget - */ - virtual void CreateConnections(); - - bool IsExclusiveFunctionality() const; - - virtual bool event( QEvent *event ); - - void OnSelectionChanged( std::vector nodes ); - - static const std::string VIEW_ID; - -protected slots: - void ClipboardHistogramButtonClicked(); - - void ClipboardStatisticsButtonClicked(); - - void IgnoreZerosCheckboxClicked( ); - - -protected: - - void StdMultiWidgetAvailable( QmitkStdMultiWidget& stdMultiWidget ); - - void FillStatisticsTableView( const mitk::ImageStatisticsCalculator::Statistics &s, - const mitk::Image *image ); - - void InvalidateStatisticsTableView(); - - /** \brief Issues a request to update statistics by sending an event to the - * Qt event processing queue. - * - * Statistics update should only be executed after program execution returns - * to the Qt main loop. This mechanism also prevents multiple execution of - * updates where only one is required.*/ - void RequestStatisticsUpdate(); - - /** \brief Recalculate statistics for currently selected image and mask and - * update the GUI. */ - void UpdateStatistics(); - - /** \brief Listener for progress events to update progress bar. */ - void UpdateProgressBar(); - - - /** \brief Removes any cached images which are no longer referenced elsewhere. */ - void RemoveOrphanImages(); - - /** \brief Computes an Intensity Profile along line and updates the histogram widget with it. */ - void ComputeIntensityProfile( mitk::PlanarLine* line ); - - void Visible( ); - - - - typedef std::map< mitk::Image *, mitk::ImageStatisticsCalculator::Pointer > - ImageStatisticsMapType; - - /*! - * controls containing sliders for scrolling through the slices - */ - Ui::QmitkImageStatisticsViewControls *m_Controls; - - QmitkStepperAdapter* m_TimeStepperAdapter; - unsigned int m_CurrentTime; - - QString m_Clipboard; - - // Image and mask data - mitk::DataNode *m_SelectedImageNode; - mitk::Image *m_SelectedImage; - - mitk::DataNode *m_SelectedMaskNode; - mitk::Image *m_SelectedImageMask; - mitk::PlanarFigure *m_SelectedPlanarFigure; - - long m_ImageObserverTag; - long m_ImageMaskObserverTag; - long m_PlanarFigureObserverTag; - - // Hash map for associating one image statistics calculator with each iamge - // (so that previously calculated histograms / statistics can be recovered - // if a recalculation is not required) - ImageStatisticsMapType m_ImageStatisticsMap; - - mitk::ImageStatisticsCalculator::Pointer m_CurrentStatisticsCalculator; - - bool m_CurrentStatisticsValid; - - bool m_StatisticsUpdatePending; -}; - - -#endif // QmitkImageStatisticsView_H__INCLUDED diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.cpp b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.cpp deleted file mode 100644 index 7af4c0847e..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.cpp +++ /dev/null @@ -1,1060 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 15412 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include -#include -#include - -#include "mitkGlobalInteraction.h" -#include "mitkPointSet.h" -#include "mitkProperties.h" -#include "mitkStringProperty.h" -#include "mitkIDataStorageService.h" -#include "mitkDataNodeObject.h" -#include -#include -#include -#include -#include - -#include "mitkPlanarCircle.h" -#include "mitkPlanarPolygon.h" -#include "mitkPlanarAngle.h" -#include "mitkPlanarRectangle.h" -#include "mitkPlanarLine.h" -#include "mitkPlanarCross.h" -#include "mitkPlanarFourPointAngle.h" -#include "mitkPlanarFigureInteractor.h" -#include "mitkPlaneGeometry.h" -#include "QmitkPlanarFiguresTableModel.h" - -#include "QmitkMeasurementView.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "mitkNodePredicateDataType.h" -#include "mitkPlanarFigure.h" - -#include -#include -#include -#include - -const std::string QmitkMeasurementView::VIEW_ID = -"org.mitk.views.measurement"; - -QmitkMeasurementView::QmitkMeasurementView() : -m_Layout(0), m_DrawActionsToolBar(0), -m_DrawActionsGroup(0), m_MeasurementInfoRenderer(0), -m_MeasurementInfoAnnotation(0), m_SelectedPlanarFigures(0), -m_SelectedImageNode(), -m_LineCounter(0), m_PathCounter(0), -m_AngleCounter(0), m_FourPointAngleCounter(0), m_EllipseCounter(0), -m_RectangleCounter(0), m_PolygonCounter(0), -m_CurrentFigureNodeInitialized(false), m_LastRenderWindow(0) -{ - -} - -QmitkMeasurementView::~QmitkMeasurementView() -{ - - m_MeasurementInfoRenderer->Delete(); - - this->GetDefaultDataStorage()->AddNodeEvent -= mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeAddedInDataStorage ); - - m_SelectedPlanarFigures->NodeChanged.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); - - m_SelectedPlanarFigures->NodeRemoved.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); - - m_SelectedPlanarFigures->PropertyChanged.RemoveListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); - - m_SelectedImageNode->NodeChanged.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); - - m_SelectedImageNode->NodeRemoved.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); - - m_SelectedImageNode->PropertyChanged.RemoveListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); - -} - -void QmitkMeasurementView::CreateQtPartControl(QWidget* parent) -{ - m_MeasurementInfoRenderer = vtkRenderer::New(); - m_MeasurementInfoAnnotation = vtkCornerAnnotation::New(); - vtkTextProperty *textProp = vtkTextProperty::New(); - - m_MeasurementInfoAnnotation->SetMaximumFontSize(12); - textProp->SetColor(1.0, 1.0, 1.0); - m_MeasurementInfoAnnotation->SetTextProperty(textProp); - - m_MeasurementInfoRenderer->AddActor(m_MeasurementInfoAnnotation); - m_DrawActionsToolBar = new QToolBar; - m_DrawActionsGroup = new QActionGroup(this); - m_DrawActionsGroup->setExclusive(true); - - //# add actions - QAction* currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/measurement/line.png"), "Draw Line"); - m_DrawLine = currentAction; - m_DrawLine->setCheckable(true); - m_DrawActionsToolBar->addAction(currentAction); - m_DrawActionsGroup->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ActionDrawLineTriggered(bool) ) ); - - currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/measurement/path.png"), "Draw Path"); - m_DrawPath = currentAction; - m_DrawPath->setCheckable(true); - m_DrawActionsToolBar->addAction(currentAction); - m_DrawActionsGroup->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ActionDrawPathTriggered(bool) ) ); - - currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/measurement/angle.png"), "Draw Angle"); - m_DrawAngle = currentAction; - m_DrawAngle->setCheckable(true); - m_DrawActionsToolBar->addAction(currentAction); - m_DrawActionsGroup->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ActionDrawAngleTriggered(bool) ) ); - - currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/measurement/four-point-angle.png"), "Draw Four Point Angle"); - m_DrawFourPointAngle = currentAction; - m_DrawFourPointAngle->setCheckable(true); - m_DrawActionsToolBar->addAction(currentAction); - m_DrawActionsGroup->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ActionDrawFourPointAngleTriggered(bool) ) ); - - currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/measurement/circle.png"), "Draw Circle"); - m_DrawEllipse = currentAction; - m_DrawEllipse->setCheckable(true); - m_DrawActionsToolBar->addAction(currentAction); - m_DrawActionsGroup->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ActionDrawEllipseTriggered(bool) ) ); - - currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/measurement/rectangle.png"), "Draw Rectangle"); - m_DrawRectangle = currentAction; - m_DrawRectangle->setCheckable(true); - m_DrawActionsToolBar->addAction(currentAction); - m_DrawActionsGroup->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ActionDrawRectangleTriggered(bool) ) ); - - currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/measurement/polygon.png"), "Draw Polygon"); - m_DrawPolygon = currentAction; - m_DrawPolygon->setCheckable(true); - m_DrawActionsToolBar->addAction(currentAction); - m_DrawActionsGroup->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ActionDrawPolygonTriggered(bool) ) ); - - currentAction = m_DrawActionsToolBar->addAction(QIcon( - ":/Qmitk/Images_48.png"), "Reproduce potential bug"); - m_DrawActionsToolBar->addAction(currentAction); - QObject::connect( currentAction, SIGNAL( triggered(bool) ) - , this, SLOT( ReproducePotentialBug(bool) ) ); - - - QLabel* selectedImageLabel = new QLabel("Selected Image: "); - m_SelectedImage = new QLabel; - m_SelectedImage->setStyleSheet("font-weight: bold;"); - m_SelectedPlanarFiguresText = new QTextBrowser; - - m_CopyToClipboard = new QPushButton("Copy to Clipboard"); - QObject::connect( m_CopyToClipboard, SIGNAL( clicked(bool) ) - , this, SLOT( CopyToClipboard(bool) ) ); - - m_Layout = new QGridLayout; - m_Layout->addWidget(selectedImageLabel, 0, 0, 1, 1); - m_Layout->addWidget(m_SelectedImage, 0, 1, 1, 1); - m_Layout->addWidget(m_DrawActionsToolBar, 1, 0, 1, 2); - m_Layout->addWidget(m_SelectedPlanarFiguresText, 2, 0, 1, 2); - m_Layout->addWidget(m_CopyToClipboard, 3, 0, 1, 2); - m_Layout->setRowStretch(0, 1); - m_Layout->setRowStretch(1, 1); - m_Layout->setRowStretch(2, 10); - m_Layout->setRowStretch(3, 1); - m_Layout->setContentsMargins(2, 2, 2, 2); - - parent->setLayout(m_Layout); - - - m_SelectedPlanarFigures = mitk::DataStorageSelection::New(this->GetDefaultDataStorage(), false); - - m_SelectedPlanarFigures->NodeChanged.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); - - m_SelectedPlanarFigures->NodeRemoved.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); - - m_SelectedPlanarFigures->PropertyChanged.AddListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); - - m_SelectedImageNode = mitk::DataStorageSelection::New(this->GetDefaultDataStorage(), false); - - m_SelectedImageNode->PropertyChanged.AddListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); - - m_SelectedImageNode->NodeChanged.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); - - m_SelectedImageNode->NodeRemoved.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); - - this->GetDefaultDataStorage()->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeAddedInDataStorage ) ); - -} - -void QmitkMeasurementView::OnSelectionChanged(std::vector nodes) -{ - if ( nodes.empty() ) return; - - m_SelectedImageNode->RemoveAllNodes(); - - mitk::DataNode* _DataNode = 0; - mitk::BaseData* _BaseData; - mitk::PlanarFigure* _PlanarFigure; - mitk::Image* selectedImage; - m_SelectedPlanarFigures->RemoveAllNodes(); - - for (std::vector::iterator it = nodes.begin(); - it != nodes.end(); - ++it) - { - _PlanarFigure = 0; - - _DataNode = *it; - - if (!_DataNode) - continue; - - _BaseData = _DataNode->GetData(); - - if (!_BaseData) - continue; - - // planar figure selected - if ((_PlanarFigure = dynamic_cast (_BaseData))) - { - // add to the selected planar figures - m_SelectedPlanarFigures->AddNode(_DataNode); - // take parent image as the selected image - mitk::DataStorage::SetOfObjects::ConstPointer parents = - this->GetDefaultDataStorage()->GetSources(_DataNode); - if (parents->size() > 0) - { - mitk::DataNode::Pointer parent = parents->front(); - if ((selectedImage = dynamic_cast (parent->GetData()))) - { - *m_SelectedImageNode = parent; - } - } - - } - else if ((selectedImage = dynamic_cast (_BaseData))) - { - *m_SelectedImageNode = _DataNode; - /*mitk::RenderingManager::GetInstance()->InitializeViews( - selectedImage->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true );*/ - } - } // end for - - this->PlanarFigureSelectionChanged(); -} - -void QmitkMeasurementView::PlanarFigureSelectionChanged() -{ - if ( !this->IsActivated() ) return; - - if (m_SelectedImageNode->GetNode().IsNotNull()) - { - mitk::Image* selectedImage = dynamic_cast(m_SelectedImageNode->GetNode()->GetData()); - if(selectedImage && selectedImage->GetDimension() > 3) - { - m_SelectedImageNode->RemoveAllNodes(); - m_SelectedImage->setText( "4D images are not supported." ); - m_DrawActionsToolBar->setEnabled(false); - } - else - { - m_SelectedImage->setText(QString::fromStdString( - m_SelectedImageNode->GetNode()->GetName())); - m_DrawActionsToolBar->setEnabled(true); - } - } - else - { - m_SelectedImage->setText( - "None. Please select an image."); - - m_DrawActionsToolBar->setEnabled(false); - } - - if (m_SelectedPlanarFigures->GetSize() == 0){ - this->SetMeasurementInfoToRenderWindow("", this->GetActiveStdMultiWidget()->GetRenderWindow1()); - this->SetMeasurementInfoToRenderWindow("", this->GetActiveStdMultiWidget()->GetRenderWindow2()); - this->SetMeasurementInfoToRenderWindow("", this->GetActiveStdMultiWidget()->GetRenderWindow3()); - this->SetMeasurementInfoToRenderWindow("", this->GetActiveStdMultiWidget()->GetRenderWindow4()); - } - - unsigned int j = 1; - mitk::PlanarFigure* _PlanarFigure = 0; - mitk::PlanarAngle* planarAngle = 0; - mitk::PlanarFourPointAngle* planarFourPointAngle = 0; - mitk::DataNode::Pointer node = 0; - m_SelectedPlanarFiguresText->clear(); - QString infoText; - QString plainInfoText; - std::vector nodes = m_SelectedPlanarFigures->GetNodes(); - - for (std::vector::iterator it = nodes.begin(); it - != nodes.end(); ++it, ++j) - { - plainInfoText.clear(); - node = *it; - if(j>1) - infoText.append("
"); - - infoText.append(QString("%1
").arg(QString::fromStdString( - node->GetName()))); - plainInfoText.append(QString("%1").arg(QString::fromStdString( - node->GetName()))); - - _PlanarFigure = dynamic_cast (node->GetData()); - - planarAngle = dynamic_cast (_PlanarFigure); - if(!planarAngle) - { - planarFourPointAngle = dynamic_cast (_PlanarFigure); - } - - if(!_PlanarFigure) - continue; - - double featureQuantity = 0.0; - for (unsigned int i = 0; i < _PlanarFigure->GetNumberOfFeatures(); ++i) - { - if ( !_PlanarFigure->IsFeatureActive( i ) ) continue; - - featureQuantity = _PlanarFigure->GetQuantity(i); - if ((planarAngle && i == planarAngle->FEATURE_ID_ANGLE) - || (planarFourPointAngle && i == planarFourPointAngle->FEATURE_ID_ANGLE)) - featureQuantity = featureQuantity * 180 / vnl_math::pi; - - infoText.append( - QString("%1: %2 %3") .arg(QString( - _PlanarFigure->GetFeatureName(i))) .arg(featureQuantity, 0, 'f', - 2) .arg(QString(_PlanarFigure->GetFeatureUnit(i)))); - - plainInfoText.append( - QString("\n%1: %2 %3") .arg(QString(_PlanarFigure->GetFeatureName(i))) .arg( - featureQuantity, 0, 'f', 2) .arg(QString( - _PlanarFigure->GetFeatureUnit(i)))); - - if(i+1 != _PlanarFigure->GetNumberOfFeatures()) - infoText.append("
"); - } - - if (j != nodes.size()) - infoText.append("
"); - } - - m_SelectedPlanarFiguresText->setHtml(infoText); - - // for the last selected planar figure ... - if (_PlanarFigure) - { - const mitk::PlaneGeometry - * _PlaneGeometry = - dynamic_cast (_PlanarFigure->GetGeometry2D()); - - QmitkRenderWindow* selectedRenderWindow = 0; - QmitkRenderWindow* RenderWindow1 = - this->GetActiveStdMultiWidget()->GetRenderWindow1(); - QmitkRenderWindow* RenderWindow2 = - this->GetActiveStdMultiWidget()->GetRenderWindow2(); - QmitkRenderWindow* RenderWindow3 = - this->GetActiveStdMultiWidget()->GetRenderWindow3(); - QmitkRenderWindow* RenderWindow4 = - this->GetActiveStdMultiWidget()->GetRenderWindow4(); - bool PlanarFigureInitializedWindow = false; - - // find initialized renderwindow - if (node->GetBoolProperty("PlanarFigureInitializedWindow", - PlanarFigureInitializedWindow, RenderWindow1->GetRenderer())) - selectedRenderWindow = RenderWindow1; - if (!selectedRenderWindow && node->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow2->GetRenderer())) - selectedRenderWindow = RenderWindow2; - if (!selectedRenderWindow && node->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow3->GetRenderer())) - selectedRenderWindow = RenderWindow3; - if (!selectedRenderWindow && node->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow4->GetRenderer())) - selectedRenderWindow = RenderWindow4; - - // make node visible - if (selectedRenderWindow) - { - mitk::Point3D centerP = _PlaneGeometry->GetOrigin(); - //selectedRenderWindow->GetSliceNavigationController()->ReorientSlices( - //centerP, _PlaneGeometry->GetNormal()); - selectedRenderWindow->GetSliceNavigationController()->SelectSliceByPoint( - centerP); - - // now paint infos also on renderwindow - this->SetMeasurementInfoToRenderWindow(plainInfoText, selectedRenderWindow); - } - } - // no last planarfigure - else - this->SetMeasurementInfoToRenderWindow("", 0); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkMeasurementView::NodeAddedInDataStorage(const mitk::DataNode* node) -{ - if(!m_Visible) - return; - mitk::DataNode* nonConstNode = const_cast(node); - mitk::PlanarFigure* figure = dynamic_cast(nonConstNode->GetData()); - if(figure) - { - mitk::PlanarFigureInteractor::Pointer figureInteractor - = dynamic_cast(node->GetInteractor()); - - if(figureInteractor.IsNull()) - figureInteractor = mitk::PlanarFigureInteractor::New("PlanarFigureInteractor", nonConstNode); - - // remove old interactor if present - if( m_CurrentFigureNode.IsNotNull() && m_CurrentFigureNodeInitialized == false ) - { - mitk::Interactor::Pointer oldInteractor = m_CurrentFigureNode->GetInteractor(); - if(oldInteractor.IsNotNull()) - mitk::GlobalInteraction::GetInstance()->RemoveInteractor(oldInteractor); - - this->GetDefaultDataStorage()->Remove(m_CurrentFigureNode); - } - - mitk::GlobalInteraction::GetInstance()->AddInteractor(figureInteractor); - } -} - - -void QmitkMeasurementView::PlanarFigureInitialized() -{ - if(m_CurrentFigureNode.IsNull()) - return; - - m_CurrentFigureNodeInitialized = true; - - this->PlanarFigureSelectionChanged(); - - m_DrawLine->setChecked(false); - m_DrawPath->setChecked(false); - m_DrawAngle->setChecked(false); - m_DrawFourPointAngle->setChecked(false); - m_DrawEllipse->setChecked(false); - m_DrawRectangle->setChecked(false); - m_DrawPolygon->setChecked(false); - // enable the crosshair navigation - this->EnableCrosshairNavigation(); -} - - -void QmitkMeasurementView::PlanarFigureSelected( itk::Object* object, const itk::EventObject& event ) -{ - // Mark to-be-edited PlanarFigure as selected - mitk::PlanarFigure* figure = dynamic_cast< mitk::PlanarFigure* >( object ); - if ( figure != NULL ) - { - // Get node corresponding to PlanarFigure - mitk::DataNode::Pointer figureNode = this->GetDefaultDataStorage()->GetNode( - mitk::NodePredicateData::New( figure ) ); - - // Select this node (and deselect all others) - std::vector< mitk::DataNode* > selectedNodes = this->GetDataManagerSelection(); - for ( unsigned int i = 0; i < selectedNodes.size(); i++ ) - { - selectedNodes[i]->SetSelected( false ); - } - selectedNodes = m_SelectedPlanarFigures->GetNodes(); - for ( unsigned int i = 0; i < selectedNodes.size(); i++ ) - { - selectedNodes[i]->SetSelected( false ); - } - figureNode->SetSelected( true ); - - m_CurrentFigureNode = figureNode; - - *m_SelectedPlanarFigures = figureNode; - - // Re-initialize after selecting new PlanarFigure - this->PlanarFigureSelectionChanged(); - } -} - - -mitk::DataNode::Pointer QmitkMeasurementView::DetectTopMostVisibleImage() -{ - // get all images from the data storage - mitk::DataStorage::SetOfObjects::ConstPointer Images = this->GetDefaultDataStorage()->GetSubset( mitk::NodePredicateDataType::New("Image") ); - - mitk::DataNode::Pointer currentNode( m_SelectedImageNode->GetNode() ); - int maxLayer = itk::NumericTraits::min(); - - // iterate over selection - for (mitk::DataStorage::SetOfObjects::ConstIterator sofIt = Images->Begin(); sofIt != Images->End(); ++sofIt) - { - mitk::DataNode::Pointer node = sofIt->Value(); - if ( node.IsNull() ) - continue; - if (node->IsVisible(NULL) == false) - continue; - int layer = 0; - node->GetIntProperty("layer", layer); - if ( layer < maxLayer ) - continue; - - currentNode = node; - } - - return currentNode; -} - -void QmitkMeasurementView::AddFigureToDataStorage(mitk::PlanarFigure* figure, const QString& name, - const char *propertyKey, mitk::BaseProperty *property ) -{ - if ( m_CurrentFigureNode.IsNotNull() ) - { - m_CurrentFigureNode->GetData()->RemoveObserver( m_EndPlacementObserverTag ); - } - - mitk::DataNode::Pointer newNode = mitk::DataNode::New(); - newNode->SetName(name.toStdString()); - newNode->SetData(figure); - - // Add custom property, if available - if ( (propertyKey != NULL) && (property != NULL) ) - { - newNode->AddProperty( propertyKey, property ); - } - - // add observer for event when figure has been placed - typedef itk::SimpleMemberCommand< QmitkMeasurementView > SimpleCommandType; - SimpleCommandType::Pointer initializationCommand = SimpleCommandType::New(); - initializationCommand->SetCallbackFunction( this, &QmitkMeasurementView::PlanarFigureInitialized ); - m_EndPlacementObserverTag = figure->AddObserver( mitk::EndPlacementPlanarFigureEvent(), initializationCommand ); - - // add observer for event when figure is picked (selected) - typedef itk::MemberCommand< QmitkMeasurementView > MemberCommandType; - MemberCommandType::Pointer selectCommand = MemberCommandType::New(); - selectCommand->SetCallbackFunction( this, &QmitkMeasurementView::PlanarFigureSelected ); - m_SelectObserverTag = figure->AddObserver( mitk::SelectPlanarFigureEvent(), selectCommand ); - - // add observer for event when interaction with figure starts - SimpleCommandType::Pointer startInteractionCommand = SimpleCommandType::New(); - startInteractionCommand->SetCallbackFunction( this, &QmitkMeasurementView::DisableCrosshairNavigation); - m_StartInteractionObserverTag = figure->AddObserver( mitk::StartInteractionPlanarFigureEvent(), startInteractionCommand ); - - // add observer for event when interaction with figure starts - SimpleCommandType::Pointer endInteractionCommand = SimpleCommandType::New(); - endInteractionCommand->SetCallbackFunction( this, &QmitkMeasurementView::EnableCrosshairNavigation); - m_EndInteractionObserverTag = figure->AddObserver( mitk::EndInteractionPlanarFigureEvent(), endInteractionCommand ); - - - // figure drawn on the topmost layer / image - this->GetDataStorage()->Add(newNode, this->DetectTopMostVisibleImage() ); - std::vector selectedNodes = GetDataManagerSelection(); - for(unsigned int i = 0; i < selectedNodes.size(); i++) - { - selectedNodes[i]->SetSelected(false); - } - selectedNodes = m_SelectedPlanarFigures->GetNodes(); - for(unsigned int i = 0; i < selectedNodes.size(); i++) - { - selectedNodes[i]->SetSelected(false); - } - newNode->SetSelected(true); - - - m_CurrentFigureNodeInitialized = false; - m_CurrentFigureNode = newNode; - - *m_SelectedPlanarFigures = newNode; - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -bool QmitkMeasurementView::AssertDrawingIsPossible(bool checked) -{ - if (m_SelectedImageNode->GetNode().IsNull()) - { - checked = false; - this->HandleException("Please select an image!", this->m_Parent, true); - m_DrawLine->setChecked(false); - return false; - } - - this->GetActiveStdMultiWidget()->SetWidgetPlanesVisibility(false); - // disable the crosshair navigation during the drawing - this->DisableCrosshairNavigation(); - - //this->GetActiveStdMultiWidget()->GetRenderWindow1()->FullScreenMode(true); - - return checked; -} - -void QmitkMeasurementView::ActionDrawLineTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - mitk::PlanarLine::Pointer figure = mitk::PlanarLine::New(); - QString qString; - if(m_CurrentFigureNode.IsNull() || m_LineCounter == 0 || m_CurrentFigureNodeInitialized){ - qString = QString("Line%1").arg(++m_LineCounter); - } - else{ - qString = QString("Line%1").arg(m_LineCounter); - } - this->AddFigureToDataStorage(figure, qString); - - MITK_INFO << "PlanarLine initialized..."; -} - -void QmitkMeasurementView::ActionDrawPathTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - mitk::PlanarPolygon::Pointer figure = mitk::PlanarPolygon::New(); - figure->ClosedOff(); - - mitk::BoolProperty::Pointer closedProperty = mitk::BoolProperty::New( false ); - - QString qString; - if(m_CurrentFigureNode.IsNull() || m_PathCounter == 0 || m_CurrentFigureNodeInitialized){ - qString = QString("Path%1").arg(++m_PathCounter); - } - else{ - qString = QString("Path%1").arg(m_PathCounter); - } - this->AddFigureToDataStorage(figure, qString, - "ClosedPlanarPolygon", closedProperty); - - MITK_INFO << "PlanarPath initialized..."; -} - -void QmitkMeasurementView::ActionDrawAngleTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - mitk::PlanarAngle::Pointer figure = mitk::PlanarAngle::New(); - QString qString; - if(m_CurrentFigureNode.IsNull() || m_AngleCounter == 0 || m_CurrentFigureNodeInitialized){ - qString = QString("Angle%1").arg(++m_AngleCounter); - } - else{ - qString = QString("Angle%1").arg(m_AngleCounter); - } - this->AddFigureToDataStorage(figure, qString); - - MITK_INFO << "PlanarAngle initialized..."; -} - -void QmitkMeasurementView::ActionDrawFourPointAngleTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - mitk::PlanarFourPointAngle::Pointer figure = - mitk::PlanarFourPointAngle::New(); - QString qString; - if(m_CurrentFigureNode.IsNull() || m_FourPointAngleCounter == 0 || m_CurrentFigureNodeInitialized){ - qString = QString("Four Point Angle%1").arg(++m_FourPointAngleCounter); - } - else{ - qString = QString("Four Point Angle%1").arg(m_FourPointAngleCounter); - } - this->AddFigureToDataStorage(figure, qString); - - MITK_INFO << "PlanarFourPointAngle initialized..."; -} - -void QmitkMeasurementView::ActionDrawEllipseTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - mitk::PlanarCircle::Pointer figure = mitk::PlanarCircle::New(); - QString qString; - if(m_CurrentFigureNode.IsNull() || m_EllipseCounter == 0 || m_CurrentFigureNodeInitialized){ - qString = QString("Circle%1").arg(++m_EllipseCounter); - } - else{ - qString = QString("Circle%1").arg(m_EllipseCounter); - } - this->AddFigureToDataStorage(figure, qString); - - MITK_INFO << "PlanarCircle initialized..."; -} - -void QmitkMeasurementView::ActionDrawRectangleTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - mitk::PlanarRectangle::Pointer figure = mitk::PlanarRectangle::New(); - QString qString; - if(m_CurrentFigureNode.IsNull() || m_RectangleCounter == 0 || m_CurrentFigureNodeInitialized){ - qString = QString("Rectangle%1").arg(++m_RectangleCounter); - } - else{ - qString = QString("Rectangle%1").arg(m_RectangleCounter); - } - this->AddFigureToDataStorage(figure, qString); - - MITK_INFO << "PlanarRectangle initialized..."; -} - -void QmitkMeasurementView::ActionDrawPolygonTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - mitk::PlanarPolygon::Pointer figure = mitk::PlanarPolygon::New(); - figure->ClosedOn(); - QString qString; - if(m_CurrentFigureNode.IsNull() || m_PolygonCounter == 0 || m_CurrentFigureNodeInitialized){ - qString = QString("Polygon%1").arg(++m_PolygonCounter); - } - else{ - qString = QString("Polygon%1").arg(m_PolygonCounter); - } - this->AddFigureToDataStorage(figure, qString); - - MITK_INFO << "PlanarPolygon initialized..."; -} - -void QmitkMeasurementView::ActionDrawArrowTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - MITK_WARN << "Draw Arrow not implemented yet."; -} - -void QmitkMeasurementView::ActionDrawTextTriggered(bool checked) -{ - if(!this->AssertDrawingIsPossible(checked)) - return; - - MITK_WARN << "Draw Text not implemented yet."; -} - -void QmitkMeasurementView::Activated() -{ - this->GetActiveStdMultiWidget()->SetWidgetPlanesVisibility(false); - //this->GetActiveStdMultiWidget()->GetRenderWindow1()->FullScreenMode(true); - - mitk::TNodePredicateDataType::Pointer isPlanarFigure - = mitk::TNodePredicateDataType::New(); - - mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = this->GetDefaultDataStorage()->GetAll(); - mitk::DataNode* node = 0; - mitk::PlanarFigure* figure = 0; - mitk::PlanarFigureInteractor::Pointer figureInteractor = 0; - // finally add all nodes to the model - for(mitk::DataStorage::SetOfObjects::ConstIterator it=_NodeSet->Begin(); it!=_NodeSet->End() - ; it++) - { - node = const_cast(it->Value().GetPointer()); - figure = dynamic_cast(node->GetData()); - if(figure) - { - figureInteractor = dynamic_cast(node->GetInteractor()); - - if(figureInteractor.IsNull()) - figureInteractor = mitk::PlanarFigureInteractor::New("PlanarFigureInteractor", node); - - mitk::GlobalInteraction::GetInstance()->AddInteractor(figureInteractor); - } - } - - m_Visible = true; - -} - -void QmitkMeasurementView::Deactivated() -{ - this->GetActiveStdMultiWidget()->SetWidgetPlanesVisibility(true); - //this->GetActiveStdMultiWidget()->GetRenderWindow1()->FullScreenMode(false); - this->SetMeasurementInfoToRenderWindow("", m_LastRenderWindow); - this->EnableCrosshairNavigation(); - - mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = this->GetDefaultDataStorage()->GetAll(); - mitk::DataNode* node = 0; - mitk::PlanarFigure* figure = 0; - mitk::PlanarFigureInteractor::Pointer figureInteractor = 0; - // finally add all nodes to the model - for(mitk::DataStorage::SetOfObjects::ConstIterator it=_NodeSet->Begin(); it!=_NodeSet->End() - ; it++) - { - node = const_cast(it->Value().GetPointer()); - figure = dynamic_cast(node->GetData()); - if(figure) - { - - figure->RemoveAllObservers(); - figureInteractor = dynamic_cast(node->GetInteractor()); - - if(figureInteractor) - mitk::GlobalInteraction::GetInstance()->RemoveInteractor(figureInteractor); - } - } - - m_Visible = false; -} - - -void QmitkMeasurementView::PropertyChanged(const mitk::DataNode* /*node*/, const mitk::BaseProperty* /*prop*/) -{ - this->PlanarFigureSelectionChanged(); -} - -void QmitkMeasurementView::NodeChanged(const mitk::DataNode* /*node*/) -{ - this->PlanarFigureSelectionChanged(); -} - -void QmitkMeasurementView::NodeRemoved(const mitk::DataNode* /*node*/) -{ - this->PlanarFigureSelectionChanged(); -} - -void QmitkMeasurementView::CopyToClipboard(bool) -{ - std::vector headerRow; - std::vector > rows; - QString featureName; - QString featureQuantity; - std::vector newRow; - headerRow.push_back("Name"); - - std::vector nodes = m_SelectedPlanarFigures->GetNodes(); - - for (std::vector::iterator it = nodes.begin(); it - != nodes.end(); ++it) - { - mitk::PlanarFigure* planarFigure = - dynamic_cast ((*it)->GetData()); - if (!planarFigure) - continue; - - newRow.clear(); - newRow.push_back(QString::fromStdString((*it)->GetName())); - newRow.resize(headerRow.size()); - for (unsigned int i = 0; i < planarFigure->GetNumberOfFeatures(); ++i) - { - if ( !planarFigure->IsFeatureActive( i ) ) continue; - - featureName = planarFigure->GetFeatureName(i); - featureName.append(QString(" [%1]").arg(planarFigure->GetFeatureUnit(i))); - std::vector::iterator itColumn = std::find(headerRow.begin(), - headerRow.end(), featureName); - - featureQuantity - = QString("%1").arg(planarFigure->GetQuantity(i)).replace(QChar('.'), - ","); - if (itColumn == headerRow.end()) - { - headerRow.push_back(featureName); - newRow.push_back(featureQuantity); - } else - { - newRow[std::distance(headerRow.begin(), itColumn)] = featureQuantity; - } - - } - rows.push_back(newRow); - } - - QString clipboardText; - for (std::vector::iterator it = headerRow.begin(); it - != headerRow.end(); ++it) - clipboardText.append(QString("%1 \t").arg(*it)); - - for (std::vector >::iterator it = rows.begin(); it - != rows.end(); ++it) - { - clipboardText.append("\n"); - for (std::vector::iterator it2 = (*it).begin(); it2 != (*it).end(); ++it2) - { - clipboardText.append(QString("%1 \t").arg(*it2)); - } - } - - QApplication::clipboard()->setText(clipboardText, QClipboard::Clipboard); - -} - -void QmitkMeasurementView::SetMeasurementInfoToRenderWindow(const QString& text, - QmitkRenderWindow* _RenderWindow) -{ - if(m_LastRenderWindow != _RenderWindow) - { - - if(m_LastRenderWindow) - { - QObject::disconnect( m_LastRenderWindow, SIGNAL( destroyed(QObject*) ) - , this, SLOT( OnRenderWindowDelete(QObject*) ) ); - } - m_LastRenderWindow = _RenderWindow; - if(m_LastRenderWindow) - { - QObject::connect( m_LastRenderWindow, SIGNAL( destroyed(QObject*) ) - , this, SLOT( OnRenderWindowDelete(QObject*) ) ); - } - } - - if(m_LastRenderWindow) - { - if (!text.isEmpty() && m_SelectedPlanarFigures->GetNode()->IsSelected()) - { - m_MeasurementInfoAnnotation->SetText(1, text.toLatin1().data()); - mitk::VtkLayerController::GetInstance(m_LastRenderWindow->GetRenderWindow())->InsertForegroundRenderer( - m_MeasurementInfoRenderer, true); - } - else - { - if (mitk::VtkLayerController::GetInstance( - m_LastRenderWindow->GetRenderWindow()) ->IsRendererInserted( - m_MeasurementInfoRenderer)) - mitk::VtkLayerController::GetInstance(m_LastRenderWindow->GetRenderWindow())->RemoveRenderer( - m_MeasurementInfoRenderer); - } - } -} - -void QmitkMeasurementView::EnableCrosshairNavigation() -{ - // enable the crosshair navigation - this->GetActiveStdMultiWidget()->EnableNavigationControllerEventListening(); -} - -void QmitkMeasurementView::DisableCrosshairNavigation() -{ - // disable the crosshair navigation during the drawing - this->GetActiveStdMultiWidget()->DisableNavigationControllerEventListening(); -} - - - -void QmitkMeasurementView::OnRenderWindowDelete(QObject * obj) -{ - if(obj == m_LastRenderWindow) - m_LastRenderWindow = 0; -} - -void QmitkMeasurementView::ReproducePotentialBug(bool) -{ - std::vector nodes = m_SelectedPlanarFigures->GetNodes(); - QString output; - - for (std::vector::iterator it = nodes.begin(); it - != nodes.end(); ++it) - { - mitk::DataNode* node = *it; - if (!node) continue; - - mitk::PlanarFigure* pf = dynamic_cast( node->GetData() ); - if (!pf) continue; - - output.append("huhu"); - output.append( QString::fromStdString( node->GetName() ) ); - - /** - Bug reproduction: - - 1. get geometry of planar figure from object - - 2. use this geometry to initialize rendering manager via InitializeViews - - 3. see what is produced. the DisplayGeometry of the render window will NOT contain the planar figure nicely. - - */ - - mitk::PlaneGeometry::Pointer planarFigureGeometry = dynamic_cast( pf->GetGeometry() ); - if (planarFigureGeometry.IsNull()) continue; // not expected - - - mitk::PlaneGeometry::Pointer geometryForRendering = dynamic_cast( planarFigureGeometry->Clone().GetPointer() ); - - bool applyWorkaround(true); - geometryForRendering->SetImageGeometry( applyWorkaround ); - - - std::cout << "==== with" << (applyWorkaround?"":"OUT") << " workaround ====================================" << std::endl; - std::cout << "--- PlanarFigure geometry --------------" << std::endl; - planarFigureGeometry->Print(std::cout); - std::cout << "----------------------------------------" << std::endl; - - mitk::RenderingManager::GetInstance()->InitializeViews( geometryForRendering, mitk::RenderingManager::REQUEST_UPDATE_ALL, false ); - - std::cout << "--- Renderer->GetDisplayGeometry() ------------" << std::endl; - this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer()->GetDisplayGeometry()->Print(std::cout); - std::cout << "--- Renderer->GetCurrentWorldGeometry2D() -----" << std::endl; - this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer()->GetCurrentWorldGeometry2D()->Print(std::cout); - std::cout << "--- Renderer->GetWorldGeometry() --------------" << std::endl; - this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer()->GetWorldGeometry()->Print(std::cout); - } - - m_SelectedPlanarFiguresText->setText(output); - - - -} - diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.h b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.h deleted file mode 100644 index 1b5bc495fa..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.h +++ /dev/null @@ -1,217 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 15412 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QMITK_MEASUREMENT_H__INCLUDED -#define QMITK_MEASUREMENT_H__INCLUDED - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -class QmitkPlanarFiguresTableModel; -class QGridLayout; -class QMainWindow; -class QToolBar; -class QLabel; -class QTableView; -class QTextBrowser; - -class vtkRenderer; -class vtkCornerAnnotation; - - -/// -/// A view for doing measurements in digital images by means of -/// mitk::Planarfigures which can represent drawing primitives (Lines, circles, ...). -/// The view consists of only three main elements: -/// 1. A toolbar for activating PlanarFigure drawing -/// 2. A textbrowser which shows details for the selected PlanarFigures -/// 3. A button for copying all details to the clipboard -/// -class QmitkMeasurementView : public QmitkFunctionality -{ - Q_OBJECT - - public: - /// - /// Just a shortcut - /// - typedef std::vector DataNodes; - - /// - /// Initialize pointers to 0. The rest is done in CreateQtPartControl() - /// - QmitkMeasurementView(); - - QmitkMeasurementView(const QmitkMeasurementView& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - - /// - /// Remove all event listener from DataStorage, DataStorageSelection, Selection Service - /// - virtual ~QmitkMeasurementView(); - - static const std::string VIEW_ID; - - public: - /// - /// Initializes all variables. - /// Builds up GUI. - /// - void CreateQtPartControl(QWidget* parent); - /// - /// Set widget planes visibility to false. - /// Show only transversal view. - /// Add an interactor to all PlanarFigures in the DataStorage (if they dont have one yet). - /// Add their interactor to the global interaction. - /// - virtual void Activated(); - /// - /// Show widget planes and all renderwindows again. - /// Remove all planar figure interactors from the global interaction. - /// - virtual void Deactivated(); - /// - /// Invoked from a DataStorage selection - /// - virtual void NodeChanged(const mitk::DataNode* node); - virtual void PropertyChanged(const mitk::DataNode* node, const mitk::BaseProperty* prop); - virtual void NodeRemoved(const mitk::DataNode* node); - virtual void NodeAddedInDataStorage(const mitk::DataNode* node); - virtual void PlanarFigureInitialized(); - virtual void PlanarFigureSelected( itk::Object* object, const itk::EventObject& event ); - virtual void AddFigureToDataStorage(mitk::PlanarFigure* figure, const QString& name, - const char *propertyKey = NULL, mitk::BaseProperty *property = NULL ); - - /// - /// Invoked when the DataManager selection changed. - /// If an image is in the selection it will be set as the selected one for measurement, - /// If a planarfigure is in the selection its parent image will be set as the selected one for measurement. - /// All selected planarfigures will be added to m_SelectedPlanarFigures. - /// Then PlanarFigureSelectionChanged is called - /// - virtual void OnSelectionChanged(std::vector nodes); - - public slots: - /// - /// Called when the renderwindow gets deleted - /// - void OnRenderWindowDelete(QObject * obj = 0); - - protected: - /// - /// Prints all features of the selected PlanarFigures into the TextBrowser. - /// For the last figure in the selection list: - /// - Go to the corresponding slice and show figure - /// - Draw info text on the bottom right side of the corresponding renderwindow - /// - void PlanarFigureSelectionChanged(); - /// Draws a string on the bottom left side of the render window - /// - void SetMeasurementInfoToRenderWindow(const QString& text, QmitkRenderWindow* _RenderWindow); - - bool AssertDrawingIsPossible(bool checked); - - void EnableCrosshairNavigation(); - void DisableCrosshairNavigation(); - - protected slots: - ///# draw actions - void ActionDrawLineTriggered( bool checked = false ); - void ActionDrawPathTriggered( bool checked = false ); - void ActionDrawAngleTriggered( bool checked = false ); - void ActionDrawFourPointAngleTriggered( bool checked = false ); - void ActionDrawEllipseTriggered( bool checked = false ); - void ActionDrawRectangleTriggered( bool checked = false ); - void ActionDrawPolygonTriggered( bool checked = false ); - void ActionDrawArrowTriggered( bool checked = false ); - void ActionDrawTextTriggered( bool checked = false ); - void CopyToClipboard( bool checked = false ); - - void ReproducePotentialBug(bool); - // fields - // widgets -protected: - QGridLayout* m_Layout; - QLabel* m_SelectedImage; - QAction* m_DrawLine; - QAction* m_DrawPath; - QAction* m_DrawAngle; - QAction* m_DrawFourPointAngle; - QAction* m_DrawEllipse; - QAction* m_DrawRectangle; - QAction* m_DrawPolygon; - QToolBar* m_DrawActionsToolBar; - QActionGroup* m_DrawActionsGroup; - QTextBrowser* m_SelectedPlanarFiguresText; - QPushButton* m_CopyToClipboard; - vtkRenderer * m_MeasurementInfoRenderer; - vtkCornerAnnotation *m_MeasurementInfoAnnotation; - - // Selection service - /// berry::SelectionChangedAdapter must be a friend to call - friend struct berry::SelectionChangedAdapter; - berry::ISelectionListener::Pointer m_SelectionListener; - - mitk::DataStorageSelection::Pointer m_SelectedPlanarFigures; - /// Selected image on which measurements will be performed - /// - mitk::DataStorageSelection::Pointer m_SelectedImageNode; - mitk::DataNode::Pointer m_CurrentFigureNode; - - /// Counter variables to give a newly created Figure a unique name. - /// - unsigned int m_LineCounter; - unsigned int m_PathCounter; - unsigned int m_AngleCounter; - unsigned int m_FourPointAngleCounter; - unsigned int m_EllipseCounter; - unsigned int m_RectangleCounter; - unsigned int m_PolygonCounter; - unsigned int m_EndPlacementObserverTag; - unsigned int m_SelectObserverTag; - unsigned int m_StartInteractionObserverTag; - unsigned int m_EndInteractionObserverTag; - bool m_Visible; - bool m_CurrentFigureNodeInitialized; - - /// - /// Saves the last renderwindow any info data was inserted - /// - QmitkRenderWindow* m_LastRenderWindow; - - private: - mitk::DataNode::Pointer DetectTopMostVisibleImage(); - -}; - -#endif // QMITK_MEASUREMENT_H__INCLUDED diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkMeasurementSelectionProvider.cpp b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkMeasurementSelectionProvider.cpp deleted file mode 100644 index e797da5883..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkMeasurementSelectionProvider.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date: 2009-11-02 20:38:30 +0100 (Mo, 02 Nov 2009) $ - Version: $Revision: 19650 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#include "mitkMeasurementSelectionProvider.h" -#include -#include "berrySelectionChangedEvent.h" - -namespace mitk -{ - - - -MeasurementSelectionProvider::MeasurementSelectionProvider() -: m_CurrentSelection(new DataNodeSelection) -{ -} - - -void MeasurementSelectionProvider::AddSelectionChangedListener(berry::ISelectionChangedListener::Pointer listener) -{ - m_RegisteredListeners.AddListener(listener); -} - -void MeasurementSelectionProvider::RemoveSelectionChangedListener(berry::ISelectionChangedListener::Pointer listener) -{ - m_RegisteredListeners.RemoveListener(listener); - -} - -berry::ISelection::ConstPointer MeasurementSelectionProvider::GetSelection() const -{ - return m_CurrentSelection; -} - - -void MeasurementSelectionProvider::SetSelection(berry::ISelection::Pointer selection) -{ -} - -void MeasurementSelectionProvider::FireSelectionChanged(DataNodeSelection::Pointer selection) -{ - if(selection.IsNotNull()) - { - m_CurrentSelection = selection; - berry::SelectionChangedEvent::Pointer event( - new berry::SelectionChangedEvent(berry::ISelectionProvider::Pointer(this), m_CurrentSelection)); - m_RegisteredListeners.selectionChanged(event); - } -} - -void MeasurementSelectionProvider::FireSelectionChanged(DataNode::Pointer selectedNode) -{ - this->FireSelectionChanged(DataNodeSelection::Pointer(new DataNodeSelection(selectedNode))); -} - -} diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkMeasurementSelectionProvider.h b/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkMeasurementSelectionProvider.h deleted file mode 100644 index d3a6d0b2dc..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkMeasurementSelectionProvider.h +++ /dev/null @@ -1,68 +0,0 @@ -/*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date: 2009-05-26 13:47:06 +0200 (Di, 26 Mai 2009) $ - Version: $Revision: 17408 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - -#ifndef MITKMeasurementSelectionProvider_H_ -#define MITKMeasurementSelectionProvider_H_ - -//#include "berryUiQtDll.h" - -#include -#include -#include -#include -#include - -/* -#include -#include -#include -*/ -namespace mitk -{ - -class MeasurementSelectionProvider: public berry::ISelectionProvider -{ - - -public: - - berryObjectMacro(MeasurementSelectionProvider) - - MeasurementSelectionProvider(); - - void AddSelectionChangedListener(berry::ISelectionChangedListener::Pointer listener); - - void RemoveSelectionChangedListener(berry::ISelectionChangedListener::Pointer listener); - - berry::ISelection::ConstPointer GetSelection() const; - - void SetSelection(berry::ISelection::Pointer selection); - - void FireSelectionChanged(DataNodeSelection::Pointer selection); - - void FireSelectionChanged(DataNode::Pointer selectedNode); - - protected: - DataNodeSelection::Pointer m_CurrentSelection; - berry::ISelectionChangedListener::Events m_RegisteredListeners; - - -}; - -} - -#endif /* MITKMeasurementSelectionProvider_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/doxygen/modules.dox deleted file mode 100644 index 81df81ea1f..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_moviemaker org.mitk.gui.qt.moviemaker Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_moviemaker_internal Internal - \ingroup org_mitk_gui_qt_moviemaker - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.moviemaker plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.moviemaker/manifest_headers.cmake deleted file mode 100644 index 84719cea59..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.moviemaker/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Movie Maker") -set(Plugin-Version "0.9") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/doxygen/modules.dox deleted file mode 100644 index 7358b0e64a..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_pointsetinteraction org.mitk.gui.qt.pointsetinteraction Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_pointsetinteraction_internal Internal - \ingroup org_mitk_gui_qt_pointsetinteraction - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.pointsetinteraction plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/manifest_headers.cmake deleted file mode 100644 index 12c8ebbc7c..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Pointset Interaction") -set(Plugin-Version "0.9") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.python.console/documentation/doxygen/modules.dox deleted file mode 100644 index ab53095bfe..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.python.console/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_python_console org.mitk.gui.qt.python.console Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_python_console_internal Internal - \ingroup org_mitk_gui_qt_python_console - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.python.console plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.python.console/manifest_headers.cmake deleted file mode 100644 index 00f0378505..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.python.console/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Python Console") -set(Plugin-Version "0.9") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.registration/manifest_headers.cmake deleted file mode 100644 index a0604a2789..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.registration/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Registration") -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) diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.segmentation/manifest_headers.cmake deleted file mode 100644 index f7cd162d1a..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Segmentation") -set(Plugin-Version "1.0.0") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common org.mitk.gui.qt.datamanager) diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h deleted file mode 100644 index 8f22722e01..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h +++ /dev/null @@ -1,89 +0,0 @@ -/*========================================================================= - - Program: Medical Imaging & Interaction Toolkit - Language: C++ - Date: $Date$ - Version: $Revision: 16224 $ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ - - -#ifndef QmitkSegmentationPreferencePage_h_included -#define QmitkSegmentationPreferencePage_h_included - -#include "berryIQtPreferencePage.h" -#include "org_mitk_gui_qt_segmentation_Export.h" -#include - -class QWidget; -class QCheckBox; -class QRadioButton; -class QDoubleSpinBox; - -class MITK_QT_SEGMENTATION QmitkSegmentationPreferencePage : public QObject, public berry::IQtPreferencePage -{ - Q_OBJECT - Q_INTERFACES(berry::IPreferencePage) - -public: - - QmitkSegmentationPreferencePage(); - QmitkSegmentationPreferencePage(const QmitkSegmentationPreferencePage& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - ~QmitkSegmentationPreferencePage(); - - void Init(berry::IWorkbench::Pointer workbench); - - void CreateQtControl(QWidget* widget); - - QWidget* GetQtControl() const; - - /// - /// \see IPreferencePage::PerformOk() - /// - virtual bool PerformOk(); - - /// - /// \see IPreferencePage::PerformCancel() - /// - virtual void PerformCancel(); - - /// - /// \see IPreferencePage::Update() - /// - virtual void Update(); - -protected slots: - - void OnVolumeRenderingCheckboxChecked(int); - void OnSmoothingCheckboxChecked(int); - -protected: - - QWidget* m_MainControl; - QRadioButton* m_RadioOutline; - QRadioButton* m_RadioOverlay; - QCheckBox* m_VolumeRenderingCheckBox; - QCheckBox* m_SmoothingCheckBox; - QDoubleSpinBox* m_SmoothingSpinBox; - QDoubleSpinBox* m_DecimationSpinBox; - QDoubleSpinBox* m_ClosingSpinBox; - - bool m_Initializing; - - berry::IPreferences::Pointer m_SegmentationPreferencesNode; -}; - -#endif /* QMITKDATAMANAGERPREFERENCEPAGE_H_ */ - diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp deleted file mode 100644 index 331c476a50..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "QmitkAutocropAction.h" - -#include "mitkAutoCropImageFilter.h" -#include "mitkImageCast.h" -#include "mitkRenderingManager.h" -#include "mitkProgressBar.h" - -#include - -//needed for qApp -#include - -QmitkAutocropAction::QmitkAutocropAction() -{ -} - -QmitkAutocropAction::~QmitkAutocropAction() -{ -} - -void QmitkAutocropAction::Run( const std::vector& selectedNodes ) -{ - NodeList selection = selectedNodes; - - for ( NodeList::iterator iter = selection.begin(); iter != selection.end(); ++iter ) - { - mitk::DataNode* node = *iter; - - if (node) - { - mitk::Image::Pointer image = dynamic_cast( node->GetData() ); - if (image.IsNull()) return; - - mitk::ProgressBar::GetInstance()->AddStepsToDo(10); - mitk::ProgressBar::GetInstance()->Progress(2); - - qApp->processEvents(); - - mitk::AutoCropImageFilter::Pointer cropFilter = mitk::AutoCropImageFilter::New(); - cropFilter->SetInput( image ); - cropFilter->SetBackgroundValue( 0 ); - try - { - cropFilter->Update(); - - image = cropFilter->GetOutput(); - - if (image.IsNotNull()) - { - node->SetData( this->IncreaseCroppedImageSize(image) ); // bug fix 3145 - // Reinit node - mitk::RenderingManager::GetInstance()->InitializeViews( - node->GetData()->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - - } - } - catch(...) - { - MITK_ERROR << "Cropping image failed..."; - } - mitk::ProgressBar::GetInstance()->Progress(8); - } - else - { - MITK_INFO << " a NULL node selected"; - } - } -} - -mitk::Image::Pointer QmitkAutocropAction::IncreaseCroppedImageSize( mitk::Image::Pointer image ) -{ - typedef itk::Image< short, 3 > ImageType; - typedef itk::Image< unsigned char, 3 > PADOutputImageType; - ImageType::Pointer itkTransformImage = ImageType::New(); - mitk::CastToItkImage( image, itkTransformImage ); - - typedef itk::ConstantPadImageFilter< ImageType, PADOutputImageType > PadFilterType; - PadFilterType::Pointer padFilter = PadFilterType::New(); - - unsigned long upperPad[3]; - unsigned long lowerPad[3]; - int borderLiner = 3; - - mitk::Point3D mitkOriginPoint; - double origin[3]; - origin[0]=0; - origin[1]=0; - origin[2]=0; - itkTransformImage->SetOrigin(origin); - - lowerPad[0]=borderLiner; - lowerPad[1]=borderLiner; - lowerPad[2]=borderLiner; - - upperPad[0]=borderLiner; - upperPad[1]=borderLiner; - upperPad[2]=borderLiner; - - padFilter->SetInput(itkTransformImage); - padFilter->SetConstant(0); - padFilter->SetPadUpperBound(upperPad); - padFilter->SetPadLowerBound(lowerPad); - padFilter->UpdateLargestPossibleRegion(); - - - mitk::Image::Pointer paddedImage = mitk::Image::New(); - paddedImage->InitializeByItk(padFilter->GetOutput()); - mitk::CastToMitkImage(padFilter->GetOutput(), paddedImage); - - //calculate translation according to padding to get the new origin - mitk::Point3D paddedOrigin = image->GetGeometry()->GetOrigin(); - mitk::Vector3D spacing = image->GetGeometry()->GetSpacing(); - paddedOrigin[0] -= (borderLiner)*spacing[0]; - paddedOrigin[1] -= (borderLiner)*spacing[1]; - paddedOrigin[2] -= (borderLiner)*spacing[2]; - - paddedImage->GetGeometry()->SetOrigin( paddedOrigin ); - - return paddedImage; -} - -void QmitkAutocropAction::SetSmoothed(bool smoothed) -{ - //not needed -} - -void QmitkAutocropAction::SetDecimated(bool decimated) -{ - //not needed -} - -void QmitkAutocropAction::SetDataStorage(mitk::DataStorage* dataStorage) -{ - //not needed -} - -void QmitkAutocropAction::SetStdMultiWidget(QmitkStdMultiWidget *) -{ - //not needed -} - -void QmitkAutocropAction::SetFunctionality(berry::QtViewPart *functionality) -{ - //not needed -} diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h deleted file mode 100644 index b438e05bd1..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef QMITK_AUTOCROPACTION_H -#define QMITK_AUTOCROPACTION_H - -#include "mitkIContextMenuAction.h" - -#include "org_mitk_gui_qt_segmentation_Export.h" - -#include "vector" -#include "mitkDataNode.h" -#include "mitkImage.h" - -class QmitkStdMultiWidget; - -class MITK_QT_SEGMENTATION QmitkAutocropAction : public QObject, public mitk::IContextMenuAction -{ - Q_OBJECT - Q_INTERFACES(mitk::IContextMenuAction) - -public: - - QmitkAutocropAction(); - QmitkAutocropAction(const QmitkAutocropAction& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - virtual ~QmitkAutocropAction(); - - //interface methods - void Run( const std::vector& selectedNodes ); - void SetDataStorage(mitk::DataStorage* dataStorage); - void SetStdMultiWidget(QmitkStdMultiWidget *stdMultiWidget); - void SetSmoothed(bool smoothed); - void SetDecimated(bool decimated); - void SetFunctionality(berry::QtViewPart* functionality); - -protected: - - mitk::Image::Pointer IncreaseCroppedImageSize( mitk::Image::Pointer image ); - -private: - - typedef std::vector NodeList; - -}; - -#endif // QMITK_AUTOCROPACTION_H diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp deleted file mode 100644 index 9851a30d01..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "QmitkCreatePolygonModelAction.h" - -// MITK -#include -#include -#include -#include -#include - -// Blueberry -#include -#include - -using namespace berry; -using namespace mitk; -using namespace std; - -QmitkCreatePolygonModelAction::QmitkCreatePolygonModelAction() - : m_StdMultiWidget(0) -{ -} - -QmitkCreatePolygonModelAction::~QmitkCreatePolygonModelAction() -{ -} - -void QmitkCreatePolygonModelAction::Run(const vector &selectedNodes) -{ - DataNode::Pointer selectedNode = selectedNodes[0]; - Image::Pointer image = dynamic_cast(selectedNode->GetData()); - - if (image.IsNull()) - return; - - try - { - if (!m_IsSmoothed) - { - ShowSegmentationAsSurface::Pointer surfaceFilter = ShowSegmentationAsSurface::New(); - - itk::SimpleMemberCommand::Pointer successCommand = itk::SimpleMemberCommand::New(); - successCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); - surfaceFilter->AddObserver(ResultAvailable(), successCommand); - - itk::SimpleMemberCommand::Pointer errorCommand = itk::SimpleMemberCommand::New(); - errorCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); - surfaceFilter->AddObserver(ProcessingError(), errorCommand); - - surfaceFilter->SetDataStorage(*m_DataStorage); - surfaceFilter->SetPointerParameter("Input", image); - surfaceFilter->SetPointerParameter("Group node", selectedNode); - surfaceFilter->SetParameter("Show result", true); - surfaceFilter->SetParameter("Sync visibility", false); - surfaceFilter->SetParameter("Smooth", false); - surfaceFilter->SetParameter("Apply median", false); - surfaceFilter->SetParameter("Median kernel size", 3u); - surfaceFilter->SetParameter("Gaussian SD", 1.5f); - surfaceFilter->SetParameter("Decimate mesh", m_IsDecimated); - surfaceFilter->SetParameter("Decimation rate", 0.8f); - - StatusBar::GetInstance()->DisplayText("Surface creation started in background..."); - - surfaceFilter->StartAlgorithm(); - } - else - { - ShowSegmentationAsSmoothedSurface::Pointer surfaceFilter = ShowSegmentationAsSmoothedSurface::New(); - - itk::SimpleMemberCommand::Pointer successCommand = itk::SimpleMemberCommand::New(); - successCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); - surfaceFilter->AddObserver(mitk::ResultAvailable(), successCommand); - - itk::SimpleMemberCommand::Pointer errorCommand = itk::SimpleMemberCommand::New(); - errorCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); - surfaceFilter->AddObserver(mitk::ProcessingError(), errorCommand); - - surfaceFilter->SetDataStorage(*m_DataStorage); - surfaceFilter->SetPointerParameter("Input", image); - surfaceFilter->SetPointerParameter("Group node", selectedNode); - - int timeNr = m_StdMultiWidget != 0 ? m_StdMultiWidget->GetTimeNavigationController()->GetTime()->GetPos() : 0; - surfaceFilter->SetParameter("TimeNr", timeNr); - - IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID); - IPreferences::Pointer segPref = prefService->GetSystemPreferences()->Node("/org.mitk.views.segmentation"); - - bool smoothingHint = segPref->GetBool("smoothing hint", true); - float smoothing = (float)segPref->GetDouble("smoothing value", 1.0); - float decimation = (float)segPref->GetDouble("decimation rate", 0.5); - float closing = (float)segPref->GetDouble("closing ratio", 0.0); - - if (smoothingHint) - { - smoothing = 0.0; - Vector3D spacing = image->GetGeometry()->GetSpacing(); - - for (Vector3D::Iterator iter = spacing.Begin(); iter != spacing.End(); ++iter) - smoothing = max(smoothing, *iter); - } - - surfaceFilter->SetParameter("Smoothing", smoothing); - surfaceFilter->SetParameter("Decimation", decimation); - surfaceFilter->SetParameter("Closing", closing); - - ProgressBar::GetInstance()->AddStepsToDo(8); - StatusBar::GetInstance()->DisplayText("Smoothed surface creation started in background..."); - - surfaceFilter->StartAlgorithm(); - } - } - catch(...) - { - MITK_ERROR << "Surface creation failed!"; - } -} - -void QmitkCreatePolygonModelAction::OnSurfaceCalculationDone() -{ - StatusBar::GetInstance()->Clear(); -} - -void QmitkCreatePolygonModelAction::SetDataStorage(DataStorage *dataStorage) -{ - m_DataStorage = dataStorage; -} - -void QmitkCreatePolygonModelAction::SetStdMultiWidget(QmitkStdMultiWidget *stdMultiWidget) -{ - m_StdMultiWidget = stdMultiWidget; -} - -void QmitkCreatePolygonModelAction::SetSmoothed(bool smoothed) -{ - m_IsSmoothed = smoothed; -} - -void QmitkCreatePolygonModelAction::SetDecimated(bool decimated) -{ - m_IsDecimated = decimated; -} - -void QmitkCreatePolygonModelAction::SetFunctionality(QtViewPart *) -{ -} diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h deleted file mode 100644 index 379a59027e..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef QMITKCREATEPOLYGONMODELACTION_H -#define QMITKCREATEPOLYGONMODELACTION_H - -#include - -// Parent classes -#include -#include - -// Data members -#include - -class QmitkStdMultiWidget; - -class MITK_QT_SEGMENTATION QmitkCreatePolygonModelAction : public QObject, public mitk::IContextMenuAction -{ - Q_OBJECT - Q_INTERFACES(mitk::IContextMenuAction) - -public: - QmitkCreatePolygonModelAction(); - ~QmitkCreatePolygonModelAction(); - - // IContextMenuAction - void Run(const std::vector &selectedNodes); - void SetDataStorage(mitk::DataStorage *dataStorage); - void SetStdMultiWidget(QmitkStdMultiWidget *stdMultiWidget); - void SetSmoothed(bool smoothed); - void SetDecimated(bool decimated); - void SetFunctionality(berry::QtViewPart *functionality); - - void OnSurfaceCalculationDone(); - -private: - QmitkCreatePolygonModelAction(const QmitkCreatePolygonModelAction &); - QmitkCreatePolygonModelAction & operator=(const QmitkCreatePolygonModelAction &); - - mitk::DataStorage::Pointer m_DataStorage; - QmitkStdMultiWidget *m_StdMultiWidget; - bool m_IsSmoothed; - bool m_IsDecimated; -}; - -#endif diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.cpp deleted file mode 100644 index 57955dd778..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Module: $RCSfile$ -Language: C++ -Date: $Date$ -Version: $Revision$ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "QmitkDeformableClippingPlaneView.h" - -#include "mitkClippingPlaneDeformationTool.h" -#include "mitkClippingPlaneRotationTool.h" -#include "mitkClippingPlaneTranslationTool.h" -#include "mitkHeightFieldSurfaceClipImageFilter.h" -#include "mitkImageToSurfaceFilter.h" -#include "mitkInteractionConst.h" -#include "mitkLabeledImageLookupTable.h" -#include "mitkLabeledImageVolumeCalculator.h" -#include "mitkLevelWindowProperty.h" -#include "mitkLookupTableProperty.h" -#include "mitkPlane.h" -#include "mitkRotationOperation.h" -#include "mitkSurfaceVtkMapper3D.h" -#include "mitkVtkRepresentationProperty.h" - -#include "vtkFloatArray.h" -#include "vtkPointData.h" -#include "vtkProperty.h" - - -const std::string QmitkDeformableClippingPlaneView::VIEW_ID = "org.mitk.views.deformableclippingplane"; - -QmitkDeformableClippingPlaneView::QmitkDeformableClippingPlaneView() -: QmitkFunctionality() -, m_MultiWidget(NULL) -, m_ToolManager(NULL) -{ - //Current fix for bug 10707. Waiting for a solution of bug 10834. - itk::Object::Pointer o; - o = mitk::ClippingPlaneRotationTool::New(); - o = mitk::ClippingPlaneDeformationTool::New(); - o = mitk::ClippingPlaneTranslationTool::New(); -} - -QmitkDeformableClippingPlaneView::~QmitkDeformableClippingPlaneView() -{ -} - -void QmitkDeformableClippingPlaneView::CreateQtPartControl(QWidget *parent) -{ - // create GUI widgets - m_Controls.setupUi(parent); - this->CreateConnections(); -} - -void QmitkDeformableClippingPlaneView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) -{ - m_MultiWidget = &stdMultiWidget; -} - -void QmitkDeformableClippingPlaneView::StdMultiWidgetNotAvailable() -{ - m_MultiWidget = NULL; -} - -void QmitkDeformableClippingPlaneView::CreateConnections() -{ - m_ToolManager = m_Controls.interactionToolSelectionBox->GetToolManager(); - m_ToolManager->SetDataStorage(*(this->GetDefaultDataStorage())); - assert(m_ToolManager); - - mitk::NodePredicateProperty::Pointer clipPredicate = mitk::NodePredicateProperty::New("clippingPlane",mitk::BoolProperty::New(true)); - //set only clipping planes in the list of the selector - m_Controls.clippingPlaneSelector->SetDataStorage(this->GetDefaultDataStorage()); - m_Controls.clippingPlaneSelector->SetPredicate(clipPredicate); - - //Shows and set the tool buttons - m_Controls.interactionToolSelectionBox->SetGenerateAccelerators(true); - m_Controls.interactionToolSelectionBox->SetDisplayedToolGroups("ClippingTool"); - m_Controls.interactionToolSelectionBox->SetLayoutColumns(3); - m_Controls.interactionToolSelectionBox->SetEnabledMode(QmitkToolSelectionBox::EnabledWithWorkingData); - - //No working data set, yet - m_Controls.volumeGroupBox->setEnabled(false); - m_Controls.noSelectedImageLabel->show(); - m_Controls.planesWarningLabel->hide(); - - connect (m_Controls.createNewPlanePushButton, SIGNAL(clicked()), this, SLOT(OnCreateNewClippingPlane())); - connect (m_Controls.updateVolumePushButton, SIGNAL(clicked()), this, SLOT(OnCalculateClippingVolume())); - connect (m_Controls.clippingPlaneSelector, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), - this, SLOT(OnComboBoxSelectionChanged(const mitk::DataNode*))); -} - -void QmitkDeformableClippingPlaneView::Activated() -{ - QmitkFunctionality::Activated(); -} - -void QmitkDeformableClippingPlaneView::Deactivated() -{ - QmitkFunctionality::Deactivated(); -} - -void QmitkDeformableClippingPlaneView::OnComboBoxSelectionChanged( const mitk::DataNode* node ) -{ - mitk::DataNode* selectedNode = const_cast(node); - if( selectedNode != NULL ) - { - //remember the active tool - int toolID = m_ToolManager->GetActiveToolID(); - - m_ToolManager->SetWorkingData(selectedNode); - - //reset Tool - m_ToolManager->ActivateTool(-1); - //set tool again with new working data (calls activated() in Tool) - m_ToolManager->ActivateTool(toolID); - } - this->UpdateView(); -} - -void QmitkDeformableClippingPlaneView::OnSelectionChanged(mitk::DataNode* node) -{ - std::vector nodes; - nodes.push_back(node); - this->OnSelectionChanged(nodes); -} - -void QmitkDeformableClippingPlaneView::OnSelectionChanged(std::vector nodes) -{ - bool isClippingPlane(false); - for(unsigned int i = 0; i < nodes.size(); ++i) - { - if(nodes.at(i)->GetBoolProperty("clippingPlane", isClippingPlane)) - m_Controls.clippingPlaneSelector->setCurrentIndex( m_Controls.clippingPlaneSelector->Find(nodes.at(i)) ); - - else - { - if(dynamic_cast (nodes.at(i)->GetData())&& nodes.at(i)) - { - if(m_ToolManager->GetReferenceData(0)!= NULL && nodes.at(i)->GetData()==m_ToolManager->GetReferenceData(0)->GetData()) - return; - - m_ToolManager->SetReferenceData(nodes.at(i)); - } - } - } - this->UpdateView(); -} - -void::QmitkDeformableClippingPlaneView::NodeChanged(const mitk::DataNode* node) -{ - this->UpdateView(); -} - -void QmitkDeformableClippingPlaneView::NodeRemoved(const mitk::DataNode* node) -{ - bool isClippingPlane(false); - - if (node->GetBoolProperty("clippingPlane", isClippingPlane)) - { - if(this->GetAllClippingPlanes()->empty()) - { - m_ToolManager->SetWorkingData(NULL); - this->UpdateView(); - } - else - this->OnSelectionChanged(GetAllClippingPlanes()->front()); - } - else - { - if(m_ToolManager->GetReferenceData(0)!= NULL) - { - if(node->GetData() == m_ToolManager->GetReferenceData(0)->GetData()) - { - m_ToolManager->SetReferenceData(NULL); - m_Controls.volumeList->clear(); - } - this->OnSelectionChanged(mitk::DataNode::New()); - } - } -} - -void QmitkDeformableClippingPlaneView::UpdateView() -{ - if (m_ToolManager->GetReferenceData(0)!= NULL) - { - m_Controls.volumeGroupBox->setEnabled(m_ToolManager->GetWorkingData(0)!= NULL); - m_Controls.noSelectedImageLabel->hide(); - m_Controls.selectedImageLabel->setText(QString::fromUtf8(m_ToolManager->GetReferenceData(0)->GetName().c_str())); - - //clear list --> than search for all shown clipping plans (max 7 planes) - m_Controls.selectedVolumePlanesLabel->setText(""); - m_Controls.planesWarningLabel->hide(); - int volumePlanes=0; - - mitk::DataStorage::SetOfObjects::ConstPointer allClippingPlanes = this->GetAllClippingPlanes(); - for (mitk::DataStorage::SetOfObjects::ConstIterator itPlanes = allClippingPlanes->Begin(); itPlanes != allClippingPlanes->End(); itPlanes++) - { - bool isVisible(false); - itPlanes.Value()->GetBoolProperty("visible",isVisible); - if (isVisible) - { - if (volumePlanes<7) - { - volumePlanes ++; - m_Controls.selectedVolumePlanesLabel->setText(m_Controls.selectedVolumePlanesLabel->text().append(QString::fromStdString(itPlanes.Value()->GetName()+"\n"))); - } - else - { - m_Controls.planesWarningLabel->show(); - return; - } - } - } - } - - else - { - m_Controls.volumeGroupBox->setEnabled(false); - m_Controls.noSelectedImageLabel->show(); - m_Controls.selectedImageLabel->setText(""); - m_Controls.selectedVolumePlanesLabel->setText(""); - m_Controls.planesWarningLabel->hide(); - } -} - -void QmitkDeformableClippingPlaneView::OnCreateNewClippingPlane() -{ - mitk::DataNode* referenceNode = m_ToolManager->GetReferenceData(0); - mitk::Image::Pointer referenceImage = mitk::Image::New(); - - //the new clipping plane - mitk::Plane::Pointer plane = mitk::Plane::New(); - - double imageDiagonal = 200; - - if (referenceNode != NULL) - { - referenceImage = dynamic_cast (referenceNode->GetData()); - - if (referenceImage.IsNotNull()) - { - // check if user wants a surface model - if(m_Controls.surfaceModelCheckBox->isChecked()) - { - //Check if there is a surface node from the image. If not, create one - bool createSurfaceFromImage(true); - - mitk::TNodePredicateDataType::Pointer isSurface = mitk::TNodePredicateDataType::New(); - mitk::DataStorage::SetOfObjects::ConstPointer childNodes = m_ToolManager->GetDataStorage()->GetDerivations(referenceNode,isSurface, true); - - for (mitk::DataStorage::SetOfObjects::ConstIterator itChildNodes = childNodes->Begin(); - itChildNodes != childNodes->End(); itChildNodes++) - { - if (itChildNodes.Value().IsNotNull()) - createSurfaceFromImage=false; - } - - if(createSurfaceFromImage) - { - //Lsg 2: Surface for the 3D-perspective - mitk::ImageToSurfaceFilter::Pointer surfaceFilter = mitk::ImageToSurfaceFilter::New(); - surfaceFilter->SetInput(referenceImage); - surfaceFilter->SetThreshold(1); - surfaceFilter->SetSmooth(true); - //Downsampling - surfaceFilter->SetDecimate(mitk::ImageToSurfaceFilter::DecimatePro); - - mitk::DataNode::Pointer surfaceNode = mitk::DataNode::New(); - surfaceNode->SetData(surfaceFilter->GetOutput()); - surfaceNode->SetProperty("color", referenceNode->GetProperty("color")); - surfaceNode->SetOpacity(0.5); - surfaceNode->SetName(referenceNode->GetName()); - m_ToolManager->GetDataStorage()->Add(surfaceNode, referenceNode); - } - } - - //If an image is selected trim the plane to this. - imageDiagonal = referenceImage->GetGeometry()->GetDiagonalLength(); - plane->SetOrigin( referenceImage->GetGeometry()->GetCenter()); - - // Rotate plane - mitk::Vector3D rotationAxis; - mitk::FillVector3D(rotationAxis, 0.0, 1.0, 0.0); - mitk::RotationOperation op(mitk::OpROTATE, referenceImage->GetGeometry()->GetCenter(), rotationAxis, 90.0); - plane->GetGeometry()->ExecuteOperation(&op); - } - } - - //set some properties for the clipping plane - plane->SetExtent(imageDiagonal * 0.9, imageDiagonal * 0.9); - plane->SetResolution(64, 64); - - // Set scalars (for colorization of plane) - vtkFloatArray *scalars = vtkFloatArray::New(); - scalars->SetName("Distance"); - scalars->SetNumberOfComponents(1); - - for ( unsigned int i = 0; i < plane->GetVtkPolyData(0)->GetNumberOfPoints(); ++i) - { - scalars->InsertNextValue(-1.0); - } - plane->GetVtkPolyData(0)->GetPointData()->SetScalars(scalars); - plane->GetVtkPolyData(0)->GetPointData()->Update(); - - mitk::DataNode::Pointer planeNode = mitk::DataNode::New(); - planeNode->SetData(plane); - - std::stringstream planeName; - planeName << "ClippingPlane "; - planeName << this->GetAllClippingPlanes()->Size() + 1; - - planeNode->SetName(planeName.str()); - planeNode->AddProperty("clippingPlane",mitk::BoolProperty::New(true)); - // Make plane pickable - planeNode->SetBoolProperty("pickable", true); - - mitk::SurfaceVtkMapper3D::SetDefaultProperties(planeNode); - - // Don't include plane in bounding box! - planeNode->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); - - // Set lookup table for plane surface visualization - vtkLookupTable *lookupTable = vtkLookupTable::New(); - lookupTable->SetHueRange(0.6, 0.0); - lookupTable->SetSaturationRange(1.0, 1.0); - lookupTable->SetValueRange(1.0, 1.0); - lookupTable->SetTableRange(-1.0, 1.0); - lookupTable->Build(); - - mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); - lut->SetVtkLookupTable(lookupTable); - - mitk::LookupTableProperty::Pointer prop = mitk::LookupTableProperty::New(lut); - - planeNode->SetProperty("LookupTable", prop); - planeNode->SetBoolProperty("scalar visibility", true); - planeNode->SetBoolProperty("color mode", true); - planeNode->SetFloatProperty("ScalarsRangeMinimum", -1.0); - planeNode->SetFloatProperty("ScalarsRangeMaximum", 1.0); - - // Configure material so that only scalar colors are shown - planeNode->SetColor(0.0f,0.0f,0.0f); - planeNode->SetOpacity(1.0f); - planeNode->SetFloatProperty("material.wireframeLineWidth",2.0f); - - //Set view of plane to wireframe - planeNode->SetProperty("material.representation", mitk::VtkRepresentationProperty::New(VTK_WIREFRAME)); - - //Set the plane as working data for the tools and selected it - this->OnSelectionChanged (planeNode); - - //Add the plane to data storage - this->GetDataStorage()->Add(planeNode); - - //Change the index of the selector to the new generated node - m_Controls.clippingPlaneSelector->setCurrentIndex( m_Controls.clippingPlaneSelector->Find(planeNode) ); - - // set crosshair invisible - mitk::DataNode* dataNode; - - dataNode = this->GetDataStorage()->GetNamedNode("widget1Plane"); - if(dataNode) dataNode->SetVisibility(false); - dataNode = this->GetDataStorage()->GetNamedNode("widget2Plane"); - if(dataNode) dataNode->SetVisibility(false); - dataNode = this->GetDataStorage()->GetNamedNode("widget3Plane"); - if(dataNode) dataNode->SetVisibility(false); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkDeformableClippingPlaneView::OnCalculateClippingVolume() -{ - mitk::DataNode::Pointer imageNode = m_ToolManager->GetReferenceData(0); - bool isSegmentation(false); - imageNode->GetBoolProperty("binary", isSegmentation); - - if(imageNode.IsNull() || !isSegmentation) - { - MITK_INFO << "No segmentation selected! Can't calculate volume"; - return; - } - - std::vector clippingPlanes; - mitk::DataStorage::SetOfObjects::ConstPointer allClippingPlanes = this->GetAllClippingPlanes(); - for (mitk::DataStorage::SetOfObjects::ConstIterator itPlanes = allClippingPlanes->Begin(); itPlanes != allClippingPlanes->End(); itPlanes++) - { - bool isVisible(false); - itPlanes.Value()->GetBoolProperty("visible",isVisible); - mitk::Surface* plane = dynamic_cast(itPlanes.Value()->GetData()); - - if (isVisible && plane) - clippingPlanes.push_back(plane); - } - - if (clippingPlanes.empty()) - { - MITK_INFO << "No clipping plane selected! Can't calculate volume"; - return; - } - - - //deactivate Tools - m_ToolManager->ActivateTool(-1); - //Clear the list of volumes, before calculating the new values - m_Controls.volumeList->clear(); - - imageNode->SetBoolProperty("visible", false); - - //set some properties for clipping the image-->Output: labled Image - mitk::HeightFieldSurfaceClipImageFilter::Pointer surfaceClipFilter = mitk::HeightFieldSurfaceClipImageFilter::New(); - - surfaceClipFilter->SetInput(dynamic_cast (imageNode->GetData())); - surfaceClipFilter->SetClippingModeToMultiPlaneValue(); - surfaceClipFilter->SetClippingSurfaces(clippingPlanes); - surfaceClipFilter->Update(); - - //delete the old clipped image node - mitk::DataStorage::SetOfObjects::ConstPointer oldClippedNode = this->GetDataStorage()->GetSubset(mitk::NodePredicateProperty::New("name", mitk::StringProperty::New("Clipped Image"))); - if (oldClippedNode.IsNotNull()) - this->GetDataStorage()->Remove(oldClippedNode); - - //add the new clipped image node - mitk::DataNode::Pointer clippedNode = mitk::DataNode::New(); - mitk::Image::Pointer clippedImage = surfaceClipFilter->GetOutput(); - clippedImage->DisconnectPipeline(); - clippedNode->SetData(clippedImage); - //clippedNode->SetProperty("helper object", mitk::BoolProperty::New(true)); - clippedNode->SetName("Clipped Image"); - clippedNode->SetColor(1.0,1.0,1.0); // color property will not be used, labeled image lookuptable will be used instead - clippedNode->SetProperty ("use color", mitk::BoolProperty::New(false)); - clippedNode->SetOpacity(0.4); - this->GetDataStorage()->Add(clippedNode); - - mitk::LabeledImageVolumeCalculator::Pointer volumeCalculator = mitk::LabeledImageVolumeCalculator::New(); - volumeCalculator->SetImage(clippedImage); - volumeCalculator->Calculate(); - - std::vector volumes = volumeCalculator->GetVolumes(); - - mitk::LabeledImageLookupTable::Pointer lut = mitk::LabeledImageLookupTable::New(); - int lablesWithVolume=0; - - for(unsigned int i = 1; i < volumes.size(); ++i) - { - if(volumes.at(i)!=0) - { - lablesWithVolume++; - - mitk::Color color (GetLabelColor(lablesWithVolume)); - lut->SetColorForLabel(i,color.GetRed(), color.GetGreen(), color.GetBlue(), 1.0); - - QColor qcolor; - qcolor.setRgbF(color.GetRed(), color.GetGreen(), color.GetBlue(), 0.7); - - //output volume as string "x.xx ml" - std::stringstream stream; - stream<< std::fixed << std::setprecision(2)<setText(QString::fromStdString(stream.str())); - item->setBackgroundColor(qcolor); - m_Controls.volumeList->addItem(item); - } - } - - - mitk::LookupTableProperty::Pointer lutProp = mitk::LookupTableProperty::New(lut.GetPointer()); - clippedNode->SetProperty("LookupTable", lutProp); - // it is absolutely important, to use the LevelWindow settings provided by - // the LUT generator, otherwise, it is not guaranteed, that colors show - // up correctly. - clippedNode->SetProperty("levelwindow", mitk::LevelWindowProperty::New(lut->GetLevelWindow())); -} - -mitk::DataStorage::SetOfObjects::ConstPointer QmitkDeformableClippingPlaneView::GetAllClippingPlanes() -{ - mitk::NodePredicateProperty::Pointer clipPredicate= mitk::NodePredicateProperty::New("clippingPlane",mitk::BoolProperty::New(true)); - mitk::DataStorage::SetOfObjects::ConstPointer allPlanes = m_ToolManager->GetDataStorage()->GetSubset(clipPredicate); - return allPlanes; -} - -mitk::Color QmitkDeformableClippingPlaneView::GetLabelColor(int label) -{ - float red, green, blue; - switch ( label % 6 ) - { - case 0: - {red = 1.0; green = 0.0; blue = 0.0; break;} - case 1: - {red = 0.0; green = 1.0; blue = 0.0; break;} - case 2: - {red = 0.0; green = 0.0; blue = 1.0;break;} - case 3: - {red = 1.0; green = 1.0; blue = 0.0;break;} - case 4: - {red = 1.0; green = 0.0; blue = 1.0;break;} - case 5: - {red = 0.0; green = 1.0; blue = 1.0;break;} - default: - {red = 0.0; green = 0.0; blue = 0.0;} - } - - float tmp[3] = { red, green, blue }; - - double factor; - - int outerCycleNr = label / 6; - int cycleSize = pow(2.0,(int)(log((double)(outerCycleNr))/log( 2.0 ))); - if (cycleSize==0) - cycleSize = 1; - int insideCycleCounter = outerCycleNr % cycleSize; - - if ( outerCycleNr == 0) - factor = 255; - - else - factor = ( 256 / ( 2 * cycleSize ) ) + ( insideCycleCounter * ( 256 / cycleSize ) ); - - tmp[0]= tmp[0]/256*factor; - tmp[1]= tmp[1]/256*factor; - tmp[2]= tmp[2]/256*factor; - - return mitk::Color(tmp); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp deleted file mode 100644 index 2211df5033..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp +++ /dev/null @@ -1,1227 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 1.12 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "mitkDataNodeObject.h" -#include "mitkProperties.h" -#include "mitkSegTool2D.h" -#include "mitkGlobalInteraction.h" - -#include "QmitkStdMultiWidget.h" -#include "QmitkNewSegmentationDialog.h" - -#include - -#include - -#include "QmitkSegmentationView.h" -#include "QmitkSegmentationPostProcessing.h" -#include "QmitkSegmentationOrganNamesHandling.cpp" - -#include -#include - -//For Segmentation in rotated slices -//TODO clean up includes -#include "mitkVtkResliceInterpolationProperty.h" -#include "mitkPlanarCircle.h" - -#include "mitkGetModuleContext.h" -#include "mitkModule.h" -#include "mitkModuleRegistry.h" - -const std::string QmitkSegmentationView::VIEW_ID = -"org.mitk.views.segmentation"; - -// public methods - -QmitkSegmentationView::QmitkSegmentationView() -:m_Parent(NULL) -,m_Controls(NULL) -,m_MultiWidget(NULL) -,m_RenderingManagerObserverTag(0) -{ -} - -QmitkSegmentationView::~QmitkSegmentationView() -{ - // delete m_PostProcessing; - delete m_Controls; -} - -void QmitkSegmentationView::NewNodesGenerated() -{ -// ForceDisplayPreferencesUponAllImages(); -} - -void QmitkSegmentationView::NewNodeObjectsGenerated(mitk::ToolManager::DataVectorType* nodes) -{ - if (!nodes) return; - - mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); - if (!toolManager) return; - for (mitk::ToolManager::DataVectorType::iterator iter = nodes->begin(); iter != nodes->end(); ++iter) - { - this->FireNodeSelected( *iter ); - // only last iteration meaningful, multiple generated objects are not taken into account here - } -} - -void QmitkSegmentationView::Activated() -{ - // should be moved to ::BecomesVisible() or similar - if( m_Controls ) - { - m_Controls->m_ManualToolSelectionBox->setEnabled( true ); - m_Controls->m_OrganToolSelectionBox->setEnabled( true ); - m_Controls->m_LesionToolSelectionBox->setEnabled( true ); - - m_Controls->m_SlicesInterpolator->Enable3DInterpolation( m_Controls->widgetStack->currentWidget() == m_Controls->pageManual ); - - //TODO Remove Observer - itk::ReceptorMemberCommand::Pointer command1 = itk::ReceptorMemberCommand::New(); - command1->SetCallbackFunction( this, &QmitkSegmentationView::RenderingManagerReinitialized ); - m_RenderingManagerObserverTag = mitk::RenderingManager::GetInstance()->AddObserver( mitk::RenderingManagerViewsInitializedEvent(), command1 ); - - //Adding observers for node visibility to existing segmentations - mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); - mitk::NodePredicateProperty::Pointer isBinary = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)); - mitk::NodePredicateAnd::Pointer isSegmentation = mitk::NodePredicateAnd::New( isImage, isBinary ); - - mitk::DataStorage::SetOfObjects::ConstPointer segmentations = this->GetDefaultDataStorage()->GetSubset( isSegmentation ); - - for ( mitk::DataStorage::SetOfObjects::const_iterator iter = segmentations->begin(); - iter != segmentations->end(); - ++iter) - { - mitk::DataNode* node = *iter; - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); - command->SetCallbackFunction(this, &QmitkSegmentationView::OnWorkingNodeVisibilityChanged); - m_WorkingDataObserverTags.insert( std::pair( node, node->GetProperty("visible")->AddObserver( itk::ModifiedEvent(), command ) ) ); - } - - if(segmentations->Size() > 0) - { - FireNodeSelected(segmentations->ElementAt(0)); - segmentations->ElementAt(0)->GetProperty("visible")->Modified(); - } - } -} - -void QmitkSegmentationView::Deactivated() -{ - if( m_Controls ) - { - mitk::RenderingManager::GetInstance()->RemoveObserver( m_RenderingManagerObserverTag ); - m_Controls->m_ManualToolSelectionBox->setEnabled( false ); - //deactivate all tools - m_Controls->m_ManualToolSelectionBox->GetToolManager()->ActivateTool(-1); - m_Controls->m_OrganToolSelectionBox->setEnabled( false ); - m_Controls->m_LesionToolSelectionBox->setEnabled( false ); - m_Controls->m_SlicesInterpolator->EnableInterpolation( false ); - - //Removing all observers - for ( NodeTagMapType::iterator dataIter = m_WorkingDataObserverTags.begin(); dataIter != m_WorkingDataObserverTags.end(); ++dataIter ) - { - (*dataIter).first->GetProperty("visible")->RemoveObserver( (*dataIter).second ); - } - m_WorkingDataObserverTags.clear(); - - // gets the context of the "Mitk" (Core) module (always has id 1) - // TODO Workaround until CTL plugincontext is available - mitk::ModuleContext* context = mitk::ModuleRegistry::GetModule(1)->GetModuleContext(); - // Workaround end - mitk::ServiceReference serviceRef = context->GetServiceReference(); - //mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); - mitk::PlanePositionManagerService* service = dynamic_cast(context->GetService(serviceRef)); - service->RemoveAllPlanePositions(); - } -} - -void QmitkSegmentationView::StdMultiWidgetAvailable( QmitkStdMultiWidget& stdMultiWidget ) -{ - SetMultiWidget(&stdMultiWidget); -} - -void QmitkSegmentationView::StdMultiWidgetNotAvailable() -{ - SetMultiWidget(NULL); -} - -void QmitkSegmentationView::StdMultiWidgetClosed( QmitkStdMultiWidget& /*stdMultiWidget*/ ) -{ - SetMultiWidget(NULL); -} - -void QmitkSegmentationView::SetMultiWidget(QmitkStdMultiWidget* multiWidget) -{ - if (m_MultiWidget) - { - mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); - if (coordinator) - { - coordinator->RemoveObserver( m_SlicesRotationObserverTag1 ); - } - coordinator = m_MultiWidget->GetSlicesSwiveller(); - if (coordinator) - { - coordinator->RemoveObserver( m_SlicesRotationObserverTag2 ); - } - } - - // save the current multiwidget as the working widget - m_MultiWidget = multiWidget; - - //TODO Remove Observers - if (m_MultiWidget) - { - mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); - if (coordinator) - { - itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); - command2->SetCallbackFunction( this, &QmitkSegmentationView::SliceRotation ); - m_SlicesRotationObserverTag1 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); - } - - coordinator = m_MultiWidget->GetSlicesSwiveller(); - if (coordinator) - { - itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); - command2->SetCallbackFunction( this, &QmitkSegmentationView::SliceRotation ); - m_SlicesRotationObserverTag2 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); - } - } - //TODO End Remove Observers - - if (m_Parent) - { - m_Parent->setEnabled(m_MultiWidget); - } - - // tell the interpolation about toolmanager and multiwidget (and data storage) - if (m_Controls && m_MultiWidget) - { - mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); - m_Controls->m_SlicesInterpolator->SetDataStorage( *(this->GetDefaultDataStorage())); - m_Controls->m_SlicesInterpolator->Initialize( toolManager, m_MultiWidget ); - } -} - -void QmitkSegmentationView::OnPreferencesChanged(const berry::IBerryPreferences*) -{ - ForceDisplayPreferencesUponAllImages(); -} - -//TODO remove function -void QmitkSegmentationView::RenderingManagerReinitialized(const itk::EventObject&) -{ - CheckImageAlignment(); -} - -//TODO remove function -void QmitkSegmentationView::SliceRotation(const itk::EventObject&) -{ - CheckImageAlignment(); -} - - -// protected slots - -void QmitkSegmentationView::CreateNewSegmentation() -{ - mitk::DataNode::Pointer node = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); - if (node.IsNotNull()) - { - mitk::Image::Pointer image = dynamic_cast( node->GetData() ); - if (image.IsNotNull()) - { - if (image->GetDimension()>1) - { - // ask about the name and organ type of the new segmentation - QmitkNewSegmentationDialog* dialog = new QmitkNewSegmentationDialog( m_Parent ); // needs a QWidget as parent, "this" is not QWidget - - QString storedList = QString::fromStdString( this->GetPreferences()->GetByteArray("Organ-Color-List","") ); - QStringList organColors; - if (storedList.isEmpty()) - { - organColors = GetDefaultOrganColorString(); - } - else - { - /* - a couple of examples of how organ names are stored: - - a simple item is built up like 'name#AABBCC' where #AABBCC is the hexadecimal notation of a color as known from HTML - - items are stored separated by ';' - this makes it necessary to escape occurrences of ';' in name. - otherwise the string "hugo;ypsilon#AABBCC;eugen#AABBCC" could not be parsed as two organs - but we would get "hugo" and "ypsilon#AABBCC" and "eugen#AABBCC" - - so the organ name "hugo;ypsilon" is stored as "hugo\;ypsilon" - and must be unescaped after loading - - the following lines could be one split with Perl's negative lookbehind - */ - - // recover string list from BlueBerry view's preferences - QString storedString = QString::fromStdString( this->GetPreferences()->GetByteArray("Organ-Color-List","") ); - MITK_DEBUG << "storedString: " << storedString.toStdString(); - // match a string consisting of any number of repetitions of either "anything but ;" or "\;". This matches everything until the next unescaped ';' - QRegExp onePart("(?:[^;]|\\\\;)*"); - MITK_DEBUG << "matching " << onePart.pattern().toStdString(); - int count = 0; - int pos = 0; - while( (pos = onePart.indexIn( storedString, pos )) != -1 ) - { - ++count; - int length = onePart.matchedLength(); - if (length == 0) break; - QString matchedString = storedString.mid(pos, length); - MITK_DEBUG << " Captured length " << length << ": " << matchedString.toStdString(); - pos += length + 1; // skip separating ';' - - // unescape possible occurrences of '\;' in the string - matchedString.replace("\\;", ";"); - - // add matched string part to output list - organColors << matchedString; - } - MITK_DEBUG << "Captured " << count << " organ name/colors"; - } - - dialog->SetSuggestionList( organColors ); - - int dialogReturnValue = dialog->exec(); - - if ( dialogReturnValue == QDialog::Rejected ) return; // user clicked cancel or pressed Esc or something similar - - // ask the user about an organ type and name, add this information to the image's (!) propertylist - // create a new image of the same dimensions and smallest possible pixel type - mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); - mitk::Tool* firstTool = toolManager->GetToolById(0); - if (firstTool) - { - try - { - mitk::DataNode::Pointer emptySegmentation = - firstTool->CreateEmptySegmentationNode( image, dialog->GetSegmentationName().toStdString(), dialog->GetColor() ); - - //Here we change the reslice interpolation mode for a segmentation, so that contours in rotated slice can be shown correctly - emptySegmentation->SetProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New(VTK_RESLICE_LINEAR) ); - // initialize showVolume to false to prevent recalculating the volume while working on the segmentation - emptySegmentation->SetProperty( "showVolume", mitk::BoolProperty::New( false ) ); - - if (!emptySegmentation) return; // could be aborted by user - - UpdateOrganList( organColors, dialog->GetSegmentationName(), dialog->GetColor() ); - - /* - escape ';' here (replace by '\;'), see longer comment above - */ - std::string stringForStorage = organColors.replaceInStrings(";","\\;").join(";").toStdString(); - MITK_DEBUG << "Will store: " << stringForStorage; - this->GetPreferences()->PutByteArray("Organ-Color-List", stringForStorage ); - this->GetPreferences()->Flush(); - - if(m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)) - { - m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)->SetSelected(false); - } - //emptySegmentation->SetSelected(true); - this->GetDefaultDataStorage()->Add( emptySegmentation, node ); // add as a child, because the segmentation "derives" from the original - - this->FireNodeSelected( emptySegmentation ); - this->OnSelectionChanged( emptySegmentation ); - this->SetToolManagerSelection(node, emptySegmentation); - } - catch (std::bad_alloc) - { - QMessageBox::warning(NULL,"Create new segmentation","Could not allocate memory for new segmentation"); - } - } - } - else - { - QMessageBox::information(NULL,"Segmentation","Segmentation is currently not supported for 2D images"); - } - } - } - else - { - MITK_ERROR << "'Create new segmentation' button should never be clickable unless a patient image is selected..."; - } -} - -void QmitkSegmentationView::OnWorkingNodeVisibilityChanged(/*const itk::Object* caller, const itk::EventObject& e*/) -{ - if (!m_Parent || !m_Parent->isVisible()) return; - - // The new selection behaviour is: - // - // When clicking on the checkbox of a segmentation the node will e selected and its reference node either - // The previous selected segmentation (if there is one) will be deselected. Additionally a reinit on the - // selected segmenation will be performed. - // If more than one segmentation is selected the tools will be disabled. - - if (!m_Controls) return; // might happen on initialization (preferences loaded) - mitk::DataNode::Pointer referenceDataNew = mitk::DataNode::New(); - mitk::DataNode::Pointer workingData; - - bool workingNodeIsVisible (true); - - unsigned int numberOfSelectedSegmentations (0); - - // iterate all images - mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); - - mitk::DataStorage::SetOfObjects::ConstPointer allImages = this->GetDefaultDataStorage()->GetSubset( isImage ); - for ( mitk::DataStorage::SetOfObjects::const_iterator iter = allImages->begin(); - iter != allImages->end(); - ++iter) - { - mitk::DataNode* node = *iter; - // apply display preferences - ApplyDisplayOptions(node); - - bool isSegmentation(false); - node->GetBoolProperty("binary", isSegmentation); - if (node->IsSelected() && isSegmentation) - { - workingNodeIsVisible = node->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))); - if (!workingNodeIsVisible) - return; - numberOfSelectedSegmentations++; - - workingData = node; - - if (this->GetDefaultDataStorage()->GetSources(node)->Size() != 0) - { - referenceDataNew = this->GetDefaultDataStorage()->GetSources(node)->ElementAt(0); - } - - bool isBinary(false); - - //Find topmost source or first source which is no binary image - while (referenceDataNew && this->GetDefaultDataStorage()->GetSources(referenceDataNew)->Size() != 0) - { - referenceDataNew = this->GetDefaultDataStorage()->GetSources(referenceDataNew)->ElementAt(0); - - referenceDataNew->GetBoolProperty("binary",isBinary); - if (!isBinary) - break; - } - - if (workingNodeIsVisible && referenceDataNew) - { - //Since the binary property of a segmentation can be set to false and afterwards you can create a new segmentation out of it - //->could lead to a deadloop - NodeTagMapType::iterator searchIter = m_WorkingDataObserverTags.find( referenceDataNew ); - if ( searchIter != m_WorkingDataObserverTags.end()) - { - referenceDataNew->GetProperty("visible")->RemoveObserver( (*searchIter).second ); - } - referenceDataNew->SetVisibility(true); - } - - //set comboBox to reference image - disconnect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); - - m_Controls->refImageSelector->setCurrentIndex( m_Controls->refImageSelector->Find(referenceDataNew) ); - - connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); - - continue; - } - if (workingData.IsNull() || (workingNodeIsVisible && node != referenceDataNew)) - { - node->SetVisibility((false)); - } - } - if(numberOfSelectedSegmentations == 1) - SetToolManagerSelection(referenceDataNew, workingData); - - mitk::DataStorage::SetOfObjects::Pointer temp = mitk::DataStorage::SetOfObjects::New(); - temp->InsertElement(0,workingData); - mitk::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(temp); - - // initialize the views to the bounding geometry - mitk::RenderingManager::GetInstance()->InitializeViews(bounds); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkSegmentationView::NodeRemoved(const mitk::DataNode* node) -{ - bool isSeg(false); - bool isHelperObject(false); - node->GetBoolProperty("helper object", isHelperObject); - node->GetBoolProperty("binary", isSeg); - if(isSeg && !isHelperObject) - { - mitk::DataStorage::SetOfObjects::ConstPointer allContourMarkers = this->GetDataStorage()->GetDerivations(node, mitk::NodePredicateProperty::New("isContourMarker" - , mitk::BoolProperty::New(true))); - - // gets the context of the "Mitk" (Core) module (always has id 1) - // TODO Workaround until CTL plugincontext is available - mitk::ModuleContext* context = mitk::ModuleRegistry::GetModule(1)->GetModuleContext(); - // Workaround end - mitk::ServiceReference serviceRef = context->GetServiceReference(); - //mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); - - mitk::PlanePositionManagerService* service = dynamic_cast(context->GetService(serviceRef)); - - for (mitk::DataStorage::SetOfObjects::ConstIterator it = allContourMarkers->Begin(); it != allContourMarkers->End(); ++it) - { - std::string nodeName = node->GetName(); - unsigned int t = nodeName.find_last_of(" "); - unsigned int id = atof(nodeName.substr(t+1).c_str())-1; - - service->RemovePlanePosition(id); - - this->GetDataStorage()->Remove(it->Value()); - } - mitk::DataNode* tempNode = const_cast(node); - node->GetProperty("visible")->RemoveObserver( m_WorkingDataObserverTags[tempNode] ); - m_WorkingDataObserverTags.erase(tempNode); - this->SetToolManagerSelection(NULL, NULL); - } -} - -void QmitkSegmentationView::CreateSegmentationFromSurface() -{ - mitk::DataNode::Pointer surfaceNode = - m_Controls->MaskSurfaces->GetSelectedNode(); - mitk::Surface::Pointer surface(0); - if(surfaceNode.IsNotNull()) - surface = dynamic_cast ( surfaceNode->GetData() ); - if(surface.IsNull()) - { - this->HandleException( "No surface selected.", m_Parent, true); - return; - } - - mitk::DataNode::Pointer imageNode - = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); - mitk::Image::Pointer image(0); - if (imageNode.IsNotNull()) - image = dynamic_cast( imageNode->GetData() ); - if(image.IsNull()) - { - this->HandleException( "No image selected.", m_Parent, true); - return; - } - - mitk::SurfaceToImageFilter::Pointer s2iFilter - = mitk::SurfaceToImageFilter::New(); - - s2iFilter->MakeOutputBinaryOn(); - s2iFilter->SetInput(surface); - s2iFilter->SetImage(image); - s2iFilter->Update(); - - mitk::DataNode::Pointer resultNode = mitk::DataNode::New(); - std::string nameOfResultImage = imageNode->GetName(); - nameOfResultImage.append(surfaceNode->GetName()); - resultNode->SetProperty("name", mitk::StringProperty::New(nameOfResultImage) ); - resultNode->SetProperty("binary", mitk::BoolProperty::New(true) ); - resultNode->SetData( s2iFilter->GetOutput() ); - - this->GetDataStorage()->Add(resultNode, imageNode); - -} - -void QmitkSegmentationView::ManualToolSelected(int id) -{ - // disable crosshair movement when a manual drawing tool is active (otherwise too much visual noise) - if (m_MultiWidget) - { - if (id >= 0) - { - m_MultiWidget->DisableNavigationControllerEventListening(); - } - else - { - m_MultiWidget->EnableNavigationControllerEventListening(); - } - } -} - -void QmitkSegmentationView::ToolboxStackPageChanged(int id) -{ - // interpolation only with manual tools visible - m_Controls->m_SlicesInterpolator->EnableInterpolation( id == 0 ); - - if( id == 0 ) - { - mitk::DataNode::Pointer workingData = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0); - if( workingData.IsNotNull() ) - { - m_Controls->lblSegmentation->setText( workingData->GetName().c_str() ); - m_Controls->lblSegImage->show(); - m_Controls->lblSegmentation->show(); - } - } - else - { - m_Controls->lblSegImage->hide(); - m_Controls->lblSegmentation->hide(); - } - - // this is just a workaround, should be removed when all tools support 3D+t - if (id==2) // lesions - { - mitk::DataNode::Pointer node = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); - if (node.IsNotNull()) - { - mitk::Image::Pointer image = dynamic_cast( node->GetData() ); - if (image.IsNotNull()) - { - if (image->GetDimension()>3) - { - m_Controls->widgetStack->setCurrentIndex(0); - QMessageBox::information(NULL,"Segmentation","Lesion segmentation is currently not supported for 4D images"); - } - } - } - } -} - -// protected - -void QmitkSegmentationView::OnComboBoxSelectionChanged( const mitk::DataNode* node ) -{ - mitk::DataNode* selectedNode = const_cast(node); - if( selectedNode != NULL ) - { - m_Controls->refImageSelector->show(); - m_Controls->lblReferenceImageSelectionWarning->hide(); - - bool isBinary(false); - selectedNode->GetBoolProperty("binary", isBinary); - if ( isBinary ) - { - FireNodeSelected(selectedNode); - selectedNode->SetVisibility(true); - } - else if (node != m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0)) - { - if (m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0)) - m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0)->SetVisibility(false); - if (m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)) - { - m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)->SetVisibility(false); - } - FireNodeSelected(selectedNode); - selectedNode->SetVisibility(true); - SetToolManagerSelection(selectedNode, NULL); - } - } - else - { - m_Controls->refImageSelector->hide(); - m_Controls->lblReferenceImageSelectionWarning->show(); - } -} - - -void QmitkSegmentationView::OnShowMarkerNodes (bool state) -{ - mitk::SegTool2D::Pointer manualSegmentationTool; - - unsigned int numberOfExistingTools = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetTools().size(); - - for(unsigned int i = 0; i < numberOfExistingTools; i++) - { - manualSegmentationTool = dynamic_cast(m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetToolById(i)); - - if (manualSegmentationTool) - { - if(state == true) - { - manualSegmentationTool->SetShowMarkerNodes( true ); - } - else - { - manualSegmentationTool->SetShowMarkerNodes( false ); - } - } - } -} - -void QmitkSegmentationView::On3DInterpolationEnabled (bool state) -{ - mitk::SegTool2D::Pointer manualSegmentationTool; - - unsigned int numberOfExistingTools = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetTools().size(); - - for(unsigned int i = 0; i < numberOfExistingTools; i++) -{ - manualSegmentationTool = dynamic_cast(m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetToolById(i)); - - if (manualSegmentationTool) - { - manualSegmentationTool->Enable3DInterpolation( state ); - } - } -} - -void QmitkSegmentationView::OnSelectionChanged(mitk::DataNode* node) -{ - std::vector nodes; - nodes.push_back( node ); - this->OnSelectionChanged( nodes ); -} - -void QmitkSegmentationView::OnSurfaceSelectionChanged() -{ - // if Image and Surface are selected, enable button - if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || - (m_Controls->MaskSurfaces->GetSelectedNode().IsNull())) - m_Controls->CreateSegmentationFromSurface->setEnabled(false); - else - m_Controls->CreateSegmentationFromSurface->setEnabled(true); -} - -void QmitkSegmentationView::OnSelectionChanged(std::vector nodes) -{ - // if the selected node is a contourmarker - if ( !nodes.empty() ) - { - std::string markerName = "Position"; - unsigned int numberOfNodes = nodes.size(); - std::string nodeName = nodes.at( 0 )->GetName(); - if ( ( numberOfNodes == 1 ) && ( nodeName.find( markerName ) == 0) ) - { - this->OnContourMarkerSelected( nodes.at( 0 ) ); - } - } - - // if Image and Surface are selected, enable button - if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || - (m_Controls->MaskSurfaces->GetSelectedNode().IsNull())) - m_Controls->CreateSegmentationFromSurface->setEnabled(false); - else - m_Controls->CreateSegmentationFromSurface->setEnabled(true); - - if (!m_Parent || !m_Parent->isVisible()) return; - - // reaction to BlueBerry selection events - // this method will try to figure out if a relevant segmentation and its corresponding original image were selected - // a warning is issued if the selection is invalid - // appropriate reactions are triggered otherwise - - mitk::DataNode::Pointer referenceData = FindFirstRegularImage( nodes ); //m_Controls->refImageSelector->GetSelectedNode(); //FindFirstRegularImage( nodes ); - mitk::DataNode::Pointer workingData = FindFirstSegmentation( nodes ); - - if(referenceData.IsNull() && workingData.IsNull()) - return; - - bool invalidSelection( !nodes.empty() && - ( - nodes.size() > 2 || // maximum 2 selected nodes - (nodes.size() == 2 && (workingData.IsNull() || referenceData.IsNull()) ) || // with two nodes, one must be the original image, one the segmentation - ( workingData.GetPointer() == referenceData.GetPointer() ) //one node is selected as reference and working image - // one item is always ok (might be working or reference or nothing - ) - ); - - if (invalidSelection) - { - // TODO visible warning when two images are selected - MITK_ERROR << "WARNING: No image, too many (>2) or two equal images were selected."; - workingData = NULL; - - if( m_Controls->refImageSelector->GetSelectedNode().IsNull() ) - referenceData = NULL; - } - - if ( workingData.IsNotNull() && referenceData.IsNull() ) - { - // find the DataStorage parent of workingData - // try to find a "normal image" parent, select this as reference image - mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); - mitk::NodePredicateProperty::Pointer isBinary = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)); - mitk::NodePredicateNot::Pointer isNotBinary = mitk::NodePredicateNot::New( isBinary ); - mitk::NodePredicateAnd::Pointer isNormalImage = mitk::NodePredicateAnd::New( isImage, isNotBinary ); - - mitk::DataStorage::SetOfObjects::ConstPointer possibleParents = this->GetDefaultDataStorage()->GetSources( workingData, isNormalImage ); - - if (possibleParents->size() > 0) - { - if (possibleParents->size() > 1) - { - // TODO visible warning for this rare case - MITK_ERROR << "Selected binary image has multiple parents. Using arbitrary first one for segmentation."; - } - - referenceData = (*possibleParents)[0]; - } - - NodeTagMapType::iterator searchIter = m_WorkingDataObserverTags.find( workingData ); - if ( searchIter == m_WorkingDataObserverTags.end() ) - { - //MITK_INFO<<"Creating new observer"; - itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); - command->SetCallbackFunction(this, &QmitkSegmentationView::OnWorkingNodeVisibilityChanged); - m_WorkingDataObserverTags.insert( std::pair( workingData, workingData->GetProperty("visible")->AddObserver( itk::ModifiedEvent(), command ) ) ); - workingData->GetProperty("visible")->Modified(); - - return; - } - - if(workingData->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1")))) - { - //set comboBox to reference image - disconnect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); - - m_Controls->refImageSelector->setCurrentIndex( m_Controls->refImageSelector->Find(workingData) ); - - connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); - - - // if Image and Surface are selected, enable button - if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || - (m_Controls->MaskSurfaces->GetSelectedNode().IsNull()) || - (!referenceData)) - m_Controls->CreateSegmentationFromSurface->setEnabled(false); - else - m_Controls->CreateSegmentationFromSurface->setEnabled(true); - - SetToolManagerSelection(referenceData, workingData); - FireNodeSelected(workingData); - } - else - { - SetToolManagerSelection(NULL, NULL); - FireNodeSelected(workingData); - } - - } - else - { - //set comboBox to reference image - disconnect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); - - m_Controls->refImageSelector->setCurrentIndex( m_Controls->refImageSelector->Find(referenceData) ); - - connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); - - // if Image and Surface are selected, enable button - if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || - (m_Controls->MaskSurfaces->GetSelectedNode().IsNull()) || - (!referenceData)) - m_Controls->CreateSegmentationFromSurface->setEnabled(false); - else - m_Controls->CreateSegmentationFromSurface->setEnabled(true); - - SetToolManagerSelection(referenceData, workingData); - - FireNodeSelected(referenceData); - } -} - -void QmitkSegmentationView::OnContourMarkerSelected(const mitk::DataNode *node) -{ - //TODO renderWindow anders bestimmen, siehe CheckAlignment - QmitkRenderWindow* selectedRenderWindow = 0; - QmitkRenderWindow* RenderWindow1 = - this->GetActiveStdMultiWidget()->GetRenderWindow1(); - QmitkRenderWindow* RenderWindow2 = - this->GetActiveStdMultiWidget()->GetRenderWindow2(); - QmitkRenderWindow* RenderWindow3 = - this->GetActiveStdMultiWidget()->GetRenderWindow3(); - QmitkRenderWindow* RenderWindow4 = - this->GetActiveStdMultiWidget()->GetRenderWindow4(); - bool PlanarFigureInitializedWindow = false; - - // find initialized renderwindow - if (node->GetBoolProperty("PlanarFigureInitializedWindow", - PlanarFigureInitializedWindow, RenderWindow1->GetRenderer())) - { - selectedRenderWindow = RenderWindow1; - } - if (!selectedRenderWindow && node->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow2->GetRenderer())) - { - selectedRenderWindow = RenderWindow2; - } - if (!selectedRenderWindow && node->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow3->GetRenderer())) - { - selectedRenderWindow = RenderWindow3; - } - if (!selectedRenderWindow && node->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow4->GetRenderer())) - { - selectedRenderWindow = RenderWindow4; - } - - // make node visible - if (selectedRenderWindow) - { - std::string nodeName = node->GetName(); - unsigned int t = nodeName.find_last_of(" "); - unsigned int id = atof(nodeName.substr(t+1).c_str())-1; - - // gets the context of the "Mitk" (Core) module (always has id 1) - // TODO Workaround until CTL plugincontext is available - mitk::ModuleContext* context = mitk::ModuleRegistry::GetModule(1)->GetModuleContext(); - // Workaround end - mitk::ServiceReference serviceRef = context->GetServiceReference(); - //mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); - - mitk::PlanePositionManagerService* service = dynamic_cast(context->GetService(serviceRef)); - selectedRenderWindow->GetSliceNavigationController()->ExecuteOperation(service->GetPlanePosition(id)); - selectedRenderWindow->GetRenderer()->GetDisplayGeometry()->Fit(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } -} - - -mitk::DataNode::Pointer QmitkSegmentationView::FindFirstRegularImage( std::vector nodes ) -{ - if (nodes.empty()) return NULL; - - for(unsigned int i = 0; i < nodes.size(); ++i) - { - //mitk::DataNode::Pointer node = i.value() - bool isImage(false); - if (nodes.at(i)->GetData()) - { - isImage = dynamic_cast(nodes.at(i)->GetData()) != NULL; - } - - // make sure this is not a binary image - bool isSegmentation(false); - nodes.at(i)->GetBoolProperty("binary", isSegmentation); - - // return first proper mitk::Image - if (isImage && !isSegmentation) return nodes.at(i); - } - - return NULL; -} - - -mitk::DataNode::Pointer QmitkSegmentationView::FindFirstSegmentation( std::vector nodes ) -{ - if (nodes.empty()) return NULL; - - - for(unsigned int i = 0; i < nodes.size(); ++i) - { - bool isImage(false); - if (nodes.at(i)->GetData()) - { - isImage = dynamic_cast(nodes.at(i)->GetData()) != NULL; - } - - bool isSegmentation(false); - nodes.at(i)->GetBoolProperty("binary", isSegmentation); - - // return first proper binary mitk::Image - if (isImage && isSegmentation) - { - return nodes.at(i); - } - } - - return NULL; -} - -void QmitkSegmentationView::SetToolManagerSelection(const mitk::DataNode* referenceData, const mitk::DataNode* workingData) -{ - // called as a result of new BlueBerry selections - // tells the ToolManager for manual segmentation about new selections - // updates GUI information about what the user should select - mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); - toolManager->SetReferenceData(const_cast(referenceData)); - toolManager->SetWorkingData( const_cast(workingData)); - - - // check original image - m_Controls->btnNewSegmentation->setEnabled(referenceData != NULL); - if (referenceData) - { - m_Controls->lblReferenceImageSelectionWarning->hide(); - } - else - { - m_Controls->lblReferenceImageSelectionWarning->show(); - m_Controls->lblWorkingImageSelectionWarning->hide(); - m_Controls->lblSegImage->hide(); - m_Controls->lblSegmentation->hide(); - } - - //TODO remove statement - // check, wheter reference image is aligned like render windows. Otherwise display a visible warning (because 2D tools will probably not work) - CheckImageAlignment(); - - // check segmentation - if (referenceData) - { - if (!workingData) - { - m_Controls->lblWorkingImageSelectionWarning->show(); - - if( m_Controls->widgetStack->currentIndex() == 0 ) - { - m_Controls->lblSegImage->hide(); - m_Controls->lblSegmentation->hide(); - } - } - else - { - m_Controls->lblWorkingImageSelectionWarning->hide(); - this->FireNodeSelected(const_cast(workingData)); - - if( m_Controls->widgetStack->currentIndex() == 0 ) - { - m_Controls->lblSegmentation->setText( workingData->GetName().c_str() ); - m_Controls->lblSegmentation->show(); - m_Controls->lblSegImage->show(); - } - } - } -} - -//TODO remove function -void QmitkSegmentationView::CheckImageAlignment() -{ - bool wrongAlignment(true); - - mitk::DataNode::Pointer node = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); - if (node.IsNotNull()) - { - mitk::Image::Pointer image = dynamic_cast( node->GetData() ); - - if (image.IsNotNull() && m_MultiWidget) - { - - wrongAlignment = !( IsRenderWindowAligned(m_MultiWidget->GetRenderWindow1(), image ) - && IsRenderWindowAligned(m_MultiWidget->GetRenderWindow2(), image ) - && IsRenderWindowAligned(m_MultiWidget->GetRenderWindow3(), image ) - ); - } - - if (wrongAlignment) - { - m_Controls->lblAlignmentWarning->show(); - } - } -} - -//TODO remove function -bool QmitkSegmentationView::IsRenderWindowAligned(QmitkRenderWindow* renderWindow, mitk::Image* image) -{ - if (!renderWindow) return false; - - // for all 2D renderwindows of m_MultiWidget check alignment - mitk::PlaneGeometry::ConstPointer displayPlane = dynamic_cast( renderWindow->GetRenderer()->GetCurrentWorldGeometry2D() ); - if (displayPlane.IsNull()) return false; - - int affectedDimension(-1); - int affectedSlice(-1); - return mitk::SegTool2D::DetermineAffectedImageSlice( image, displayPlane, affectedDimension, affectedSlice ); -} - -//TODO remove function -void QmitkSegmentationView::ForceDisplayPreferencesUponAllImages() -{ - if (!m_Parent || !m_Parent->isVisible()) return; - - // check all images and segmentations in DataStorage: - // (items in brackets are implicitly done by previous steps) - // 1. - // if a reference image is selected, - // show the reference image - // and hide all other images (orignal and segmentation), - // (and hide all segmentations of the other original images) - // and show all the reference's segmentations - // if no reference image is selected, do do nothing - // - // 2. - // if a segmentation is selected, - // show it - // (and hide all all its siblings (childs of the same parent, incl, NULL parent)) - // if no segmentation is selected, do nothing - - if (!m_Controls) return; // might happen on initialization (preferences loaded) - mitk::DataNode::Pointer referenceData = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); - mitk::DataNode::Pointer workingData = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0); - - // 1. - if (referenceData.IsNotNull()) - { - // iterate all images - mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); - - mitk::DataStorage::SetOfObjects::ConstPointer allImages = this->GetDefaultDataStorage()->GetSubset( isImage ); - //mitk::DataStorage::SetOfObjects::ConstPointer allSegmentationChilds = this->GetDefaultDataStorage()->GetDerivations(referenceData, isImage ); - for ( mitk::DataStorage::SetOfObjects::const_iterator iter = allImages->begin(); - iter != allImages->end(); - ++iter) - - { - mitk::DataNode* node = *iter; - // apply display preferences - ApplyDisplayOptions(node); - - // set visibility - if(!node->IsSelected() || (node->IsSelected() && !node->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))))) - node->SetVisibility((node == referenceData) || node->IsSelected() ); - } - } - - // 2. - //if (workingData.IsNotNull() && !workingData->IsSelected()) - //{ - // workingData->SetVisibility(true); - //} - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkSegmentationView::ApplyDisplayOptions(mitk::DataNode* node) -{ - if (!node) return; - - bool isBinary(false); - node->GetPropertyValue("binary", isBinary); - - if (isBinary) - { - node->SetProperty( "outline binary", mitk::BoolProperty::New( this->GetPreferences()->GetBool("draw outline", true)) ); - node->SetProperty( "outline width", mitk::FloatProperty::New( 2.0 ) ); - node->SetProperty( "opacity", mitk::FloatProperty::New( this->GetPreferences()->GetBool("draw outline", true) ? 1.0 : 0.3 ) ); - node->SetProperty( "volumerendering", mitk::BoolProperty::New( this->GetPreferences()->GetBool("volume rendering", false) ) ); - } -} - -void QmitkSegmentationView::CreateQtPartControl(QWidget* parent) -{ - // setup the basic GUI of this view - m_Parent = parent; - - m_Controls = new Ui::QmitkSegmentationControls; - m_Controls->setupUi(parent); - m_Controls->lblWorkingImageSelectionWarning->hide(); - m_Controls->lblAlignmentWarning->hide(); - m_Controls->lblSegImage->hide(); - m_Controls->lblSegmentation->hide(); - - m_Controls->refImageSelector->SetDataStorage(this->GetDefaultDataStorage()); - m_Controls->refImageSelector->SetPredicate(mitk::NodePredicateDataType::New("Image")); - - if( m_Controls->refImageSelector->GetSelectedNode().IsNotNull() ) - m_Controls->lblReferenceImageSelectionWarning->hide(); - else - m_Controls->refImageSelector->hide(); - - - mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); - toolManager->SetDataStorage( *(this->GetDefaultDataStorage()) ); - assert ( toolManager ); - - // all part of open source MITK - m_Controls->m_ManualToolSelectionBox->SetGenerateAccelerators(true); - m_Controls->m_ManualToolSelectionBox->SetToolGUIArea( m_Controls->m_ManualToolGUIContainer ); - m_Controls->m_ManualToolSelectionBox->SetDisplayedToolGroups("Add Subtract Paint Wipe 'Region Growing' Correction Fill Erase"); - m_Controls->m_ManualToolSelectionBox->SetEnabledMode( QmitkToolSelectionBox::EnabledWithReferenceAndWorkingData ); - - // available only in the 3M application - if ( !m_Controls->m_OrganToolSelectionBox->children().count() ) - { - m_Controls->widgetStack->setItemEnabled( 1, false ); - } - m_Controls->m_OrganToolSelectionBox->SetToolManager( *toolManager ); - m_Controls->m_OrganToolSelectionBox->SetToolGUIArea( m_Controls->m_OrganToolGUIContainer ); - m_Controls->m_OrganToolSelectionBox->SetDisplayedToolGroups("'Hippocampus left' 'Hippocampus right' 'Lung left' 'Lung right' 'Liver' 'Heart LV' 'Endocard LV' 'Epicard LV' 'Prostate'"); - m_Controls->m_OrganToolSelectionBox->SetEnabledMode( QmitkToolSelectionBox::EnabledWithReferenceData ); - - // available only in the 3M application - if ( !m_Controls->m_LesionToolSelectionBox->children().count() ) - { - m_Controls->widgetStack->setItemEnabled( 2, false ); - } - m_Controls->m_LesionToolSelectionBox->SetToolManager( *toolManager ); - m_Controls->m_LesionToolSelectionBox->SetToolGUIArea( m_Controls->m_LesionToolGUIContainer ); - m_Controls->m_LesionToolSelectionBox->SetDisplayedToolGroups("'Lymph Node'"); - m_Controls->m_LesionToolSelectionBox->SetEnabledMode( QmitkToolSelectionBox::EnabledWithReferenceData ); - - toolManager->NewNodesGenerated += - mitk::MessageDelegate( this, &QmitkSegmentationView::NewNodesGenerated ); // update the list of segmentations - toolManager->NewNodeObjectsGenerated += - mitk::MessageDelegate1( this, &QmitkSegmentationView::NewNodeObjectsGenerated ); // update the list of segmentations - - // create signal/slot connections - connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); - connect( m_Controls->btnNewSegmentation, SIGNAL(clicked()), this, SLOT(CreateNewSegmentation()) ); - connect( m_Controls->CreateSegmentationFromSurface, SIGNAL(clicked()), this, SLOT(CreateSegmentationFromSurface()) ); - connect( m_Controls->m_ManualToolSelectionBox, SIGNAL(ToolSelected(int)), this, SLOT(ManualToolSelected(int)) ); - connect( m_Controls->widgetStack, SIGNAL(currentChanged(int)), this, SLOT(ToolboxStackPageChanged(int)) ); - - connect(m_Controls->MaskSurfaces, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnSurfaceSelectionChanged( ) ) ); - - connect(m_Controls->MaskSurfaces, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), - this, SLOT( OnSurfaceSelectionChanged( ) ) ); - - connect(m_Controls->m_SlicesInterpolator, SIGNAL(SignalShowMarkerNodes(bool)), this, SLOT(OnShowMarkerNodes(bool))); - connect(m_Controls->m_SlicesInterpolator, SIGNAL(Signal3DInterpolationEnabled(bool)), this, SLOT(On3DInterpolationEnabled(bool))); - - m_Controls->MaskSurfaces->SetDataStorage(this->GetDefaultDataStorage()); - m_Controls->MaskSurfaces->SetPredicate(mitk::NodePredicateDataType::New("Surface")); - - //// create helper class to provide context menus for segmentations in data manager - // m_PostProcessing = new QmitkSegmentationPostProcessing(this->GetDefaultDataStorage(), this, m_Parent); - -} - -//void QmitkSegmentationView::OnPlaneModeChanged(int i) -//{ -// //if plane mode changes, disable all tools -// if (m_MultiWidget) -// { -// mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); -// -// if (toolManager) -// { -// if (toolManager->GetActiveToolID() >= 0) -// { -// toolManager->ActivateTool(-1); -// } -// else -// { -// m_MultiWidget->EnableNavigationControllerEventListening(); -// } -// } -// } -//} - - -// ATTENTION some methods for handling the known list of (organ names, colors) are defined in QmitkSegmentationOrganNamesHandling.cpp - diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h deleted file mode 100644 index 428e7bc935..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h +++ /dev/null @@ -1,172 +0,0 @@ -/*====================================================================== -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 1.12 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkSegmentationView_h -#define QmitkSegmentationView_h - -#include "QmitkFunctionality.h" - -#include - -#include "ui_QmitkSegmentationControls.h" - - -class QmitkRenderWindow; -// class QmitkSegmentationPostProcessing; - -/** - * \ingroup ToolManagerEtAl - * \ingroup org_mitk_gui_qt_segmentation_internal - * \warning Implementation of this class is split up into two .cpp files to make things more compact. Check both this file and QmitkSegmentationOrganNamesHandling.cpp - */ -class QmitkSegmentationView : public QmitkFunctionality -{ - Q_OBJECT - -public: - - QmitkSegmentationView(); - QmitkSegmentationView(const QmitkSegmentationView& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - virtual ~QmitkSegmentationView(); - - typedef std::map NodeTagMapType; - - /*! - \brief Invoked when the DataManager selection changed - */ - virtual void OnSelectionChanged(mitk::DataNode* node); - virtual void OnSelectionChanged(std::vector nodes); - - // reaction to new segmentations being created by segmentation tools - void NewNodesGenerated(); - void NewNodeObjectsGenerated(mitk::ToolManager::DataVectorType*); - - // QmitkFunctionality's activate/deactivate - virtual void Activated(); - virtual void Deactivated(); - - // QmitkFunctionality's changes regarding THE QmitkStdMultiWidget - virtual void StdMultiWidgetAvailable(QmitkStdMultiWidget& stdMultiWidget); - virtual void StdMultiWidgetNotAvailable(); - virtual void StdMultiWidgetClosed(QmitkStdMultiWidget& stdMultiWidget); - - // BlueBerry's notification about preference changes (e.g. from a dialog) - virtual void OnPreferencesChanged(const berry::IBerryPreferences*); - - // observer to mitk::RenderingManager's RenderingManagerViewsInitializedEvent event - void RenderingManagerReinitialized(const itk::EventObject&); - - // observer to mitk::SliceController's SliceRotation event - void SliceRotation(const itk::EventObject&); - - static const std::string VIEW_ID; - -protected slots: - - void OnComboBoxSelectionChanged(const mitk::DataNode* node); - - // reaction to the button "New segmentation" - void CreateNewSegmentation(); - - // reaction to the button "New segmentation" - void CreateSegmentationFromSurface(); - - // called when a segmentation tool is activated - void ManualToolSelected(int id); - - // called when one of "Manual", "Organ", "Lesion" pages of the QToolbox is selected - void ToolboxStackPageChanged(int id); - - void OnSurfaceSelectionChanged(); - - //called when the checkbox Remember Contour Positions is selected/deselected - - void OnWorkingNodeVisibilityChanged(); - - void OnShowMarkerNodes(bool); - - void On3DInterpolationEnabled(bool); - -protected: - - // a type for handling lists of DataNodes - typedef std::vector NodeList; - - // set available multiwidget - void SetMultiWidget(QmitkStdMultiWidget* multiWidget); - - // actively query the current selection of data manager - //void PullCurrentDataManagerSelection(); - - // reactions to selection events from data manager (and potential other senders) - //void BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection); - mitk::DataNode::Pointer FindFirstRegularImage( std::vector nodes ); - mitk::DataNode::Pointer FindFirstSegmentation( std::vector nodes ); - - // propagate BlueBerry selection to ToolManager for manual segmentation - void SetToolManagerSelection(const mitk::DataNode* referenceData, const mitk::DataNode* workingData); - - // checks if selected reference image is aligned with the slices stack orientation of the StdMultiWidget - void CheckImageAlignment(); - - // checks if given render window aligns with the slices of given image - bool IsRenderWindowAligned(QmitkRenderWindow* renderWindow, mitk::Image* image); - - // make sure all images/segmentations look as selected by the users in this view's preferences - void ForceDisplayPreferencesUponAllImages(); - - // decorates a DataNode according to the user preference settings - void ApplyDisplayOptions(mitk::DataNode* node); - - // GUI setup - void CreateQtPartControl(QWidget* parent); - - // handling of a list of known (organ name, organ color) combination - // ATTENTION these methods are defined in QmitkSegmentationOrganNamesHandling.cpp - QStringList GetDefaultOrganColorString(); - void UpdateOrganList(QStringList& organColors, const QString& organname, mitk::Color colorname); - void AppendToOrganList(QStringList& organColors, const QString& organname, int r, int g, int b); - - // If a contourmarker is selected, the plane in the related widget will be reoriented according to the marker`s geometry - void OnContourMarkerSelected (const mitk::DataNode* node); - - void NodeRemoved(const mitk::DataNode* node); - - // the Qt parent of our GUI (NOT of this object) - QWidget* m_Parent; - - // our GUI - Ui::QmitkSegmentationControls * m_Controls; - - // THE currently existing QmitkStdMultiWidget - QmitkStdMultiWidget * m_MultiWidget; - - // QmitkSegmentationPostProcessing* m_PostProcessing; - - unsigned long m_RenderingManagerObserverTag; - unsigned long m_SlicesRotationObserverTag1; - unsigned long m_SlicesRotationObserverTag2; - unsigned long m_VisibilityChangedObserverTag; - - NodeTagMapType m_WorkingDataObserverTags; -}; - -#endif /*QMITKsegmentationVIEW_H_*/ - diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp deleted file mode 100644 index 36d59dc2c3..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "QmitkStatisticsAction.h" - -QmitkStatisticsAction::QmitkStatisticsAction(): m_BlueBerryView(NULL) -{ -} - -QmitkStatisticsAction::~QmitkStatisticsAction() -{ -} - -void QmitkStatisticsAction::Run(const std::vector& selectedNodes) -{ - berry::IBundle::Pointer imageStatisticsBundle = berry::Platform::GetBundle("org.mitk.gui.qt.imagestatistics"); - - if (m_BlueBerryView && imageStatisticsBundle.IsNotNull()) - { - m_BlueBerryView->GetSite()->GetWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagestatistics"); - } -} - -void QmitkStatisticsAction::SetFunctionality(berry::QtViewPart* functionality) -{ - this->m_BlueBerryView = functionality; -} - -void QmitkStatisticsAction::SetDataStorage(mitk::DataStorage* dataStorage) -{ - //not needed -} - -void QmitkStatisticsAction::SetStdMultiWidget(QmitkStdMultiWidget *) -{ - // not needed -} - -void QmitkStatisticsAction::SetSmoothed(bool smoothed) -{ - //not needed -} - -void QmitkStatisticsAction::SetDecimated(bool decimated) -{ - //not needed -} - diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h deleted file mode 100644 index 5dcff466e0..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef QMITK_STATISTICSACTION_H -#define QMITK_STATISTICSACTION_H - -#include -#include "berryQtViewPart.h" - -#include "mitkIContextMenuAction.h" - -#include "org_mitk_gui_qt_segmentation_Export.h" - -class QmitkStdMultiWidget; - -class MITK_QT_SEGMENTATION QmitkStatisticsAction: public QObject, public mitk::IContextMenuAction -{ - Q_OBJECT - Q_INTERFACES(mitk::IContextMenuAction) - -public: - - QmitkStatisticsAction(); - QmitkStatisticsAction(const QmitkStatisticsAction& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - virtual ~QmitkStatisticsAction(); - - //interface methods - void Run( const std::vector& selectedNodes ); - void SetDataStorage(mitk::DataStorage* dataStorage); - void SetStdMultiWidget(QmitkStdMultiWidget *stdMultiWidget); - void SetSmoothed(bool smoothed); - void SetDecimated(bool decimated); - void SetFunctionality(berry::QtViewPart* functionality); - -protected: - - //needs to be set over the IContextMenuAction (with this - QmitkDataManagerView - as parameter) - berry::QtViewPart* m_BlueBerryView; -}; -#endif // QMITK_STATISTICSACTION_H diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp deleted file mode 100644 index 2f452f77d6..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "QmitkThresholdAction.h" - -// MITK -#include -#include -#include - -// Qt -#include -#include - -using namespace berry; -using namespace mitk; -using namespace std; - -QmitkThresholdAction::QmitkThresholdAction() - : m_ThresholdingDialog(NULL) -{ -} - -QmitkThresholdAction::~QmitkThresholdAction() -{ -} - -void QmitkThresholdAction::Run(const vector &selectedNodes) -{ - m_ThresholdingToolManager = ToolManager::New(m_DataStorage); - - m_ThresholdingToolManager->RegisterClient(); - m_ThresholdingToolManager->ActiveToolChanged += mitk::MessageDelegate(this, &QmitkThresholdAction::OnThresholdingToolManagerToolModified); - - m_ThresholdingDialog = new QDialog; - connect(m_ThresholdingDialog, SIGNAL(finished(int)), this, SLOT(ThresholdingDone(int))); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - - Tool *binaryThresholdTool = m_ThresholdingToolManager->GetToolById(m_ThresholdingToolManager->GetToolIdByToolType()); - - if (binaryThresholdTool != NULL) - { - QmitkToolGUI *gui = dynamic_cast(binaryThresholdTool->GetGUI("Qmitk", "GUI").GetPointer()); - - if (gui != NULL) - { - gui->SetTool(binaryThresholdTool); - gui->setParent(m_ThresholdingDialog); - - layout->addWidget(gui); - - m_ThresholdingDialog->setLayout(layout); - m_ThresholdingDialog->setFixedSize(300, 80); - - m_ThresholdingDialog->open(); - } - - m_ThresholdingToolManager->SetReferenceData(selectedNodes[0]); - m_ThresholdingToolManager->ActivateTool(m_ThresholdingToolManager->GetToolIdByToolType()); - } -} - -void QmitkThresholdAction::ThresholdingDone(int result) -{ - if (result == QDialog::Rejected) - m_ThresholdingToolManager->ActivateTool(-1); - - m_ThresholdingDialog->deleteLater(); - m_ThresholdingDialog = NULL; - - m_ThresholdingToolManager->SetReferenceData(NULL); - m_ThresholdingToolManager->SetWorkingData(NULL); - - RenderingManager::GetInstance()->RequestUpdateAll(); -} - -void QmitkThresholdAction::OnThresholdingToolManagerToolModified() -{ - if (m_ThresholdingToolManager.IsNotNull()) - if (m_ThresholdingToolManager->GetActiveToolID() < 0) - if (m_ThresholdingDialog != NULL) - m_ThresholdingDialog->accept(); -} - -void QmitkThresholdAction::SetDataStorage(DataStorage *dataStorage) -{ - m_DataStorage = dataStorage; -} - -void QmitkThresholdAction::SetStdMultiWidget(QmitkStdMultiWidget *) -{ -} - -void QmitkThresholdAction::SetSmoothed(bool) -{ -} - -void QmitkThresholdAction::SetDecimated(bool) -{ -} - -void QmitkThresholdAction::SetFunctionality(QtViewPart *functionality) -{ -} diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h deleted file mode 100644 index 31c86be488..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef QMITKTHRESHOLDACTION_H -#define QMITKTHRESHOLDACTION_H - -#include - -// Parent classes -#include -#include - -// Data members -#include -#include - -class QDialog; -class QmitkStdMultiWidget; - -class MITK_QT_SEGMENTATION QmitkThresholdAction : public QObject, public mitk::IContextMenuAction -{ - Q_OBJECT - Q_INTERFACES(mitk::IContextMenuAction) - -public: - QmitkThresholdAction(); - ~QmitkThresholdAction(); - - // IContextMenuAction - void Run(const std::vector &selectedNodes); - void SetDataStorage(mitk::DataStorage *dataStorage); - void SetStdMultiWidget(QmitkStdMultiWidget *stdMultiWidget); - void SetSmoothed(bool smoothed); - void SetDecimated(bool decimated); - void SetFunctionality(berry::QtViewPart *functionality); - - void OnThresholdingToolManagerToolModified(); - -private slots: - void ThresholdingDone(int); - -private: - QmitkThresholdAction(const QmitkThresholdAction &); - QmitkThresholdAction & operator=(const QmitkThresholdAction &); - - mitk::DataStorage::Pointer m_DataStorage; - mitk::ToolManager::Pointer m_ThresholdingToolManager; - QDialog *m_ThresholdingDialog; -}; - -#endif diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.cpp deleted file mode 100644 index 1fbdbf86e3..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 17495 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -// Blueberry -#include -#include - -// Qmitk -#include "QmitkRegionGrowingView.h" -#include "QmitkStdMultiWidget.h" - -const std::string QmitkRegionGrowingView::VIEW_ID = "org.mitk.views.regiongrowing"; - -QmitkRegionGrowingView::QmitkRegionGrowingView() -: QmitkFunctionality() -, m_Controls( 0 ) -, m_MultiWidget( NULL ) -{ -} - -QmitkRegionGrowingView::QmitkRegionGrowingView(const QmitkRegionGrowingView& other) -{ - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); -} - -QmitkRegionGrowingView::~QmitkRegionGrowingView() -{ -} - -void QmitkRegionGrowingView::Deactivated() -{ -} - -void QmitkRegionGrowingView::CreateQtPartControl( QWidget *parent ) -{ - // build up qt view, unless already done - if ( !m_Controls ) - { - // create GUI widgets from the Qt Designer's .ui file - m_Controls = new Ui::QmitkRegionGrowingViewControls; - m_Controls->setupUi( parent ); - - m_Controls->m_AdaptiveRGWidget->SetDataStorage(this->GetDataStorage()); - m_Controls->m_AdaptiveRGWidget->CreateConnections(); - } -} - -void QmitkRegionGrowingView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) -{ - m_MultiWidget = &stdMultiWidget; - m_Controls->m_AdaptiveRGWidget->SetMultiWidget(&stdMultiWidget); -} - - -void QmitkRegionGrowingView::StdMultiWidgetNotAvailable() -{ - m_MultiWidget = NULL; -} - - -void QmitkRegionGrowingView::OnSelectionChanged( std::vector nodes ) -{ - // iterate all selected objects, adjust warning visibility - for( std::vector::iterator it = nodes.begin(); - it != nodes.end(); - ++it ) - { - mitk::DataNode::Pointer node = *it; - - if( node.IsNotNull() && dynamic_cast(node->GetData()) ) - { - m_Controls->lblWarning->setVisible( false ); - m_Controls->m_AdaptiveRGWidget->SetInputImageNode(node); - return; - } - } - - m_Controls->lblWarning->setVisible( true ); -} diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.h deleted file mode 100644 index 085a14e157..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.h +++ /dev/null @@ -1,83 +0,0 @@ -/*========================================================================= - -Program: Medical Imaging & Interaction Toolkit -Language: C++ -Date: $Date$ -Version: $Revision: 17495 $ - -Copyright (c) German Cancer Research Center, Division of Medical and -Biological Informatics. All rights reserved. -See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#ifndef QmitkRegionGrowingView_h -#define QmitkRegionGrowingView_h - -#include - -#include - -#include "ui_QmitkRegionGrowingViewControls.h" - - -/*! - \brief QmitkRegionGrowingView - - Functionality for demonstration of MITK basics. - - This functionality allows the user to set some seed points that are used for a simple region growing algorithm from ITK. - - \warning This is only for demonstration, it is NOT meant to be useful! - - \sa QmitkFunctionality - \ingroup Functionalities -*/ -class QmitkRegionGrowingView : public QmitkFunctionality -{ - // this is needed for all Qt objects that should have a Qt meta-object - // (everything that derives from QObject and wants to have signal/slots) - Q_OBJECT - - public: - - static const std::string VIEW_ID; - - QmitkRegionGrowingView(); - QmitkRegionGrowingView(const QmitkRegionGrowingView& other); - virtual ~QmitkRegionGrowingView(); - - virtual void CreateQtPartControl(QWidget *parent); - - virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); - virtual void StdMultiWidgetNotAvailable(); - virtual void Deactivated(); - - protected slots: - - protected: - - /*! - \brief ITK image processing function - This function is templated like an ITK image. The MITK-Macro AccessByItk determines the actual pixel type and dimensionality of - a given MITK image and calls this function for further processing (in our case region growing) - */ - template < typename TPixel, unsigned int VImageDimension > - void ItkImageProcessing( itk::Image< TPixel, VImageDimension >* itkImage, mitk::Geometry3D* imageGeometry, mitk::DataNode* parent, int thresholdOffset, unsigned int t ); - - /// \brief called by QmitkFunctionality when DataManager's selection has changed - virtual void OnSelectionChanged( std::vector nodes ); - - Ui::QmitkRegionGrowingViewControls* m_Controls; - - QmitkStdMultiWidget* m_MultiWidget; -}; - - - -#endif // _QMITKREGIONGROWINGVIEW_H_INCLUDED - diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.toftutorial/documentation/doxygen/modules.dox deleted file mode 100644 index a55ecd8b1c..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.toftutorial/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_toftutorial org.mitk.gui.qt.toftutorial Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_toftutorial_internal Internal - \ingroup org_mitk_gui_qt_toftutorial - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.toftutorial plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.toftutorial/manifest_headers.cmake deleted file mode 100644 index bbad6b940d..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.toftutorial/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK-ToF Tutorial") -set(Plugin-Version "0.1") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "www.mitk.org/wiki/MITK-ToF") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.tofutil/documentation/doxygen/modules.dox deleted file mode 100644 index c4f162c385..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.tofutil/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_tofutil org.mitk.gui.qt.tofutil Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_tofutil_internal Internal - \ingroup org_mitk_gui_qt_tofutil - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.tofutil plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.tofutil/manifest_headers.cmake deleted file mode 100644 index e8b9bbbd26..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.tofutil/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK-ToF Util") -set(Plugin-Version "0.1") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "www.mitk.org/wiki/MITK-ToF") -set(Require-Plugin org.mitk.gui.qt.common) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.ugvisualization/documentation/doxygen/modules.dox deleted file mode 100644 index 8ee430fa0d..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_ugvisualization org.mitk.gui.qt.ugvisualization Plugin - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_ugvisualization_internal Internal - \ingroup org_mitk_gui_qt_ugvisualization - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.ugvisualization plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.ugvisualization/manifest_headers.cmake deleted file mode 100644 index ddff09b506..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK UG Visualization") -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) diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/doxygen/modules.dox deleted file mode 100644 index 65c4b233fe..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_volumevisualization org.mitk.gui.qt.volumevisualization Plugin - \ingroup MITKPlugins - - \brief This is the volume visualization plugin. - -*/ - -/** - \defgroup org_mitk_gui_qt_volumevisualization_internal Internal - \ingroup org_mitk_gui_qt_volumevisualization - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.volumevisualization plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/manifest_headers.cmake b/Modules/Bundles/org.mitk.gui.qt.volumevisualization/manifest_headers.cmake deleted file mode 100644 index b21c7bed81..0000000000 --- a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Volume Visualization") -set(Plugin-Version "1.0.0") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/META-INF/MANIFEST.MF b/Modules/Bundles/org.mitk.inputdevices.spacenavigator/META-INF/MANIFEST.MF deleted file mode 100644 index 486ae05c35..0000000000 --- a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: MITK Input Device Space Navigator -Bundle-SymbolicName: org.mitk.inputdevices.spacenavigator -Bundle-Version: 0.1 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Require-Bundle: org.mitk.core.ext, org.mitk.gui.qt.common -Bundle-Activator: diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/META-INF/MANIFEST.MF b/Modules/Bundles/org.mitk.inputdevices.wiimote/META-INF/MANIFEST.MF deleted file mode 100644 index f8dbb1b702..0000000000 --- a/Modules/Bundles/org.mitk.inputdevices.wiimote/META-INF/MANIFEST.MF +++ /dev/null @@ -1,7 +0,0 @@ -Manifest-Version: 1.0 -Bundle-Name: MITK Input Device WiiMote -Bundle-SymbolicName: org.mitk.inputdevices.wiimote -Bundle-Version: 0.1 -Bundle-Vendor: DKFZ, Medical and Biological Informatics -Require-Bundle: org.mitk.core.ext, org.mitk.gui.qt.common -Bundle-Activator: diff --git a/Modules/Bundles/org.mitk.planarfigure/documentation/doxygen/modules.dox b/Modules/Bundles/org.mitk.planarfigure/documentation/doxygen/modules.dox deleted file mode 100644 index 4f2d0639bc..0000000000 --- a/Modules/Bundles/org.mitk.planarfigure/documentation/doxygen/modules.dox +++ /dev/null @@ -1,19 +0,0 @@ -/** - \defgroup org_mitk_planarfigure org.mitk.planarfigure Plugin - \ingroup MITKPlugins - - \brief This small plug-in is responsible for initializing the PlanarFigure module. - - It is started with an "eager" Bundle-ActivationPolicy, such that the plug-ins - activator is executed before any other (non-eager) plug-ins. - -*/ - -/** - \defgroup org_mitk_planarfigure_internal Internal - \ingroup org_mitk_planarfigure - - \brief This subcategory includes the internal classes of the org.mitk.planarfigure plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index 8d0e82236a..801a9633db 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -1,50 +1,52 @@ SET(LIBPOSTFIX "Ext") +# Modules must be listed according to their dependencies SET(module_dirs SceneSerializationBase PlanarFigure ImageExtraction ImageStatistics LegacyAdaptors IpPicSupport MitkExt SceneSerialization + Qmitk QmitkExt GraphAlgorithms DiffusionImaging GPGPU IGT CameraCalibration IGTUI RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing ToFUI - ClippingTools + ClippingTools ) SET(MITK_DEFAULT_SUBPROJECTS MITK-Modules) FOREACH(module_dir ${module_dirs}) ADD_SUBDIRECTORY(${module_dir}) ENDFOREACH() IF(MITK_PRIVATE_MODULES) FILE(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) FOREACH(subdir ${all_subdirs}) STRING(FIND ${subdir} "." _result) IF(_result EQUAL -1) IF(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) MESSAGE(STATUS "Found private module ${subdir}") ADD_SUBDIRECTORY(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) ENDIF() ENDIF() ENDFOREACH() ENDIF(MITK_PRIVATE_MODULES) diff --git a/Modules/CMakeLists.txt~ b/Modules/CMakeLists.txt~ index b66eed50e5..8d0e82236a 100644 --- a/Modules/CMakeLists.txt~ +++ b/Modules/CMakeLists.txt~ @@ -1,47 +1,50 @@ SET(LIBPOSTFIX "Ext") SET(module_dirs SceneSerializationBase PlanarFigure ImageExtraction ImageStatistics + LegacyAdaptors + IpPicSupport MitkExt SceneSerialization QmitkExt - #GraphAlgorithms + GraphAlgorithms DiffusionImaging GPGPU IGT CameraCalibration IGTUI RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCVVideoSupport Overlays InputDevices ToFHardware ToFProcessing - ToFUI + ToFUI + ClippingTools ) SET(MITK_DEFAULT_SUBPROJECTS MITK-Modules) FOREACH(module_dir ${module_dirs}) ADD_SUBDIRECTORY(${module_dir}) ENDFOREACH() IF(MITK_PRIVATE_MODULES) FILE(GLOB all_subdirs RELATIVE ${MITK_PRIVATE_MODULES} ${MITK_PRIVATE_MODULES}/*) FOREACH(subdir ${all_subdirs}) STRING(FIND ${subdir} "." _result) IF(_result EQUAL -1) IF(EXISTS ${MITK_PRIVATE_MODULES}/${subdir}/CMakeLists.txt) MESSAGE(STATUS "Found private module ${subdir}") ADD_SUBDIRECTORY(${MITK_PRIVATE_MODULES}/${subdir} private_modules/${subdir}) ENDIF() ENDIF() ENDFOREACH() ENDIF(MITK_PRIVATE_MODULES) diff --git a/Modules/DiffusionImaging/Algorithms/itkReduceDirectionGradientsFilter.txx b/Modules/DiffusionImaging/Algorithms/itkReduceDirectionGradientsFilter.txx index bb4e379d0c..4aba95fa5b 100644 --- a/Modules/DiffusionImaging/Algorithms/itkReduceDirectionGradientsFilter.txx +++ b/Modules/DiffusionImaging/Algorithms/itkReduceDirectionGradientsFilter.txx @@ -1,187 +1,192 @@ /*========================================================================= Program: Tensor ToolKit - TTK Module: $URL: svn://scm.gforge.inria.fr/svn/ttk/trunk/Algorithms/itkReduceDirectionGradientsFilter.txx $ Language: C++ Date: $Date: 2010-06-07 13:39:13 +0200 (Mo, 07 Jun 2010) $ Version: $Revision: 68 $ Copyright (c) INRIA 2010. All rights reserved. See LICENSE.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itk_ReduceDirectionGradientsFilter_txx_ #define _itk_ReduceDirectionGradientsFilter_txx_ #endif #define _USE_MATH_DEFINES #include "itkReduceDirectionGradientsFilter.h" #include #include #include #include namespace itk { template ReduceDirectionGradientsFilter ::ReduceDirectionGradientsFilter(): m_Iterations(100000) { this->SetNumberOfRequiredInputs( 1 ); } template double ReduceDirectionGradientsFilter ::Costs() { double costs = 0; int c=0; for (std::vector::iterator it = m_UsedGradientIndices.begin(); it!=m_UsedGradientIndices.end(); ++it) { for (std::vector::iterator it2 = m_UsedGradientIndices.begin()+c; it2!=m_UsedGradientIndices.end(); ++it2) if (*it!=*it2) { vnl_vector_fixed v1 = m_OriginalGradientDirections->at(*it); vnl_vector_fixed v2 = m_OriginalGradientDirections->at(*it2); v1.normalize(); v2.normalize(); double angle = acos(dot_product(v1,v2)); if (angle>0) costs += 1/angle; } c++; } + return costs; } template void ReduceDirectionGradientsFilter ::GenerateData() { srand(time(NULL)); // initialize index vectors m_UsedGradientIndices.clear(); m_UnUsedGradientIndices.clear(); + + if ( m_OriginalGradientDirections->Size()<= m_NumGradientDirections ) + m_NumGradientDirections = m_OriginalGradientDirections->Size(); + int c=0; int numB0 = 0; for (int i=0; iSize(); i++) { vnl_vector_fixed< double, 3 > v = m_OriginalGradientDirections->at(i); v.normalize(); if (fabs(v[0])>0.001 || fabs(v[1])>0.001 || fabs(v[2])>0.001) { if (cSize(); for (unsigned long i=0; iSetSpacing( this->GetInput()->GetSpacing() ); // Set the image spacing outImage->SetOrigin( this->GetInput()->GetOrigin() ); // Set the image origin outImage->SetDirection( this->GetInput()->GetDirection() ); // Set the image direction outImage->SetLargestPossibleRegion( this->GetInput()->GetLargestPossibleRegion()); outImage->SetBufferedRegion( this->GetInput()->GetLargestPossibleRegion() ); outImage->SetRequestedRegion( this->GetInput()->GetLargestPossibleRegion() ); outImage->SetVectorLength(m_NumGradientDirections+numB0); outImage->Allocate(); itk::ImageRegionIterator< OutputImageType > newIt(outImage, outImage->GetLargestPossibleRegion()); newIt.GoToBegin(); typename InputImageType::Pointer inImage = const_cast(this->GetInput(0)); itk::ImageRegionIterator< InputImageType > oldIt(inImage, inImage->GetLargestPossibleRegion()); oldIt.GoToBegin(); // initial new value of voxel OutputPixelType newVec; newVec.SetSize(m_NumGradientDirections+numB0); newVec.AllocateElements(m_NumGradientDirections+numB0); int ind1 = -1; while(!newIt.IsAtEnd()) { // progress typename OutputImageType::IndexType ind = newIt.GetIndex(); ind1 = ind.m_Index[2]; // init new vector with zeros newVec.Fill(0.0); // the old voxel value with duplicates InputPixelType oldVec = oldIt.Get(); for(int i=0; iInsertElement(i, m_OriginalGradientDirections->at(m_BaselineImageIndices.at(i))); for(int i=0; iInsertElement(i+numB0, m_OriginalGradientDirections->at(m_UsedGradientIndices.at(i))); this->SetNumberOfRequiredOutputs (1); this->SetNthOutput (0, outImage); } template std::vector< int > ReduceDirectionGradientsFilter ::GetUsedGradientIndices() { return m_UsedGradientIndices; } } // end of namespace diff --git a/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.h b/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.h index bdabf1d2ba..d9f3f3c36e 100644 --- a/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.h +++ b/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.h @@ -1,97 +1,161 @@ /*========================================================================= Program: Tensor ToolKit - TTK Module: $URL: svn://scm.gforge.inria.fr/svn/ttk/trunk/Algorithms/itkTensorImageToDiffusionImageFilter.h $ Language: C++ Date: $Date: 2010-06-07 13:39:13 +0200 (Mo, 07 Jun 2010) $ Version: $Revision: 68 $ Copyright (c) INRIA 2010. All rights reserved. See LICENSE.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itk_ResidualImageFilter_h_ #define _itk_ResidualImageFilter_h_ #include "itkImageToImageFilter.h" #include + namespace itk { template class ResidualImageFilter : public ImageToImageFilter, itk::Image > { public: typedef TInputScalarType InputScalarType; typedef itk::VectorImage InputImageType; typedef typename InputImageType::PixelType InputPixelType; typedef typename InputImageType::RegionType InputImageRegionType; typedef TOutputScalarType OutputScalarType; typedef itk::Image OutputImageType; typedef typename OutputImageType::PixelType OutputPixelType; typedef typename OutputImageType::RegionType OutputImageRegionType; typedef ResidualImageFilter Self; typedef ImageToImageFilter Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; + typedef vnl_vector_fixed< double, 3 > GradientDirectionType; + typedef itk::VectorContainer< unsigned int, + GradientDirectionType > GradientDirectionContainerType; + + + typedef itk::Image BaselineImageType; + itkTypeMacro (ResidualImageFilter, ImageToImageFilter); itkStaticConstMacro (ImageDimension, unsigned int, OutputImageType::ImageDimension); itkNewMacro (Self); void SetSecondDiffusionImage(typename InputImageType::Pointer diffImage) { m_SecondDiffusionImage = diffImage; } + std::vector GetQ1() + { + return m_Q1; + } + + std::vector GetQ3() + { + return m_Q3; + } + + std::vector GetMeans() + { + return m_Means; + } + + std::vector GetPercentagesOfOutliers() + { + return m_PercentagesOfOutliers; + } + + std::vector< std::vector > GetOutliersPerSlice() + { + return m_OutliersPerSlice; + } + + void SetGradients(GradientDirectionContainerType* grads) + { + m_Gradients = grads; + } + + void SetBaseLineImage(BaselineImageType* baseline) + { + m_BaseLineImage = baseline; + } + + void SetB0Threshold(InputScalarType threshold) + { + m_B0Threshold = threshold; + } + + itkSetMacro(B0Index, int) + protected: ResidualImageFilter() { - + m_B0Threshold = 30.0; // default value. allow user to redefine }; ~ResidualImageFilter(){}; void PrintSelf (std::ostream& os, Indent indent) const { Superclass::PrintSelf (os, indent); } void GenerateData(); private: ResidualImageFilter (const Self&); void operator=(const Self&); typename InputImageType::Pointer m_SecondDiffusionImage; + std::vector m_Means, m_Q1, m_Q3, m_PercentagesOfOutliers; + + + + // 'Outer' vector: slices, 'Inner' volumes + std::vector< std::vector > m_OutliersPerSlice; + + GradientDirectionContainerType* m_Gradients; + + typename BaselineImageType::Pointer m_BaseLineImage; + + InputScalarType m_B0Threshold; + + int m_B0Index; }; } // end of namespace #ifndef ITK_MANUAL_INSTANTIATION #include "itkResidualImageFilter.txx" #endif #endif diff --git a/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.txx b/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.txx index b6dda78610..04a0ea97c4 100644 --- a/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.txx +++ b/Modules/DiffusionImaging/Algorithms/itkResidualImageFilter.txx @@ -1,112 +1,272 @@ /*========================================================================= Program: Tensor ToolKit - TTK Module: $URL: svn://scm.gforge.inria.fr/svn/ttk/trunk/Algorithms/itkTensorImageToDiffusionImageFilter.txx $ Language: C++ Date: $Date: 2010-06-07 13:39:13 +0200 (Mo, 07 Jun 2010) $ Version: $Revision: 68 $ Copyright (c) INRIA 2010. All rights reserved. See LICENSE.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itk_ResidualImageFilter_txx_ #define _itk_ResidualImageFilter_txx_ #endif #include "itkResidualImageFilter.h" #include namespace itk { template void ResidualImageFilter ::GenerateData() { typename InputImageType::SizeType size = this->GetInput()->GetLargestPossibleRegion().GetSize(); typename InputImageType::SizeType size2 = m_SecondDiffusionImage->GetLargestPossibleRegion().GetSize(); if(size != size2) { MITK_ERROR << "Sizes do not match"; return; } // Initialize output image typename OutputImageType::Pointer outputImage = static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0)); outputImage->SetSpacing( this->GetInput()->GetSpacing() ); // Set the image spacing outputImage->SetOrigin( this->GetInput()->GetOrigin() ); // Set the image origin outputImage->SetDirection( this->GetInput()->GetDirection() ); // Set the image direction outputImage->SetRegions( this->GetInput()->GetLargestPossibleRegion() ); outputImage->Allocate(); outputImage->FillBuffer(0.0); - for(int x=0; x > residuals; + + // per slice, per volume + std::vector< std::vector > > residualsPerSlice; + + // Detrmine number of B0 images + int numberB0=0; + for(int i=0; iSize(); i++) + { + GradientDirectionType grad = m_Gradients->ElementAt(i); + if(grad[0] < 0.001 && grad[1] < 0.001 && grad[2] < 0.001) + { + numberB0++; + } + } + + residuals.resize(this->GetInput()->GetVectorLength()-numberB0); + + // Calculate the standard residual image and for each volume put all residuals in a vector + for(int z=0; z > sliceResiduals; // residuals per volume for this slice + sliceResiduals.resize(this->GetInput()->GetVectorLength()-numberB0); + for(int y=0; y ix; ix[0] = x; ix[1] = y; ix[2] = z; + typename InputImageType::PixelType p1 = this->GetInput()->GetPixel(ix); typename InputImageType::PixelType p2 = m_SecondDiffusionImage->GetPixel(ix); + int s1 = p1.GetSize(); + int s2 = p2.GetSize(); if(p1.GetSize() != p2.GetSize()) { MITK_ERROR << "Vector sizes do not match"; return; } - float res = 0; - for(int i = 0; iElementAt(i); + if(!(grad[0] < 0.001 && grad[1] < 0.001 && grad[2] < 0.001)) + { + double val1 = (double)p1.GetElement(i); + double val2 = (double)p2.GetElement(i); + + res += abs(val1-val2); + + residuals[i-shift].push_back(val1-val2); + sliceResiduals[i-shift].push_back(val1-val2); + + } + else + { + shift++; + } + + + } + res = res/p1.GetSize(); + outputImage->SetPixel(ix, res); } } + + residualsPerSlice.push_back(sliceResiduals); + } + + + + + + // for each dw volume: sort the the measured residuals (for each voxel) to enable determining Q1 and Q3; calculate means + // determine percentage of errors as described in QUALITY ASSESSMENT THROUGH ANALYSIS OF RESIDUALS OF DIFFUSION IMAGE FITTING + // Leemans et al 2008 + + double q1,q3, median; + std::vector< std::vector >::iterator it = residuals.begin(); + while(it != residuals.end()) + { + std::vector res = *it; + + // sort + std::sort(res.begin(), res.end()); + + q1 = res[0.25*res.size()]; + m_Q1.push_back(q1); + q3 = res[0.75*res.size()]; + m_Q3.push_back(q3); + + + + median = res[0.5*res.size()]; + double iqr = q3-q1; + double outlierThreshold = median + 1.5*iqr; + double numberOfOutliers = 0.0; + + std::vector::iterator resIt = res.begin(); + double mean; + while(resIt != res.end()) + { + double f = *resIt; + if(f>outlierThreshold) + { + numberOfOutliers++; + } + mean += f; + ++resIt; + } + + double percOfOutliers = 100 * numberOfOutliers / res.size(); + m_PercentagesOfOutliers.push_back(percOfOutliers); + + mean /= res.size(); + m_Means.push_back(mean); + + ++it; + } + + + + // Calculate for each slice the number of outliers per volume(dw volume) + std::vector< std::vector > >::iterator sliceIt = residualsPerSlice.begin(); + + while(sliceIt != residualsPerSlice.end()) + { + std::vector< std::vector > currentSlice = *sliceIt; + std::vector percentages; + + std::vector< std::vector >::iterator volIt = currentSlice.begin(); + while(volIt != currentSlice.end()) + { + + + std::vector currentVolume = *volIt; + + //sort + std::sort(currentVolume.begin(), currentVolume.end()); + + + + q1 = currentVolume[0.25*currentVolume.size()]; + q3 = currentVolume[0.75*currentVolume.size()]; + median = currentVolume[0.5*currentVolume.size()]; + double iqr = q3-q1; + double outlierThreshold = median + 1.5*iqr; + double numberOfOutliers = 0.0; + + std::vector::iterator resIt = currentVolume.begin(); + double mean; + while(resIt != currentVolume.end()) + { + double f = *resIt; + if(f>outlierThreshold) + { + numberOfOutliers++; + } + mean += f; + ++resIt; + } + + double percOfOutliers = 100 * numberOfOutliers / currentVolume.size(); + percentages.push_back(percOfOutliers); + + ++volIt; + } + + m_OutliersPerSlice.push_back(percentages); + + + + ++sliceIt; } - // Superclass::SetNthInput(0, outputImage); } } // end of namespace diff --git a/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.h b/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.h index e8890d6b2b..8f1aaabe36 100644 --- a/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.h +++ b/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.h @@ -1,117 +1,128 @@ /*========================================================================= Program: Tensor ToolKit - TTK Module: $URL: svn://scm.gforge.inria.fr/svn/ttk/trunk/Algorithms/itkTensorImageToDiffusionImageFilter.h $ Language: C++ Date: $Date: 2010-06-07 13:39:13 +0200 (Mo, 07 Jun 2010) $ Version: $Revision: 68 $ Copyright (c) INRIA 2010. All rights reserved. See LICENSE.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _itk_TensorImageToDiffusionImageFilter_h_ #define _itk_TensorImageToDiffusionImageFilter_h_ #include "itkImageToImageFilter.h" #include namespace itk { template class TensorImageToDiffusionImageFilter : public ImageToImageFilter,3>, itk::VectorImage > { public: typedef TInputScalarType InputScalarType; typedef itk::DiffusionTensor3D InputPixelType; typedef itk::Image InputImageType; typedef typename InputImageType::RegionType InputImageRegionType; typedef TOutputScalarType OutputScalarType; typedef itk::VectorImage OutputImageType; typedef typename OutputImageType::PixelType OutputPixelType; typedef typename OutputImageType::RegionType OutputImageRegionType; typedef OutputScalarType BaselineScalarType; typedef BaselineScalarType BaselinePixelType; typedef typename itk::Image BaselineImageType; typedef typename BaselineImageType::RegionType BaselineImageRegionType; typedef TensorImageToDiffusionImageFilter Self; typedef ImageToImageFilter Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; itkTypeMacro (TensorImageToDiffusionImageFilter, ImageToImageFilter); itkStaticConstMacro (ImageDimension, unsigned int, OutputImageType::ImageDimension); itkNewMacro (Self); typedef Vector GradientType; typedef std::vector GradientListType; /** Manually Set/Get a list of gradients */ void SetGradientList(const GradientListType list) { m_GradientList = list; this->Modified(); } GradientListType GetGradientList(void) const {return m_GradientList;} void SetBValue( const double& bval) { m_BValue = bval; } + itkSetMacro(Min, OutputScalarType); + itkSetMacro(Max, OutputScalarType); + + protected: TensorImageToDiffusionImageFilter() { m_BValue = 1.0; m_BaselineImage = 0; + m_Min = 0.0; + m_Max = 10000.0; }; ~TensorImageToDiffusionImageFilter(){}; void PrintSelf (std::ostream& os, Indent indent) const { Superclass::PrintSelf (os, indent); } void BeforeThreadedGenerateData( void ); void ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread, int); //void GenerateData(); + + private: TensorImageToDiffusionImageFilter (const Self&); void operator=(const Self&); GradientListType m_GradientList; double m_BValue; typename BaselineImageType::Pointer m_BaselineImage; + OutputScalarType m_Min; + OutputScalarType m_Max; + }; } // end of namespace #ifndef ITK_MANUAL_INSTANTIATION #include "itkTensorImageToDiffusionImageFilter.txx" #endif #endif diff --git a/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.txx b/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.txx index 935147d0f9..19ef4242ed 100644 --- a/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.txx +++ b/Modules/DiffusionImaging/Algorithms/itkTensorImageToDiffusionImageFilter.txx @@ -1,214 +1,214 @@ /*========================================================================= - -Program: Tensor ToolKit - TTK -Module: $URL: svn://scm.gforge.inria.fr/svn/ttk/trunk/Algorithms/itkTensorImageToDiffusionImageFilter.txx $ -Language: C++ -Date: $Date: 2010-06-07 13:39:13 +0200 (Mo, 07 Jun 2010) $ -Version: $Revision: 68 $ - -Copyright (c) INRIA 2010. All rights reserved. -See LICENSE.txt for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ + 2 + 3 Program: Tensor ToolKit - TTK + 4 Module: $URL: svn://scm.gforge.inria.fr/svn/ttk/trunk/Algorithms/itkTensorImageToDiffusionImageFilter.txx $ + 5 Language: C++ + 6 Date: $Date: 2010-06-07 13:39:13 +0200 (Mo, 07 Jun 2010) $ + 7 Version: $Revision: 68 $ + 8 + 9 Copyright (c) INRIA 2010. All rights reserved. + 10 See LICENSE.txt for details. + 11 + 12 This software is distributed WITHOUT ANY WARRANTY; without even + 13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + 14 PURPOSE. See the above copyright notices for more information. + 15 + 16 =========================================================================*/ #ifndef _itk_TensorImageToDiffusionImageFilter_txx_ #define _itk_TensorImageToDiffusionImageFilter_txx_ #endif #include "itkTensorImageToDiffusionImageFilter.h" #include "itkTensorToL2NormImageFilter.h" #include "itkRescaleIntensityImageFilter.h" #include #include namespace itk { //template //void // TensorImageToDiffusionImageFilter // ::GenerateData() //{ // // Call a method that can be overriden by a subclass to allocate // // memory for the filter's outputs // this->AllocateOutputs(); // // Call a method that can be overridden by a subclass to perform // // some calculations prior to splitting the main computations into // // separate threads // this->BeforeThreadedGenerateData(); // // Set up the multithreaded processing // ThreadStruct str; // str.Filter = this; // this->GetMultiThreader()->SetNumberOfThreads(this->GetNumberOfThreads()); // this->GetMultiThreader()->SetSingleMethod(this->ThreaderCallback, &str); // // multithread the execution // this->GetMultiThreader()->SingleMethodExecute(); // // Call a method that can be overridden by a subclass to perform // // some calculations after all the threads have completed // this->AfterThreadedGenerateData(); //} template void TensorImageToDiffusionImageFilter ::BeforeThreadedGenerateData() { if( m_GradientList.size()==0 ) { throw itk::ExceptionObject (__FILE__,__LINE__,"Error: gradient list is empty, cannot generate DWI."); } // create a B0 image by taking the norm of the tensor field * scale: typedef itk::TensorToL2NormImageFilter > TensorToL2NormFilterType; typename TensorToL2NormFilterType::Pointer myFilter1 = TensorToL2NormFilterType::New(); myFilter1->SetInput (this->GetInput()); try { myFilter1->Update(); } catch (itk::ExceptionObject &e) { std::cerr << e; return; } typename itk::RescaleIntensityImageFilter< itk::Image, BaselineImageType>::Pointer rescaler= itk::RescaleIntensityImageFilter, BaselineImageType>::New(); - rescaler->SetOutputMinimum ( 0 ); - rescaler->SetOutputMaximum ( 10000 ); + rescaler->SetOutputMinimum ( m_Min ); + rescaler->SetOutputMaximum ( m_Max ); rescaler->SetInput ( myFilter1->GetOutput() ); try { rescaler->Update(); } catch (itk::ExceptionObject &e) { std::cerr << e; return; } m_BaselineImage = rescaler->GetOutput(); typename OutputImageType::Pointer outImage = OutputImageType::New(); outImage->SetSpacing( this->GetInput()->GetSpacing() ); // Set the image spacing outImage->SetOrigin( this->GetInput()->GetOrigin() ); // Set the image origin outImage->SetDirection( this->GetInput()->GetDirection() ); // Set the image direction outImage->SetLargestPossibleRegion( this->GetInput()->GetLargestPossibleRegion()); outImage->SetBufferedRegion( this->GetInput()->GetLargestPossibleRegion() ); outImage->SetRequestedRegion( this->GetInput()->GetLargestPossibleRegion() ); outImage->SetVectorLength(m_GradientList.size()); outImage->Allocate(); this->SetNumberOfRequiredOutputs (1); this->SetNthOutput (0, outImage); } template void TensorImageToDiffusionImageFilter ::ThreadedGenerateData ( const OutputImageRegionType &outputRegionForThread, int threadId ) { typedef ImageRegionIterator IteratorOutputType; typedef ImageRegionConstIterator IteratorInputType; typedef ImageRegionConstIterator IteratorBaselineType; unsigned long numPixels = outputRegionForThread.GetNumberOfPixels(); unsigned long step = numPixels/100; unsigned long progress = 0; IteratorOutputType itOut (this->GetOutput(0), outputRegionForThread); IteratorInputType itIn (this->GetInput(), outputRegionForThread); IteratorBaselineType itB0 (m_BaselineImage, outputRegionForThread); if( threadId==0 ) { this->UpdateProgress (0.0); } while(!itIn.IsAtEnd()) { if( this->GetAbortGenerateData() ) { throw itk::ProcessAborted(__FILE__,__LINE__); } InputPixelType T = itIn.Get(); BaselinePixelType b0 = itB0.Get(); OutputPixelType out; out.SetSize(m_GradientList.size()); out.Fill(0); if( b0 > 0) { for( unsigned int i=0; i=0) out[i] = static_cast( 1.0*b0*exp ( -1.0 * m_BValue * res ) ); } } out[m_GradientList.size()-1] = b0; itOut.Set(out); if( threadId==0 && step>0) { if( (progress%step)==0 ) { this->UpdateProgress ( double(progress)/double(numPixels) ); } } ++progress; ++itB0; ++itIn; ++itOut; } if( threadId==0 ) { this->UpdateProgress (1.0); } } } // end of namespace diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp index e55b820c47..6d860362c1 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp @@ -1,1256 +1,1262 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkFiberBundleX.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include #include const char* mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED = "Color_Orient"; //const char* mitk::FiberBundleX::COLORCODING_FA_AS_OPACITY = "Color_Orient_FA_Opacity"; const char* mitk::FiberBundleX::COLORCODING_FA_BASED = "FA_Values"; const char* mitk::FiberBundleX::COLORCODING_CUSTOM = "custom"; const char* mitk::FiberBundleX::FIBER_ID_ARRAY = "Fiber_IDs"; mitk::FiberBundleX::FiberBundleX( vtkPolyData* fiberPolyData ) : m_CurrentColorCoding(NULL) , m_NumFibers(0) { m_FiberPolyData = vtkSmartPointer::New(); if (fiberPolyData != NULL) { + vtkSmartPointer cleaner = vtkSmartPointer::New(); + cleaner->SetInput(fiberPolyData); + cleaner->Update(); + fiberPolyData = cleaner->GetOutput(); + m_FiberPolyData->DeepCopy(fiberPolyData); this->DoColorCodingOrientationBased(); } if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED)) MITK_DEBUG << "ok"; vtkUnsignedCharArray* tmpColors = (vtkUnsignedCharArray*) m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED); if (tmpColors!=NULL) { int tmpColorss = tmpColors->GetNumberOfTuples(); int tmpColorc = tmpColors->GetNumberOfComponents(); } m_NumFibers = m_FiberPolyData->GetNumberOfLines(); this->UpdateFiberGeometry(); this->SetColorCoding(COLORCODING_ORIENTATION_BASED); this->GenerateFiberIds(); } mitk::FiberBundleX::~FiberBundleX() { } mitk::FiberBundleX::Pointer mitk::FiberBundleX::GetDeepCopy() { mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(m_FiberPolyData); if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED)) MITK_DEBUG << "ok"; vtkUnsignedCharArray* tmpColors = (vtkUnsignedCharArray*) m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED); int tmpColorss = tmpColors->GetNumberOfTuples(); int tmpColorc = tmpColors->GetNumberOfComponents(); newFib->SetColorCoding(m_CurrentColorCoding); return newFib; } vtkSmartPointer mitk::FiberBundleX::GeneratePolyDataByIds(std::vector fiberIds) { MITK_DEBUG << "\n=====FINAL RESULT: fib_id ======\n"; MITK_DEBUG << "Number of new Fibers: " << fiberIds.size(); // iterate through the vectorcontainer hosting all desired fiber Ids vtkSmartPointer newFiberPolyData = vtkSmartPointer::New(); vtkSmartPointer newLineSet = vtkSmartPointer::New(); vtkSmartPointer newPointSet = vtkSmartPointer::New(); // if FA array available, initialize fa double array // if color orient array is available init color array vtkSmartPointer faValueArray; vtkSmartPointer colorsT; //colors and alpha value for each single point, RGBA = 4 components unsigned char rgba[4] = {0,0,0,0}; int componentSize = sizeof(rgba); if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_FA_BASED)){ MITK_DEBUG << "FA VALUES AVAILABLE, init array for new fiberbundle"; faValueArray = vtkSmartPointer::New(); } if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED)){ MITK_DEBUG << "colorValues available, init array for new fiberbundle"; colorsT = vtkUnsignedCharArray::New(); colorsT->SetNumberOfComponents(componentSize); colorsT->SetName(COLORCODING_ORIENTATION_BASED); } std::vector::iterator finIt = fiberIds.begin(); while ( finIt != fiberIds.end() ) { if (*finIt < 0 || *finIt>GetNumFibers()){ MITK_INFO << "FiberID can not be negative or >NumFibers!!! check id Extraction!" << *finIt; break; } vtkSmartPointer fiber = m_FiberIdDataSet->GetCell(*finIt);//->DeepCopy(fiber); vtkSmartPointer fibPoints = fiber->GetPoints(); vtkSmartPointer newFiber = vtkSmartPointer::New(); newFiber->GetPointIds()->SetNumberOfIds( fibPoints->GetNumberOfPoints() ); for(int i=0; iGetNumberOfPoints(); i++) { // MITK_DEBUG << "id: " << fiber->GetPointId(i); // MITK_DEBUG << fibPoints->GetPoint(i)[0] << " | " << fibPoints->GetPoint(i)[1] << " | " << fibPoints->GetPoint(i)[2]; newFiber->GetPointIds()->SetId(i, newPointSet->GetNumberOfPoints()); newPointSet->InsertNextPoint(fibPoints->GetPoint(i)[0], fibPoints->GetPoint(i)[1], fibPoints->GetPoint(i)[2]); if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_FA_BASED)){ // MITK_DEBUG << m_FiberIdDataSet->GetPointData()->GetArray(FA_VALUE_ARRAY)->GetTuple(fiber->GetPointId(i)); } if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED)){ // MITK_DEBUG << "ColorValue: " << m_FiberIdDataSet->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)->GetTuple(fiber->GetPointId(i))[0]; } } newLineSet->InsertNextCell(newFiber); ++finIt; } newFiberPolyData->SetPoints(newPointSet); newFiberPolyData->SetLines(newLineSet); MITK_DEBUG << "new fiberbundle polydata points: " << newFiberPolyData->GetNumberOfPoints(); MITK_DEBUG << "new fiberbundle polydata lines: " << newFiberPolyData->GetNumberOfLines(); MITK_DEBUG << "=====================\n"; // mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(newFiberPolyData); return newFiberPolyData; } // merge two fiber bundles mitk::FiberBundleX::Pointer mitk::FiberBundleX::AddBundle(mitk::FiberBundleX* fib) { vtkSmartPointer vNewPolyData = vtkSmartPointer::New(); vtkSmartPointer vNewLines = vtkSmartPointer::New(); vtkSmartPointer vNewPoints = vtkSmartPointer::New(); vtkSmartPointer vLines = m_FiberPolyData->GetLines(); vLines->InitTraversal(); // add current fiber bundle int numFibers = GetNumFibers(); for( int i=0; iGetNextCell ( numPoints, points ); vtkSmartPointer container = vtkSmartPointer::New(); for( int j=0; jInsertNextPoint(m_FiberPolyData->GetPoint(points[j])); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); } vLines = fib->m_FiberPolyData->GetLines(); vLines->InitTraversal(); // add new fiber bundle numFibers = fib->GetNumFibers(); for( int i=0; iGetNextCell ( numPoints, points ); vtkSmartPointer container = vtkSmartPointer::New(); for( int j=0; jInsertNextPoint(fib->m_FiberPolyData->GetPoint(points[j])); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); } // initialize polydata vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // initialize fiber bundle mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(vNewPolyData); return newFib; } // subtract two fiber bundles mitk::FiberBundleX::Pointer mitk::FiberBundleX::SubtractBundle(mitk::FiberBundleX* fib) { vtkSmartPointer vNewPolyData = vtkSmartPointer::New(); vtkSmartPointer vNewLines = vtkSmartPointer::New(); vtkSmartPointer vNewPoints = vtkSmartPointer::New(); vtkSmartPointer vLines = m_FiberPolyData->GetLines(); vLines->InitTraversal(); // iterate over current fibers int numFibers = GetNumFibers(); for( int i=0; iGetNextCell ( numPoints, points ); vtkSmartPointer vLines2 = fib->m_FiberPolyData->GetLines(); vLines2->InitTraversal(); int numFibers2 = fib->GetNumFibers(); bool contained = false; for( int i2=0; i2GetNextCell ( numPoints2, points2 ); // check endpoints itk::Point point_start = GetItkPoint(m_FiberPolyData->GetPoint(points[0])); itk::Point point_end = GetItkPoint(m_FiberPolyData->GetPoint(points[numPoints-1])); itk::Point point2_start = GetItkPoint(fib->m_FiberPolyData->GetPoint(points2[0])); itk::Point point2_end = GetItkPoint(fib->m_FiberPolyData->GetPoint(points2[numPoints2-1])); if (point_start.SquaredEuclideanDistanceTo(point2_start)<=mitk::eps && point_end.SquaredEuclideanDistanceTo(point2_end)<=mitk::eps || point_start.SquaredEuclideanDistanceTo(point2_end)<=mitk::eps && point_end.SquaredEuclideanDistanceTo(point2_start)<=mitk::eps) { // further checking ??? contained = true; } } // add to result because fiber is not subtracted if (!contained) { vtkSmartPointer container = vtkSmartPointer::New(); for( int j=0; jInsertNextPoint(m_FiberPolyData->GetPoint(points[j])); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); } } // initialize polydata vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // initialize fiber bundle mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(vNewPolyData); return newFib; } itk::Point mitk::FiberBundleX::GetItkPoint(double point[3]) { itk::Point itkPoint; itkPoint[0] = point[0]; itkPoint[1] = point[1]; itkPoint[2] = point[2]; return itkPoint; } /* * set polydata (additional flag to recompute fiber geometry, default = true) */ void mitk::FiberBundleX::SetFiberPolyData(vtkSmartPointer fiberPD, bool updateGeometry) { if (fiberPD == NULL) this->m_FiberPolyData = vtkSmartPointer::New(); else { m_FiberPolyData->DeepCopy(fiberPD); DoColorCodingOrientationBased(); } m_NumFibers = m_FiberPolyData->GetNumberOfLines(); if (updateGeometry) UpdateFiberGeometry(); SetColorCoding(COLORCODING_ORIENTATION_BASED); GenerateFiberIds(); } /* * return vtkPolyData */ vtkSmartPointer mitk::FiberBundleX::GetFiberPolyData() { return m_FiberPolyData; } void mitk::FiberBundleX::DoColorCodingOrientationBased() { //===== FOR WRITING A TEST ======================== // colorT size == tupelComponents * tupelElements // compare color results // to cover this code 100% also polydata needed, where colorarray already exists // + one fiber with exactly 1 point // + one fiber with 0 points //================================================= /* make sure that processing colorcoding is only called when necessary */ if ( m_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED) && m_FiberPolyData->GetNumberOfPoints() == m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)->GetNumberOfTuples() ) { // fiberstructure is already colorcoded MITK_DEBUG << " NO NEED TO REGENERATE COLORCODING! " ; this->ResetFiberOpacity(); this->SetColorCoding(COLORCODING_ORIENTATION_BASED); return; } /* Finally, execute color calculation */ vtkPoints* extrPoints = NULL; extrPoints = m_FiberPolyData->GetPoints(); int numOfPoints = 0; if (extrPoints!=NULL) numOfPoints = extrPoints->GetNumberOfPoints(); //colors and alpha value for each single point, RGBA = 4 components unsigned char rgba[4] = {0,0,0,0}; // int componentSize = sizeof(rgba); int componentSize = 4; vtkSmartPointer colorsT = vtkUnsignedCharArray::New(); colorsT->Allocate(numOfPoints * componentSize); colorsT->SetNumberOfComponents(componentSize); colorsT->SetName(COLORCODING_ORIENTATION_BASED); /* checkpoint: does polydata contain any fibers */ int numOfFibers = m_FiberPolyData->GetNumberOfLines(); if (numOfFibers < 1) { MITK_DEBUG << "\n ========= Number of Fibers is 0 and below ========= \n"; return; } /* extract single fibers of fiberBundle */ vtkCellArray* fiberList = m_FiberPolyData->GetLines(); fiberList->InitTraversal(); for (int fi=0; fiGetNextCell(pointsPerFiber, idList); // MITK_DEBUG << "Fib#: " << fi << " of " << numOfFibers << " pnts in fiber: " << pointsPerFiber ; /* single fiber checkpoints: is number of points valid */ if (pointsPerFiber > 1) { /* operate on points of single fiber */ for (int i=0; i 0) { /* The color value of the current point is influenced by the previous point and next point. */ vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = currentPntvtk - nextPntvtk; vnl_vector_fixed< double, 3 > diff2; diff2 = currentPntvtk - prevPntvtk; vnl_vector_fixed< double, 3 > diff; diff = (diff1 - diff2) / 2.0; diff.normalize(); rgba[0] = (unsigned char) (255.0 * std::fabs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::fabs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::fabs(diff[2])); rgba[3] = (unsigned char) (255.0); } else if (i==0) { /* First point has no previous point, therefore only diff1 is taken */ vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = currentPntvtk - nextPntvtk; diff1.normalize(); rgba[0] = (unsigned char) (255.0 * std::fabs(diff1[0])); rgba[1] = (unsigned char) (255.0 * std::fabs(diff1[1])); rgba[2] = (unsigned char) (255.0 * std::fabs(diff1[2])); rgba[3] = (unsigned char) (255.0); } else if (i==pointsPerFiber-1) { /* Last point has no next point, therefore only diff2 is taken */ vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); vnl_vector_fixed< double, 3 > diff2; diff2 = currentPntvtk - prevPntvtk; diff2.normalize(); rgba[0] = (unsigned char) (255.0 * std::fabs(diff2[0])); rgba[1] = (unsigned char) (255.0 * std::fabs(diff2[1])); rgba[2] = (unsigned char) (255.0 * std::fabs(diff2[2])); rgba[3] = (unsigned char) (255.0); } colorsT->InsertTupleValue(idList[i], rgba); } //end for loop } else if (pointsPerFiber == 1) { /* a single point does not define a fiber (use vertex mechanisms instead */ continue; // colorsT->InsertTupleValue(0, rgba); } else { MITK_DEBUG << "Fiber with 0 points detected... please check your tractography algorithm!" ; continue; } }//end for loop m_FiberPolyData->GetPointData()->AddArray(colorsT); /*========================= - this is more relevant for renderer than for fiberbundleX datastructure - think about sourcing this to a explicit method which coordinates colorcoding */ this->SetColorCoding(COLORCODING_ORIENTATION_BASED); // =========================== //mini test, shall be ported to MITK TESTINGS! if (colorsT->GetSize() != numOfPoints*componentSize) MITK_DEBUG << "ALLOCATION ERROR IN INITIATING COLOR ARRAY"; } void mitk::FiberBundleX::DoColorCodingFaBased() { if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_FA_BASED) != 1 ) return; this->SetColorCoding(COLORCODING_FA_BASED); MITK_DEBUG << "FBX: done CC FA based"; this->GenerateFiberIds(); } void mitk::FiberBundleX::DoUseFaFiberOpacity() { if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_FA_BASED) != 1 ) return; if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED) != 1 ) return; vtkDoubleArray* FAValArray = (vtkDoubleArray*) m_FiberPolyData->GetPointData()->GetArray(COLORCODING_FA_BASED); vtkUnsignedCharArray* ColorArray = dynamic_cast (m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)); for(long i=0; iGetNumberOfTuples(); i++) { double faValue = FAValArray->GetValue(i); faValue = faValue * 255.0; ColorArray->SetComponent(i,3, (unsigned char) faValue ); } this->SetColorCoding(COLORCODING_ORIENTATION_BASED); MITK_DEBUG << "FBX: done CC OPACITY"; this->GenerateFiberIds(); } void mitk::FiberBundleX::ResetFiberOpacity() { vtkUnsignedCharArray* ColorArray = dynamic_cast (m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)); for(long i=0; iGetNumberOfTuples(); i++) { ColorArray->SetComponent(i,3, 255.0 ); } } void mitk::FiberBundleX::SetFAMap(mitk::Image::Pointer FAimage) { MITK_DEBUG << "SetFAMap"; vtkSmartPointer faValues = vtkDoubleArray::New(); faValues->SetName(COLORCODING_FA_BASED); faValues->Allocate(m_FiberPolyData->GetNumberOfPoints()); // MITK_DEBUG << faValues->GetNumberOfTuples(); // MITK_DEBUG << faValues->GetSize(); faValues->SetNumberOfValues(m_FiberPolyData->GetNumberOfPoints()); // MITK_DEBUG << faValues->GetNumberOfTuples(); // MITK_DEBUG << faValues->GetSize(); vtkPoints* pointSet = m_FiberPolyData->GetPoints(); for(long i=0; iGetNumberOfPoints(); ++i) { Point3D px; px[0] = pointSet->GetPoint(i)[0]; px[1] = pointSet->GetPoint(i)[1]; px[2] = pointSet->GetPoint(i)[2]; double faPixelValue = FAimage->GetPixelValueByWorldCoordinate(px) * 0.01; // faValues->InsertNextTuple1(faPixelValue); faValues->InsertValue(i, faPixelValue); // MITK_DEBUG << faPixelValue; // MITK_DEBUG << faValues->GetValue(i); } m_FiberPolyData->GetPointData()->AddArray(faValues); this->GenerateFiberIds(); if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_FA_BASED)) MITK_DEBUG << "FA VALUE ARRAY SET"; // vtkDoubleArray* valueArray = (vtkDoubleArray*) m_FiberPolyData->GetPointData()->GetArray(FA_VALUE_ARRAY); // for(long i=0; iGetNumberOfPoints(); i++) // { // MITK_DEBUG << "value at pos "<< i << ": " << valueArray->GetValue(i); // } } void mitk::FiberBundleX::GenerateFiberIds() { if (m_FiberPolyData == NULL) return; vtkSmartPointer idFiberFilter = vtkSmartPointer::New(); idFiberFilter->SetInput(m_FiberPolyData); idFiberFilter->CellIdsOn(); // idFiberFilter->PointIdsOn(); // point id's are not needed idFiberFilter->SetIdsArrayName(FIBER_ID_ARRAY); idFiberFilter->FieldDataOn(); idFiberFilter->Update(); m_FiberIdDataSet = idFiberFilter->GetOutput(); MITK_DEBUG << "Generating Fiber Ids...[done] | " << m_FiberIdDataSet->GetNumberOfCells(); } mitk::FiberBundleX::Pointer mitk::FiberBundleX::ExtractFiberSubset(mitk::PlanarFigure::Pointer pf) { std::vector tmp = ExtractFiberIdSubset(pf); if (tmp.size()<=0) return mitk::FiberBundleX::New(); vtkSmartPointer pTmp = GeneratePolyDataByIds(tmp); return mitk::FiberBundleX::New(pTmp); } std::vector mitk::FiberBundleX::ExtractFiberIdSubset(mitk::PlanarFigure::Pointer pf) { MITK_DEBUG << "Extracting fibers!"; // vector which is returned, contains all extracted FiberIds std::vector FibersInROI; /* Handle type of planarfigure */ // if incoming pf is a pfc mitk::PlanarFigureComposite::Pointer pfcomp= dynamic_cast(pf.GetPointer()); if (!pfcomp.IsNull()) { // process requested boolean operation of PFC switch (pfcomp->getOperationType()) { case 0: { MITK_DEBUG << "AND PROCESSING"; //AND //temporarly store results of the child in this vector, we need that to accumulate the std::vector childResults = this->ExtractFiberIdSubset(pfcomp->getChildAt(0)); MITK_DEBUG << "first roi got fibers in ROI: " << childResults.size(); MITK_DEBUG << "sorting..."; std::sort(childResults.begin(), childResults.end()); MITK_DEBUG << "sorting done"; std::vector AND_Assamblage(childResults.size()); //std::vector AND_Assamblage; fill(AND_Assamblage.begin(), AND_Assamblage.end(), -1); //AND_Assamblage.reserve(childResults.size()); //max size AND can reach anyway std::vector::iterator it; for (int i=1; igetNumberOfChildren(); ++i) { std::vector tmpChild = this->ExtractFiberIdSubset(pfcomp->getChildAt(i)); MITK_DEBUG << "ROI " << i << " has fibers in ROI: " << tmpChild.size(); sort(tmpChild.begin(), tmpChild.end()); it = std::set_intersection(childResults.begin(), childResults.end(), tmpChild.begin(), tmpChild.end(), AND_Assamblage.begin() ); } MITK_DEBUG << "resize Vector"; long i=0; while (i < AND_Assamblage.size() && AND_Assamblage[i] != -1){ //-1 represents a placeholder in the array ++i; } AND_Assamblage.resize(i); MITK_DEBUG << "returning AND vector, size: " << AND_Assamblage.size(); return AND_Assamblage; // break; } case 1: { //OR std::vector OR_Assamblage = this->ExtractFiberIdSubset(pfcomp->getChildAt(0)); std::vector::iterator it; MITK_DEBUG << OR_Assamblage.size(); for (int i=1; igetNumberOfChildren(); ++i) { it = OR_Assamblage.end(); std::vector tmpChild = this->ExtractFiberIdSubset(pfcomp->getChildAt(i)); OR_Assamblage.insert(it, tmpChild.begin(), tmpChild.end()); MITK_DEBUG << "ROI " << i << " has fibers in ROI: " << tmpChild.size() << " OR Assamblage: " << OR_Assamblage.size(); } sort(OR_Assamblage.begin(), OR_Assamblage.end()); it = unique(OR_Assamblage.begin(), OR_Assamblage.end()); OR_Assamblage.resize( it - OR_Assamblage.begin() ); MITK_DEBUG << "returning OR vector, size: " << OR_Assamblage.size(); return OR_Assamblage; } case 2: { //NOT //get IDs of all fibers std::vector childResults; childResults.reserve(this->GetNumFibers()); vtkSmartPointer idSet = m_FiberIdDataSet->GetCellData()->GetArray(FIBER_ID_ARRAY); MITK_DEBUG << "m_NumOfFib: " << this->GetNumFibers() << " cellIdNum: " << idSet->GetNumberOfTuples(); for(long i=0; iGetNumFibers(); i++) { MITK_DEBUG << "i: " << i << " idset: " << idSet->GetTuple(i)[0]; childResults.push_back(idSet->GetTuple(i)[0]); } std::sort(childResults.begin(), childResults.end()); std::vector NOT_Assamblage(childResults.size()); //fill it with -1, otherwise 0 will be stored and 0 can also be an ID of fiber! fill(NOT_Assamblage.begin(), NOT_Assamblage.end(), -1); std::vector::iterator it; for (long i=0; igetNumberOfChildren(); ++i) { std::vector tmpChild = ExtractFiberIdSubset(pfcomp->getChildAt(i)); sort(tmpChild.begin(), tmpChild.end()); it = std::set_difference(childResults.begin(), childResults.end(), tmpChild.begin(), tmpChild.end(), NOT_Assamblage.begin() ); } MITK_DEBUG << "resize Vector"; long i=0; while (NOT_Assamblage[i] != -1){ //-1 represents a placeholder in the array ++i; } NOT_Assamblage.resize(i); return NOT_Assamblage; } default: MITK_DEBUG << "we have an UNDEFINED composition... ERROR" ; break; } } else { mitk::Geometry2D::ConstPointer pfgeometry = pf->GetGeometry2D(); const mitk::PlaneGeometry* planeGeometry = dynamic_cast (pfgeometry.GetPointer()); Vector3D planeNormal = planeGeometry->GetNormal(); planeNormal.Normalize(); Point3D planeOrigin = planeGeometry->GetOrigin(); MITK_DEBUG << "planeOrigin: " << planeOrigin[0] << " | " << planeOrigin[1] << " | " << planeOrigin[2] << endl; MITK_DEBUG << "planeNormal: " << planeNormal[0] << " | " << planeNormal[1] << " | " << planeNormal[2] << endl; std::vector PointsOnPlane; // contains all pointIds which are crossing the cutting plane std::vector PointsInROI; // based on PointsOnPlane, all ROI relevant point IDs are stored here /* Define cutting plane by ROI (PlanarFigure) */ vtkSmartPointer plane = vtkSmartPointer::New(); plane->SetOrigin(planeOrigin[0],planeOrigin[1],planeOrigin[2]); plane->SetNormal(planeNormal[0],planeNormal[1],planeNormal[2]); //same plane but opposite normal direction. so point cloud will be reduced -> better performance // vtkSmartPointer planeR = vtkSmartPointer::New(); //define new origin along the normal but close to the original one // OriginNew = OriginOld + 1*Normal // Vector3D extendedNormal; // int multiplyFactor = 1; // extendedNormal[0] = planeNormal[0] * multiplyFactor; // extendedNormal[1] = planeNormal[1] * multiplyFactor; // extendedNormal[2] = planeNormal[2] * multiplyFactor; // Point3D RplaneOrigin = planeOrigin - extendedNormal; // planeR->SetOrigin(RplaneOrigin[0],RplaneOrigin[1],RplaneOrigin[2]); // planeR->SetNormal(-planeNormal[0],-planeNormal[1],-planeNormal[2]); // MITK_DEBUG << "RPlaneOrigin: " << RplaneOrigin[0] << " | " << RplaneOrigin[1] // << " | " << RplaneOrigin[2]; /* get all points/fibers cutting the plane */ MITK_DEBUG << "start clipping"; vtkSmartPointer clipper = vtkSmartPointer::New(); clipper->SetInput(m_FiberIdDataSet); clipper->SetClipFunction(plane); clipper->GenerateClipScalarsOn(); clipper->GenerateClippedOutputOn(); vtkSmartPointer clipperout = clipper->GetClippedOutput(); MITK_DEBUG << "end clipping"; /* for some reason clipperoutput is not initialized for futher processing * so far only writing out clipped polydata provides requested */ // MITK_DEBUG << "writing clipper output"; // vtkSmartPointer writerC = vtkSmartPointer::New(); // writerC->SetInput(clipperout1); // writerC->SetFileName("/vtkOutput/Clipping.vtk"); // writerC->SetFileTypeToASCII(); // writerC->Write(); // MITK_DEBUG << "writing done"; MITK_DEBUG << "init and update clipperoutput"; clipperout->GetPointData()->Initialize(); clipperout->Update(); MITK_DEBUG << "init and update clipperoutput completed"; // MITK_DEBUG << "start clippingRecursive"; // vtkSmartPointer Rclipper = vtkSmartPointer::New(); // Rclipper->SetInput(clipperout1); // Rclipper->SetClipFunction(planeR); // Rclipper->GenerateClipScalarsOn(); // Rclipper->GenerateClippedOutputOn(); // vtkSmartPointer clipperout = Rclipper->GetClippedOutput(); // MITK_DEBUG << "end clipping recursive"; // MITK_DEBUG << "writing clipper output 2"; // vtkSmartPointer writerC1 = vtkSmartPointer::New(); // writerC1->SetInput(clipperout); // writerC1->SetFileName("/vtkOutput/RClipping.vtk"); // writerC1->SetFileTypeToASCII(); // writerC1->Write(); // MITK_DEBUG << "init and update clipperoutput"; // clipperout->GetPointData()->Initialize(); // clipperout->Update(); // MITK_DEBUG << "init and update clipperoutput completed"; MITK_DEBUG << "STEP 1: find all points which have distance 0 to the given plane"; /*======STEP 1====== * extract all points, which are crossing the plane */ // Scalar values describe the distance between each remaining point to the given plane. Values sorted by point index vtkSmartPointer distanceList = clipperout->GetPointData()->GetScalars(); vtkIdType sizeOfList = distanceList->GetNumberOfTuples(); PointsOnPlane.reserve(sizeOfList); /* use reserve for high-performant push_back, no hidden copy procedures are processed then! * size of list can be optimized by reducing allocation, but be aware of iterator and vector size*/ for (int i=0; iGetTuple(i); // check if point is on plane. // 0.01 due to some approximation errors when calculating distance if (distance[0] >= -0.01 && distance[0] <= 0.01) PointsOnPlane.push_back(i); } // DEBUG print out all interesting points, stop where array starts with value -1. after -1 no more interesting idx are set! // std::vector::iterator rit = PointsOnPlane.begin(); // while (rit != PointsOnPlane.end() ) { // std::cout << "interesting point: " << *rit << " coord: " << clipperout->GetPoint(*rit)[0] << " | " << clipperout->GetPoint(*rit)[1] << " | " << clipperout->GetPoint(*rit)[2] << endl; // rit++; // } MITK_DEBUG << "Num Of points on plane: " << PointsOnPlane.size(); MITK_DEBUG << "Step 2: extract Interesting points with respect to given extraction planarFigure"; PointsInROI.reserve(PointsOnPlane.size()); /*=======STEP 2===== * extract ROI relevant pointIds */ mitk::PlanarCircle::Pointer circleName = mitk::PlanarCircle::New(); mitk::PlanarPolygon::Pointer polyName = mitk::PlanarPolygon::New(); if ( pf->GetNameOfClass() == circleName->GetNameOfClass() ) { //calculate circle radius mitk::Point3D V1w = pf->GetWorldControlPoint(0); //centerPoint mitk::Point3D V2w = pf->GetWorldControlPoint(1); //radiusPoint double distPF = V1w.EuclideanDistanceTo(V2w); for (int i=0; iGetPoint(PointsOnPlane[i])[0] - V1w[0]) * (clipperout->GetPoint(PointsOnPlane[i])[0] - V1w[0]) + (clipperout->GetPoint(PointsOnPlane[i])[1] - V1w[1]) * (clipperout->GetPoint(PointsOnPlane[i])[1] - V1w[1]) + (clipperout->GetPoint(PointsOnPlane[i])[2] - V1w[2]) * (clipperout->GetPoint(PointsOnPlane[i])[2] - V1w[2])) ; if( XdistPnt <= distPF) PointsInROI.push_back(PointsOnPlane[i]); } } else if ( pf->GetNameOfClass() == polyName->GetNameOfClass() ) { //create vtkPolygon using controlpoints from planarFigure polygon vtkSmartPointer polygonVtk = vtkPolygon::New(); //get the control points from pf and insert them to vtkPolygon unsigned int nrCtrlPnts = pf->GetNumberOfControlPoints(); for (int i=0; iGetPoints()->InsertNextPoint((double)pf->GetWorldControlPoint(i)[0], (double)pf->GetWorldControlPoint(i)[1], (double)pf->GetWorldControlPoint(i)[2] ); } //prepare everything for using pointInPolygon function double n[3]; polygonVtk->ComputeNormal(polygonVtk->GetPoints()->GetNumberOfPoints(), static_cast(polygonVtk->GetPoints()->GetData()->GetVoidPointer(0)), n); double bounds[6]; polygonVtk->GetPoints()->GetBounds(bounds); for (int i=0; iGetPoint(PointsOnPlane[i])[0], clipperout->GetPoint(PointsOnPlane[i])[1], clipperout->GetPoint(PointsOnPlane[i])[2]}; int isInPolygon = polygonVtk->PointInPolygon(checkIn, polygonVtk->GetPoints()->GetNumberOfPoints() , static_cast(polygonVtk->GetPoints()->GetData()->GetVoidPointer(0)), bounds, n); if( isInPolygon ) PointsInROI.push_back(PointsOnPlane[i]); } } MITK_DEBUG << "Step3: Identify fibers"; // we need to access the fiberId Array, so make sure that this array is available if (!clipperout->GetCellData()->HasArray(FIBER_ID_ARRAY)) { MITK_DEBUG << "ERROR: FiberID array does not exist, no correlation between points and fiberIds possible! Make sure calling GenerateFiberIds()"; return FibersInROI; // FibersInRoi is empty then } if (PointsInROI.size()<=0) return FibersInROI; // prepare a structure where each point id is represented as an indexId. // vector looks like: | pntId | fiberIdx | std::vector< long > pointindexFiberMap; // walk through the whole subline section and create an vector sorted by point index vtkCellArray *clipperlines = clipperout->GetLines(); clipperlines->InitTraversal(); long numOfLineCells = clipperlines->GetNumberOfCells(); long numofClippedPoints = clipperout->GetNumberOfPoints(); pointindexFiberMap.reserve(numofClippedPoints); //prepare resulting vector FibersInROI.reserve(PointsInROI.size()); MITK_DEBUG << "\n===== Pointindex based structure initialized ======\n"; // go through resulting "sub"lines which are stored as cells, "i" corresponds to current line id. for (int i=0, ic=0 ; iGetCell(ic, npts, pts); // go through point ids in hosting subline, "j" corresponds to current pointindex in current line i. eg. idx[0]=45; idx[1]=46 for (long j=0; jGetCellData()->GetArray(FIBER_ID_ARRAY)->GetTuple(i)[0] << " to pointId: " << pts[j]; pointindexFiberMap[ pts[j] ] = clipperout->GetCellData()->GetArray(FIBER_ID_ARRAY)->GetTuple(i)[0]; // MITK_DEBUG << "in array: " << pointindexFiberMap[ pts[j] ]; } } MITK_DEBUG << "\n===== Pointindex based structure finalized ======\n"; // get all Points in ROI with according fiberID for (long k = 0; k < PointsInROI.size(); k++) { //MITK_DEBUG << "point " << PointsInROI[k] << " belongs to fiber " << pointindexFiberMap[ PointsInROI[k] ]; if (pointindexFiberMap[ PointsInROI[k] ]<=GetNumFibers() && pointindexFiberMap[ PointsInROI[k] ]>=0) FibersInROI.push_back(pointindexFiberMap[ PointsInROI[k] ]); else MITK_INFO << "ERROR in ExtractFiberIdSubset; impossible fiber id detected"; } } // detecting fiberId duplicates MITK_DEBUG << "check for duplicates"; sort(FibersInROI.begin(), FibersInROI.end()); bool hasDuplicats = false; for(long i=0; i::iterator it; it = unique (FibersInROI.begin(), FibersInROI.end()); FibersInROI.resize( it - FibersInROI.begin() ); } return FibersInROI; } void mitk::FiberBundleX::UpdateFiberGeometry() { if (m_NumFibers<=0) { mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); geometry->SetImageGeometry(true); float b[] = {0, 1, 0, 1, 0, 1}; geometry->SetFloatBounds(b); SetGeometry(geometry); return; } float min = itk::NumericTraits::min(); float max = itk::NumericTraits::max(); float b[] = {max, min, max, min, max, min}; vtkCellArray* cells = m_FiberPolyData->GetLines(); cells->InitTraversal(); for (int i=0; iGetNumberOfCells(); i++) { vtkCell* cell = m_FiberPolyData->GetCell(i); int p = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); for (int j=0; jGetPoint(j, p); if (p[0]b[1]) b[1]=p[0]; if (p[1]b[3]) b[3]=p[1]; if (p[2]b[5]) b[5]=p[2]; } } // provide some border margin for(int i=0; i<=4; i+=2) b[i] -=10; for(int i=1; i<=5; i+=2) b[i] +=10; mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); geometry->SetImageGeometry(true); geometry->SetFloatBounds(b); this->SetGeometry(geometry); } QStringList mitk::FiberBundleX::GetAvailableColorCodings() { QStringList availableColorCodings; int numColors = m_FiberPolyData->GetPointData()->GetNumberOfArrays(); for(int i=0; iGetPointData()->GetArrayName(i)); } //this controlstructure shall be implemented by the calling method if (availableColorCodings.isEmpty()) MITK_DEBUG << "no colorcodings available in fiberbundleX"; // for(int i=0; im_CurrentColorCoding = (char*) COLORCODING_ORIENTATION_BASED; } else if( strcmp (COLORCODING_FA_BASED,requestedColorCoding) == 0 ) { this->m_CurrentColorCoding = (char*) COLORCODING_FA_BASED; } else if( strcmp (COLORCODING_CUSTOM,requestedColorCoding) == 0 ) { this->m_CurrentColorCoding = (char*) COLORCODING_CUSTOM; } else { MITK_DEBUG << "FIBERBUNDLE X: UNKNOWN COLORCODING in FIBERBUNDLEX Datastructure"; this->m_CurrentColorCoding = (char*) COLORCODING_CUSTOM; //will cause blank colorcoding of fibers } } void mitk::FiberBundleX::DoFiberSmoothing(int pointsPerCm) { vtkSmartPointer vtkSmoothPoints = vtkPoints::New(); //in smoothpoints the interpolated points representing a fiber are stored. //in vtkcells all polylines are stored, actually all id's of them are stored vtkSmartPointer vtkSmoothCells = vtkCellArray::New(); //cellcontainer for smoothed lines vtkSmartPointer vLines = m_FiberPolyData->GetLines(); vLines->InitTraversal(); vtkIdType pointHelperCnt = 0; for (int i=0; iGetNextCell ( numPoints, pointIds ); vtkSmartPointer points = vtkSmartPointer::New(); float length = 0; itk::Point lastP; for (int j=0; jGetPoint(pointIds[j]); points->InsertNextPoint(p); if (j>0) length += sqrt(pow(p[0]-lastP[0], 2)+pow(p[1]-lastP[1], 2)+pow(p[2]-lastP[2], 2)); lastP[0] = p[0]; lastP[1] = p[1]; lastP[2] = p[2]; } length /=10; int sampling = pointsPerCm*length; /////PROCESS POLYLINE SMOOTHING///// vtkSmartPointer xSpline = vtkKochanekSpline::New(); vtkSmartPointer ySpline = vtkKochanekSpline::New(); vtkSmartPointer zSpline = vtkKochanekSpline::New(); vtkSmartPointer spline = vtkParametricSpline::New(); spline->SetXSpline(xSpline); spline->SetYSpline(ySpline); spline->SetZSpline(zSpline); spline->SetPoints(points); vtkSmartPointer functionSource = vtkParametricFunctionSource::New(); functionSource->SetParametricFunction(spline); functionSource->SetUResolution(sampling); functionSource->SetVResolution(sampling); functionSource->SetWResolution(sampling); functionSource->Update(); vtkPolyData* outputFunction = functionSource->GetOutput(); vtkPoints* tmpSmoothPnts = outputFunction->GetPoints(); //smoothPoints of current fiber vtkSmartPointer smoothLine = vtkPolyLine::New(); smoothLine->GetPointIds()->SetNumberOfIds(tmpSmoothPnts->GetNumberOfPoints()); for (int j=0; jGetNumberOfPoints(); j++) { smoothLine->GetPointIds()->SetId(j, j+pointHelperCnt); vtkSmoothPoints->InsertNextPoint(tmpSmoothPnts->GetPoint(j)); } vtkSmoothCells->InsertNextCell(smoothLine); pointHelperCnt += tmpSmoothPnts->GetNumberOfPoints(); } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkSmoothPoints); m_FiberPolyData->SetLines(vtkSmoothCells); UpdateColorCoding(); UpdateFiberGeometry(); } // Resample fiber to get equidistant points void mitk::FiberBundleX::ResampleFibers(float pointDistance) { vtkSmartPointer newPoly = vtkSmartPointer::New(); vtkSmartPointer newCellArray = vtkSmartPointer::New(); vtkSmartPointer newPoints = vtkSmartPointer::New(); vtkSmartPointer vLines = m_FiberPolyData->GetLines(); vLines->InitTraversal(); int numberOfLines = m_NumFibers; for (int i=0; iGetNextCell ( numPoints, points ); vtkSmartPointer container = vtkSmartPointer::New(); double* point = m_FiberPolyData->GetPoint(points[0]); vtkIdType pointId = newPoints->InsertNextPoint(point); container->GetPointIds()->InsertNextId(pointId); float dtau = 0; int cur_p = 1; itk::Vector dR; float normdR = 0; for (;;) { while (dtau <= pointDistance && cur_p < numPoints) { itk::Vector v1; point = m_FiberPolyData->GetPoint(points[cur_p-1]); v1[0] = point[0]; v1[1] = point[1]; v1[2] = point[2]; itk::Vector v2; point = m_FiberPolyData->GetPoint(points[cur_p]); v2[0] = point[0]; v2[1] = point[1]; v2[2] = point[2]; dR = v2 - v1; normdR = std::sqrt(dR.GetSquaredNorm()); dtau += normdR; cur_p++; } if (dtau >= pointDistance) { itk::Vector v1; point = m_FiberPolyData->GetPoint(points[cur_p-1]); v1[0] = point[0]; v1[1] = point[1]; v1[2] = point[2]; itk::Vector v2 = v1 - dR*( (dtau-pointDistance)/normdR ); pointId = newPoints->InsertNextPoint(v2.GetDataPointer()); container->GetPointIds()->InsertNextId(pointId); } else { point = m_FiberPolyData->GetPoint(points[numPoints-1]); pointId = newPoints->InsertNextPoint(point); container->GetPointIds()->InsertNextId(pointId); break; } dtau = dtau-pointDistance; } newCellArray->InsertNextCell(container); } newPoly->SetPoints(newPoints); newPoly->SetLines(newCellArray); m_FiberPolyData = newPoly; UpdateFiberGeometry(); UpdateColorCoding(); } // reapply selected colorcoding in case polydata structure has changed void mitk::FiberBundleX::UpdateColorCoding() { char* cc = GetCurrentColorCoding(); if( strcmp (COLORCODING_ORIENTATION_BASED,cc) == 0 ) DoColorCodingOrientationBased(); else if( strcmp (COLORCODING_FA_BASED,cc) == 0 ) DoColorCodingFaBased(); } /* ESSENTIAL IMPLEMENTATION OF SUPERCLASS METHODS */ void mitk::FiberBundleX::UpdateOutputInformation() { } void mitk::FiberBundleX::SetRequestedRegionToLargestPossibleRegion() { } bool mitk::FiberBundleX::RequestedRegionIsOutsideOfTheBufferedRegion() { return false; } bool mitk::FiberBundleX::VerifyRequestedRegion() { return true; } void mitk::FiberBundleX::SetRequestedRegion( itk::DataObject *data ) { } diff --git a/Modules/IGT/Testing/files.cmake b/Modules/IGT/Testing/files.cmake index 52cf36db56..aa68b50c05 100644 --- a/Modules/IGT/Testing/files.cmake +++ b/Modules/IGT/Testing/files.cmake @@ -1,49 +1,49 @@ SET(MODULE_TESTS mitkCameraVisualizationTest.cpp mitkClaronInterfaceTest.cpp mitkClaronToolTest.cpp mitkClaronTrackingDeviceTest.cpp mitkInternalTrackingToolTest.cpp mitkNavigationDataDisplacementFilterTest.cpp mitkNavigationDataLandmarkTransformFilterTest.cpp mitkNavigationDataObjectVisualizationFilterTest.cpp mitkNavigationDataTest.cpp mitkNavigationDataRecorderTest.cpp mitkNavigationDataReferenceTransformFilterTest.cpp mitkNavigationDataSequentialPlayerTest.cpp mitkNavigationDataToMessageFilterTest.cpp mitkNavigationDataToNavigationDataFilterTest.cpp mitkNavigationDataToPointSetFilterTest.cpp mitkNavigationDataTransformFilterTest.cpp mitkNDIPassiveToolTest.cpp mitkNDIProtocolTest.cpp mitkNDITrackingDeviceTest.cpp mitkTimeStampTest.cpp mitkTrackingVolumeGeneratorTest.cpp mitkTrackingDeviceTest.cpp mitkTrackingToolTest.cpp # This test fails randomly, see bug #8033 mitkVirtualTrackingDeviceTest.cpp mitkNavigationDataPlayerTest.cpp mitkTrackingDeviceSourceTest.cpp mitkTrackingDeviceSourceConfiguratorTest.cpp mitkNavigationDataEvaluationFilterTest.cpp mitkTrackingTypesTest.cpp # ------------------ Navigation Tool Management Tests ------------------- mitkNavigationToolStorageTest.cpp - mitkNavigationToolStorageSerializerAndDeserializerTest.cpp + #mitkNavigationToolStorageSerializerAndDeserializerTest.cpp #deactivated, see bug #10701 mitkNavigationToolTest.cpp - mitkNavigationToolReaderAndWriterTest.cpp #deactivated, see bug #3461 + mitkNavigationToolReaderAndWriterTest.cpp # ----------------------------------------------------------------------- # ------------------ Deavtivated Tests ---------------------------------- # ----------------------------------------------------------------------- ) SET(MODULE_CUSTOM_TESTS mitkNDIAuroraHardwareTest.cpp mitkNDIPolarisHardwareTest.cpp mitkClaronTrackingDeviceHardwareTest.cpp -) +) \ No newline at end of file diff --git a/Modules/ImageStatistics/mitkImageStatisticsCalculator.cpp b/Modules/ImageStatistics/mitkImageStatisticsCalculator.cpp index 453a0d101c..a463bdbff6 100644 --- a/Modules/ImageStatistics/mitkImageStatisticsCalculator.cpp +++ b/Modules/ImageStatistics/mitkImageStatisticsCalculator.cpp @@ -1,1035 +1,1055 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkImageStatisticsCalculator.h" #include "mitkImageAccessByItk.h" #include "mitkImageCast.h" #include "mitkExtractImageFilter.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if ( ( VTK_MAJOR_VERSION <= 5 ) && ( VTK_MINOR_VERSION<=8) ) #include "mitkvtkLassoStencilSource.h" #else #include "vtkLassoStencilSource.h" #endif #include #include - - namespace mitk { ImageStatisticsCalculator::ImageStatisticsCalculator() : m_MaskingMode( MASKING_MODE_NONE ), m_MaskingModeChanged( false ), m_IgnorePixelValue(0.0), m_DoIgnorePixelValue(false), m_IgnorePixelValueChanged(false) { m_EmptyHistogram = HistogramType::New(); HistogramType::SizeType histogramSize; histogramSize.Fill( 256 ); m_EmptyHistogram->Initialize( histogramSize ); m_EmptyStatistics.Reset(); } ImageStatisticsCalculator::~ImageStatisticsCalculator() { } void ImageStatisticsCalculator::SetImage( const mitk::Image *image ) { if ( m_Image != image ) { m_Image = image; this->Modified(); unsigned int numberOfTimeSteps = image->GetTimeSteps(); // Initialize vectors to time-size of this image m_ImageHistogramVector.resize( numberOfTimeSteps ); m_MaskedImageHistogramVector.resize( numberOfTimeSteps ); m_PlanarFigureHistogramVector.resize( numberOfTimeSteps ); m_ImageStatisticsVector.resize( numberOfTimeSteps ); m_MaskedImageStatisticsVector.resize( numberOfTimeSteps ); m_PlanarFigureStatisticsVector.resize( numberOfTimeSteps ); m_ImageStatisticsTimeStampVector.resize( numberOfTimeSteps ); m_MaskedImageStatisticsTimeStampVector.resize( numberOfTimeSteps ); m_PlanarFigureStatisticsTimeStampVector.resize( numberOfTimeSteps ); m_ImageStatisticsCalculationTriggerVector.resize( numberOfTimeSteps ); m_MaskedImageStatisticsCalculationTriggerVector.resize( numberOfTimeSteps ); m_PlanarFigureStatisticsCalculationTriggerVector.resize( numberOfTimeSteps ); for ( unsigned int t = 0; t < image->GetTimeSteps(); ++t ) { m_ImageStatisticsTimeStampVector[t].Modified(); m_ImageStatisticsCalculationTriggerVector[t] = true; } } } void ImageStatisticsCalculator::SetImageMask( const mitk::Image *imageMask ) { if ( m_Image.IsNull() ) { itkExceptionMacro( << "Image needs to be set first!" ); } if ( m_Image->GetTimeSteps() != imageMask->GetTimeSteps() ) { itkExceptionMacro( << "Image and image mask need to have equal number of time steps!" ); } if ( m_ImageMask != imageMask ) { m_ImageMask = imageMask; this->Modified(); for ( unsigned int t = 0; t < m_Image->GetTimeSteps(); ++t ) { m_MaskedImageStatisticsTimeStampVector[t].Modified(); m_MaskedImageStatisticsCalculationTriggerVector[t] = true; } } } void ImageStatisticsCalculator::SetPlanarFigure( mitk::PlanarFigure *planarFigure ) { if ( m_Image.IsNull() ) { itkExceptionMacro( << "Image needs to be set first!" ); } if ( m_PlanarFigure != planarFigure ) { m_PlanarFigure = planarFigure; this->Modified(); for ( unsigned int t = 0; t < m_Image->GetTimeSteps(); ++t ) { m_PlanarFigureStatisticsTimeStampVector[t].Modified(); m_PlanarFigureStatisticsCalculationTriggerVector[t] = true; } } } void ImageStatisticsCalculator::SetMaskingMode( unsigned int mode ) { if ( m_MaskingMode != mode ) { m_MaskingMode = mode; m_MaskingModeChanged = true; this->Modified(); } } void ImageStatisticsCalculator::SetMaskingModeToNone() { if ( m_MaskingMode != MASKING_MODE_NONE ) { m_MaskingMode = MASKING_MODE_NONE; m_MaskingModeChanged = true; this->Modified(); } } void ImageStatisticsCalculator::SetMaskingModeToImage() { if ( m_MaskingMode != MASKING_MODE_IMAGE ) { m_MaskingMode = MASKING_MODE_IMAGE; m_MaskingModeChanged = true; this->Modified(); } } void ImageStatisticsCalculator::SetMaskingModeToPlanarFigure() { if ( m_MaskingMode != MASKING_MODE_PLANARFIGURE ) { m_MaskingMode = MASKING_MODE_PLANARFIGURE; m_MaskingModeChanged = true; this->Modified(); } } void ImageStatisticsCalculator::SetIgnorePixelValue(double value) { if ( m_IgnorePixelValue != value ) { m_IgnorePixelValue = value; if(m_DoIgnorePixelValue) { m_IgnorePixelValueChanged = true; } this->Modified(); } } double ImageStatisticsCalculator::GetIgnorePixelValue() { return m_IgnorePixelValue; } void ImageStatisticsCalculator::SetDoIgnorePixelValue(bool value) { if ( m_DoIgnorePixelValue != value ) { m_DoIgnorePixelValue = value; m_IgnorePixelValueChanged = true; this->Modified(); } } bool ImageStatisticsCalculator::GetDoIgnorePixelValue() { return m_DoIgnorePixelValue; } bool ImageStatisticsCalculator::ComputeStatistics( unsigned int timeStep ) { if ( m_Image.IsNull() ) { itkExceptionMacro( << "Image not set!" ); } if ( m_Image->GetReferenceCount() == 1 ) { // Image no longer valid; we are the only ones to still hold a reference on it return false; } if ( timeStep >= m_Image->GetTimeSteps() ) { throw std::runtime_error( "Error: invalid time step!" ); } // If a mask was set but we are the only ones to still hold a reference on // it, delete it. if ( m_ImageMask.IsNotNull() && (m_ImageMask->GetReferenceCount() == 1) ) { m_ImageMask = NULL; } // Check if statistics is already up-to-date unsigned long imageMTime = m_ImageStatisticsTimeStampVector[timeStep].GetMTime(); unsigned long maskedImageMTime = m_MaskedImageStatisticsTimeStampVector[timeStep].GetMTime(); unsigned long planarFigureMTime = m_PlanarFigureStatisticsTimeStampVector[timeStep].GetMTime(); bool imageStatisticsCalculationTrigger = m_ImageStatisticsCalculationTriggerVector[timeStep]; bool maskedImageStatisticsCalculationTrigger = m_MaskedImageStatisticsCalculationTriggerVector[timeStep]; bool planarFigureStatisticsCalculationTrigger = m_PlanarFigureStatisticsCalculationTriggerVector[timeStep]; if ( !m_IgnorePixelValueChanged && ((m_MaskingMode != MASKING_MODE_NONE) || (imageMTime > m_Image->GetMTime() && !imageStatisticsCalculationTrigger)) && ((m_MaskingMode != MASKING_MODE_IMAGE) || (maskedImageMTime > m_ImageMask->GetMTime() && !maskedImageStatisticsCalculationTrigger)) && ((m_MaskingMode != MASKING_MODE_PLANARFIGURE) || (planarFigureMTime > m_PlanarFigure->GetMTime() && !planarFigureStatisticsCalculationTrigger)) ) { // Statistics is up to date! if ( m_MaskingModeChanged ) { m_MaskingModeChanged = false; return true; } else { return false; } } // Reset state changed flag m_MaskingModeChanged = false; m_IgnorePixelValueChanged = false; // Depending on masking mode, extract and/or generate the required image // and mask data from the user input this->ExtractImageAndMask( timeStep ); Statistics *statistics; HistogramType::ConstPointer *histogram; switch ( m_MaskingMode ) { case MASKING_MODE_NONE: default: { if(!m_DoIgnorePixelValue) { statistics = &m_ImageStatisticsVector[timeStep]; histogram = &m_ImageHistogramVector[timeStep]; m_ImageStatisticsTimeStampVector[timeStep].Modified(); m_ImageStatisticsCalculationTriggerVector[timeStep] = false; } else { statistics = &m_MaskedImageStatisticsVector[timeStep]; histogram = &m_MaskedImageHistogramVector[timeStep]; m_MaskedImageStatisticsTimeStampVector[timeStep].Modified(); m_MaskedImageStatisticsCalculationTriggerVector[timeStep] = false; } break; } case MASKING_MODE_IMAGE: statistics = &m_MaskedImageStatisticsVector[timeStep]; histogram = &m_MaskedImageHistogramVector[timeStep]; m_MaskedImageStatisticsTimeStampVector[timeStep].Modified(); m_MaskedImageStatisticsCalculationTriggerVector[timeStep] = false; break; case MASKING_MODE_PLANARFIGURE: statistics = &m_PlanarFigureStatisticsVector[timeStep]; histogram = &m_PlanarFigureHistogramVector[timeStep]; m_PlanarFigureStatisticsTimeStampVector[timeStep].Modified(); m_PlanarFigureStatisticsCalculationTriggerVector[timeStep] = false; break; } // Calculate statistics and histogram(s) if ( m_InternalImage->GetDimension() == 3 ) { if ( m_MaskingMode == MASKING_MODE_NONE && !m_DoIgnorePixelValue ) { AccessFixedDimensionByItk_2( m_InternalImage, InternalCalculateStatisticsUnmasked, 3, *statistics, histogram ); } else { AccessFixedDimensionByItk_3( m_InternalImage, InternalCalculateStatisticsMasked, 3, m_InternalImageMask3D.GetPointer(), *statistics, histogram ); } } else if ( m_InternalImage->GetDimension() == 2 ) { if ( m_MaskingMode == MASKING_MODE_NONE && !m_DoIgnorePixelValue ) { AccessFixedDimensionByItk_2( m_InternalImage, InternalCalculateStatisticsUnmasked, 2, *statistics, histogram ); } else { AccessFixedDimensionByItk_3( m_InternalImage, InternalCalculateStatisticsMasked, 2, m_InternalImageMask2D.GetPointer(), *statistics, histogram ); } } else { MITK_ERROR << "ImageStatistics: Image dimension not supported!"; } // Release unused image smart pointers to free memory m_InternalImage = mitk::Image::ConstPointer(); m_InternalImageMask3D = MaskImage3DType::Pointer(); m_InternalImageMask2D = MaskImage2DType::Pointer(); return true; } const ImageStatisticsCalculator::HistogramType * ImageStatisticsCalculator::GetHistogram( unsigned int timeStep ) const { if ( m_Image.IsNull() || (timeStep >= m_Image->GetTimeSteps()) ) { return NULL; } switch ( m_MaskingMode ) { case MASKING_MODE_NONE: default: { if(m_DoIgnorePixelValue) return m_MaskedImageHistogramVector[timeStep]; return m_ImageHistogramVector[timeStep]; } case MASKING_MODE_IMAGE: return m_MaskedImageHistogramVector[timeStep]; case MASKING_MODE_PLANARFIGURE: return m_PlanarFigureHistogramVector[timeStep]; } } const ImageStatisticsCalculator::Statistics & ImageStatisticsCalculator::GetStatistics( unsigned int timeStep ) const { if ( m_Image.IsNull() || (timeStep >= m_Image->GetTimeSteps()) ) { return m_EmptyStatistics; } switch ( m_MaskingMode ) { case MASKING_MODE_NONE: default: { if(m_DoIgnorePixelValue) return m_MaskedImageStatisticsVector[timeStep]; return m_ImageStatisticsVector[timeStep]; } case MASKING_MODE_IMAGE: return m_MaskedImageStatisticsVector[timeStep]; case MASKING_MODE_PLANARFIGURE: return m_PlanarFigureStatisticsVector[timeStep]; } } void ImageStatisticsCalculator::ExtractImageAndMask( unsigned int timeStep ) { if ( m_Image.IsNull() ) { throw std::runtime_error( "Error: image empty!" ); } if ( timeStep >= m_Image->GetTimeSteps() ) { throw std::runtime_error( "Error: invalid time step!" ); } ImageTimeSelector::Pointer imageTimeSelector = ImageTimeSelector::New(); imageTimeSelector->SetInput( m_Image ); imageTimeSelector->SetTimeNr( timeStep ); imageTimeSelector->UpdateLargestPossibleRegion(); mitk::Image *timeSliceImage = imageTimeSelector->GetOutput(); switch ( m_MaskingMode ) { case MASKING_MODE_NONE: { m_InternalImage = timeSliceImage; m_InternalImageMask2D = NULL; m_InternalImageMask3D = NULL; if(m_DoIgnorePixelValue) { if( m_InternalImage->GetDimension() == 3 ) { CastToItkImage( timeSliceImage, m_InternalImageMask3D ); m_InternalImageMask3D->FillBuffer(1); } if( m_InternalImage->GetDimension() == 2 ) { CastToItkImage( timeSliceImage, m_InternalImageMask2D ); m_InternalImageMask2D->FillBuffer(1); } } break; } case MASKING_MODE_IMAGE: { if ( m_ImageMask.IsNotNull() && (m_ImageMask->GetReferenceCount() > 1) ) { if ( timeStep < m_ImageMask->GetTimeSteps() ) { ImageTimeSelector::Pointer maskedImageTimeSelector = ImageTimeSelector::New(); maskedImageTimeSelector->SetInput( m_ImageMask ); maskedImageTimeSelector->SetTimeNr( timeStep ); maskedImageTimeSelector->UpdateLargestPossibleRegion(); mitk::Image *timeSliceMaskedImage = maskedImageTimeSelector->GetOutput(); m_InternalImage = timeSliceImage; CastToItkImage( timeSliceMaskedImage, m_InternalImageMask3D ); } else { throw std::runtime_error( "Error: image mask has not enough time steps!" ); } } else { throw std::runtime_error( "Error: image mask empty!" ); } break; } case MASKING_MODE_PLANARFIGURE: { m_InternalImageMask2D = NULL; if ( m_PlanarFigure.IsNull() ) { throw std::runtime_error( "Error: planar figure empty!" ); } if ( !m_PlanarFigure->IsClosed() ) { throw std::runtime_error( "Masking not possible for non-closed figures" ); } const Geometry3D *imageGeometry = timeSliceImage->GetGeometry(); if ( imageGeometry == NULL ) { throw std::runtime_error( "Image geometry invalid!" ); } const Geometry2D *planarFigureGeometry2D = m_PlanarFigure->GetGeometry2D(); if ( planarFigureGeometry2D == NULL ) { throw std::runtime_error( "Planar-Figure not yet initialized!" ); } const PlaneGeometry *planarFigureGeometry = dynamic_cast< const PlaneGeometry * >( planarFigureGeometry2D ); if ( planarFigureGeometry == NULL ) { throw std::runtime_error( "Non-planar planar figures not supported!" ); } // Find principal direction of PlanarFigure in input image unsigned int axis; if ( !this->GetPrincipalAxis( imageGeometry, planarFigureGeometry->GetNormal(), axis ) ) { throw std::runtime_error( "Non-aligned planar figures not supported!" ); } // Find slice number corresponding to PlanarFigure in input image MaskImage3DType::IndexType index; imageGeometry->WorldToIndex( planarFigureGeometry->GetOrigin(), index ); unsigned int slice = index[axis]; // Extract slice with given position and direction from image ExtractImageFilter::Pointer imageExtractor = ExtractImageFilter::New(); imageExtractor->SetInput( timeSliceImage ); imageExtractor->SetSliceDimension( axis ); imageExtractor->SetSliceIndex( slice ); imageExtractor->Update(); m_InternalImage = imageExtractor->GetOutput(); // Compute mask from PlanarFigure AccessFixedDimensionByItk_1( m_InternalImage, InternalCalculateMaskFromPlanarFigure, 2, axis ); } } if(m_DoIgnorePixelValue) { if ( m_InternalImage->GetDimension() == 3 ) { AccessFixedDimensionByItk_1( m_InternalImage, InternalMaskIgnoredPixels, 3, m_InternalImageMask3D.GetPointer() ); } else if ( m_InternalImage->GetDimension() == 2 ) { AccessFixedDimensionByItk_1( m_InternalImage, InternalMaskIgnoredPixels, 2, m_InternalImageMask2D.GetPointer() ); } } } bool ImageStatisticsCalculator::GetPrincipalAxis( const Geometry3D *geometry, Vector3D vector, unsigned int &axis ) { vector.Normalize(); for ( unsigned int i = 0; i < 3; ++i ) { Vector3D axisVector = geometry->GetAxisVector( i ); axisVector.Normalize(); if ( fabs( fabs( axisVector * vector ) - 1.0) < mitk::eps ) { axis = i; return true; } } return false; } template < typename TPixel, unsigned int VImageDimension > void ImageStatisticsCalculator::InternalCalculateStatisticsUnmasked( const itk::Image< TPixel, VImageDimension > *image, Statistics &statistics, typename HistogramType::ConstPointer *histogram ) { typedef itk::Image< TPixel, VImageDimension > ImageType; typedef itk::Image< unsigned short, VImageDimension > MaskImageType; typedef typename ImageType::IndexType IndexType; typedef itk::Statistics::ScalarImageToHistogramGenerator< ImageType > HistogramGeneratorType; // Progress listening... typedef itk::SimpleMemberCommand< ImageStatisticsCalculator > ITKCommandType; ITKCommandType::Pointer progressListener; progressListener = ITKCommandType::New(); progressListener->SetCallbackFunction( this, &ImageStatisticsCalculator::UnmaskedStatisticsProgressUpdate ); // Issue 100 artificial progress events since ScalarIMageToHistogramGenerator // does not (yet?) support progress reporting this->InvokeEvent( itk::StartEvent() ); for ( unsigned int i = 0; i < 100; ++i ) { this->UnmaskedStatisticsProgressUpdate(); } // Calculate histogram typename HistogramGeneratorType::Pointer histogramGenerator = HistogramGeneratorType::New(); histogramGenerator->SetInput( image ); histogramGenerator->SetMarginalScale( 100 ); // Defines y-margin width of histogram histogramGenerator->SetNumberOfBins( 768 ); // CT range [-1024, +2048] --> bin size 4 values histogramGenerator->SetHistogramMin( -1024.0 ); histogramGenerator->SetHistogramMax( 2048.0 ); histogramGenerator->Compute(); *histogram = histogramGenerator->GetOutput(); // Calculate statistics (separate filter) typedef itk::StatisticsImageFilter< ImageType > StatisticsFilterType; typename StatisticsFilterType::Pointer statisticsFilter = StatisticsFilterType::New(); statisticsFilter->SetInput( image ); unsigned long observerTag = statisticsFilter->AddObserver( itk::ProgressEvent(), progressListener ); statisticsFilter->Update(); statisticsFilter->RemoveObserver( observerTag ); this->InvokeEvent( itk::EndEvent() ); statistics.N = image->GetBufferedRegion().GetNumberOfPixels(); statistics.Min = statisticsFilter->GetMinimum(); statistics.Max = statisticsFilter->GetMaximum(); statistics.Mean = statisticsFilter->GetMean(); statistics.Median = 0.0; statistics.Sigma = statisticsFilter->GetSigma(); statistics.RMS = sqrt( statistics.Mean * statistics.Mean + statistics.Sigma * statistics.Sigma ); } template < typename TPixel, unsigned int VImageDimension > void ImageStatisticsCalculator::InternalMaskIgnoredPixels( const itk::Image< TPixel, VImageDimension > *image, itk::Image< unsigned short, VImageDimension > *maskImage ) { typedef itk::Image< TPixel, VImageDimension > ImageType; typedef itk::Image< unsigned short, VImageDimension > MaskImageType; itk::ImageRegionIterator itmask(maskImage, maskImage->GetLargestPossibleRegion()); itk::ImageRegionConstIterator itimage(image, image->GetLargestPossibleRegion()); itmask = itmask.Begin(); itimage = itimage.Begin(); while( !itmask.IsAtEnd() ) { if(m_IgnorePixelValue == itimage.Get()) { itmask.Set(0); } ++itmask; ++itimage; } } template < typename TPixel, unsigned int VImageDimension > void ImageStatisticsCalculator::InternalCalculateStatisticsMasked( const itk::Image< TPixel, VImageDimension > *image, itk::Image< unsigned short, VImageDimension > *maskImage, Statistics &statistics, typename HistogramType::ConstPointer *histogram ) { typedef itk::Image< TPixel, VImageDimension > ImageType; typedef itk::Image< unsigned short, VImageDimension > MaskImageType; typedef typename ImageType::IndexType IndexType; typedef typename ImageType::PointType PointType; typedef typename ImageType::SpacingType SpacingType; typedef itk::LabelStatisticsImageFilter< ImageType, MaskImageType > LabelStatisticsFilterType; typedef itk::ChangeInformationImageFilter< MaskImageType > ChangeInformationFilterType; typedef itk::ExtractImageFilter< ImageType, ImageType > ExtractImageFilterType; // Make sure that mask is set if ( maskImage == NULL ) { itkExceptionMacro( << "Mask image needs to be set!" ); } // Make sure that spacing of mask and image are the same SpacingType imageSpacing = image->GetSpacing(); SpacingType maskSpacing = maskImage->GetSpacing(); PointType zeroPoint; zeroPoint.Fill( 0.0 ); if ( (zeroPoint + imageSpacing).SquaredEuclideanDistanceTo( (zeroPoint + maskSpacing) ) > mitk::eps ) { itkExceptionMacro( << "Mask needs to have same spacing as image! (Image spacing: " << imageSpacing << "; Mask spacing: " << maskSpacing << ")" ); } + // Make sure that orientation of mask and image are the same + typedef typename ImageType::DirectionType DirectionType; + DirectionType imageDirection = image->GetDirection(); + DirectionType maskDirection = maskImage->GetDirection(); + for( int i = 0; i < imageDirection.ColumnDimensions; ++i ) + { + for( int j = 0; j < imageDirection.ColumnDimensions; ++j ) + { + double differenceDirection = imageDirection[i][j] - maskDirection[i][j]; + if ( fabs( differenceDirection ) > mitk::eps ) + { + itkExceptionMacro( << "Mask needs to have same direction as image! (Image direction: " << imageDirection << "; Mask direction: " << maskDirection << ")" ); + } + } + } // Make sure that the voxels of mask and image are correctly "aligned", i.e., voxel boundaries are the same in both images PointType imageOrigin = image->GetOrigin(); PointType maskOrigin = maskImage->GetOrigin(); long offset[ImageType::ImageDimension]; + + typedef itk::ContinuousIndex ContinousIndexType; + ContinousIndexType maskOriginContinousIndex, imageOriginContinousIndex; + + image->TransformPhysicalPointToContinuousIndex(maskOrigin, maskOriginContinousIndex); + image->TransformPhysicalPointToContinuousIndex(imageOrigin, imageOriginContinousIndex); + for ( unsigned int i = 0; i < ImageType::ImageDimension; ++i ) { - double indexCoordDistance = (maskOrigin[i] - imageOrigin[i]) / imageSpacing[i]; - double misalignment = indexCoordDistance - floor( indexCoordDistance + 0.5 ); - if ( fabs( misalignment ) > imageSpacing[i] / 20.0 ) + double misalignment = maskOriginContinousIndex[i] - floor( maskOriginContinousIndex[i] + 0.5 ); + if ( fabs( misalignment ) > mitk::eps ) { itkExceptionMacro( << "Pixels/voxels of mask and image are not sufficiently aligned! (Misalignment: " << misalignment << ")" ); } + double indexCoordDistance = maskOriginContinousIndex[i] - imageOriginContinousIndex[i]; offset[i] = (int) indexCoordDistance + image->GetBufferedRegion().GetIndex()[i]; } // Adapt the origin and region (index/size) of the mask so that the origin of both are the same typename ChangeInformationFilterType::Pointer adaptMaskFilter; adaptMaskFilter = ChangeInformationFilterType::New(); adaptMaskFilter->ChangeOriginOn(); adaptMaskFilter->ChangeRegionOn(); adaptMaskFilter->SetInput( maskImage ); adaptMaskFilter->SetOutputOrigin( image->GetOrigin() ); adaptMaskFilter->SetOutputOffset( offset ); adaptMaskFilter->Update(); typename MaskImageType::Pointer adaptedMaskImage = adaptMaskFilter->GetOutput(); // Make sure that mask region is contained within image region if ( !image->GetLargestPossibleRegion().IsInside( adaptedMaskImage->GetLargestPossibleRegion() ) ) { itkExceptionMacro( << "Mask region needs to be inside of image region! (Image region: " << image->GetLargestPossibleRegion() << "; Mask region: " << adaptedMaskImage->GetLargestPossibleRegion() << ")" ); } // If mask region is smaller than image region, extract the sub-sampled region from the original image typename ImageType::SizeType imageSize = image->GetBufferedRegion().GetSize(); typename ImageType::SizeType maskSize = maskImage->GetBufferedRegion().GetSize(); bool maskSmallerImage = false; for ( unsigned int i = 0; i < ImageType::ImageDimension; ++i ) { if ( maskSize[i] < imageSize[i] ) { maskSmallerImage = true; } } typename ImageType::ConstPointer adaptedImage; if ( maskSmallerImage ) { typename ExtractImageFilterType::Pointer extractImageFilter = ExtractImageFilterType::New(); extractImageFilter->SetInput( image ); extractImageFilter->SetExtractionRegion( adaptedMaskImage->GetBufferedRegion() ); extractImageFilter->Update(); adaptedImage = extractImageFilter->GetOutput(); } else { adaptedImage = image; } // Initialize Filter typename LabelStatisticsFilterType::Pointer labelStatisticsFilter; labelStatisticsFilter = LabelStatisticsFilterType::New(); labelStatisticsFilter->SetInput( adaptedImage ); labelStatisticsFilter->SetLabelInput( adaptedMaskImage ); labelStatisticsFilter->UseHistogramsOn(); labelStatisticsFilter->SetHistogramParameters( 384, -1024.0, 2048.0); // Add progress listening typedef itk::SimpleMemberCommand< ImageStatisticsCalculator > ITKCommandType; ITKCommandType::Pointer progressListener; progressListener = ITKCommandType::New(); progressListener->SetCallbackFunction( this, &ImageStatisticsCalculator::MaskedStatisticsProgressUpdate ); unsigned long observerTag = labelStatisticsFilter->AddObserver( itk::ProgressEvent(), progressListener ); // Execute filter this->InvokeEvent( itk::StartEvent() ); // Make sure that only the mask region is considered (otherwise, if the mask region is smaller // than the image region, the Update() would result in an exception). labelStatisticsFilter->GetOutput()->SetRequestedRegion( adaptedMaskImage->GetLargestPossibleRegion() ); // Execute the filter labelStatisticsFilter->Update(); this->InvokeEvent( itk::EndEvent() ); labelStatisticsFilter->RemoveObserver( observerTag ); // Find label of mask (other than 0) bool maskNonEmpty = false; unsigned int i; for ( i = 1; i < 4096; ++i ) { if ( labelStatisticsFilter->HasLabel( i ) ) { maskNonEmpty = true; break; } } if ( maskNonEmpty ) { *histogram = labelStatisticsFilter->GetHistogram( i ); statistics.N = labelStatisticsFilter->GetCount( i ); statistics.Min = labelStatisticsFilter->GetMinimum( i ); statistics.Max = labelStatisticsFilter->GetMaximum( i ); statistics.Mean = labelStatisticsFilter->GetMean( i ); statistics.Median = labelStatisticsFilter->GetMedian( i ); statistics.Sigma = labelStatisticsFilter->GetSigma( i ); statistics.RMS = sqrt( statistics.Mean * statistics.Mean + statistics.Sigma * statistics.Sigma ); } else { *histogram = m_EmptyHistogram; statistics.Reset(); } } template < typename TPixel, unsigned int VImageDimension > void ImageStatisticsCalculator::InternalCalculateMaskFromPlanarFigure( const itk::Image< TPixel, VImageDimension > *image, unsigned int axis ) { typedef itk::Image< TPixel, VImageDimension > ImageType; typedef itk::CastImageFilter< ImageType, MaskImage2DType > CastFilterType; // Generate mask image as new image with same header as input image and // initialize with "1". typename CastFilterType::Pointer castFilter = CastFilterType::New(); castFilter->SetInput( image ); castFilter->Update(); castFilter->GetOutput()->FillBuffer( 1 ); // all PolylinePoints of the PlanarFigure are stored in a vtkPoints object. // These points are used by the vtkLassoStencilSource to create // a vtkImageStencil. const mitk::Geometry2D *planarFigureGeometry2D = m_PlanarFigure->GetGeometry2D(); const typename PlanarFigure::PolyLineType planarFigurePolyline = m_PlanarFigure->GetPolyLine( 0 ); const mitk::Geometry3D *imageGeometry3D = m_Image->GetGeometry( 0 ); // Determine x- and y-dimensions depending on principal axis int i0, i1; switch ( axis ) { case 0: i0 = 1; i1 = 2; break; case 1: i0 = 0; i1 = 2; break; case 2: default: i0 = 0; i1 = 1; break; } // store the polyline contour as vtkPoints object bool outOfBounds = false; vtkSmartPointer points = vtkPoints::New(); typename PlanarFigure::PolyLineType::const_iterator it; for ( it = planarFigurePolyline.begin(); it != planarFigurePolyline.end(); ++it ) { Point3D point3D; // Convert 2D point back to the local index coordinates of the selected // image planarFigureGeometry2D->Map( it->Point, point3D ); // Polygons (partially) outside of the image bounds can not be processed // further due to a bug in vtkPolyDataToImageStencil if ( !imageGeometry3D->IsInside( point3D ) ) { outOfBounds = true; } imageGeometry3D->WorldToIndex( point3D, point3D ); points->InsertNextPoint( point3D[i0], point3D[i1], 0 ); } if ( outOfBounds ) { throw std::runtime_error( "Figure at least partially outside of image bounds!" ); } // create a vtkLassoStencilSource and set the points of the Polygon vtkSmartPointer lassoStencil = vtkLassoStencilSource::New(); lassoStencil->SetShapeToPolygon(); lassoStencil->SetPoints( points ); // Export from ITK to VTK (to use a VTK filter) typedef itk::VTKImageImport< MaskImage2DType > ImageImportType; typedef itk::VTKImageExport< MaskImage2DType > ImageExportType; typename ImageExportType::Pointer itkExporter = ImageExportType::New(); itkExporter->SetInput( castFilter->GetOutput() ); vtkSmartPointer vtkImporter = vtkImageImport::New(); this->ConnectPipelines( itkExporter, vtkImporter ); // Apply the generated image stencil to the input image vtkSmartPointer imageStencilFilter = vtkImageStencil::New(); imageStencilFilter->SetInputConnection( vtkImporter->GetOutputPort() ); imageStencilFilter->SetStencil( lassoStencil->GetOutput() ); imageStencilFilter->ReverseStencilOff(); imageStencilFilter->SetBackgroundValue( 0 ); imageStencilFilter->Update(); // Export from VTK back to ITK vtkSmartPointer vtkExporter = vtkImageExport::New(); vtkExporter->SetInputConnection( imageStencilFilter->GetOutputPort() ); vtkExporter->Update(); typename ImageImportType::Pointer itkImporter = ImageImportType::New(); this->ConnectPipelines( vtkExporter, itkImporter ); itkImporter->Update(); // Store mask m_InternalImageMask2D = itkImporter->GetOutput(); // Clean up VTK objects vtkImporter->Delete(); imageStencilFilter->Delete(); //vtkExporter->Delete(); // TODO: crashes when outcommented; memory leak?? } void ImageStatisticsCalculator::UnmaskedStatisticsProgressUpdate() { // Need to throw away every second progress event to reach a final count of // 100 since two consecutive filters are used in this case static int updateCounter = 0; if ( updateCounter++ % 2 == 0 ) { this->InvokeEvent( itk::ProgressEvent() ); } } void ImageStatisticsCalculator::MaskedStatisticsProgressUpdate() { this->InvokeEvent( itk::ProgressEvent() ); } } diff --git a/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.cpp b/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.cpp index 2d1fe3e3fe..546d20a67b 100644 --- a/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.cpp +++ b/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.cpp @@ -1,235 +1,237 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkSplineVtkMapper3D.h" #include #include #include #include #include #include #include #include #include #include #include #include #include mitk::SplineVtkMapper3D::SplineVtkMapper3D() : m_SplinesAvailable (false), m_SplinesAddedToAssembly(false) { m_SplinesActor = vtkActor::New(); m_SplineAssembly = vtkPropAssembly::New(); m_SplineResolution = 500; } mitk::SplineVtkMapper3D::~SplineVtkMapper3D() { m_SplinesActor->Delete(); m_SplineAssembly->Delete(); } vtkProp* mitk::SplineVtkMapper3D::GetVtkProp(mitk::BaseRenderer * /*renderer*/) { return m_SplineAssembly; } void mitk::SplineVtkMapper3D::UpdateVtkTransform(mitk::BaseRenderer * /*renderer*/) { vtkLinearTransform * vtktransform = this->GetDataNode()->GetVtkTransform(this->GetTimestep()); m_SplinesActor->SetUserTransform(vtktransform); } void mitk::SplineVtkMapper3D::GenerateData() { Superclass::GenerateData(); // only update spline if UpdateSpline has not been called from // external, e.g. by the SplineMapper2D. But call it the first time when m_SplineUpdateTime = 0 and m_LastUpdateTime = 0. if ( m_SplineUpdateTime < m_LastUpdateTime || m_SplineUpdateTime == 0) { this->UpdateSpline(); - this->ApplyProperties(); + this->ApplyProperties(m_SplinesActor, NULL); } if ( m_SplinesAvailable ) { if ( ! m_SplinesAddedToAssembly ) { m_SplineAssembly->AddPart( m_SplinesActor ); m_SplinesAddedToAssembly = true; } } else { if ( m_SplinesAddedToAssembly ) { m_SplineAssembly->RemovePart( m_SplinesActor ); m_SplinesAddedToAssembly = false; } } } void mitk::SplineVtkMapper3D::GenerateDataForRenderer( mitk::BaseRenderer* renderer ) { if ( IsVisible( renderer ) == false ) { m_SplinesActor->VisibilityOff(); m_SplineAssembly->VisibilityOff(); } else { m_SplinesActor->VisibilityOn(); m_SplineAssembly->VisibilityOn(); //remove the PointsAssembly if it was added in superclass. No need to display points and spline! if(m_SplineAssembly->GetParts()->IsItemPresent(m_PointsAssembly)) m_SplineAssembly->RemovePart(m_PointsAssembly); } //if the properties have been changed, then refresh the properties if ( (m_SplineUpdateTime < this->m_DataNode->GetPropertyList()->GetMTime() ) || (m_SplineUpdateTime < this->m_DataNode->GetPropertyList(renderer)->GetMTime() ) ) - this->ApplyProperties(); + this->ApplyProperties(m_SplinesActor, NULL); } -void mitk::SplineVtkMapper3D::ApplyProperties() +void mitk::SplineVtkMapper3D::ApplyProperties(vtkActor *actor, BaseRenderer *renderer) { + Superclass::ApplyProperties(actor, renderer); + //vtk changed the type of rgba during releases. Due to that, the following convert is done vtkFloatingPointType rgba[ 4 ] = {1.0f, 1.0f, 1.0f, 1.0f};//white //getting the color from DataNode float temprgba[4]; this->GetDataNode()->GetColor( &temprgba[0], NULL ); //convert to rgba, what ever type it has! rgba[0] = temprgba[0]; rgba[1] = temprgba[1]; rgba[2] = temprgba[2]; rgba[3] = temprgba[3]; //finaly set the color inside the actor m_SplinesActor->GetProperty()->SetColor( rgba ); float lineWidth; if (dynamic_cast(this->GetDataNode()->GetProperty("line width")) == NULL) lineWidth = 1.0; else lineWidth = dynamic_cast(this->GetDataNode()->GetProperty("line width"))->GetValue(); m_SplinesActor->GetProperty()->SetLineWidth(lineWidth); m_SplineUpdateTime.Modified(); } bool mitk::SplineVtkMapper3D::SplinesAreAvailable() { return m_SplinesAvailable; } vtkPolyData* mitk::SplineVtkMapper3D::GetSplinesPolyData() { if ( m_SplinesAvailable ) return ( dynamic_cast( m_SplinesActor->GetMapper() ) )->GetInput(); else return NULL; } vtkActor* mitk::SplineVtkMapper3D::GetSplinesActor() { if ( m_SplinesAvailable ) return m_SplinesActor; else return vtkActor::New(); } unsigned long mitk::SplineVtkMapper3D::GetLastUpdateTime() const { return m_LastUpdateTime.GetMTime(); } void mitk::SplineVtkMapper3D::UpdateSpline() { mitk::PointSet::Pointer input = const_cast( this->GetInput( ) ); // input->Update();//already done in superclass // Number of points on the spline unsigned int numberOfOutputPoints = m_SplineResolution; unsigned int numberOfInputPoints = input->GetSize(); if ( numberOfInputPoints >= 2 ) { m_SplinesAvailable = true; vtkCardinalSpline* splineX = vtkCardinalSpline::New(); vtkCardinalSpline* splineY = vtkCardinalSpline::New(); vtkCardinalSpline* splineZ = vtkCardinalSpline::New(); unsigned int index = 0; mitk::PointSet::DataType::PointsContainer::Pointer pointsContainer = input->GetPointSet()->GetPoints(); for ( mitk::PointSet::DataType::PointsContainer::Iterator it = pointsContainer->Begin(); it != pointsContainer->End(); ++it, ++index ) //for ( unsigned int i = 0 ; i < numberOfInputPoints; ++i ) { mitk::PointSet::PointType point = it->Value(); splineX->AddPoint( index, point[ 0 ] ); splineY->AddPoint( index, point[ 1 ] ); splineZ->AddPoint( index, point[ 2 ] ); } vtkPoints* points = vtkPoints::New(); vtkPolyData* profileData = vtkPolyData::New(); // Interpolate x, y and z by using the three spline filters and // create new points double t = 0.0f; for ( unsigned int i = 0; i < numberOfOutputPoints; ++i ) { t = ( ( ( ( double ) numberOfInputPoints ) - 1.0f ) / ( ( ( double ) numberOfOutputPoints ) - 1.0f ) ) * ( ( double ) i ); points->InsertPoint( i, splineX->Evaluate( t ), splineY->Evaluate( t ), splineZ->Evaluate( t ) ) ; } // Create the polyline. vtkCellArray* lines = vtkCellArray::New(); lines->InsertNextCell( numberOfOutputPoints ); for ( unsigned int i = 0; i < numberOfOutputPoints; ++i ) lines->InsertCellPoint( i ); profileData->SetPoints( points ); profileData->SetLines( lines ); // Add thickness to the resulting line. //vtkTubeFilter* profileTubes = vtkTubeFilter::New(); //profileTubes->SetNumberOfSides(8); //profileTubes->SetInput(profileData); //profileTubes->SetRadius(.005); vtkPolyDataMapper* profileMapper = vtkPolyDataMapper::New(); profileMapper->SetInput( profileData ); m_SplinesActor->SetMapper( profileMapper ); } else { m_SplinesAvailable = false; } m_SplineUpdateTime.Modified(); } diff --git a/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.h b/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.h index 7117c08011..f832ec46e5 100644 --- a/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.h +++ b/Modules/MitkExt/Rendering/mitkSplineVtkMapper3D.h @@ -1,99 +1,99 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_SPLINE_VTK_MAPPER_3D__H #define _MITK_SPLINE_VTK_MAPPER_3D__H #include "mitkPointSetVtkMapper3D.h" #include "MitkExtExports.h" class vtkActor; class vtkAssembly; namespace mitk { //##Documentation //## @brief Vtk-based mapper for Splines //## //## properties looked for: //## "line width" = with of the spline //## @ingroup Mapper /************************************************************************/ /* * - \b "line width": (FloatProperty) line width of the spline */ /************************************************************************/ class MitkExt_EXPORT SplineVtkMapper3D : public PointSetVtkMapper3D { public: mitkClassMacro( SplineVtkMapper3D, PointSetVtkMapper3D ); itkNewMacro( Self ); virtual vtkProp* GetVtkProp(mitk::BaseRenderer *renderer); virtual void UpdateVtkTransform(mitk::BaseRenderer *renderer); bool SplinesAreAvailable(); vtkPolyData* GetSplinesPolyData(); vtkActor* GetSplinesActor(); unsigned long GetLastUpdateTime() const; virtual void UpdateSpline(); itkSetMacro( SplineResolution, unsigned int ); itkGetMacro( SplineResolution, unsigned int ); protected: SplineVtkMapper3D(); virtual ~SplineVtkMapper3D(); virtual void GenerateData(); virtual void GenerateDataForRenderer(mitk::BaseRenderer * renderer); - virtual void ApplyProperties(); + virtual void ApplyProperties(vtkActor *actor, BaseRenderer *renderer); vtkActor* m_SplinesActor; vtkPropAssembly* m_SplineAssembly; bool m_SplinesAvailable; bool m_SplinesAddedToAssembly; unsigned int m_SplineResolution; itk::TimeStamp m_SplineUpdateTime; }; } //namespace mitk #endif diff --git a/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.cpp b/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.cpp index 4c27097cc8..579e968060 100644 --- a/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.cpp +++ b/Modules/PlanarFigure/Interactions/mitkPlanarFigureInteractor.cpp @@ -1,950 +1,950 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-10-02 16:21:08 +0200 (Do, 02 Okt 2008) $ Version: $Revision: 13129 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPlanarFigureInteractor.h" #include "mitkPointOperation.h" #include "mitkPositionEvent.h" #include "mitkPlanarFigure.h" #include "mitkStatusBar.h" #include "mitkDataNode.h" #include "mitkInteractionConst.h" #include "mitkAction.h" #include "mitkStateEvent.h" #include "mitkOperationEvent.h" #include "mitkUndoController.h" #include "mitkStateMachineFactory.h" #include "mitkStateTransitionOperation.h" #include "mitkBaseRenderer.h" #include "mitkRenderingManager.h" #include "mitkNodePredicateDataType.h" #include "mitkNodePredicateOr.h" //how precise must the user pick the point //default value mitk::PlanarFigureInteractor ::PlanarFigureInteractor(const char * type, DataNode* dataNode, int /* n */ ) : Interactor( type, dataNode ), m_Precision( 6.5 ), m_MinimumPointDistance( 25.0 ), m_IsHovering( false ), m_LastPointWasValid( false ) { } mitk::PlanarFigureInteractor::~PlanarFigureInteractor() { } void mitk::PlanarFigureInteractor::SetPrecision( mitk::ScalarType precision ) { m_Precision = precision; } void mitk::PlanarFigureInteractor::SetMinimumPointDistance( ScalarType minimumDistance ) { m_MinimumPointDistance = minimumDistance; } // Overwritten since this class can handle it better! float mitk::PlanarFigureInteractor ::CanHandleEvent(StateEvent const* stateEvent) const { float returnValue = 0.5; // If it is a key event that can be handled in the current state, // then return 0.5 mitk::DisplayPositionEvent const *disPosEvent = dynamic_cast (stateEvent->GetEvent()); // Key event handling: if (disPosEvent == NULL) { // Check if the current state has a transition waiting for that key event. if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) { return 0.5; } else { return 0.0; } } mitk::PlanarFigure *planarFigure = dynamic_cast( m_DataNode->GetData() ); if ( planarFigure != NULL ) { // Give higher priority if this figure is currently selected if ( planarFigure->GetSelectedControlPoint() >= 0 ) { return 1.0; } } return returnValue; } bool mitk::PlanarFigureInteractor ::ExecuteAction( Action *action, mitk::StateEvent const *stateEvent ) { bool ok = false; // Check corresponding data; has to be sub-class of mitk::PlanarFigure mitk::PlanarFigure *planarFigure = dynamic_cast< mitk::PlanarFigure * >( m_DataNode->GetData() ); if ( planarFigure == NULL ) { return false; } // Get the timestep to also support 3D+t const mitk::Event *theEvent = stateEvent->GetEvent(); int timeStep = 0; - mitk::ScalarType timeInMS = 0.0; + //mitk::ScalarType timeInMS = 0.0; if ( theEvent ) { if (theEvent->GetSender() != NULL) { timeStep = theEvent->GetSender()->GetTimeStep( planarFigure ); - timeInMS = theEvent->GetSender()->GetTime(); + //timeInMS = theEvent->GetSender()->GetTime(); } } // Get Geometry2D of PlanarFigure mitk::Geometry2D *planarFigureGeometry = dynamic_cast< mitk::Geometry2D * >( planarFigure->GetGeometry( timeStep ) ); // Get the Geometry2D of the window the user interacts with (for 2D point // projection) mitk::BaseRenderer *renderer = NULL; const Geometry2D *projectionPlane = NULL; if ( theEvent ) { renderer = theEvent->GetSender(); projectionPlane = renderer->GetCurrentWorldGeometry2D(); } // TODO: Check if display and PlanarFigure geometries are parallel (if they are PlaneGeometries) switch (action->GetActionId()) { case AcDONOTHING: ok = true; break; case AcCHECKOBJECT: { if ( planarFigure->IsPlaced() ) { this->HandleEvent( new mitk::StateEvent( EIDYES, NULL ) ); } else { this->HandleEvent( new mitk::StateEvent( EIDNO, NULL ) ); } ok = false; break; } case AcADD: { // Invoke event to notify listeners that placement of this PF starts now planarFigure->InvokeEvent( StartPlacementPlanarFigureEvent() ); // Use Geometry2D of the renderer clicked on for this PlanarFigure mitk::PlaneGeometry *planeGeometry = const_cast< mitk::PlaneGeometry * >( dynamic_cast< const mitk::PlaneGeometry * >( renderer->GetSliceNavigationController()->GetCurrentPlaneGeometry() ) ); if ( planeGeometry != NULL ) { planarFigureGeometry = planeGeometry; planarFigure->SetGeometry2D( planeGeometry ); } else { ok = false; break; } // Extract point in 2D world coordinates (relative to Geometry2D of // PlanarFigure) Point2D point2D; if ( !this->TransformPositionEventToPoint2D( stateEvent, point2D, planarFigureGeometry ) ) { ok = false; break; } // Place PlanarFigure at this point planarFigure->PlaceFigure( point2D ); // Re-evaluate features planarFigure->EvaluateFeatures(); //this->LogPrintPlanarFigureQuantities( planarFigure ); // Set a bool property indicating that the figure has been placed in // the current RenderWindow. This is required so that the same render // window can be re-aligned to the Geometry2D of the PlanarFigure later // on in an application. m_DataNode->SetBoolProperty( "PlanarFigureInitializedWindow", true, renderer ); // Update rendered scene renderer->GetRenderingManager()->RequestUpdateAll(); ok = true; break; } case AcMOVEPOINT: { bool isEditable = true; m_DataNode->GetBoolProperty( "planarfigure.iseditable", isEditable ); // Extract point in 2D world coordinates (relative to Geometry2D of // PlanarFigure) Point2D point2D; if ( !this->TransformPositionEventToPoint2D( stateEvent, point2D, planarFigureGeometry ) || !isEditable ) { ok = false; break; } // check if the control points shall be hidden during interaction bool hidecontrolpointsduringinteraction = false; m_DataNode->GetBoolProperty( "planarfigure.hidecontrolpointsduringinteraction", hidecontrolpointsduringinteraction ); // hide the control points if necessary m_DataNode->SetBoolProperty( "planarfigure.drawcontrolpoints", !hidecontrolpointsduringinteraction ); // Move current control point to this point planarFigure->SetCurrentControlPoint( point2D ); // Re-evaluate features planarFigure->EvaluateFeatures(); //this->LogPrintPlanarFigureQuantities( planarFigure ); // Update rendered scene renderer->GetRenderingManager()->RequestUpdateAll(); ok = true; break; } case AcCHECKNMINUS1: { if ( planarFigure->GetNumberOfControlPoints() >= planarFigure->GetMaximumNumberOfControlPoints() ) { // Initial placement finished: deselect control point and send an // event to notify application listeners planarFigure->Modified(); planarFigure->DeselectControlPoint(); planarFigure->InvokeEvent( EndPlacementPlanarFigureEvent() ); planarFigure->InvokeEvent( EndInteractionPlanarFigureEvent() ); planarFigure->SetProperty( "initiallyplaced", mitk::BoolProperty::New( true ) ); m_DataNode->SetBoolProperty( "planarfigure.drawcontrolpoints", true ); m_DataNode->Modified(); this->HandleEvent( new mitk::StateEvent( EIDYES, stateEvent->GetEvent() ) ); } else { this->HandleEvent( new mitk::StateEvent( EIDNO, stateEvent->GetEvent() ) ); } // Update rendered scene renderer->GetRenderingManager()->RequestUpdateAll(); ok = true; break; } case AcCHECKEQUALS1: { // NOTE: Action name is a bit misleading; this action checks whether // the figure has already the minimum number of required points to // be finished (by double-click) const mitk::PositionEvent *positionEvent = dynamic_cast< const mitk::PositionEvent * > ( stateEvent->GetEvent() ); if ( positionEvent == NULL ) { ok = false; break; } - if ( m_LastPointWasValid && planarFigure->GetNumberOfControlPoints() > planarFigure->GetMinimumNumberOfControlPoints() ) + if ( planarFigure->GetNumberOfControlPoints() > planarFigure->GetMinimumNumberOfControlPoints() ) { // Initial placement finished: deselect control point and send an // event to notify application listeners planarFigure->Modified(); planarFigure->DeselectControlPoint(); planarFigure->RemoveLastControlPoint(); planarFigure->SetProperty( "initiallyplaced", mitk::BoolProperty::New( true ) ); m_DataNode->SetBoolProperty( "planarfigure.drawcontrolpoints", true ); m_DataNode->Modified(); planarFigure->InvokeEvent( EndPlacementPlanarFigureEvent() ); planarFigure->InvokeEvent( EndInteractionPlanarFigureEvent() ); this->HandleEvent( new mitk::StateEvent( EIDYES, NULL ) ); } else { this->HandleEvent( new mitk::StateEvent( EIDNO, NULL ) ); } // Update rendered scene renderer->GetRenderingManager()->RequestUpdateAll(); ok = true; break; } case AcCHECKPOINT: { // Check if the distance of the current point to the previously set point in display coordinates // is sufficient (if a previous point exists) // Extract display position const mitk::PositionEvent *positionEvent = dynamic_cast< const mitk::PositionEvent * > ( stateEvent->GetEvent() ); if ( positionEvent == NULL ) { ok = false; break; } m_LastPointWasValid = IsMousePositionAcceptableAsNewControlPoint( positionEvent, planarFigure ); if (m_LastPointWasValid) { this->HandleEvent( new mitk::StateEvent( EIDYES, stateEvent->GetEvent() ) ); } else { this->HandleEvent( new mitk::StateEvent( EIDNO, stateEvent->GetEvent() ) ); } ok = true; break; } case AcADDPOINT: { bool selected = false; bool isEditable = true; m_DataNode->GetBoolProperty("selected", selected); m_DataNode->GetBoolProperty( "planarfigure.iseditable", isEditable ); if ( !selected || !isEditable ) { ok = false; break; } // Extract point in 2D world coordinates (relative to Geometry2D of // PlanarFigure) Point2D point2D, projectedPoint; if ( !this->TransformPositionEventToPoint2D( stateEvent, point2D, planarFigureGeometry ) ) { ok = false; break; } // TODO: check segement of polyline we clicked in int nextIndex = this->IsPositionOverFigure( stateEvent, planarFigure, planarFigureGeometry, projectionPlane, renderer->GetDisplayGeometry(), projectedPoint ); // Add point as new control point renderer->GetDisplayGeometry()->DisplayToWorld( projectedPoint, projectedPoint ); if ( planarFigure->IsPreviewControlPointVisible() ) { point2D = planarFigure->GetPreviewControlPoint(); } planarFigure->AddControlPoint( point2D, nextIndex ); if ( planarFigure->IsPreviewControlPointVisible() ) { planarFigure->SelectControlPoint( nextIndex ); planarFigure->ResetPreviewContolPoint(); } // Re-evaluate features planarFigure->EvaluateFeatures(); //this->LogPrintPlanarFigureQuantities( planarFigure ); // Update rendered scene renderer->GetRenderingManager()->RequestUpdateAll(); ok = true; break; } case AcDESELECTPOINT: { planarFigure->DeselectControlPoint(); // Issue event so that listeners may update themselves planarFigure->Modified(); planarFigure->InvokeEvent( EndInteractionPlanarFigureEvent() ); m_DataNode->SetBoolProperty( "planarfigure.drawcontrolpoints", true ); m_DataNode->Modified(); // falls through } case AcCHECKHOVERING: { mitk::Point2D pointProjectedOntoLine; int previousControlPoint = mitk::PlanarFigureInteractor::IsPositionOverFigure( stateEvent, planarFigure, planarFigureGeometry, projectionPlane, renderer->GetDisplayGeometry(), pointProjectedOntoLine ); bool isHovering = ( previousControlPoint != -1 ); int pointIndex = mitk::PlanarFigureInteractor::IsPositionInsideMarker( stateEvent, planarFigure, planarFigureGeometry, projectionPlane, renderer->GetDisplayGeometry() ); int initiallySelectedControlPoint = planarFigure->GetSelectedControlPoint(); if ( pointIndex >= 0 ) { // If mouse is above control point, mark it as selected planarFigure->SelectControlPoint( pointIndex ); // If mouse is hovering above a marker, it is also hovering above the figure isHovering = true; } else { // Mouse in not above control point --> deselect point planarFigure->DeselectControlPoint(); } bool renderingUpdateNeeded = true; if ( isHovering ) { if ( !m_IsHovering ) { // Invoke hover event once when the mouse is entering the figure area m_IsHovering = true; planarFigure->InvokeEvent( StartHoverPlanarFigureEvent() ); // Set bool property to indicate that planar figure is currently in "hovering" mode m_DataNode->SetBoolProperty( "planarfigure.ishovering", true ); renderingUpdateNeeded = true; } bool selected = false; bool isExtendable = false; bool isEditable = true; m_DataNode->GetBoolProperty("selected", selected); m_DataNode->GetBoolProperty("planarfigure.isextendable", isExtendable); m_DataNode->GetBoolProperty( "planarfigure.iseditable", isEditable ); if ( selected && isHovering && isExtendable && pointIndex == -1 && isEditable ) { const mitk::PositionEvent *positionEvent = dynamic_cast< const mitk::PositionEvent * > ( stateEvent->GetEvent() ); if ( positionEvent != NULL ) { renderer->GetDisplayGeometry()->DisplayToWorld( pointProjectedOntoLine, pointProjectedOntoLine ); planarFigure->SetPreviewControlPoint( pointProjectedOntoLine ); renderingUpdateNeeded = true; } } else { planarFigure->ResetPreviewContolPoint(); } if ( planarFigure->GetSelectedControlPoint() != initiallySelectedControlPoint ) { // the selected control point has changed -> rendering update necessary renderingUpdateNeeded = true; } this->HandleEvent( new mitk::StateEvent( EIDYES, stateEvent->GetEvent() ) ); // Return true: only this interactor is eligible to react on this event ok = true; } else { if ( m_IsHovering ) { planarFigure->ResetPreviewContolPoint(); // Invoke end-hover event once the mouse is exiting the figure area m_IsHovering = false; planarFigure->InvokeEvent( EndHoverPlanarFigureEvent() ); // Set bool property to indicate that planar figure is no longer in "hovering" mode m_DataNode->SetBoolProperty( "planarfigure.ishovering", false ); renderingUpdateNeeded = true; } this->HandleEvent( new mitk::StateEvent( EIDNO, NULL ) ); // Return false so that other (PlanarFigure) Interactors may react on this // event as well ok = false; } // Update rendered scene if necessray if ( renderingUpdateNeeded ) { renderer->GetRenderingManager()->RequestUpdateAll(); } break; } case AcCHECKSELECTED: { bool selected = false; m_DataNode->GetBoolProperty("selected", selected); if ( selected ) { this->HandleEvent( new mitk::StateEvent( EIDYES, stateEvent->GetEvent() ) ); } else { // Invoke event to notify listeners that this planar figure should be selected planarFigure->InvokeEvent( SelectPlanarFigureEvent() ); this->HandleEvent( new mitk::StateEvent( EIDNO, NULL ) ); } } case AcSELECTPICKEDOBJECT: { //// Invoke event to notify listeners that this planar figure should be selected //planarFigure->InvokeEvent( SelectPlanarFigureEvent() ); // Check if planar figure is marked as "editable" bool isEditable = true; m_DataNode->GetBoolProperty( "planarfigure.iseditable", isEditable ); int pointIndex = -1; if ( isEditable ) { // If planar figure is editable, check if mouse is over a control point pointIndex = mitk::PlanarFigureInteractor::IsPositionInsideMarker( stateEvent, planarFigure, planarFigureGeometry, projectionPlane, renderer->GetDisplayGeometry() ); } // If editing is enabled and the mouse is currently over a control point, select it if ( pointIndex >= 0 ) { this->HandleEvent( new mitk::StateEvent( EIDYES, stateEvent->GetEvent() ) ); // Return true: only this interactor is eligible to react on this event ok = true; } else { this->HandleEvent( new mitk::StateEvent( EIDNO, stateEvent->GetEvent() ) ); // Return false so that other (PlanarFigure) Interactors may react on this // event as well ok = false; } ok = true; break; } case AcSELECTPOINT: { // Invoke event to notify listeners that interaction with this PF starts now planarFigure->InvokeEvent( StartInteractionPlanarFigureEvent() ); // Reset the PlanarFigure if required if ( planarFigure->ResetOnPointSelect() ) { this->HandleEvent( new mitk::StateEvent( EIDYES, stateEvent->GetEvent() ) ); } else { this->HandleEvent( new mitk::StateEvent( EIDNO, stateEvent->GetEvent() ) ); } ok = true; break; } case AcREMOVEPOINT: { bool isExtendable = false; m_DataNode->GetBoolProperty("planarfigure.isextendable", isExtendable); if ( isExtendable ) { int selectedControlPoint = planarFigure->GetSelectedControlPoint(); planarFigure->RemoveControlPoint( selectedControlPoint ); // Re-evaluate features planarFigure->EvaluateFeatures(); planarFigure->Modified(); m_DataNode->SetBoolProperty( "planarfigure.drawcontrolpoints", true ); planarFigure->InvokeEvent( EndInteractionPlanarFigureEvent() ); renderer->GetRenderingManager()->RequestUpdateAll(); this->HandleEvent( new mitk::StateEvent( EIDYES, NULL ) ); } else { this->HandleEvent( new mitk::StateEvent( EIDNO, NULL ) ); } } //case AcMOVEPOINT: //case AcMOVESELECTED: // { // // Update the display // renderer->GetRenderingManager()->RequestUpdateAll(); // ok = true; // break; // } //case AcFINISHMOVE: // { // ok = true; // break; // } default: return Superclass::ExecuteAction( action, stateEvent ); } return ok; } bool mitk::PlanarFigureInteractor::TransformPositionEventToPoint2D( const StateEvent *stateEvent, Point2D &point2D, const Geometry2D *planarFigureGeometry ) { // Extract world position, and from this position on geometry, if // available const mitk::PositionEvent *positionEvent = dynamic_cast< const mitk::PositionEvent * > ( stateEvent->GetEvent() ); if ( positionEvent == NULL ) { return false; } mitk::Point3D worldPoint3D = positionEvent->GetWorldPosition(); // TODO: proper handling of distance tolerance if ( planarFigureGeometry->Distance( worldPoint3D ) > 0.1 ) { return false; } // Project point onto plane of this PlanarFigure planarFigureGeometry->Map( worldPoint3D, point2D ); return true; } bool mitk::PlanarFigureInteractor::TransformObjectToDisplay( const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::Geometry2D *objectGeometry, const mitk::Geometry2D *rendererGeometry, const mitk::DisplayGeometry *displayGeometry ) const { mitk::Point3D point3D; // Map circle point from local 2D geometry into 3D world space objectGeometry->Map( point2D, point3D ); // TODO: proper handling of distance tolerance if ( displayGeometry->Distance( point3D ) < 0.1 ) { // Project 3D world point onto display geometry rendererGeometry->Map( point3D, displayPoint ); displayGeometry->WorldToDisplay( displayPoint, displayPoint ); return true; } return false; } bool mitk::PlanarFigureInteractor::IsPointNearLine( const mitk::Point2D& point, const mitk::Point2D& startPoint, const mitk::Point2D& endPoint, mitk::Point2D& projectedPoint ) const { mitk::Vector2D n1 = endPoint - startPoint; n1.Normalize(); // Determine dot products between line vector and startpoint-point / endpoint-point vectors double l1 = n1 * (point - startPoint); double l2 = -n1 * (point - endPoint); // Determine projection of specified point onto line defined by start / end point mitk::Point2D crossPoint = startPoint + n1 * l1; projectedPoint = crossPoint; // Point is inside encompassing rectangle IF // - its distance to its projected point is small enough // - it is not further outside of the line than the defined tolerance if (((crossPoint.SquaredEuclideanDistanceTo(point) < 20.0) && (l1 > 0.0) && (l2 > 0.0)) || endPoint.SquaredEuclideanDistanceTo(point) < 20.0 || startPoint.SquaredEuclideanDistanceTo(point) < 20.0) { return true; } return false; } int mitk::PlanarFigureInteractor::IsPositionOverFigure( const StateEvent *stateEvent, PlanarFigure *planarFigure, const Geometry2D *planarFigureGeometry, const Geometry2D *rendererGeometry, const DisplayGeometry *displayGeometry, Point2D& pointProjectedOntoLine ) const { // Extract display position const mitk::PositionEvent *positionEvent = dynamic_cast< const mitk::PositionEvent * > ( stateEvent->GetEvent() ); if ( positionEvent == NULL ) { return -1; } mitk::Point2D displayPosition = positionEvent->GetDisplayPosition(); // Iterate over all polylines of planar figure, and check if // any one is close to the current display position typedef mitk::PlanarFigure::PolyLineType VertexContainerType; mitk::Point2D worldPoint2D, displayControlPoint; mitk::Point3D worldPoint3D; for ( unsigned short loop = 0; loop < planarFigure->GetPolyLinesSize(); ++loop ) { const VertexContainerType polyLine = planarFigure->GetPolyLine( loop ); Point2D polyLinePoint; Point2D firstPolyLinePoint; Point2D previousPolyLinePoint; bool firstPoint = true; for ( VertexContainerType::const_iterator it = polyLine.begin(); it != polyLine.end(); ++it ) { // Get plane coordinates of this point of polyline (if possible) if ( !this->TransformObjectToDisplay( it->Point, polyLinePoint, planarFigureGeometry, rendererGeometry, displayGeometry ) ) { break; // Poly line invalid (not on current 2D plane) --> skip it } if ( firstPoint ) { firstPolyLinePoint = polyLinePoint; firstPoint = false; } else if ( this->IsPointNearLine( displayPosition, previousPolyLinePoint, polyLinePoint, pointProjectedOntoLine ) ) { // Point is close enough to line segment --> Return index of the segment return it->Index; } previousPolyLinePoint = polyLinePoint; } // For closed figures, also check last line segment if ( planarFigure->IsClosed() && this->IsPointNearLine( displayPosition, polyLinePoint, firstPolyLinePoint, pointProjectedOntoLine ) ) { return 0; // Return index of first control point } } return -1; } int mitk::PlanarFigureInteractor::IsPositionInsideMarker( const StateEvent *stateEvent, const PlanarFigure *planarFigure, const Geometry2D *planarFigureGeometry, const Geometry2D *rendererGeometry, const DisplayGeometry *displayGeometry ) const { // Extract display position const mitk::PositionEvent *positionEvent = dynamic_cast< const mitk::PositionEvent * > ( stateEvent->GetEvent() ); if ( positionEvent == NULL ) { return -1; } mitk::Point2D displayPosition = positionEvent->GetDisplayPosition(); // Iterate over all control points of planar figure, and check if // any one is close to the current display position mitk::Point2D worldPoint2D, displayControlPoint; mitk::Point3D worldPoint3D; int numberOfControlPoints = planarFigure->GetNumberOfControlPoints(); for ( int i=0; iTransformObjectToDisplay( planarFigure->GetControlPoint(i), displayControlPoint, planarFigureGeometry, rendererGeometry, displayGeometry ) ) { // TODO: variable size of markers if ( displayPosition.SquaredEuclideanDistanceTo( displayControlPoint ) < 20.0 ) { return i; } } } //for ( it = controlPoints.begin(); it != controlPoints.end(); ++it ) //{ // Point2D displayControlPoint; // if ( this->TransformObjectToDisplay( it->Point, displayControlPoint, // planarFigureGeometry, rendererGeometry, displayGeometry ) ) // { // // TODO: variable size of markers // if ( (abs(displayPosition[0] - displayControlPoint[0]) < 4 ) // && (abs(displayPosition[1] - displayControlPoint[1]) < 4 ) ) // { // return index; // } // } //} return -1; } void mitk::PlanarFigureInteractor::LogPrintPlanarFigureQuantities( const PlanarFigure *planarFigure ) { MITK_INFO << "PlanarFigure: " << planarFigure->GetNameOfClass(); for ( unsigned int i = 0; i < planarFigure->GetNumberOfFeatures(); ++i ) { MITK_INFO << "* " << planarFigure->GetFeatureName( i ) << ": " << planarFigure->GetQuantity( i ) << " " << planarFigure->GetFeatureUnit( i ); } } bool mitk::PlanarFigureInteractor::IsMousePositionAcceptableAsNewControlPoint( const PositionEvent* positionEvent, const PlanarFigure* planarFigure ) { assert(positionEvent && planarFigure); BaseRenderer* renderer = positionEvent->GetSender(); assert(renderer); // Get the timestep to support 3D+t int timeStep( renderer->GetTimeStep( planarFigure ) ); // Get current display position of the mouse Point2D currentDisplayPosition = positionEvent->GetDisplayPosition(); // Check if a previous point has been set bool tooClose = false; for( int i=0; i < (int)planarFigure->GetNumberOfControlPoints(); i++ ) { if ( i != planarFigure->GetSelectedControlPoint() ) { // Try to convert previous point to current display coordinates mitk::Geometry2D *planarFigureGeometry = dynamic_cast< mitk::Geometry2D * >( planarFigure->GetGeometry( timeStep ) ); const Geometry2D *projectionPlane = renderer->GetCurrentWorldGeometry2D(); mitk::Point3D previousPoint3D; planarFigureGeometry->Map( planarFigure->GetControlPoint( i ), previousPoint3D ); if ( renderer->GetDisplayGeometry()->Distance( previousPoint3D ) < 0.1 ) // ugly, but assert makes this work { mitk::Point2D previousDisplayPosition; projectionPlane->Map( previousPoint3D, previousDisplayPosition ); renderer->GetDisplayGeometry()->WorldToDisplay( previousDisplayPosition, previousDisplayPosition ); double a = currentDisplayPosition[0] - previousDisplayPosition[0]; double b = currentDisplayPosition[1] - previousDisplayPosition[1]; // If point is to close, do not set a new point tooClose = (a * a + b * b < m_MinimumPointDistance ); } if ( tooClose ) return false; // abort loop early } } return !tooClose; // default } diff --git a/Modules/PlanarFigure/Rendering/mitkPlanarFigureMapper2D.cpp b/Modules/PlanarFigure/Rendering/mitkPlanarFigureMapper2D.cpp index 78765132a4..0a2d648f8c 100644 --- a/Modules/PlanarFigure/Rendering/mitkPlanarFigureMapper2D.cpp +++ b/Modules/PlanarFigure/Rendering/mitkPlanarFigureMapper2D.cpp @@ -1,688 +1,688 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-04-23 13:50:34 +0200 (Do, 23 Apr 2009) $ Version: $Revision: 16947 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPlanarFigureMapper2D.h" #include "mitkBaseRenderer.h" #include "mitkPlaneGeometry.h" #include "mitkColorProperty.h" #include "mitkProperties.h" #include "mitkGL.h" #include "mitkVtkPropRenderer.h" #define _USE_MATH_DEFINES #include // offset which moves the planarfigures on top of the other content // the crosshair is rendered into the z = 1 layer. static const float PLANAR_OFFSET = 0.5f; mitk::PlanarFigureMapper2D::PlanarFigureMapper2D() { this->InitializeDefaultPlanarFigureProperties(); } mitk::PlanarFigureMapper2D::~PlanarFigureMapper2D() { } void mitk::PlanarFigureMapper2D::Paint( mitk::BaseRenderer *renderer ) { if ( !this->IsVisible( renderer ) ) { return; } // Get PlanarFigure from input mitk::PlanarFigure *planarFigure = const_cast< mitk::PlanarFigure * >( static_cast< const mitk::PlanarFigure * >( this->GetData() ) ); // Check if PlanarFigure has already been placed; otherwise, do nothing if ( !planarFigure->IsPlaced() ) { return; } // Get 2D geometry frame of PlanarFigure mitk::Geometry2D *planarFigureGeometry2D = dynamic_cast< Geometry2D * >( planarFigure->GetGeometry( 0 ) ); if ( planarFigureGeometry2D == NULL ) { MITK_ERROR << "PlanarFigure does not have valid Geometry2D!"; return; } // Get current world 2D geometry from renderer const mitk::Geometry2D *rendererGeometry2D = renderer->GetCurrentWorldGeometry2D(); // If the PlanarFigure geometry is a plane geometry, check if current // world plane is parallel to and within the planar figure geometry bounds // (otherwise, display nothing) mitk::PlaneGeometry *planarFigurePlaneGeometry = dynamic_cast< PlaneGeometry * >( planarFigureGeometry2D ); const mitk::PlaneGeometry *rendererPlaneGeometry = dynamic_cast< const PlaneGeometry * >( rendererGeometry2D ); if ( (planarFigurePlaneGeometry != NULL) && (rendererPlaneGeometry != NULL) ) { double planeThickness = planarFigurePlaneGeometry->GetExtentInMM( 2 ); if ( !planarFigurePlaneGeometry->IsParallel( rendererPlaneGeometry ) || !(planarFigurePlaneGeometry->DistanceFromPlane( rendererPlaneGeometry ) < planeThickness / 3.0) ) { // Planes are not parallel or renderer plane is not within PlanarFigure // geometry bounds --> exit return; } } else { // Plane is not valid (curved reformations are not possible yet) return; } // Get display geometry mitk::DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); assert( displayGeometry != NULL ); // Apply visual appearance properties from the PropertyList this->ApplyProperties( renderer ); // Enable line antialiasing glEnable( GL_LINE_SMOOTH ); glHint( GL_LINE_SMOOTH_HINT, GL_NICEST ); glEnable(GL_DEPTH_TEST); // Get properties from node (if present) const mitk::DataNode* node=this->GetDataNode(); this->InitializePlanarFigurePropertiesFromDataNode( node ); PlanarFigureDisplayMode lineDisplayMode = PF_DEFAULT; if ( m_IsSelected ) { lineDisplayMode = PF_SELECTED; } else if ( m_IsHovering ) { lineDisplayMode = PF_HOVER; } mitk::Point2D firstPoint; firstPoint[0] = 0; firstPoint[1] = 1; if ( m_DrawOutline ) { // Draw the outline for all polylines if requested this->DrawMainLines( planarFigure, m_OutlineColor[lineDisplayMode], m_OutlineOpacity[lineDisplayMode], m_DrawShadow, m_OutlineWidth, m_ShadowWidthFactor, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); // Draw the outline for all helper objects if requested this->DrawHelperLines( planarFigure, m_OutlineColor[lineDisplayMode], m_OutlineOpacity[lineDisplayMode], m_DrawShadow, m_OutlineWidth, m_ShadowWidthFactor, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); } // Draw the main line for all polylines this->DrawMainLines( planarFigure, m_LineColor[lineDisplayMode], m_LineOpacity[lineDisplayMode], m_DrawShadow, m_LineWidth, m_ShadowWidthFactor, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); double annotationOffset = 0.0; // draw name near the first point (if present) std::string name = node->GetName(); if ( !name.empty() ) { mitk::VtkPropRenderer* openGLrenderer = dynamic_cast( renderer ); if ( openGLrenderer ) { if ( m_IsSelected || m_IsHovering ) { openGLrenderer->WriteSimpleText( name, firstPoint[0] + 6.0, firstPoint[1] + 4.0, 0, 0, 0); //this is a shadow openGLrenderer->WriteSimpleText( name, firstPoint[0] + 5.0, firstPoint[1] + 5.0, m_LineColor[lineDisplayMode][0], m_LineColor[lineDisplayMode][1], m_LineColor[lineDisplayMode][2] ); } // If drawing is successful, add approximate height to annotation offset annotationOffset -= 15.0; } } // draw feature quantities (if requested) new the first point if ( m_DrawQuantities ) { std::stringstream quantityString; quantityString.setf( ios::fixed, ios::floatfield ); quantityString.precision( 1 ); bool firstActiveFeature = true; for ( unsigned int i = 0; i < planarFigure->GetNumberOfFeatures(); ++i ) { if( planarFigure->IsFeatureActive(i) && planarFigure->IsFeatureVisible( i ) ) { if ( ! firstActiveFeature ) { quantityString << " / "; } quantityString << planarFigure->GetQuantity( i ) << " "; quantityString << planarFigure->GetFeatureUnit( i ); firstActiveFeature = false; } } mitk::VtkPropRenderer* openGLrenderer = dynamic_cast( renderer ); if ( openGLrenderer ) { openGLrenderer->WriteSimpleText( quantityString.str().c_str(), firstPoint[0] + 6.0, firstPoint[1] + 4.0 + annotationOffset, 0, 0, 0); //this is a shadow openGLrenderer->WriteSimpleText( quantityString.str().c_str(), firstPoint[0] + 5.0, firstPoint[1] + 5.0 + annotationOffset, m_LineColor[lineDisplayMode][0], m_LineColor[lineDisplayMode][1], m_LineColor[lineDisplayMode][2] ); // If drawing is successful, add approximate height to annotation offset annotationOffset -= 15.0; } } // Draw helper objects this->DrawHelperLines( planarFigure, m_HelperlineColor[lineDisplayMode], m_HelperlineOpacity[lineDisplayMode], m_DrawShadow, m_LineWidth, m_ShadowWidthFactor, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); if ( m_DrawControlPoints ) { // Draw markers at control points (selected control point will be colored) for ( unsigned int i = 0; i < planarFigure->GetNumberOfControlPoints(); ++i ) { bool isEditable = true; m_DataNode->GetBoolProperty( "planarfigure.iseditable", isEditable ); PlanarFigureDisplayMode pointDisplayMode = PF_DEFAULT; // Only if planar figure is marked as editable: display markers (control points) in a // different style if mouse is over them or they are selected if ( isEditable ) { if ( i == (unsigned int) planarFigure->GetSelectedControlPoint() ) { pointDisplayMode = PF_SELECTED; } else if ( m_IsHovering ) { pointDisplayMode = PF_HOVER; } } this->DrawMarker( planarFigure->GetControlPoint( i ), m_MarkerlineColor[pointDisplayMode], m_MarkerlineOpacity[pointDisplayMode], m_MarkerColor[pointDisplayMode], m_MarkerOpacity[pointDisplayMode], m_LineWidth, m_ControlPointShape, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); } if ( planarFigure->IsPreviewControlPointVisible() ) { this->DrawMarker( planarFigure->GetPreviewControlPoint(), m_MarkerlineColor[PF_HOVER], m_MarkerlineOpacity[PF_HOVER], m_MarkerColor[PF_HOVER], m_MarkerOpacity[PF_HOVER], m_LineWidth, m_ControlPointShape, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); } } glLineWidth( 1.0f ); } void mitk::PlanarFigureMapper2D::PaintPolyLine( mitk::PlanarFigure::PolyLineType vertices, bool closed, float* color, float opacity, float lineWidth, Point2D& firstPoint, const Geometry2D* planarFigureGeometry2D, const Geometry2D* rendererGeometry2D, const DisplayGeometry* displayGeometry) { glColor4f( color[0], color[1], color[2], opacity ); glLineWidth(lineWidth); if ( closed ) { glBegin( GL_LINE_LOOP ); } else { glBegin( GL_LINE_STRIP ); } for ( PlanarFigure::PolyLineType::iterator iter = vertices.begin(); iter!=vertices.end(); iter++ ) { // Draw this 2D point as OpenGL vertex mitk::Point2D displayPoint; this->TransformObjectToDisplay( iter->Point, displayPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); if(iter == vertices.begin()) firstPoint = displayPoint; - glVertex3f( displayPoint[0], displayPoint[1],PLANAR_OFFSET); + glVertex3f( displayPoint[0], displayPoint[1], PLANAR_OFFSET ); } glEnd(); } void mitk::PlanarFigureMapper2D::DrawMainLines( mitk::PlanarFigure* figure, float* color, float opacity, bool drawShadow, float lineWidth, float shadowWidthFactor, Point2D& firstPoint, const Geometry2D* planarFigureGeometry2D, const Geometry2D* rendererGeometry2D, const DisplayGeometry* displayGeometry) { for ( unsigned short loop = 0; loop < figure->GetPolyLinesSize(); ++loop ) { PlanarFigure::PolyLineType polyline = figure->GetPolyLine(loop); if ( drawShadow ) { float* shadow = new float[3]; shadow[0] = 0; shadow[1] = 0; shadow[2] = 0; this->PaintPolyLine( polyline, figure->IsClosed(), shadow, 0.8, lineWidth*shadowWidthFactor, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); delete shadow; } this->PaintPolyLine( polyline, figure->IsClosed(), color, opacity, lineWidth, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); } } void mitk::PlanarFigureMapper2D::DrawHelperLines( mitk::PlanarFigure* figure, float* color, float opacity, bool drawShadow, float lineWidth, float shadowWidthFactor, Point2D& firstPoint, const Geometry2D* planarFigureGeometry2D, const Geometry2D* rendererGeometry2D, const DisplayGeometry* displayGeometry) { // Draw helper objects for ( unsigned int loop = 0; loop < figure->GetHelperPolyLinesSize(); ++loop ) { const mitk::PlanarFigure::PolyLineType helperPolyLine = figure->GetHelperPolyLine(loop, displayGeometry->GetScaleFactorMMPerDisplayUnit(), displayGeometry->GetDisplayHeight() ); // Check if the current helper objects is to be painted if ( !figure->IsHelperToBePainted( loop ) ) { continue; } // check if shadow shall be painted around the figure if ( drawShadow ) { float* shadow = new float[3]; shadow[0] = 0; shadow[1] = 0; shadow[2] = 0; // paint shadow by painting the figure twice // one in black with a slightly broader line-width ... this->PaintPolyLine( helperPolyLine, false, shadow, 0.8, lineWidth*shadowWidthFactor, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); delete shadow; } // ... and once normally above the shadow. this->PaintPolyLine( helperPolyLine, false, color, opacity, lineWidth, firstPoint, planarFigureGeometry2D, rendererGeometry2D, displayGeometry ); } } void mitk::PlanarFigureMapper2D::TransformObjectToDisplay( const mitk::Point2D &point2D, mitk::Point2D &displayPoint, const mitk::Geometry2D *objectGeometry, const mitk::Geometry2D *rendererGeometry, const mitk::DisplayGeometry *displayGeometry ) { mitk::Point3D point3D; // Map circle point from local 2D geometry into 3D world space objectGeometry->Map( point2D, point3D ); // Project 3D world point onto display geometry rendererGeometry->Map( point3D, displayPoint ); displayGeometry->WorldToDisplay( displayPoint, displayPoint ); } void mitk::PlanarFigureMapper2D::DrawMarker( const mitk::Point2D &point, float* lineColor, float lineOpacity, float* markerColor, float markerOpacity, float lineWidth, PlanarFigureControlPointStyleProperty::Shape shape, const mitk::Geometry2D *objectGeometry, const mitk::Geometry2D *rendererGeometry, const mitk::DisplayGeometry *displayGeometry ) { mitk::Point2D displayPoint; this->TransformObjectToDisplay( point, displayPoint, objectGeometry, rendererGeometry, displayGeometry ); glColor4f( markerColor[0], markerColor[1], markerColor[2], markerOpacity ); glLineWidth( lineWidth ); switch ( shape ) { case PlanarFigureControlPointStyleProperty::Square: default: // Paint filled square // Disable line antialiasing (does not look nice for squares) glDisable( GL_LINE_SMOOTH ); glRectf( displayPoint[0] - 4, displayPoint[1] - 4, displayPoint[0] + 4, displayPoint[1] + 4 ); // Paint outline glColor4f( lineColor[0], lineColor[1], lineColor[2], lineOpacity ); glBegin( GL_LINE_LOOP ); - glVertex2f( displayPoint[0] - 4, displayPoint[1] - 4 ); - glVertex2f( displayPoint[0] - 4, displayPoint[1] + 4 ); - glVertex2f( displayPoint[0] + 4, displayPoint[1] + 4 ); - glVertex2f( displayPoint[0] + 4, displayPoint[1] - 4 ); + glVertex3f( displayPoint[0] - 4, displayPoint[1] - 4, PLANAR_OFFSET ); + glVertex3f( displayPoint[0] - 4, displayPoint[1] + 4, PLANAR_OFFSET ); + glVertex3f( displayPoint[0] + 4, displayPoint[1] + 4, PLANAR_OFFSET ); + glVertex3f( displayPoint[0] + 4, displayPoint[1] - 4, PLANAR_OFFSET ); glEnd(); break; case PlanarFigureControlPointStyleProperty::Circle: // Paint filled circle glBegin( GL_POLYGON ); float radius = 4.0; for ( int angle = 0; angle < 8; ++angle ) { float angleRad = angle * (float) 3.14159 / 4.0; float x = displayPoint[0] + radius * (float)cos( angleRad ); float y = displayPoint[1] + radius * (float)sin( angleRad ); - glVertex2f(x,y); + glVertex3f(x, y, PLANAR_OFFSET); } glEnd(); // Paint outline glColor4f( lineColor[0], lineColor[1], lineColor[2], lineOpacity ); glBegin( GL_LINE_LOOP ); for ( int angle = 0; angle < 8; ++angle ) { float angleRad = angle * (float) 3.14159 / 4.0; float x = displayPoint[0] + radius * (float)cos( angleRad ); float y = displayPoint[1] + radius * (float)sin( angleRad ); - glVertex2f(x,y); + glVertex3f(x, y, PLANAR_OFFSET); } glEnd(); break; } // end switch } void mitk::PlanarFigureMapper2D::InitializeDefaultPlanarFigureProperties() { m_IsSelected = false; m_IsHovering = false; m_DrawOutline = false; m_DrawQuantities = false; m_DrawShadow = false; m_DrawControlPoints = false; m_ShadowWidthFactor = 1.2; m_LineWidth = 1.0; m_OutlineWidth = 4.0; m_HelperlineWidth = 2.0; m_ControlPointShape = PlanarFigureControlPointStyleProperty::Square; this->SetColorProperty( m_LineColor, PF_DEFAULT, 1.0, 1.0, 1.0 ); this->SetFloatProperty( m_LineOpacity, PF_DEFAULT, 1.0 ); this->SetColorProperty( m_OutlineColor, PF_DEFAULT, 0.0, 0.0, 1.0 ); this->SetFloatProperty( m_OutlineOpacity, PF_DEFAULT, 1.0 ); this->SetColorProperty( m_HelperlineColor, PF_DEFAULT, 0.4, 0.8, 0.2 ); this->SetFloatProperty( m_HelperlineOpacity, PF_DEFAULT, 0.4 ); this->SetColorProperty( m_MarkerlineColor, PF_DEFAULT, 1.0, 1.0, 1.0 ); this->SetFloatProperty( m_MarkerlineOpacity, PF_DEFAULT, 1.0 ); this->SetColorProperty( m_MarkerColor, PF_DEFAULT, 1.0, 1.0, 1.0 ); this->SetFloatProperty( m_MarkerOpacity, PF_DEFAULT, 0.0 ); this->SetColorProperty( m_LineColor, PF_HOVER, 1.0, 0.7, 0.0 ); this->SetFloatProperty( m_LineOpacity, PF_HOVER, 1.0 ); this->SetColorProperty( m_OutlineColor, PF_HOVER, 0.0, 0.0, 1.0 ); this->SetFloatProperty( m_OutlineOpacity, PF_HOVER, 1.0 ); this->SetColorProperty( m_HelperlineColor, PF_HOVER, 0.4, 0.8, 0.2 ); this->SetFloatProperty( m_HelperlineOpacity, PF_HOVER, 0.4 ); this->SetColorProperty( m_MarkerlineColor, PF_HOVER, 1.0, 1.0, 1.0 ); this->SetFloatProperty( m_MarkerlineOpacity, PF_HOVER, 1.0 ); this->SetColorProperty( m_MarkerColor, PF_HOVER, 1.0, 0.6, 0.0 ); this->SetFloatProperty( m_MarkerOpacity, PF_HOVER, 0.2 ); this->SetColorProperty( m_LineColor, PF_SELECTED, 1.0, 0.0, 0.0 ); this->SetFloatProperty( m_LineOpacity, PF_SELECTED, 1.0 ); this->SetColorProperty( m_OutlineColor, PF_SELECTED, 0.0, 0.0, 1.0 ); this->SetFloatProperty( m_OutlineOpacity, PF_SELECTED, 1.0 ); this->SetColorProperty( m_HelperlineColor, PF_SELECTED, 0.4, 0.8, 0.2 ); this->SetFloatProperty( m_HelperlineOpacity, PF_SELECTED, 0.4 ); this->SetColorProperty( m_MarkerlineColor, PF_SELECTED, 1.0, 1.0, 1.0 ); this->SetFloatProperty( m_MarkerlineOpacity, PF_SELECTED, 1.0 ); this->SetColorProperty( m_MarkerColor, PF_SELECTED, 1.0, 0.6, 0.0 ); this->SetFloatProperty( m_MarkerOpacity, PF_SELECTED, 1.0 ); } void mitk::PlanarFigureMapper2D::InitializePlanarFigurePropertiesFromDataNode( const mitk::DataNode* node ) { if ( node == NULL ) { return; } node->GetBoolProperty( "selected", m_IsSelected ); node->GetBoolProperty( "planarfigure.ishovering", m_IsHovering ); node->GetBoolProperty( "planarfigure.drawoutline", m_DrawOutline ); node->GetBoolProperty( "planarfigure.drawquantities", m_DrawQuantities ); node->GetBoolProperty( "planarfigure.drawshadow", m_DrawShadow ); node->GetBoolProperty( "planarfigure.drawcontrolpoints", m_DrawControlPoints ); node->GetFloatProperty( "planarfigure.line.width", m_LineWidth ); node->GetFloatProperty( "planarfigure.shadow.widthmodifier", m_ShadowWidthFactor ); node->GetFloatProperty( "planarfigure.outline.width", m_OutlineWidth ); node->GetFloatProperty( "planarfigure.helperline.width", m_HelperlineWidth ); PlanarFigureControlPointStyleProperty::Pointer styleProperty = dynamic_cast< PlanarFigureControlPointStyleProperty* >( node->GetProperty( "planarfigure.controlpointshape" ) ); if ( styleProperty.IsNotNull() ) { m_ControlPointShape = styleProperty->GetShape(); } node->GetColor( m_LineColor[PF_DEFAULT], NULL, "planarfigure.default.line.color" ); node->GetFloatProperty( "planarfigure.default.line.opacity", m_LineOpacity[PF_DEFAULT] ); node->GetColor( m_OutlineColor[PF_DEFAULT], NULL, "planarfigure.default.outline.color" ); node->GetFloatProperty( "planarfigure.default.outline.opacity", m_OutlineOpacity[PF_DEFAULT] ); node->GetColor( m_HelperlineColor[PF_DEFAULT], NULL, "planarfigure.default.helperline.color" ); node->GetFloatProperty( "planarfigure.default.helperline.opacity", m_HelperlineOpacity[PF_DEFAULT] ); node->GetColor( m_MarkerlineColor[PF_DEFAULT], NULL, "planarfigure.default.markerline.color" ); node->GetFloatProperty( "planarfigure.default.markerline.opacity", m_MarkerlineOpacity[PF_DEFAULT] ); node->GetColor( m_MarkerColor[PF_DEFAULT], NULL, "planarfigure.default.marker.color" ); node->GetFloatProperty( "planarfigure.default.marker.opacity", m_MarkerOpacity[PF_DEFAULT] ); node->GetColor( m_LineColor[PF_HOVER], NULL, "planarfigure.hover.line.color" ); node->GetFloatProperty( "planarfigure.hover.line.opacity", m_LineOpacity[PF_HOVER] ); node->GetColor( m_OutlineColor[PF_HOVER], NULL, "planarfigure.hover.outline.color" ); node->GetFloatProperty( "planarfigure.hover.outline.opacity", m_OutlineOpacity[PF_HOVER] ); node->GetColor( m_HelperlineColor[PF_HOVER], NULL, "planarfigure.hover.helperline.color" ); node->GetFloatProperty( "planarfigure.hover.helperline.opacity", m_HelperlineOpacity[PF_HOVER] ); node->GetColor( m_MarkerlineColor[PF_HOVER], NULL, "planarfigure.hover.markerline.color" ); node->GetFloatProperty( "planarfigure.hover.markerline.opacity", m_MarkerlineOpacity[PF_HOVER] ); node->GetColor( m_MarkerColor[PF_HOVER], NULL, "planarfigure.hover.marker.color" ); node->GetFloatProperty( "planarfigure.hover.marker.opacity", m_MarkerOpacity[PF_HOVER] ); node->GetColor( m_LineColor[PF_SELECTED], NULL, "planarfigure.selected.line.color" ); node->GetFloatProperty( "planarfigure.selected.line.opacity", m_LineOpacity[PF_SELECTED] ); node->GetColor( m_OutlineColor[PF_SELECTED], NULL, "planarfigure.selected.outline.color" ); node->GetFloatProperty( "planarfigure.selected.outline.opacity", m_OutlineOpacity[PF_SELECTED] ); node->GetColor( m_HelperlineColor[PF_SELECTED], NULL, "planarfigure.selected.helperline.color" ); node->GetFloatProperty( "planarfigure.selected.helperline.opacity", m_HelperlineOpacity[PF_SELECTED] ); node->GetColor( m_MarkerlineColor[PF_SELECTED], NULL, "planarfigure.selected.markerline.color" ); node->GetFloatProperty( "planarfigure.selected.markerline.opacity", m_MarkerlineOpacity[PF_SELECTED] ); node->GetColor( m_MarkerColor[PF_SELECTED], NULL, "planarfigure.selected.marker.color" ); node->GetFloatProperty( "planarfigure.selected.marker.opacity", m_MarkerOpacity[PF_SELECTED] ); } void mitk::PlanarFigureMapper2D::SetDefaultProperties( mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite ) { node->AddProperty( "visible", mitk::BoolProperty::New(true), renderer, overwrite ); //node->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true)); //node->SetProperty("planarfigure.isextendable",mitk::BoolProperty::New(true)); //node->AddProperty( "planarfigure.ishovering", mitk::BoolProperty::New(true) ); node->AddProperty( "planarfigure.drawoutline", mitk::BoolProperty::New(true) ); //node->AddProperty( "planarfigure.drawquantities", mitk::BoolProperty::New(true) ); node->AddProperty( "planarfigure.drawshadow", mitk::BoolProperty::New(true) ); node->AddProperty( "planarfigure.drawcontrolpoints", mitk::BoolProperty::New(true) ); node->AddProperty("planarfigure.line.width", mitk::FloatProperty::New(2.0) ); node->AddProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(2.0) ); node->AddProperty("planarfigure.outline.width", mitk::FloatProperty::New(2.0) ); node->AddProperty("planarfigure.helperline.width", mitk::FloatProperty::New(2.0) ); node->AddProperty( "planarfigure.default.line.color", mitk::ColorProperty::New(1.0,1.0,1.0) ); node->AddProperty( "planarfigure.default.line.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.default.outline.color", mitk::ColorProperty::New(1.0,1.0,1.0) ); node->AddProperty( "planarfigure.default.outline.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.default.helperline.color", mitk::ColorProperty::New(1.0,1.0,1.0) ); node->AddProperty( "planarfigure.default.helperline.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.default.markerline.color", mitk::ColorProperty::New(1.0,1.0,1.0) ); node->AddProperty( "planarfigure.default.markerline.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.default.marker.color", mitk::ColorProperty::New(1.0,1.0,1.0) ); node->AddProperty( "planarfigure.default.marker.opacity",mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.hover.line.color", mitk::ColorProperty::New(0.0,1.0,0.0) ); node->AddProperty( "planarfigure.hover.line.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.hover.outline.color", mitk::ColorProperty::New(0.0,1.0,0.0) ); node->AddProperty( "planarfigure.hover.outline.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.hover.helperline.color", mitk::ColorProperty::New(0.0,1.0,0.0) ); node->AddProperty( "planarfigure.hover.helperline.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.hover.markerline.color", mitk::ColorProperty::New(0.0,1.0,0.0) ); node->AddProperty( "planarfigure.hover.markerline.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.hover.marker.color", mitk::ColorProperty::New(0.0,1.0,0.0) ); node->AddProperty( "planarfigure.hover.marker.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.selected.line.color", mitk::ColorProperty::New(1.0,0.0,0.0) ); node->AddProperty( "planarfigure.selected.line.opacity",mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.selected.outline.color", mitk::ColorProperty::New(1.0,0.0,0.0) ); node->AddProperty( "planarfigure.selected.outline.opacity", mitk::FloatProperty::New(1.0)); node->AddProperty( "planarfigure.selected.helperline.color", mitk::ColorProperty::New(1.0,0.0,0.0) ); node->AddProperty( "planarfigure.selected.helperline.opacity",mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.selected.markerline.color", mitk::ColorProperty::New(1.0,0.0,0.0) ); node->AddProperty( "planarfigure.selected.markerline.opacity", mitk::FloatProperty::New(1.0) ); node->AddProperty( "planarfigure.selected.marker.color", mitk::ColorProperty::New(1.0,0.0,0.0) ); node->AddProperty( "planarfigure.selected.marker.opacity",mitk::FloatProperty::New(1.0)); } diff --git a/CoreUI/Qmitk/Binaerbilder_48.png b/Modules/Qmitk/Binaerbilder_48.png similarity index 100% rename from CoreUI/Qmitk/Binaerbilder_48.png rename to Modules/Qmitk/Binaerbilder_48.png diff --git a/CoreUI/Qmitk/CMakeLists.txt b/Modules/Qmitk/CMakeLists.txt similarity index 100% rename from CoreUI/Qmitk/CMakeLists.txt rename to Modules/Qmitk/CMakeLists.txt diff --git a/CoreUI/Qmitk/DataTypeUnknown_48.png b/Modules/Qmitk/DataTypeUnknown_48.png similarity index 100% rename from CoreUI/Qmitk/DataTypeUnknown_48.png rename to Modules/Qmitk/DataTypeUnknown_48.png diff --git a/CoreUI/Qmitk/Images_48.png b/Modules/Qmitk/Images_48.png similarity index 100% rename from CoreUI/Qmitk/Images_48.png rename to Modules/Qmitk/Images_48.png diff --git a/CoreUI/Qmitk/PointSet_48.png b/Modules/Qmitk/PointSet_48.png similarity index 100% rename from CoreUI/Qmitk/PointSet_48.png rename to Modules/Qmitk/PointSet_48.png diff --git a/CoreUI/Qmitk/Qmitk.qrc b/Modules/Qmitk/Qmitk.qrc similarity index 100% rename from CoreUI/Qmitk/Qmitk.qrc rename to Modules/Qmitk/Qmitk.qrc diff --git a/CoreUI/Qmitk/QmitkApplicationCursor.cpp b/Modules/Qmitk/QmitkApplicationCursor.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkApplicationCursor.cpp rename to Modules/Qmitk/QmitkApplicationCursor.cpp diff --git a/CoreUI/Qmitk/QmitkApplicationCursor.h b/Modules/Qmitk/QmitkApplicationCursor.h similarity index 100% rename from CoreUI/Qmitk/QmitkApplicationCursor.h rename to Modules/Qmitk/QmitkApplicationCursor.h diff --git a/Modules/Qmitk/QmitkCustomVariants.h b/Modules/Qmitk/QmitkCustomVariants.h new file mode 100755 index 0000000000..fdbbd0628e --- /dev/null +++ b/Modules/Qmitk/QmitkCustomVariants.h @@ -0,0 +1,27 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITKCUSTOMVARIANTS_H_ +#define QMITKCUSTOMVARIANTS_H_ + +#include + +Q_DECLARE_METATYPE(mitk::DataNode::Pointer) +Q_DECLARE_METATYPE(mitk::DataNode*) + +#endif /* QMITKCUSTOMVARIANTS_H_ */ diff --git a/CoreUI/Qmitk/QmitkDataStorageComboBox.cpp b/Modules/Qmitk/QmitkDataStorageComboBox.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkDataStorageComboBox.cpp rename to Modules/Qmitk/QmitkDataStorageComboBox.cpp diff --git a/CoreUI/Qmitk/QmitkDataStorageComboBox.h b/Modules/Qmitk/QmitkDataStorageComboBox.h similarity index 100% rename from CoreUI/Qmitk/QmitkDataStorageComboBox.h rename to Modules/Qmitk/QmitkDataStorageComboBox.h diff --git a/CoreUI/Qmitk/QmitkDataStorageListModel.cpp b/Modules/Qmitk/QmitkDataStorageListModel.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkDataStorageListModel.cpp rename to Modules/Qmitk/QmitkDataStorageListModel.cpp diff --git a/CoreUI/Qmitk/QmitkDataStorageListModel.h b/Modules/Qmitk/QmitkDataStorageListModel.h similarity index 100% rename from CoreUI/Qmitk/QmitkDataStorageListModel.h rename to Modules/Qmitk/QmitkDataStorageListModel.h diff --git a/Modules/Qmitk/QmitkDataStorageTableModel.cpp b/Modules/Qmitk/QmitkDataStorageTableModel.cpp new file mode 100644 index 0000000000..9cf8fbc3b6 --- /dev/null +++ b/Modules/Qmitk/QmitkDataStorageTableModel.cpp @@ -0,0 +1,525 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkDataStorageTableModel.h" + +//# Own includes +#include "mitkNodePredicateBase.h" +#include "mitkProperties.h" +#include "mitkRenderingManager.h" +#include "QmitkEnums.h" +#include "QmitkCustomVariants.h" +#include + +//# Toolkit includes +#include +#include + +//#CTORS/DTOR +QmitkDataStorageTableModel::QmitkDataStorageTableModel(mitk::DataStorage::Pointer _DataStorage + , mitk::NodePredicateBase* _Predicate + , QObject* parent ) +: QAbstractTableModel(parent) +, m_DataStorage(0) +, m_Predicate(0) +, m_BlockEvents(false) +, m_SortDescending(false) +{ + this->SetPredicate(_Predicate); + this->SetDataStorage(_DataStorage); +} + +QmitkDataStorageTableModel::~QmitkDataStorageTableModel() +{ + // set data storage 0 to remove event listeners + this->SetDataStorage(0); +} + +//# Public GETTER +const mitk::DataStorage::Pointer QmitkDataStorageTableModel::GetDataStorage() const +{ + return m_DataStorage.GetPointer(); +} + +mitk::NodePredicateBase::Pointer QmitkDataStorageTableModel::GetPredicate() const +{ + return m_Predicate; +} + +mitk::DataNode::Pointer QmitkDataStorageTableModel::GetNode( const QModelIndex &index ) const +{ + mitk::DataNode::Pointer node; + + if(index.isValid()) + { + node = m_NodeSet.at(index.row()); + } + + return node; +} + + +QVariant QmitkDataStorageTableModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + QVariant headerData; + + // show only horizontal header + if ( role == Qt::DisplayRole ) + { + if( orientation == Qt::Horizontal ) + { + // first column: "Name" + if(section == 0) + headerData = "Name"; + else if(section == 1) + headerData = "Data Type"; + else if(section == 2) + headerData = "Visibility"; + } + else if( orientation == Qt::Vertical ) + { + // show numbers for rows + headerData = section+1; + } + } + + return headerData; +} + +Qt::ItemFlags QmitkDataStorageTableModel::flags(const QModelIndex &index) const +{ + Qt::ItemFlags flags = QAbstractItemModel::flags(index); + + // name & visibility is editable + if (index.column() == 0) + { + flags |= Qt::ItemIsEditable; + } + else if (index.column() == 2) + { + flags |= Qt::ItemIsUserCheckable; + } + + return flags; +} + +int QmitkDataStorageTableModel::rowCount(const QModelIndex &) const +{ + return m_NodeSet.size(); +} + +int QmitkDataStorageTableModel::columnCount(const QModelIndex &) const +{ + // show name, type and visible columnn + int columns = 3; + return columns; +} + +QVariant QmitkDataStorageTableModel::data(const QModelIndex &index, int role) const +{ + QVariant data; + + if (index.isValid() && !m_NodeSet.empty()) + { + mitk::DataNode::Pointer node = m_NodeSet.at(index.row()); + + std::string nodeName = node->GetName(); + if(nodeName.empty()) + nodeName = "unnamed"; + + // get name + if(index.column() == 0) + { + // get name of node (may also be edited) + if (role == Qt::DisplayRole || role == Qt::EditRole) + { + data = nodeName.c_str(); + } + else if (role == QmitkDataNodeRole) + { + data = QVariant::fromValue(node); + } + } + else if (index.column() == 1) + { + + QmitkNodeDescriptor* nodeDescriptor + = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(node); + + // get type property of mitk::BaseData + if (role == Qt::DisplayRole) + { + + data = nodeDescriptor->GetClassName(); + } + // show some nice icons for datatype + else if(role == Qt::DecorationRole) + { + data = nodeDescriptor->GetIcon(); + } + } + else if (index.column() == 2) + { + // get visible property of mitk::BaseData + bool visibility = false; + + if(node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole) + { + data = (visibility ? Qt::Checked : Qt::Unchecked); + } // node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole + + } // index.column() == 2 + + } // index.isValid() && !m_NodeSet.empty() + return data; +} + +//# Public SETTERS +void QmitkDataStorageTableModel::SetPredicate( mitk::NodePredicateBase* _Predicate ) +{ + // ensure that a new predicate is set in order to avoid unnecessary changed events + if(m_Predicate != _Predicate) + { + m_Predicate = _Predicate; + this->Reset(); + } +} + +void QmitkDataStorageTableModel::SetDataStorage( mitk::DataStorage::Pointer _DataStorage ) +{ + // only proceed if we have a new datastorage + if(m_DataStorage.GetPointer() != _DataStorage.GetPointer()) + { + // if a data storage was set before remove old event listeners + if(m_DataStorage.IsNotNull()) + { + this->m_DataStorage->AddNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::AddNode ) ); + + this->m_DataStorage->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::RemoveNode ) ); + } + + // set new data storage + m_DataStorage = _DataStorage.GetPointer(); + + // if new storage is not 0 subscribe for events + if(m_DataStorage.IsNotNull()) + { + // subscribe for node added/removed events + this->m_DataStorage->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::AddNode ) ); + + this->m_DataStorage->RemoveNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTableModel::RemoveNode ) ); + } + + // Reset model (even if datastorage is 0->will be checked in Reset()) + this->Reset(); + } +} + + +void QmitkDataStorageTableModel::AddNode( const mitk::DataNode* node ) +{ + // garantuee no recursions when a new node event is thrown + if(!m_BlockEvents) + { + // if we have a predicate, check node against predicate first + if(m_Predicate.IsNotNull() && !m_Predicate->CheckNode(node)) + return; + + // dont add nodes without data (formerly known as helper objects) + if(node->GetData() == 0) + return; + + // create listener commands to listen to changes in the name or the visibility of the node + itk::MemberCommand::Pointer propertyModifiedCommand + = itk::MemberCommand::New(); + propertyModifiedCommand->SetCallbackFunction(this, &QmitkDataStorageTableModel::PropertyModified); + + mitk::BaseProperty* tempProperty = 0; + + // add listener for properties + tempProperty = node->GetProperty("visible"); + if(tempProperty) + m_VisiblePropertyModifiedObserverTags[tempProperty] + = tempProperty->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); + + tempProperty = node->GetProperty("name"); + if(tempProperty) + m_NamePropertyModifiedObserverTags[tempProperty] + = tempProperty->AddObserver(itk::ModifiedEvent(), propertyModifiedCommand); + + // emit beginInsertRows event + beginInsertRows(QModelIndex(), m_NodeSet.size(), m_NodeSet.size()); + + // add node + m_NodeSet.push_back(const_cast(node)); + + // emit endInsertRows event + endInsertRows(); + } +} + +void QmitkDataStorageTableModel::RemoveNode( const mitk::DataNode* node ) +{ + // garantuee no recursions when a new node event is thrown + if(!m_BlockEvents) + { + // find corresponding node + std::vector::iterator nodeIt + = std::find(m_NodeSet.begin(), m_NodeSet.end(), node); + + if(nodeIt != m_NodeSet.end()) + { + // now: remove listeners for name property ... + mitk::BaseProperty* tempProperty = 0; + + tempProperty = (*nodeIt)->GetProperty("visible"); + if(tempProperty) + tempProperty->RemoveObserver(m_VisiblePropertyModifiedObserverTags[tempProperty]); + m_VisiblePropertyModifiedObserverTags.erase(tempProperty); + + // ... and visibility property + tempProperty = (*nodeIt)->GetProperty("name"); + if(tempProperty) + tempProperty->RemoveObserver(m_NamePropertyModifiedObserverTags[tempProperty]); + m_NamePropertyModifiedObserverTags.erase(tempProperty); + + // get an index from iterator + int row = std::distance(m_NodeSet.begin(), nodeIt); + + // emit beginRemoveRows event (QModelIndex is empty because we dont have a tree model) + this->beginRemoveRows(QModelIndex(), row, row); + + // remove node + m_NodeSet.erase(nodeIt); + + // emit endRemoveRows event + endRemoveRows(); + } + } +} + +void QmitkDataStorageTableModel::PropertyModified( const itk::Object *caller, const itk::EventObject & ) +{ + if(!m_BlockEvents) + { + // get modified property + const mitk::BaseProperty* modifiedProperty = dynamic_cast(caller); + + if(modifiedProperty) + { + // find node that holds the modified property + int row = -1; + int column = -1; + + std::vector::iterator it; + mitk::BaseProperty* visibilityProperty = 0; + mitk::BaseProperty* nameProperty = 0; + + // search for property that changed and emit datachanged on the corresponding ModelIndex + for(it=m_NodeSet.begin(); it!=m_NodeSet.end(); it++) + { + // check for the visible property or the name property + visibilityProperty = (*it)->GetProperty("visible"); + if(modifiedProperty == visibilityProperty) + { + column = 2; + break; + } + + nameProperty = (*it)->GetProperty("name"); + if(modifiedProperty == nameProperty) + { + column = 0; + break; + } + } + + // if we have the property we have a valid iterator + if( it != m_NodeSet.end() ) + row = std::distance(m_NodeSet.begin(), it); + + // now emit the dataChanged signal + QModelIndex indexOfChangedProperty = index(row, column); + emit dataChanged(indexOfChangedProperty, indexOfChangedProperty); + } + } +} + +bool QmitkDataStorageTableModel::setData(const QModelIndex &index, const QVariant &value, + int role) +{ + bool noErr = false; + + if (index.isValid() && (role == Qt::EditRole || role == Qt::CheckStateRole)) + { + // any change events produced here should not be caught in this class + // --> set m_BlockEvents to true + m_BlockEvents = true; + + mitk::DataNode::Pointer node = m_NodeSet.at(index.row()); + + if(index.column() == 0) + { + node->SetStringProperty("name", value.toString().toStdString().c_str()); + } + else if(index.column() == 2) + { + node->SetBoolProperty("visible", (value.toInt() == Qt::Checked ? true : false)); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + + // inform listeners about changes + emit dataChanged(index, index); + + m_BlockEvents = false; + noErr = true; + } + + return noErr; +} + +//#Protected SETTER +void QmitkDataStorageTableModel::Reset() +{ + mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet; + + // remove all nodes now (dont use iterators because removing elements + // would invalidate the iterator) + // start at the last element: first in, last out + unsigned int i = m_NodeSet.size(); + while(!m_NodeSet.empty()) + { + --i; + this->RemoveNode(m_NodeSet.at(i)); + } + + // normally now everything should be empty->just to be sure + // erase all arrays again + m_NamePropertyModifiedObserverTags.clear(); + m_VisiblePropertyModifiedObserverTags.clear(); + m_NodeSet.clear(); + + // the whole reset depends on the fact if a data storage is set or not + if(m_DataStorage.IsNotNull()) + { + if(m_Predicate.IsNotNull()) + // get subset + _NodeSet = m_DataStorage->GetSubset(m_Predicate); + // if predicate is NULL, select all nodes + else + { + _NodeSet = m_DataStorage->GetAll(); + // remove ghost root node + } + + // finally add all nodes to the model + for(mitk::DataStorage::SetOfObjects::const_iterator it=_NodeSet->begin(); it!=_NodeSet->end() + ; it++) + { + // save node + this->AddNode(*it); + } + + } +} + +void QmitkDataStorageTableModel::sort( int column, Qt::SortOrder order /*= Qt::AscendingOrder */ ) +{ + bool sortDescending = (order == Qt::DescendingOrder) ? true: false; + + // do not sort twice !!! (dont know why, but qt calls this func twice. STUPID!) +/* + if(sortDescending != m_SortDescending) + {*/ + + //m_SortDescending = sortDescending; + + DataNodeCompareFunction::CompareCriteria _CompareCriteria + = DataNodeCompareFunction::CompareByName; + + DataNodeCompareFunction::CompareOperator _CompareOperator + = sortDescending ? DataNodeCompareFunction::Greater: DataNodeCompareFunction::Less; + + if(column == 1) + _CompareCriteria = DataNodeCompareFunction::CompareByClassName; + + else if(column == 2) + _CompareCriteria = DataNodeCompareFunction::CompareByVisibility; + + + DataNodeCompareFunction compareFunc(_CompareCriteria, _CompareOperator); + std::sort(m_NodeSet.begin(), m_NodeSet.end(), compareFunc); + + QAbstractTableModel::reset(); + //} +} + +std::vector QmitkDataStorageTableModel::GetNodeSet() const +{ + return m_NodeSet; +} + +QmitkDataStorageTableModel::DataNodeCompareFunction::DataNodeCompareFunction( CompareCriteria _CompareCriteria + , CompareOperator _CompareOperator ) + : m_CompareCriteria(_CompareCriteria) + , m_CompareOperator(_CompareOperator) +{ +} + +bool QmitkDataStorageTableModel::DataNodeCompareFunction::operator() +( const mitk::DataNode::Pointer& _Left + , const mitk::DataNode::Pointer& _Right ) const +{ + switch(m_CompareCriteria) + { + case CompareByClassName: + if(m_CompareOperator == Less) + return (_Left->GetData()->GetNameOfClass() < _Right->GetData()->GetNameOfClass() ); + else + return (_Left->GetData()->GetNameOfClass() > _Right->GetData()->GetNameOfClass() ); + break; + + case CompareByVisibility: + { + + bool _LeftVisibility = false; + bool _RightVisibility = false; + _Left->GetVisibility(_LeftVisibility, 0); + _Right->GetVisibility(_RightVisibility, 0); + + if(m_CompareOperator == Less) + return (_LeftVisibility < _RightVisibility); + else + return (_LeftVisibility > _RightVisibility); + } + break; + + // CompareByName: + default: + if(m_CompareOperator == Less) + return (_Left->GetName() < _Right->GetName()); + else + return (_Left->GetName() > _Right->GetName()); + break; + } +} + diff --git a/CoreUI/Qmitk/QmitkDataStorageTableModel.h b/Modules/Qmitk/QmitkDataStorageTableModel.h similarity index 100% rename from CoreUI/Qmitk/QmitkDataStorageTableModel.h rename to Modules/Qmitk/QmitkDataStorageTableModel.h diff --git a/Modules/Qmitk/QmitkDataStorageTreeModel.cpp b/Modules/Qmitk/QmitkDataStorageTreeModel.cpp new file mode 100644 index 0000000000..ab86eaa4c7 --- /dev/null +++ b/Modules/Qmitk/QmitkDataStorageTreeModel.cpp @@ -0,0 +1,862 @@ +/*========================================================================= + + Program: MITK + Language: C++ + Date: $Date: 2008-08-13 16:56:36 +0200 (Mi, 13 Aug 2008) $ + Version: $Revision: 14972 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "QmitkDataStorageTreeModel.h" +#include "QmitkNodeDescriptorManager.h" +#include +#include + +#include +#include +#include + +#include + +QmitkDataStorageTreeModel::QmitkDataStorageTreeModel( mitk::DataStorage* _DataStorage + , bool _PlaceNewNodesOnTop + , bool _ShowHelperObjects + , bool _ShowNodesContainingNoData + , QObject* parent ) +: QAbstractItemModel(parent) +, m_DataStorage(0) +, m_PlaceNewNodesOnTop(_PlaceNewNodesOnTop) +, m_ShowHelperObjects(_ShowHelperObjects) +, m_ShowNodesContainingNoData(_ShowNodesContainingNoData) +, m_Root(0) +{ + this->UpdateNodeVisibility(); + this->SetDataStorage(_DataStorage); +} + +QmitkDataStorageTreeModel::~QmitkDataStorageTreeModel() +{ + // set data storage to 0 = remove all listeners + this->SetDataStorage(0); + m_Root->Delete(); m_Root = 0; + + //Removing all observers + for ( NodeTagMapType::iterator dataIter = m_HelperObjectObserverTags.begin(); dataIter != m_HelperObjectObserverTags.end(); ++dataIter ) + { + (*dataIter).first->GetProperty("helper object")->RemoveObserver( (*dataIter).second ); + } + m_HelperObjectObserverTags.clear(); +} + +mitk::DataNode::Pointer QmitkDataStorageTreeModel::GetNode( const QModelIndex &index ) const +{ + return this->TreeItemFromIndex(index)->GetDataNode(); +} + +const mitk::DataStorage::Pointer QmitkDataStorageTreeModel::GetDataStorage() const +{ + return m_DataStorage.GetPointer(); +} + +QModelIndex QmitkDataStorageTreeModel::index( int row, int column, const QModelIndex & parent ) const +{ + TreeItem* parentItem; + + if (!parent.isValid()) + parentItem = m_Root; + else + parentItem = static_cast(parent.internalPointer()); + + TreeItem *childItem = parentItem->GetChild(row); + if (childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); + + +} + +int QmitkDataStorageTreeModel::rowCount(const QModelIndex &parent) const +{ + TreeItem *parentTreeItem = this->TreeItemFromIndex(parent); + return parentTreeItem->GetChildCount(); +} + + +Qt::ItemFlags QmitkDataStorageTreeModel::flags( const QModelIndex& index ) const +{ + if (index.isValid()) + return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable + | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; + else + return Qt::ItemIsDropEnabled; +} + +int QmitkDataStorageTreeModel::columnCount( const QModelIndex& /* parent = QModelIndex() */ ) const +{ + return 1; +} + +QModelIndex QmitkDataStorageTreeModel::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + TreeItem *childItem = this->TreeItemFromIndex(index); + TreeItem *parentItem = childItem->GetParent(); + + if (parentItem == m_Root) + return QModelIndex(); + + return this->createIndex(parentItem->GetIndex(), 0, parentItem); +} + +QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItemFromIndex( const QModelIndex &index ) const +{ + if (index.isValid()) + return static_cast(index.internalPointer()); + else + return m_Root; +} +Qt::DropActions QmitkDataStorageTreeModel::supportedDropActions() const +{ + return Qt::CopyAction | Qt::MoveAction; +} + +Qt::DropActions QmitkDataStorageTreeModel::supportedDragActions() const +{ + return Qt::CopyAction | Qt::MoveAction; +} + +bool QmitkDataStorageTreeModel::dropMimeData(const QMimeData *data, + Qt::DropAction action, int /*row*/, int /*column*/, const QModelIndex &parent) +{ + // Early exit, returning true, but not actually doing anything (ignoring data). + if (action == Qt::IgnoreAction) + { + return true; + } + + // Note, we are returning true if we handled it, and false otherwise + bool returnValue = false; + + if(data->hasFormat("application/x-qabstractitemmodeldatalist")) + { + returnValue = true; + + // First we extract a Qlist of TreeItem* pointers. + QString arg = QString(data->data("application/x-qabstractitemmodeldatalist").data()); + QStringList listOfTreeItemAddressPointers = arg.split(","); + + QStringList::iterator slIter; + QList listOfItemsToDrop; + + for(slIter = listOfTreeItemAddressPointers.begin(); + slIter != listOfTreeItemAddressPointers.end(); + slIter++) + { + long val = (*slIter).toLong(); + listOfItemsToDrop << static_cast((void*)val); + } + + // Retrieve the TreeItem* where we are dropping stuff, and its parent. + TreeItem* dropItem = this->TreeItemFromIndex(parent); + TreeItem* parentItem = dropItem->GetParent(); + + // If item was dropped onto empty space, we select the root node + if(dropItem == m_Root) + { + parentItem = m_Root; + } + + // Dragging and Dropping is only allowed within the same parent, so use the first item in list to validate. + // (otherwise, you could have a derived image such as a segmentation, and assign it to another image). + // NOTE: We are assuming the input list is valid... i.e. when it was dragged, all the items had the same parent. + + if(listOfItemsToDrop[0] != dropItem && listOfItemsToDrop[0]->GetParent() == parentItem) + { + // Retrieve the index of where we are dropping stuff. + QModelIndex dropItemModelIndex = this->IndexFromTreeItem(dropItem); + QModelIndex parentModelIndex = this->IndexFromTreeItem(parentItem); + + // Iterate through the list of TreeItem (which may be at non-consecutive indexes). + QList::iterator diIter; + for (diIter = listOfItemsToDrop.begin(); + diIter != listOfItemsToDrop.end(); + diIter++) + { + // Here we assume that as you remove items, one at a time, that GetIndex() will be valid. + this->beginRemoveRows(parentModelIndex, (*diIter)->GetIndex(), (*diIter)->GetIndex()); + parentItem->RemoveChild(*diIter); + this->endRemoveRows(); + } + + // Select the target index position, or put it at the end of the list. + int dropIndex = dropItemModelIndex.row(); + if (dropIndex == -1) + { + dropIndex = parentItem->GetChildCount(); + } + + // Now insert items again at the drop item position + this->beginInsertRows(parentModelIndex, dropIndex, dropIndex + listOfItemsToDrop.size() - 1); + + for (diIter = listOfItemsToDrop.begin(); + diIter != listOfItemsToDrop.end(); + diIter++) + { + parentItem->InsertChild( (*diIter), dropIndex ); + dropIndex++; + } + this->endInsertRows(); + + // Change Layers to match. + this->AdjustLayerProperty(); + } + } + else if(data->hasFormat("application/x-mitk-datanodes")) + { + returnValue = true; + + QString arg = QString(data->data("application/x-mitk-datanodes").data()); + QStringList listOfDataNodeAddressPointers = arg.split(","); + int numberOfNodesDropped = 0; + + QStringList::iterator slIter; + for (slIter = listOfDataNodeAddressPointers.begin(); + slIter != listOfDataNodeAddressPointers.end(); + slIter++) + { + long val = (*slIter).toLong(); + mitk::DataNode* node = static_cast((void*)val); + + if(node && m_DataStorage.IsNotNull() && !m_DataStorage->Exists(node)) + { + m_DataStorage->Add( node ); + mitk::BaseData::Pointer basedata = node->GetData(); + + if (basedata.IsNotNull()) + { + mitk::RenderingManager::GetInstance()->InitializeViews( + basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + + numberOfNodesDropped++; + } + } + } + // Only do a rendering update, if we actually dropped anything. + if (numberOfNodesDropped > 0) + { + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + } + + return returnValue; +} + +QStringList QmitkDataStorageTreeModel::mimeTypes() const +{ + QStringList types = QAbstractItemModel::mimeTypes(); + types << "application/x-qabstractitemmodeldatalist"; + types << "application/x-mitk-datanodes"; + return types; +} + +QMimeData * QmitkDataStorageTreeModel::mimeData(const QModelIndexList & indexes) const{ + + QMimeData * ret = new QMimeData; + + QString treeItemAddresses(""); + QString dataNodeAddresses(""); + + for (int i = 0; i < indexes.size(); i++) + { + TreeItem* treeItem = static_cast(indexes.at(i).internalPointer()); + long treeItemAddress = reinterpret_cast(treeItem); + long dataNodeAddress = reinterpret_cast(treeItem->GetDataNode().GetPointer()); + QTextStream(&treeItemAddresses) << treeItemAddress; + QTextStream(&dataNodeAddresses) << dataNodeAddress; + + if (i != indexes.size() - 1) + { + QTextStream(&treeItemAddresses) << ","; + QTextStream(&dataNodeAddresses) << ","; + } + } + + ret->setData("application/x-qabstractitemmodeldatalist", QByteArray(treeItemAddresses.toAscii())); + ret->setData("application/x-mitk-datanodes", QByteArray(dataNodeAddresses.toAscii())); + + return ret; +} + +QVariant QmitkDataStorageTreeModel::data( const QModelIndex & index, int role ) const +{ + mitk::DataNode* dataNode = this->TreeItemFromIndex(index)->GetDataNode(); + + // get name of treeItem (may also be edited) + QString nodeName = QString::fromStdString(dataNode->GetName()); + if(nodeName.isEmpty()) + nodeName = "unnamed"; + + if (role == Qt::DisplayRole) + return nodeName; + else if(role == Qt::ToolTipRole) + return nodeName; + else if(role == Qt::DecorationRole) + { + QmitkNodeDescriptor* nodeDescriptor + = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(dataNode); + return nodeDescriptor->GetIcon(); + } + else if(role == Qt::CheckStateRole) + { + return dataNode->IsVisible(0); + } + else if(role == QmitkDataNodeRole) + { + return QVariant::fromValue(mitk::DataNode::Pointer(dataNode)); + } + + return QVariant(); +} + +QVariant QmitkDataStorageTreeModel::headerData(int /*section*/, + Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole && m_Root) + return QString::fromStdString(m_Root->GetDataNode()->GetName()); + + return QVariant(); +} + +void QmitkDataStorageTreeModel::SetDataStorage( mitk::DataStorage* _DataStorage ) +{ + if(m_DataStorage != _DataStorage) // dont take the same again + { + if(m_DataStorage.IsNotNull()) + { + // remove Listener for the data storage itself + m_DataStorage.ObjectDelete.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetDataStorageDeleted ) ); + + // remove listeners for the nodes + m_DataStorage->AddNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::AddNode ) ); + + m_DataStorage->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetNodeModified ) ); + + m_DataStorage->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::RemoveNode ) ); + + } + + // take over the new data storage + m_DataStorage = _DataStorage; + + // delete the old root (if necessary, create new) + if(m_Root) + m_Root->Delete(); + mitk::DataNode::Pointer rootDataNode = mitk::DataNode::New(); + rootDataNode->SetName("Data Manager"); + m_Root = new TreeItem(rootDataNode, 0); + this->reset(); + + if(m_DataStorage.IsNotNull()) + { + // add Listener for the data storage itself + m_DataStorage.ObjectDelete.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetDataStorageDeleted ) ); + + // add listeners for the nodes + m_DataStorage->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::AddNode ) ); + + m_DataStorage->ChangedNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::SetNodeModified ) ); + + m_DataStorage->RemoveNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkDataStorageTreeModel::RemoveNode ) ); + + mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = m_DataStorage->GetSubset(m_Predicate); + + // finally add all nodes to the model + this->Update(); + } + } +} + +void QmitkDataStorageTreeModel::SetDataStorageDeleted( const itk::Object* /*_DataStorage*/ ) +{ + this->SetDataStorage(0); +} + +void QmitkDataStorageTreeModel::AddNodeInternal(const mitk::DataNode *node) +{ + if(node == 0 + || m_DataStorage.IsNull() + || !m_DataStorage->Exists(node) + || !m_Predicate->CheckNode(node) + || m_Root->Find(node) != 0) + return; + + // find out if we have a root node + TreeItem* parentTreeItem = m_Root; + QModelIndex index; + mitk::DataNode* parentDataNode = this->GetParentNode(node); + + if(parentDataNode) // no top level data node + { + parentTreeItem = m_Root->Find(parentDataNode); // find the corresponding tree item + if(!parentTreeItem) + { + this->AddNode(parentDataNode); + parentTreeItem = m_Root->Find(parentDataNode); + if(!parentTreeItem) + return; + } + + // get the index of this parent with the help of the grand parent + index = this->createIndex(parentTreeItem->GetIndex(), 0, parentTreeItem); + } + + // add node + if(m_PlaceNewNodesOnTop) + { + // emit beginInsertRows event + beginInsertRows(index, 0, 0); + parentTreeItem->InsertChild(new TreeItem( + const_cast(node)), 0); + } + else + { + beginInsertRows(index, parentTreeItem->GetChildCount() + , parentTreeItem->GetChildCount()); + new TreeItem(const_cast(node), parentTreeItem); + } + + // emit endInsertRows event + endInsertRows(); + + this->AdjustLayerProperty(); +} + +void QmitkDataStorageTreeModel::AddNode( const mitk::DataNode* node ) +{ + if(node == 0 + || m_DataStorage.IsNull() + || !m_DataStorage->Exists(node) + || !m_Predicate->CheckNode(node) + || m_Root->Find(node) != 0) + return; + + bool isHelperObject (false); + NodeTagMapType::iterator searchIter = m_HelperObjectObserverTags.find( const_cast(node) ); + if (node->GetBoolProperty("helper object", isHelperObject) && searchIter == m_HelperObjectObserverTags.end()) { + itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + command->SetCallbackFunction(this, &QmitkDataStorageTreeModel::UpdateNodeVisibility); + m_HelperObjectObserverTags.insert( std::pair( const_cast(node), node->GetProperty("helper object")->AddObserver( itk::ModifiedEvent(), command ) ) ); + } + + this->AddNodeInternal(node); +} + + +void QmitkDataStorageTreeModel::SetPlaceNewNodesOnTop(bool _PlaceNewNodesOnTop) +{ + m_PlaceNewNodesOnTop = _PlaceNewNodesOnTop; +} + +void QmitkDataStorageTreeModel::RemoveNodeInternal( const mitk::DataNode* node ) +{ + if(!m_Root) return; + + TreeItem* treeItem = m_Root->Find(node); + if(!treeItem) + return; // return because there is no treeitem containing this node + + TreeItem* parentTreeItem = treeItem->GetParent(); + QModelIndex parentIndex = this->IndexFromTreeItem(parentTreeItem); + + // emit beginRemoveRows event (QModelIndex is empty because we dont have a tree model) + this->beginRemoveRows(parentIndex, treeItem->GetIndex(), treeItem->GetIndex()); + + // remove node + std::vector children = treeItem->GetChildren(); + delete treeItem; + + // emit endRemoveRows event + endRemoveRows(); + + // move all children of deleted node into its parent + for ( std::vector::iterator it = children.begin() + ; it != children.end(); it++) + { + // emit beginInsertRows event + beginInsertRows(parentIndex, parentTreeItem->GetChildCount(), parentTreeItem->GetChildCount()); + + // add nodes again + parentTreeItem->AddChild(*it); + + // emit endInsertRows event + endInsertRows(); + } + + this->AdjustLayerProperty(); +} + +void QmitkDataStorageTreeModel::RemoveNode( const mitk::DataNode* node ) +{ + if (node == 0) + return; + + //Removing Observer + bool isHelperObject (false); + NodeTagMapType::iterator searchIter = m_HelperObjectObserverTags.find( const_cast(node) ); + if (node->GetBoolProperty("helper object", isHelperObject) && searchIter != m_HelperObjectObserverTags.end()) { + (*searchIter).first->GetProperty("helper object")->RemoveObserver( (*searchIter).second ); + m_HelperObjectObserverTags.erase(const_cast(node)); + } + + this->RemoveNodeInternal(node); +} + +void QmitkDataStorageTreeModel::SetNodeModified( const mitk::DataNode* node ) +{ + TreeItem* treeItem = m_Root->Find(node); + if(!treeItem) + return; + + TreeItem* parentTreeItem = treeItem->GetParent(); + // as the root node should not be removed one should always have a parent item + if(!parentTreeItem) + return; + QModelIndex index = this->createIndex(treeItem->GetIndex(), 0, treeItem); + + // now emit the dataChanged signal + emit dataChanged(index, index); +} + +mitk::DataNode* QmitkDataStorageTreeModel::GetParentNode( const mitk::DataNode* node ) const +{ + mitk::DataNode* dataNode = 0; + + mitk::DataStorage::SetOfObjects::ConstPointer _Sources = m_DataStorage->GetSources(node); + + if(_Sources->Size() > 0) + dataNode = _Sources->front(); + + return dataNode; +} + +bool QmitkDataStorageTreeModel::setData( const QModelIndex &index, const QVariant &value, int role ) +{ + mitk::DataNode* dataNode = this->TreeItemFromIndex(index)->GetDataNode(); + if(!dataNode) + return false; + + if(role == Qt::EditRole && !value.toString().isEmpty()) + { + dataNode->SetStringProperty("name", value.toString().toStdString().c_str()); + } + else if(role == Qt::CheckStateRole) + { + // Please note: value.toInt() returns 2, independentely from the actual checkstate of the index element. + // Therefore the checkstate is being estimated again here. + + QVariant qcheckstate = index.data(Qt::CheckStateRole); + int checkstate = qcheckstate.toInt(); + bool isVisible = bool(checkstate); + dataNode->SetVisibility(!isVisible); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + // inform listeners about changes + emit dataChanged(index, index); + return true; +} + +bool QmitkDataStorageTreeModel::setHeaderData( int /*section*/, Qt::Orientation /*orientation*/, const QVariant& /* value */, int /*role = Qt::EditRole*/ ) +{ + return false; +} + +void QmitkDataStorageTreeModel::AdjustLayerProperty() +{ + /// transform the tree into an array and set the layer property descending + std::vector vec; + this->TreeToVector(m_Root, vec); + + int i = vec.size()-1; + for(std::vector::const_iterator it = vec.begin(); it != vec.end(); ++it) + { + (*it)->GetDataNode()->SetIntProperty("layer", i); + --i; + } + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkDataStorageTreeModel::TreeToVector(TreeItem* parent, std::vector& vec) const +{ + TreeItem* current; + for(int i = 0; iGetChildCount(); ++i) + { + current = parent->GetChild(i); + this->TreeToVector(current, vec); + vec.push_back(current); + } +} + +QModelIndex QmitkDataStorageTreeModel::IndexFromTreeItem( TreeItem* item ) const +{ + if(item == m_Root) + return QModelIndex(); + else + return this->createIndex(item->GetIndex(), 0, item); +} + +QList QmitkDataStorageTreeModel::GetNodeSet() const +{ + QList res; + if(m_Root) + this->TreeToNodeSet(m_Root, res); + + return res; +} + +void QmitkDataStorageTreeModel::TreeToNodeSet( TreeItem* parent, QList& vec ) const +{ + TreeItem* current; + for(int i = 0; iGetChildCount(); ++i) + { + current = parent->GetChild(i); + vec.push_back(current->GetDataNode()); + this->TreeToNodeSet(current, vec); + } +} + +QModelIndex QmitkDataStorageTreeModel::GetIndex( const mitk::DataNode* node ) const +{ + if(m_Root) + { + TreeItem* item = m_Root->Find(node); + if(item) + return this->IndexFromTreeItem(item); + } + return QModelIndex(); +} + +QmitkDataStorageTreeModel::TreeItem::TreeItem( mitk::DataNode* _DataNode, TreeItem* _Parent ) +: m_Parent(_Parent) +, m_DataNode(_DataNode) +{ + if(m_Parent) + m_Parent->AddChild(this); +} + +QmitkDataStorageTreeModel::TreeItem::~TreeItem() +{ + if(m_Parent) + m_Parent->RemoveChild(this); +} + +void QmitkDataStorageTreeModel::TreeItem::Delete() +{ + while(m_Children.size() > 0) + delete m_Children.back(); + + delete this; +} + +QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::Find( const mitk::DataNode* _DataNode ) const +{ + QmitkDataStorageTreeModel::TreeItem* item = 0; + if(_DataNode) + { + if(m_DataNode == _DataNode) + item = const_cast(this); + else + { + for(std::vector::const_iterator it = m_Children.begin(); it != m_Children.end(); ++it) + { + if(item) + break; + item = (*it)->Find(_DataNode); + } + } + } + return item; +} + +int QmitkDataStorageTreeModel::TreeItem::IndexOfChild( const TreeItem* item ) const +{ + std::vector::const_iterator it = std::find(m_Children.begin(), m_Children.end(), item); + return it != m_Children.end() ? std::distance(m_Children.begin(), it): -1; +} + +QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::GetChild( int index ) const +{ + return (m_Children.size() > 0 && index >= 0 && index < (int)m_Children.size())? m_Children.at(index): 0; +} + +void QmitkDataStorageTreeModel::TreeItem::AddChild( TreeItem* item ) +{ + this->InsertChild(item); +} + +void QmitkDataStorageTreeModel::TreeItem::RemoveChild( TreeItem* item ) +{ + std::vector::iterator it = std::find(m_Children.begin(), m_Children.end(), item); + if(it != m_Children.end()) + { + m_Children.erase(it); + item->SetParent(0); + } +} + +int QmitkDataStorageTreeModel::TreeItem::GetChildCount() const +{ + return m_Children.size(); +} + +int QmitkDataStorageTreeModel::TreeItem::GetIndex() const +{ + if (m_Parent) + return m_Parent->IndexOfChild(this); + + return 0; +} + +QmitkDataStorageTreeModel::TreeItem* QmitkDataStorageTreeModel::TreeItem::GetParent() const +{ + return m_Parent; +} + +mitk::DataNode::Pointer QmitkDataStorageTreeModel::TreeItem::GetDataNode() const +{ + return m_DataNode; +} + +void QmitkDataStorageTreeModel::TreeItem::InsertChild( TreeItem* item, int index ) +{ + std::vector::iterator it = std::find(m_Children.begin(), m_Children.end(), item); + if(it == m_Children.end()) + { + if(m_Children.size() > 0 && index >= 0 && index < (int)m_Children.size()) + { + it = m_Children.begin(); + std::advance(it, index); + m_Children.insert(it, item); + } + else + m_Children.push_back(item); + + // add parent if necessary + if(item->GetParent() != this) + item->SetParent(this); + } +} + +std::vector QmitkDataStorageTreeModel::TreeItem::GetChildren() const +{ + return m_Children; +} + +void QmitkDataStorageTreeModel::TreeItem::SetParent( TreeItem* _Parent ) +{ + m_Parent = _Parent; + if(m_Parent) + m_Parent->AddChild(this); +} + +void QmitkDataStorageTreeModel::SetShowHelperObjects(bool _ShowHelperObjects) +{ + m_ShowHelperObjects = _ShowHelperObjects; + this->UpdateNodeVisibility(); +} + +void QmitkDataStorageTreeModel::SetShowNodesContainingNoData(bool _ShowNodesContainingNoData) +{ + m_ShowNodesContainingNoData = _ShowNodesContainingNoData; + this->UpdateNodeVisibility(); +} + +void QmitkDataStorageTreeModel::UpdateNodeVisibility() +{ + mitk::NodePredicateData::Pointer dataIsNull = mitk::NodePredicateData::New(0); + mitk::NodePredicateNot::Pointer dataIsNotNull = mitk::NodePredicateNot::New(dataIsNull);// Show only nodes that really contain dat + + if (m_ShowHelperObjects) + { + if (m_ShowNodesContainingNoData) + { + // Show every node + m_Predicate = mitk::NodePredicateOr::New(dataIsNull, dataIsNotNull); + } + else + { + // Show helper objects but not nodes containing no data + m_Predicate = dataIsNotNull; + } + } + else + { + mitk::NodePredicateProperty::Pointer isHelperObject = mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true)); + mitk::NodePredicateNot::Pointer isNotHelperObject = mitk::NodePredicateNot::New(isHelperObject);// Show only nodes that are not helper objects + if (m_ShowNodesContainingNoData) + { + // Don't show helper objects but nodes containing no data + m_Predicate = isNotHelperObject; + } + else + { + // Don't show helper objects and nodes containing no data + m_Predicate = mitk::NodePredicateAnd::New(isNotHelperObject, dataIsNotNull); + } + } + this->Update(); +} + +void QmitkDataStorageTreeModel::Update() +{ + if (m_DataStorage.IsNotNull()) + { + this->reset(); + + mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = m_DataStorage->GetSubset(m_Predicate); + + for(mitk::DataStorage::SetOfObjects::const_iterator it=_NodeSet->begin(); it!=_NodeSet->end(); it++) + { + // save node + this->AddNodeInternal(*it); + } + + mitk::DataStorage::SetOfObjects::ConstPointer _NotNodeSet = m_DataStorage->GetSubset(mitk::NodePredicateNot::New(m_Predicate)); + + for(mitk::DataStorage::SetOfObjects::const_iterator it=_NotNodeSet->begin(); it!=_NotNodeSet->end(); it++) + { + // remove node + this->RemoveNodeInternal(*it); + } + + } +} + diff --git a/Modules/Qmitk/QmitkDataStorageTreeModel.h b/Modules/Qmitk/QmitkDataStorageTreeModel.h new file mode 100644 index 0000000000..0ef751248d --- /dev/null +++ b/Modules/Qmitk/QmitkDataStorageTreeModel.h @@ -0,0 +1,289 @@ +/*========================================================================= + + Program: MITK + Language: C++ + Date: $Date: 2008-08-13 16:56:36 +0200 (Mi, 13 Aug 2008) $ + Version: $Revision: 14972 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKDATASTORAGETREEMODEL_H_ +#define QMITKDATASTORAGETREEMODEL_H_ + +#include + +#include +#include +#include + +#include + +#include "QmitkEnums.h" +#include "QmitkCustomVariants.h" + +#include +#include +#include + +class QMITK_EXPORT QmitkDataStorageTreeModel : public QAbstractItemModel +{ +//# CONSTANTS,TYPEDEFS +public: + static const std::string COLUMN_NAME; + static const std::string COLUMN_TYPE; + static const std::string COLUMN_VISIBILITY; + +//# CTORS,DTOR +public: + QmitkDataStorageTreeModel(mitk::DataStorage* _DataStorage + , bool _PlaceNewNodesOnTop=false + , bool _ShowHelperObjects=false + , bool _ShowNodesContainingNoData=false + , QObject* parent = 0); + ~QmitkDataStorageTreeModel(); + +//# GETTER +public: + + typedef std::map NodeTagMapType; + /// + /// Get node at a specific model index. + /// This function is used to get a node from a QModelIndex + /// + mitk::DataNode::Pointer GetNode(const QModelIndex &index) const; + /// + /// Returns a copy of the node-vector that is shown by this model + /// + virtual QList GetNodeSet() const; + /// + /// Get the DataStorage. + /// + const mitk::DataStorage::Pointer GetDataStorage() const; + + /// + /// Get the top placement flag + /// + bool GetPlaceNewNodesOnTopFlag() + { + return m_PlaceNewNodesOnTop; + } + + /// + /// Get the helper object visibility flag + /// + bool GetShowHelperObjectsFlag() + { + return m_ShowHelperObjects; + } + + /// + /// Get the visibility flag for showing nodes that contain no data + /// + bool GetShowNodesContainingNoDataFlag() + { + return m_ShowNodesContainingNoData; + } + + /// + /// Set the top placement flag + /// + void SetPlaceNewNodesOnTop(bool _PlaceNewNodesOnTop); + + //# (Re-)implemented from QAbstractItemModel + //# Read model + Qt::ItemFlags flags(const QModelIndex& index) const; + QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + int rowCount ( const QModelIndex & parent = QModelIndex() ) const; + int columnCount ( const QModelIndex & parent = QModelIndex() ) const; + //# hierarchical model + /// + /// called whenever the model or the view needs to create a QModelIndex for a particular + /// child item (or a top-level item if parent is an invalid QModelIndex) + /// + QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; + QModelIndex parent ( const QModelIndex & index ) const; + //# editable model + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); + bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); + Qt::DropActions supportedDropActions() const; + Qt::DropActions supportedDragActions() const; + QStringList mimeTypes() const; + QMimeData * mimeData(const QModelIndexList & indexes) const; + + //# End of QAbstractItemModel + +//# SETTER +public: + /// + /// Sets the DataStorage. The whole model will be resetted. + /// + void SetDataStorage(mitk::DataStorage* _DataStorage); + /// + /// Notify that the DataStorage was deleted. The whole model will be resetted. + /// + void SetDataStorageDeleted(const itk::Object* _DataStorage); + /// + /// Adds a node to this model. + /// If a predicate is set (not null) the node will be checked against it.The node has to have a data object (no one wants to see empty nodes). + /// + virtual void AddNode(const mitk::DataNode* node); + /// + /// Removes a node from this model. Also removes any event listener from the node. + /// + virtual void RemoveNode(const mitk::DataNode* node); + /// + /// Sets a node to modfified. Called by the DataStorage + /// + virtual void SetNodeModified(const mitk::DataNode* node); + + /// + /// \return an index for the given datatreenode in the tree. If the node is not found + /// + QModelIndex GetIndex(const mitk::DataNode*) const; + + /// + /// Show or hide helper objects + /// + void SetShowHelperObjects(bool _ShowHelperObjects); + + /// + /// Show or hide objects that contain no data + /// + void SetShowNodesContainingNoData(bool _ShowNodesContainingNoData); + + /// + /// Update the visibility of data nodes according to the preference settings + /// + void UpdateNodeVisibility(); + +//# MISC +protected: + /// + /// Helper class to represent a tree structure of DataNodes + /// + class TreeItem + { + public: + /// + /// Constructs a new TreeItem with the given DataNode (must not be 0) + /// + TreeItem(mitk::DataNode* _DataNode, TreeItem* _Parent=0); + /// + /// Removes itself as child from its parent-> Does not delete its children + /// \sa Delete() + /// + virtual ~TreeItem(); + /// + /// Find the index of an item + /// + int IndexOfChild(const TreeItem* item) const; + /// + /// \child The child at pos index or 0 if it not exists + /// + TreeItem* GetChild(int index) const; + /// + /// Find the TreeItem containing a special tree node (recursive tree function) + /// + TreeItem* Find( const mitk::DataNode* _DataNode) const; + /// + /// Get the amount of children + /// + int GetChildCount() const; + /// + /// \return the index of this node in its parent list + /// + int GetIndex() const; + /// + /// \return the parent of this tree item + /// + TreeItem* GetParent() const; + /// + /// Return the DataNode associated with this node + /// + mitk::DataNode::Pointer GetDataNode() const; + /// + /// Get all children as vector + /// + std::vector GetChildren() const; + + /// + /// add another item as a child of this (only if not already in that list) + /// + void AddChild( TreeItem* item); + /// + /// remove another item as child from this + /// + void RemoveChild( TreeItem* item); + /// + /// inserts a child at the given position. if pos is not in range + /// the element is added at the end + /// + void InsertChild( TreeItem* item, int index=-1 ); + /// Sets the parent on the treeitem + void SetParent(TreeItem* _Parent); + /// + /// Deletes the whole tree branch + /// + void Delete(); + protected: + TreeItem* m_Parent; + std::vector m_Children; + mitk::DataNode::Pointer m_DataNode; + }; + /// + /// Adjusts the LayerProperty according to the nodes position + /// + void AdjustLayerProperty(); + /// + /// invoked after m_DataStorage or m_Predicate changed + /// + TreeItem* TreeItemFromIndex(const QModelIndex &index) const; + /// + /// Gives a ModelIndex for the Tree Item + /// + QModelIndex IndexFromTreeItem(TreeItem*) const; + /// + /// Returns the first element in the nodes sources list (if available) or 0 + /// + mitk::DataNode* GetParentNode(const mitk::DataNode* node) const; + /// + /// Adds all Childs in parent to vec. Before a child is added the function is called recursively + /// + void TreeToVector(TreeItem* parent, std::vector& vec) const; + /// + /// Adds all Childs in parent to vec. Before a child is added the function is called recursively + /// + void TreeToNodeSet(TreeItem* parent, QList &vec) const; + /// + /// Update Tree Model according to predicates + /// + void Update(); + + //# ATTRIBUTES +protected: + mitk::WeakPointer m_DataStorage; + mitk::NodePredicateBase::Pointer m_Predicate; + bool m_PlaceNewNodesOnTop; + bool m_ShowHelperObjects; + bool m_ShowNodesContainingNoData; + TreeItem* m_Root; + + NodeTagMapType m_HelperObjectObserverTags; + +private: + void AddNodeInternal(const mitk::DataNode*); + void RemoveNodeInternal(const mitk::DataNode*); +}; + +#endif /* QMITKDATASTORAGETREEMODEL_H_ */ diff --git a/Modules/Qmitk/QmitkEnums.h b/Modules/Qmitk/QmitkEnums.h new file mode 100755 index 0000000000..641138711b --- /dev/null +++ b/Modules/Qmitk/QmitkEnums.h @@ -0,0 +1,27 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITKENUMS_H_ +#define QMITKENUMS_H_ + +enum QmitkItemModelRole +{ + QmitkDataNodeRole = 64 +}; + +#endif /* QMITKENUMS_H_ */ diff --git a/CoreUI/Qmitk/QmitkEventAdapter.cpp b/Modules/Qmitk/QmitkEventAdapter.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkEventAdapter.cpp rename to Modules/Qmitk/QmitkEventAdapter.cpp diff --git a/CoreUI/Qmitk/QmitkEventAdapter.h b/Modules/Qmitk/QmitkEventAdapter.h similarity index 100% rename from CoreUI/Qmitk/QmitkEventAdapter.h rename to Modules/Qmitk/QmitkEventAdapter.h diff --git a/CoreUI/Qmitk/QmitkLevelWindowPresetDefinition.ui b/Modules/Qmitk/QmitkLevelWindowPresetDefinition.ui similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowPresetDefinition.ui rename to Modules/Qmitk/QmitkLevelWindowPresetDefinition.ui diff --git a/CoreUI/Qmitk/QmitkLevelWindowPresetDefinitionDialog.cpp b/Modules/Qmitk/QmitkLevelWindowPresetDefinitionDialog.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowPresetDefinitionDialog.cpp rename to Modules/Qmitk/QmitkLevelWindowPresetDefinitionDialog.cpp diff --git a/CoreUI/Qmitk/QmitkLevelWindowPresetDefinitionDialog.h b/Modules/Qmitk/QmitkLevelWindowPresetDefinitionDialog.h similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowPresetDefinitionDialog.h rename to Modules/Qmitk/QmitkLevelWindowPresetDefinitionDialog.h diff --git a/CoreUI/Qmitk/QmitkLevelWindowRangeChange.ui b/Modules/Qmitk/QmitkLevelWindowRangeChange.ui similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowRangeChange.ui rename to Modules/Qmitk/QmitkLevelWindowRangeChange.ui diff --git a/CoreUI/Qmitk/QmitkLevelWindowRangeChangeDialog.cpp b/Modules/Qmitk/QmitkLevelWindowRangeChangeDialog.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowRangeChangeDialog.cpp rename to Modules/Qmitk/QmitkLevelWindowRangeChangeDialog.cpp diff --git a/CoreUI/Qmitk/QmitkLevelWindowRangeChangeDialog.h b/Modules/Qmitk/QmitkLevelWindowRangeChangeDialog.h similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowRangeChangeDialog.h rename to Modules/Qmitk/QmitkLevelWindowRangeChangeDialog.h diff --git a/CoreUI/Qmitk/QmitkLevelWindowWidget.cpp b/Modules/Qmitk/QmitkLevelWindowWidget.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowWidget.cpp rename to Modules/Qmitk/QmitkLevelWindowWidget.cpp diff --git a/CoreUI/Qmitk/QmitkLevelWindowWidget.h b/Modules/Qmitk/QmitkLevelWindowWidget.h similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowWidget.h rename to Modules/Qmitk/QmitkLevelWindowWidget.h diff --git a/CoreUI/Qmitk/QmitkLevelWindowWidget.ui b/Modules/Qmitk/QmitkLevelWindowWidget.ui similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowWidget.ui rename to Modules/Qmitk/QmitkLevelWindowWidget.ui diff --git a/CoreUI/Qmitk/QmitkLevelWindowWidgetContextMenu.cpp b/Modules/Qmitk/QmitkLevelWindowWidgetContextMenu.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowWidgetContextMenu.cpp rename to Modules/Qmitk/QmitkLevelWindowWidgetContextMenu.cpp diff --git a/CoreUI/Qmitk/QmitkLevelWindowWidgetContextMenu.h b/Modules/Qmitk/QmitkLevelWindowWidgetContextMenu.h similarity index 100% rename from CoreUI/Qmitk/QmitkLevelWindowWidgetContextMenu.h rename to Modules/Qmitk/QmitkLevelWindowWidgetContextMenu.h diff --git a/CoreUI/Qmitk/QmitkLineEditLevelWindowWidget.cpp b/Modules/Qmitk/QmitkLineEditLevelWindowWidget.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkLineEditLevelWindowWidget.cpp rename to Modules/Qmitk/QmitkLineEditLevelWindowWidget.cpp diff --git a/CoreUI/Qmitk/QmitkLineEditLevelWindowWidget.h b/Modules/Qmitk/QmitkLineEditLevelWindowWidget.h similarity index 100% rename from CoreUI/Qmitk/QmitkLineEditLevelWindowWidget.h rename to Modules/Qmitk/QmitkLineEditLevelWindowWidget.h diff --git a/CoreUI/Qmitk/QmitkMemoryUsageIndicator.ui b/Modules/Qmitk/QmitkMemoryUsageIndicator.ui similarity index 100% rename from CoreUI/Qmitk/QmitkMemoryUsageIndicator.ui rename to Modules/Qmitk/QmitkMemoryUsageIndicator.ui diff --git a/CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesGreen.xpm b/Modules/Qmitk/QmitkMemoryUsageIndicatorImagesGreen.xpm similarity index 100% rename from CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesGreen.xpm rename to Modules/Qmitk/QmitkMemoryUsageIndicatorImagesGreen.xpm diff --git a/CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesOrange.xpm b/Modules/Qmitk/QmitkMemoryUsageIndicatorImagesOrange.xpm similarity index 100% rename from CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesOrange.xpm rename to Modules/Qmitk/QmitkMemoryUsageIndicatorImagesOrange.xpm diff --git a/CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesRed.xpm b/Modules/Qmitk/QmitkMemoryUsageIndicatorImagesRed.xpm similarity index 100% rename from CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesRed.xpm rename to Modules/Qmitk/QmitkMemoryUsageIndicatorImagesRed.xpm diff --git a/CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesYellow.xpm b/Modules/Qmitk/QmitkMemoryUsageIndicatorImagesYellow.xpm similarity index 100% rename from CoreUI/Qmitk/QmitkMemoryUsageIndicatorImagesYellow.xpm rename to Modules/Qmitk/QmitkMemoryUsageIndicatorImagesYellow.xpm diff --git a/CoreUI/Qmitk/QmitkMemoryUsageIndicatorView.cpp b/Modules/Qmitk/QmitkMemoryUsageIndicatorView.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkMemoryUsageIndicatorView.cpp rename to Modules/Qmitk/QmitkMemoryUsageIndicatorView.cpp diff --git a/CoreUI/Qmitk/QmitkMemoryUsageIndicatorView.h b/Modules/Qmitk/QmitkMemoryUsageIndicatorView.h similarity index 100% rename from CoreUI/Qmitk/QmitkMemoryUsageIndicatorView.h rename to Modules/Qmitk/QmitkMemoryUsageIndicatorView.h diff --git a/CoreUI/Qmitk/QmitkMouseModeSwitcher.cpp b/Modules/Qmitk/QmitkMouseModeSwitcher.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkMouseModeSwitcher.cpp rename to Modules/Qmitk/QmitkMouseModeSwitcher.cpp diff --git a/CoreUI/Qmitk/QmitkMouseModeSwitcher.h b/Modules/Qmitk/QmitkMouseModeSwitcher.h similarity index 100% rename from CoreUI/Qmitk/QmitkMouseModeSwitcher.h rename to Modules/Qmitk/QmitkMouseModeSwitcher.h diff --git a/CoreUI/Qmitk/QmitkNodeDescriptor.cpp b/Modules/Qmitk/QmitkNodeDescriptor.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkNodeDescriptor.cpp rename to Modules/Qmitk/QmitkNodeDescriptor.cpp diff --git a/CoreUI/Qmitk/QmitkNodeDescriptor.h b/Modules/Qmitk/QmitkNodeDescriptor.h similarity index 100% rename from CoreUI/Qmitk/QmitkNodeDescriptor.h rename to Modules/Qmitk/QmitkNodeDescriptor.h diff --git a/Modules/Qmitk/QmitkNodeDescriptorManager.cpp b/Modules/Qmitk/QmitkNodeDescriptorManager.cpp new file mode 100644 index 0000000000..210b4e204f --- /dev/null +++ b/Modules/Qmitk/QmitkNodeDescriptorManager.cpp @@ -0,0 +1,174 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkNodeDescriptorManager.h" +#include +#include +#include +#include +#include +#include + +#include +#include + + +QmitkNodeDescriptorManager* QmitkNodeDescriptorManager::GetInstance() +{ + static QmitkNodeDescriptorManager _Instance; + return &_Instance; +/* + static std::auto_ptr instance; + if(instance.get() == 0) + { + instance.reset(new QmitkNodeDescriptorManager()); + instance->Initialize(); + } + return instance.get();*/ + +} + +void QmitkNodeDescriptorManager::Initialize() +{ + // Adding "Images" + mitk::NodePredicateDataType::Pointer isImage = mitk::NodePredicateDataType::New("Image"); + this->AddDescriptor(new QmitkNodeDescriptor(tr("Image"), QString(":/Qmitk/Images_48.png"), isImage, this)); + + // Adding "Image Masks" + mitk::NodePredicateProperty::Pointer isBinary = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)); + mitk::NodePredicateAnd::Pointer isBinaryImage = mitk::NodePredicateAnd::New(isBinary, isImage); + this->AddDescriptor(new QmitkNodeDescriptor(tr("ImageMask"), QString(":/Qmitk/Binaerbilder_48.png"), isBinaryImage, this)); + + // Adding "PointSet" + mitk::NodePredicateDataType::Pointer isPointSet = mitk::NodePredicateDataType::New("PointSet"); + this->AddDescriptor(new QmitkNodeDescriptor(tr("PointSet"), QString(":/Qmitk/PointSet_48.png"), isPointSet, this)); + + // Adding "Surface" + mitk::NodePredicateDataType::Pointer isSurface = mitk::NodePredicateDataType::New("Surface"); + this->AddDescriptor(new QmitkNodeDescriptor(tr("Surface"), QString(":/Qmitk/Surface_48.png"), isSurface, this)); + + // Adding "NoneBinaryImages" + mitk::NodePredicateNot::Pointer isNotBinary = mitk::NodePredicateNot::New(isBinary); + mitk::NodePredicateAnd::Pointer isNoneBinaryImage = mitk::NodePredicateAnd::New(isImage, isNotBinary); + this->AddDescriptor(new QmitkNodeDescriptor(tr("NoneBinaryImage"), QString(":/Qmitk/Images_48.png"), isNoneBinaryImage, this)); + +} + +void QmitkNodeDescriptorManager::AddDescriptor( QmitkNodeDescriptor* _Descriptor ) +{ + _Descriptor->setParent(this); + m_NodeDescriptors.push_back(_Descriptor); +} + +void QmitkNodeDescriptorManager::RemoveDescriptor( QmitkNodeDescriptor* _Descriptor ) +{ + int index = m_NodeDescriptors.indexOf(_Descriptor); + + if(index != -1) + { + m_NodeDescriptors.removeAt(index); + _Descriptor->setParent(0); + delete _Descriptor; + } + +} + +QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetDescriptor( const mitk::DataNode* _Node ) const +{ + QmitkNodeDescriptor* _Descriptor = m_UnknownDataNodeDescriptor; + + for(QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it) + { + if((*it)->CheckNode(_Node)) + _Descriptor = *it; + } + + return _Descriptor; +} + +QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetDescriptor( const QString& _ClassName ) const +{ + QmitkNodeDescriptor* _Descriptor = 0; + + for(QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it) + { + if((*it)->GetClassName() == _ClassName) + _Descriptor = *it; + } + + return _Descriptor; +} +QList QmitkNodeDescriptorManager::GetActions( const mitk::DataNode* _Node ) const +{ + QList actions = m_UnknownDataNodeDescriptor->GetBatchActions(); + actions.append(m_UnknownDataNodeDescriptor->GetActions()); + QmitkNodeDescriptor* lastDescriptor = m_UnknownDataNodeDescriptor; + + for(QList::const_iterator it = m_NodeDescriptors.begin(); it != m_NodeDescriptors.end(); ++it) + { + if((*it)->CheckNode(_Node)) + { + actions.append(lastDescriptor->GetSeparator()); + lastDescriptor = *it; + actions.append(lastDescriptor->GetBatchActions()); + actions.append(lastDescriptor->GetActions()); + } + } + + return actions; +} + +QList QmitkNodeDescriptorManager::GetActions( const QList &_Nodes ) const +{ + QList actions = m_UnknownDataNodeDescriptor->GetBatchActions(); + QSet nodeDescriptors; + QmitkNodeDescriptor* lastDescriptor; + + // find all descriptors for the nodes (unique) + foreach (mitk::DataNode::Pointer node, _Nodes) + { + lastDescriptor = this->GetDescriptor(node); + nodeDescriptors.insert(lastDescriptor); + } + // add all actions for the found descriptors + lastDescriptor = m_UnknownDataNodeDescriptor; + foreach (QmitkNodeDescriptor* descr, nodeDescriptors) + { + actions.append(lastDescriptor->GetSeparator()); + lastDescriptor = descr; + actions.append(lastDescriptor->GetBatchActions()); + } + + return actions; +} + +QmitkNodeDescriptorManager::QmitkNodeDescriptorManager() +: m_UnknownDataNodeDescriptor(new QmitkNodeDescriptor("Unknown", QString(":/Qmitk/DataTypeUnknown_48.png"), 0, this)) +{ + this->Initialize(); +} + +QmitkNodeDescriptorManager::~QmitkNodeDescriptorManager() +{ + //delete m_UnknownDataNodeDescriptor; + //qDeleteAll(m_NodeDescriptors); +} + +QmitkNodeDescriptor* QmitkNodeDescriptorManager::GetUnknownDataNodeDescriptor() const +{ + return m_UnknownDataNodeDescriptor; +} diff --git a/Modules/Qmitk/QmitkNodeDescriptorManager.h b/Modules/Qmitk/QmitkNodeDescriptorManager.h new file mode 100644 index 0000000000..a387616f55 --- /dev/null +++ b/Modules/Qmitk/QmitkNodeDescriptorManager.h @@ -0,0 +1,117 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkNodeDescriptorManager_h +#define QmitkNodeDescriptorManager_h + +#include + +#include "QmitkNodeDescriptor.h" + +/// +/// \class QmitkNodeDescriptorManager +/// \brief QmitkNodeDescriptorManager manages a set of QmitkNodeDescriptors +/// +/// \sa QmitkNodeDescriptor +/// +class QMITK_EXPORT QmitkNodeDescriptorManager : public QObject +{ + Q_OBJECT +public: + /// + /// \return the solely instance of QmitkNodeDescriptorManager + /// + static QmitkNodeDescriptorManager* GetInstance(); + + /// + /// Initializes the QmitkNodeDescriptorManager. + /// Adds a few standard Descriptors. + /// This Descriptors are added: + /// - A QmitkNodeDescriptor for the class of "Image" DataNodes + /// - A QmitkNodeDescriptor for the class of "Image Mask" DataNodes + /// - A QmitkNodeDescriptor for the class of "Surface" DataNodes + /// - A QmitkNodeDescriptor for the class of "PointSet" DataNodes + /// + virtual void Initialize(); + + /// + /// Adds a new descriptor to the manager. The manager takes the ownership. + /// + void AddDescriptor(QmitkNodeDescriptor* _Descriptor); + + /// + /// Removes and deletes a descriptor from the manager + /// + void RemoveDescriptor(QmitkNodeDescriptor* _Descriptor); + + /// + /// Get the last descriptor in the descriptors list that matches the given node. + /// *Attention*: More specialized Descriptors should therefore be appended at + /// the end of the list, e.g. first add "Image", then add "Image Mask" + /// + /// \return a QmitkNodeDescriptor for the given node or a QmitkNodeDescriptor describing unknown nodes (never 0) + /// \sa AddDescriptor() + /// + QmitkNodeDescriptor* GetDescriptor(const mitk::DataNode* _Node) const; + + /// + /// Get the last QmitkNodeDescriptor for the given class name + /// + /// \return a QmitkNodeDescriptor for the given class name or 0 if there is no QmitkNodeDescriptor for _ClassName + /// + QmitkNodeDescriptor* GetDescriptor(const QString& _ClassName) const; + + /// + /// \return The UnknownDataNodeDescriptor, which is the default Descriptor for all Nodes. + /// + QmitkNodeDescriptor* GetUnknownDataNodeDescriptor() const; + + /// + /// Returns a list of all actions that are associated with the given node. + /// If there are more than one Descriptors for this node all actions + /// will be merged together. + /// E.g. all actions from the "unknown" DataNodes will be added to + /// this list. Generic Actions like Save, Load, etc. are stored there. + /// + QList GetActions(const mitk::DataNode* _Node) const; + /// + /// \return a list of actions associated with the given nodes + /// + QList GetActions( const QList& _Nodes ) const; + /// + /// Deletes all Descriptors in the list + /// + virtual ~QmitkNodeDescriptorManager(); +protected: + /// + /// Creates the m_UnknownDataNodeDescriptor + /// Calls Initialize + /// + QmitkNodeDescriptorManager(); +protected: + /// + /// This is the standard QmitkNodeDescriptor matching every node + /// + QmitkNodeDescriptor* m_UnknownDataNodeDescriptor; + /// + /// Holds all user defined descriptors + /// + QList m_NodeDescriptors; + +}; + +#endif // QmitkNodeDescriptorManager_h diff --git a/CoreUI/Qmitk/QmitkProgressBar.cpp b/Modules/Qmitk/QmitkProgressBar.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkProgressBar.cpp rename to Modules/Qmitk/QmitkProgressBar.cpp diff --git a/CoreUI/Qmitk/QmitkProgressBar.h b/Modules/Qmitk/QmitkProgressBar.h similarity index 100% rename from CoreUI/Qmitk/QmitkProgressBar.h rename to Modules/Qmitk/QmitkProgressBar.h diff --git a/CoreUI/Qmitk/QmitkPropertiesTableEditor.cpp b/Modules/Qmitk/QmitkPropertiesTableEditor.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkPropertiesTableEditor.cpp rename to Modules/Qmitk/QmitkPropertiesTableEditor.cpp diff --git a/CoreUI/Qmitk/QmitkPropertiesTableEditor.h b/Modules/Qmitk/QmitkPropertiesTableEditor.h similarity index 100% rename from CoreUI/Qmitk/QmitkPropertiesTableEditor.h rename to Modules/Qmitk/QmitkPropertiesTableEditor.h diff --git a/CoreUI/Qmitk/QmitkPropertiesTableModel.cpp b/Modules/Qmitk/QmitkPropertiesTableModel.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkPropertiesTableModel.cpp rename to Modules/Qmitk/QmitkPropertiesTableModel.cpp diff --git a/CoreUI/Qmitk/QmitkPropertiesTableModel.h b/Modules/Qmitk/QmitkPropertiesTableModel.h similarity index 100% rename from CoreUI/Qmitk/QmitkPropertiesTableModel.h rename to Modules/Qmitk/QmitkPropertiesTableModel.h diff --git a/CoreUI/Qmitk/QmitkPropertyDelegate.cpp b/Modules/Qmitk/QmitkPropertyDelegate.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkPropertyDelegate.cpp rename to Modules/Qmitk/QmitkPropertyDelegate.cpp diff --git a/CoreUI/Qmitk/QmitkPropertyDelegate.h b/Modules/Qmitk/QmitkPropertyDelegate.h similarity index 100% rename from CoreUI/Qmitk/QmitkPropertyDelegate.h rename to Modules/Qmitk/QmitkPropertyDelegate.h diff --git a/CoreUI/Qmitk/QmitkRegisterClasses.cpp b/Modules/Qmitk/QmitkRegisterClasses.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkRegisterClasses.cpp rename to Modules/Qmitk/QmitkRegisterClasses.cpp diff --git a/CoreUI/Qmitk/QmitkRegisterClasses.h b/Modules/Qmitk/QmitkRegisterClasses.h similarity index 100% rename from CoreUI/Qmitk/QmitkRegisterClasses.h rename to Modules/Qmitk/QmitkRegisterClasses.h diff --git a/Modules/Qmitk/QmitkRenderWindow.cpp b/Modules/Qmitk/QmitkRenderWindow.cpp new file mode 100644 index 0000000000..4d1d1ae195 --- /dev/null +++ b/Modules/Qmitk/QmitkRenderWindow.cpp @@ -0,0 +1,276 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "QmitkRenderWindow.h" + +#include +#include +#include +#include +#include +#include + +#include "QmitkEventAdapter.h" + +#include "QmitkRenderWindowMenu.h" + +QmitkRenderWindow::QmitkRenderWindow(QWidget *parent, QString name, mitk::VtkPropRenderer* /*renderer*/, mitk::RenderingManager* renderingManager ) +: QVTKWidget(parent) +, m_ResendQtEvents(true) +, m_MenuWidget(NULL) +, m_MenuWidgetActivated(false) +, m_LayoutIndex(0) +{ + Initialize( renderingManager, name.toStdString().c_str() ); // Initialize mitkRenderWindowBase + + setFocusPolicy(Qt::StrongFocus); + setMouseTracking(true); + + } + +QmitkRenderWindow::~QmitkRenderWindow() +{ + Destroy(); // Destroy mitkRenderWindowBase + +} + +void QmitkRenderWindow::SetResendQtEvents(bool resend) +{ + m_ResendQtEvents = resend; +} + +void QmitkRenderWindow::SetLayoutIndex( unsigned int layoutIndex ) +{ + m_LayoutIndex = layoutIndex; + if( m_MenuWidget ) + m_MenuWidget->SetLayoutIndex(layoutIndex); +} + +unsigned int QmitkRenderWindow::GetLayoutIndex() +{ + if( m_MenuWidget ) + return m_MenuWidget->GetLayoutIndex(); + else + return 0; +} + +void QmitkRenderWindow::LayoutDesignListChanged( int layoutDesignIndex ) +{ + if( m_MenuWidget ) + m_MenuWidget->UpdateLayoutDesignList( layoutDesignIndex ); +} + +void QmitkRenderWindow::mousePressEvent(QMouseEvent *me) +{ + mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); + this->mousePressMitkEvent(&myevent); + + QVTKWidget::mousePressEvent(me); + + if (m_ResendQtEvents) me->ignore(); +} + +void QmitkRenderWindow::mouseReleaseEvent(QMouseEvent *me) +{ + mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); + this->mouseReleaseMitkEvent(&myevent); + + QVTKWidget::mouseReleaseEvent(me); + + if (m_ResendQtEvents) me->ignore(); +} + +void QmitkRenderWindow::mouseMoveEvent(QMouseEvent *me) +{ + this->AdjustRenderWindowMenuVisibility( me->pos() ); + + + mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); + this->mouseMoveMitkEvent(&myevent); + + QVTKWidget::mouseMoveEvent(me); + + //if (m_ResendQtEvents) me->ignore(); + ////Show/Hide Menu Widget + //if( m_MenuWidgetActivated ) + //{ + // //Show Menu Widget when mouse is inside of the define region of the top right corner + // if( m_MenuWidget->GetLayoutIndex() <= QmitkRenderWindowMenu::CORONAL + // && me->pos().x() >= 0 + // && me->pos().y() <= m_MenuWidget->height() + 20 ) + // { + // m_MenuWidget->MoveWidgetToCorrectPos(1.0); + // m_MenuWidget->show(); + // m_MenuWidget->update(); + // } + // else if( m_MenuWidget->GetLayoutIndex() == QmitkRenderWindowMenu::THREE_D + // && me->pos().x() >= this->width() - m_MenuWidget->width() - 20 + // && me->pos().y() <= m_MenuWidget->height() + 20 ) + // { + // m_MenuWidget->MoveWidgetToCorrectPos(1.0); + // m_MenuWidget->show(); + // m_MenuWidget->update(); + // } + // //Hide Menu Widget when mouse is outside of the define region of the the right corner + // else if( !m_MenuWidget->GetSettingsMenuVisibilty() ) + // { + // m_MenuWidget->hide(); + // } + //} +} + +void QmitkRenderWindow::wheelEvent(QWheelEvent *we) +{ + mitk::WheelEvent myevent(QmitkEventAdapter::AdaptWheelEvent(m_Renderer, we)); + this->wheelMitkEvent(&myevent); + + QVTKWidget::wheelEvent(we); + + if (m_ResendQtEvents) + we->ignore(); +} + +void QmitkRenderWindow::keyPressEvent(QKeyEvent *ke) +{ + QPoint cp = mapFromGlobal(QCursor::pos()); + mitk::KeyEvent mke(QmitkEventAdapter::AdaptKeyEvent(m_Renderer, ke, cp)); + this->keyPressMitkEvent(&mke); + ke->accept(); + + QVTKWidget::keyPressEvent(ke); + + if (m_ResendQtEvents) ke->ignore(); +} + +void QmitkRenderWindow::enterEvent( QEvent *e ) +{ +MITK_DEBUG << "rw enter Event"; + + QVTKWidget::enterEvent(e); +} + +void QmitkRenderWindow::DeferredHideMenu( ) +{ + MITK_DEBUG << "QmitkRenderWindow::DeferredHideMenu"; + + if( m_MenuWidget ) + m_MenuWidget->HideMenu(); +} + +void QmitkRenderWindow::leaveEvent( QEvent *e ) +{ + MITK_DEBUG << "QmitkRenderWindow::leaveEvent"; + + if( m_MenuWidget ) + m_MenuWidget->smoothHide(); + + QVTKWidget::leaveEvent(e); +} + +void QmitkRenderWindow::paintEvent(QPaintEvent* /*event*/) +{ + //We are using our own interaction and thus have to call the rendering manually. + this->GetRenderer()->GetRenderingManager()->RequestUpdate(GetRenderWindow()); +} + +void QmitkRenderWindow::resizeEvent(QResizeEvent* event) +{ + this->resizeMitkEvent(event->size().width(), event->size().height()); + + QVTKWidget::resizeEvent(event); + + emit resized(); +} + + +void QmitkRenderWindow::moveEvent( QMoveEvent* event ) +{ + QVTKWidget::moveEvent( event ); + + // after a move the overlays need to be positioned + emit moved(); +} + + +void QmitkRenderWindow::showEvent( QShowEvent* event ) +{ + QVTKWidget::showEvent( event ); + + // this singleshot is necessary to have the overlays positioned correctly after initial show + // simple call of moved() is no use here!! + QTimer::singleShot(0, this ,SIGNAL( moved() ) ); +} + +void QmitkRenderWindow::ActivateMenuWidget( bool state ) +{ + m_MenuWidgetActivated = state; + + if(!m_MenuWidgetActivated && m_MenuWidget) + { + //disconnect Signal/Slot Connection + disconnect( m_MenuWidget, SIGNAL( SignalChangeLayoutDesign(int) ), this, SLOT(OnChangeLayoutDesign(int)) ); + disconnect( m_MenuWidget, SIGNAL( ResetView() ), this, SIGNAL( ResetView()) ); + disconnect( m_MenuWidget, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SIGNAL( ChangeCrosshairRotationMode(int)) ); + + delete m_MenuWidget; + m_MenuWidget = 0; + } + else if(m_MenuWidgetActivated && !m_MenuWidget ) + { + //create render window MenuBar for split, close Window or set new setting. + m_MenuWidget = new QmitkRenderWindowMenu(this,0,m_Renderer); + m_MenuWidget->SetLayoutIndex( m_LayoutIndex ); + + //create Signal/Slot Connection + connect( m_MenuWidget, SIGNAL( SignalChangeLayoutDesign(int) ), this, SLOT(OnChangeLayoutDesign(int)) ); + connect( m_MenuWidget, SIGNAL( ResetView() ), this, SIGNAL( ResetView()) ); + connect( m_MenuWidget, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SIGNAL( ChangeCrosshairRotationMode(int)) ); + } +} + +void QmitkRenderWindow::AdjustRenderWindowMenuVisibility( const QPoint& /*pos*/ ) +{ + if( m_MenuWidget ) + { + m_MenuWidget->ShowMenu(); + m_MenuWidget->MoveWidgetToCorrectPos(1.0f); + } +} + +void QmitkRenderWindow::HideRenderWindowMenu( ) +{ + // DEPRECATED METHOD +} + + +void QmitkRenderWindow::OnChangeLayoutDesign( int layoutDesignIndex ) +{ + emit SignalLayoutDesignChanged( layoutDesignIndex ); +} + +void QmitkRenderWindow::OnWidgetPlaneModeChanged( int mode ) +{ + if( m_MenuWidget ) + m_MenuWidget->NotifyNewWidgetPlanesMode( mode ); +} + +void QmitkRenderWindow::FullScreenMode(bool state) +{ + if( m_MenuWidget ) + m_MenuWidget->ChangeFullScreenMode( state ); +} diff --git a/CoreUI/Qmitk/QmitkRenderWindow.h b/Modules/Qmitk/QmitkRenderWindow.h similarity index 100% rename from CoreUI/Qmitk/QmitkRenderWindow.h rename to Modules/Qmitk/QmitkRenderWindow.h diff --git a/CoreUI/Qmitk/QmitkRenderWindowMenu.cpp b/Modules/Qmitk/QmitkRenderWindowMenu.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkRenderWindowMenu.cpp rename to Modules/Qmitk/QmitkRenderWindowMenu.cpp diff --git a/CoreUI/Qmitk/QmitkRenderWindowMenu.h b/Modules/Qmitk/QmitkRenderWindowMenu.h similarity index 100% rename from CoreUI/Qmitk/QmitkRenderWindowMenu.h rename to Modules/Qmitk/QmitkRenderWindowMenu.h diff --git a/CoreUI/Qmitk/QmitkRenderingManager.cpp b/Modules/Qmitk/QmitkRenderingManager.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkRenderingManager.cpp rename to Modules/Qmitk/QmitkRenderingManager.cpp diff --git a/CoreUI/Qmitk/QmitkRenderingManager.h b/Modules/Qmitk/QmitkRenderingManager.h similarity index 100% rename from CoreUI/Qmitk/QmitkRenderingManager.h rename to Modules/Qmitk/QmitkRenderingManager.h diff --git a/CoreUI/Qmitk/QmitkRenderingManagerFactory.cpp b/Modules/Qmitk/QmitkRenderingManagerFactory.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkRenderingManagerFactory.cpp rename to Modules/Qmitk/QmitkRenderingManagerFactory.cpp diff --git a/CoreUI/Qmitk/QmitkRenderingManagerFactory.h b/Modules/Qmitk/QmitkRenderingManagerFactory.h similarity index 100% rename from CoreUI/Qmitk/QmitkRenderingManagerFactory.h rename to Modules/Qmitk/QmitkRenderingManagerFactory.h diff --git a/CoreUI/Qmitk/QmitkSliderLevelWindowWidget.cpp b/Modules/Qmitk/QmitkSliderLevelWindowWidget.cpp similarity index 100% rename from CoreUI/Qmitk/QmitkSliderLevelWindowWidget.cpp rename to Modules/Qmitk/QmitkSliderLevelWindowWidget.cpp diff --git a/CoreUI/Qmitk/QmitkSliderLevelWindowWidget.h b/Modules/Qmitk/QmitkSliderLevelWindowWidget.h similarity index 100% rename from CoreUI/Qmitk/QmitkSliderLevelWindowWidget.h rename to Modules/Qmitk/QmitkSliderLevelWindowWidget.h diff --git a/Modules/Qmitk/QmitkStdMultiWidget.cpp b/Modules/Qmitk/QmitkStdMultiWidget.cpp new file mode 100644 index 0000000000..c1e98b77fc --- /dev/null +++ b/Modules/Qmitk/QmitkStdMultiWidget.cpp @@ -0,0 +1,2169 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#define SMW_INFO MITK_INFO("widget.stdmulti") + +#include "QmitkStdMultiWidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mitkProperties.h" +#include "mitkGeometry2DDataMapper2D.h" +#include "mitkGlobalInteraction.h" +#include "mitkDisplayInteractor.h" +#include "mitkPointSet.h" +#include "mitkPositionEvent.h" +#include "mitkStateEvent.h" +#include "mitkLine.h" +#include "mitkInteractionConst.h" +#include "mitkDataStorage.h" + +#include "mitkNodePredicateBase.h" +#include "mitkNodePredicateDataType.h" + +#include "mitkNodePredicateNot.h" +#include "mitkNodePredicateProperty.h" +#include "mitkStatusBar.h" +#include "mitkImage.h" + +#include "mitkVtkLayerController.h" + +QmitkStdMultiWidget::QmitkStdMultiWidget(QWidget* parent, Qt::WindowFlags f) +: QWidget(parent, f), +mitkWidget1(NULL), +mitkWidget2(NULL), +mitkWidget3(NULL), +mitkWidget4(NULL), +m_GradientBackgroundFlag(true), +m_PlaneNode1(NULL), +m_PlaneNode2(NULL), +m_PlaneNode3(NULL), +m_Node(NULL), +m_PendingCrosshairPositionEvent(false), +m_CrosshairNavigationEnabled(false) +{ + /*******************************/ + //Create Widget manually + /*******************************/ + + //create Layouts + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + QmitkStdMultiWidgetLayout->setContentsMargins(0,0,0,0); + + //Set Layout to widget + this->setLayout(QmitkStdMultiWidgetLayout); + +// QmitkNavigationToolBar* toolBar = new QmitkNavigationToolBar(); +// QmitkStdMultiWidgetLayout->addWidget( toolBar ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + //creae Widget Container + mitkWidget1Container = new QWidget(m_SubSplit1); + mitkWidget2Container = new QWidget(m_SubSplit1); + mitkWidget3Container = new QWidget(m_SubSplit2); + mitkWidget4Container = new QWidget(m_SubSplit2); + + mitkWidget1Container->setContentsMargins(0,0,0,0); + mitkWidget2Container->setContentsMargins(0,0,0,0); + mitkWidget3Container->setContentsMargins(0,0,0,0); + mitkWidget4Container->setContentsMargins(0,0,0,0); + + //create Widget Layout + QHBoxLayout *mitkWidgetLayout1 = new QHBoxLayout(mitkWidget1Container); + QHBoxLayout *mitkWidgetLayout2 = new QHBoxLayout(mitkWidget2Container); + QHBoxLayout *mitkWidgetLayout3 = new QHBoxLayout(mitkWidget3Container); + QHBoxLayout *mitkWidgetLayout4 = new QHBoxLayout(mitkWidget4Container); + + mitkWidgetLayout1->setMargin(0); + mitkWidgetLayout2->setMargin(0); + mitkWidgetLayout3->setMargin(0); + mitkWidgetLayout4->setMargin(0); + + //set Layout to Widget Container + mitkWidget1Container->setLayout(mitkWidgetLayout1); + mitkWidget2Container->setLayout(mitkWidgetLayout2); + mitkWidget3Container->setLayout(mitkWidgetLayout3); + mitkWidget4Container->setLayout(mitkWidgetLayout4); + + //set SizePolicy + mitkWidget1Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + mitkWidget2Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + mitkWidget3Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + mitkWidget4Container->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); + + + //insert Widget Container into the splitters + m_SubSplit1->addWidget( mitkWidget1Container ); + m_SubSplit1->addWidget( mitkWidget2Container ); + + m_SubSplit2->addWidget( mitkWidget3Container ); + m_SubSplit2->addWidget( mitkWidget4Container ); + +// mitk::RenderingManager::GetInstance()->SetGlobalInteraction( mitk::GlobalInteraction::GetInstance() ); + + //Create RenderWindows 1 + mitkWidget1 = new QmitkRenderWindow(mitkWidget1Container, "stdmulti.widget1"); + mitkWidget1->setMaximumSize(2000,2000); + mitkWidget1->SetLayoutIndex( TRANSVERSAL ); + mitkWidgetLayout1->addWidget(mitkWidget1); + + //Create RenderWindows 2 + mitkWidget2 = new QmitkRenderWindow(mitkWidget2Container, "stdmulti.widget2"); + mitkWidget2->setMaximumSize(2000,2000); + mitkWidget2->setEnabled( TRUE ); + mitkWidget2->SetLayoutIndex( SAGITTAL ); + mitkWidgetLayout2->addWidget(mitkWidget2); + + //Create RenderWindows 3 + mitkWidget3 = new QmitkRenderWindow(mitkWidget3Container, "stdmulti.widget3"); + mitkWidget3->setMaximumSize(2000,2000); + mitkWidget3->SetLayoutIndex( CORONAL ); + mitkWidgetLayout3->addWidget(mitkWidget3); + + //Create RenderWindows 4 + mitkWidget4 = new QmitkRenderWindow(mitkWidget4Container, "stdmulti.widget4"); + mitkWidget4->setMaximumSize(2000,2000); + mitkWidget4->SetLayoutIndex( THREE_D ); + mitkWidgetLayout4->addWidget(mitkWidget4); + + //create SignalSlot Connection + connect( mitkWidget1, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); + connect( mitkWidget1, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); + connect( mitkWidget1, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); + connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget1, SLOT(OnWidgetPlaneModeChanged(int)) ); + + connect( mitkWidget2, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); + connect( mitkWidget2, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); + connect( mitkWidget2, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); + connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget2, SLOT(OnWidgetPlaneModeChanged(int)) ); + + connect( mitkWidget3, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); + connect( mitkWidget3, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); + connect( mitkWidget3, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); + connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget3, SLOT(OnWidgetPlaneModeChanged(int)) ); + + connect( mitkWidget4, SIGNAL( SignalLayoutDesignChanged(int) ), this, SLOT( OnLayoutDesignChanged(int) ) ); + connect( mitkWidget4, SIGNAL( ResetView() ), this, SLOT( ResetCrosshair() ) ); + connect( mitkWidget4, SIGNAL( ChangeCrosshairRotationMode(int) ), this, SLOT( SetWidgetPlaneMode(int) ) ); + connect( this, SIGNAL(WidgetNotifyNewCrossHairMode(int)), mitkWidget4, SLOT(OnWidgetPlaneModeChanged(int)) ); + + //Create Level Window Widget + levelWindowWidget = new QmitkLevelWindowWidget( m_MainSplit ); //this + levelWindowWidget->setObjectName(QString::fromUtf8("levelWindowWidget")); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(levelWindowWidget->sizePolicy().hasHeightForWidth()); + levelWindowWidget->setSizePolicy(sizePolicy); + levelWindowWidget->setMaximumSize(QSize(50, 2000)); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //resize Image. + this->resize( QSize(364, 477).expandedTo(minimumSizeHint()) ); + + //Initialize the widgets. + this->InitializeWidget(); + + //Activate Widget Menu + this->ActivateMenuWidget( true ); +} + +void QmitkStdMultiWidget::InitializeWidget() +{ + m_PositionTracker = NULL; + + // transfer colors in WorldGeometry-Nodes of the associated Renderer + QColor qcolor; + //float color[3] = {1.0f,1.0f,1.0f}; + mitk::DataNode::Pointer planeNode; + mitk::IntProperty::Pointer layer; + + // of widget 1 + planeNode = mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); + planeNode->SetColor(1.0,0.0,0.0); + layer = mitk::IntProperty::New(1000); + planeNode->SetProperty("layer",layer); + + // ... of widget 2 + planeNode = mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); + planeNode->SetColor(0.0,1.0,0.0); + layer = mitk::IntProperty::New(1000); + planeNode->SetProperty("layer",layer); + + // ... of widget 3 + planeNode = mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); + planeNode->SetColor(0.0,0.0,1.0); + layer = mitk::IntProperty::New(1000); + planeNode->SetProperty("layer",layer); + + // ... of widget 4 + planeNode = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetCurrentWorldGeometry2DNode(); + planeNode->SetColor(1.0,1.0,0.0); + layer = mitk::IntProperty::New(1000); + planeNode->SetProperty("layer",layer); + + mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->SetMapperID(mitk::BaseRenderer::Standard3D); + // Set plane mode (slicing/rotation behavior) to slicing (default) + m_PlaneMode = PLANE_MODE_SLICING; + + // Set default view directions for SNCs + mitkWidget1->GetSliceNavigationController()->SetDefaultViewDirection( + mitk::SliceNavigationController::Transversal ); + mitkWidget2->GetSliceNavigationController()->SetDefaultViewDirection( + mitk::SliceNavigationController::Sagittal ); + mitkWidget3->GetSliceNavigationController()->SetDefaultViewDirection( + mitk::SliceNavigationController::Frontal ); + mitkWidget4->GetSliceNavigationController()->SetDefaultViewDirection( + mitk::SliceNavigationController::Original ); + + /*************************************************/ + //Write Layout Names into the viewers -- hardCoded + + //Info for later: + //int view = this->GetRenderWindow1()->GetSliceNavigationController()->GetDefaultViewDirection(); + //QString layoutName; + //if( view == mitk::SliceNavigationController::Transversal ) + // layoutName = "Transversal"; + //else if( view == mitk::SliceNavigationController::Sagittal ) + // layoutName = "Sagittal"; + //else if( view == mitk::SliceNavigationController::Frontal ) + // layoutName = "Coronal"; + //else if( view == mitk::SliceNavigationController::Original ) + // layoutName = "Original"; + //if( view >= 0 && view < 4 ) + // //write LayoutName --> Viewer 3D shoudn't write the layoutName. + + //Render Window 1 == transversal + m_CornerAnnotaions[0].cornerText = vtkCornerAnnotation::New(); + m_CornerAnnotaions[0].cornerText->SetText(0, "Transversal"); + m_CornerAnnotaions[0].cornerText->SetMaximumFontSize(12); + m_CornerAnnotaions[0].textProp = vtkTextProperty::New(); + m_CornerAnnotaions[0].textProp->SetColor( 1.0, 0.0, 0.0 ); + m_CornerAnnotaions[0].cornerText->SetTextProperty( m_CornerAnnotaions[0].textProp ); + m_CornerAnnotaions[0].ren = vtkRenderer::New(); + m_CornerAnnotaions[0].ren->AddActor(m_CornerAnnotaions[0].cornerText); + m_CornerAnnotaions[0].ren->InteractiveOff(); + mitk::VtkLayerController::GetInstance(this->GetRenderWindow1()->GetRenderWindow())->InsertForegroundRenderer(m_CornerAnnotaions[0].ren,true); + + //Render Window 2 == sagittal + m_CornerAnnotaions[1].cornerText = vtkCornerAnnotation::New(); + m_CornerAnnotaions[1].cornerText->SetText(0, "Sagittal"); + m_CornerAnnotaions[1].cornerText->SetMaximumFontSize(12); + m_CornerAnnotaions[1].textProp = vtkTextProperty::New(); + m_CornerAnnotaions[1].textProp->SetColor( 0.0, 1.0, 0.0 ); + m_CornerAnnotaions[1].cornerText->SetTextProperty( m_CornerAnnotaions[1].textProp ); + m_CornerAnnotaions[1].ren = vtkRenderer::New(); + m_CornerAnnotaions[1].ren->AddActor(m_CornerAnnotaions[1].cornerText); + m_CornerAnnotaions[1].ren->InteractiveOff(); + mitk::VtkLayerController::GetInstance(this->GetRenderWindow2()->GetRenderWindow())->InsertForegroundRenderer(m_CornerAnnotaions[1].ren,true); + + //Render Window 3 == coronal + m_CornerAnnotaions[2].cornerText = vtkCornerAnnotation::New(); + m_CornerAnnotaions[2].cornerText->SetText(0, "Coronal"); + m_CornerAnnotaions[2].cornerText->SetMaximumFontSize(12); + m_CornerAnnotaions[2].textProp = vtkTextProperty::New(); + m_CornerAnnotaions[2].textProp->SetColor( 0.295, 0.295, 1.0 ); + m_CornerAnnotaions[2].cornerText->SetTextProperty( m_CornerAnnotaions[2].textProp ); + m_CornerAnnotaions[2].ren = vtkRenderer::New(); + m_CornerAnnotaions[2].ren->AddActor(m_CornerAnnotaions[2].cornerText); + m_CornerAnnotaions[2].ren->InteractiveOff(); + mitk::VtkLayerController::GetInstance(this->GetRenderWindow3()->GetRenderWindow())->InsertForegroundRenderer(m_CornerAnnotaions[2].ren,true); + + /*************************************************/ + + + // create a slice rotator + // m_SlicesRotator = mitk::SlicesRotator::New(); + // @TODO next line causes sure memory leak + // rotator will be created nonetheless (will be switched on and off) + m_SlicesRotator = mitk::SlicesRotator::New("slices-rotator"); + m_SlicesRotator->AddSliceController( + mitkWidget1->GetSliceNavigationController() ); + m_SlicesRotator->AddSliceController( + mitkWidget2->GetSliceNavigationController() ); + m_SlicesRotator->AddSliceController( + mitkWidget3->GetSliceNavigationController() ); + + // create a slice swiveller (using the same state-machine as SlicesRotator) + m_SlicesSwiveller = mitk::SlicesSwiveller::New("slices-rotator"); + m_SlicesSwiveller->AddSliceController( + mitkWidget1->GetSliceNavigationController() ); + m_SlicesSwiveller->AddSliceController( + mitkWidget2->GetSliceNavigationController() ); + m_SlicesSwiveller->AddSliceController( + mitkWidget3->GetSliceNavigationController() ); + + //initialize m_TimeNavigationController: send time via sliceNavigationControllers + m_TimeNavigationController = mitk::SliceNavigationController::New("dummy"); + m_TimeNavigationController->ConnectGeometryTimeEvent( + mitkWidget1->GetSliceNavigationController() , false); + m_TimeNavigationController->ConnectGeometryTimeEvent( + mitkWidget2->GetSliceNavigationController() , false); + m_TimeNavigationController->ConnectGeometryTimeEvent( + mitkWidget3->GetSliceNavigationController() , false); + m_TimeNavigationController->ConnectGeometryTimeEvent( + mitkWidget4->GetSliceNavigationController() , false); + mitkWidget1->GetSliceNavigationController() + ->ConnectGeometrySendEvent(mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); + + // Set TimeNavigationController to RenderingManager + // (which uses it internally for views initialization!) + mitk::RenderingManager::GetInstance()->SetTimeNavigationController( + m_TimeNavigationController ); + + //reverse connection between sliceNavigationControllers and m_TimeNavigationController + mitkWidget1->GetSliceNavigationController() + ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); + mitkWidget2->GetSliceNavigationController() + ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); + mitkWidget3->GetSliceNavigationController() + ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); + mitkWidget4->GetSliceNavigationController() + ->ConnectGeometryTimeEvent(m_TimeNavigationController.GetPointer(), false); + + m_MouseModeSwitcher = mitk::MouseModeSwitcher::New( mitk::GlobalInteraction::GetInstance() ); + + m_LastLeftClickPositionSupplier = + mitk::CoordinateSupplier::New("navigation", NULL); + mitk::GlobalInteraction::GetInstance()->AddListener( + m_LastLeftClickPositionSupplier + ); + // setup gradient background + m_GradientBackground1 = mitk::GradientBackground::New(); + m_GradientBackground1->SetRenderWindow( + mitkWidget1->GetRenderWindow() ); + m_GradientBackground1->Disable(); + + m_GradientBackground2 = mitk::GradientBackground::New(); + m_GradientBackground2->SetRenderWindow( + mitkWidget2->GetRenderWindow() ); + m_GradientBackground2->Disable(); + + m_GradientBackground3 = mitk::GradientBackground::New(); + m_GradientBackground3->SetRenderWindow( + mitkWidget3->GetRenderWindow() ); + m_GradientBackground3->Disable(); + + m_GradientBackground4 = mitk::GradientBackground::New(); + m_GradientBackground4->SetRenderWindow( + mitkWidget4->GetRenderWindow() ); + m_GradientBackground4->SetGradientColors(0.1,0.1,0.1,0.5,0.5,0.5); + m_GradientBackground4->Enable(); + + // setup the department logo rendering + m_LogoRendering1 = mitk::ManufacturerLogo::New(); + m_LogoRendering1->SetRenderWindow( + mitkWidget1->GetRenderWindow() ); + m_LogoRendering1->Disable(); + + m_LogoRendering2 = mitk::ManufacturerLogo::New(); + m_LogoRendering2->SetRenderWindow( + mitkWidget2->GetRenderWindow() ); + m_LogoRendering2->Disable(); + + m_LogoRendering3 = mitk::ManufacturerLogo::New(); + m_LogoRendering3->SetRenderWindow( + mitkWidget3->GetRenderWindow() ); + m_LogoRendering3->Disable(); + + m_LogoRendering4 = mitk::ManufacturerLogo::New(); + m_LogoRendering4->SetRenderWindow( + mitkWidget4->GetRenderWindow() ); + m_LogoRendering4->Enable(); + + m_RectangleRendering1 = mitk::RenderWindowFrame::New(); + m_RectangleRendering1->SetRenderWindow( + mitkWidget1->GetRenderWindow() ); + m_RectangleRendering1->Enable(1.0,0.0,0.0); + + m_RectangleRendering2 = mitk::RenderWindowFrame::New(); + m_RectangleRendering2->SetRenderWindow( + mitkWidget2->GetRenderWindow() ); + m_RectangleRendering2->Enable(0.0,1.0,0.0); + + m_RectangleRendering3 = mitk::RenderWindowFrame::New(); + m_RectangleRendering3->SetRenderWindow( + mitkWidget3->GetRenderWindow() ); + m_RectangleRendering3->Enable(0.0,0.0,1.0); + + m_RectangleRendering4 = mitk::RenderWindowFrame::New(); + m_RectangleRendering4->SetRenderWindow( + mitkWidget4->GetRenderWindow() ); + m_RectangleRendering4->Enable(1.0,1.0,0.0); +} + +QmitkStdMultiWidget::~QmitkStdMultiWidget() +{ + DisablePositionTracking(); + DisableNavigationControllerEventListening(); + + mitk::VtkLayerController::GetInstance(this->GetRenderWindow1()->GetRenderWindow())->RemoveRenderer( m_CornerAnnotaions[0].ren ); + mitk::VtkLayerController::GetInstance(this->GetRenderWindow2()->GetRenderWindow())->RemoveRenderer( m_CornerAnnotaions[1].ren ); + mitk::VtkLayerController::GetInstance(this->GetRenderWindow3()->GetRenderWindow())->RemoveRenderer( m_CornerAnnotaions[2].ren ); + + //Delete CornerAnnotation + m_CornerAnnotaions[0].cornerText->Delete(); + m_CornerAnnotaions[0].textProp->Delete(); + m_CornerAnnotaions[0].ren->Delete(); + + m_CornerAnnotaions[1].cornerText->Delete(); + m_CornerAnnotaions[1].textProp->Delete(); + m_CornerAnnotaions[1].ren->Delete(); + + m_CornerAnnotaions[2].cornerText->Delete(); + m_CornerAnnotaions[2].textProp->Delete(); + m_CornerAnnotaions[2].ren->Delete(); +} + +void QmitkStdMultiWidget::RemovePlanesFromDataStorage() +{ + if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_Node.IsNotNull()) + { + if(m_DataStorage.IsNotNull()) + { + m_DataStorage->Remove(m_PlaneNode1); + m_DataStorage->Remove(m_PlaneNode2); + m_DataStorage->Remove(m_PlaneNode3); + m_DataStorage->Remove(m_Node); + } + } +} + +void QmitkStdMultiWidget::AddPlanesToDataStorage() +{ + if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_Node.IsNotNull()) + { + if (m_DataStorage.IsNotNull()) + { + m_DataStorage->Add(m_Node); + m_DataStorage->Add(m_PlaneNode1, m_Node); + m_DataStorage->Add(m_PlaneNode2, m_Node); + m_DataStorage->Add(m_PlaneNode3, m_Node); + static_cast(m_PlaneNode1->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); + static_cast(m_PlaneNode2->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); + static_cast(m_PlaneNode3->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(m_DataStorage, m_Node); + } + } +} + +void QmitkStdMultiWidget::changeLayoutTo2DImagesUp() +{ + SMW_INFO << "changing layout to 2D images up... " << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //Set Layout to widget + this->setLayout(QmitkStdMultiWidgetLayout); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + //insert Widget Container into splitter top + m_SubSplit1->addWidget( mitkWidget1Container ); + m_SubSplit1->addWidget( mitkWidget2Container ); + m_SubSplit1->addWidget( mitkWidget3Container ); + + //set SplitterSize for splitter top + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_SubSplit1->setSizes( splitterSize ); + + //insert Widget Container into splitter bottom + m_SubSplit2->addWidget( mitkWidget4Container ); + + //set SplitterSize for splitter m_LayoutSplit + splitterSize.clear(); + splitterSize.push_back(400); + splitterSize.push_back(1000); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt + m_MainSplit->show(); + + //show Widget if hidden + if ( mitkWidget1->isHidden() ) mitkWidget1->show(); + if ( mitkWidget2->isHidden() ) mitkWidget2->show(); + if ( mitkWidget3->isHidden() ) mitkWidget3->show(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + //Change Layout Name + m_Layout = LAYOUT_2D_IMAGES_UP; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_IMAGES_UP ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutTo2DImagesLeft() +{ + SMW_INFO << "changing layout to 2D images left... " << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + //insert Widget into the splitters + m_SubSplit1->addWidget( mitkWidget1Container ); + m_SubSplit1->addWidget( mitkWidget2Container ); + m_SubSplit1->addWidget( mitkWidget3Container ); + + //set splitterSize of SubSplit1 + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_SubSplit1->setSizes( splitterSize ); + + m_SubSplit2->addWidget( mitkWidget4Container ); + + //set splitterSize of Layout Split + splitterSize.clear(); + splitterSize.push_back(400); + splitterSize.push_back(1000); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show Widget if hidden + if ( mitkWidget1->isHidden() ) mitkWidget1->show(); + if ( mitkWidget2->isHidden() ) mitkWidget2->show(); + if ( mitkWidget3->isHidden() ) mitkWidget3->show(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + //update Layout Name + m_Layout = LAYOUT_2D_IMAGES_LEFT; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_IMAGES_LEFT ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToDefault() +{ + SMW_INFO << "changing layout to default... " << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + //insert Widget container into the splitters + m_SubSplit1->addWidget( mitkWidget1Container ); + m_SubSplit1->addWidget( mitkWidget2Container ); + + m_SubSplit2->addWidget( mitkWidget3Container ); + m_SubSplit2->addWidget( mitkWidget4Container ); + + //set splitter Size + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_SubSplit1->setSizes( splitterSize ); + m_SubSplit2->setSizes( splitterSize ); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show Widget if hidden + if ( mitkWidget1->isHidden() ) mitkWidget1->show(); + if ( mitkWidget2->isHidden() ) mitkWidget2->show(); + if ( mitkWidget3->isHidden() ) mitkWidget3->show(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_DEFAULT; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_DEFAULT ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_DEFAULT ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_DEFAULT ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_DEFAULT ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToBig3D() +{ + SMW_INFO << "changing layout to big 3D ..." << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //add widget Splitter to main Splitter + m_MainSplit->addWidget( mitkWidget4Container ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + mitkWidget1->hide(); + mitkWidget2->hide(); + mitkWidget3->hide(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_BIG_3D; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_BIG_3D ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_BIG_3D ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_BIG_3D ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_BIG_3D ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToWidget1() +{ + SMW_INFO << "changing layout to big Widget1 ..." << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //add widget Splitter to main Splitter + m_MainSplit->addWidget( mitkWidget1Container ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + if ( mitkWidget1->isHidden() ) mitkWidget1->show(); + mitkWidget2->hide(); + mitkWidget3->hide(); + mitkWidget4->hide(); + + m_Layout = LAYOUT_WIDGET1; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_WIDGET1 ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_WIDGET1 ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_WIDGET1 ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_WIDGET1 ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToWidget2() +{ + SMW_INFO << "changing layout to big Widget2 ..." << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //add widget Splitter to main Splitter + m_MainSplit->addWidget( mitkWidget2Container ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + mitkWidget1->hide(); + if ( mitkWidget2->isHidden() ) mitkWidget2->show(); + mitkWidget3->hide(); + mitkWidget4->hide(); + + m_Layout = LAYOUT_WIDGET2; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_WIDGET2 ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_WIDGET2 ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_WIDGET2 ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_WIDGET2 ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToWidget3() +{ + SMW_INFO << "changing layout to big Widget3 ..." << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //add widget Splitter to main Splitter + m_MainSplit->addWidget( mitkWidget3Container ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + mitkWidget1->hide(); + mitkWidget2->hide(); + if ( mitkWidget3->isHidden() ) mitkWidget3->show(); + mitkWidget4->hide(); + + m_Layout = LAYOUT_WIDGET3; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_WIDGET3 ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_WIDGET3 ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_WIDGET3 ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_WIDGET3 ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToRowWidget3And4() +{ + SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //add Widgets to splitter + m_LayoutSplit->addWidget( mitkWidget3Container ); + m_LayoutSplit->addWidget( mitkWidget4Container ); + + //set Splitter Size + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + mitkWidget1->hide(); + mitkWidget2->hide(); + if ( mitkWidget3->isHidden() ) mitkWidget3->show(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_ROW_WIDGET_3_AND_4; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_ROW_WIDGET_3_AND_4 ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToColumnWidget3And4() +{ + SMW_INFO << "changing layout to Widget3 and 4 in one Column..." << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //add Widgets to splitter + m_LayoutSplit->addWidget( mitkWidget3Container ); + m_LayoutSplit->addWidget( mitkWidget4Container ); + + //set SplitterSize + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + mitkWidget1->hide(); + mitkWidget2->hide(); + if ( mitkWidget3->isHidden() ) mitkWidget3->show(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_COLUMN_WIDGET_3_AND_4; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_COLUMN_WIDGET_3_AND_4 ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutToRowWidgetSmall3andBig4() +{ + SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; + + this->changeLayoutToRowWidget3And4(); + + m_Layout = LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4; +} + + +void QmitkStdMultiWidget::changeLayoutToSmallUpperWidget2Big3and4() +{ + SMW_INFO << "changing layout to Widget3 and 4 in a Row..." << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + //insert Widget into the splitters + m_SubSplit1->addWidget( mitkWidget2Container ); + + m_SubSplit2->addWidget( mitkWidget3Container ); + m_SubSplit2->addWidget( mitkWidget4Container ); + + //set Splitter Size + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_SubSplit2->setSizes( splitterSize ); + splitterSize.clear(); + splitterSize.push_back(500); + splitterSize.push_back(1000); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt + m_MainSplit->show(); + + //show Widget if hidden + mitkWidget1->hide(); + if ( mitkWidget2->isHidden() ) mitkWidget2->show(); + if ( mitkWidget3->isHidden() ) mitkWidget3->show(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4 ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + + +void QmitkStdMultiWidget::changeLayoutTo2x2Dand3DWidget() +{ + SMW_INFO << "changing layout to 2 x 2D and 3D Widget" << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + //add Widgets to splitter + m_SubSplit1->addWidget( mitkWidget1Container ); + m_SubSplit1->addWidget( mitkWidget2Container ); + m_SubSplit2->addWidget( mitkWidget4Container ); + + //set Splitter Size + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_SubSplit1->setSizes( splitterSize ); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + if ( mitkWidget1->isHidden() ) mitkWidget1->show(); + if ( mitkWidget2->isHidden() ) mitkWidget2->show(); + mitkWidget3->hide(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_2X_2D_AND_3D_WIDGET; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_2X_2D_AND_3D_WIDGET ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + + +void QmitkStdMultiWidget::changeLayoutToLeft2Dand3DRight2D() +{ + SMW_INFO << "changing layout to 2D and 3D left, 2D right Widget" << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( Qt::Vertical, m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + + //add Widgets to splitter + m_SubSplit1->addWidget( mitkWidget1Container ); + m_SubSplit1->addWidget( mitkWidget4Container ); + m_SubSplit2->addWidget( mitkWidget2Container ); + + //set Splitter Size + QList splitterSize; + splitterSize.push_back(1000); + splitterSize.push_back(1000); + m_SubSplit1->setSizes( splitterSize ); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt and add to Layout + m_MainSplit->show(); + + //show/hide Widgets + if ( mitkWidget1->isHidden() ) mitkWidget1->show(); + if ( mitkWidget2->isHidden() ) mitkWidget2->show(); + mitkWidget3->hide(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET ); + + //update Alle Widgets + this->UpdateAllWidgets(); +} + +void QmitkStdMultiWidget::changeLayoutTo2DUpAnd3DDown() +{ + SMW_INFO << "changing layout to 2D up and 3D down" << std::endl; + + //Hide all Menu Widgets + this->HideAllWidgetToolbars(); + + delete QmitkStdMultiWidgetLayout ; + + //create Main Layout + QmitkStdMultiWidgetLayout = new QHBoxLayout( this ); + + //Set Layout to widget + this->setLayout(QmitkStdMultiWidgetLayout); + + //create main splitter + m_MainSplit = new QSplitter( this ); + QmitkStdMultiWidgetLayout->addWidget( m_MainSplit ); + + //create m_LayoutSplit and add to the mainSplit + m_LayoutSplit = new QSplitter( Qt::Vertical, m_MainSplit ); + m_MainSplit->addWidget( m_LayoutSplit ); + + //add LevelWindow Widget to mainSplitter + m_MainSplit->addWidget( levelWindowWidget ); + + //create m_SubSplit1 and m_SubSplit2 + m_SubSplit1 = new QSplitter( m_LayoutSplit ); + m_SubSplit2 = new QSplitter( m_LayoutSplit ); + + //insert Widget Container into splitter top + m_SubSplit1->addWidget( mitkWidget1Container ); + + //set SplitterSize for splitter top + QList splitterSize; +// splitterSize.push_back(1000); +// splitterSize.push_back(1000); +// splitterSize.push_back(1000); +// m_SubSplit1->setSizes( splitterSize ); + + //insert Widget Container into splitter bottom + m_SubSplit2->addWidget( mitkWidget4Container ); + + //set SplitterSize for splitter m_LayoutSplit + splitterSize.clear(); + splitterSize.push_back(700); + splitterSize.push_back(700); + m_LayoutSplit->setSizes( splitterSize ); + + //show mainSplitt + m_MainSplit->show(); + + //show/hide Widgets + if ( mitkWidget1->isHidden() ) mitkWidget1->show(); + mitkWidget2->hide(); + mitkWidget3->hide(); + if ( mitkWidget4->isHidden() ) mitkWidget4->show(); + + m_Layout = LAYOUT_2D_UP_AND_3D_DOWN; + + //update Layout Design List + mitkWidget1->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); + mitkWidget2->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); + mitkWidget3->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); + mitkWidget4->LayoutDesignListChanged( LAYOUT_2D_UP_AND_3D_DOWN ); + + //update all Widgets + this->UpdateAllWidgets(); +} + + + +void QmitkStdMultiWidget::SetDataStorage( mitk::DataStorage* ds ) +{ + mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->SetDataStorage(ds); + mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->SetDataStorage(ds); + mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->SetDataStorage(ds); + mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->SetDataStorage(ds); + m_DataStorage = ds; +} + + +void QmitkStdMultiWidget::Fit() +{ + vtkRenderer * vtkrenderer; + mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetDisplayGeometry()->Fit(); + mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetDisplayGeometry()->Fit(); + mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetDisplayGeometry()->Fit(); + mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetDisplayGeometry()->Fit(); + + int w = vtkObject::GetGlobalWarningDisplay(); + vtkObject::GlobalWarningDisplayOff(); + + vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetVtkRenderer(); + if ( vtkrenderer!= NULL ) + vtkrenderer->ResetCamera(); + + vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow())->GetVtkRenderer(); + if ( vtkrenderer!= NULL ) + vtkrenderer->ResetCamera(); + + vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow())->GetVtkRenderer(); + if ( vtkrenderer!= NULL ) + vtkrenderer->ResetCamera(); + + vtkrenderer = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())->GetVtkRenderer(); + if ( vtkrenderer!= NULL ) + vtkrenderer->ResetCamera(); + + vtkObject::SetGlobalWarningDisplay(w); +} + + +void QmitkStdMultiWidget::InitPositionTracking() +{ + //PoinSetNode for MouseOrientation + m_PositionTrackerNode = mitk::DataNode::New(); + m_PositionTrackerNode->SetProperty("name", mitk::StringProperty::New("Mouse Position")); + m_PositionTrackerNode->SetData( mitk::PointSet::New() ); + m_PositionTrackerNode->SetColor(1.0,0.33,0.0); + m_PositionTrackerNode->SetProperty("layer", mitk::IntProperty::New(1001)); + m_PositionTrackerNode->SetVisibility(true); + m_PositionTrackerNode->SetProperty("inputdevice", mitk::BoolProperty::New(true) ); + m_PositionTrackerNode->SetProperty("BaseRendererMapperID", mitk::IntProperty::New(0) );//point position 2D mouse + m_PositionTrackerNode->SetProperty("baserenderer", mitk::StringProperty::New("N/A")); +} + + +void QmitkStdMultiWidget::AddDisplayPlaneSubTree() +{ + // add the displayed planes of the multiwidget to a node to which the subtree + // @a planesSubTree points ... + + float white[3] = {1.0f,1.0f,1.0f}; + mitk::Geometry2DDataMapper2D::Pointer mapper; + + // ... of widget 1 + m_PlaneNode1 = (mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow()))->GetCurrentWorldGeometry2DNode(); + m_PlaneNode1->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); + m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true)); + m_PlaneNode1->SetProperty("name", mitk::StringProperty::New("widget1Plane")); + m_PlaneNode1->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); + m_PlaneNode1->SetProperty("helper object", mitk::BoolProperty::New(true)); + mapper = mitk::Geometry2DDataMapper2D::New(); + m_PlaneNode1->SetMapper(mitk::BaseRenderer::Standard2D, mapper); + + // ... of widget 2 + m_PlaneNode2 =( mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow()))->GetCurrentWorldGeometry2DNode(); + m_PlaneNode2->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); + m_PlaneNode2->SetProperty("visible", mitk::BoolProperty::New(true)); + m_PlaneNode2->SetProperty("name", mitk::StringProperty::New("widget2Plane")); + m_PlaneNode2->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); + m_PlaneNode2->SetProperty("helper object", mitk::BoolProperty::New(true)); + mapper = mitk::Geometry2DDataMapper2D::New(); + m_PlaneNode2->SetMapper(mitk::BaseRenderer::Standard2D, mapper); + + // ... of widget 3 + m_PlaneNode3 = (mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow()))->GetCurrentWorldGeometry2DNode(); + m_PlaneNode3->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow())); + m_PlaneNode3->SetProperty("visible", mitk::BoolProperty::New(true)); + m_PlaneNode3->SetProperty("name", mitk::StringProperty::New("widget3Plane")); + m_PlaneNode3->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); + m_PlaneNode3->SetProperty("helper object", mitk::BoolProperty::New(true)); + mapper = mitk::Geometry2DDataMapper2D::New(); + m_PlaneNode3->SetMapper(mitk::BaseRenderer::Standard2D, mapper); + + m_Node = mitk::DataNode::New(); + m_Node->SetProperty("name", mitk::StringProperty::New("Widgets")); + m_Node->SetProperty("helper object", mitk::BoolProperty::New(true)); +} + + +mitk::SliceNavigationController* QmitkStdMultiWidget::GetTimeNavigationController() +{ + return m_TimeNavigationController.GetPointer(); +} + + +void QmitkStdMultiWidget::EnableStandardLevelWindow() +{ + levelWindowWidget->disconnect(this); + levelWindowWidget->SetDataStorage(mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow())->GetDataStorage()); + levelWindowWidget->show(); +} + + +void QmitkStdMultiWidget::DisableStandardLevelWindow() +{ + levelWindowWidget->disconnect(this); + levelWindowWidget->hide(); +} + + +// CAUTION: Legacy code for enabling Qt-signal-controlled view initialization. +// Use RenderingManager::InitializeViews() instead. +bool QmitkStdMultiWidget::InitializeStandardViews( const mitk::Geometry3D * geometry ) +{ + return mitk::RenderingManager::GetInstance()->InitializeViews( geometry ); +} + + +void QmitkStdMultiWidget::RequestUpdate() +{ + mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget1->GetRenderWindow()); + mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget2->GetRenderWindow()); + mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget3->GetRenderWindow()); + mitk::RenderingManager::GetInstance()->RequestUpdate(mitkWidget4->GetRenderWindow()); +} + + +void QmitkStdMultiWidget::ForceImmediateUpdate() +{ + mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget1->GetRenderWindow()); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget2->GetRenderWindow()); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget3->GetRenderWindow()); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdate(mitkWidget4->GetRenderWindow()); +} + + +void QmitkStdMultiWidget::wheelEvent( QWheelEvent * e ) +{ + emit WheelMoved( e ); +} + +void QmitkStdMultiWidget::mousePressEvent(QMouseEvent * e) +{ + if (e->button() == Qt::LeftButton) { + mitk::Point3D pointValue = this->GetLastLeftClickPosition(); + emit LeftMouseClicked(pointValue); + } +} + +void QmitkStdMultiWidget::moveEvent( QMoveEvent* e ) +{ + QWidget::moveEvent( e ); + + // it is necessary to readjust the position of the overlays as the StdMultiWidget has moved + // unfortunately it's not done by QmitkRenderWindow::moveEvent -> must be done here + emit Moved(); +} + +void QmitkStdMultiWidget::leaveEvent ( QEvent * /*e*/ ) +{ + //set cursor back to initial state + m_SlicesRotator->ResetMouseCursor(); +} + +QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow1() const +{ + return mitkWidget1; +} + + +QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow2() const +{ + return mitkWidget2; +} + + +QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow3() const +{ + return mitkWidget3; +} + + +QmitkRenderWindow* QmitkStdMultiWidget::GetRenderWindow4() const +{ + return mitkWidget4; +} + + +const mitk::Point3D& QmitkStdMultiWidget::GetLastLeftClickPosition() const +{ + return m_LastLeftClickPositionSupplier->GetCurrentPoint(); +} + + +const mitk::Point3D QmitkStdMultiWidget::GetCrossPosition() const +{ + const mitk::PlaneGeometry *plane1 = + mitkWidget1->GetSliceNavigationController()->GetCurrentPlaneGeometry(); + const mitk::PlaneGeometry *plane2 = + mitkWidget2->GetSliceNavigationController()->GetCurrentPlaneGeometry(); + const mitk::PlaneGeometry *plane3 = + mitkWidget3->GetSliceNavigationController()->GetCurrentPlaneGeometry(); + + mitk::Line3D line; + if ( (plane1 != NULL) && (plane2 != NULL) + && (plane1->IntersectionLine( plane2, line )) ) + { + mitk::Point3D point; + if ( (plane3 != NULL) + && (plane3->IntersectionPoint( line, point )) ) + { + return point; + } + } + return m_LastLeftClickPositionSupplier->GetCurrentPoint(); +} + + +void QmitkStdMultiWidget::EnablePositionTracking() +{ + if (!m_PositionTracker) + { + m_PositionTracker = mitk::PositionTracker::New("PositionTracker", NULL); + } + mitk::GlobalInteraction* globalInteraction = mitk::GlobalInteraction::GetInstance(); + if (globalInteraction) + { + if(m_DataStorage.IsNotNull()) + m_DataStorage->Add(m_PositionTrackerNode); + globalInteraction->AddListener(m_PositionTracker); + } +} + + +void QmitkStdMultiWidget::DisablePositionTracking() +{ + mitk::GlobalInteraction* globalInteraction = + mitk::GlobalInteraction::GetInstance(); + + if(globalInteraction) + { + if (m_DataStorage.IsNotNull()) + m_DataStorage->Remove(m_PositionTrackerNode); + globalInteraction->RemoveListener(m_PositionTracker); + } +} + + +void QmitkStdMultiWidget::EnsureDisplayContainsPoint( + mitk::DisplayGeometry* displayGeometry, const mitk::Point3D& p) +{ + mitk::Point2D pointOnPlane; + displayGeometry->Map( p, pointOnPlane ); + + // point minus origin < width or height ==> outside ? + mitk::Vector2D pointOnRenderWindow_MM; + pointOnRenderWindow_MM = pointOnPlane.GetVectorFromOrigin() + - displayGeometry->GetOriginInMM(); + + mitk::Vector2D sizeOfDisplay( displayGeometry->GetSizeInMM() ); + + if ( sizeOfDisplay[0] < pointOnRenderWindow_MM[0] + || 0 > pointOnRenderWindow_MM[0] + || sizeOfDisplay[1] < pointOnRenderWindow_MM[1] + || 0 > pointOnRenderWindow_MM[1] ) + { + // point is not visible -> move geometry + mitk::Vector2D offset( (pointOnRenderWindow_MM - sizeOfDisplay / 2.0) + / displayGeometry->GetScaleFactorMMPerDisplayUnit() ); + + displayGeometry->MoveBy( offset ); + } +} + + +void QmitkStdMultiWidget::MoveCrossToPosition(const mitk::Point3D& newPosition) +{ + // create a PositionEvent with the given position and + // tell the slice navigation controllers to move there + + mitk::Point2D p2d; + mitk::PositionEvent event( mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow()), 0, 0, 0, + mitk::Key_unknown, p2d, newPosition ); + mitk::StateEvent stateEvent(mitk::EIDLEFTMOUSEBTN, &event); + mitk::StateEvent stateEvent2(mitk::EIDLEFTMOUSERELEASE, &event); + + switch ( m_PlaneMode ) + { + default: + case PLANE_MODE_SLICING: + mitkWidget1->GetSliceNavigationController()->HandleEvent( &stateEvent ); + mitkWidget2->GetSliceNavigationController()->HandleEvent( &stateEvent ); + mitkWidget3->GetSliceNavigationController()->HandleEvent( &stateEvent ); + + // just in case SNCs will develop something that depends on the mouse + // button being released again + mitkWidget1->GetSliceNavigationController()->HandleEvent( &stateEvent2 ); + mitkWidget2->GetSliceNavigationController()->HandleEvent( &stateEvent2 ); + mitkWidget3->GetSliceNavigationController()->HandleEvent( &stateEvent2 ); + break; + + case PLANE_MODE_ROTATION: + m_SlicesRotator->HandleEvent( &stateEvent ); + + // just in case SNCs will develop something that depends on the mouse + // button being released again + m_SlicesRotator->HandleEvent( &stateEvent2 ); + break; + + case PLANE_MODE_SWIVEL: + m_SlicesSwiveller->HandleEvent( &stateEvent ); + + // just in case SNCs will develop something that depends on the mouse + // button being released again + m_SlicesSwiveller->HandleEvent( &stateEvent2 ); + break; + } + + // determine if cross is now out of display + // if so, move the display window + EnsureDisplayContainsPoint( mitk::BaseRenderer::GetInstance(mitkWidget1->GetRenderWindow()) + ->GetDisplayGeometry(), newPosition ); + EnsureDisplayContainsPoint( mitk::BaseRenderer::GetInstance(mitkWidget2->GetRenderWindow()) + ->GetDisplayGeometry(), newPosition ); + EnsureDisplayContainsPoint( mitk::BaseRenderer::GetInstance(mitkWidget3->GetRenderWindow()) + ->GetDisplayGeometry(), newPosition ); + + // update displays + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkStdMultiWidget::HandleCrosshairPositionEvent() +{ + if(!m_PendingCrosshairPositionEvent) + { + m_PendingCrosshairPositionEvent=true; + QTimer::singleShot(0,this,SLOT( HandleCrosshairPositionEventDelayed() ) ); + } +} + +void QmitkStdMultiWidget::HandleCrosshairPositionEventDelayed() +{ + m_PendingCrosshairPositionEvent = false; + + // find image with highest layer + mitk::Point3D crosshairPos = this->GetCrossPosition(); + + mitk::TNodePredicateDataType::Pointer isImageData = mitk::TNodePredicateDataType::New(); + + mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->m_DataStorage->GetSubset(isImageData).GetPointer(); + std::string statusText; + mitk::Image::Pointer image3D; + int maxlayer = -32768; + + mitk::BaseRenderer* baseRenderer = this->mitkWidget1->GetSliceNavigationController()->GetRenderer(); + // find image with largest layer, that is the image shown on top in the render window + for (unsigned int x = 0; x < nodes->size(); x++) + { + if(nodes->at(x)->GetData()->GetGeometry()->IsInside(crosshairPos)) + { + int layer = 0; + if(!(nodes->at(x)->GetIntProperty("layer", layer))) continue; + if(layer > maxlayer) + { + if( static_cast(nodes->at(x))->IsVisible( baseRenderer ) ) + { + image3D = dynamic_cast(nodes->at(x)->GetData()); + maxlayer = layer; + } + } + } + } + + std::stringstream stream; + + mitk::Index3D p; + if(image3D.IsNotNull()) + { + image3D->GetGeometry()->WorldToIndex(crosshairPos, p); + stream.precision(2); + stream<<"Position: <" << std::fixed < mm"; + stream<<"; Index: <"< "; + mitk::ScalarType pixelValue = image3D->GetPixelValueByIndex(p, baseRenderer->GetTimeStep()); + if (fabs(pixelValue)>1000000) + { + stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: "<GetPixelValueByIndex(p, baseRenderer->GetTimeStep())<<" "; + } + else + { + stream<<"; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: "<GetPixelValueByIndex(p, baseRenderer->GetTimeStep())<<" "; + } + } + else + { + stream << "No image information at this position!"; + } + + statusText = stream.str(); + mitk::StatusBar::GetInstance()->DisplayGreyValueText(statusText.c_str()); + + +} + +void QmitkStdMultiWidget::EnableNavigationControllerEventListening() +{ + // Let NavigationControllers listen to GlobalInteraction + mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); + + // Listen for SliceNavigationController + mitkWidget1->GetSliceNavigationController()->crosshairPositionEvent.AddListener( mitk::MessageDelegate( this, &QmitkStdMultiWidget::HandleCrosshairPositionEvent ) ); + mitkWidget2->GetSliceNavigationController()->crosshairPositionEvent.AddListener( mitk::MessageDelegate( this, &QmitkStdMultiWidget::HandleCrosshairPositionEvent ) ); + mitkWidget3->GetSliceNavigationController()->crosshairPositionEvent.AddListener( mitk::MessageDelegate( this, &QmitkStdMultiWidget::HandleCrosshairPositionEvent ) ); + + switch ( m_PlaneMode ) + { + default: + case PLANE_MODE_SLICING: + gi->AddListener( mitkWidget1->GetSliceNavigationController() ); + gi->AddListener( mitkWidget2->GetSliceNavigationController() ); + gi->AddListener( mitkWidget3->GetSliceNavigationController() ); + gi->AddListener( mitkWidget4->GetSliceNavigationController() ); + break; + + case PLANE_MODE_ROTATION: + gi->AddListener( m_SlicesRotator ); + break; + + case PLANE_MODE_SWIVEL: + gi->AddListener( m_SlicesSwiveller ); + break; + } + + gi->AddListener( m_TimeNavigationController ); + m_CrosshairNavigationEnabled = true; +} + +void QmitkStdMultiWidget::DisableNavigationControllerEventListening() +{ + // Do not let NavigationControllers listen to GlobalInteraction + mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); + + switch ( m_PlaneMode ) + { + default: + case PLANE_MODE_SLICING: + gi->RemoveListener( mitkWidget1->GetSliceNavigationController() ); + gi->RemoveListener( mitkWidget2->GetSliceNavigationController() ); + gi->RemoveListener( mitkWidget3->GetSliceNavigationController() ); + gi->RemoveListener( mitkWidget4->GetSliceNavigationController() ); + break; + + case PLANE_MODE_ROTATION: + m_SlicesRotator->ResetMouseCursor(); + gi->RemoveListener( m_SlicesRotator ); + break; + + case PLANE_MODE_SWIVEL: + m_SlicesSwiveller->ResetMouseCursor(); + gi->RemoveListener( m_SlicesSwiveller ); + break; + } + + gi->RemoveListener( m_TimeNavigationController ); + m_CrosshairNavigationEnabled = false; +} + + +int QmitkStdMultiWidget::GetLayout() const +{ + return m_Layout; +} + +bool QmitkStdMultiWidget::GetGradientBackgroundFlag() const +{ + return m_GradientBackgroundFlag; +} + +void QmitkStdMultiWidget::EnableGradientBackground() +{ + // gradient background is by default only in widget 4, otherwise + // interferences between 2D rendering and VTK rendering may occur. + //m_GradientBackground1->Enable(); + //m_GradientBackground2->Enable(); + //m_GradientBackground3->Enable(); + m_GradientBackground4->Enable(); + m_GradientBackgroundFlag = true; +} + + +void QmitkStdMultiWidget::DisableGradientBackground() +{ + //m_GradientBackground1->Disable(); + //m_GradientBackground2->Disable(); + //m_GradientBackground3->Disable(); + m_GradientBackground4->Disable(); + m_GradientBackgroundFlag = false; +} + + +void QmitkStdMultiWidget::EnableDepartmentLogo() +{ + m_LogoRendering4->Enable(); +} + + +void QmitkStdMultiWidget::DisableDepartmentLogo() +{ + m_LogoRendering4->Disable(); +} + +bool QmitkStdMultiWidget::IsDepartmentLogoEnabled() const +{ + return m_LogoRendering4->IsEnabled(); +} + +bool QmitkStdMultiWidget::IsCrosshairNavigationEnabled() const +{ + return m_CrosshairNavigationEnabled; +} + + +mitk::SlicesRotator * QmitkStdMultiWidget::GetSlicesRotator() const +{ + return m_SlicesRotator; +} + + +mitk::SlicesSwiveller * QmitkStdMultiWidget::GetSlicesSwiveller() const +{ + return m_SlicesSwiveller; +} + + +void QmitkStdMultiWidget::SetWidgetPlaneVisibility(const char* widgetName, bool visible, mitk::BaseRenderer *renderer) +{ + if (m_DataStorage.IsNotNull()) + { + mitk::DataNode* n = m_DataStorage->GetNamedNode(widgetName); + if (n != NULL) + n->SetVisibility(visible, renderer); + } +} + + +void QmitkStdMultiWidget::SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer) +{ + SetWidgetPlaneVisibility("widget1Plane", visible, renderer); + SetWidgetPlaneVisibility("widget2Plane", visible, renderer); + SetWidgetPlaneVisibility("widget3Plane", visible, renderer); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + + +void QmitkStdMultiWidget::SetWidgetPlanesLocked(bool locked) +{ + //do your job and lock or unlock slices. + GetRenderWindow1()->GetSliceNavigationController()->SetSliceLocked(locked); + GetRenderWindow2()->GetSliceNavigationController()->SetSliceLocked(locked); + GetRenderWindow3()->GetSliceNavigationController()->SetSliceLocked(locked); +} + + +void QmitkStdMultiWidget::SetWidgetPlanesRotationLocked(bool locked) +{ + //do your job and lock or unlock slices. + GetRenderWindow1()->GetSliceNavigationController()->SetSliceRotationLocked(locked); + GetRenderWindow2()->GetSliceNavigationController()->SetSliceRotationLocked(locked); + GetRenderWindow3()->GetSliceNavigationController()->SetSliceRotationLocked(locked); +} + + +void QmitkStdMultiWidget::SetWidgetPlanesRotationLinked( bool link ) +{ + m_SlicesRotator->SetLinkPlanes( link ); + m_SlicesSwiveller->SetLinkPlanes( link ); + emit WidgetPlanesRotationLinked( link ); +} + + +void QmitkStdMultiWidget::SetWidgetPlaneMode( int userMode ) +{ + MITK_DEBUG << "Changing crosshair mode to " << userMode; + + // first of all reset left mouse button interaction to default if PACS interaction style is active + m_MouseModeSwitcher->SelectMouseMode( mitk::MouseModeSwitcher::MousePointer ); + + emit WidgetNotifyNewCrossHairMode( userMode ); + + int mode = m_PlaneMode; + bool link = false; + + // Convert user interface mode to actual mode + { + switch(userMode) + { + case 0: + mode = PLANE_MODE_SLICING; + link = false; + break; + + case 1: + mode = PLANE_MODE_ROTATION; + link = false; + break; + + case 2: + mode = PLANE_MODE_ROTATION; + link = true; + break; + + case 3: + mode = PLANE_MODE_SWIVEL; + link = false; + break; + } + } + + // Slice rotation linked + m_SlicesRotator->SetLinkPlanes( link ); + m_SlicesSwiveller->SetLinkPlanes( link ); + + // Do nothing if mode didn't change + if ( m_PlaneMode == mode ) + { + return; + } + + mitk::GlobalInteraction *gi = mitk::GlobalInteraction::GetInstance(); + + // Remove listeners of previous mode + switch ( m_PlaneMode ) + { + default: + case PLANE_MODE_SLICING: + // Notify MainTemplate GUI that this mode has been deselected + emit WidgetPlaneModeSlicing( false ); + + gi->RemoveListener( mitkWidget1->GetSliceNavigationController() ); + gi->RemoveListener( mitkWidget2->GetSliceNavigationController() ); + gi->RemoveListener( mitkWidget3->GetSliceNavigationController() ); + gi->RemoveListener( mitkWidget4->GetSliceNavigationController() ); + break; + + case PLANE_MODE_ROTATION: + // Notify MainTemplate GUI that this mode has been deselected + emit WidgetPlaneModeRotation( false ); + + m_SlicesRotator->ResetMouseCursor(); + gi->RemoveListener( m_SlicesRotator ); + break; + + case PLANE_MODE_SWIVEL: + // Notify MainTemplate GUI that this mode has been deselected + emit WidgetPlaneModeSwivel( false ); + + m_SlicesSwiveller->ResetMouseCursor(); + gi->RemoveListener( m_SlicesSwiveller ); + break; + } + + // Set new mode and add corresponding listener to GlobalInteraction + m_PlaneMode = mode; + switch ( m_PlaneMode ) + { + default: + case PLANE_MODE_SLICING: + // Notify MainTemplate GUI that this mode has been selected + emit WidgetPlaneModeSlicing( true ); + + // Add listeners + gi->AddListener( mitkWidget1->GetSliceNavigationController() ); + gi->AddListener( mitkWidget2->GetSliceNavigationController() ); + gi->AddListener( mitkWidget3->GetSliceNavigationController() ); + gi->AddListener( mitkWidget4->GetSliceNavigationController() ); + + mitk::RenderingManager::GetInstance()->InitializeViews(); + break; + + case PLANE_MODE_ROTATION: + // Notify MainTemplate GUI that this mode has been selected + emit WidgetPlaneModeRotation( true ); + + // Add listener + gi->AddListener( m_SlicesRotator ); + break; + + case PLANE_MODE_SWIVEL: + // Notify MainTemplate GUI that this mode has been selected + emit WidgetPlaneModeSwivel( true ); + + // Add listener + gi->AddListener( m_SlicesSwiveller ); + break; + } + // Notify MainTemplate GUI that mode has changed + emit WidgetPlaneModeChange(m_PlaneMode); +} + + +void QmitkStdMultiWidget::SetGradientBackgroundColors( const mitk::Color & upper, const mitk::Color & lower ) +{ + m_GradientBackground1->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); + m_GradientBackground2->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); + m_GradientBackground3->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); + m_GradientBackground4->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]); + m_GradientBackgroundFlag = true; +} + + +void QmitkStdMultiWidget::SetDepartmentLogoPath( const char * path ) +{ + m_LogoRendering1->SetLogoSource(path); + m_LogoRendering2->SetLogoSource(path); + m_LogoRendering3->SetLogoSource(path); + m_LogoRendering4->SetLogoSource(path); +} + + +void QmitkStdMultiWidget::SetWidgetPlaneModeToSlicing( bool activate ) +{ + if ( activate ) + { + this->SetWidgetPlaneMode( PLANE_MODE_SLICING ); + } +} + + +void QmitkStdMultiWidget::SetWidgetPlaneModeToRotation( bool activate ) +{ + if ( activate ) + { + this->SetWidgetPlaneMode( PLANE_MODE_ROTATION ); + } +} + + +void QmitkStdMultiWidget::SetWidgetPlaneModeToSwivel( bool activate ) +{ + if ( activate ) + { + this->SetWidgetPlaneMode( PLANE_MODE_SWIVEL ); + } +} + +void QmitkStdMultiWidget::OnLayoutDesignChanged( int layoutDesignIndex ) +{ + switch( layoutDesignIndex ) + { + case LAYOUT_DEFAULT: + { + this->changeLayoutToDefault(); + break; + } + case LAYOUT_2D_IMAGES_UP: + { + this->changeLayoutTo2DImagesUp(); + break; + } + case LAYOUT_2D_IMAGES_LEFT: + { + this->changeLayoutTo2DImagesLeft(); + break; + } + case LAYOUT_BIG_3D: + { + this->changeLayoutToBig3D(); + break; + } + case LAYOUT_WIDGET1: + { + this->changeLayoutToWidget1(); + break; + } + case LAYOUT_WIDGET2: + { + this->changeLayoutToWidget2(); + break; + } + case LAYOUT_WIDGET3: + { + this->changeLayoutToWidget3(); + break; + } + case LAYOUT_2X_2D_AND_3D_WIDGET: + { + this->changeLayoutTo2x2Dand3DWidget(); + break; + } + case LAYOUT_ROW_WIDGET_3_AND_4: + { + this->changeLayoutToRowWidget3And4(); + break; + } + case LAYOUT_COLUMN_WIDGET_3_AND_4: + { + this->changeLayoutToColumnWidget3And4(); + break; + } + case LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4: + { + this->changeLayoutToRowWidgetSmall3andBig4(); + break; + } + case LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4: + { + this->changeLayoutToSmallUpperWidget2Big3and4(); + break; + } + case LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET: + { + this->changeLayoutToLeft2Dand3DRight2D(); + break; + } + + }; + + +} + +void QmitkStdMultiWidget::UpdateAllWidgets() +{ + mitkWidget1->resize( mitkWidget1Container->frameSize().width()-1, mitkWidget1Container->frameSize().height() ); + mitkWidget1->resize( mitkWidget1Container->frameSize().width(), mitkWidget1Container->frameSize().height() ); + + mitkWidget2->resize( mitkWidget2Container->frameSize().width()-1, mitkWidget2Container->frameSize().height() ); + mitkWidget2->resize( mitkWidget2Container->frameSize().width(), mitkWidget2Container->frameSize().height() ); + + mitkWidget3->resize( mitkWidget3Container->frameSize().width()-1, mitkWidget3Container->frameSize().height() ); + mitkWidget3->resize( mitkWidget3Container->frameSize().width(), mitkWidget3Container->frameSize().height() ); + + mitkWidget4->resize( mitkWidget4Container->frameSize().width()-1, mitkWidget4Container->frameSize().height() ); + mitkWidget4->resize( mitkWidget4Container->frameSize().width(), mitkWidget4Container->frameSize().height() ); + +} + + +void QmitkStdMultiWidget::HideAllWidgetToolbars() +{ + mitkWidget1->HideRenderWindowMenu(); + mitkWidget2->HideRenderWindowMenu(); + mitkWidget3->HideRenderWindowMenu(); + mitkWidget4->HideRenderWindowMenu(); +} + +void QmitkStdMultiWidget::ActivateMenuWidget( bool state ) +{ + mitkWidget1->ActivateMenuWidget( state ); + mitkWidget2->ActivateMenuWidget( state ); + mitkWidget3->ActivateMenuWidget( state ); + mitkWidget4->ActivateMenuWidget( state ); +} + +bool QmitkStdMultiWidget::IsMenuWidgetEnabled() const +{ + return mitkWidget1->GetActivateMenuWidgetFlag(); +} + +void QmitkStdMultiWidget::ResetCrosshair() +{ + if (m_DataStorage.IsNotNull()) + { + mitk::NodePredicateNot::Pointer pred + = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" + , mitk::BoolProperty::New(false))); + + mitk::NodePredicateNot::Pointer pred2 + = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" + , mitk::BoolProperty::New(true))); + + mitk::DataStorage::SetOfObjects::ConstPointer rs = m_DataStorage->GetSubset(pred); + mitk::DataStorage::SetOfObjects::ConstPointer rs2 = m_DataStorage->GetSubset(pred2); + // calculate bounding geometry of these nodes + mitk::TimeSlicedGeometry::Pointer bounds = m_DataStorage->ComputeBoundingGeometry3D(rs, "visible"); + + mitk::RenderingManager::GetInstance()->InitializeViews(bounds); + //mitk::RenderingManager::GetInstance()->InitializeViews( m_DataStorage->ComputeVisibleBoundingGeometry3D() ); + // reset interactor to normal slicing + this->SetWidgetPlaneMode(PLANE_MODE_SLICING); + } +} + +void QmitkStdMultiWidget::EnableColoredRectangles() +{ + m_RectangleRendering1->Enable(1.0, 0.0, 0.0); + m_RectangleRendering2->Enable(0.0, 1.0, 0.0); + m_RectangleRendering3->Enable(0.0, 0.0, 1.0); + m_RectangleRendering4->Enable(1.0, 1.0, 0.0); +} + +void QmitkStdMultiWidget::DisableColoredRectangles() +{ + m_RectangleRendering1->Disable(); + m_RectangleRendering2->Disable(); + m_RectangleRendering3->Disable(); + m_RectangleRendering4->Disable(); +} + +bool QmitkStdMultiWidget::IsColoredRectanglesEnabled() const +{ + return m_RectangleRendering1->IsEnabled(); +} + +mitk::MouseModeSwitcher* QmitkStdMultiWidget::GetMouseModeSwitcher() +{ + return m_MouseModeSwitcher; +} + +void QmitkStdMultiWidget::MouseModeSelected( mitk::MouseModeSwitcher::MouseMode mouseMode ) +{ + if ( mouseMode == 0 ) + { + this->EnableNavigationControllerEventListening(); + } + else + { + this->DisableNavigationControllerEventListening(); + } +} + diff --git a/Modules/Qmitk/QmitkStdMultiWidget.h b/Modules/Qmitk/QmitkStdMultiWidget.h new file mode 100644 index 0000000000..e76b9bd068 --- /dev/null +++ b/Modules/Qmitk/QmitkStdMultiWidget.h @@ -0,0 +1,331 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKSTDMULTIWIDGET_H_ +#define QMITKSTDMULTIWIDGET_H_ + +#include + +#include "mitkPositionTracker.h" +#include "mitkSlicesRotator.h" +#include "mitkSlicesSwiveller.h" +#include "mitkRenderWindowFrame.h" +#include "mitkManufacturerLogo.h" +#include "mitkGradientBackground.h" +#include "mitkCoordinateSupplier.h" +#include "mitkDataStorage.h" + +#include "mitkMouseModeSwitcher.h" + +#include +#include +#include + +#include +#include + +#include "vtkTextProperty.h" +#include "vtkCornerAnnotation.h" + +class QHBoxLayout; +class QVBoxLayout; +class QGridLayout; +class QSpacerItem; +class QmitkLevelWindowWidget; +class QmitkRenderWindow; + +class QMITK_EXPORT QmitkStdMultiWidget : public QWidget +{ + Q_OBJECT + +public: + + QmitkStdMultiWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkStdMultiWidget(); + + mitk::SliceNavigationController* + GetTimeNavigationController(); + + void RequestUpdate(); + + void ForceImmediateUpdate(); + + mitk::MouseModeSwitcher* GetMouseModeSwitcher(); + + + QmitkRenderWindow* GetRenderWindow1() const; + + QmitkRenderWindow* GetRenderWindow2() const; + + QmitkRenderWindow* GetRenderWindow3() const; + + QmitkRenderWindow* GetRenderWindow4() const; + + const mitk::Point3D & + GetLastLeftClickPosition() const; + + const mitk::Point3D + GetCrossPosition() const; + + void EnablePositionTracking(); + + void DisablePositionTracking(); + + int GetLayout() const; + + mitk::SlicesRotator * GetSlicesRotator() const; + + mitk::SlicesSwiveller * GetSlicesSwiveller() const; + + bool GetGradientBackgroundFlag() const; + + bool IsColoredRectanglesEnabled() const; + + bool IsDepartmentLogoEnabled() const; + + bool IsCrosshairNavigationEnabled() const; + + void InitializeWidget(); + + /// called when the StdMultiWidget is closed to remove the 3 widget planes and the helper node from the DataStorage + void RemovePlanesFromDataStorage(); + + void AddPlanesToDataStorage(); + + void SetDataStorage( mitk::DataStorage* ds ); + + /** \brief Listener to the CrosshairPositionEvent + + Ensures the CrosshairPositionEvent is handled only once and at the end of the Qt-Event loop + */ + void HandleCrosshairPositionEvent(); + + /// activate Menu Widget. true: activated, false: deactivated + void ActivateMenuWidget( bool state ); + + bool IsMenuWidgetEnabled() const; + +protected: + + void UpdateAllWidgets(); + + void HideAllWidgetToolbars(); + +public slots: + + /// Receives the signal from HandleCrosshairPositionEvent, executes the StatusBar update + void HandleCrosshairPositionEventDelayed(); + + void changeLayoutTo2DImagesUp(); + + void changeLayoutTo2DImagesLeft(); + + void changeLayoutToDefault(); + + void changeLayoutToBig3D(); + + void changeLayoutToWidget1(); + + void changeLayoutToWidget2(); + + void changeLayoutToWidget3(); + + void changeLayoutToRowWidget3And4(); + + void changeLayoutToColumnWidget3And4(); + + void changeLayoutToRowWidgetSmall3andBig4(); + + void changeLayoutToSmallUpperWidget2Big3and4(); + + void changeLayoutTo2x2Dand3DWidget(); + + void changeLayoutToLeft2Dand3DRight2D(); + + void changeLayoutTo2DUpAnd3DDown(); + + void Fit(); + + void InitPositionTracking(); + + void AddDisplayPlaneSubTree(); + + void EnableStandardLevelWindow(); + + void DisableStandardLevelWindow(); + + bool InitializeStandardViews( const mitk::Geometry3D * geometry ); + + void wheelEvent( QWheelEvent * e ); + + void mousePressEvent(QMouseEvent * e); + + void moveEvent( QMoveEvent* e ); + + void leaveEvent ( QEvent * e ); + + void EnsureDisplayContainsPoint( + mitk::DisplayGeometry* displayGeometry, const mitk::Point3D& p); + + void MoveCrossToPosition(const mitk::Point3D& newPosition); + + void EnableNavigationControllerEventListening(); + + void DisableNavigationControllerEventListening(); + + void EnableGradientBackground(); + + void DisableGradientBackground(); + + void EnableDepartmentLogo(); + + void DisableDepartmentLogo(); + + void EnableColoredRectangles(); + + void DisableColoredRectangles(); + + void SetWidgetPlaneVisibility(const char* widgetName, bool visible, mitk::BaseRenderer *renderer=NULL); + + void SetWidgetPlanesVisibility(bool visible, mitk::BaseRenderer *renderer=NULL); + + void SetWidgetPlanesLocked(bool locked); + + void SetWidgetPlanesRotationLocked(bool locked); + + void SetWidgetPlanesRotationLinked( bool link ); + + void SetWidgetPlaneMode( int mode ); + + void SetGradientBackgroundColors( const mitk::Color & upper, const mitk::Color & lower ); + + void SetDepartmentLogoPath( const char * path ); + + void SetWidgetPlaneModeToSlicing( bool activate ); + + void SetWidgetPlaneModeToRotation( bool activate ); + + void SetWidgetPlaneModeToSwivel( bool activate ); + + void OnLayoutDesignChanged( int layoutDesignIndex ); + + void ResetCrosshair(); + + void MouseModeSelected( mitk::MouseModeSwitcher::MouseMode mouseMode ); + + +signals: + + void LeftMouseClicked(mitk::Point3D pointValue); + void WheelMoved(QWheelEvent*); + void WidgetPlanesRotationLinked(bool); + void WidgetPlanesRotationEnabled(bool); + void ViewsInitialized(); + void WidgetPlaneModeSlicing(bool); + void WidgetPlaneModeRotation(bool); + void WidgetPlaneModeSwivel(bool); + void WidgetPlaneModeChange(int); + void WidgetNotifyNewCrossHairMode(int); + void Moved(); + +public: + + /** Define RenderWindow (public)*/ + QmitkRenderWindow* mitkWidget1; + QmitkRenderWindow* mitkWidget2; + QmitkRenderWindow* mitkWidget3; + QmitkRenderWindow* mitkWidget4; + QmitkLevelWindowWidget* levelWindowWidget; + /********************************/ + + enum { PLANE_MODE_SLICING = 0, PLANE_MODE_ROTATION, PLANE_MODE_SWIVEL }; + enum { LAYOUT_DEFAULT = 0, LAYOUT_2D_IMAGES_UP, LAYOUT_2D_IMAGES_LEFT, + LAYOUT_BIG_3D, LAYOUT_WIDGET1, LAYOUT_WIDGET2, LAYOUT_WIDGET3, + LAYOUT_2X_2D_AND_3D_WIDGET, LAYOUT_ROW_WIDGET_3_AND_4, + LAYOUT_COLUMN_WIDGET_3_AND_4, LAYOUT_ROW_WIDGET_SMALL3_AND_BIG4 , + LAYOUT_SMALL_UPPER_WIDGET2_BIG3_AND4,LAYOUT_2D_AND_3D_LEFT_2D_RIGHT_WIDGET, + LAYOUT_2D_UP_AND_3D_DOWN}; + + enum { + TRANSVERSAL, + SAGITTAL, + CORONAL, + THREE_D + }; + + +protected: + + QHBoxLayout* QmitkStdMultiWidgetLayout; + + int m_Layout; + int m_PlaneMode; + + mitk::RenderWindowFrame::Pointer m_RectangleRendering3; + mitk::RenderWindowFrame::Pointer m_RectangleRendering2; + mitk::RenderWindowFrame::Pointer m_RectangleRendering1; + mitk::RenderWindowFrame::Pointer m_RectangleRendering4; + + mitk::ManufacturerLogo::Pointer m_LogoRendering1; + mitk::ManufacturerLogo::Pointer m_LogoRendering2; + mitk::ManufacturerLogo::Pointer m_LogoRendering3; + mitk::ManufacturerLogo::Pointer m_LogoRendering4; + + mitk::GradientBackground::Pointer m_GradientBackground1; + mitk::GradientBackground::Pointer m_GradientBackground2; + mitk::GradientBackground::Pointer m_GradientBackground4; + mitk::GradientBackground::Pointer m_GradientBackground3; + bool m_GradientBackgroundFlag; + + + mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher; + mitk::CoordinateSupplier::Pointer m_LastLeftClickPositionSupplier; + mitk::PositionTracker::Pointer m_PositionTracker; + mitk::SliceNavigationController::Pointer m_TimeNavigationController; + mitk::SlicesRotator::Pointer m_SlicesRotator; + mitk::SlicesSwiveller::Pointer m_SlicesSwiveller; + + mitk::DataNode::Pointer m_PositionTrackerNode; + mitk::DataStorage::Pointer m_DataStorage; + + mitk::DataNode::Pointer m_PlaneNode1; + mitk::DataNode::Pointer m_PlaneNode2; + mitk::DataNode::Pointer m_PlaneNode3; + mitk::DataNode::Pointer m_Node; + + QSplitter *m_MainSplit; + QSplitter *m_LayoutSplit; + QSplitter *m_SubSplit1; + QSplitter *m_SubSplit2; + + QWidget *mitkWidget1Container; + QWidget *mitkWidget2Container; + QWidget *mitkWidget3Container; + QWidget *mitkWidget4Container; + + struct + { + vtkCornerAnnotation *cornerText; + vtkTextProperty *textProp; + vtkRenderer *ren; + } m_CornerAnnotaions[3]; + + bool m_PendingCrosshairPositionEvent; + bool m_CrosshairNavigationEnabled; + +}; +#endif /*QMITKSTDMULTIWIDGET_H_*/ diff --git a/CoreUI/Qmitk/Segmentation_48.png b/Modules/Qmitk/Segmentation_48.png similarity index 100% rename from CoreUI/Qmitk/Segmentation_48.png rename to Modules/Qmitk/Segmentation_48.png diff --git a/CoreUI/Qmitk/Surface_48.png b/Modules/Qmitk/Surface_48.png similarity index 100% rename from CoreUI/Qmitk/Surface_48.png rename to Modules/Qmitk/Surface_48.png diff --git a/Modules/Qmitk/files.cmake b/Modules/Qmitk/files.cmake new file mode 100644 index 0000000000..de4e751642 --- /dev/null +++ b/Modules/Qmitk/files.cmake @@ -0,0 +1,63 @@ +SET(CPP_FILES +QmitkApplicationCursor.cpp +QmitkEnums.h +QmitkCustomVariants.h +QmitkDataStorageComboBox.cpp +QmitkDataStorageListModel.cpp +QmitkDataStorageTableModel.cpp +QmitkDataStorageTreeModel.cpp +QmitkEventAdapter.cpp +QmitkLevelWindowPresetDefinitionDialog.cpp +QmitkLevelWindowRangeChangeDialog.cpp +QmitkLevelWindowWidgetContextMenu.cpp +QmitkLevelWindowWidget.cpp +QmitkLineEditLevelWindowWidget.cpp +QmitkMemoryUsageIndicatorView.cpp +QmitkNodeDescriptor.cpp +QmitkNodeDescriptorManager.cpp +QmitkRenderWindowMenu.cpp +QmitkProgressBar.cpp +QmitkPropertiesTableEditor.cpp +QmitkPropertiesTableModel.cpp +QmitkPropertyDelegate.cpp +QmitkRegisterClasses.cpp +QmitkRenderingManager.cpp +QmitkRenderingManagerFactory.cpp +QmitkRenderWindow.cpp +QmitkSliderLevelWindowWidget.cpp +QmitkStdMultiWidget.cpp +QmitkMouseModeSwitcher.cpp +) + +SET(MOC_H_FILES +QmitkDataStorageComboBox.h +QmitkDataStorageTableModel.h +QmitkLevelWindowPresetDefinitionDialog.h +QmitkLevelWindowRangeChangeDialog.h +QmitkLevelWindowWidgetContextMenu.h +QmitkLevelWindowWidget.h +QmitkLineEditLevelWindowWidget.h +QmitkMemoryUsageIndicatorView.h +QmitkNodeDescriptor.h +QmitkNodeDescriptorManager.h +QmitkRenderWindowMenu.h +QmitkProgressBar.h +QmitkPropertiesTableEditor.h +QmitkPropertyDelegate.h +QmitkRenderingManager.h +QmitkRenderWindow.h +QmitkSliderLevelWindowWidget.h +QmitkStdMultiWidget.h +QmitkMouseModeSwitcher.h +) + +SET(UI_FILES +QmitkLevelWindowPresetDefinition.ui +QmitkLevelWindowWidget.ui +QmitkLevelWindowRangeChange.ui +QmitkMemoryUsageIndicator.ui +) + +SET(QRC_FILES + Qmitk.qrc +) diff --git a/CoreUI/Qmitk/iconClose.xpm b/Modules/Qmitk/iconClose.xpm similarity index 100% rename from CoreUI/Qmitk/iconClose.xpm rename to Modules/Qmitk/iconClose.xpm diff --git a/CoreUI/Qmitk/iconCrosshairMode.xpm b/Modules/Qmitk/iconCrosshairMode.xpm similarity index 100% rename from CoreUI/Qmitk/iconCrosshairMode.xpm rename to Modules/Qmitk/iconCrosshairMode.xpm diff --git a/CoreUI/Qmitk/iconFullScreen.xpm b/Modules/Qmitk/iconFullScreen.xpm similarity index 100% rename from CoreUI/Qmitk/iconFullScreen.xpm rename to Modules/Qmitk/iconFullScreen.xpm diff --git a/CoreUI/Qmitk/iconHoriSplit.xpm b/Modules/Qmitk/iconHoriSplit.xpm similarity index 100% rename from CoreUI/Qmitk/iconHoriSplit.xpm rename to Modules/Qmitk/iconHoriSplit.xpm diff --git a/CoreUI/Qmitk/iconLeaveFullScreen.xpm b/Modules/Qmitk/iconLeaveFullScreen.xpm similarity index 100% rename from CoreUI/Qmitk/iconLeaveFullScreen.xpm rename to Modules/Qmitk/iconLeaveFullScreen.xpm diff --git a/CoreUI/Qmitk/iconSettings.xpm b/Modules/Qmitk/iconSettings.xpm similarity index 100% rename from CoreUI/Qmitk/iconSettings.xpm rename to Modules/Qmitk/iconSettings.xpm diff --git a/CoreUI/Qmitk/iconVertiSplit.xpm b/Modules/Qmitk/iconVertiSplit.xpm similarity index 100% rename from CoreUI/Qmitk/iconVertiSplit.xpm rename to Modules/Qmitk/iconVertiSplit.xpm diff --git a/CoreUI/Qmitk/mm_contrast.png b/Modules/Qmitk/mm_contrast.png similarity index 100% rename from CoreUI/Qmitk/mm_contrast.png rename to Modules/Qmitk/mm_contrast.png diff --git a/CoreUI/Qmitk/mm_pan.png b/Modules/Qmitk/mm_pan.png similarity index 100% rename from CoreUI/Qmitk/mm_pan.png rename to Modules/Qmitk/mm_pan.png diff --git a/CoreUI/Qmitk/mm_pointer.png b/Modules/Qmitk/mm_pointer.png similarity index 100% rename from CoreUI/Qmitk/mm_pointer.png rename to Modules/Qmitk/mm_pointer.png diff --git a/CoreUI/Qmitk/mm_scroll.png b/Modules/Qmitk/mm_scroll.png similarity index 100% rename from CoreUI/Qmitk/mm_scroll.png rename to Modules/Qmitk/mm_scroll.png diff --git a/CoreUI/Qmitk/mm_zoom.png b/Modules/Qmitk/mm_zoom.png similarity index 100% rename from CoreUI/Qmitk/mm_zoom.png rename to Modules/Qmitk/mm_zoom.png diff --git a/CoreUI/Qmitk/mousemodes.xcf b/Modules/Qmitk/mousemodes.xcf similarity index 100% rename from CoreUI/Qmitk/mousemodes.xcf rename to Modules/Qmitk/mousemodes.xcf diff --git a/Modules/SceneSerialization/mitkSceneDataNodeReader.cpp b/Modules/SceneSerialization/mitkSceneDataNodeReader.cpp new file mode 100644 index 0000000000..13688938ad --- /dev/null +++ b/Modules/SceneSerialization/mitkSceneDataNodeReader.cpp @@ -0,0 +1,38 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "mitkSceneDataNodeReader.h" + +#include "mitkSceneIO.h" + +namespace mitk { + +int mitk::SceneDataNodeReader::Read(const std::string &fileName, mitk::DataStorage &storage) +{ + int n = 0; + if (fileName.substr(fileName.size()-5) == ".mitk") + { + SceneIO::Pointer sceneIO = SceneIO::New(); + int oldSize = storage.GetAll()->Size(); + sceneIO->LoadScene(fileName, &storage, false); + n = storage.GetAll()->Size() - oldSize; + } + return n; +} + +} diff --git a/Modules/SceneSerialization/mitkSceneDataNodeReader.h b/Modules/SceneSerialization/mitkSceneDataNodeReader.h new file mode 100644 index 0000000000..1202d4d7c0 --- /dev/null +++ b/Modules/SceneSerialization/mitkSceneDataNodeReader.h @@ -0,0 +1,38 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKSCENEDATANODEREADER_H +#define MITKSCENEDATANODEREADER_H + +#include + +namespace mitk { + +class SceneDataNodeReader : public itk::LightObject, public mitk::IDataNodeReader +{ + +public: + + itkNewMacro(SceneDataNodeReader) + + int Read(const std::string& fileName, mitk::DataStorage& storage); +}; + +} + +#endif // MITKSCENEDATANODEREADER_H diff --git a/Modules/SceneSerialization/mitkSceneSerializationActivator.cpp b/Modules/SceneSerialization/mitkSceneSerializationActivator.cpp new file mode 100644 index 0000000000..df4e612323 --- /dev/null +++ b/Modules/SceneSerialization/mitkSceneSerializationActivator.cpp @@ -0,0 +1,50 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkSceneDataNodeReader.h" + +#include +#include + +namespace mitk { + +/* + * This is the module activator for the "SceneSerialization" module. + */ +class SceneSerializationActivator : public ModuleActivator +{ +public: + + void Load(mitk::ModuleContext* context) + { + m_SceneDataNodeReader = mitk::SceneDataNodeReader::New(); + context->RegisterService(m_SceneDataNodeReader); + } + + void Unload(mitk::ModuleContext* ) + { + } + +private: + + SceneDataNodeReader::Pointer m_SceneDataNodeReader; +}; + +} + +MITK_EXPORT_MODULE_ACTIVATOR(SceneSerialization, mitk::SceneSerializationActivator) + diff --git a/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.cpp b/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.cpp index 3bd68c89b6..bb71f7aaa2 100644 --- a/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.cpp +++ b/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.cpp @@ -1,253 +1,277 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include #include -#include -#include -#include #include #include #include #include #include #include mitk::ToFDistanceImageToSurfaceFilter::ToFDistanceImageToSurfaceFilter() : - m_IplScalarImage(NULL), m_CameraIntrinsics(), m_TextureImageWidth(0), m_TextureImageHeight(0), m_InterPixelDistance(), m_TextureIndex(0) + m_IplScalarImage(NULL), m_CameraIntrinsics(), m_TextureImageWidth(0), m_TextureImageHeight(0), m_InterPixelDistance(), m_TextureIndex(0) { - m_InterPixelDistance.Fill(0.045); - m_CameraIntrinsics = mitk::CameraIntrinsics::New(); - m_CameraIntrinsics->SetFocalLength(295.78960196187319,296.1255427948447); - m_CameraIntrinsics->SetPrincipalPoint(113.29063841714108,97.243216122015184); - m_CameraIntrinsics->SetDistorsionCoeffs(-0.36874385358645773f,-0.14339503290129013,0.0033210108720361795,-0.004277703352074105); + //intialize these variables just once and not in every run of the filter! + m_InterPixelDistance.Fill(0.045); + m_CameraIntrinsics = mitk::CameraIntrinsics::New(); + m_CameraIntrinsics->SetFocalLength(295.78960196187319,296.1255427948447); + m_CameraIntrinsics->SetPrincipalPoint(113.29063841714108,97.243216122015184); + m_CameraIntrinsics->SetDistorsionCoeffs(-0.36874385358645773f,-0.14339503290129013,0.0033210108720361795,-0.004277703352074105); + m_Mesh = vtkSmartPointer::New(); + m_Points = vtkSmartPointer::New(); + m_Points->SetDataTypeToDouble(); + m_Polys = vtkSmartPointer::New(); } mitk::ToFDistanceImageToSurfaceFilter::~ToFDistanceImageToSurfaceFilter() { } void mitk::ToFDistanceImageToSurfaceFilter::SetInput( Image* distanceImage, mitk::CameraIntrinsics::Pointer cameraIntrinsics ) { - this->SetCameraIntrinsics(cameraIntrinsics); - this->SetInput(0,distanceImage); + this->SetCameraIntrinsics(cameraIntrinsics); + this->SetInput(0,distanceImage); } void mitk::ToFDistanceImageToSurfaceFilter::SetInput( unsigned int idx, Image* distanceImage, mitk::CameraIntrinsics::Pointer cameraIntrinsics ) { - this->SetCameraIntrinsics(cameraIntrinsics); - this->SetInput(idx,distanceImage); + this->SetCameraIntrinsics(cameraIntrinsics); + this->SetInput(idx,distanceImage); } void mitk::ToFDistanceImageToSurfaceFilter::SetInput( mitk::Image* distanceImage ) { - this->SetInput(0,distanceImage); + this->SetInput(0,distanceImage); } //TODO: braucht man diese Methode? void mitk::ToFDistanceImageToSurfaceFilter::SetInput( unsigned int idx, mitk::Image* distanceImage ) { - if ((distanceImage == NULL) && (idx == this->GetNumberOfInputs() - 1)) // if the last input is set to NULL, reduce the number of inputs by one - this->SetNumberOfInputs(this->GetNumberOfInputs() - 1); - else - this->ProcessObject::SetNthInput(idx, distanceImage); // Process object is not const-correct so the const_cast is required here + if ((distanceImage == NULL) && (idx == this->GetNumberOfInputs() - 1)) // if the last input is set to NULL, reduce the number of inputs by one + this->SetNumberOfInputs(this->GetNumberOfInputs() - 1); + else + this->ProcessObject::SetNthInput(idx, distanceImage); // Process object is not const-correct so the const_cast is required here - this->CreateOutputsForAllInputs(); + this->CreateOutputsForAllInputs(); } mitk::Image* mitk::ToFDistanceImageToSurfaceFilter::GetInput() { - return this->GetInput(0); + return this->GetInput(0); } mitk::Image* mitk::ToFDistanceImageToSurfaceFilter::GetInput( unsigned int idx ) { - if (this->GetNumberOfInputs() < 1) - return NULL; //TODO: geeignete exception werfen - return static_cast< mitk::Image*>(this->ProcessObject::GetInput(idx)); + if (this->GetNumberOfInputs() < 1) + return NULL; //TODO: geeignete exception werfen + return static_cast< mitk::Image*>(this->ProcessObject::GetInput(idx)); } void mitk::ToFDistanceImageToSurfaceFilter::GenerateData() { - mitk::Surface::Pointer output = this->GetOutput(); - assert(output); - mitk::Image::Pointer input = this->GetInput(); - assert(input); - // mesh points - int xDimension = input->GetDimension(0); - int yDimension = input->GetDimension(1); - unsigned int size = xDimension*yDimension; //size of the image-array - std::vector isPointValid; - isPointValid.resize(size); - int pointCount = 0; - vtkSmartPointer points = vtkSmartPointer::New(); - points->SetDataTypeToDouble(); - vtkSmartPointer polys = vtkSmartPointer::New(); - vtkSmartPointer scalarArray = vtkSmartPointer::New(); - vtkSmartPointer textureCoords = vtkSmartPointer::New(); - textureCoords->SetNumberOfComponents(2); - - float textureScaleCorrection1 = 0.0; - float textureScaleCorrection2 = 0.0; - if (this->m_TextureImageHeight > 0.0 && this->m_TextureImageWidth > 0.0) - { - textureScaleCorrection1 = float(this->m_TextureImageHeight) / float(this->m_TextureImageWidth); - textureScaleCorrection2 = ((float(this->m_TextureImageWidth) - float(this->m_TextureImageHeight))/2) / float(this->m_TextureImageWidth); - } - - float* scalarFloatData = NULL; - - if (this->m_IplScalarImage) // if scalar image is defined use it for texturing - { - scalarFloatData = (float*)this->m_IplScalarImage->imageData; - } - else if (this->GetInput(m_TextureIndex)) // otherwise use intensity image (input(2)) - { - scalarFloatData = (float*)this->GetInput(m_TextureIndex)->GetData(); - } - - float* inputFloatData = (float*)(input->GetSliceData(0, 0, 0)->GetData()); - //calculate world coordinates - mitk::ToFProcessingCommon::ToFScalarType focalLength = (m_CameraIntrinsics->GetFocalLengthX()*m_InterPixelDistance[0]+m_CameraIntrinsics->GetFocalLengthY()*m_InterPixelDistance[1])/2.0; - mitk::ToFProcessingCommon::ToFPoint2D principalPoint; - principalPoint[0] = m_CameraIntrinsics->GetPrincipalPointX(); - principalPoint[1] = m_CameraIntrinsics->GetPrincipalPointY(); - - for (int j=0; jGetOutput(); + assert(output); + mitk::Image::Pointer input = this->GetInput(); + assert(input); + int xDimension = input->GetDimension(0); + int yDimension = input->GetDimension(1); + unsigned int size = xDimension*yDimension; //size of the image-array + std::vector isPointValid; + isPointValid.resize(size); + vtkSmartPointer scalarArray = vtkSmartPointer::New(); + vtkSmartPointer textureCoords = vtkSmartPointer::New(); + textureCoords->SetNumberOfComponents(2); + + float textureScaleCorrection1 = 0.0; + float textureScaleCorrection2 = 0.0; + if (this->m_TextureImageHeight > 0.0 && this->m_TextureImageWidth > 0.0) + { + textureScaleCorrection1 = float(this->m_TextureImageHeight) / float(this->m_TextureImageWidth); + textureScaleCorrection2 = ((float(this->m_TextureImageWidth) - float(this->m_TextureImageHeight))/2) / float(this->m_TextureImageWidth); + } + + float* scalarFloatData = NULL; + + if (this->m_IplScalarImage) // if scalar image is defined use it for texturing + { + scalarFloatData = (float*)this->m_IplScalarImage->imageData; + } + else if (this->GetInput(m_TextureIndex)) // otherwise use intensity image (input(2)) { - // distance value - mitk::Index3D pixel; - pixel[0] = i; - pixel[1] = j; - pixel[2] = 0; - - unsigned int pixelID = pixel[0]+pixel[1]*xDimension; - - mitk::ToFProcessingCommon::ToFScalarType distance = (double)inputFloatData[pixelID]; - - mitk::ToFProcessingCommon::ToFPoint3D cartesianCoordinates = - mitk::ToFProcessingCommon::IndexToCartesianCoordinates(i,j,distance,focalLength,m_InterPixelDistance,principalPoint); - - //TODO: why epsilon here and what value should it have? -// if (cartesianCoordinates[2] == 0) - if (distance<=mitk::eps) - { - isPointValid[pointCount] = false; - } - else - { - isPointValid[pointCount] = true; - - points->InsertPoint(pixelID, cartesianCoordinates.GetDataPointer()); - - if((i >= 1) && (j >= 1)) + scalarFloatData = (float*)this->GetInput(m_TextureIndex)->GetData(); + } + + float* inputFloatData = (float*)(input->GetData()); + //calculate world coordinates. *0.5 is faster then /2. + mitk::ToFProcessingCommon::ToFScalarType focalLength = (m_CameraIntrinsics->GetFocalLengthX()*m_InterPixelDistance[0]+m_CameraIntrinsics->GetFocalLengthY()*m_InterPixelDistance[1])*0.5; + mitk::ToFProcessingCommon::ToFPoint2D principalPoint; + principalPoint[0] = m_CameraIntrinsics->GetPrincipalPointX(); + principalPoint[1] = m_CameraIntrinsics->GetPrincipalPointY(); + + //array to save the distance values corresponding to 1 quad + mitk::ToFProcessingCommon::ToFScalarType lastDistances[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + + + for (int j=0; jInsertNextCell(3); - polys->InsertCellPoint(x_1y); - polys->InsertCellPoint(xy); - polys->InsertCellPoint(x_1y_1); - - polys->InsertNextCell(3); - polys->InsertCellPoint(x_1y_1); - polys->InsertCellPoint(xy); - polys->InsertCellPoint(xy_1); - } + // distance value + unsigned int pixelID = i+j*xDimension; + + mitk::ToFProcessingCommon::ToFScalarType distance = inputFloatData[pixelID]; + + mitk::ToFProcessingCommon::ToFPoint3D cartesianCoordinates = + mitk::ToFProcessingCommon::IndexToCartesianCoordinates(i,j,distance,focalLength,m_InterPixelDistance,principalPoint); + + //Test if the distance is (almost) 0.0 or smaller, because we want to exclude 0 and negative values. + if (distance<=mitk::eps) + { + isPointValid[pixelID] = false; + } + else + { + isPointValid[pixelID] = true; + + //expensive call, because of memory allocation of VTK + m_Points->InsertPoint(pixelID, cartesianCoordinates.GetDataPointer()); + + + + if((i >= 1) && (j >= 1)) + { + lastDistances[2] = lastDistances[3]; //(i-1,j) + lastDistances[3] = cartesianCoordinates[2]; // = (i,j) + //save as much arithmetic as possible + vtkIdType xy = pixelID; + vtkIdType x_1y = pixelID-1; + vtkIdType xy_1 = i+(j-1)*xDimension; + vtkIdType x_1y_1 = xy_1-1; + + //Delaunay-like triangulation. + //The edge is placed such that the difference between opposing points is minimized. + if (isPointValid[xy]&&isPointValid[x_1y]&&isPointValid[x_1y_1]&&isPointValid[xy_1]) + { + //Check which two corner-points have the smallest difference + lastDistances[0] = inputFloatData[x_1y_1]; + lastDistances[1] = inputFloatData[xy_1]; + if( fabs(lastDistances[3] - lastDistances[0]) < fabs(lastDistances[1] - lastDistances[2]) ) + { + //Edge: left down to top right + //expensive call, because of memory allocation of VTK + m_Polys->InsertNextCell(3); + m_Polys->InsertCellPoint(xy); + m_Polys->InsertCellPoint(xy_1); + m_Polys->InsertCellPoint(x_1y_1); + m_Polys->InsertNextCell(3); + m_Polys->InsertCellPoint(xy); + m_Polys->InsertCellPoint(x_1y); + m_Polys->InsertCellPoint(x_1y_1); + } + else + { + //Edge: top to down right + //expensive call, because of memory allocation of VTK + m_Polys->InsertNextCell(3); + m_Polys->InsertCellPoint(xy_1); + m_Polys->InsertCellPoint(x_1y); + m_Polys->InsertCellPoint(xy); + m_Polys->InsertNextCell(3); + m_Polys->InsertCellPoint(xy_1); + m_Polys->InsertCellPoint(x_1y_1); + m_Polys->InsertCellPoint(x_1y); + } + } + } + else if(i == 0) + { + lastDistances[3] = cartesianCoordinates[2]; // = (i,j) + } + + if (scalarFloatData) + { + scalarArray->InsertTuple1(pixelID, scalarFloatData[pixelID]); + } + if (this->m_TextureImageHeight > 0.0 && this->m_TextureImageWidth > 0.0) + { + + float xNorm = (((float)i)/xDimension)*textureScaleCorrection1 + textureScaleCorrection2 ; // correct video texture scale 640 * 480!! + float yNorm = 1.0 - ((float)j)/yDimension; //flip y-axis + textureCoords->InsertTuple2(pixelID, xNorm, yNorm); + } + } } + } - if (scalarFloatData) - { - scalarArray->InsertTuple1(pixelID, scalarFloatData[pixel[0]+pixel[1]*xDimension]); - //scalarArray->InsertTuple1(pixelID, scalarFloatData[pixelID]); - } + m_Mesh->SetPoints(m_Points); + m_Mesh->SetPolys(m_Polys); + if (scalarArray->GetNumberOfTuples()>0) + { + m_Mesh->GetPointData()->SetScalars(scalarArray); if (this->m_TextureImageHeight > 0.0 && this->m_TextureImageWidth > 0.0) { - - float xNorm = (((float)pixel[0])/xDimension)*textureScaleCorrection1 + textureScaleCorrection2 ; // correct video texture scale 640 * 480!! - float yNorm = 1.0 - ((float)pixel[1])/yDimension; //flip y-axis - textureCoords->InsertTuple2(pixelID, xNorm, yNorm); + m_Mesh->GetPointData()->SetTCoords(textureCoords); } - } - pointCount++; } - } - - vtkSmartPointer mesh = vtkSmartPointer::New(); - mesh->SetPoints(points); - mesh->SetPolys(polys); - if (scalarArray->GetNumberOfTuples()>0) - { - mesh->GetPointData()->SetScalars(scalarArray); - if (this->m_TextureImageHeight > 0.0 && this->m_TextureImageWidth > 0.0) - { - mesh->GetPointData()->SetTCoords(textureCoords); - } - } - output->SetVtkPolyData(mesh); + output->SetVtkPolyData(m_Mesh); } void mitk::ToFDistanceImageToSurfaceFilter::CreateOutputsForAllInputs() { - this->SetNumberOfOutputs(this->GetNumberOfInputs()); // create outputs for all inputs - for (unsigned int idx = 0; idx < this->GetNumberOfOutputs(); ++idx) - if (this->GetOutput(idx) == NULL) - { - DataObjectPointer newOutput = this->MakeOutput(idx); - this->SetNthOutput(idx, newOutput); - } - this->Modified(); + this->SetNumberOfOutputs(this->GetNumberOfInputs()); // create outputs for all inputs + for (unsigned int idx = 0; idx < this->GetNumberOfOutputs(); ++idx) + if (this->GetOutput(idx) == NULL) + { + DataObjectPointer newOutput = this->MakeOutput(idx); + this->SetNthOutput(idx, newOutput); + } + this->Modified(); } void mitk::ToFDistanceImageToSurfaceFilter::GenerateOutputInformation() { - this->GetOutput(); - itkDebugMacro(<<"GenerateOutputInformation()"); + this->GetOutput(); + itkDebugMacro(<<"GenerateOutputInformation()"); } void mitk::ToFDistanceImageToSurfaceFilter::SetScalarImage(IplImage* iplScalarImage) { - this->m_IplScalarImage = iplScalarImage; - this->Modified(); + this->m_IplScalarImage = iplScalarImage; + this->Modified(); } IplImage* mitk::ToFDistanceImageToSurfaceFilter::GetScalarImage() { - return this->m_IplScalarImage; + return this->m_IplScalarImage; } void mitk::ToFDistanceImageToSurfaceFilter::SetTextureImageWidth(int width) { - this->m_TextureImageWidth = width; + this->m_TextureImageWidth = width; } void mitk::ToFDistanceImageToSurfaceFilter::SetTextureImageHeight(int height) { - this->m_TextureImageHeight = height; + this->m_TextureImageHeight = height; } diff --git a/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.h b/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.h index 88fed281fe..fcd638073a 100644 --- a/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.h +++ b/Modules/ToFProcessing/mitkToFDistanceImageToSurfaceFilter.h @@ -1,155 +1,165 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkToFDistanceImageToSurfaceFilter_h #define __mitkToFDistanceImageToSurfaceFilter_h #include #include -#include -#include +#include "mitkToFProcessingExports.h" +#include "mitkToFProcessingCommon.h" #include -#include "mitkCameraIntrinsics.h" #include + + +#include +#include +#include +#include + #include + namespace mitk { /** * @brief Converts a Time-of-Flight (ToF) distance image to a 3D surface using the pinhole camera model for coordinate computation. * The intrinsic parameters of the camera (FocalLength, PrincipalPoint, InterPixelDistance) are set via SetCameraIntrinsics(). The * measured distance for each pixel corresponds to the distance between the object point and the corresponding image point on the * image plane. * * The coordinate conversion follows the model of a common pinhole camera where the origin of the camera * coordinate system (world coordinates) is at the pinhole * \image html ../Modules/ToFProcessing/Documentation/PinholeCameraModel.png * The definition of the image plane and its coordinate systems (pixel and mm) is depicted in the following image * \image html ../Modules/ToFProcessing/Documentation/ImagePlane.png * * @ingroup SurfaceFilters * @ingroup ToFProcessing */ class mitkToFProcessing_EXPORT ToFDistanceImageToSurfaceFilter : public SurfaceSource { public: mitkClassMacro( ToFDistanceImageToSurfaceFilter , SurfaceSource ); itkNewMacro( Self ); itkSetMacro(CameraIntrinsics, mitk::CameraIntrinsics::Pointer); itkGetMacro(CameraIntrinsics, mitk::CameraIntrinsics::Pointer); itkSetMacro(InterPixelDistance,ToFProcessingCommon::ToFPoint2D); itkGetMacro(InterPixelDistance,ToFProcessingCommon::ToFPoint2D); itkSetMacro(TextureIndex,int); /*! \brief Set scalar image used as texture of the surface. \param iplScalarImage OpenCV image for texturing */ void SetScalarImage(IplImage* iplScalarImage); /*! \brief Set scalar image used as texture of the surface. \return OpenCV image for texturing */ IplImage* GetScalarImage(); /*! \brief Set width of the scalar image used for texturing the surface \param width width (x-dimension) of the texture image */ void SetTextureImageWidth(int width); /*! \brief Set height of the scalar image used for texturing the surface \param height height (y-dimension) of the texture image */ void SetTextureImageHeight(int height); /*! \brief Sets the input of this filter \param distanceImage input is the distance image of e.g. a ToF camera */ virtual void SetInput( Image* distanceImage); /*! \brief Sets the input of this filter and the intrinsic parameters \param distanceImage input is the distance image of e.g. a ToF camera */ virtual void SetInput( Image* distanceImage, mitk::CameraIntrinsics::Pointer cameraIntrinsics ); /*! \brief Sets the input of this filter at idx \param idx number of the current input \param distanceImage input is the distance image of e.g. a ToF camera */ virtual void SetInput(unsigned int idx, Image* distanceImage); /*! \brief Sets the input of this filter at idx and the intrinsic parameters \param idx number of the current input \param distanceImage input is the distance image of e.g. a ToF camera \param cameraIntrinsics This is the camera model which holds parameters like focal length, pixel size, etc. which are needed for the reconstruction of the surface. */ virtual void SetInput( unsigned int idx, Image* distanceImage, mitk::CameraIntrinsics::Pointer cameraIntrinsics ); /*! \brief Returns the input of this filter */ Image* GetInput(); /*! \brief Returns the input with id idx of this filter */ Image* GetInput(unsigned int idx); protected: /*! \brief Standard constructor */ ToFDistanceImageToSurfaceFilter(); /*! \brief Standard destructor */ ~ToFDistanceImageToSurfaceFilter(); virtual void GenerateOutputInformation(); /*! \brief Method generating the output of this filter. Called in the updated process of the pipeline. This method generates the output of the ToFSurfaceSource: The generated surface of the 3d points */ virtual void GenerateData(); /** * \brief Create an output for each input * * This Method sets the number of outputs to the number of inputs * and creates missing outputs objects. * \warning any additional outputs that exist before the method is called are deleted */ void CreateOutputsForAllInputs(); IplImage* m_IplScalarImage; ///< Scalar image used for surface texturing mitk::CameraIntrinsics::Pointer m_CameraIntrinsics; ///< Specifies the intrinsic parameters - //mitk::CameraIntrinsics::Pointer m_CameraModel; ///< Specifies the intrinsic parameters int m_TextureImageWidth; ///< Width (x-dimension) of the texture image int m_TextureImageHeight; ///< Height (y-dimension) of the texture image ToFProcessingCommon::ToFPoint2D m_InterPixelDistance; ///< distance in mm between two adjacent pixels on the ToF camera chip int m_TextureIndex; ///< Index of the input used as texture image when no scalar image was set via SetIplScalarImage(). 0 = Distance, 1 = Amplitude, 2 = Intensity + vtkSmartPointer m_Points; ///< VTK representation of all points in worldcoordinates + vtkSmartPointer m_Polys; ///< VTK representation of the faces/edges connecting the points + vtkSmartPointer m_Mesh; ///< Faces and points together form the mesh in VTK + }; } //END mitk namespace #endif diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake new file mode 100644 index 0000000000..37a1544854 --- /dev/null +++ b/Plugins/PluginList.cmake @@ -0,0 +1,41 @@ + +# Plug-ins must be ordered according to their dependencies + +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.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.diffusionimagingapp:OFF + org.mitk.gui.qt.datamanager:ON + org.mitk.gui.qt.basicimageprocessing: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.igtnavigation: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.moviemaker:OFF + org.mitk.gui.qt.pointsetinteraction:OFF + org.mitk.gui.qt.python.console:OFF + org.mitk.gui.qt.registration:OFF + org.mitk.gui.qt.segmentation:OFF + org.mitk.gui.qt.toftutorial:OFF + org.mitk.gui.qt.tofutil:OFF + org.mitk.gui.qt.ugvisualization:OFF + org.mitk.gui.qt.volumevisualization:OFF +) diff --git a/Modules/Bundles/org.mitk.core.ext/CMakeLists.txt b/Plugins/org.mitk.core.ext/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/CMakeLists.txt rename to Plugins/org.mitk.core.ext/CMakeLists.txt diff --git a/Plugins/org.mitk.core.ext/documentation/doxygen/modules.dox b/Plugins/org.mitk.core.ext/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..746060c9f1 --- /dev/null +++ b/Plugins/org.mitk.core.ext/documentation/doxygen/modules.dox @@ -0,0 +1,19 @@ +/** + \defgroup org_mitk_core_ext org.mitk.core.ext + \ingroup MITKPlugins + + \brief This small plug-in is responsible for initializing the MBI CoreExt module. + + It is started with an "eager" Bundle-ActivationPolicy, sucht that the plug-ins + activator is executed before any other (non-eager) plug-ins. + +*/ + +/** + \defgroup org_mitk_core_ext_internal Internal + \ingroup org_mitk_core_ext + + \brief This subcategory includes the internal classes of the org.mitk.core.ext plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.core.ext/files.cmake b/Plugins/org.mitk.core.ext/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/files.cmake rename to Plugins/org.mitk.core.ext/files.cmake diff --git a/Modules/Bundles/org.mitk.core.ext/manifest_headers.cmake b/Plugins/org.mitk.core.ext/manifest_headers.cmake similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/manifest_headers.cmake rename to Plugins/org.mitk.core.ext/manifest_headers.cmake diff --git a/Modules/Bundles/org.mitk.core.ext/plugin.xml b/Plugins/org.mitk.core.ext/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/plugin.xml rename to Plugins/org.mitk.core.ext/plugin.xml diff --git a/Modules/Bundles/org.mitk.core.ext/schema/inputdevice.exsd b/Plugins/org.mitk.core.ext/schema/inputdevice.exsd similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/schema/inputdevice.exsd rename to Plugins/org.mitk.core.ext/schema/inputdevice.exsd diff --git a/Modules/Bundles/org.mitk.core.ext/src/internal/mitkCoreExtActivator.cpp b/Plugins/org.mitk.core.ext/src/internal/mitkCoreExtActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/src/internal/mitkCoreExtActivator.cpp rename to Plugins/org.mitk.core.ext/src/internal/mitkCoreExtActivator.cpp diff --git a/Modules/Bundles/org.mitk.core.ext/src/internal/mitkCoreExtActivator.h b/Plugins/org.mitk.core.ext/src/internal/mitkCoreExtActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/src/internal/mitkCoreExtActivator.h rename to Plugins/org.mitk.core.ext/src/internal/mitkCoreExtActivator.h diff --git a/Plugins/org.mitk.core.ext/src/mitkCoreExtConstants.cpp b/Plugins/org.mitk.core.ext/src/mitkCoreExtConstants.cpp new file mode 100644 index 0000000000..f492b8291f --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkCoreExtConstants.cpp @@ -0,0 +1,31 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include + +#include "mitkIInputDeviceRegistry.h" + +const std::string mitk::CoreExtConstants::INPUTDEVICE_SERVICE = "org.mitk.core.ext.services.inputdeviceregistry"; +const std::string mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES = "org.mitk.core.ext.preferences.inputdevices"; +const std::string mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME = "org.mitk.core.ext.inputdevices"; +const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS = "class"; +const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION = "description"; +const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_NAME = "name"; +const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_ID = "id"; +const std::string mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION = "Surface Interaction"; +const std::string mitk::CoreExtConstants::WIIMOTE_HEADTRACKING = "Headtracking"; +const std::string mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME = "org.mitk.inputdevices.wiimote"; diff --git a/Plugins/org.mitk.core.ext/src/mitkCoreExtConstants.h b/Plugins/org.mitk.core.ext/src/mitkCoreExtConstants.h new file mode 100644 index 0000000000..4b7cae4abd --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkCoreExtConstants.h @@ -0,0 +1,54 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKCOREEXTCONSTANTS_H_ +#define MITKCOREEXTCONSTANTS_H_ + +#include + +#include + +namespace mitk +{ + /** + * The CoreExt Constants contains a list of unique ids in the following form:
+ * "org.mitk.mybundle.mytype.propername"
+ * + * This ids have the purpose of connecting the plugin.xml of each bundle to the + * appropriate classes. + * + * Additionally it includes names of tags, which are used in XML files
+ * regarding any input device. + * + * @ingroup org_mitk_core_ext + */ + struct MITKCOREEXT_EXPORT CoreExtConstants + { + static const std::string INPUTDEVICE_SERVICE; + static const std::string INPUTDEVICE_PREFERENCES; + static const std::string INPUTDEVICE_EXTENSION_NAME; + static const std::string INPUTDEVICE_XMLATTRIBUTE_CLASS; + static const std::string INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION; + static const std::string INPUTDEVICE_XMLATTRIBUTE_NAME; + static const std::string INPUTDEVICE_XMLATTRIBUTE_ID; + static const std::string WIIMOTE_SURFACEINTERACTION; + static const std::string WIIMOTE_HEADTRACKING; + static const std::string WIIMOTE_XMLATTRIBUTE_NAME; + }; +} + +#endif /*MITKCOREEXTCONSTANTS_H_*/ diff --git a/Plugins/org.mitk.core.ext/src/mitkIInputDevice.h b/Plugins/org.mitk.core.ext/src/mitkIInputDevice.h new file mode 100644 index 0000000000..ca8ae7603a --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkIInputDevice.h @@ -0,0 +1,57 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKIINPUTDEVICE_H_ +#define MITKIINPUTDEVICE_H_ + +#include +#include + +#include + +namespace mitk +{ + /** + * An input device provides a method to register and unregister itself. Meaning
+ * for example adding listeners and instianciate classes necessary to use the input device. + * + * @noimplement This interface is not intended to be implemented by clients. + * @ingroup org_mitk_core_ext + */ + struct IInputDevice : public berry::Object + { + + berryInterfaceMacro(IInputDevice, mitk) + + /** + * Register the input device at one or more instances. + */ + virtual bool RegisterInputDevice() = 0; + + /** + * Unregister the input device at one or more instances. + */ + virtual bool UnRegisterInputDevice() = 0; + + virtual ~IInputDevice() {} + + }; // end struct IInputDevice +} // end namespace mitk + +Q_DECLARE_INTERFACE(mitk::IInputDevice, "org.mitk.IInputDevice") + +#endif /*MITKIINPUTDEVICE_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceDescriptor.h b/Plugins/org.mitk.core.ext/src/mitkIInputDeviceDescriptor.h similarity index 100% rename from Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceDescriptor.h rename to Plugins/org.mitk.core.ext/src/mitkIInputDeviceDescriptor.h diff --git a/Plugins/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h b/Plugins/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h new file mode 100644 index 0000000000..2c02905d65 --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h @@ -0,0 +1,77 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKIINPUTDEVICEREGISTRY_H_ +#define MITKIINPUTDEVICEREGISTRY_H_ + +#include + +#include + +#include +#include + +#include + +#include "mitkIInputDeviceDescriptor.h" + +namespace mitk +{ + /** + * + * The input device registry maintains a list of input devices explicitly registered + * against the view extension point. + *

+ * The description of a given input device is kept in a IInputDeviceDescriptor. + *

+ *

+ * This interface is not intended to be implemented by clients. + *

+ * + * @see mitk::IInputDeviceDescriptor + * @noimplement This interface is not intended to be implemented by clients. + * @ingroup org_mitk_core_ext + */ + struct MITKCOREEXT_EXPORT IInputDeviceRegistry: public berry::Service + { + berryInterfaceMacro(IInputDeviceRegistry, mitk) + + /** + * Return an input device descriptor with the given extension id. If no input device exists, + * with the id return null. + * + * @param id + * the id to search for + * @return the descriptor or null + */ + virtual IInputDeviceDescriptor::Pointer Find(const std::string& id) const = 0; + + /** + * Return a list of input devices defined in the registry. + * + * @return the input devices. + */ + virtual std::vector GetInputDevices() const = 0; + + virtual ~IInputDeviceRegistry() {} + + }; // end struct IInputDeviceRegistry +} // end namespace mitk + +Q_DECLARE_INTERFACE(mitk::IInputDeviceRegistry, "org.mitk.service.IInputDeviceRegistry") + +#endif /*MITKIINPUTDEVICEREGISTRY_H_*/ diff --git a/Plugins/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp b/Plugins/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp new file mode 100644 index 0000000000..d98d818f4b --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp @@ -0,0 +1,84 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkInputDeviceDescriptor.h" +#include "mitkCoreExtConstants.h" + + +mitk::InputDeviceDescriptor::InputDeviceDescriptor(berry::IConfigurationElement::Pointer inputDeviceExtensionPoint) +: IInputDeviceDescriptor(), m_InputDeviceExtensionPoint(inputDeviceExtensionPoint) +{ +} + +mitk::InputDeviceDescriptor::~InputDeviceDescriptor() +{ +} + +mitk::IInputDevice::Pointer mitk::InputDeviceDescriptor::CreateInputDevice() +{ + if(this->m_InputDevice == 0) + { + // "class" refers to xml attribute in a xml tag + this->m_InputDevice = this->m_InputDeviceExtensionPoint + ->CreateExecutableExtension(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS); + if (this->m_InputDevice == 0) + { + // support legacy BlueBerry extensions + this->m_InputDevice = this->m_InputDeviceExtensionPoint + ->CreateExecutableExtension( + mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS, + IInputDevice::GetManifestName()); + } + } + return this->m_InputDevice; +} + +std::string mitk::InputDeviceDescriptor::GetID() const +{ + std::string idOfExtensionPoint; + this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_ID,idOfExtensionPoint); + return idOfExtensionPoint; +} + +std::string mitk::InputDeviceDescriptor::GetDescription() const +{ + std::vector + descriptions(this->m_InputDeviceExtensionPoint->GetChildren(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION)); + + if(!descriptions.empty()) + { + return descriptions[0]->GetValue(); + } + return ""; +} + +std::string mitk::InputDeviceDescriptor::GetName() const +{ + std::string name; + this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_NAME,name); + return name; +} + +bool mitk::InputDeviceDescriptor::operator==(const Object* object) const +{ + if (const InputDeviceDescriptor* other = dynamic_cast(object)) + { + return this->GetID() == other->GetID(); + } + return false; +} + diff --git a/Plugins/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h b/Plugins/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h new file mode 100644 index 0000000000..ca40817db1 --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h @@ -0,0 +1,88 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKINPUTDEVICEDESCRIPTOR_H_ +#define MITKINPUTDEVICEDESCRIPTOR_H_ + +#include + +#include + +#include "mitkIInputDeviceDescriptor.h" +#include "mitkIInputDevice.h" + +namespace mitk +{ + /** + * Documentation in the interface. + * + * @see mitk::IInputDeviceDescriptor + * @ingroup org_mitk_core_ext + */ + class InputDeviceDescriptor : public IInputDeviceDescriptor + { + + public: + + /** + * Initialize the Input Device Descriptor with the given extension point. + * + * @param inputDeviceExtensionPoint + * element, that refers to a extension point (type, id, name, class) + */ + InputDeviceDescriptor(berry::IConfigurationElement::Pointer inputDeviceExtensionPoint); + + /** + * Default destructor + */ + ~InputDeviceDescriptor(); + + /** + * @see mitk::IInputDeviceDescriptor::CreateInputDevice() + */ + mitk::IInputDevice::Pointer CreateInputDevice(); + + /** + * @see mitk::IInputDeviceDescriptor::GetDescription() + */ + std::string GetDescription() const; + + /** + * @see mitk::IInputDeviceDescriptor::GetID() + */ + std::string GetID() const; + + /** + * @see mitk::IInputDeviceDescriptor::GetName() + */ + std::string GetName() const; + + /** + * @see mitk::IInputDeviceDescriptor::operator==(const Object* object) + */ + bool operator==(const Object* object) const; + + private: + + // IConfigurationElements are used to access xml files (here: plugin.xml) + berry::IConfigurationElement::Pointer m_InputDeviceExtensionPoint; + mitk::IInputDevice::Pointer m_InputDevice; + + }; // end class +} // end namespace + +#endif /*MITKINPUTDEVICEDESCRIPTOR_H_*/ diff --git a/Plugins/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp b/Plugins/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp new file mode 100644 index 0000000000..28966b038e --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp @@ -0,0 +1,86 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include +#include +#include +#include +#include +#include "mitkCoreExtConstants.h" + +mitk::InputDeviceRegistry::InputDeviceRegistry() +{ + //initialize the registry by copying all available extension points into a local variable + berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); + std::vector allExtensionsInputDevices + = extensionPointService->GetConfigurationElementsFor(mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME); + + for(std::vector::const_iterator it = allExtensionsInputDevices.begin(); + it != allExtensionsInputDevices.end();++it) + { + InputDeviceDescriptorPtr temp(new mitk::InputDeviceDescriptor(*it)); + + // The equation with the end means, that if there is no such element and + // the pointer will be at end (not the last element, actually after it) + if(this->m_ListRegisteredDevices.find(temp->GetID()) == this->m_ListRegisteredDevices.end()) + { + m_ListRegisteredDevices.insert(std::make_pair(temp->GetID(),temp)); + } + else + { + throw std::runtime_error("The Input Device ID: "+temp->GetID()+" is already registered."); + } + } +} + +mitk::InputDeviceRegistry::~InputDeviceRegistry() +{ +} + +mitk::InputDeviceRegistry::InputDeviceDescriptorPtr mitk::InputDeviceRegistry::Find(const std::string &id) const +{ + Poco::HashMap::ConstIterator result = this->m_ListRegisteredDevices.find(id); + + // first = key, second = element or vice versa, if inserted different in the hash map + if(result != this->m_ListRegisteredDevices.end()) return result->second; + + return InputDeviceDescriptorPtr(0); +} + +std::vector mitk::InputDeviceRegistry::GetInputDevices() const +{ + std::vector temp; + for(Poco::HashMap::ConstIterator it = m_ListRegisteredDevices.begin(); + it != m_ListRegisteredDevices.end();++it) + { + // first = key, second = element or vice versa, if inserted different in the hash map + temp.push_back(it->second); + } + return temp; +} + +bool mitk::InputDeviceRegistry::IsA(const std::type_info& type) const +{ + std::string name(GetType().name()); + return name == type.name() || berry::Service::IsA(type); +} + +const std::type_info& mitk::InputDeviceRegistry::GetType() const +{ + return typeid(IInputDeviceRegistry); +} + diff --git a/Plugins/org.mitk.core.ext/src/mitkInputDeviceRegistry.h b/Plugins/org.mitk.core.ext/src/mitkInputDeviceRegistry.h new file mode 100644 index 0000000000..3e990240fd --- /dev/null +++ b/Plugins/org.mitk.core.ext/src/mitkInputDeviceRegistry.h @@ -0,0 +1,67 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKSPACENAVIGATORREGISTRY_H_ +#define MITKSPACENAVIGATORREGISTRY_H_ + +#include +#include +#include + +#include +#include + +namespace mitk +{ + /** + * Documentation in the interface. + * + * @see mitk::IInputDeviceRegistry + * @ingroup org_mitk_core_ext + */ + class InputDeviceRegistry : public IInputDeviceRegistry + { + public: + + bool IsA(const std::type_info& type) const; + const std::type_info& GetType() const; + + // easier maintenance + typedef IInputDeviceDescriptor::Pointer InputDeviceDescriptorPtr; + + InputDeviceRegistry(); + ~InputDeviceRegistry(); + + /** + * @see mitk::IInputDeviceRegistry::Find(const std::string& id) + */ + InputDeviceDescriptorPtr Find(const std::string& id) const; + + /** + * @see mitk::IInputDeviceRegistry´::GetInputDevices() + */ + std::vector GetInputDevices() const; + + protected: + + private: + Poco::HashMap m_ListRegisteredDevices; + + }; // end class InputDeviceRegistry +} // end namespace mitk + +#endif /*MITKSPACENAVIGATORREGISTRY_H_*/ diff --git a/Modules/Bundles/org.mitk.core.jobs/CMakeLists.txt b/Plugins/org.mitk.core.jobs/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/CMakeLists.txt rename to Plugins/org.mitk.core.jobs/CMakeLists.txt diff --git a/Plugins/org.mitk.core.jobs/documentation/doxygen/modules.dox b/Plugins/org.mitk.core.jobs/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..c59dbdc2c2 --- /dev/null +++ b/Plugins/org.mitk.core.jobs/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_core_jobs org.mitk.core.jobs + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_core_jobs_internal Internal + \ingroup org_mitk_core_jobs + + \brief This subcategory includes the internal classes of the org.mitk.core.jobs plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/pics/AddandRemoveRule.png b/Plugins/org.mitk.core.jobs/documentation/doxygen/pics/AddandRemoveRule.png similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/pics/AddandRemoveRule.png rename to Plugins/org.mitk.core.jobs/documentation/doxygen/pics/AddandRemoveRule.png diff --git a/Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/pics/TwoAddRules.png b/Plugins/org.mitk.core.jobs/documentation/doxygen/pics/TwoAddRules.png similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/pics/TwoAddRules.png rename to Plugins/org.mitk.core.jobs/documentation/doxygen/pics/TwoAddRules.png diff --git a/Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/pics/TwoRemoveRules.png b/Plugins/org.mitk.core.jobs/documentation/doxygen/pics/TwoRemoveRules.png similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/documentation/doxygen/pics/TwoRemoveRules.png rename to Plugins/org.mitk.core.jobs/documentation/doxygen/pics/TwoRemoveRules.png diff --git a/Modules/Bundles/org.mitk.core.jobs/files.cmake b/Plugins/org.mitk.core.jobs/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/files.cmake rename to Plugins/org.mitk.core.jobs/files.cmake diff --git a/Modules/Bundles/org.mitk.core.jobs/manifest_headers.cmake b/Plugins/org.mitk.core.jobs/manifest_headers.cmake similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/manifest_headers.cmake rename to Plugins/org.mitk.core.jobs/manifest_headers.cmake diff --git a/Modules/Bundles/org.mitk.core.jobs/resources/.qrc b/Plugins/org.mitk.core.jobs/resources/.qrc similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/resources/.qrc rename to Plugins/org.mitk.core.jobs/resources/.qrc diff --git a/Modules/Bundles/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp b/Plugins/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp rename to Plugins/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp diff --git a/Modules/Bundles/org.mitk.core.jobs/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.core.jobs/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.core.jobs/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.core.jobs/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.core.jobs/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.core.jobs/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.core.jobs/src/internal/mitkPluginActivator.h diff --git a/Plugins/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h b/Plugins/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h new file mode 100644 index 0000000000..124bf2ee61 --- /dev/null +++ b/Plugins/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h @@ -0,0 +1,159 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ +#define MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ + +#include + +#include "berryISchedulingRule.h" +#include "berryObject.h" +#include "mitkDataNode.h" +#include "mitkDataStorage.h" +#include "mitkStandaloneDataStorage.h" + +namespace mitk { + + /** + *@class DataStorageAccessRule + * + *@brief The DataStorageAccessRule inherits from the ISchedulingRule class. DataStorageAccessRule are used to restrict the adding and + * removing of DataStorage nodes in multi-threaded scenarios. Only DataStorageNodes within different branches can be modified + * concurrently. The idea and its restrictions is explained in the sections and diagrams below. + * + *

the IsScheduling(...) method :

+ * returns true or false depending if conflictions with another rule are found + *
+ *

+ * + *

+ *

the rule behavior if jobs holing add rules of an DataTree node

+ * + * two add rules are always allowed since there are no conflictions when adding nodes concurrently. The final order the nodes are finally added has + * to be checked by the programmer of the particular job + * + * + *

the rule behavior when two jobs holding remove rules of a DataNode

+ * + * two jobs holding remove rules can be executed concurrently since all removing scenarios do not cause conflictions. If two jobs are + * trying to remove the same DataTree node the job by itself needs to check if the node is still available before executing the removing + * command + * + * + *

the rule behavior of a jobs that is holding an add rule compared with a job that is holding a remove rule on a + * DataNode

+ * + * adding and removing of DataTree nodes concurrently can cause serious errors and needs to be restricted. Performing add and remove + * operations on different DataStorage branches can be done concurrently since no conflictions are expected. + * the performing of add and remove operation on the same DataNode, its parent nodes or child nodes of the same branch + * by different jobs is not allowed. Jobs holding rules that are trying to perform such operations are blocked until the running job is done. + * + *

+ * + *

+ *

the Contains method (...) method :

+ * only necessary for a specific type of scheduling rules. Has to be used if IScheduling rules are composed into hierarchies. + * In such scenarios the contains(...) method specifies the hierarchical relationships among the locks. For example if a method tries to acquire a specific * rule to lock a specific directory it needs to check if no job is holding a rule for one or more subdirectories. For all cases in which no composing of + * IScheduling rules is needed the Contains(...) method only needs to check if two jobs are holding exactly the same IScheduling rule on the same object. + * Normally this can be achieved by just calling the IsConflicting(...) method. + *

+ * + *@author Jan Woerner + */ + + + + + class MITK_JOBS_EXPORT DataStorageAccessRule : public berry::ISchedulingRule { + + public: + + + enum RuleType {ADD_RULE = 0, REMOVE_RULE} ; + + RuleType m_Rule; + + berryObjectMacro(DataStorageAccessRule) + + DataStorageAccessRule (mitk::DataStorage::Pointer myDataStorage, mitk::DataNode::Pointer myDataNode, + DataStorageAccessRule::RuleType myRule) ; + + bool Contains (berry::ISchedulingRule::Pointer otherISchedulingRule) ; + bool IsConflicting (berry::ISchedulingRule::Pointer otherISchedulingRule) ; + + + + + + +private: + + + /** + * Returns false, identifying no conflictions between two DataStorageAccessRules. + * Two add and remove rules do work together. From importance is that jobs using this rule need to check if the + * node operating on is still available or already deleted by another job. The DataStorageAccessRule only checks if conflictions could + * occur if the removing or adding of nodes is performed currently. + */ + bool CompareTwoAddorRemoveRules() const ; + /** + * searches for conflictions of an add DataStorageAccessRule with a remove DataStorageAccess rule + * if the add and remove rule do operate in different branches, no conflictions are expected and false is returned + */ + bool CompareAddandRemoveRules(mitk::DataStorageAccessRule::Pointer sptr_otherDataStorageAccessRule) const; + /** + * for internal use only, + * checks if the jobs that are to be compared do hold DataStorageAccessRule on the same + * DataStorage. Jobs that do operate on different DataStorage do not conflict and false is returned + */ + bool CompareDataStorages(mitk::DataStorage::Pointer otherDataStorage) const; + /** + * for internal use only + * validates if the DataTree node of a particular DataStorageAccess rule belongs to the DataStorage specified within the particular rule. + * if not the rule is invalid and false is returned. No conflictions can be expected + */ + bool TestDataNode(mitk::DataNode::Pointer dataTreeToBeStored) const; + + /** + * returns a pointer to the specified DataStorage node + */ + mitk::DataNode::Pointer GetDataNode() const; + + /** + * returns a pointer to the specified DataStorage + */ + mitk::DataStorage::Pointer GetDataStorage() const; + + mitk::DataStorageAccessRule::RuleType GetRuleType() const; + + + + + DataStorage::Pointer m_sptrMyDataStorage ; + DataNode::Pointer m_sptrMyDataNode ; + + + }; + + } + +#endif /*MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ */ diff --git a/CoreUI/Bundles/org.mitk.core.services/CMakeLists.txt b/Plugins/org.mitk.core.services/CMakeLists.txt similarity index 100% rename from CoreUI/Bundles/org.mitk.core.services/CMakeLists.txt rename to Plugins/org.mitk.core.services/CMakeLists.txt diff --git a/Plugins/org.mitk.core.services/documentation/doxygen/modules.dox b/Plugins/org.mitk.core.services/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..9ce368e6d1 --- /dev/null +++ b/Plugins/org.mitk.core.services/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_core_services org.mitk.core.services + \ingroup MITKPlugins + + \brief Provides basic MITK services. + +*/ + +/** + \defgroup org_mitk_core_services_internal Internal + \ingroup org_mitk_core_services + + \brief This subcategory includes the internal classes of the org.mitk.core.services plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/CoreUI/Bundles/org.mitk.core.services/files.cmake b/Plugins/org.mitk.core.services/files.cmake similarity index 100% rename from CoreUI/Bundles/org.mitk.core.services/files.cmake rename to Plugins/org.mitk.core.services/files.cmake diff --git a/CoreUI/Bundles/org.mitk.core.services/manifest_headers.cmake b/Plugins/org.mitk.core.services/manifest_headers.cmake similarity index 100% rename from CoreUI/Bundles/org.mitk.core.services/manifest_headers.cmake rename to Plugins/org.mitk.core.services/manifest_headers.cmake diff --git a/Plugins/org.mitk.core.services/src/internal/mitkDataStorageReference.cpp b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageReference.cpp new file mode 100644 index 0000000000..939955f942 --- /dev/null +++ b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageReference.cpp @@ -0,0 +1,56 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkDataStorageReference.h" + +namespace mitk { + +DataStorageReference::DataStorageReference(DataStorage::Pointer dataStorage, bool isDefault) +: m_Default(isDefault), m_DataStorage(dataStorage) +{ + +} + +DataStorage::Pointer DataStorageReference::GetDataStorage() const +{ + return m_DataStorage; +} + + +bool DataStorageReference::IsDefault() const +{ + return m_Default; +} + +QString DataStorageReference::GetLabel() const +{ + return m_Label; +} + +void DataStorageReference::SetLabel(const QString& label) +{ + m_Label = label; +} + +bool DataStorageReference::operator==(const berry::Object* o) const +{ + const DataStorageReference* other = dynamic_cast(o); + if (other == 0) return false; + return (m_DataStorage == other->m_DataStorage); +} + +} diff --git a/Plugins/org.mitk.core.services/src/internal/mitkDataStorageReference.h b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageReference.h new file mode 100644 index 0000000000..152e5c8615 --- /dev/null +++ b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageReference.h @@ -0,0 +1,50 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKDATASTORAGEREFERENCE_H_ +#define MITKDATASTORAGEREFERENCE_H_ + +#include "../mitkIDataStorageReference.h" + +namespace mitk +{ + +class DataStorageReference : public IDataStorageReference +{ +public: + + DataStorageReference(DataStorage::Pointer dataStorage, bool isDefault = false); + + DataStorage::Pointer GetDataStorage() const; + + bool IsDefault() const; + + QString GetLabel() const; + void SetLabel(const QString& label); + + bool operator==(const berry::Object* o) const; + +private: + + bool m_Default; + QString m_Label; + DataStorage::Pointer m_DataStorage; +}; + +} + +#endif /*MITKDATASTORAGEREFERENCE_H_*/ diff --git a/Plugins/org.mitk.core.services/src/internal/mitkDataStorageService.cpp b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageService.cpp new file mode 100644 index 0000000000..cbda248971 --- /dev/null +++ b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageService.cpp @@ -0,0 +1,104 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkDataStorageService.h" + +#include "mitkDataStorageReference.h" +#include "mitkStandaloneDataStorage.h" + +namespace mitk { + +DataStorageService::DataStorageService() +{ + m_DefaultDataStorageRef = this->CreateDataStorage("Default DataStorage"); + m_ActiveDataStorageRef = m_DefaultDataStorageRef; +} + +bool +DataStorageService::IsA(const std::type_info& type) const +{ + std::string name(GetType().name()); + return name == type.name() || Service::IsA(type); +} + +const std::type_info& +DataStorageService::GetType() const +{ + return typeid(IDataStorageService); +} + +IDataStorageReference::Pointer DataStorageService::CreateDataStorage(const QString& label) +{ + + StandaloneDataStorage::Pointer dataStorage = mitk::StandaloneDataStorage::New(); + DataStorageReference::Pointer ref(new DataStorageReference(dataStorage.GetPointer())); + ref->SetLabel(label); + m_DataStorageReferences.insert(ref); + + return ref; +} + + +std::vector DataStorageService::GetDataStorageReferences() const +{ + std::vector res; + res.reserve(m_DataStorageReferences.size()+1); + res.push_back(m_DefaultDataStorageRef); + res.insert(res.end(), m_DataStorageReferences.begin(), m_DataStorageReferences.end()); + return res; +} + +IDataStorageReference::Pointer DataStorageService::GetDefaultDataStorage() const +{ + return m_DefaultDataStorageRef; +} + +IDataStorageReference::Pointer DataStorageService::GetDataStorage() const +{ + if (m_ActiveDataStorageRef.IsNotNull()) return m_ActiveDataStorageRef; + return m_DefaultDataStorageRef; +} + +IDataStorageReference::Pointer DataStorageService::GetActiveDataStorage() const +{ + return m_ActiveDataStorageRef; +} + +void DataStorageService::SetActiveDataStorage(IDataStorageReference::Pointer dataStorageRef) +{ + if (dataStorageRef.IsNull()) m_ActiveDataStorageRef = m_DefaultDataStorageRef; + else m_ActiveDataStorageRef = dataStorageRef; +} + +void DataStorageService::AddDataStorageReference(IDataStorageReference::Pointer dataStorageRef) +{ + if (dataStorageRef.IsNull() || dataStorageRef->IsDefault()) return; + + m_DataStorageReferences.insert(dataStorageRef); +} + +bool DataStorageService::RemoveDataStorageReference(IDataStorageReference::Pointer dataStorageRef) +{ + if (m_ActiveDataStorageRef == dataStorageRef) + { + m_ActiveDataStorageRef = 0; + } + + return m_DataStorageReferences.erase(dataStorageRef); +} + +} diff --git a/Plugins/org.mitk.core.services/src/internal/mitkDataStorageService.h b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageService.h new file mode 100644 index 0000000000..a299807dc0 --- /dev/null +++ b/Plugins/org.mitk.core.services/src/internal/mitkDataStorageService.h @@ -0,0 +1,60 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKDATASTORAGESERVICE_H_ +#define MITKDATASTORAGESERVICE_H_ + +#include "../mitkIDataStorageService.h" + +namespace mitk { + +class DataStorageService : public QObject, public IDataStorageService +{ + Q_OBJECT + Q_INTERFACES(mitk::IDataStorageService) + +public: + + DataStorageService(); + + bool IsA(const std::type_info& type) const; + + const std::type_info& GetType() const; + + IDataStorageReference::Pointer CreateDataStorage(const QString& label); + + std::vector GetDataStorageReferences() const; + + IDataStorageReference::Pointer GetDefaultDataStorage() const; + IDataStorageReference::Pointer GetDataStorage() const; + + IDataStorageReference::Pointer GetActiveDataStorage() const; + void SetActiveDataStorage(IDataStorageReference::Pointer dataStorageRef); + + void AddDataStorageReference(IDataStorageReference::Pointer dataStorageRef); + bool RemoveDataStorageReference(IDataStorageReference::Pointer dataStorageRef); + +private: + + IDataStorageReference::Pointer m_ActiveDataStorageRef; + IDataStorageReference::Pointer m_DefaultDataStorageRef; + std::set m_DataStorageReferences; +}; + +} + +#endif /*MITKDATASTORAGESERVICE_H_*/ diff --git a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.core.services/src/internal/mitkPluginActivator.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.core.services/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.core.services/src/internal/mitkPluginActivator.cpp diff --git a/CoreUI/Bundles/org.mitk.core.services/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.core.services/src/internal/mitkPluginActivator.h similarity index 100% rename from CoreUI/Bundles/org.mitk.core.services/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.core.services/src/internal/mitkPluginActivator.h diff --git a/Plugins/org.mitk.core.services/src/mitkIDataStorageReference.h b/Plugins/org.mitk.core.services/src/mitkIDataStorageReference.h new file mode 100644 index 0000000000..5a681dabf1 --- /dev/null +++ b/Plugins/org.mitk.core.services/src/mitkIDataStorageReference.h @@ -0,0 +1,51 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKIDATASTORAGEREFERENCE_H_ +#define MITKIDATASTORAGEREFERENCE_H_ + +#include +#include + +#include + +#include + +namespace mitk +{ + +/** + * \ingroup org_mitk_core_services + */ +struct MITK_CORE_SERVICES_PLUGIN IDataStorageReference : public berry::Object +{ + berryInterfaceMacro(IDataStorageReference, mitk); + + + virtual DataStorage::Pointer GetDataStorage() const = 0; + + virtual bool IsDefault() const = 0; + + virtual QString GetLabel() const = 0; + virtual void SetLabel(const QString& label) = 0; + + virtual bool operator==(const berry::Object* o) const = 0; +}; + +} + +#endif /*MITKIDATASTORAGEREFERENCE_H_*/ diff --git a/CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageService.cpp b/Plugins/org.mitk.core.services/src/mitkIDataStorageService.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.core.services/src/mitkIDataStorageService.cpp rename to Plugins/org.mitk.core.services/src/mitkIDataStorageService.cpp diff --git a/Plugins/org.mitk.core.services/src/mitkIDataStorageService.h b/Plugins/org.mitk.core.services/src/mitkIDataStorageService.h new file mode 100644 index 0000000000..254dade2f2 --- /dev/null +++ b/Plugins/org.mitk.core.services/src/mitkIDataStorageService.h @@ -0,0 +1,60 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKIDATASTORAGESERVICE_H_ +#define MITKIDATASTORAGESERVICE_H_ + +#include + +#include +#include "mitkIDataStorageReference.h" + +#include + +#include + +namespace mitk +{ + +/** + * \ingroup org_mitk_core_services + */ +struct MITK_CORE_SERVICES_PLUGIN IDataStorageService : public berry::Service +{ + berryInterfaceMacro(IDataStorageService, berry); + + static const std::string ID; + + virtual IDataStorageReference::Pointer CreateDataStorage(const QString& label) = 0; + virtual std::vector GetDataStorageReferences() const = 0; + + virtual IDataStorageReference::Pointer GetDefaultDataStorage() const = 0; + + virtual IDataStorageReference::Pointer GetDataStorage() const = 0; + + virtual IDataStorageReference::Pointer GetActiveDataStorage() const = 0; + virtual void SetActiveDataStorage(IDataStorageReference::Pointer dataStorageRef) = 0; + + virtual void AddDataStorageReference(IDataStorageReference::Pointer dataStorageRef) = 0; + virtual bool RemoveDataStorageReference(IDataStorageReference::Pointer dataStorageRef) = 0; +}; + +} + +Q_DECLARE_INTERFACE(mitk::IDataStorageService, "org.mitk.service.IDataStorageService") + +#endif /*MITKIDATASTORAGESERVICE_H_*/ diff --git a/Modules/Bundles/org.mitk.diffusionimaging/CMakeLists.txt b/Plugins/org.mitk.diffusionimaging/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.diffusionimaging/CMakeLists.txt rename to Plugins/org.mitk.diffusionimaging/CMakeLists.txt diff --git a/Plugins/org.mitk.diffusionimaging/documentation/doxygen/modules.dox b/Plugins/org.mitk.diffusionimaging/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..e59da8066d --- /dev/null +++ b/Plugins/org.mitk.diffusionimaging/documentation/doxygen/modules.dox @@ -0,0 +1,19 @@ +/** + \defgroup org_mitk_diffusionimaging org.mitk.diffusionimaging + \ingroup MITKPlugins + + \brief This small plug-in is responsible for initializing the mitkDiffusionImaging module. + + It is started with an "eager" Bundle-ActivationPolicy, sucht that the plug-ins + activator is executed before any other (non-eager) plug-ins. + +*/ + +/** + \defgroup org_mitk_diffusionimaging_internal Internal + \ingroup org_mitk_diffusionimaging + + \brief This subcategory includes the internal classes of the org.mitk.diffusionimaging plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.diffusionimaging/files.cmake b/Plugins/org.mitk.diffusionimaging/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.diffusionimaging/files.cmake rename to Plugins/org.mitk.diffusionimaging/files.cmake diff --git a/Modules/Bundles/org.mitk.diffusionimaging/manifest_headers.cmake b/Plugins/org.mitk.diffusionimaging/manifest_headers.cmake similarity index 100% rename from Modules/Bundles/org.mitk.diffusionimaging/manifest_headers.cmake rename to Plugins/org.mitk.diffusionimaging/manifest_headers.cmake diff --git a/Modules/Bundles/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.cpp b/Plugins/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.cpp rename to Plugins/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.cpp diff --git a/Modules/Bundles/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.h b/Plugins/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.h rename to Plugins/org.mitk.diffusionimaging/src/internal/mitkDiffusionImagingActivator.h diff --git a/CoreUI/Bundles/org.mitk.gui.common/CMakeLists.txt b/Plugins/org.mitk.gui.common/CMakeLists.txt similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.common/CMakeLists.txt rename to Plugins/org.mitk.gui.common/CMakeLists.txt diff --git a/Plugins/org.mitk.gui.common/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.common/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..ddfd2bca7f --- /dev/null +++ b/Plugins/org.mitk.gui.common/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_common org.mitk.gui.common + \ingroup MITKPlugins + + \brief Provides common interfaces and utility classes for MITK Worbkench Views and Editors. + +*/ + +/** + \defgroup org_mitk_gui_common_internal Internal + \ingroup org_mitk_gui_common + + \brief This subcategory includes the internal classes of the org.mitk.gui.common plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.common/files.cmake b/Plugins/org.mitk.gui.common/files.cmake new file mode 100644 index 0000000000..966ce2635d --- /dev/null +++ b/Plugins/org.mitk.gui.common/files.cmake @@ -0,0 +1,31 @@ +SET(MOC_H_FILES + src/internal/org_mitk_gui_common_Activator.h +) + +SET(SRC_CPP_FILES + mitkDataNodeObject.cpp + mitkDataNodeSelection.cpp + mitkDataStorageEditorInput.cpp + mitkILifecycleAwarePart.h + mitkILinkedRenderWindowPart.h + mitkIRenderingManager.cpp + mitkIRenderWindowPart.cpp + mitkIRenderWindowPartListener.h + mitkIZombieViewPart.h + mitkWorkbenchUtil.cpp +) + +SET(INTERNAL_CPP_FILES + org_mitk_gui_common_Activator.cpp +) + + +#SET(CPP_FILES manifest.cpp) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/CoreUI/Bundles/org.mitk.gui.common/manifest_headers.cmake b/Plugins/org.mitk.gui.common/manifest_headers.cmake similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.common/manifest_headers.cmake rename to Plugins/org.mitk.gui.common/manifest_headers.cmake diff --git a/Plugins/org.mitk.gui.common/src/internal/org_mitk_gui_common_Activator.cpp b/Plugins/org.mitk.gui.common/src/internal/org_mitk_gui_common_Activator.cpp new file mode 100644 index 0000000000..fc603d63b6 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/internal/org_mitk_gui_common_Activator.cpp @@ -0,0 +1,47 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "org_mitk_gui_common_Activator.h" + +#include + +namespace mitk { + +ctkPluginContext* org_mitk_gui_common_Activator::m_Context = 0; + +void org_mitk_gui_common_Activator::start(ctkPluginContext* context) +{ + m_Context = context; +} + +void org_mitk_gui_common_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + m_Context = 0; +} + +ctkPluginContext *org_mitk_gui_common_Activator::GetContext() +{ + return m_Context; +} + +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_common, mitk::org_mitk_gui_common_Activator) + + diff --git a/Plugins/org.mitk.gui.common/src/internal/org_mitk_gui_common_Activator.h b/Plugins/org.mitk.gui.common/src/internal/org_mitk_gui_common_Activator.h new file mode 100644 index 0000000000..c5aa6faca9 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/internal/org_mitk_gui_common_Activator.h @@ -0,0 +1,49 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKPLUGINACTIVATOR_H +#define MITKPLUGINACTIVATOR_H + +#include + +namespace mitk { + +class org_mitk_gui_common_Activator : + public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + + static ctkPluginContext* GetContext(); + +private: + + static ctkPluginContext* m_Context; + +}; // org_mitk_gui_common_Activator + +typedef org_mitk_gui_common_Activator PluginActivator; + +} + +#endif // MITKPLUGINACTIVATOR_H diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeObject.cpp b/Plugins/org.mitk.gui.common/src/mitkDataNodeObject.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeObject.cpp rename to Plugins/org.mitk.gui.common/src/mitkDataNodeObject.cpp diff --git a/Plugins/org.mitk.gui.common/src/mitkDataNodeObject.h b/Plugins/org.mitk.gui.common/src/mitkDataNodeObject.h new file mode 100644 index 0000000000..53f31c2c10 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkDataNodeObject.h @@ -0,0 +1,58 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef MITKDATATREENODEOBJECT_H_ +#define MITKDATATREENODEOBJECT_H_ + +#include +#include + +#include + +#include + +namespace mitk +{ + +/** + * \ingroup org_mitk_gui_common + */ +class MITK_GUI_COMMON_PLUGIN DataNodeObject : public berry::Object +{ + +public: + + berryObjectMacro(mitk::DataNodeObject) + + DataNodeObject(); + DataNodeObject(DataNode::Pointer node); + + DataNode::Pointer GetDataNode() const; + + bool operator==(const berry::Object* obj) const; + +private: + + DataNode::Pointer m_Node; + + +}; + +} + +#endif /* MITKDATATREENODEOBJECT_H_ */ diff --git a/Plugins/org.mitk.gui.common/src/mitkDataNodeSelection.cpp b/Plugins/org.mitk.gui.common/src/mitkDataNodeSelection.cpp new file mode 100644 index 0000000000..afe696f36f --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkDataNodeSelection.cpp @@ -0,0 +1,91 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkDataNodeSelection.h" + +#include "mitkDataNodeObject.h" + +namespace mitk +{ + +DataNodeSelection::DataNodeSelection() : + m_Selection(new ContainerType()) +{ + +} + +DataNodeSelection::DataNodeSelection(DataNode::Pointer node) : + m_Selection(new ContainerType()) +{ + DataNodeObject::Pointer obj(new DataNodeObject(node)); + m_Selection->push_back(obj); +} + +DataNodeSelection::DataNodeSelection(const std::vector& nodes) : + m_Selection(new ContainerType()) +{ + for (std::vector::const_iterator i = nodes.begin(); i != nodes.end(); ++i) + { + DataNodeObject::Pointer obj(new DataNodeObject(*i)); + m_Selection->push_back(obj); + } +} + +berry::Object::Pointer DataNodeSelection::GetFirstElement() const +{ + if (m_Selection->empty()) + return berry::Object::Pointer(); + + return *(m_Selection->begin()); +} + +berry::IStructuredSelection::iterator DataNodeSelection::Begin() const +{ + return m_Selection->begin(); +} + +berry::IStructuredSelection::iterator DataNodeSelection::End() const +{ + return m_Selection->end(); +} + +int DataNodeSelection::Size() const +{ + return m_Selection->size(); +} + +berry::IStructuredSelection::ContainerType::Pointer DataNodeSelection::ToVector() const +{ + return m_Selection; +} + +bool DataNodeSelection::IsEmpty() const +{ + return m_Selection->empty(); +} + +bool DataNodeSelection::operator==(const berry::Object* obj) const +{ + if (const berry::IStructuredSelection* other = dynamic_cast(obj)) + { + return m_Selection == other->ToVector(); + } + + return false; +} + +} diff --git a/Plugins/org.mitk.gui.common/src/mitkDataNodeSelection.h b/Plugins/org.mitk.gui.common/src/mitkDataNodeSelection.h new file mode 100644 index 0000000000..ebd5a3c66b --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkDataNodeSelection.h @@ -0,0 +1,66 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef MITKDATATREENODESELECTION_H_ +#define MITKDATATREENODESELECTION_H_ + +#include +#include +#include + + +namespace mitk { + +/** + * \ingroup org_mitk_gui_common + */ +class MITK_GUI_COMMON_PLUGIN DataNodeSelection : public virtual berry::IStructuredSelection +{ + +public: + + berryObjectMacro(DataNodeSelection); + + DataNodeSelection(); + DataNodeSelection(DataNode::Pointer node); + DataNodeSelection(const std::vector& nodes); + + virtual Object::Pointer GetFirstElement() const; + virtual iterator Begin() const; + virtual iterator End() const; + + virtual int Size() const; + + virtual ContainerType::Pointer ToVector() const; + + /** + * @see berry::ISelection::IsEmpty() + */ + bool IsEmpty() const; + + bool operator==(const berry::Object* obj) const; + +protected: + + ContainerType::Pointer m_Selection; +}; + +} + + +#endif /* MITKDATATREENODESELECTION_H_ */ diff --git a/Plugins/org.mitk.gui.common/src/mitkDataStorageEditorInput.cpp b/Plugins/org.mitk.gui.common/src/mitkDataStorageEditorInput.cpp new file mode 100644 index 0000000000..8f1acbe999 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkDataStorageEditorInput.cpp @@ -0,0 +1,72 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkDataStorageEditorInput.h" + +#include +#include + +namespace mitk +{ + +DataStorageEditorInput::DataStorageEditorInput() +{ +} + +DataStorageEditorInput::DataStorageEditorInput(IDataStorageReference::Pointer ref) +{ + m_DataStorageRef = ref; +} + +bool DataStorageEditorInput::Exists() const +{ + return true; +} + +std::string DataStorageEditorInput::GetName() const +{ + return "DataStorage Scene"; +} + +std::string DataStorageEditorInput::GetToolTipText() const +{ + return ""; +} + +bool DataStorageEditorInput::operator==(const berry::Object* o) const +{ + if (const DataStorageEditorInput* input = dynamic_cast(o)) + return this->m_DataStorageRef == input->m_DataStorageRef; + + return false; +} + +IDataStorageReference::Pointer +DataStorageEditorInput::GetDataStorageReference() +{ + if (m_DataStorageRef.IsNull()) + { + berry::ServiceRegistry& serviceRegistry = berry::Platform::GetServiceRegistry(); + IDataStorageService::Pointer dataService = serviceRegistry.GetServiceById(IDataStorageService::ID); + if (!dataService) return IDataStorageReference::Pointer(0); + m_DataStorageRef = dataService->GetDefaultDataStorage(); + } + + return m_DataStorageRef; +} + +} diff --git a/Plugins/org.mitk.gui.common/src/mitkDataStorageEditorInput.h b/Plugins/org.mitk.gui.common/src/mitkDataStorageEditorInput.h new file mode 100644 index 0000000000..aa7f239073 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkDataStorageEditorInput.h @@ -0,0 +1,60 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef MITKDATASTORAGEEDITORINPUT_H_ +#define MITKDATASTORAGEEDITORINPUT_H_ + +#include +#include + +#include + +namespace mitk +{ + +/** + * \ingroup org_mitk_gui_common + * + * \brief An editor input based on a mitk::DataStorage. + * + * This editor input is usually used in render window editors inheriting from + * QmitkAbstractRenderEditor. + */ +class MITK_GUI_COMMON_PLUGIN DataStorageEditorInput : public berry::IEditorInput +{ +public: + berryObjectMacro(DataStorageEditorInput); + + DataStorageEditorInput(); + DataStorageEditorInput(IDataStorageReference::Pointer ref); + + bool Exists() const; + std::string GetName() const; + std::string GetToolTipText() const; + + IDataStorageReference::Pointer GetDataStorageReference(); + + bool operator==(const berry::Object*) const; + +private: + + IDataStorageReference::Pointer m_DataStorageRef; +}; + +} + +#endif /*MITKDATASTORAGEEDITORINPUT_H_*/ diff --git a/Plugins/org.mitk.gui.common/src/mitkILifecycleAwarePart.h b/Plugins/org.mitk.gui.common/src/mitkILifecycleAwarePart.h new file mode 100644 index 0000000000..e53ded00d0 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkILifecycleAwarePart.h @@ -0,0 +1,59 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKILIFECYCLEAWAREPART_H +#define MITKILIFECYCLEAWAREPART_H + + +namespace mitk { + +/** + * \ingroup org_mitk_gui_common + * + * \brief Interface for a MITK Workbench part which wants to be notified about lifecycle changes. + * + * This interface is intended to be implemented by subclasses of berry::IWorkbenchPart. MITK Workbench parts + * implementing this interface will be notified about their lifecycle changes. The same effect could + * be achieved by registering a custom berry::IPartListener. + * + * \note There are no "Closed()" or "Opened()" methods. These correspond to the constructor and + * desctructor of the Workbench part class. + * + * \see berry::IPartListener + * \see mitk::IZombieViewPart + */ +struct ILifecycleAwarePart +{ + virtual ~ILifecycleAwarePart() {} + + /** \see berry::IPartListener::PartActivated */ + virtual void Activated() = 0; + + /** \see berry::IPartListener::PartDeactivated */ + virtual void Deactivated() = 0; + + /** \see berry::IPartListener::PartVisible */ + virtual void Visible() = 0; + + /** \see berry::IPartListener::PartHidden */ + virtual void Hidden() = 0; +}; + +} + +#endif // MITKILIFECYCLEAWAREPART_H diff --git a/Plugins/org.mitk.gui.common/src/mitkILinkedRenderWindowPart.h b/Plugins/org.mitk.gui.common/src/mitkILinkedRenderWindowPart.h new file mode 100644 index 0000000000..2cc427f485 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkILinkedRenderWindowPart.h @@ -0,0 +1,91 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#ifndef MITKILINKEDRENDERWINDOWPART_H +#define MITKILINKEDRENDERWINDOWPART_H + +#include "mitkIRenderWindowPart.h" + +namespace mitk { + +class SlicesRotator; +class SlicesSwiveller; + +/** + * \ingroup org_mitk_gui_common + * + * \brief Extends the IRenderWindowPart interface with methods for controlling linked + * render windows. + * + * This inteface should be implemented by subclasses of berry::IWorkbenchPart if they + * provided several linked QmitkRenderWindow instances. + */ +struct ILinkedRenderWindowPart : public virtual IRenderWindowPart { + + /** + * Get the mitk::SlicesRotator. + * + * \return A mitk::SlicesRotator instance if rotating slices is supported; + * NULL otherwise. + */ + virtual mitk::SlicesRotator* GetSlicesRotator() const = 0; + + /** + * Get the mitk::SlicesSwiveller. + * + * \return A mitk::SlicesSwiveller instance if swivelling slices is supported; + * NULL otherwise. + */ + virtual mitk::SlicesSwiveller* GetSlicesSwiveller() const = 0; + + /** + * Enable or disable the slicing planes linking the QmitkRenderWindow instances. + * + * \param enable true if the slicing planes should be enabled; + * false otherwise. + */ + virtual void EnableSlicingPlanes(bool enable) = 0; + + /** + * Get the enabled status of the slicing planes. + * + * \return true if the slicing planes are enabled; false + * otherwise. + */ + virtual bool IsSlicingPlanesEnabled() const = 0; + + /** + * Enable or disalbe linked navigation. + * + * \param enable If true, setting the selected position in one QmitkRenderWindow + * affects the positions in the linked windows. If false, linked navigation + * is disabled. + */ + virtual void EnableLinkedNavigation(bool enable) = 0; + + /** + * Get the enabled status of linked navigation. + * + * \return true if linked navigation is enabled; false + * otherwise. + */ + virtual bool IsLinkedNavigationEnabled() const = 0; +}; + +} + +#endif // MITKILINKEDRENDERWINDOWPART_H diff --git a/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPart.cpp b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPart.cpp new file mode 100644 index 0000000000..9e9677284c --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPart.cpp @@ -0,0 +1,27 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "mitkIRenderWindowPart.h" + +namespace mitk { + +const QString IRenderWindowPart::DECORATION_BORDER = "border"; +const QString IRenderWindowPart::DECORATION_LOGO = "logo"; +const QString IRenderWindowPart::DECORATION_MENU = "menu"; +const QString IRenderWindowPart::DECORATION_BACKGROUND = "background"; + +} diff --git a/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPart.h b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPart.h new file mode 100644 index 0000000000..cee4fc9374 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPart.h @@ -0,0 +1,191 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#ifndef MITKIRENDERWINDOWPART_H +#define MITKIRENDERWINDOWPART_H + +#include +#include +#include +#include + +#include +#include + +#include + +class QmitkRenderWindow; + +namespace mitk { + +struct IRenderingManager; +class SliceNavigationController; + +/** + * \ingroup org_mitk_gui_common + * + * \brief Interface for a MITK Workbench Part providing a render window. + * + * This interface allows generic access to Workbench parts which provide some + * kind of render window. The interface is intended to be implemented by + * subclasses of berry::IWorkbenchPart. Usually, the interface is implemented + * by a Workbench editor. + * + * A IRenderWindowPart provides zero or more QmitkRenderWindow instances which can + * be controlled via this interface. QmitkRenderWindow instances have an associated + * \e id, which is implementation specific. However, implementations should consider + * to use one of the following ids for certain QmitkRenderWindow instances to maximize + * reusability (they are free to map multiple ids to one QmitkRenderWindow internally): + *
    + *
  • transversal
  • + *
  • sagittal
  • + *
  • coronal
  • + *
  • 3d
  • + *
+ * + * \see ILinkedRenderWindowPart + * \see IRenderWindowPartListener + * \see QmitkAbstractRenderEditor + */ +struct MITK_GUI_COMMON_PLUGIN IRenderWindowPart { + + static const QString DECORATION_BORDER; // = "border" + static const QString DECORATION_LOGO; // = "logo" + static const QString DECORATION_MENU; // = "menu" + static const QString DECORATION_BACKGROUND; // = "background; + + virtual ~IRenderWindowPart() {} + + /** + * Get the currently active (focused) render window. + * Focus handling is implementation specific. + * + * \return The active QmitkRenderWindow instance; NULL + * if no render window is active. + */ + virtual QmitkRenderWindow* GetActiveRenderWindow() const = 0; + + /** + * Get all render windows with their ids. + * + * \return A hash map mapping the render window id to the QmitkRenderWindow instance. + */ + virtual QHash GetRenderWindows() const = 0; + + /** + * Get a render window with a specific id. + * + * \param id The render window id. + * \return The QmitkRenderWindow instance for id + */ + virtual QmitkRenderWindow* GetRenderWindow(const QString& id) const = 0; + + /** + * Get the rendering manager used by this render window part. + * + * \return The current IRenderingManager instance or NULL + * if no rendering manager is used. + */ + virtual mitk::IRenderingManager* GetRenderingManager() const = 0; + + /** + * Request an update of all render windows. + * + * \param requestType Specifies the type of render windows for which an update + * will be requested. + */ + virtual void RequestUpdate(mitk::RenderingManager::RequestType requestType = mitk::RenderingManager::REQUEST_UPDATE_ALL) = 0; + + /** + * Force an immediate update of all render windows. + * + * \param requestType Specifies the type of render windows for which an immediate update + * will be requested. + */ + virtual void ForceImmediateUpdate(mitk::RenderingManager::RequestType requestType = mitk::RenderingManager::REQUEST_UPDATE_ALL) = 0; + + /** + * Get the SliceNavigationController for controlling time positions. + * + * \return A SliceNavigationController if the render window supports this + * operation; otherwise returns NULL. + */ + virtual mitk::SliceNavigationController* GetTimeNavigationController() const = 0; + + /** + * Get the selected position in the render window with id id + * or in the active render window if id is NULL. + * + * \param id The render window id. + * \return The currently selected position in world coordinates. + */ + virtual mitk::Point3D GetSelectedPosition(const QString& id = QString()) const = 0; + + /** + * Set the selected position in the render window with id id + * or in the active render window if id is NULL. + * + * \param pos The position in world coordinates which should be selected. + * \param id The render window id in which the selection should take place. + */ + virtual void SetSelectedPosition(const mitk::Point3D& pos, const QString& id = QString()) = 0; + + /** + * Enable \e decorations like colored borders, menu widgets, logos, text annotations, etc. + * + * Decorations are implementation specific. A set of standardized decoration names is listed + * in GetDecorations(). + * + * \param enable If true enable the decorations specified in decorations, + * otherwise disable them. + * \param decorations A list of decoration names. If empty, all supported decorations are affected. + * + * \see GetDecorations() + */ + virtual void EnableDecorations(bool enable, const QStringList& decorations = QStringList()) = 0; + + /** + * Return if a specific decoration is enabled. + * + * \return true if the decoration is enabled, false if it is disabled + * or unknown. + * + * \see GetDecorations() + */ + virtual bool IsDecorationEnabled(const QString& decoration) const = 0; + + /** + * Get a list of supported decorations. + * + * The following decoration names are standardized and should not be used for other decoration types: + *
    + *
  • \e DECORATION_BORDER Any border decorations like colored rectangles, etc. + *
  • \e DECORATION_MENU Menus associated with render windows + *
  • \e DECORATION_BACKGROUND All kinds of backgrounds (patterns, gradients, etc.) except for solid colored backgrounds + *
  • \e DECORATION_LOGO Any kind of logo overlayed on the rendered scene + *
+ * + * \return A list of supported decoration names. + */ + virtual QStringList GetDecorations() const = 0; +}; + +} + +Q_DECLARE_INTERFACE(mitk::IRenderWindowPart, "org.mitk.ui.IRenderWindowPart") + +#endif // MITKIRENDERWINDOWPART_H diff --git a/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPartListener.h b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPartListener.h new file mode 100644 index 0000000000..b7abf8b0a2 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPartListener.h @@ -0,0 +1,59 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKIRENDERWINDOWPARTLISTENER_H +#define MITKIRENDERWINDOWPARTLISTENER_H + +namespace mitk { + +struct IRenderWindowPart; + +/** + * \ingroup org_mitk_gui_common + * + * \brief Interface for berry::IViewPart implementations to be notified about mitk::IRenderWindowPart lifecycle changes. + * + * This interface is intended to be implemented by subclasses of berry::IWorkbenchPart. If implemented, + * the interface methods are called automatically if a Workbench part which implementes mitk::IRenderWindowPart + * is activated or deactivated. + * + * The notion of activated and deactivated is slightly different from the usual Workbench part lifecycle. + */ +struct IRenderWindowPartListener +{ + virtual ~IRenderWindowPartListener() {} + + /** + * Called when a IRenderWindowPart is activated or if it becomes visible and no + * other IRenderWindowPart was activated before. + * + * \param renderWindowPart The newly activated IRenderWindowPart. + */ + virtual void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) = 0; + + /** + * Called when a IRenderWindowPart becomes invisible and if it was active before. + * + * \param renderWindowPart The deactivated IRenderWindowPart. + */ + virtual void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) = 0; +}; + +} + +#endif // MITKIRENDERWINDOWPARTLISTENER_H diff --git a/Plugins/org.mitk.gui.common/src/mitkIRenderingManager.cpp b/Plugins/org.mitk.gui.common/src/mitkIRenderingManager.cpp new file mode 100644 index 0000000000..987637c780 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkIRenderingManager.cpp @@ -0,0 +1,190 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkIRenderingManager.h" + +namespace mitk { + +struct RenderingManagerInterface : public IRenderingManager +{ + RenderingManagerInterface(RenderingManager::Pointer manager) + : m_RM(manager) + {} + + QList GetAllRegisteredVtkRenderWindows() const + { + RenderingManager::RenderWindowVector vec(m_RM->GetAllRegisteredRenderWindows()); + QList result; + for (RenderingManager::RenderWindowVector::iterator i = vec.begin(); + i != vec.end(); ++i) + { + result.append(*i); + } + return result; + } + + void RequestUpdate( vtkRenderWindow *renderWindow ) + { + m_RM->RequestUpdate(renderWindow); + } + + void ForceImmediateUpdate( vtkRenderWindow *renderWindow ) + { + m_RM->ForceImmediateUpdate(renderWindow); + } + + void RequestUpdateAll( RenderingManager::RequestType type ) + { + m_RM->RequestUpdateAll(type); + } + + void ForceImmediateUpdateAll( RenderingManager::RequestType type ) + { + m_RM->ForceImmediateUpdateAll(type); + } + + bool InitializeViews( const Geometry3D *geometry, + RenderingManager::RequestType type = RenderingManager::REQUEST_UPDATE_ALL, + bool preserveRoughOrientationInWorldSpace = false ) + { + return m_RM->InitializeViews( geometry, type, preserveRoughOrientationInWorldSpace); + } + + bool InitializeViews( RenderingManager::RequestType type ) + { + return m_RM->InitializeViews(type); + } + + bool InitializeView( vtkRenderWindow *renderWindow, const Geometry3D *geometry, + bool initializeGlobalTimeSNC = false) + { + return m_RM->InitializeView(renderWindow, geometry, initializeGlobalTimeSNC); + } + + bool InitializeView( vtkRenderWindow *renderWindow ) + { + return m_RM->InitializeView(renderWindow); + } + + const SliceNavigationController *GetTimeNavigationController() const + { + return m_RM->GetTimeNavigationController(); + } + + SliceNavigationController *GetTimeNavigationController() + { + return m_RM->GetTimeNavigationController(); + } + + bool IsRendering() const + { + return m_RM->IsRendering(); + } + + void AbortRendering() + { + m_RM->AbortRendering(); + } + + void SetLODIncreaseBlocked(bool blocked) + { + m_RM->SetLODIncreaseBlocked(blocked); + } + + bool GetLODIncreaseBlocked() const + { + return m_RM->GetLODIncreaseBlocked(); + } + + void SetLODAbortMechanismEnabled(bool abort) + { + m_RM->SetLODAbortMechanismEnabled(abort); + } + + bool GetLODAbortMechanismEnabled() const + { + return m_RM->GetLODAbortMechanismEnabled(); + } + + void SetDepthPeelingEnabled(bool enabled) + { + m_RM->SetDepthPeelingEnabled(enabled); + } + + void SetMaxNumberOfPeels(int maxNumber) + { + m_RM->SetMaxNumberOfPeels(maxNumber); + } + + int GetNextLOD( BaseRenderer* renderer ) const + { + return m_RM->GetNextLOD(renderer); + } + + void SetMaximumLOD( unsigned int max ) + { + m_RM->SetMaximumLOD(max); + } + + void SetShading( bool state, unsigned int lod ) + { + m_RM->SetShading(state, lod); + } + + bool GetShading( unsigned int lod ) + { + return m_RM->GetShading(lod); + } + + void SetClippingPlaneStatus( bool status ) + { + m_RM->SetClippingPlaneStatus(status); + } + + bool GetClippingPlaneStatus() + { + return m_RM->GetClippingPlaneStatus(); + } + + void SetShadingValues( float ambient, float diffuse, + float specular, float specpower ) + { + m_RM->SetShadingValues(ambient, diffuse, specular, specpower); + } + + QList GetShadingValues() const + { + RenderingManager::FloatVector vec(m_RM->GetShadingValues()); + QList result; + for (RenderingManager::FloatVector::iterator i = vec.begin(); + i != vec.end(); ++i) + { + result.push_back(*i); + } + return result; + } + + const RenderingManager::Pointer m_RM; + +}; + +IRenderingManager* MakeRenderingManagerInterface(RenderingManager::Pointer manager) +{ + return new RenderingManagerInterface(manager); +} + +} diff --git a/Plugins/org.mitk.gui.common/src/mitkIRenderingManager.h b/Plugins/org.mitk.gui.common/src/mitkIRenderingManager.h new file mode 100644 index 0000000000..ef9ab0973b --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkIRenderingManager.h @@ -0,0 +1,159 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKIRENDERINGMANAGER_H +#define MITKIRENDERINGMANAGER_H + +#include + +#include + +#include +#include + +namespace mitk { + +/** + * \ingroup org_mitk_gui_common + * + * \brief An interface for accessing a mitk::RenderingManager instance. + * + * This interface acts as a wrapper to a mitk::RenderingManager instance, hiding some + * methods from the user. + * + * \see MakeRenderingManagerInterface + */ +struct IRenderingManager { + + virtual ~IRenderingManager() {} + + /** Get a list of all registered RenderWindows */ + virtual QList GetAllRegisteredVtkRenderWindows() const = 0; + + /** + * Requests an update for the specified RenderWindow, to be executed as + * soon as the main loop is ready for rendering. + */ + virtual void RequestUpdate( vtkRenderWindow *renderWindow ) = 0; + + /** Immediately executes an update of the specified RenderWindow. */ + virtual void ForceImmediateUpdate( vtkRenderWindow *renderWindow ) = 0; + + /** + * Requests all currently registered RenderWindows to be updated. + * If only 2D or 3D windows should be updated, this can be specified + * via the parameter requestType. + */ + virtual void RequestUpdateAll( RenderingManager::RequestType type = RenderingManager::REQUEST_UPDATE_ALL ) = 0; + + /** + * Immediately executes an update of all registered RenderWindows. + * If only 2D or 3D windows should be updated, this can be specified + * via the parameter requestType. + */ + virtual void ForceImmediateUpdateAll( RenderingManager::RequestType type = RenderingManager::REQUEST_UPDATE_ALL ) = 0; + + /** Initializes the windows specified by requestType to the given geometry. */ + virtual bool InitializeViews( const Geometry3D *geometry, + RenderingManager::RequestType type = RenderingManager::REQUEST_UPDATE_ALL, + bool preserveRoughOrientationInWorldSpace = false ) = 0; + + /** + * Initializes the windows to the default viewing direction + * (geomtry information is NOT changed). + */ + virtual bool InitializeViews( RenderingManager::RequestType type = RenderingManager::REQUEST_UPDATE_ALL ) = 0; + + /** + * Initializes the specified window to the given geometry. Set + * "initializeGlobalTimeSNC" to true in order to use this geometry as + * global TimeSlicedGeometry. + */ + virtual bool InitializeView( vtkRenderWindow *renderWindow, const Geometry3D *geometry, + bool initializeGlobalTimeSNC = false) = 0; + + /** + * Initializes the specified window to the default viewing direction + * (geomtry information is NOT changed). + */ + virtual bool InitializeView( vtkRenderWindow *renderWindow ) = 0; + + /** Gets the SliceNavigationController responsible for time-slicing. */ + virtual const SliceNavigationController *GetTimeNavigationController() const = 0; + + /** Gets the SliceNavigationController responsible for time-slicing. */ + virtual SliceNavigationController *GetTimeNavigationController() = 0; + + virtual bool IsRendering() const = 0; + + virtual void AbortRendering() = 0; + + /** En-/Disable LOD increase globally. */ + virtual void SetLODIncreaseBlocked(bool blocked) = 0; + + /** Get LOD blocked status. */ + virtual bool GetLODIncreaseBlocked() const = 0; + + /** En-/Disable LOD abort mechanism. */ + virtual void SetLODAbortMechanismEnabled(bool abort) = 0; + + /** Get LOD abort mechanism status. */ + virtual bool GetLODAbortMechanismEnabled() const = 0; + + /** En-/Disable depth peeling for all renderers */ + virtual void SetDepthPeelingEnabled(bool enabled) = 0; + + /** Set maximum number of peels for all renderers */ + virtual void SetMaxNumberOfPeels(int maxNumber) = 0; + + virtual int GetNextLOD( BaseRenderer* renderer ) const = 0; + + /** Set current LOD (NULL means all renderers)*/ + virtual void SetMaximumLOD( unsigned int max ) = 0; + + virtual void SetShading( bool state, unsigned int lod ) = 0; + virtual bool GetShading( unsigned int lod ) = 0; + + virtual void SetClippingPlaneStatus( bool status ) = 0; + virtual bool GetClippingPlaneStatus() = 0; + + virtual void SetShadingValues( float ambient, float diffuse, + float specular, float specpower ) = 0; + + virtual QList GetShadingValues() const = 0; + +}; + +} + +Q_DECLARE_INTERFACE(mitk::IRenderingManager, "org.mitk.ui.IRenderingManager") + +namespace mitk { + +/** + * Create a IRenderManager interface for a given RenderingManager. Ownership of the + * returned pointer is transferred to the caller of this function. + * + * \param manager The RenderingManager instance for which to create a interface. + * \return A pointer to the interface object. The caller is responsible for deleting the pointer. + */ +MITK_GUI_COMMON_PLUGIN IRenderingManager* MakeRenderingManagerInterface(RenderingManager::Pointer manager); + +} + +#endif // MITKIRENDERINGMANAGER_H diff --git a/Plugins/org.mitk.gui.common/src/mitkIZombieViewPart.h b/Plugins/org.mitk.gui.common/src/mitkIZombieViewPart.h new file mode 100644 index 0000000000..0eedfbf4aa --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkIZombieViewPart.h @@ -0,0 +1,60 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKIZOMBIEVIEWPART_H +#define MITKIZOMBIEVIEWPART_H + +#include "mitkILifecycleAwarePart.h" + +namespace mitk { + +/** + * \ingroup org_mitk_gui_common + * + * \brief Interface for MITK Workbench Views with special \e Zombie state handling. + * + * Some MITK Views need to change the application state in a way which should not be affected + * by this View's activated/deactivated state. Examples are setting special interactors or removing + * the crosshair from a QmitkRenderWindow. Such MITK Views are called \emph{Zombie Views} because + * they partially outlive their own deactivation. Zombie Views are usually mutually exclusive. + * + * To ease the handling of Zombie Views, this interface acts as a marker to declare the implementing + * class being a Zombie View, meaning that it will change some application state when it is activated + * but will not reset it when deactivated. + * + * If a Zombie View is activated, the previously active Zombie View is notified by calling its + * ActivatedZombieView() method. It should then reset the application state. + * + * \see ILifecycleAwarePart + */ +struct IZombieViewPart : public virtual ILifecycleAwarePart +{ + + /** + * Called when another Zombie View was activated. This usually means that this part + * should clean up its Zombie state. + * + * \param zombieView The newly activate Zombie View. + */ + virtual void ActivatedZombieView(berry::IWorkbenchPartReference::Pointer zombieView) = 0; + +}; + +} + +#endif // MITKIZOMBIEVIEWPART_H diff --git a/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.cpp b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.cpp new file mode 100644 index 0000000000..25acbd33ba --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.cpp @@ -0,0 +1,255 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "mitkWorkbenchUtil.h" + +#include +#include +#include + +#include +#include "mitkIDataStorageService.h" +#include "mitkDataStorageEditorInput.h" +#include "mitkRenderingManager.h" +#include "mitkIRenderWindowPart.h" +#include "mitkIRenderingManager.h" + +#include "mitkProperties.h" +#include "mitkNodePredicateData.h" +#include "mitkNodePredicateNot.h" +#include "mitkNodePredicateProperty.h" +#include "mitkIOUtil.h" +#include "mitkWorkbenchUtil.h" + +#include + +#include +#include + +#include "internal/org_mitk_gui_common_Activator.h" + +namespace mitk { + +struct WorkbenchUtilPrivate { + + /** + * Get the editor descriptor for a given name using the editorDescriptor + * passed in as a default as a starting point. + * + * @param name + * The name of the element to open. + * @param editorReg + * The editor registry to do the lookups from. + * @param defaultDescriptor + * IEditorDescriptor or null + * @return IEditorDescriptor + * @throws PartInitException + * if no valid editor can be found + */ + static berry::IEditorDescriptor::Pointer GetEditorDescriptor(const QString& name, + berry::IEditorRegistry* editorReg, + berry::IEditorDescriptor::Pointer defaultDescriptor) + { + + if (defaultDescriptor.IsNotNull()) + { + return defaultDescriptor; + } + + berry::IEditorDescriptor::Pointer editorDesc = defaultDescriptor; + + // next check the OS for in-place editor (OLE on Win32) + if (editorReg->IsSystemInPlaceEditorAvailable(name.toStdString())) + { + editorDesc = editorReg->FindEditor(berry::IEditorRegistry::SYSTEM_INPLACE_EDITOR_ID); + } + + // next check with the OS for an external editor + if (editorDesc.IsNull() && editorReg->IsSystemExternalEditorAvailable(name.toStdString())) + { + editorDesc = editorReg->FindEditor(berry::IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID); + } + + // if no valid editor found, bail out + if (editorDesc.IsNull()) + { + throw berry::PartInitException("No editor found"); + } + + return editorDesc; + } +}; + +void WorkbenchUtil::LoadFiles(const QStringList &fileNames, berry::IWorkbenchWindow::Pointer window) +{ + if (fileNames.empty()) + return; + + mitk::IDataStorageReference::Pointer dataStorageRef; + + { + ctkPluginContext* context = mitk::PluginActivator::GetContext(); + mitk::IDataStorageService* dss = 0; + ctkServiceReference dsRef = context->getServiceReference(); + if (dsRef) + { + dss = context->getService(dsRef); + } + + if (!dss) + { + QString msg = "IDataStorageService service not available. Unable to open files."; + MITK_WARN << msg.toStdString(); + QMessageBox::warning(QApplication::activeWindow(), "Unable to open files", msg); + return; + } + + // Get the active data storage (or the default one, if none is active) + dataStorageRef = dss->GetDataStorage(); + context->ungetService(dsRef); + } + + mitk::DataStorage::Pointer dataStorage = dataStorageRef->GetDataStorage(); + + // Do the actual work of loading the data into the data storage + std::vector fileNames2; + ctk::qListToSTLVector(fileNames, fileNames2); + const bool dsmodified = mitk::IOUtil::LoadFiles(fileNames2, *dataStorage); + + // Check if there is an open perspective. If not, open the default perspective. + if (window->GetActivePage().IsNull()) + { + std::string defaultPerspId = window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective(); + window->GetWorkbench()->ShowPerspective(defaultPerspId, window); + } + + try + { + // Activate the editor using the same data storage or open the default editor + mitk::DataStorageEditorInput::Pointer input(new mitk::DataStorageEditorInput(dataStorageRef)); + berry::IEditorPart::Pointer editor = mitk::WorkbenchUtil::OpenEditor(window->GetActivePage(), input, true); + mitk::IRenderWindowPart* renderEditor = dynamic_cast(editor.GetPointer()); + mitk::IRenderingManager* renderingManager = renderEditor == 0 ? 0 : renderEditor->GetRenderingManager(); + + if(dsmodified && renderingManager) + { + // 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 = dataStorage->GetSubset(pred); + // calculate bounding geometry of these nodes + mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); + // initialize the views to the bounding geometry + renderingManager->InitializeViews(bounds); + } + } + catch (const berry::PartInitException& e) + { + QString msg = "An error occurred when displaying the file(s): %1"; + QMessageBox::warning(QApplication::activeWindow(), "Error displaying file", + msg.arg(QString::fromStdString(e.message()))); + } +} + +berry::IEditorPart::Pointer WorkbenchUtil::OpenEditor(berry::IWorkbenchPage::Pointer page, + berry::IEditorInput::Pointer input, + const QString &editorId, bool activate) +{ + // sanity checks + if (page.IsNull()) + { + throw std::invalid_argument("page argument must not be NULL"); + } + + // open the editor on the input + return page->OpenEditor(input, editorId.toStdString(), activate); +} + +berry::IEditorPart::Pointer WorkbenchUtil::OpenEditor(berry::IWorkbenchPage::Pointer page, + mitk::DataStorageEditorInput::Pointer input, + bool activate, + bool determineContentType) +{ + // sanity checks + if (page.IsNull()) + { + throw std::invalid_argument("page argument must not be NULL"); + } + + // open the editor on the data storage + QString name = QString::fromStdString(input->GetName()) + ".mitk"; + berry::IEditorDescriptor::Pointer editorDesc = + WorkbenchUtilPrivate::GetEditorDescriptor(name, + berry::PlatformUI::GetWorkbench()->GetEditorRegistry(), + GetDefaultEditor(name, determineContentType)); + return page->OpenEditor(input, editorDesc->GetId(), activate); +} + +berry::IEditorDescriptor::Pointer WorkbenchUtil::GetEditorDescriptor( + const QString& name, bool /*inferContentType*/) +{ + if (name.isEmpty()) + { + throw std::invalid_argument("name argument must not be empty"); + } + + // no used for now + //IContentType contentType = inferContentType ? Platform + // .getContentTypeManager().findContentTypeFor(name) : null; + + berry::IEditorRegistry* editorReg = berry::PlatformUI::GetWorkbench()->GetEditorRegistry(); + + return WorkbenchUtilPrivate::GetEditorDescriptor(name, editorReg, + editorReg->GetDefaultEditor(name.toStdString() /*, contentType*/)); +} + +berry::IEditorDescriptor::Pointer WorkbenchUtil::GetDefaultEditor(const QString& name, + bool /*determineContentType*/) +{ + // Try file specific editor. + berry::IEditorRegistry* editorReg = berry::PlatformUI::GetWorkbench()->GetEditorRegistry(); + try + { + QString editorID; // = file.getPersistentProperty(EDITOR_KEY); + if (!editorID.isEmpty()) + { + berry::IEditorDescriptor::Pointer desc = editorReg->FindEditor(editorID.toStdString()); + if (desc.IsNotNull()) + { + return desc; + } + } + } + catch (const berry::CoreException& e) + { + // do nothing + } + +// IContentType contentType = null; +// if (determineContentType) +// { +// contentType = getContentType(file); +// } + + // Try lookup with filename + return editorReg->GetDefaultEditor(name.toStdString()); //, contentType); +} + +} // namespace mitk diff --git a/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.h b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.h new file mode 100644 index 0000000000..f66e3f5ad0 --- /dev/null +++ b/Plugins/org.mitk.gui.common/src/mitkWorkbenchUtil.h @@ -0,0 +1,175 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKWORKBENCHUTIL_H +#define MITKWORKBENCHUTIL_H + +#include + +#include "mitkDataStorageEditorInput.h" + +#include +#include + +namespace mitk { + +/** + * @ingroup org_mitk_gui_common + * + * @brief Utility class for loading data and opening editors in a MITK Workbench. + * + * @note Infering the content type is not yet supported (ignore the comments about it + * in the method documentation). + */ +struct MITK_GUI_COMMON_PLUGIN WorkbenchUtil +{ + + /** + * Loads the set of given files into the active data storage of the given Workbench window. + * + * If the window already has an editor open on the active datastorage then that editor + * is activated; otherwise the default editor for the "mitk" extension is activated. + * + * @param fileNames + * A list of file names with absolute path. + * @param wnd + * The Workbench window in which the data will be loaded. + * + * @see mitk::IDataNodeReader + */ + static void LoadFiles(const QStringList& fileNames, berry::IWorkbenchWindow::Pointer wnd); + + /** + * Opens an editor on the given object. + *

+ * If the page already has an editor open on the target object then that + * editor is brought to front; otherwise, a new editor is opened. If + * activate == true the editor will be activated. + *

+ * + * @param page + * the page in which the editor will be opened + * @param input + * the editor input + * @param editorId + * the id of the editor extension to use + * @param activate + * if true the editor will be activated + * @return an open editor or null if an external editor was + * opened + * @exception PartInitException + * if the editor could not be initialized + * @see IWorkbenchPage#OpenEditor(IEditorInput::Pointer, std::string, bool) + */ + static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page, + berry::IEditorInput::Pointer input, + const QString& editorId, bool activate = false); + + /** + * Opens an editor on the given file resource. This method will attempt to + * resolve the editor based on content-type bindings as well as traditional + * name/extension bindings if determineContentType is + * true. + *

+ * If the page already has an editor open on the target object then that + * editor is brought to front; otherwise, a new editor is opened. If + * activate == true the editor will be activated. + *

+ * + * @param page + * the page in which the editor will be opened + * @param input + * the editor input + * @param activate + * if true the editor will be activated + * @param determineContentType + * attempt to resolve the content type for this file + * @return an open editor or null if an external editor was + * opened + * @exception PartInitException + * if the editor could not be initialized + * @see IWorkbenchPage#OpenEditor(IEditorInput::Pointer,std::string,bool) + */ + static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page, + mitk::DataStorageEditorInput::Pointer input, + bool activate = false, + bool determineContentType = false); + + /** + * Returns an editor descriptor appropriate for opening a file resource with + * the given name. + *

+ * The editor descriptor is determined using a multi-step process. This + * method will attempt to infer the content type of the file if + * inferContentType is true. + *

+ *
    + *
  1. The file is consulted for a persistent property named + * IDE.EDITOR_KEY containing the preferred editor id to be + * used.
  2. + *
  3. The workbench editor registry is consulted to determine if an editor + * extension has been registered for the file type. If so, an instance of + * the editor extension is opened on the file. See + * IEditorRegistry#GetDefaultEditor(std::string).
  4. + *
  5. The operating system is consulted to determine if an in-place + * component editor is available (e.g. OLE editor on Win32 platforms).
  6. + *
  7. The operating system is consulted to determine if an external editor + * is available.
  8. + *
+ *

+ * + * @param name + * the file name + * @param inferContentType + * attempt to infer the content type from the file name if this + * is true + * @return an editor descriptor, appropriate for opening the file + * @throws PartInitException + * if no editor can be found + */ + static berry::IEditorDescriptor::Pointer GetEditorDescriptor( + const QString& name, bool inferContentType = true); + + /** + * Returns the default editor for a given file. This method will attempt to + * resolve the editor based on content-type bindings as well as traditional + * name/extension bindings if determineContentType is + * true. + *

+ * A default editor id may be registered for a specific file using + * setDefaultEditor. If the given file has a registered + * default editor id the default editor will derived from it. If not, the + * default editor is determined by taking the file name for the file and + * obtaining the default editor for that name. + *

+ * + * @param file + * the file + * @param determineContentType + * determine the content type for the given file + * @return the descriptor of the default editor, or null if + * not found + */ + static berry::IEditorDescriptor::Pointer GetDefaultEditor(const QString& file, + bool determineContentType); + +}; + +} + +#endif // MITKWORKBENCHUTIL_H diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/CMakeLists.txt b/Plugins/org.mitk.gui.qt.application/CMakeLists.txt similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.application/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.application/CMakeLists.txt diff --git a/Plugins/org.mitk.gui.qt.application/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.application/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..77592d99d4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_application org.mitk.gui.qt.application + \ingroup MITKPlugins + + \brief Provides utility classes for MITK application developers. + +*/ + +/** + \defgroup org_mitk_gui_qt_application_internal Internal + \ingroup org_mitk_gui_qt_application + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.application plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.application/files.cmake b/Plugins/org.mitk.gui.qt.application/files.cmake new file mode 100644 index 0000000000..52b966668b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/files.cmake @@ -0,0 +1,47 @@ +SET(SRC_CPP_FILES + QmitkCloseProjectAction.cpp + QmitkDefaultDropTargetListener.cpp + QmitkFileExitAction.cpp + QmitkFileOpenAction.cpp + QmitkPreferencesDialog.cpp + QmitkStatusBar.cpp +) + +SET(INTERNAL_CPP_FILES + org_mitk_gui_qt_application_Activator.cpp + QmitkEditorsPreferencePage.cpp + QmitkGeneralPreferencePage.cpp +) + +SET(MOC_H_FILES + src/QmitkCloseProjectAction.h + src/QmitkFileExitAction.h + src/QmitkFileOpenAction.h + src/QmitkPreferencesDialog.h + + src/internal/org_mitk_gui_qt_application_Activator.h + src/internal/QmitkEditorsPreferencePage.h + src/internal/QmitkGeneralPreferencePage.h +) + +SET(UI_FILES + src/QmitkPreferencesDialog.ui +) + +SET(CACHED_RESOURCE_FILES + plugin.xml +) + +SET(QRC_FILES + resources/resources.qrc +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.application/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.application/manifest_headers.cmake new file mode 100644 index 0000000000..679f7d98a4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "MITK Qt CoreApp application") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.blueberry.ui.qt org.mitk.gui.common) + diff --git a/Plugins/org.mitk.gui.qt.application/plugin.xml b/Plugins/org.mitk.gui.qt.application/plugin.xml new file mode 100644 index 0000000000..eb6511c500 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/plugin.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml b/Plugins/org.mitk.gui.qt.application/resources/StateMachine.xml similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/StateMachine.xml rename to Plugins/org.mitk.gui.qt.application/resources/StateMachine.xml diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/document-save.png b/Plugins/org.mitk.gui.qt.application/resources/document-save.png similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/document-save.png rename to Plugins/org.mitk.gui.qt.application/resources/document-save.png diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/edit-redo.png b/Plugins/org.mitk.gui.qt.application/resources/edit-redo.png similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/edit-redo.png rename to Plugins/org.mitk.gui.qt.application/resources/edit-redo.png diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/edit-undo.png b/Plugins/org.mitk.gui.qt.application/resources/edit-undo.png similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/edit-undo.png rename to Plugins/org.mitk.gui.qt.application/resources/edit-undo.png diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/mitkEventAndActionConstants.xml b/Plugins/org.mitk.gui.qt.application/resources/mitkEventAndActionConstants.xml similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/mitkEventAndActionConstants.xml rename to Plugins/org.mitk.gui.qt.application/resources/mitkEventAndActionConstants.xml diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/preferences-system.png b/Plugins/org.mitk.gui.qt.application/resources/preferences-system.png similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/preferences-system.png rename to Plugins/org.mitk.gui.qt.application/resources/preferences-system.png diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/resources.qrc b/Plugins/org.mitk.gui.qt.application/resources/resources.qrc similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/resources.qrc rename to Plugins/org.mitk.gui.qt.application/resources/resources.qrc diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/resources/system-log-out.png b/Plugins/org.mitk.gui.qt.application/resources/system-log-out.png similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/resources/system-log-out.png rename to Plugins/org.mitk.gui.qt.application/resources/system-log-out.png diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkCloseProjectAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkCloseProjectAction.cpp new file mode 100644 index 0000000000..fb9652c3f8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkCloseProjectAction.cpp @@ -0,0 +1,129 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-10-07 16:14:59 +0200 (Mi, 07 Okt 2009) $ +Version: $Revision: 19343 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkCloseProjectAction.h" +#include "internal/org_mitk_gui_qt_application_Activator.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include + +QmitkCloseProjectAction::QmitkCloseProjectAction(berry::IWorkbenchWindow::Pointer window) +: QAction(0) +{ + this->init(window); +} + +QmitkCloseProjectAction::QmitkCloseProjectAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window) +: QAction(0) +{ + this->setIcon(icon); + this->init(window); +} + +void QmitkCloseProjectAction::init(berry::IWorkbenchWindow::Pointer window) +{ + m_Window = window; + this->setParent(static_cast(m_Window->GetShell()->GetControl())); + this->setText("&Close Project..."); + this->setToolTip("Close Project will remove all data objects from the application. This will free up the memory that is used by the data."); + m_Window = window; + this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); +} + +void QmitkCloseProjectAction::Run() +{ + + + try + { + ctkPluginContext* context = mitk::PluginActivator::GetContext(); + mitk::IDataStorageService* dss = 0; + ctkServiceReference dsRef = context->getServiceReference(); + if (dsRef) + { + dss = context->getService(dsRef); + } + + if (!dss) + { + MITK_WARN << "IDataStorageService service not available. Unable to close project."; + context->ungetService(dsRef); + return; + } + + mitk::IDataStorageReference::Pointer dataStorageRef = dss->GetActiveDataStorage(); + if (dataStorageRef.IsNull()) + { + // No active data storage set (i.e. not editor with a DataStorageEditorInput is active). + dataStorageRef = dss->GetDefaultDataStorage(); + } + + mitk::DataStorage::Pointer dataStorage = dataStorageRef->GetDataStorage(); + if (dataStorage.IsNull()) + { + MITK_WARN << "No data storage available. Cannot close project."; + return; + } + + //check if we got the default datastorage and if there is anything else then helper object in the storage + if(dataStorageRef->IsDefault() && + dataStorage->GetSubset(mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true))))->empty()) + { + return; + } + + /* Ask, if the user is sure about that */ + QString msg = "Are you sure that you want to close the current project (%1)?\nThis will remove all data objects."; + if (QMessageBox::question(NULL, "Remove all data?", msg.arg(dataStorageRef->GetLabel()), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) + { + return; + } + + /* Remove everything */ + mitk::DataStorage::SetOfObjects::ConstPointer nodesToRemove = dataStorage->GetAll(); + dataStorage->Remove(nodesToRemove); + + // Remove the datastorage from the data storage service + dss->RemoveDataStorageReference(dataStorageRef); + + // Close all editors with this data storage as input + mitk::DataStorageEditorInput::Pointer dsInput(new mitk::DataStorageEditorInput(dataStorageRef)); + std::vector dsEditors = + m_Window->GetActivePage()->FindEditors(dsInput, std::string(), berry::IWorkbenchPage::MATCH_INPUT); + + if (!dsEditors.empty()) + { + std::list editorsToClose; + editorsToClose.assign(dsEditors.begin(), dsEditors.end()); + m_Window->GetActivePage()->CloseEditors(editorsToClose, false); + } + } + catch (std::exception& e) + { + MITK_ERROR << "Exception caught during closing project: " << e.what(); + QMessageBox::warning(NULL, "Error", QString("An error occurred during Close Project: %1").arg(e.what())); + } +} diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkCloseProjectAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkCloseProjectAction.h new file mode 100644 index 0000000000..5858850f4a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkCloseProjectAction.h @@ -0,0 +1,51 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-10-09 16:36:23 +0200 (Fr, 09 Okt 2009) $ +Version: $Revision: 19414 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkCloseProjectAction_H_ +#define QmitkCloseProjectAction_H_ + +#ifdef __MINGW32__ +// We need to include winbase.h here in order to declare +// atomic intrinsics like InterlockedIncrement correctly. +// Otherwhise, they would be declared wrong within qatomic_windows.h . +#include +#endif + +#include + +#include + +#include + +/** + * \ingroup org_mitk_gui_qt_application + */ +class MITK_QT_APP QmitkCloseProjectAction : public QAction +{ + Q_OBJECT + +public: + QmitkCloseProjectAction(berry::IWorkbenchWindow::Pointer window); + QmitkCloseProjectAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window); +protected slots: + void Run(); + +private: + void init(berry::IWorkbenchWindow::Pointer window); + berry::IWorkbenchWindow::Pointer m_Window; +}; +#endif /*QmitkCloseProjectAction_H_*/ diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDefaultDropTargetListener.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkDefaultDropTargetListener.cpp new file mode 100644 index 0000000000..85690d184e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDefaultDropTargetListener.cpp @@ -0,0 +1,53 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "QmitkDefaultDropTargetListener.h" +#include +#include +#include +#include + +#include +#include + +berry::IDropTargetListener::Events::Types QmitkDefaultDropTargetListener::GetDropTargetEventTypes() const +{ + return Events::DROP; +} + +void QmitkDefaultDropTargetListener::DropEvent(QDropEvent *event) +{ + qDebug() << event->mimeData()->formats(); + qDebug() << event->mimeData()->text(); + + QList fileNames = event->mimeData()->urls(); + if (fileNames.empty()) + return; + + QStringList fileNames2; + fileNames2.reserve(fileNames.size()); + foreach(QUrl url, fileNames) + { + fileNames2.push_back(url.toLocalFile()); + } + + mitk::WorkbenchUtil::LoadFiles(fileNames2, + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); + + event->accept(); +} diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkDefaultDropTargetListener.h b/Plugins/org.mitk.gui.qt.application/src/QmitkDefaultDropTargetListener.h new file mode 100644 index 0000000000..bfefd59d52 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkDefaultDropTargetListener.h @@ -0,0 +1,39 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITKDEFAULTDROPTARGETLISTENER_H +#define QMITKDEFAULTDROPTARGETLISTENER_H + +#include + +#include + +/** + * \ingroup org_mitk_gui_qt_application + */ +class MITK_QT_APP QmitkDefaultDropTargetListener : public berry::IDropTargetListener +{ +public: + + Events::Types GetDropTargetEventTypes() const; + + void DropEvent(QDropEvent* event); + +}; + +#endif // QMITKDEFAULTDROPTARGETLISTENER_H diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileExitAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkFileExitAction.cpp new file mode 100644 index 0000000000..1b60840103 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileExitAction.cpp @@ -0,0 +1,44 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-08-26 18:11:29 +0200 (Mi, 26 Aug 2009) $ +Version: $Revision: 18726 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkFileExitAction.h" + +#include +#include + +#include +#include +#include +#include + +#include + +QmitkFileExitAction::QmitkFileExitAction(berry::IWorkbenchWindow::Pointer window) +: QAction(0) +{ + m_Window = window.GetPointer(); + + this->setParent(static_cast(m_Window->GetShell()->GetControl())); + this->setText("&Exit"); + + this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); +} + +void QmitkFileExitAction::Run() +{ + berry::PlatformUI::GetWorkbench()->Close(); +} diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileExitAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkFileExitAction.h new file mode 100644 index 0000000000..0a91fcb022 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileExitAction.h @@ -0,0 +1,48 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-08-04 15:43:53 +0200 (Di, 04 Aug 2009) $ +Version: $Revision: 18435 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKFILEEXITACTION_H_ +#define QMITKFILEEXITACTION_H_ + +#include + +#include + +#include + +/** + * \ingroup org_mitk_gui_qt_application + */ +class MITK_QT_APP QmitkFileExitAction : public QAction +{ + Q_OBJECT + +public: + + QmitkFileExitAction(berry::IWorkbenchWindow::Pointer window); + +protected slots: + + void Run(); + +private: + + berry::IWorkbenchWindow* m_Window; +}; + + +#endif /*QMITKFILEOPENACTION_H_*/ diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp new file mode 100644 index 0000000000..fc795fd08b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp @@ -0,0 +1,121 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkFileOpenAction.h" + +#include "internal/org_mitk_gui_qt_application_Activator.h" + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +class QmitkFileOpenActionPrivate +{ +public: + + QmitkFileOpenActionPrivate() + : m_PrefServiceTracker(mitk::PluginActivator::GetContext()) + {} + + void init ( berry::IWorkbenchWindow::Pointer window, QmitkFileOpenAction* action ) + { + m_PrefServiceTracker.open(); + + m_Window = window; + action->setParent(static_cast(m_Window.Lock()->GetShell()->GetControl())); + action->setText("&Open..."); + action->setToolTip("Open data files (images, surfaces,...)"); + + QObject::connect(action, SIGNAL(triggered(bool)), action, SLOT(Run())); + } + + berry::IPreferences::Pointer GetPreferences() const + { + berry::IPreferencesService* prefService = m_PrefServiceTracker.getService(); + if (prefService) + { + return prefService->GetSystemPreferences()->Node("/General"); + } + return berry::IPreferences::Pointer(0); + } + + QString getLastFileOpenPath() const + { + berry::IPreferences::Pointer prefs = GetPreferences(); + if(prefs.IsNotNull()) + { + return QString::fromStdString(prefs->Get("LastFileOpenPath", "")); + } + return QString(); + } + + void setLastFileOpenPath(const QString& path) const + { + berry::IPreferences::Pointer prefs = GetPreferences(); + if(prefs.IsNotNull()) + { + prefs->Put("LastFileOpenPath", path.toStdString()); + prefs->Flush(); + } + } + + berry::IWorkbenchWindow::WeakPtr m_Window; + ctkServiceTracker m_PrefServiceTracker; +}; + +QmitkFileOpenAction::QmitkFileOpenAction(berry::IWorkbenchWindow::Pointer window) + : QAction(0), d(new QmitkFileOpenActionPrivate) +{ + d->init(window, this); +} + +QmitkFileOpenAction::QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window) + : QAction(0), d(new QmitkFileOpenActionPrivate) +{ + d->init(window, this); + this->setIcon(icon); +} + +QmitkFileOpenAction::~QmitkFileOpenAction() +{ +} + +void QmitkFileOpenAction::Run() +{ + + // Ask the user for a list of files to open + QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Open", + d->getLastFileOpenPath(), + mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); + + if (fileNames.empty()) + return; + + d->setLastFileOpenPath(fileNames.front()); + mitk::WorkbenchUtil::LoadFiles(fileNames, d->m_Window.Lock()); +} diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.h b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.h new file mode 100644 index 0000000000..20e6f8bc54 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.h @@ -0,0 +1,63 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKFILEOPENACTION_H_ +#define QMITKFILEOPENACTION_H_ + +#ifdef __MINGW32__ +// We need to inlclude winbase.h here in order to declare +// atomic intrinsics like InterlockedIncrement correctly. +// Otherwhise, they would be declared wrong within qatomic_windows.h . +#include +#endif + +#include +#include + +#include + +#include + +#include + +class QmitkFileOpenActionPrivate; + +/** + * \ingroup org_mitk_gui_qt_application + */ +class MITK_QT_APP QmitkFileOpenAction : public QAction +{ + Q_OBJECT + +public: + QmitkFileOpenAction(berry::IWorkbenchWindow::Pointer window); + QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window); + + ~QmitkFileOpenAction(); + +protected slots: + + virtual void Run(); + +private: + + const QScopedPointer d; + +}; + + +#endif /*QMITKFILEOPENACTION_H_*/ diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.cpp new file mode 100644 index 0000000000..ac320171e0 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.cpp @@ -0,0 +1,444 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkPreferencesDialog.h" + +#include "berryPlatform.h" +#include "berryIConfigurationElement.h" +#include "berryIExtensionPointService.h" +#include "berryIExtension.h" +#include +#include + +#include + +#include +#include +#include + +#include + +#include + +using namespace std; + +class QmitkPreferencesDialogPrivate : public Ui::QmitkPreferencesDialog +{ +public: + + /// + /// Just a stub class for holding information on prefpages (metadata) + /// + struct PrefPage + { + PrefPage(std::string _id, std::string _name, std::string _category + , std::string _className, std::string _keywords, berry::IConfigurationElement::Pointer _confElem) + : id(_id), name(_name), category(_category), className(_className), keywords(_keywords), + prefPage(0), confElem(_confElem), treeWidgetItem(0) + {} + + bool operator==(const PrefPage& other) + { return id == other.id; } + + bool operator<(const PrefPage& other) + { return name < other.name; } + + std::string id; + std::string name; + std::string category; + std::string className; + std::string keywords; + berry::IQtPreferencePage* prefPage; + berry::IConfigurationElement::Pointer confElem; + QTreeWidgetItem* treeWidgetItem; + }; + + QmitkPreferencesDialogPrivate() + : m_CurrentPage(0) + { + // m_PreferencesService + m_PreferencesService = + berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); + + // m_PrefPages + berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); + berry::IConfigurationElement::vector prefPages(extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.preferencePages")); + berry::IConfigurationElement::vector keywordExts(extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.keywords")); + berry::IConfigurationElement::vector::iterator prefPagesIt; + std::string id; + std::string name; + std::string category; + std::string className; + std::vector keywords; + vector keywordRefs; + berry::IConfigurationElement::vector::iterator keywordRefsIt; + berry::IConfigurationElement::vector::iterator keywordExtsIt; + string keywordRefId; + string keywordId; + string keywordLabels; + + for (prefPagesIt = prefPages.begin(); prefPagesIt != prefPages.end(); ++prefPagesIt) + { + keywords.clear(); + id.clear(); + name.clear(); + className.clear(); + category.clear(); + keywordRefId.clear(); + keywordId.clear(); + keywordLabels.clear(); + + if((*prefPagesIt)->GetAttribute("id", id) + && (*prefPagesIt)->GetAttribute("name", name) + && (*prefPagesIt)->GetAttribute("class", className)) + { + (*prefPagesIt)->GetAttribute("category", category); + //# collect keywords + keywordRefs = (*prefPagesIt)->GetChildren("keywordreference"); // get all keyword references + for (keywordRefsIt = keywordRefs.begin() + ; keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs + { + (*keywordRefsIt)->GetAttribute("id", keywordRefId); // get referenced id + + for (keywordExtsIt = keywordExts.begin(); keywordExtsIt != keywordExts.end(); ++keywordExtsIt) // iterate over all keywords + { + (*keywordExtsIt)->GetAttribute("id", keywordId); // get keyword id + if(keywordId == keywordRefId) // if referenced id is equals the current keyword id + { + //# collect all keywords from label attribute with a tokenizer + std::string currLabel; + (*keywordExtsIt)->GetAttribute("label", currLabel); + std::transform(currLabel.begin(), currLabel.end(), currLabel.begin(), ::tolower); + if (!currLabel.empty()) keywordLabels += std::string(" ") + currLabel; + + //break; // break here; possibly search for other referenced keywords + } + } + } + + // add information as PrefPage + m_PrefPages.push_back(PrefPage(id, name, category, className, keywordLabels, berry::IConfigurationElement::Pointer(*prefPagesIt))); + } + + } + } + + /// + /// The Preferences Service to retrieve and store preferences. + /// + berry::IPreferencesService::WeakPtr m_PreferencesService; + + /// + /// Saves all treewidgetitems in a map, the key is the id of the preferencepage. + /// + std::vector m_PrefPages; + std::size_t m_CurrentPage; +}; + +QmitkPreferencesDialog::QmitkPreferencesDialog(QWidget * parent, Qt::WindowFlags f) + : QDialog(parent, f), d(new QmitkPreferencesDialogPrivate) +{ + d->setupUi(this); + + QObject::connect(d->m_Keyword, SIGNAL(editingFinished()), this, SLOT(OnKeywordEditingFinished())); + QObject::connect(d->m_Keyword, SIGNAL(textChanged(QString)), this, SLOT(OnKeywordTextChanged(QString))); + + QObject::connect(d->m_PreferencesTree, SIGNAL(itemSelectionChanged()), this, SLOT(OnPreferencesTreeItemSelectionChanged())); + + QPushButton* importButton = d->buttonBox->addButton("Import...", QDialogButtonBox::ActionRole); + QObject::connect(importButton, SIGNAL(clicked()), this, SLOT(OnImportButtonClicked())); + + QPushButton* exportButton = d->buttonBox->addButton("Export...", QDialogButtonBox::ActionRole); + QObject::connect(exportButton, SIGNAL(clicked()), this, SLOT(OnExportButtonClicked())); + + QObject::connect(this, SIGNAL(accepted()), this, SLOT(OnDialogAccepted())); + QObject::connect(this, SIGNAL(rejected()), this, SLOT(OnDialogRejected())); + + d->buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true); + + this->UpdateTree(); +} + +QmitkPreferencesDialog::~QmitkPreferencesDialog() +{ +} + +void QmitkPreferencesDialog::SetSelectedPage(const std::string& id) +{ + for(vector::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it) + { + if(it->id == id) + { + d->m_PreferencesTree->setCurrentItem(it->treeWidgetItem); + break; + } + } +} + +void QmitkPreferencesDialog::OnImportButtonClicked() +{ + int answer = QMessageBox::question(this, "Importing Preferences" + , "All existing preferences will be overwritten!\nAre you sure that you want to import other preferences?", QMessageBox::Yes | QMessageBox::No ); + if(answer == QMessageBox::No) + return; + + try + { + berry::IPreferencesService::Pointer prefService = d->m_PreferencesService.Lock(); + if(prefService.IsNotNull()) + { + berry::IBerryPreferencesService::Pointer berryPrefService = prefService.Cast(); + if(berryPrefService != 0) + { + static QString importDir = ""; + QString fileName = QFileDialog::getOpenFileName(this, tr("Choose file to import preferences"), + importDir, tr("XML files (*.xml)")); + + if(!fileName.isEmpty()) + { + importDir = QFileInfo(fileName).absoluteDir().path(); + Poco::File f(fileName.toLocal8Bit().data()); + berryPrefService->ImportPreferences(f, ""); + berry::IQtPreferencePage* prefPage = d->m_PrefPages[d->m_CurrentPage].prefPage; + if(prefPage) + prefPage->Update(); + + MITK_INFO("QmitkPreferencesDialog") << "Preferences successfully imported from " << f.path(); + } + } + } + } + catch (Poco::Exception& pe) + { + QMessageBox::critical(this, "Error Importing", pe.message().c_str()); + MITK_ERROR("QmitkPreferencesDialog") << pe.what(); + } + catch (std::exception& e) + { + QMessageBox::critical(this, "Error Importing", e.what()); + MITK_ERROR("QmitkPreferencesDialog") << e.what(); + } +} + +void QmitkPreferencesDialog::OnExportButtonClicked() +{ + try + { + berry::IPreferencesService::Pointer prefService = d->m_PreferencesService.Lock(); + if(prefService.IsNotNull()) + { + berry::IBerryPreferencesService::Pointer berryPrefService = prefService.Cast(); + if(berryPrefService != 0) + { + SavePreferences(); + static QString exportDir = ""; + QString fileName = QFileDialog::getSaveFileName(this, tr("Choose file to export preferences"), + exportDir, tr("XML files (*.xml)")); + + if(!fileName.isEmpty()) + { + if(QFileInfo(fileName).suffix() != ".xml") + { + fileName += ".xml"; + } + exportDir = QFileInfo(fileName).absoluteDir().path(); + Poco::File f(fileName.toLocal8Bit().data()); + berryPrefService->ExportPreferences(f, ""); + MITK_INFO("QmitkPreferencesDialog") << "Preferences successfully exported to " << f.path(); + } + } + } + } + catch (Poco::Exception& pe) + { + QMessageBox::critical(this, "Error Exporting", pe.message().c_str()); + MITK_ERROR("QmitkPreferencesDialog") << pe.what(); + } + catch (std::exception& e) + { + QMessageBox::critical(this, "Error Exporting", e.what()); + MITK_ERROR("QmitkPreferencesDialog") << e.what(); + } +} + +void QmitkPreferencesDialog::SavePreferences() +{ + berry::IQtPreferencePage* prefPage = 0; + + for(vector::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it) + { + prefPage = it->prefPage; + if(prefPage) { + prefPage->PerformOk(); + } + } + + /** + * Every preference page has its own preferences, which should stay the same after a system restart.
+ * Therefore this method flushes all the preferences, every time a change in the preferences is
+ * performed and confirmed. + * + */ + berry::IPreferencesService::Pointer prefService = d->m_PreferencesService.Lock(); + if (prefService) + { + prefService->GetSystemPreferences()->Flush(); + } +} + +void QmitkPreferencesDialog::OnDialogAccepted() +{ + this->SavePreferences(); +} + +void QmitkPreferencesDialog::OnDialogRejected() +{ + berry::IQtPreferencePage* prefPage = d->m_PrefPages[d->m_CurrentPage].prefPage; + if(prefPage) + prefPage->PerformCancel(); +} + +void QmitkPreferencesDialog::OnKeywordTextChanged(const QString & /*s*/) +{ + // search for text + this->UpdateTree(); +} + +void QmitkPreferencesDialog::OnKeywordEditingFinished() +{ +} + +//bool QmitkPreferencesDialog::eventFilter( QObject *obj, QEvent *event ) +//{ +// if(obj == d->m_Keyword) +// { +// if(event->type() == QEvent::FocusIn && d->m_Keyword->text() == "search ...") +// { +// d->m_Keyword->setText(""); +// d->m_Keyword->setStyleSheet("color: black;"); +// } +// else if(event->type() == QEvent::FocusOut && d->m_Keyword->text() == "") +// { +// d->m_Keyword->setText("search ..."); +// d->m_Keyword->setStyleSheet("color: gray;"); +// } +// } +// return true; +//} + +void QmitkPreferencesDialog::OnPreferencesTreeItemSelectionChanged() +{ + if(d->m_PreferencesTree == 0) + return; + + // TODO: create page and show it + QList selectedItems = d->m_PreferencesTree->selectedItems(); + if(selectedItems.size()>0) + { + + d->m_CurrentPage = 0; + for(vector::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it, ++d->m_CurrentPage) + { + if(it->treeWidgetItem == selectedItems.at(0)) + { + d->m_Headline->setText(QString::fromStdString(it->name)); + if(it->prefPage == 0) + { + berry::IPreferencePage* page = it->confElem->CreateExecutableExtension("class"); + if (page == 0) + { + // support legacy BlueBerry extensions + page = it->confElem->CreateExecutableExtension("class", berry::IPreferencePage::GetManifestName()); + } + it->prefPage = dynamic_cast(page); + it->prefPage->CreateQtControl(d->m_PreferencesPanel); + d->m_PreferencesPanel->addWidget(it->prefPage->GetQtControl()); + } + d->m_PreferencesPanel->setCurrentWidget(it->prefPage->GetQtControl()); + + break; + } + } + } +} + +void QmitkPreferencesDialog::UpdateTree() +{ + if(d->m_PreferencesTree == 0) + return; + + //m_PreferencesTree->clear(); + string keyword = d->m_Keyword->text().toLower().toStdString(); + + map items; + + for(vector::iterator it = d->m_PrefPages.begin(); + it != d->m_PrefPages.end(); ++it) + { + if(it->treeWidgetItem == 0) + { + + if(it->category.empty()) + { + it->treeWidgetItem = new QTreeWidgetItem(d->m_PreferencesTree); + } + else + { + it->treeWidgetItem = new QTreeWidgetItem(items[it->category]); + } + it->treeWidgetItem->setText(0, QString::fromStdString(it->name)); + items[it->id] = it->treeWidgetItem; + } + + // hide treeWidgetItem if keyword not matches + if(!keyword.empty()) + { + if( it->keywords.find(keyword) == string::npos ) + it->treeWidgetItem->setHidden(true); + else + { + //#make the whole branch visible + QTreeWidgetItem* treeWidgetParent = it->treeWidgetItem->parent(); + while(treeWidgetParent!=0) + { + treeWidgetParent->setHidden(false); + treeWidgetParent->setExpanded(true); + treeWidgetParent = treeWidgetParent->parent(); + } + + it->treeWidgetItem->setHidden(false); + QFont f = it->treeWidgetItem->font(0); + f.setBold(true); + it->treeWidgetItem->setFont(0, f); + } + } + else + { + QFont f = it->treeWidgetItem->font(0); + f.setBold(false); + it->treeWidgetItem->setFont(0, f); + it->treeWidgetItem->setHidden(false); + } + } + + if(d->m_PrefPages.size()>0) + { + if(d->m_PrefPages.front().treeWidgetItem != 0) + d->m_PrefPages.front().treeWidgetItem->setSelected(true); + } + +} diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.h b/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.h new file mode 100644 index 0000000000..059c6a8486 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.h @@ -0,0 +1,69 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef BERRYQMITKPREFERENCESDIALOG_H_ +#define BERRYQMITKPREFERENCESDIALOG_H_ + +#include + +#include +#include + + +class QmitkPreferencesDialogPrivate; + +/** + * \ingroup org_mitk_gui_qt_application + */ +class MITK_QT_APP QmitkPreferencesDialog : public QDialog +{ + Q_OBJECT + +public: + + QmitkPreferencesDialog(QWidget * parent = 0, Qt::WindowFlags f = 0); + ~QmitkPreferencesDialog(); + + void SetSelectedPage(const std::string& id); + +protected slots: + + void OnImportButtonClicked(); + void OnExportButtonClicked(); + void OnDialogAccepted(); + void OnDialogRejected(); + + void OnKeywordTextChanged(const QString & s); + void OnKeywordEditingFinished(); + void OnPreferencesTreeItemSelectionChanged(); + +protected: + + //bool eventFilter(QObject *obj, QEvent *event); + void UpdateTree(); + + /// + /// Saves all preferencepages. + /// + void SavePreferences(); + + QScopedPointer d; + +}; + +#endif /* BERRYQMITKPREFERENCESDIALOG_H_ */ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.ui b/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.ui similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkPreferencesDialog.ui rename to Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.ui diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStatusBar.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkStatusBar.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStatusBar.cpp rename to Plugins/org.mitk.gui.qt.application/src/QmitkStatusBar.cpp diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkStatusBar.h b/Plugins/org.mitk.gui.qt.application/src/QmitkStatusBar.h new file mode 100755 index 0000000000..bb95f8c1da --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkStatusBar.h @@ -0,0 +1,85 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITKSTATUSBAR_H +#define QMITKSTATUSBAR_H +#include +#include +#include +#include +#include + +/** + * \ingroup org_mitk_gui_qt_application + * + * \brief QT-Toolkit/GUI dependent class that provides to send a Message to the QT's StatusBar + * + * A delay time can be set. + * + * All mitk-classes will call this class for output: + * mitk::StatusBar::GetInstance(); + */ +class MITK_QT_APP QmitkStatusBar : public mitk::StatusBarImplementation +{ +public: + + mitkClassMacro(QmitkStatusBar, mitk::StatusBarImplementation); + + //##Documentation + //##@brief Constructor; + //## holds param instance internaly and connects this to the mitkStatusBar + QmitkStatusBar(QStatusBar* instance); + + //##Documentation + //##@brief Destructor + virtual ~QmitkStatusBar(); + + + //##Documentation + //## @brief Send a string to the applications StatusBar (QStatusBar). + virtual void DisplayText(const char* t); + virtual void DisplayText(const char* t, int ms); + + //##Documentation + //## @brief Send a string as an error message to StatusBar. + //## The implementation calls DisplayText() + virtual void DisplayErrorText(const char *t) { this->DisplayText(t); }; + virtual void DisplayWarningText(const char *t) { this->DisplayText(t); }; + virtual void DisplayWarningText(const char *t, int ms) { this->DisplayText(t, ms); }; + virtual void DisplayGenericOutputText(const char *t) {this->DisplayText(t);} + virtual void DisplayDebugText(const char *t) { this->DisplayText(t); }; + virtual void DisplayGreyValueText(const char *t); + + //##Documentation + //## @brief removes any temporary message being shown. + virtual void Clear(); + + //##Documentation + //## @brief Set the QSizeGrip of the window + //## (the triangle in the lower right Windowcorner for changing the size) + //## to enabled or disabled + virtual void SetSizeGripEnabled(bool enable); + +private: + //static Pointer m_Instance; + QStatusBar* m_StatusBar; + QLabel* m_GreyValueLabel; + +}; + +#endif /* define QMITKSTATUSBAR_H */ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkEditorsPreferencePage.cpp b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkEditorsPreferencePage.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkEditorsPreferencePage.cpp rename to Plugins/org.mitk.gui.qt.application/src/internal/QmitkEditorsPreferencePage.cpp diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkEditorsPreferencePage.h b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkEditorsPreferencePage.h similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkEditorsPreferencePage.h rename to Plugins/org.mitk.gui.qt.application/src/internal/QmitkEditorsPreferencePage.h diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkGeneralPreferencePage.cpp b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkGeneralPreferencePage.cpp rename to Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.cpp diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkGeneralPreferencePage.h b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.h similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkGeneralPreferencePage.h rename to Plugins/org.mitk.gui.qt.application/src/internal/QmitkGeneralPreferencePage.h diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/org_mitk_gui_qt_application_Activator.cpp b/Plugins/org.mitk.gui.qt.application/src/internal/org_mitk_gui_qt_application_Activator.cpp new file mode 100644 index 0000000000..2a5b308f08 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/internal/org_mitk_gui_qt_application_Activator.cpp @@ -0,0 +1,70 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "org_mitk_gui_qt_application_Activator.h" + +#include "QmitkGeneralPreferencePage.h" +#include "QmitkEditorsPreferencePage.h" + +#include +#include + +#include + +namespace mitk { + +ctkPluginContext* org_mitk_gui_qt_application_Activator::m_Context = 0; + +void org_mitk_gui_qt_application_Activator::start(ctkPluginContext* context) +{ + this->m_Context = context; + + BERRY_REGISTER_EXTENSION_CLASS(QmitkGeneralPreferencePage, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkEditorsPreferencePage, context) + + QFile file(":/org.mitk.gui.qt.common/StateMachine.xml"); + if(file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text) ) + { + QByteArray contents = file.readAll(); + QString string(contents); + file.close(); + + mitk::GlobalInteraction::GetInstance()->Initialize("global", string.toStdString()); + } + else throw std::exception(); + + QmitkRegisterClasses(); +} + +void org_mitk_gui_qt_application_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + + this->m_Context = 0; +} + +ctkPluginContext* org_mitk_gui_qt_application_Activator::GetContext() +{ + return m_Context; +} + +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_application, mitk::org_mitk_gui_qt_application_Activator) + + diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/org_mitk_gui_qt_application_Activator.h b/Plugins/org.mitk.gui.qt.application/src/internal/org_mitk_gui_qt_application_Activator.h new file mode 100644 index 0000000000..4bd05dfeca --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/internal/org_mitk_gui_qt_application_Activator.h @@ -0,0 +1,49 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKPLUGINACTIVATOR_H +#define MITKPLUGINACTIVATOR_H + +#include + +namespace mitk { + +class org_mitk_gui_qt_application_Activator : + public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + + static ctkPluginContext* GetContext(); + +private: + + static ctkPluginContext* m_Context; + +}; // org_mitk_gui_common_Activator + +typedef org_mitk_gui_qt_application_Activator PluginActivator; + +} + +#endif // MITKPLUGINACTIVATOR_H diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/target_libraries.cmake b/Plugins/org.mitk.gui.qt.application/target_libraries.cmake similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/target_libraries.cmake rename to Plugins/org.mitk.gui.qt.application/target_libraries.cmake diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/CMakeLists.txt b/Plugins/org.mitk.gui.qt.basicimageprocessing/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.basicimageprocessing/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/BIP_Overview.png b/Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/BIP_Overview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/BIP_Overview.png rename to Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/BIP_Overview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/ImageProcessing_48.png b/Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/ImageProcessing_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/ImageProcessing_48.png rename to Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/ImageProcessing_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/QmitkBasicImageProcessing.dox b/Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/QmitkBasicImageProcessing.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/QmitkBasicImageProcessing.dox rename to Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/UserManual/QmitkBasicImageProcessing.dox diff --git a/Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..7bf036aa2a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.basicimageprocessing/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_basicimageprocessing org.mitk.gui.qt.basicimageprocessing + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_basicimageprocessing_internal Internal + \ingroup org_mitk_gui_qt_basicimageprocessing + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.basicimageprocessing plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/files.cmake b/Plugins/org.mitk.gui.qt.basicimageprocessing/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/files.cmake rename to Plugins/org.mitk.gui.qt.basicimageprocessing/files.cmake diff --git a/Plugins/org.mitk.gui.qt.basicimageprocessing/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.basicimageprocessing/manifest_headers.cmake new file mode 100644 index 0000000000..64cf4a666d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.basicimageprocessing/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Basic Image Processing") +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) diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/plugin.xml b/Plugins/org.mitk.gui.qt.basicimageprocessing/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/plugin.xml rename to Plugins/org.mitk.gui.qt.basicimageprocessing/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/resources/ImageProcessing_64.xpm b/Plugins/org.mitk.gui.qt.basicimageprocessing/resources/ImageProcessing_64.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/resources/ImageProcessing_64.xpm rename to Plugins/org.mitk.gui.qt.basicimageprocessing/resources/ImageProcessing_64.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/resources/QmitkBasicImageProcessingView.qrc b/Plugins/org.mitk.gui.qt.basicimageprocessing/resources/QmitkBasicImageProcessingView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/resources/QmitkBasicImageProcessingView.qrc rename to Plugins/org.mitk.gui.qt.basicimageprocessing/resources/QmitkBasicImageProcessingView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/resources/lena.xpm b/Plugins/org.mitk.gui.qt.basicimageprocessing/resources/lena.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/resources/lena.xpm rename to Plugins/org.mitk.gui.qt.basicimageprocessing/resources/lena.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.cpp b/Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.cpp rename to Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.h b/Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.h rename to Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingViewControls.ui b/Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingViewControls.ui rename to Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/QmitkBasicImageProcessingViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.cpp b/Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.cpp rename to Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.h b/Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.h rename to Plugins/org.mitk.gui.qt.basicimageprocessing/src/internal/mitkBasicImageProcessingActivator.h diff --git a/Plugins/org.mitk.gui.qt.common.legacy/CMakeLists.txt b/Plugins/org.mitk.gui.qt.common.legacy/CMakeLists.txt new file mode 100755 index 0000000000..19059562eb --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/CMakeLists.txt @@ -0,0 +1,8 @@ +PROJECT(org_mitk_gui_qt_common_legacy) + +MACRO_CREATE_MITK_CTK_PLUGIN( + EXPORT_DIRECTIVE MITK_QT_COMMON_LEGACY + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDENCIES Qmitk + SUBPROJECTS MITK-CoreUI + ) diff --git a/Plugins/org.mitk.gui.qt.common.legacy/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.common.legacy/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..f895c8411e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/documentation/doxygen/modules.dox @@ -0,0 +1,19 @@ +/** + \defgroup org_mitk_gui_qt_common_legacy org.mitk.gui.qt.common.legacy + \ingroup MITKPlugins + + \brief Provides legacy classes and functionality common for MITK plug-ins. + + \deprecated This plug-in is deprecated. Old plug-ins having a dependency on it should + migrate to the org_mitk_gui_qt_common Plug-in using http://www.mitk.org/wiki/ViewsWithoutMultiWidget + +*/ + +/** + \defgroup org_mitk_gui_qt_common_legacy_internal Internal + \ingroup org_mitk_gui_qt_common_legacy + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.common.legacy plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.common.legacy/files.cmake b/Plugins/org.mitk.gui.qt.common.legacy/files.cmake new file mode 100755 index 0000000000..9081ef1134 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/files.cmake @@ -0,0 +1,33 @@ +SET(SRC_CPP_FILES + QmitkFunctionality.cpp + QmitkFunctionality2.cpp + QmitkFunctionalityCoordinator.cpp +) + +SET(INTERNAL_CPP_FILES + QmitkCommonLegacyActivator.cpp + QmitkFunctionalityUtil.cpp +) + +SET(MOC_H_FILES + src/internal/QmitkCommonLegacyActivator.h +) + +SET(UI_FILES +) + +SET(CACHED_RESOURCE_FILES +) + +SET(QRC_FILES +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.common.legacy/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.common.legacy/manifest_headers.cmake new file mode 100644 index 0000000000..b9d31fb32e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "Legacy Plug-in for QmitkStdMultiWidgetEditor") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.stdmultiwidgeteditor) + diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp new file mode 100755 index 0000000000..e70d6a235d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp @@ -0,0 +1,354 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkFunctionality.h" +#include "internal/QmitkFunctionalityUtil.h" + +// other includes +#include + +// mitk Includes +#include +#include + +// berry Includes +#include +#include +#include + +// Qmitk Includes +#include + +// Qt Includes +#include +#include +#include +#include + +QmitkFunctionality::QmitkFunctionality() + : m_Parent(0) + , m_Active(false) + , m_Visible(false) + , m_SelectionProvider(0) + , m_HandlesMultipleDataStorages(false) + , m_InDataStorageChanged(false) +{ + m_PreferencesService = + berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID); +} + +void QmitkFunctionality::SetHandleMultipleDataStorages(bool multiple) +{ + m_HandlesMultipleDataStorages = multiple; +} + +bool QmitkFunctionality::HandlesMultipleDataStorages() const +{ + return m_HandlesMultipleDataStorages; +} + +mitk::DataStorage::Pointer +QmitkFunctionality::GetDataStorage() const +{ + mitk::IDataStorageService::Pointer service = + berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); + + if (service.IsNotNull()) + { + if (m_HandlesMultipleDataStorages) + return service->GetActiveDataStorage()->GetDataStorage(); + else + return service->GetDefaultDataStorage()->GetDataStorage(); + } + + return 0; +} + +mitk::DataStorage::Pointer QmitkFunctionality::GetDefaultDataStorage() const +{ + mitk::IDataStorageService::Pointer service = + berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); + + return service->GetDefaultDataStorage()->GetDataStorage(); +} + +void QmitkFunctionality::CreatePartControl(void* parent) +{ + + // scrollArea + QScrollArea* scrollArea = new QScrollArea; + //QVBoxLayout* scrollAreaLayout = new QVBoxLayout(scrollArea); + scrollArea->setFrameShadow(QFrame::Plain); + scrollArea->setFrameShape(QFrame::NoFrame); + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + // m_Parent + m_Parent = new QWidget; + //m_Parent->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + this->CreateQtPartControl(m_Parent); + + //scrollAreaLayout->addWidget(m_Parent); + //scrollArea->setLayout(scrollAreaLayout); + + // set the widget now + scrollArea->setWidgetResizable(true); + scrollArea->setWidget(m_Parent); + + // add the scroll area to the real parent (the view tabbar) + QWidget* parentQWidget = static_cast(parent); + QVBoxLayout* parentLayout = new QVBoxLayout(parentQWidget); + parentLayout->setMargin(0); + parentLayout->setSpacing(0); + parentLayout->addWidget(scrollArea); + + // finally set the layout containing the scroll area to the parent widget (= show it) + parentQWidget->setLayout(parentLayout); + + this->AfterCreateQtPartControl(); +} + +void QmitkFunctionality::AfterCreateQtPartControl() +{ + // REGISTER DATASTORAGE LISTENER + this->GetDefaultDataStorage()->AddNodeEvent.AddListener( mitk::MessageDelegate1 + ( this, &QmitkFunctionality::NodeAddedProxy ) ); + this->GetDefaultDataStorage()->ChangedNodeEvent.AddListener( mitk::MessageDelegate1 + ( this, &QmitkFunctionality::NodeChangedProxy ) ); + this->GetDefaultDataStorage()->RemoveNodeEvent.AddListener( mitk::MessageDelegate1 + ( this, &QmitkFunctionality::NodeRemovedProxy ) ); + + // REGISTER PREFERENCES LISTENER + berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); + if(prefs.IsNotNull()) + prefs->OnChanged.AddListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); + + // REGISTER FOR WORKBENCH SELECTION EVENTS + m_BlueBerrySelectionListener = berry::ISelectionListener::Pointer(new berry::SelectionChangedAdapter(this + , &QmitkFunctionality::BlueBerrySelectionChanged)); + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_BlueBerrySelectionListener); + + // REGISTER A SELECTION PROVIDER + QmitkFunctionalitySelectionProvider::Pointer _SelectionProvider + = QmitkFunctionalitySelectionProvider::New(this); + m_SelectionProvider = _SelectionProvider.GetPointer(); + this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(m_SelectionProvider)); + + // EMULATE INITIAL SELECTION EVENTS + + // by default a a multi widget is always available + this->StdMultiWidgetAvailable(*this->GetActiveStdMultiWidget()); + + // send datamanager selection + this->OnSelectionChanged(this->GetDataManagerSelection()); + + // send preferences changed event + this->OnPreferencesChanged(this->GetPreferences().Cast().GetPointer()); +} + +void QmitkFunctionality::ClosePart() +{ + +} + +void QmitkFunctionality::ClosePartProxy() +{ + this->GetDefaultDataStorage()->AddNodeEvent.RemoveListener( mitk::MessageDelegate1 + ( this, &QmitkFunctionality::NodeAddedProxy ) ); + this->GetDefaultDataStorage()->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1 + ( this, &QmitkFunctionality::NodeRemovedProxy) ); + this->GetDefaultDataStorage()->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1 + ( this, &QmitkFunctionality::NodeChangedProxy ) ); + + berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); + if(prefs.IsNotNull()) + { + prefs->OnChanged.RemoveListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); + // flush the preferences here (disabled, everyone should flush them by themselves at the right moment) + // prefs->Flush(); + } + + // REMOVE SELECTION PROVIDER + this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(NULL)); + + berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); + if(s) + { + s->RemovePostSelectionListener(m_BlueBerrySelectionListener); + } + + this->ClosePart(); +} + +QmitkFunctionality::~QmitkFunctionality() +{ + this->Register(); + this->ClosePartProxy(); + + this->UnRegister(false); +} + +void QmitkFunctionality::OnPreferencesChanged( const berry::IBerryPreferences* ) +{ +} + +void QmitkFunctionality::BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection) +{ + if(sourcepart.IsNull() || sourcepart->GetSite()->GetId() != "org.mitk.views.datamanager") + return; + + mitk::DataNodeSelection::ConstPointer _DataNodeSelection + = selection.Cast(); + this->OnSelectionChanged(this->DataNodeSelectionToVector(_DataNodeSelection)); +} + +bool QmitkFunctionality::IsVisible() const +{ + return m_Visible; +} + +void QmitkFunctionality::SetFocus() +{ +} + +void QmitkFunctionality::Activated() +{ +} + +void QmitkFunctionality::Deactivated() +{ +} + +void QmitkFunctionality::StdMultiWidgetAvailable( QmitkStdMultiWidget& /*stdMultiWidget*/ ) +{ +} +void QmitkFunctionality::StdMultiWidgetNotAvailable() +{ +} + +void QmitkFunctionality::DataStorageChanged() +{ + +} + +QmitkStdMultiWidget* QmitkFunctionality::GetActiveStdMultiWidget( bool reCreateWidget ) +{ + QmitkStdMultiWidget* activeStdMultiWidget = 0; + berry::IEditorPart::Pointer editor = + this->GetSite()->GetPage()->GetActiveEditor(); + + if (editor.Cast().IsNotNull()) + { + activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); + } + else if (reCreateWidget) + { + mitk::DataStorageEditorInput::Pointer editorInput; + editorInput = new mitk::DataStorageEditorInput(); + // open a new multi-widget editor, but do not give it the focus + berry::IEditorPart::Pointer editor = this->GetSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID, false); + activeStdMultiWidget = editor.Cast()->GetStdMultiWidget(); + } + + return activeStdMultiWidget; +} + +void QmitkFunctionality::HandleException( const char* str, QWidget* parent, bool showDialog ) const +{ + //itkGenericOutputMacro( << "Exception caught: " << str ); + MITK_ERROR << str; + if ( showDialog ) + { + QMessageBox::critical ( parent, "Exception caught!", str ); + } +} + +void QmitkFunctionality::HandleException( std::exception& e, QWidget* parent, bool showDialog ) const +{ + HandleException( e.what(), parent, showDialog ); +} + +void QmitkFunctionality::StdMultiWidgetClosed( QmitkStdMultiWidget& /*stdMultiWidget*/ ) +{ + +} + +void QmitkFunctionality::WaitCursorOn() +{ + QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); +} + +void QmitkFunctionality::BusyCursorOn() +{ + QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); +} + +void QmitkFunctionality::WaitCursorOff() +{ + this->RestoreOverrideCursor(); +} + +void QmitkFunctionality::BusyCursorOff() +{ + this->RestoreOverrideCursor(); +} + +void QmitkFunctionality::RestoreOverrideCursor() +{ + QApplication::restoreOverrideCursor(); +} + +berry::IPreferences::Pointer QmitkFunctionality::GetPreferences() const +{ + berry::IPreferencesService::Pointer prefService = m_PreferencesService.Lock(); + // const_cast workaround for bad programming: const uncorrectness this->GetViewSite() should be const + std::string id = "/" + (const_cast(this))->GetViewSite()->GetId(); + return prefService.IsNotNull() ? prefService->GetSystemPreferences()->Node(id): berry::IPreferences::Pointer(0); +} + +void QmitkFunctionality::Visible() +{ + +} + +void QmitkFunctionality::Hidden() +{ + +} + +bool QmitkFunctionality::IsExclusiveFunctionality() const +{ + return true; +} + +void QmitkFunctionality::SetVisible( bool visible ) +{ + m_Visible = visible; +} + +void QmitkFunctionality::SetActivated( bool activated ) +{ + m_Active = activated; +} + +bool QmitkFunctionality::IsActivated() const +{ + return m_Active; +} + diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h new file mode 100755 index 0000000000..97e072497b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h @@ -0,0 +1,397 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#ifndef QMITKFUNCTIONALITY_H_ +#define QMITKFUNCTIONALITY_H_ + +#ifdef __MINGW32__ +// We need to inlclude winbase.h here in order to declare +// atomic intrinsics like InterlockedIncrement correctly. +// Otherwhise, they would be declared wrong within qatomic_windows.h . +#include +#endif + +//# blueberry stuff +#include +#include +#include + +#include + +//# mitk stuff +#include +#include "mitkDataNodeSelection.h" +#include +#include + +//# forward declarations + +namespace mitk { + class DataNode; +} + +namespace berry { + struct IBerryPreferences; +} + +class QmitkFunctionalitySelectionProvider; + +/// +/// \ingroup org_mitk_gui_qt_common_legacy +/// +/// \class QmitkFunctionality +/// +/// \brief The base class of all MITK related blueberry views (~ in the old version of MITK, this was called "Functionality") +/// +/// QmitkFunctionality provides several convenience methods that eases the introduction of a new view: +/// +///
    +///
  1. Access to the DataStorage (~ the shared data repository) +///
  2. Access to the StdMultiWidget (the 2x2 RenderWindow arrangement) +///
  3. Access to and update notification for the functionality/view preferences +///
  4. Access to and update notification for the current DataNode selection / to DataNode selection events send through the SelectionService +///
  5. Methods to send DataNode selections through the SelectionService +///
  6. Some events for unproblematic inter-View communication (e.g. when to add/remove interactors) +///
  7. Some minor important convenience methods (like changing the mouse cursor/exception handling) +///
+/// +/// Please use the Activated/Deactivated method to add/remove interactors, disabling multiwidget crosshair or anything which may +/// "affect" other functionalities. For further reading please have a look at QmitkFunctionality::IsExclusiveFunctionality(). +/// +class MITK_QT_COMMON_LEGACY QmitkFunctionality : public berry::QtViewPart +{ + +//# public virtual methods which can be overwritten +public: + /// + /// Creates smartpointer typedefs + /// + berryObjectMacro(QmitkFunctionality) + /// + /// Nothing to do in the standard ctor. Initiliaze your GUI in CreateQtPartControl(QWidget*) + /// \see berry::QtViewPart::CreateQtPartControl(QWidget*) + /// + QmitkFunctionality(); + /// + /// Disconnects all standard event listeners + /// + virtual ~QmitkFunctionality(); + /// + /// Called, when the WorkbenchPart gets closed + /// by the user directly or by closing the whole + /// app (e.g. for removing event listeners) + /// + virtual void ClosePart(); + /// + /// Called when the selection in the workbench changed + /// + virtual void OnSelectionChanged(std::vector /*nodes*/); + /// + /// Called when the preferences object of this view changed. + /// \see GetPreferences() + /// + virtual void OnPreferencesChanged(const berry::IBerryPreferences*); + /// + /// Make this view manage multiple DataStorage. If set to true GetDataStorage() + /// will return the currently active DataStorage (and not the default one). + /// \see GetDataStorage() + /// + void SetHandleMultipleDataStorages(bool multiple); + /// + /// \return true if this view handles multiple DataStorages, false otherwise + /// + bool HandlesMultipleDataStorages() const; + /// + /// Called when a StdMultiWidget is available. Should not be used anymore, see GetActiveStdMultiWidget() + /// \see GetActiveStdMultiWidget() + /// + virtual void StdMultiWidgetAvailable(QmitkStdMultiWidget& stdMultiWidget); + /// + /// Called when a StdMultiWidget is available. Should not be used anymore, see GetActiveStdMultiWidget() + /// \see GetActiveStdMultiWidget() + /// + virtual void StdMultiWidgetClosed(QmitkStdMultiWidget& stdMultiWidget); + /// + /// Called when no StdMultiWidget is available anymore. Should not be used anymore, see GetActiveStdMultiWidget() + /// \see GetActiveStdMultiWidget() + /// + virtual void StdMultiWidgetNotAvailable(); + /// + /// Only called when IsExclusiveFunctionality() returns true. + /// \see IsExclusiveFunctionality() + /// + virtual void Activated(); + /// + /// \return true if this view is currently activated, false otherwise + /// + bool IsActivated() const; + /// + /// Only called when IsExclusiveFunctionality() returns true. + /// \see IsExclusiveFunctionality() + /// + virtual void Deactivated(); + /// + /// Some functionalities need to add special interactors, removes the crosshair from the stdmultiwidget, etc. + /// In this case the functionality has to tidy up when changing to another functionality + /// which also wants to change the "default configuration". In the old Qt3-based + /// version of MITK, two functionalities could never be opened at the same time so that the + /// methods Activated() and Deactivated() were the right place for the functionalitites to + /// add/remove their interactors, etc. This is still true for the new MITK Workbench, + /// but as there can be several functionalities visible at the same time, the behaviour concerning + /// when Activated() and Deactivated() are called has changed: + /// + /// 1. Activated() and Deactivated() are only called if IsExclusiveFunctionality() returns true + /// + /// 2. If only one standalone functionality is or becomes visible, Activated() will be called on that functionality + /// + /// 3. If two or more standalone functionalities are visible, + /// Activated() will be called on the functionality that receives focus, Deactivated() will be called + /// on the one that looses focus, gets hidden or closed + /// + /// + /// As a consequence of 1. if you overwrite IsExclusiveFunctionality() and let it return false, you + /// signalize the MITK Workbench that this functionality does nothing to the "default configuration" + /// and can easily be visible while other functionalities are also visible. + /// + /// By default the method returns true. + /// + /// \return true if this functionality is meant to work as a standalone view, false otherwise + /// + virtual bool IsExclusiveFunctionality() const; + /// + /// Informs other parts of the workbench that node is selected via the blueberry selection service. + /// + void FireNodeSelected(mitk::DataNode* node); + /// + /// Informs other parts of the workbench that the nodes are selected via the blueberry selection service. + /// + void FireNodesSelected(std::vector nodes); + /// + /// Called when this functionality becomes visible ( no matter what IsExclusiveFunctionality() returns ) + /// + virtual void Visible(); + /// + /// \return true if this view is currently visible, false otherwise + /// + bool IsVisible() const; + /// + /// Called when this functionality is hidden ( no matter what IsExclusiveFunctionality() returns ) + /// + virtual void Hidden(); +//# protected virtual methods which can be overwritten +protected: + /// + /// Called when a DataStorage Add event was thrown. May be reimplemented + /// by deriving classes. + /// + virtual void NodeAdded(const mitk::DataNode* node); + /// + /// Called when a DataStorage Changed event was thrown. May be reimplemented + /// by deriving classes. + /// + virtual void NodeChanged(const mitk::DataNode* /*node*/); + /// + /// Called when a DataStorage Remove event was thrown. May be reimplemented + /// by deriving classes. + /// + virtual void NodeRemoved(const mitk::DataNode* node); + /// + /// Called when a DataStorage add *or* remove *or* change event was thrown. May be reimplemented + /// by deriving classes. + /// + virtual void DataStorageChanged(); + /// + /// \return the selection of the currently active part of the workbench or an empty vector + /// if nothing is selected + /// + std::vector GetCurrentSelection() const; + /// + /// Returns the current selection made in the datamanager bundle or an empty vector + /// if nothing`s selected or if the bundle does not exist + /// + std::vector GetDataManagerSelection() const; + /// + /// Returns the Preferences object for this Functionality. + /// Important: When refering to this preferences, e.g. in a PreferencePage: The ID + /// for this preferences object is "/", e.g. "/org.mitk.views.datamanager" + /// + berry::IPreferences::Pointer GetPreferences() const; + /// + /// Returns the default or the currently active DataStorage if m_HandlesMultipleDataStorages + /// is set to true + /// \see SetHandleMultipleDataStorages(bool) + /// \see HandlesMultipleDataStorages() + /// + mitk::DataStorage::Pointer GetDataStorage() const; + /// + /// \return always returns the default DataStorage + /// + mitk::DataStorage::Pointer GetDefaultDataStorage() const; + /// + /// Returns the default and active StdMultiWidget. + /// \param reCreateWidget a boolean flag to en-/disable the attept to re-create the StdWidget + /// If there is not StdMultiWidget yet a new one is + /// created in this method when called with default parameter! + /// + QmitkStdMultiWidget* GetActiveStdMultiWidget( bool reCreateWidget = true); + /// + /// Outputs an error message to the console and displays a message box containing + /// the exception description. + /// \param e the exception which should be handled + /// \param showDialog controls, whether additionally a message box should be + /// displayed to inform the user that something went wrong + /// + void HandleException( std::exception& e, QWidget* parent = NULL, bool showDialog = true ) const; + /// + /// Calls HandleException ( std::exception&, QWidget*, bool ) internally + /// \see HandleException ( std::exception&, QWidget*, bool ) + /// + void HandleException( const char* str, QWidget* parent = NULL, bool showDialog = true ) const; + /// + /// Convenient method to set and reset a wait cursor ("hourglass") + /// + void WaitCursorOn(); + /// + /// Convenient method to restore the standard cursor + /// + void WaitCursorOff(); + /// + /// Convenient method to set and reset a busy cursor + /// + void BusyCursorOn(); + /// + /// Convenient method to restore the standard cursor + /// + void BusyCursorOff(); + /// + /// Convenient method to restore the standard cursor + /// + void RestoreOverrideCursor(); + +//# other public methods which should not be overwritten +public: + /// + /// Creates a scroll area for this view and calls CreateQtPartControl then + /// + void CreatePartControl(void* parent); + /// + /// Called when this view receives the focus. Same as Activated() + /// \see Activated() + /// + void SetFocus(); + /// + /// Called when a DataStorage Add Event was thrown. Sets + /// m_InDataStorageChanged to true and calls NodeAdded afterwards. + /// \see m_InDataStorageChanged + /// + void NodeAddedProxy(const mitk::DataNode* node); + /// + /// Called when a DataStorage remove event was thrown. Sets + /// m_InDataStorageChanged to true and calls NodeRemoved afterwards. + /// \see m_InDataStorageChanged + /// + void NodeRemovedProxy(const mitk::DataNode* node); + /// + /// Called when a DataStorage changed event was thrown. Sets + /// m_InDataStorageChanged to true and calls NodeChanged afterwards. + /// \see m_InDataStorageChanged + /// + void NodeChangedProxy(const mitk::DataNode* node); + /// + /// Toggles the visible flag m_Visible + /// + void SetVisible(bool visible); + /// + /// Toggles the activated flag m_Activated + /// + void SetActivated(bool activated); + /// + /// Called, when the WorkbenchPart gets closed for removing event listeners + /// Internally this method calls ClosePart after it removed the listeners registered + /// by QmitkFunctionality. By having this proxy method the user does not have to + /// call QmitkFunctionality::ClosePart() when overwriting ClosePart() + /// + void ClosePartProxy(); + +//# other protected methods which should not be overwritten (or which are deprecated) +protected: + /// + /// Called immediately after CreateQtPartControl(). + /// Here standard event listeners for a QmitkFunctionality are registered + /// + void AfterCreateQtPartControl(); + /// + /// code to activate the last visible functionality + /// + void ActivateLastVisibleFunctionality(); + /// + /// reactions to selection events from data manager (and potential other senders) + /// + void BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection); + /// + /// Converts a mitk::DataNodeSelection to a std::vector (possibly empty + /// + std::vector DataNodeSelectionToVector(mitk::DataNodeSelection::ConstPointer currentSelection) const; + //# protected fields +protected: + /// + /// helper stuff to observe BlueBerry selections + /// + friend struct berry::SelectionChangedAdapter; + /// + /// Saves the parent of this view (this is the scrollarea created in CreatePartControl(void*) + /// \see CreatePartControl(void*) + /// + QWidget* m_Parent; + /// + /// Saves if this view is the currently active one. + /// + bool m_Active; + /// + /// Saves if this view is visible + /// + bool m_Visible; + +//# private fields: +private: + /// + /// Holds the current selection (selection made by this Functionality !!!) + /// + QmitkFunctionalitySelectionProvider* m_SelectionProvider; + /// + /// object to observe BlueBerry selections + /// + berry::ISelectionListener::Pointer m_BlueBerrySelectionListener; + /// + /// Saves if this view handles multiple datastorages + /// + bool m_HandlesMultipleDataStorages; + /// + /// Saves if this class is currently working on DataStorage changes. + /// This is a protector variable to avoid recursive calls on event listener functions. + bool m_InDataStorageChanged; + /// + /// saves all visible functionalities + /// + std::set m_VisibleFunctionalities; + /// + /// The Preferences Service to retrieve and store preferences. + /// + berry::IPreferencesService::WeakPtr m_PreferencesService; +}; + +#endif /*QMITKFUNCTIONALITY_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality2.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkFunctionality2.cpp rename to Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp new file mode 100644 index 0000000000..691f0904bb --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp @@ -0,0 +1,223 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkFunctionalityCoordinator.h" +#include "QmitkFunctionality.h" +#include +#include +#include + +#include + +QmitkFunctionalityCoordinator::QmitkFunctionalityCoordinator() + : m_StandaloneFuntionality(0) +{ +} + +void QmitkFunctionalityCoordinator::Start() +{ + berry::PlatformUI::GetWorkbench()->AddWindowListener(berry::IWindowListener::Pointer(this)); + std::vector wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); + for (std::vector::iterator i = wnds.begin(); + i != wnds.end(); ++i) + { + (*i)->GetPartService()->AddPartListener(berry::IPartListener::Pointer(this)); + } +} + +void QmitkFunctionalityCoordinator::Stop() +{ + if (!berry::PlatformUI::IsWorkbenchRunning()) return; + + berry::PlatformUI::GetWorkbench()->RemoveWindowListener(berry::IWindowListener::Pointer(this)); + std::vector wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); + for (std::vector::iterator i = wnds.begin(); + i != wnds.end(); ++i) + { + (*i)->GetPartService()->RemovePartListener(berry::IPartListener::Pointer(this)); + } +} + +QmitkFunctionalityCoordinator::~QmitkFunctionalityCoordinator() +{ +} + +berry::IPartListener::Events::Types QmitkFunctionalityCoordinator::GetPartEventTypes() const +{ + return berry::IPartListener::Events::ACTIVATED | berry::IPartListener::Events::DEACTIVATED + | berry::IPartListener::Events::CLOSED | berry::IPartListener::Events::HIDDEN + | berry::IPartListener::Events::VISIBLE | berry::IPartListener::Events::OPENED; +} + +void QmitkFunctionalityCoordinator::PartActivated( berry::IWorkbenchPartReference::Pointer partRef ) +{ + // change the active standalone functionality + this->ActivateStandaloneFunctionality(partRef.GetPointer()); +} + +void QmitkFunctionalityCoordinator::PartDeactivated( berry::IWorkbenchPartReference::Pointer /*partRef*/ ) +{ + // nothing to do here: see PartActivated() +} + +void QmitkFunctionalityCoordinator::PartOpened( berry::IWorkbenchPartReference::Pointer partRef ) +{ + // check for multiwidget and inform views that it is available now + if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) + { + for (std::set::iterator it = m_Functionalities.begin() + ; it != m_Functionalities.end(); it++) + { + (*it)->StdMultiWidgetAvailable(*(partRef + ->GetPart(false).Cast()->GetStdMultiWidget())); + } + } + else + { + // Check for QmitkFunctionality + QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); + if(_QmitkFunctionality.IsNotNull()) + { + m_Functionalities.insert(_QmitkFunctionality.GetPointer()); // save as opened functionality + } + } +} + +void QmitkFunctionalityCoordinator::PartClosed( berry::IWorkbenchPartReference::Pointer partRef ) +{ + // check for multiwidget and inform views that it not available any more + if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) + { + + QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); + for (std::set::iterator it = m_Functionalities.begin() + ; it != m_Functionalities.end(); it++) + { + (*it)->StdMultiWidgetClosed(*(stdMultiWidgetEditor->GetStdMultiWidget())); + (*it)->StdMultiWidgetNotAvailable(); // deprecated call, provided for consistence + } + } + else + { + // check for functionality + QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); + if(_QmitkFunctionality.IsNotNull()) + { + // deactivate on close ( the standalone functionality may still be activated ) + this->DeactivateStandaloneFunctionality(partRef.GetPointer(), 0); + + // and set pointer to 0 + if(m_StandaloneFuntionality == partRef.GetPointer()) + m_StandaloneFuntionality = 0; + + m_Functionalities.erase(_QmitkFunctionality.GetPointer()); // remove as opened functionality + + // call PartClosed on the QmitkFunctionality + _QmitkFunctionality->ClosePartProxy(); + //m_VisibleStandaloneFunctionalities.erase(_QmitkFunctionality.GetPointer()); // remove if necessary (should be done before in PartHidden() + } + } +} + +void QmitkFunctionalityCoordinator::PartHidden( berry::IWorkbenchPartReference::Pointer partRef ) +{ + // Check for QmitkFunctionality + QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); + if(_QmitkFunctionality != 0) + { + _QmitkFunctionality->SetVisible(false); + _QmitkFunctionality->Hidden(); + + // tracking of Visible Standalone Functionalities + m_VisibleStandaloneFunctionalities.erase(partRef.GetPointer()); + + // activate Functionality if just one Standalone Functionality is visible + if( m_VisibleStandaloneFunctionalities.size() == 1 ) + this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); + } +} + +void QmitkFunctionalityCoordinator::PartVisible( berry::IWorkbenchPartReference::Pointer partRef ) +{ + // Check for QmitkFunctionality + QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); + if(_QmitkFunctionality.IsNotNull()) + { + _QmitkFunctionality->SetVisible(true); + _QmitkFunctionality->Visible(); + + // tracking of Visible Standalone Functionalities + if( _QmitkFunctionality->IsExclusiveFunctionality() ) + { + m_VisibleStandaloneFunctionalities.insert(partRef.GetPointer()); + + // activate Functionality if just one Standalone Functionality is visible + if( m_VisibleStandaloneFunctionalities.size() == 1 ) + this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); + } + } +} + +void QmitkFunctionalityCoordinator::ActivateStandaloneFunctionality( berry::IWorkbenchPartReference* partRef ) +{ + QmitkFunctionality* functionality = dynamic_cast(partRef->GetPart(false).GetPointer()); + if( functionality && !functionality->IsActivated() && functionality->IsExclusiveFunctionality() ) + { + MITK_INFO << "**** Activating legacy standalone functionality"; + // deactivate old one if necessary + this->DeactivateStandaloneFunctionality(m_StandaloneFuntionality, partRef); + m_StandaloneFuntionality = partRef; + + MITK_INFO << "setting active flag"; + // call activated on this functionality + functionality->SetActivated(true); + functionality->Activated(); + } + else if (dynamic_cast(partRef->GetPart(false).GetPointer()) && + m_StandaloneFuntionality != partRef) + { + this->DeactivateStandaloneFunctionality(m_StandaloneFuntionality, partRef); + m_StandaloneFuntionality = partRef; + } +} + +void QmitkFunctionalityCoordinator::DeactivateStandaloneFunctionality(berry::IWorkbenchPartReference* partRef, + berry::IWorkbenchPartReference* newRef) +{ + if (partRef == 0) return; + + QmitkFunctionality* functionality = dynamic_cast(partRef->GetPart(false).GetPointer()); + if(functionality && functionality->IsActivated()) + { + functionality->SetActivated(false); + functionality->Deactivated(); + } + else if (mitk::IZombieViewPart* zombie = dynamic_cast(partRef->GetPart(false).GetPointer())) + { + zombie->ActivatedZombieView(berry::IWorkbenchPartReference::Pointer(newRef)); + } +} + +void QmitkFunctionalityCoordinator::WindowClosed( berry::IWorkbenchWindow::Pointer /*window*/ ) +{ + +} + +void QmitkFunctionalityCoordinator::WindowOpened( berry::IWorkbenchWindow::Pointer window ) +{ + window->GetPartService()->AddPartListener(berry::IPartListener::Pointer(this)); +} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h new file mode 100644 index 0000000000..528e7180ec --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h @@ -0,0 +1,124 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ +Version: $Revision: 21070 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QmitkFunctionalityCoordinator_h +#define QmitkFunctionalityCoordinator_h + +#include +#include +#include + +#include +#include + +class QmitkFunctionality; + +/// +/// \ingroup org_mitk_gui_qt_common_legacy +/// +/// A class which coordinates active QmitkFunctionalities, e.g. calling activated and hidden on them. +/// +class MITK_QT_COMMON_LEGACY QmitkFunctionalityCoordinator : virtual public berry::IPartListener, virtual public berry::IWindowListener +{ +public: + berryObjectMacro(QmitkFunctionalityCoordinator); + berryNewMacro(QmitkFunctionalityCoordinator); + + QmitkFunctionalityCoordinator(); + + virtual ~QmitkFunctionalityCoordinator(); + + /// + /// Add listener + /// + void Start(); + + /// + /// Remove listener + /// + void Stop(); + + //#IPartListener methods (these methods internally call Activated() or other similar methods) + /// + /// \see IPartListener::GetPartEventTypes() + /// + berry::IPartListener::Events::Types GetPartEventTypes() const; + /// + /// \see IPartListener::PartActivated() + /// + virtual void PartActivated (berry::IWorkbenchPartReference::Pointer partRef); + /// + /// \see IPartListener::PartDeactivated() + /// + virtual void PartDeactivated(berry::IWorkbenchPartReference::Pointer /*partRef*/); + /// + /// \see IPartListener::PartOpened() + /// + virtual void PartOpened(berry::IWorkbenchPartReference::Pointer partRef); + /// + /// \see IPartListener::PartClosed() + /// + virtual void PartClosed (berry::IWorkbenchPartReference::Pointer partRef); + /// + /// \see IPartListener::PartHidden() + /// + virtual void PartHidden (berry::IWorkbenchPartReference::Pointer partRef); + /// + /// \see IPartListener::PartVisible() + /// + virtual void PartVisible (berry::IWorkbenchPartReference::Pointer partRef); + + /** + * Notifies this listener that the given window has been closed. + */ + virtual void WindowClosed(berry::IWorkbenchWindow::Pointer window); + + /** + * Notifies this listener that the given window has been opened. + */ + virtual void WindowOpened(berry::IWorkbenchWindow::Pointer /*window*/); + +protected: + /// + /// Activates the standalone functionality + /// + void ActivateStandaloneFunctionality(berry::IWorkbenchPartReference *partRef); + /// + /// Deactivates the standalone functionality + /// + void DeactivateStandaloneFunctionality(berry::IWorkbenchPartReference *functionality, berry::IWorkbenchPartReference *newRef); + /// + /// Saves the workbench window + /// + berry::IWorkbenchWindow::WeakPtr m_Window; + /// + /// Saves the last part that added interactors + /// + berry::IWorkbenchPartReference* m_StandaloneFuntionality; + + /// + /// Saves all opened QmitkFclassunctionalities + /// + std::set m_Functionalities; + /// + /// Saves all visible QmitkFunctionalities + /// + std::set m_VisibleStandaloneFunctionalities; +}; + +#endif // QmitkFunctionalityCoordinator_h diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp new file mode 100644 index 0000000000..5f2a25d2a0 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp @@ -0,0 +1,51 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkCommonLegacyActivator.h" + +#include + +#include + +#include + +void +QmitkCommonLegacyActivator::start(ctkPluginContext* context) +{ + Q_UNUSED(context) + + if(berry::PlatformUI::IsWorkbenchRunning()) + { + m_FunctionalityCoordinator = QmitkFunctionalityCoordinator::Pointer(new QmitkFunctionalityCoordinator); + m_FunctionalityCoordinator->Start(); + } + else + { + MITK_ERROR << "BlueBerry Workbench not running!"; + } +} + +void +QmitkCommonLegacyActivator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + + m_FunctionalityCoordinator->Stop(); + m_FunctionalityCoordinator = 0; +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_common_legacy, QmitkCommonLegacyActivator) diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h new file mode 100644 index 0000000000..c841521baa --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h @@ -0,0 +1,49 @@ +/*========================================================================= + + Program: MITK Platform + Language: C++ + Date: $Date$ + Version: $Revision: 17020 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKCOMMONLEGACYACTIVATOR_H_ +#define QMITKCOMMONLEGACYACTIVATOR_H_ + +#include + +#include "QmitkFunctionalityCoordinator.h" + +/** + * \ingroup org_mitk_gui_qt_common_legacy_internal + */ +class QmitkCommonLegacyActivator : public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + /** + * Sets default StateMachine to EventMapper. + */ + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + +private: + + QmitkFunctionalityCoordinator::Pointer m_FunctionalityCoordinator; + +}; + +#endif /* QMITKCOMMONLEGACYACTIVATOR_H_ */ + diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkFunctionalityUtil.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkFunctionalityUtil.cpp rename to Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkFunctionalityUtil.h b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkFunctionalityUtil.h rename to Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/CMakeLists.txt b/Plugins/org.mitk.gui.qt.common/CMakeLists.txt similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.common/CMakeLists.txt diff --git a/Plugins/org.mitk.gui.qt.common/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.common/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..a9b4ee94e6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_common org.mitk.gui.qt.common + \ingroup MITKPlugins + + \brief Provides Qt GUI specific utility classes for MITK View and Editor developers. + +*/ + +/** + \defgroup org_mitk_gui_qt_common_internal Internal + \ingroup org_mitk_gui_qt_common + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.common plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.common/files.cmake b/Plugins/org.mitk.gui.qt.common/files.cmake new file mode 100755 index 0000000000..d3c3feebdf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/files.cmake @@ -0,0 +1,36 @@ +SET(SRC_CPP_FILES + QmitkAbstractRenderEditor.cpp + QmitkAbstractView.cpp + QmitkDataNodeSelectionProvider.cpp + QmitkDnDFrameWidget.cpp +) + +SET(INTERNAL_CPP_FILES + QmitkCommonActivator.cpp + QmitkDataNodeItemModel.cpp + QmitkDataNodeSelection.cpp + QmitkViewCoordinator.cpp +) + +SET(MOC_H_FILES + src/QmitkAbstractRenderEditor.h + src/QmitkDnDFrameWidget.h + + src/internal/QmitkCommonActivator.h +) + +SET(CACHED_RESOURCE_FILES +) + +SET(QRC_FILES +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.common/manifest_headers.cmake similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/manifest_headers.cmake rename to Plugins/org.mitk.gui.qt.common/manifest_headers.cmake diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractRenderEditor.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractRenderEditor.cpp new file mode 100644 index 0000000000..202dddc085 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractRenderEditor.cpp @@ -0,0 +1,147 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "QmitkAbstractRenderEditor.h" +#include "internal/QmitkCommonActivator.h" + +#include +#include + +#include +#include + +#include + +class QmitkAbstractRenderEditorPrivate +{ +public: + + QmitkAbstractRenderEditorPrivate() + : m_RenderingManagerInterface(mitk::MakeRenderingManagerInterface(mitk::RenderingManager::GetInstance())) + , m_PrefServiceTracker(QmitkCommonActivator::GetContext()) + { + m_PrefServiceTracker.open(); + } + + ~QmitkAbstractRenderEditorPrivate() + { + delete m_RenderingManagerInterface; + } + + mitk::IRenderingManager* m_RenderingManagerInterface; + ctkServiceTracker m_PrefServiceTracker; + berry::IBerryPreferences::Pointer m_Prefs; +}; + +QmitkAbstractRenderEditor::QmitkAbstractRenderEditor() + : d(new QmitkAbstractRenderEditorPrivate) +{ +} + +QmitkAbstractRenderEditor::~QmitkAbstractRenderEditor() +{ + if (d->m_Prefs.IsNotNull()) + { + d->m_Prefs->OnChanged.RemoveListener(berry::MessageDelegate1 + (this, &QmitkAbstractRenderEditor::OnPreferencesChanged ) ); + } +} + +void QmitkAbstractRenderEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) +{ + if (input.Cast().IsNull()) + throw berry::PartInitException("Invalid Input: Must be mitk::DataStorageEditorInput"); + + this->SetSite(site); + this->SetInput(input); + + d->m_Prefs = this->GetPreferences().Cast(); + if (d->m_Prefs.IsNotNull()) + { + d->m_Prefs->OnChanged.AddListener(berry::MessageDelegate1 + (this, &QmitkAbstractRenderEditor::OnPreferencesChanged ) ); + } +} + +mitk::IDataStorageReference::Pointer QmitkAbstractRenderEditor::GetDataStorageReference() const +{ + mitk::DataStorageEditorInput::Pointer input = this->GetEditorInput().Cast(); + if (input.IsNotNull()) + { + return input->GetDataStorageReference(); + } + return mitk::IDataStorageReference::Pointer(0); +} + +mitk::DataStorage::Pointer QmitkAbstractRenderEditor::GetDataStorage() const +{ + mitk::IDataStorageReference::Pointer ref = this->GetDataStorageReference(); + if (ref.IsNotNull()) return ref->GetDataStorage(); + return mitk::DataStorage::Pointer(0); +} + +berry::IPreferences::Pointer QmitkAbstractRenderEditor::GetPreferences() const +{ + berry::IPreferencesService* prefService = d->m_PrefServiceTracker.getService(); + if (prefService != 0) + { + return prefService->GetSystemPreferences()->Node(this->GetSite()->GetId()); + } + return berry::IPreferences::Pointer(0); +} + +mitk::IRenderingManager* QmitkAbstractRenderEditor::GetRenderingManager() const +{ + // we use the global rendering manager here. This should maybe replaced + // by a local one, managing only the render windows specific for the editor + return d->m_RenderingManagerInterface; +} + +void QmitkAbstractRenderEditor::RequestUpdate(mitk::RenderingManager::RequestType requestType) +{ + if (GetRenderingManager()) + GetRenderingManager()->RequestUpdateAll(requestType); +} + +void QmitkAbstractRenderEditor::ForceImmediateUpdate(mitk::RenderingManager::RequestType requestType) +{ + if (GetRenderingManager()) + GetRenderingManager()->ForceImmediateUpdateAll(requestType); +} + +mitk::SliceNavigationController* QmitkAbstractRenderEditor::GetTimeNavigationController() const +{ + if (GetRenderingManager()) + return GetRenderingManager()->GetTimeNavigationController(); + return 0; +} + +void QmitkAbstractRenderEditor::OnPreferencesChanged(const berry::IBerryPreferences *) +{} + +void QmitkAbstractRenderEditor::DoSave() +{} + +void QmitkAbstractRenderEditor::DoSaveAs() +{} + +bool QmitkAbstractRenderEditor::IsDirty() const +{ return false; } + +bool QmitkAbstractRenderEditor::IsSaveAsAllowed() const +{ return false; } diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractRenderEditor.h b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractRenderEditor.h new file mode 100644 index 0000000000..4af4a520ca --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractRenderEditor.h @@ -0,0 +1,158 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITKABSTRACTRENDEREDITOR_H +#define QMITKABSTRACTRENDEREDITOR_H + +#include +#include + +#include "mitkIRenderWindowPart.h" + +#include +#include + +#include + +class QmitkAbstractRenderEditorPrivate; + +/** + * \ingroup org_mitk_gui_qt_common + * + * \brief A convenient base class for MITK render window BlueBerry Editors. + * + * QmitkAbstractRenderEditor provides several convenience methods that ease the introduction of + * a new editor for rendering a MITK DataStorage: + * + *
    + *
  1. Access to the DataStorage (~ the shared data repository) + *
  2. Access to and update notification for the editor's preferences + *
  3. Default implementation of some mitk::IRenderWindowPart methods + *
+ * + * When inheriting from QmitkAbstractRenderEditor, you must implement the following methods: + *
    + *
  • void CreateQtPartControl(QWidget* parent) + *
  • void SetFocus() + *
+ * + * You may reimplement the following private virtual methods to be notified about certain changes: + *
    + *
  • void OnPreferencesChanged(const berry::IBerryPreferences*) + *
+ * + * \see IRenderWindowPart + * \see ILinkedRenderWindowPart + */ +class MITK_QT_COMMON QmitkAbstractRenderEditor : public berry::QtEditorPart, + public virtual mitk::IRenderWindowPart +{ + Q_OBJECT + Q_INTERFACES(mitk::IRenderWindowPart) + +public: + + QmitkAbstractRenderEditor(); + ~QmitkAbstractRenderEditor(); + +protected: + + /** + * Initializes this editor by checking for a valid mitk::DataStorageEditorInput as input. + * + * \see berry::IEditorPart::Init + */ + void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input); + + /** + * Get a reference to the DataStorage set by the editor input. + */ + virtual mitk::IDataStorageReference::Pointer GetDataStorageReference() const; + + /** + * Get the DataStorage set by the editor input. + */ + virtual mitk::DataStorage::Pointer GetDataStorage() const; + + /** + * Get the preferences for this editor. + */ + virtual berry::IPreferences::Pointer GetPreferences() const; + + /** + * Get the RenderingManager used by this editor. This default implementation uses the + * global MITK RenderingManager provided by mitk::RenderingManager::GetInstance(). + * + * \see mitk::IRenderWindowPart::GetRenderingManager + */ + mitk::IRenderingManager* GetRenderingManager() const; + + /** + * Request an update of this editor's render windows. + * This implementation calls mitk::IRenderingManager::RequestUpdate on the rendering + * manager interface returned by GetRenderingManager(); + * + * \param requestType The type of render windows for which an update is requested. + * + * \see mitk::IRenderWindowPart::RequestUpdate + */ + void RequestUpdate(mitk::RenderingManager::RequestType requestType = mitk::RenderingManager::REQUEST_UPDATE_ALL); + + /** + * Force an immediate update of this editor's render windows. + * This implementation calls mitk::IRenderingManager::ForceImmediateUpdate() on the rendering + * manager interface returned by GetRenderingManager(); + * + * \param requestType The type of render windows for which an immedate update is forced. + * + * \see mitk::IRenderWindowPart::ForceImmediateUpdate + */ + void ForceImmediateUpdate(mitk::RenderingManager::RequestType requestType = mitk::RenderingManager::REQUEST_UPDATE_ALL); + + /** + * Get the time navigation controller for this editor. + * This implementation returns the SliceNavigationController returned by the mitk::IRenderingManager::GetTimeNavigationController() + * method of the interface implementation returned by GetRenderingManager(). + * + * \see mitk::IRenderingManager::GetTimeNavigationController + */ + mitk::SliceNavigationController* GetTimeNavigationController() const; + + /** \see berry::IEditorPart::DoSave */ + void DoSave(); + + /** \see berry::IEditorPart::DoSaveAs */ + void DoSaveAs(); + + /** \see berry::IEditorPart::IsDirty */ + bool IsDirty() const; + + /** \see berry::IEditorPart::IsSaveAsAllowed */ + bool IsSaveAsAllowed() const; + +private: + + virtual void OnPreferencesChanged(const berry::IBerryPreferences*); + +private: + + QScopedPointer d; + +}; + +#endif // QMITKABSTRACTRENDEREDITOR_H diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.cpp new file mode 100644 index 0000000000..423053e073 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.cpp @@ -0,0 +1,561 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkAbstractView.h" +#include "QmitkDataNodeSelectionProvider.h" +#include "internal/QmitkCommonActivator.h" +#include "internal/QmitkDataNodeItemModel.h" + +// mitk Includes +#include +#include +#include +#include +#include +#include + +// berry Includes +#include +#include +#include + +// CTK Includes +#include + +// Qt Includes +#include +#include +#include +#include +#include + +class QmitkAbstractViewPrivate +{ +public: + + QmitkAbstractViewPrivate(QmitkAbstractView* qq) + : q(qq) + , m_PrefServiceTracker(QmitkCommonActivator::GetContext()) + , m_DataStorageServiceTracker(QmitkCommonActivator::GetContext()) + , m_Parent(0) + , m_DataNodeItemModel(new QmitkDataNodeItemModel) + , m_DataNodeSelectionModel(new QItemSelectionModel(m_DataNodeItemModel)) + , m_InDataStorageChanged(false) + { + m_PrefServiceTracker.open(); + m_DataStorageServiceTracker.open(); + } + + ~QmitkAbstractViewPrivate() + { + delete m_DataNodeSelectionModel; + delete m_DataNodeItemModel; + + m_PrefServiceTracker.close(); + m_DataStorageServiceTracker.close(); + } + + /** + * Called when a DataStorage Add Event was thrown. Sets + * m_InDataStorageChanged to true and calls NodeAdded afterwards. + * \see m_InDataStorageChanged + */ + void NodeAddedProxy(const mitk::DataNode* node) + { + // garantuee no recursions when a new node event is thrown in NodeAdded() + if(!m_InDataStorageChanged) + { + m_InDataStorageChanged = true; + q->NodeAdded(node); + q->DataStorageModified(); + m_InDataStorageChanged = false; + } + } + + /** + * Called when a DataStorage remove event was thrown. Sets + * m_InDataStorageChanged to true and calls NodeRemoved afterwards. + * \see m_InDataStorageChanged + */ + void NodeRemovedProxy(const mitk::DataNode* node) + { + // garantuee no recursions when a new node event is thrown in NodeAdded() + if(!m_InDataStorageChanged) + { + m_InDataStorageChanged = true; + q->NodeRemoved(node); + q->DataStorageModified(); + m_InDataStorageChanged = false; + } + } + + /** + * Called when a DataStorage changed event was thrown. Sets + * m_InDataStorageChanged to true and calls NodeChanged afterwards. + * \see m_InDataStorageChanged + */ + void NodeChangedProxy(const mitk::DataNode* node) + { + // garantuee no recursions when a new node event is thrown in NodeAdded() + if(!m_InDataStorageChanged) + { + m_InDataStorageChanged = true; + q->NodeChanged(node); + q->DataStorageModified(); + m_InDataStorageChanged = false; + } + } + + /** + * reactions to selection events from data manager (and potential other senders) + */ + void BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection) + { + if(sourcepart.IsNull() || sourcepart->GetSite()->GetId() != "org.mitk.views.datamanager") + return; + + mitk::DataNodeSelection::ConstPointer _DataNodeSelection + = selection.Cast(); + q->OnSelectionChanged(sourcepart, this->DataNodeSelectionToQList(_DataNodeSelection)); + } + + /** + * Converts a mitk::DataNodeSelection to a QList (possibly empty) + */ + QList DataNodeSelectionToQList(mitk::DataNodeSelection::ConstPointer currentSelection) const; + + QmitkAbstractView* const q; + + ctkServiceTracker m_PrefServiceTracker; + + ctkServiceTracker m_DataStorageServiceTracker; + + /** + * Saves the parent of this view (this is the scrollarea created in CreatePartControl(void*) + * \see CreatePartControl(void*) + */ + QWidget* m_Parent; + + /** + * Holds the current selection (selection made by this View !!!) + */ + QmitkDataNodeSelectionProvider::Pointer m_SelectionProvider; + + /** + * Holds a helper model for firing selection events. + */ + QmitkDataNodeItemModel* m_DataNodeItemModel; + + /** + * The selection model for the QmitkDataNodeItemModel; + */ + QItemSelectionModel* m_DataNodeSelectionModel; + + /** + * object to observe BlueBerry selections + */ + berry::ISelectionListener::Pointer m_BlueBerrySelectionListener; + + /** + * Saves if this class is currently working on DataStorage changes. + * This is a protector variable to avoid recursive calls on event listener functions. + */ + bool m_InDataStorageChanged; + +}; + +QmitkAbstractView::QmitkAbstractView() + : d(new QmitkAbstractViewPrivate(this)) +{ +} + +void QmitkAbstractView::CreatePartControl(void* parent) +{ + + // scrollArea + QScrollArea* scrollArea = new QScrollArea; + //QVBoxLayout* scrollAreaLayout = new QVBoxLayout(scrollArea); + scrollArea->setFrameShadow(QFrame::Plain); + scrollArea->setFrameShape(QFrame::NoFrame); + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + // m_Parent + d->m_Parent = new QWidget; + //m_Parent->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + this->CreateQtPartControl(d->m_Parent); + + //scrollAreaLayout->addWidget(m_Parent); + //scrollArea->setLayout(scrollAreaLayout); + + // set the widget now + scrollArea->setWidgetResizable(true); + scrollArea->setWidget(d->m_Parent); + + // add the scroll area to the real parent (the view tabbar) + QWidget* parentQWidget = static_cast(parent); + QVBoxLayout* parentLayout = new QVBoxLayout(parentQWidget); + parentLayout->setMargin(0); + parentLayout->setSpacing(0); + parentLayout->addWidget(scrollArea); + + // finally set the layout containing the scroll area to the parent widget (= show it) + parentQWidget->setLayout(parentLayout); + + this->AfterCreateQtPartControl(); +} + +void QmitkAbstractView::AfterCreateQtPartControl() +{ + this->SetSelectionProvider(); + + // REGISTER DATASTORAGE LISTENER + this->GetDataStorage()->AddNodeEvent.AddListener( mitk::MessageDelegate1 + ( d.data(), &QmitkAbstractViewPrivate::NodeAddedProxy ) ); + this->GetDataStorage()->ChangedNodeEvent.AddListener( mitk::MessageDelegate1 + ( d.data(), &QmitkAbstractViewPrivate::NodeChangedProxy ) ); + this->GetDataStorage()->RemoveNodeEvent.AddListener( mitk::MessageDelegate1 + ( d.data(), &QmitkAbstractViewPrivate::NodeRemovedProxy ) ); + + // REGISTER PREFERENCES LISTENER + berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); + if(prefs.IsNotNull()) + prefs->OnChanged.AddListener( + berry::MessageDelegate1(this, + &QmitkAbstractView::OnPreferencesChanged)); + + // REGISTER FOR WORKBENCH SELECTION EVENTS + d->m_BlueBerrySelectionListener = berry::ISelectionListener::Pointer( + new berry::SelectionChangedAdapter(d.data(), + &QmitkAbstractViewPrivate::BlueBerrySelectionChanged)); + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ d->m_BlueBerrySelectionListener); + + // EMULATE INITIAL SELECTION EVENTS + + // send the current selection + berry::IWorkbenchPart::Pointer activePart = this->GetSite()->GetPage()->GetActivePart(); + if (activePart.IsNotNull()) + { + this->OnSelectionChanged(activePart, this->GetCurrentSelection()); + } + + // send preferences changed event + this->OnPreferencesChanged(this->GetPreferences().Cast().GetPointer()); +} + +QmitkAbstractView::~QmitkAbstractView() +{ + this->Register(); + + this->GetDataStorage()->AddNodeEvent.RemoveListener( mitk::MessageDelegate1 + ( d.data(), &QmitkAbstractViewPrivate::NodeAddedProxy ) ); + this->GetDataStorage()->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1 + ( d.data(), &QmitkAbstractViewPrivate::NodeRemovedProxy) ); + this->GetDataStorage()->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1 + ( d.data(), &QmitkAbstractViewPrivate::NodeChangedProxy ) ); + + berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); + if(prefs.IsNotNull()) + { + prefs->OnChanged.RemoveListener( + berry::MessageDelegate1(this, + &QmitkAbstractView::OnPreferencesChanged)); + // flush the preferences here (disabled, everyone should flush them by themselves at the right moment) + // prefs->Flush(); + } + + // REMOVE SELECTION PROVIDER + this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(NULL)); + + berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); + if(s) + { + s->RemovePostSelectionListener(d->m_BlueBerrySelectionListener); + } + + this->UnRegister(false); +} + +void QmitkAbstractView::SetSelectionProvider() +{ + // REGISTER A SELECTION PROVIDER + d->m_SelectionProvider = QmitkDataNodeSelectionProvider::Pointer(new QmitkDataNodeSelectionProvider); + d->m_SelectionProvider->SetItemSelectionModel(GetDataNodeSelectionModel()); + this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(d->m_SelectionProvider)); +} + +QItemSelectionModel *QmitkAbstractView::GetDataNodeSelectionModel() const +{ + return d->m_DataNodeSelectionModel; +} + +void QmitkAbstractView::OnPreferencesChanged( const berry::IBerryPreferences* ) +{ +} + +void QmitkAbstractView::DataStorageModified() +{ +} + +void QmitkAbstractView::DataStorageChanged(mitk::IDataStorageReference::Pointer /*dsRef*/) +{ +} + +mitk::IRenderWindowPart* QmitkAbstractView::GetRenderWindowPart( IRenderWindowPartStrategies strategies ) const +{ + berry::IWorkbenchPage::Pointer page = this->GetSite()->GetPage(); + + // Return the active editor if it implements mitk::IRenderWindowPart + mitk::IRenderWindowPart* renderPart = + dynamic_cast(page->GetActiveEditor().GetPointer()); + if (renderPart) return renderPart; + + // No suitable active editor found, check visible editors + std::list editors = page->GetEditorReferences(); + for (std::list::iterator i = editors.begin(); + i != editors.end(); ++i) + { + berry::IWorkbenchPart::Pointer part = (*i)->GetPart(false); + if (page->IsPartVisible(part)) + { + renderPart = dynamic_cast(part.GetPointer()); + if (renderPart) return renderPart; + } + } + + // No suitable visible editor found, check visible views + std::vector views = page->GetViewReferences(); + for(std::vector::iterator i = views.begin(); + i != views.end(); ++i) + { + berry::IWorkbenchPart::Pointer part = (*i)->GetPart(false); + if (page->IsPartVisible(part)) + { + renderPart = dynamic_cast(part.GetPointer()); + if (renderPart) return renderPart; + } + } + + // No strategies given + if (strategies == NONE) return 0; + + mitk::DataStorageEditorInput::Pointer input(new mitk::DataStorageEditorInput(GetDataStorageReference())); + + bool activate = false; + if(strategies & ACTIVATE) + { + activate = true; + } + + berry::IEditorPart::Pointer editorPart; + + if(strategies & OPEN) + { + // This will create a default editor for the given input. If an editor + // with that input is already open, the editor is brought to the front. + editorPart = mitk::WorkbenchUtil::OpenEditor(page, input, activate); + } + else if (activate || (strategies & BRING_TO_FRONT)) + { + // check if a suitable editor is already opened + editorPart = page->FindEditor(input); + if (activate) + { + page->Activate(editorPart); + } + else + { + page->BringToTop(editorPart); + } + } + + return dynamic_cast(editorPart.GetPointer()); +} + +void QmitkAbstractView::RequestRenderWindowUpdate(mitk::RenderingManager::RequestType requestType) +{ + mitk::IRenderWindowPart* renderPart = this->GetRenderWindowPart(); + if (renderPart == 0) return; + + if (mitk::IRenderingManager* renderingManager = renderPart->GetRenderingManager()) + { + renderingManager->RequestUpdateAll(requestType); + } + else + { + renderPart->RequestUpdate(requestType); + } +} + +void QmitkAbstractView::HandleException( const char* str, QWidget* parent, bool showDialog ) const +{ + //itkGenericOutputMacro( << "Exception caught: " << str ); + MITK_ERROR << str; + if ( showDialog ) + { + QMessageBox::critical ( parent, "Exception caught!", str ); + } +} + +void QmitkAbstractView::HandleException( std::exception& e, QWidget* parent, bool showDialog ) const +{ + HandleException( e.what(), parent, showDialog ); +} + +void QmitkAbstractView::WaitCursorOn() +{ + QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); +} + +void QmitkAbstractView::BusyCursorOn() +{ + QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); +} + +void QmitkAbstractView::WaitCursorOff() +{ + this->RestoreOverrideCursor(); +} + +void QmitkAbstractView::BusyCursorOff() +{ + this->RestoreOverrideCursor(); +} + +void QmitkAbstractView::RestoreOverrideCursor() +{ + QApplication::restoreOverrideCursor(); +} + +berry::IPreferences::Pointer QmitkAbstractView::GetPreferences() const +{ + berry::IPreferencesService* prefService = d->m_PrefServiceTracker.getService(); + // const_cast workaround for bad programming: const uncorrectness this->GetViewSite() should be const + std::string id = "/" + (const_cast(this))->GetViewSite()->GetId(); + return prefService ? prefService->GetSystemPreferences()->Node(id): berry::IPreferences::Pointer(0); +} + +mitk::DataStorage::Pointer +QmitkAbstractView::GetDataStorage() const +{ + mitk::IDataStorageService* dsService = d->m_DataStorageServiceTracker.getService(); + + if (dsService != 0) + { + return dsService->GetDataStorage()->GetDataStorage(); + } + + return 0; +} + +mitk::IDataStorageReference::Pointer QmitkAbstractView::GetDataStorageReference() const +{ + mitk::IDataStorageService* dsService = d->m_DataStorageServiceTracker.getService(); + + if (dsService != 0) + { + return dsService->GetDataStorage(); + } + + return mitk::IDataStorageReference::Pointer(0); +} + +QList QmitkAbstractView::GetCurrentSelection() const +{ + berry::ISelection::ConstPointer selection( this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection()); + // buffer for the data manager selection + mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); + return d->DataNodeSelectionToQList(currentSelection); +} + +QList QmitkAbstractView::GetDataManagerSelection() const +{ + berry::ISelection::ConstPointer selection( this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + // buffer for the data manager selection + mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); + return d->DataNodeSelectionToQList(currentSelection); +} + +void QmitkAbstractView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, + const QList& /*nodes*/) +{ +} + +QList QmitkAbstractViewPrivate::DataNodeSelectionToQList(mitk::DataNodeSelection::ConstPointer currentSelection) const +{ + QList selectedNodes; + if(currentSelection.IsNull()) + return selectedNodes; + + mitk::DataNodeObject::Pointer _DataNodeObject; + mitk::DataNode::Pointer _DataNode; + + for(mitk::DataNodeSelection::iterator it = currentSelection->Begin(); + it != currentSelection->End(); ++it) + { + _DataNodeObject = it->Cast(); + if(_DataNodeObject.IsNotNull()) + { + _DataNode = _DataNodeObject->GetDataNode(); + if(_DataNode.IsNotNull()) + selectedNodes << _DataNode; + } + } + + return selectedNodes; +} + + +void QmitkAbstractView::NodeAdded( const mitk::DataNode* /*node*/ ) +{ +} + +void QmitkAbstractView::NodeRemoved( const mitk::DataNode* /*node*/ ) +{ +} + +void QmitkAbstractView::NodeChanged( const mitk::DataNode* /*node*/ ) +{ +} + +void QmitkAbstractView::FireNodeSelected( mitk::DataNode::Pointer node ) +{ + QList nodes; + nodes << node; + this->FireNodesSelected(nodes); +} + +void QmitkAbstractView::FireNodesSelected( const QList& nodes ) +{ + if (nodes.empty()) + { + d->m_DataNodeSelectionModel->clearSelection(); + d->m_DataNodeItemModel->clear(); + return; + } + + // The helper data node model is just used for sending selection events. + // We add the to be selected nodes and set the selection range to everything. + + d->m_DataNodeItemModel->clear(); + foreach(mitk::DataNode::Pointer node, nodes) + { + d->m_DataNodeItemModel->AddDataNode(node); + } + d->m_DataNodeSelectionModel->select(QItemSelection(d->m_DataNodeItemModel->index(0,0), d->m_DataNodeItemModel->index(nodes.size(), 0)), + QItemSelectionModel::ClearAndSelect); +} diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.h b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.h new file mode 100644 index 0000000000..b8e1d3c7ca --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.h @@ -0,0 +1,341 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#ifndef QMITKABSTRACTVIEW_H_ +#define QMITKABSTRACTVIEW_H_ + +#ifdef __MINGW32__ +// We need to inlclude winbase.h here in order to declare +// atomic intrinsics like InterlockedIncrement correctly. +// Otherwhise, they would be declared wrong within qatomic_windows.h . +#include +#endif + +//# blueberry stuff +#include +#include +#include + +#include + +//# mitk stuff +#include + +#include "mitkDataNodeSelection.h" +#include "mitkIRenderWindowPart.h" + +#include +#include +#include + +class QItemSelectionModel; + +namespace mitk { + class DataNode; +} + +namespace berry { + struct IBerryPreferences; +} + +class QmitkAbstractViewPrivate; +class QmitkAbstractViewSelectionProvider; + +/** + * \ingroup org_mitk_gui_qt_common + * + * \brief A convenient base class for MITK related BlueBerry Views. + * + * QmitkAbstractView provides several convenience methods that ease the introduction of a new view: + * + *
    + *
  1. Access to the DataStorage (~ the shared data repository) + *
  2. Access to the active IRenderWindowPart + *
  3. Access to and update notification for the view's preferences + *
  4. Access to and update notification for the current DataNode selection / to DataNode selection events send through the SelectionService + *
  5. Access to and update notification for DataNode events (added/removed/modified) + *
  6. Methods to send DataNode selections through the SelectionService + *
  7. Some minor important convenience methods (like changing the mouse cursor/exception handling) + *
+ * + * Usually all MITK Views inherit from QmitkAbstractView to achieve a consistent Workbench behavior. + * + * When inheriting from QmitkAbstractView, you must implement the following methods: + *
    + *
  • void CreateQtPartControl(QWidget* parent) + *
  • void SetFocus() + *
+ * + * You may reimplement the following private virtual methods to customize your View's behavior: + *
    + *
  • void SetSelectionProvider() + *
  • QItemSelectionModel* GetDataNodeSelectionModel() const + *
+ * + * You may reimplement the following private virtual methods to be notified about certain changes: + *
    + *
  • void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes) + *
  • void OnPreferencesChanged(const berry::IBerryPreferences*) + *
  • void NodeAdded(const mitk::DataNode* node) + *
  • void NodeChanged(const mitk::DataNode* node) + *
  • void NodeRemoved(const mitk::DataNode* node) + *
  • void DataStorageModified() + *
  • void DataStorageChanged(mitk::IDataStorageReference::Pointer dsRef) + *
+ * + * \see mitk::ILifecycleAwarePart + * \see mitk::IZombieViewPart + * \see mitk::IRenderWindowPartListener + */ +class MITK_QT_COMMON QmitkAbstractView : public berry::QtViewPart +{ + +public: + + /** + * Describes the strategies to be used for getting a mitk::IRenderWindowPart + * instance. + */ + enum IRenderWindowPartStrategy { + + /** Do nothing. */ + NONE = 0x00000000, + /** Bring the most recently activated mitk::IRenderWindowPart instance to the front. */ + BRING_TO_FRONT = 0x00000001, + /** Activate a mitk::IRenderWindowPart part (implies bringing it to the front). */ + ACTIVATE = 0x00000002, + /** Create a mitk::IRenderWindowPart if none is alredy opened. */ + OPEN = 0x00000004 + }; + + Q_DECLARE_FLAGS(IRenderWindowPartStrategies, IRenderWindowPartStrategy) + + /** + * Creates smartpointer typedefs + */ + berryObjectMacro(QmitkAbstractView) + + /** + * Nothing to do in the standard ctor. Initiliaze your GUI in CreateQtPartControl(QWidget*) + * \see berry::QtViewPart::CreateQtPartControl(QWidget*) + */ + QmitkAbstractView(); + + /** + * Disconnects all standard event listeners + */ + virtual ~QmitkAbstractView(); + +protected: + + /** + * Informs other parts of the workbench that node is selected via the blueberry selection service. + */ + void FireNodeSelected(mitk::DataNode::Pointer node); + + /** + * Informs other parts of the workbench that the nodes are selected via the blueberry selection service. + */ + virtual void FireNodesSelected(const QList& nodes); + + /** + * \return the selection of the currently active part of the workbench or an empty list + * if nothing is selected + */ + QList GetCurrentSelection() const; + + /** + * Returns the current selection made in the datamanager bundle or an empty list + * if nothing`s selected or if the data manager view does not exist + */ + QList GetDataManagerSelection() const; + + /** + * Returns the Preferences object for this View. + * Important: When refering to this preferences, e.g. in a PreferencePage: The ID + * for this preferences object is "/", e.g. "/org.mitk.views.datamanager" + */ + berry::IPreferences::Pointer GetPreferences() const; + + /** + * Returns a reference to the currently active DataStorage. + */ + mitk::IDataStorageReference::Pointer GetDataStorageReference() const; + + /** + * Returns the currently active DataStorage. + */ + mitk::DataStorage::Pointer GetDataStorage() const; + + /** + * Returns the currently active mitk::IRenderWindowPart. + * + * \param strategies Strategies for returning a mitk::IRenderWindowPart instance if there + * is currently no active one. + * \return The active mitk::IRenderWindowPart. + */ + mitk::IRenderWindowPart* GetRenderWindowPart(IRenderWindowPartStrategies strategies = NONE) const; + + /** + * Request an update of all render windows of the currently active IRenderWindowPart. + * + * \param requestType Specifies the type of render windows for which an update + * will be requested. + */ + void RequestRenderWindowUpdate(mitk::RenderingManager::RequestType requestType = mitk::RenderingManager::REQUEST_UPDATE_ALL); + + /** + * Outputs an error message to the console and displays a message box containing + * the exception description. + * \param e the exception which should be handled + * \param showDialog controls, whether additionally a message box should be + * displayed to inform the user that something went wrong + */ + void HandleException( std::exception& e, QWidget* parent = NULL, bool showDialog = true ) const; + + /** + * Calls HandleException ( std::exception&, QWidget*, bool ) internally + * \see HandleException ( std::exception&, QWidget*, bool ) + */ + void HandleException( const char* str, QWidget* parent = NULL, bool showDialog = true ) const; + + /** + * Convenient method to set and reset a wait cursor ("hourglass") + */ + void WaitCursorOn(); + + /** + * Convenient method to restore the standard cursor + */ + void WaitCursorOff(); + + /** + * Convenient method to set and reset a busy cursor + */ + void BusyCursorOn(); + + /** + * Convenient method to restore the standard cursor + */ + void BusyCursorOff(); + + /** + * Convenient method to restore the standard cursor + */ + void RestoreOverrideCursor(); + +private: + + /** + * Reimplement this method to set a custom selection provider. This method is + * called once after CreateQtPartControl(). + * + * The default implementation registers a QmitkDataNodeSelectionProvider with + * a QItemSelectionModel returned by GetDataNodeSelectionModel(). + */ + virtual void SetSelectionProvider(); + + /** + * Reimplement this method to supply a custom Qt selection model. The custom + * model will be used with the default selection provider QmitkDataNodeSelectionProvider + * to inform the MITK Workbench about selection changes. + * + * If you reimplement this method, the methods FireNodeSelected() and FireNodesSelected() + * will have no effect. Use your custom selection model to notify the MITK Workbench + * about selection changes. + * + * The Qt item model used with the custom selection model must return mitk::DataNode::Pointer + * objects for model indexes when the role is QmitkDataNodeRole. + */ + virtual QItemSelectionModel* GetDataNodeSelectionModel() const; + + /** + * Called when the selection in the workbench changed. + * May be reimplemented by deriving classes. + * + * \param part The source part responsible for the selection change. + * \param nodes A list of selected nodes. + */ + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes); + + /** + * Called when the preferences object of this view changed. + * May be reimplemented by deriving classes. + * + * \see GetPreferences() + */ + virtual void OnPreferencesChanged(const berry::IBerryPreferences*); + + /** + * Called when a DataStorage Add event was thrown. May be reimplemented + * by deriving classes. + */ + virtual void NodeAdded(const mitk::DataNode* node); + + /** + * Called when a DataStorage Changed event was thrown. May be reimplemented + * by deriving classes. + */ + virtual void NodeChanged(const mitk::DataNode* node); + + /** + * Called when a DataStorage Remove event was thrown. May be reimplemented + * by deriving classes. + */ + virtual void NodeRemoved(const mitk::DataNode* node); + + /** + * Called when a DataStorage add *or* remove *or* change event from the currently active + * data storage is thrown. + * + * May be reimplemented by deriving classes. + */ + virtual void DataStorageModified(); + + /** + * Called when the currently active DataStorage changed. + * May be reimplemented by deriving classes. + * + * \param dsRef A reference to the new active DataStorage. + */ + virtual void DataStorageChanged(mitk::IDataStorageReference::Pointer dsRef); + + /** + * Creates a scroll area for this view and calls CreateQtPartControl then + */ + void CreatePartControl(void* parent); + + /** + * Called immediately after CreateQtPartControl(). + * Here standard event listeners for a QmitkAbstractView are registered + */ + void AfterCreateQtPartControl(); + +private: + + friend class QmitkAbstractViewPrivate; + friend class QmitkViewCoordinator; + + Q_DISABLE_COPY(QmitkAbstractView) + + const QScopedPointer d; + +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QmitkAbstractView::IRenderWindowPartStrategies) + +#endif /*QMITKABSTRACTVIEW_H_*/ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.cpp rename to Plugins/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.cpp diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.h b/Plugins/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.h new file mode 100644 index 0000000000..5bfb8d8396 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkDataNodeSelectionProvider.h @@ -0,0 +1,58 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKDATATREENODESELECTIONPROVIDER_H_ +#define QMITKDATATREENODESELECTIONPROVIDER_H_ + +#include + +#include +#include + +/** + * \ingroup org_mitk_gui_qt_common + * + * \brief A BlueBerry selection provider for mitk::DataNode selections. + * + * This class works together with a Qt item selection model which holds the actual + * selection. The underlying Qt model must support the data role \e QmitkDataNodeRole + * and return a mitk::DataNode::Pointer object for each QModelIndex in the selection. + * + * You can set a Qt item selection model using QtSelectionProvider::SetItemSelectionModel(). + */ +class MITK_QT_COMMON QmitkDataNodeSelectionProvider : public berry::QtSelectionProvider +{ +public: + + berryObjectMacro(QmitkDataNodeSelectionProvider) + + QmitkDataNodeSelectionProvider(); + + /** + * This method will always return a mitk::DataNodeSelection object. + */ + berry::ISelection::ConstPointer GetSelection() const; + +protected: + + mitk::DataNodeSelection::ConstPointer GetDataNodeSelection() const; + + virtual void FireSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); +}; + +#endif /* QMITKDATATREENODESELECTIONPROVIDER_H_ */ diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp new file mode 100644 index 0000000000..70c8087dd8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.cpp @@ -0,0 +1,56 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include + +#include + +#include "mitkWorkbenchUtil.h" + +#include + + +QmitkDnDFrameWidget::QmitkDnDFrameWidget(QWidget *parent) +: QWidget(parent) +{ + setAcceptDrops(true); +} + +void QmitkDnDFrameWidget::dragEnterEvent( QDragEnterEvent *event ) +{ // accept drags + event->acceptProposedAction(); +} + +void QmitkDnDFrameWidget::dropEvent( QDropEvent * event ) +{ //open dragged files + + QList fileNames = event->mimeData()->urls(); + if (fileNames.empty()) + return; + + QStringList fileNames2; + fileNames2.reserve(fileNames.size()); + foreach(QUrl url, fileNames) + { + fileNames2.push_back(url.toLocalFile()); + } + + mitk::WorkbenchUtil::LoadFiles(fileNames2, + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); + + event->accept(); +} diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.h b/Plugins/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.h new file mode 100644 index 0000000000..dfde32d3a5 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkDnDFrameWidget.h @@ -0,0 +1,59 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ +Version: $Revision: 16224 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkDndFrameWidget_h +#define QmitkDndFrameWidget_h + +#ifdef __MINGW32__ +// We need to inlclude winbase.h here in order to declare +// atomic intrinsics like InterlockedIncrement correctly. +// Otherwhise, they would be declared wrong within qatomic_windows.h . +#include +#endif + +#include +#include +//drag&drop +class QDragEnterEvent; +class QDropEvent; +class QMouseEvent; + +/** + * \ingroup org_mitk_gui_qt_common + * + * \brief Enables loading data into a MITK application via Drag'n Drop. + * + * You can use this class inside your MITK View as a container for your widgets + * if you want the user to be able to load data by dropping files onto your view. + */ +class MITK_QT_COMMON QmitkDnDFrameWidget : public QWidget +{ + Q_OBJECT + +public: + QmitkDnDFrameWidget(QWidget *parent); + + +private: + void dragEnterEvent( QDragEnterEvent *event ); + void dropEvent( QDropEvent * event ); + + +}; + + +#endif diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.cpp b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.cpp new file mode 100644 index 0000000000..7296377b44 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.cpp @@ -0,0 +1,57 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkCommonActivator.h" + +#include +#include + +ctkPluginContext* QmitkCommonActivator::m_Context = 0; + +ctkPluginContext* QmitkCommonActivator::GetContext() +{ + return m_Context; +} + +void +QmitkCommonActivator::start(ctkPluginContext* context) +{ + this->m_Context = context; + + if(berry::PlatformUI::IsWorkbenchRunning()) + { + m_ViewCoordinator = QmitkViewCoordinator::Pointer(new QmitkViewCoordinator); + m_ViewCoordinator->Start(); + } + else + { + MITK_ERROR << "BlueBerry Workbench not running!"; + } +} + +void +QmitkCommonActivator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + + m_ViewCoordinator->Stop(); + m_ViewCoordinator = 0; + + this->m_Context = 0; +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_common, QmitkCommonActivator) diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.h b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.h new file mode 100644 index 0000000000..f9c99d1cb6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkCommonActivator.h @@ -0,0 +1,58 @@ +/*========================================================================= + + Program: MITK Platform + Language: C++ + Date: $Date$ + Version: $Revision: 17020 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKCOMMONACTIVATOR_H_ +#define QMITKCOMMONACTIVATOR_H_ + +#include + +#include "QmitkViewCoordinator.h" + +/** + * \ingroup org_mitk_gui_qt_common_internal + * + * \brief The plug-in activator for the StateMachine + * + * When the plug-in is started by the framework, it initializes StateMachine + * specific things. + */ +class QmitkCommonActivator : public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + static ctkPluginContext* GetContext(); + + /** + * Sets default StateMachine to EventMapper. + */ + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + +private: + + static ctkPluginContext* m_Context; + + QmitkViewCoordinator::Pointer m_ViewCoordinator; + +}; + +#endif /* QMITKCOMMONACTIVATOR_H_ */ + diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeItemModel.cpp b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeItemModel.cpp new file mode 100644 index 0000000000..ae4be4ddd8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeItemModel.cpp @@ -0,0 +1,46 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#include "QmitkDataNodeItemModel.h" + +#include +#include + +QmitkDataNodeItemModel::QmitkDataNodeItemModel(QObject *parent) + : QStandardItemModel(parent) +{ +} + +void QmitkDataNodeItemModel::AddDataNode(mitk::DataNode::Pointer node) +{ + QList nodes; + nodes << node; + this->AddDataNodes(nodes); +} + +void QmitkDataNodeItemModel::AddDataNodes(const QList &nodes) +{ + QList items; + foreach(mitk::DataNode::Pointer node, nodes) + { + QStandardItem* item = new QStandardItem(); + item->setData(QVariant::fromValue(node), QmitkDataNodeRole); + items << item; + } + this->appendRow(items); +} diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeItemModel.h b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeItemModel.h new file mode 100644 index 0000000000..a5afd7e7d3 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeItemModel.h @@ -0,0 +1,37 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKDATANODEITEMMODEL_H +#define QMITKDATANODEITEMMODEL_H + +#include + +#include + +class QmitkDataNodeItemModel : public QStandardItemModel +{ + +public: + + QmitkDataNodeItemModel(QObject* parent = 0); + + void AddDataNode(mitk::DataNode::Pointer node); + void AddDataNodes(const QList& nodes); +}; + +#endif // QMITKDATANODEITEMMODEL_H diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.cpp b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.cpp rename to Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.cpp diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.h b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.h similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.h rename to Plugins/org.mitk.gui.qt.common/src/internal/QmitkDataNodeSelection.h diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkViewCoordinator.cpp b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkViewCoordinator.cpp new file mode 100644 index 0000000000..7c12210282 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkViewCoordinator.cpp @@ -0,0 +1,206 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkViewCoordinator.h" +#include "QmitkAbstractView.h" + +#include +#include +#include + +#include +#include + +QmitkViewCoordinator::QmitkViewCoordinator() + : m_ActiveZombieView(0) + , m_ActiveRenderWindowPart(0) + , m_VisibleRenderWindowPart(0) +{ +} + +QmitkViewCoordinator::~QmitkViewCoordinator() +{ +} + +void QmitkViewCoordinator::Start() +{ + berry::PlatformUI::GetWorkbench()->AddWindowListener(berry::IWindowListener::Pointer(this)); + std::vector wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); + for (std::vector::iterator i = wnds.begin(); + i != wnds.end(); ++i) + { + (*i)->GetPartService()->AddPartListener(berry::IPartListener::Pointer(this)); + } +} + +void QmitkViewCoordinator::Stop() +{ + if (!berry::PlatformUI::IsWorkbenchRunning()) return; + + berry::PlatformUI::GetWorkbench()->RemoveWindowListener(berry::IWindowListener::Pointer(this)); + std::vector wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); + for (std::vector::iterator i = wnds.begin(); + i != wnds.end(); ++i) + { + (*i)->GetPartService()->RemovePartListener(berry::IPartListener::Pointer(this)); + } +} + +berry::IPartListener::Events::Types QmitkViewCoordinator::GetPartEventTypes() const +{ + return berry::IPartListener::Events::ACTIVATED | berry::IPartListener::Events::DEACTIVATED + | berry::IPartListener::Events::CLOSED | berry::IPartListener::Events::HIDDEN + | berry::IPartListener::Events::VISIBLE | berry::IPartListener::Events::OPENED; +} + +void QmitkViewCoordinator::PartActivated( berry::IWorkbenchPartReference::Pointer partRef ) +{ + //MITK_INFO << "*** PartActivated (" << partRef->GetPart(false)->GetPartName() << ")"; + berry::IWorkbenchPart* part = partRef->GetPart(false).GetPointer(); + + // Check for a render window part and inform IRenderWindowPartListener views + // that it was activated + if ( mitk::IRenderWindowPart* renderPart = dynamic_cast(part) ) + { + if (m_VisibleRenderWindowPart != renderPart) + { + RenderWindowPartActivated(renderPart); + m_ActiveRenderWindowPart = renderPart; + m_VisibleRenderWindowPart = renderPart; + } + } + + // Check if the activated part wants to be notified + if (mitk::ILifecycleAwarePart* lifecycleAwarePart = dynamic_cast(part)) + { + lifecycleAwarePart->Activated(); + } + + // Check if a zombie view has been activated. + if (mitk::IZombieViewPart* zombieView = dynamic_cast(part)) + { + if (m_ActiveZombieView && (m_ActiveZombieView != zombieView)) + { + // Another zombie view has been activated. Tell the old one about it. + m_ActiveZombieView->ActivatedZombieView(partRef); + m_ActiveZombieView = zombieView; + } + } +} + +void QmitkViewCoordinator::PartDeactivated( berry::IWorkbenchPartReference::Pointer partRef ) +{ + //MITK_INFO << "*** PartDeactivated (" << partRef->GetPart(false)->GetPartName() << ")"; + berry::IWorkbenchPart* part = partRef->GetPart(false).GetPointer(); + + if (mitk::ILifecycleAwarePart* lifecycleAwarePart = dynamic_cast(part)) + { + lifecycleAwarePart->Deactivated(); + } +} + +void QmitkViewCoordinator::PartOpened( berry::IWorkbenchPartReference::Pointer partRef ) +{ + //MITK_INFO << "*** PartOpened (" << partRef->GetPart(false)->GetPartName() << ")"; + berry::IWorkbenchPart* part = partRef->GetPart(false).GetPointer(); + + if (mitk::IRenderWindowPartListener* renderWindowListener = dynamic_cast(part)) + { + m_RenderWindowListeners.insert(renderWindowListener); + } +} + +void QmitkViewCoordinator::PartClosed( berry::IWorkbenchPartReference::Pointer partRef ) +{ + //MITK_INFO << "*** PartClosed (" << partRef->GetPart(false)->GetPartName() << ")"; + berry::IWorkbenchPart* part = partRef->GetPart(false).GetPointer(); + + if (mitk::IRenderWindowPartListener* renderWindowListener = dynamic_cast(part)) + { + m_RenderWindowListeners.remove(renderWindowListener); + } +} + +void QmitkViewCoordinator::PartHidden( berry::IWorkbenchPartReference::Pointer partRef ) +{ + //MITK_INFO << "*** PartHidden (" << partRef->GetPart(false)->GetPartName() << ")"; + berry::IWorkbenchPart* part = partRef->GetPart(false).GetPointer(); + + // Check for a render window part and if it is the currently active on. + // Inform IRenderWindowPartListener views that it has been hidden. + if ( mitk::IRenderWindowPart* renderPart = dynamic_cast(part) ) + { + if (!m_ActiveRenderWindowPart && m_VisibleRenderWindowPart == renderPart) + { + RenderWindowPartDeactivated(renderPart); + m_VisibleRenderWindowPart = 0; + } + } + + if (mitk::ILifecycleAwarePart* lifecycleAwarePart = dynamic_cast(part)) + { + lifecycleAwarePart->Hidden(); + } +} + +void QmitkViewCoordinator::PartVisible( berry::IWorkbenchPartReference::Pointer partRef ) +{ + //MITK_INFO << "*** PartVisible (" << partRef->GetPart(false)->GetPartName() << ")"; + berry::IWorkbenchPart* part = partRef->GetPart(false).GetPointer(); + + // Check for a render window part and inform IRenderWindowPartListener views + // that it was activated + if ( mitk::IRenderWindowPart* renderPart = dynamic_cast(part) ) + { + if (!m_ActiveRenderWindowPart) + { + RenderWindowPartActivated(renderPart); + m_VisibleRenderWindowPart = renderPart; + } + } + + if (mitk::ILifecycleAwarePart* lifecycleAwarePart = dynamic_cast(part)) + { + lifecycleAwarePart->Visible(); + } +} + +void QmitkViewCoordinator::RenderWindowPartActivated(mitk::IRenderWindowPart* renderPart) +{ + foreach (mitk::IRenderWindowPartListener* l, m_RenderWindowListeners) + { + l->RenderWindowPartActivated(renderPart); + } +} + +void QmitkViewCoordinator::RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderPart) +{ + foreach (mitk::IRenderWindowPartListener* l, m_RenderWindowListeners) + { + l->RenderWindowPartDeactivated(renderPart); + } +} + +void QmitkViewCoordinator::WindowClosed( berry::IWorkbenchWindow::Pointer /*window*/ ) +{ +} + +void QmitkViewCoordinator::WindowOpened( berry::IWorkbenchWindow::Pointer window ) +{ + window->GetPartService()->AddPartListener(berry::IPartListener::Pointer(this)); +} + diff --git a/Plugins/org.mitk.gui.qt.common/src/internal/QmitkViewCoordinator.h b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkViewCoordinator.h new file mode 100644 index 0000000000..f06416fdbc --- /dev/null +++ b/Plugins/org.mitk.gui.qt.common/src/internal/QmitkViewCoordinator.h @@ -0,0 +1,125 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ +Version: $Revision: 21070 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QmitkViewCoordinator_h +#define QmitkViewCoordinator_h + +#include +#include +#include + +#include + +#include + +namespace mitk { + +struct IRenderWindowPart; +struct IRenderWindowPartListener; +struct IZombieViewPart; + +} + +class QmitkAbstractView; + +/** + * A class which coordinates active QmitkAbstractView s, e.g. calling activated and hidden on them. + */ +class QmitkViewCoordinator : public berry::IPartListener, public berry::IWindowListener +{ +public: + + berryObjectMacro(QmitkViewCoordinator) + + /** + * Add listener + */ + QmitkViewCoordinator(); + + /** + * Remove listener + */ + virtual ~QmitkViewCoordinator(); + + void Start(); + void Stop(); + + + //#IPartListener methods (these methods internally call Activated() or other similar methods) + + /** + * \see IPartListener::GetPartEventTypes() + */ + berry::IPartListener::Events::Types GetPartEventTypes() const; + + /** + * \see IPartListener::PartActivated() + */ + virtual void PartActivated (berry::IWorkbenchPartReference::Pointer partRef); + + /** + * \see IPartListener::PartDeactivated() + */ + virtual void PartDeactivated(berry::IWorkbenchPartReference::Pointer /*partRef*/); + + /** + * \see IPartListener::PartOpened() + */ + virtual void PartOpened(berry::IWorkbenchPartReference::Pointer partRef); + + /** + * \see IPartListener::PartClosed() + */ + virtual void PartClosed (berry::IWorkbenchPartReference::Pointer partRef); + + /** + * \see IPartListener::PartHidden() + */ + virtual void PartHidden (berry::IWorkbenchPartReference::Pointer partRef); + + /** + * \see IPartListener::PartVisible() + */ + virtual void PartVisible (berry::IWorkbenchPartReference::Pointer partRef); + + /** + * Notifies this listener that the given window has been closed. + */ + virtual void WindowClosed(berry::IWorkbenchWindow::Pointer window); + + /** + * Notifies this listener that the given window has been opened. + */ + virtual void WindowOpened(berry::IWorkbenchWindow::Pointer /*window*/); + +private: + + void RenderWindowPartActivated(mitk::IRenderWindowPart* renderPart); + void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderPart); + +private: + + mitk::IZombieViewPart* m_ActiveZombieView; + mitk::IRenderWindowPart* m_ActiveRenderWindowPart; + mitk::IRenderWindowPart* m_VisibleRenderWindowPart; + + QSet m_RenderWindowListeners; + +}; + +#endif // QmitkViewCoordinator_h diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/CMakeLists.txt b/Plugins/org.mitk.gui.qt.common/testing/CMakeLists.txt similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.common/testing/CMakeLists.txt diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/files.cmake b/Plugins/org.mitk.gui.qt.common/testing/files.cmake similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/files.cmake rename to Plugins/org.mitk.gui.qt.common/testing/files.cmake diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/manifest.cpp b/Plugins/org.mitk.gui.qt.common/testing/manifest.cpp similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/manifest.cpp rename to Plugins/org.mitk.gui.qt.common/testing/manifest.cpp diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.common/testing/manifest_headers.cmake similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/manifest_headers.cmake rename to Plugins/org.mitk.gui.qt.common/testing/manifest_headers.cmake diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/plugin.xml b/Plugins/org.mitk.gui.qt.common/testing/plugin.xml similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/plugin.xml rename to Plugins/org.mitk.gui.qt.common/testing/plugin.xml diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/QmitkQtCommonTestSuite.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.cpp similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/QmitkQtCommonTestSuite.cpp rename to Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.cpp diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/QmitkQtCommonTestSuite.h b/Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.h similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/QmitkQtCommonTestSuite.h rename to Plugins/org.mitk.gui.qt.common/testing/src/QmitkQtCommonTestSuite.h diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkFunctionalityTest.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.cpp similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkFunctionalityTest.cpp rename to Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.cpp diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkFunctionalityTest.h b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.h similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkFunctionalityTest.h rename to Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkFunctionalityTest.h diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkMockFunctionality.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.cpp similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkMockFunctionality.cpp rename to Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.cpp diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkMockFunctionality.h b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.h similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkMockFunctionality.h rename to Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkMockFunctionality.h diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkUiApiTestSuite.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.cpp similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkUiApiTestSuite.cpp rename to Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.cpp diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkUiApiTestSuite.h b/Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.h similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/api/QmitkUiApiTestSuite.h rename to Plugins/org.mitk.gui.qt.common/testing/src/api/QmitkUiApiTestSuite.h diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.cpp similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.cpp diff --git a/CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.h similarity index 100% rename from CoreUI/BundleTesting/org.mitk.gui.qt.common.tests/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.common/testing/src/internal/mitkPluginActivator.h diff --git a/Plugins/org.mitk.gui.qt.coreapplication/CMakeLists.txt b/Plugins/org.mitk.gui.qt.coreapplication/CMakeLists.txt new file mode 100644 index 0000000000..bf2b55ceae --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/CMakeLists.txt @@ -0,0 +1,8 @@ +PROJECT(org_mitk_gui_qt_coreapplication) + +MACRO_CREATE_MITK_CTK_PLUGIN( + EXPORT_DIRECTIVE MITK_QT_COREAPP + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDENCIES Qmitk + SUBPROJECTS MITK-CoreUI + ) diff --git a/Plugins/org.mitk.gui.qt.coreapplication/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.coreapplication/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..3d641f9119 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_coreapplication org.mitk.gui.qt.coreapplication + \ingroup MITKPlugins + + \brief The CoreApp applictaion plug-in. + +*/ + +/** + \defgroup org_mitk_gui_qt_coreapplication_internal Internal + \ingroup org_mitk_gui_qt_coreapplication + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.coreapplication plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.coreapplication/files.cmake b/Plugins/org.mitk.gui.qt.coreapplication/files.cmake new file mode 100644 index 0000000000..129790de1c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/files.cmake @@ -0,0 +1,32 @@ +SET(SRC_CPP_FILES +) + +SET(INTERNAL_CPP_FILES + org_mitk_gui_qt_coreapplication_Activator.cpp + QmitkActionBarAdvisor.cpp + QmitkCoreApplication.cpp + QmitkDefaultPerspective.cpp + QmitkWorkbenchAdvisor.cpp + QmitkWorkbenchWindowAdvisor.cpp +) + +SET(MOC_H_FILES + src/internal/org_mitk_gui_qt_coreapplication_Activator.h + + src/internal/QmitkCoreApplication.h + src/internal/QmitkDefaultPerspective.h +) + +SET(CACHED_RESOURCE_FILES + plugin.xml +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.coreapplication/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.coreapplication/manifest_headers.cmake new file mode 100644 index 0000000000..ab0cc3127c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "MITK Qt CoreApp application") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.application) + diff --git a/Plugins/org.mitk.gui.qt.coreapplication/plugin.xml b/Plugins/org.mitk.gui.qt.coreapplication/plugin.xml new file mode 100644 index 0000000000..5c63c19546 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/plugin.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkActionBarAdvisor.cpp b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkActionBarAdvisor.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkActionBarAdvisor.cpp rename to Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkActionBarAdvisor.cpp diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkActionBarAdvisor.h b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkActionBarAdvisor.h new file mode 100644 index 0000000000..8112027368 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkActionBarAdvisor.h @@ -0,0 +1,35 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKACTIONBARADVISOR_H_ +#define QMITKACTIONBARADVISOR_H_ + +#include + + +class QmitkActionBarAdvisor : public berry::ActionBarAdvisor +{ +public: + + QmitkActionBarAdvisor(berry::IActionBarConfigurer::Pointer configurer); + +protected: + + void FillMenuBar(void* menuBar); +}; + +#endif /*QMITKACTIONBARADVISOR_H_*/ diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkCoreApplication.cpp b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkCoreApplication.cpp new file mode 100644 index 0000000000..a86f050cb4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkCoreApplication.cpp @@ -0,0 +1,43 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkCoreApplication.h" + +#include + +#include "QmitkWorkbenchAdvisor.h" + +QmitkCoreApplication::QmitkCoreApplication() +{ + +} + +int QmitkCoreApplication::Start() +{ + berry::Display* display = berry::PlatformUI::CreateDisplay(); + + int code = berry::PlatformUI::CreateAndRunWorkbench(display, new QmitkWorkbenchAdvisor()); + + // exit the application with an appropriate return code + return code == berry::PlatformUI::RETURN_RESTART + ? EXIT_RESTART : EXIT_OK; +} + +void QmitkCoreApplication::Stop() +{ + +} diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkCoreApplication.h b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkCoreApplication.h new file mode 100644 index 0000000000..5cb6e53c28 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkCoreApplication.h @@ -0,0 +1,39 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKCOREAPPLICATION_H_ +#define QMITKCOREAPPLICATION_H_ + +#include + +#include + + +class QmitkCoreApplication : public QObject, public berry::IApplication +{ + Q_OBJECT + Q_INTERFACES(berry::IApplication) + +public: + + QmitkCoreApplication(); + + int Start(); + void Stop(); +}; + +#endif /*QMITKCOREAPPLICATION_H_*/ diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkDefaultPerspective.cpp b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkDefaultPerspective.cpp new file mode 100755 index 0000000000..abee56e998 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkDefaultPerspective.cpp @@ -0,0 +1,28 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkDefaultPerspective.h" + +QmitkDefaultPerspective::QmitkDefaultPerspective() +{ + +} + +void QmitkDefaultPerspective::CreateInitialLayout(berry::IPageLayout::Pointer /*layout*/) +{ + +} diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkDefaultPerspective.h b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkDefaultPerspective.h new file mode 100755 index 0000000000..58614a2815 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkDefaultPerspective.h @@ -0,0 +1,40 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKDEFAULTPERSPECTIVE_H_ +#define QMITKDEFAULTPERSPECTIVE_H_ + +#include + +#include + + +struct QmitkDefaultPerspective : public QObject, public berry::IPerspectiveFactory +{ + + QmitkDefaultPerspective(); + + void CreateInitialLayout(berry::IPageLayout::Pointer /*layout*/); + +private: + + Q_OBJECT + Q_INTERFACES(berry::IPerspectiveFactory) +}; + +#endif /* QMITKDEFAULTPERSPECTIVE_H_ */ diff --git a/CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchAdvisor.cpp similarity index 100% rename from CoreUI/Bundles/org.mitk.gui.qt.application/src/QmitkWorkbenchAdvisor.cpp rename to Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchAdvisor.cpp diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchAdvisor.h b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchAdvisor.h new file mode 100644 index 0000000000..f271de0a2b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchAdvisor.h @@ -0,0 +1,46 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKWORKBENCHADVISOR_H_ +#define QMITKWORKBENCHADVISOR_H_ + +#ifdef __MINGW32__ +// We need to inlclude winbase.h here in order to declare +// atomic intrinsics like InterlockedIncrement correctly. +// Otherwhise, they would be declared wrong within qatomic_windows.h . +#include +#endif + +#include + + +class QmitkWorkbenchAdvisor : public berry::QtWorkbenchAdvisor +{ +public: + + static const std::string DEFAULT_PERSPECTIVE_ID; // = org.mitk.coreapp.defaultperspective + + void Initialize(berry::IWorkbenchConfigurer::Pointer configurer); + + berry::WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor( + berry::IWorkbenchWindowConfigurer::Pointer configurer); + + std::string GetInitialWindowPerspectiveId(); + +}; + +#endif /*QMITKWORKBENCHADVISOR_H_*/ diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchWindowAdvisor.cpp b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchWindowAdvisor.cpp new file mode 100644 index 0000000000..690c6463ea --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchWindowAdvisor.cpp @@ -0,0 +1,121 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkWorkbenchWindowAdvisor.h" +#include "QmitkActionBarAdvisor.h" + + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +QmitkWorkbenchWindowAdvisor::QmitkWorkbenchWindowAdvisor(berry::IWorkbenchWindowConfigurer::Pointer configurer) +: berry::WorkbenchWindowAdvisor(configurer) +, dropTargetListener(new QmitkDefaultDropTargetListener) +{ +} + +berry::ActionBarAdvisor::Pointer +QmitkWorkbenchWindowAdvisor::CreateActionBarAdvisor( + berry::IActionBarConfigurer::Pointer configurer) +{ + berry::ActionBarAdvisor::Pointer actionBarAdvisor(new QmitkActionBarAdvisor(configurer)); + return actionBarAdvisor; +} + +void QmitkWorkbenchWindowAdvisor::PostWindowCreate() +{ + // very bad hack... + berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); + QMainWindow* mainWindow = static_cast(window->GetShell()->GetControl()); + + QMenuBar* menuBar = mainWindow->menuBar(); + + QMenu* fileMenu = menuBar->addMenu("&File"); + + fileMenu->addAction(new QmitkFileOpenAction(window)); + fileMenu->addSeparator(); + fileMenu->addAction(new QmitkFileExitAction(window)); + + berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); + const std::vector& viewDescriptors = viewRegistry->GetViews(); + + QMenu* viewMenu = menuBar->addMenu("Show &View"); + + // sort elements (converting vector to map...) + std::vector::const_iterator iter; + std::map VDMap; + + for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) + { + if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") + continue; + std::pair p((*iter)->GetLabel(), (*iter)); + VDMap.insert(p); + } + + QToolBar* qToolbar = new QToolBar; + + std::map::const_iterator MapIter; + for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) + { + berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); + //m_ViewActions.push_back(viewAction); + viewMenu->addAction(viewAction); + qToolbar->addAction(viewAction); + } + + mainWindow->addToolBar(qToolbar); + + QStatusBar* qStatusBar = new QStatusBar(); + + //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar + QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); + //disabling the SizeGrip in the lower right corner + statusBar->SetSizeGripEnabled(false); + + QmitkProgressBar *progBar = new QmitkProgressBar(); + qStatusBar->addPermanentWidget(progBar, 0); + progBar->hide(); + mainWindow->setStatusBar(qStatusBar); + + QmitkMemoryUsageIndicatorView* memoryIndicator = new QmitkMemoryUsageIndicatorView(); + qStatusBar->addPermanentWidget(memoryIndicator, 0); +} + +void QmitkWorkbenchWindowAdvisor::PreWindowOpen() +{ + this->GetWindowConfigurer()->AddEditorAreaTransfer(QStringList("text/uri-list")); + this->GetWindowConfigurer()->ConfigureEditorAreaDropListener(dropTargetListener); +} diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchWindowAdvisor.h b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchWindowAdvisor.h new file mode 100644 index 0000000000..7d002a4891 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/QmitkWorkbenchWindowAdvisor.h @@ -0,0 +1,42 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKWORKBENCHWINDOWADVISOR_H_ +#define QMITKWORKBENCHWINDOWADVISOR_H_ + +#include + + +class QmitkWorkbenchWindowAdvisor : public berry::WorkbenchWindowAdvisor +{ +public: + + QmitkWorkbenchWindowAdvisor(berry::IWorkbenchWindowConfigurer::Pointer configurer); + + berry::ActionBarAdvisor::Pointer CreateActionBarAdvisor( + berry::IActionBarConfigurer::Pointer configurer); + + void PostWindowCreate(); + + void PreWindowOpen(); + +private: + + berry::IDropTargetListener::Pointer dropTargetListener; +}; + +#endif /*QMITKWORKBENCHWINDOWADVISOR_H_*/ diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/org_mitk_gui_qt_coreapplication_Activator.cpp b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/org_mitk_gui_qt_coreapplication_Activator.cpp new file mode 100644 index 0000000000..5563b1f0ca --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/org_mitk_gui_qt_coreapplication_Activator.cpp @@ -0,0 +1,43 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "org_mitk_gui_qt_coreapplication_Activator.h" + +#include "QmitkCoreApplication.h" +#include "QmitkDefaultPerspective.h" + +#include + +namespace mitk { + +void org_mitk_gui_qt_coreapplication_Activator::start(ctkPluginContext* context) +{ + BERRY_REGISTER_EXTENSION_CLASS(QmitkCoreApplication, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkDefaultPerspective, context) +} + +void org_mitk_gui_qt_coreapplication_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} + +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_coreapplication, mitk::org_mitk_gui_qt_coreapplication_Activator) + + diff --git a/Plugins/org.mitk.gui.qt.coreapplication/src/internal/org_mitk_gui_qt_coreapplication_Activator.h b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/org_mitk_gui_qt_coreapplication_Activator.h new file mode 100644 index 0000000000..ea6a03db24 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.coreapplication/src/internal/org_mitk_gui_qt_coreapplication_Activator.h @@ -0,0 +1,43 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKPLUGINACTIVATOR_H +#define MITKPLUGINACTIVATOR_H + +#include + +namespace mitk { + +class org_mitk_gui_qt_coreapplication_Activator : + public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + +}; // org_mitk_gui_common_Activator + +typedef org_mitk_gui_qt_coreapplication_Activator PluginActivator; + +} + +#endif // MITKPLUGINACTIVATOR_H diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/CMakeLists.txt b/Plugins/org.mitk.gui.qt.datamanager/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.datamanager/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/DataManager_48.png b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/DataManager_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/DataManager_48.png rename to Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/DataManager_48.png diff --git a/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Image_properties.png b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Image_properties.png new file mode 100644 index 0000000000..29b374e995 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Image_properties.png differ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Overview.png b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Overview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/Overview.png rename to Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Overview.png diff --git a/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Parent-Child.png b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Parent-Child.png new file mode 100644 index 0000000000..89d13fe32b Binary files /dev/null and b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Parent-Child.png differ diff --git a/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Preferences.png b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Preferences.png new file mode 100644 index 0000000000..ec2edcb7a1 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Preferences.png differ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/PropertyList.png b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/PropertyList.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/documentation/UserManual/PropertyList.png rename to Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/PropertyList.png diff --git a/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/QmitkDatamanager.dox b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/QmitkDatamanager.dox new file mode 100644 index 0000000000..6034939a5e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/QmitkDatamanager.dox @@ -0,0 +1,108 @@ +/** + +\bundlemainpage{org_datamanager} The DataManager + +\image html DataManager_48.png "Icon of the Module" + +\section QmitkDataManagerIntroduction Introduction + +The Datamanager is the central componenent to manage medical data like images, surfaces, etc.. +After loading one or more data into the Datamanager the data are shown in the four-view window, the so called Standard View. +The user can now start working on the data by just clicking into the standard view or by using the MITK-modules such as "Segmentation" or "Basic Image Processing". + +Available sections: + - \ref QmitkDataManagerIntroduction + - \ref QmitkDataManagerLoading + - \ref QmitkDataManagerSaving + - \ref QmitkDataManagerProperties + - \ref QmitkDataManagerPropertiesList + - \ref QmitkDataManagerPropertiesVisibility + - \ref QmitkDataManagerPropertiesRepresentation + - \ref QmitkDataManagerPropertiesPreferences + - \ref QmitkDataManagerPropertyList + + +\image html Overview.png "How MITK looks when starting" + + +\section QmitkDataManagerLoading Loading Data + +There are three ways of loading data into the Datamanager as so called Data-Elements. + +The user can just drag and drop data into the Datamanager or directly into one of the four parts of the Standard View. +He can as well use the Open-Button in the right upper corner. Or he can use the standard "File->Open"-Dialog on the top. + +A lot of file-formats can be loaded into MITK, for example + +
    +
  • 2D-images/3D-volumes with or without several timesteps (*.dcm, *.ima, *.pic, ...) +
  • Surfaces (*.stl, *.vtk, ...) +
  • Pointsets (*.mps) +
  • ... +
+ +The user can also load a series of 2D images (e.g. image001.png, image002.png ...) to a MITK 3D volume. +To do this, just drag and drop one of those 2D data files into the Datamanager by holding the ALT key. + +After loading one or more data into the Datamanager they appear as Data-Elements in a sorted list inside the Datamanager. +Data-Elements can also be sorted hierarchically as a parent-child-relation. +For example after using the Segmentation-Module on Data-Element1 the result is created as Data-Element2, which is a child of Data-Element1 (see Screenshot1). +The order can be changed by drag and drop. + +\image html Parent-Child.png "Screenshot1" + +The listed Data-Elements are shown in the standard view. +Here the user can scale or rotate the medical objects or he can change the cutting planes of the object by just using the mouse inside this view. + +\section QmitkDataManagerSaving Saving Data + +There are two ways of saving data from the Datamanger. The user can either save the whole project with all Data-Elements by clicking on "File"->"Save Project" +or he can save single Data-Elements by right-clicking->"Save", directly on a Data-Element. +When saving the whole project, the sorting of Data-Elements is saved as well. By contrast the sorting is lost, when saving a single Data-Element. + +\section QmitkDataManagerProperties Working with the Datamanager + +\subsection QmitkDataManagerPropertiesList List of Data-Elements + +The Data-Elements are listed in the Datamanager. +As described above the elements can be sorted hierarchically as a parent-child-relation. +For example after using the Segmentation-Module on Data-Element1 the result is created as Data-Element2, which is a child of Data-Element1 (see Screenshot1). +By drag and drop the sorting of Data-Elements and their hierarchical relation can be changed. + +\subsection QmitkDataManagerPropertiesVisibility Visibility of Data-Elements + +By default all loaded Data-Elements are visible in the standard view. +The visibility can be changed by right-clicking on the Data-Element and then choosing "Toogle visibility". +The box in front of the Data-Element in the Datamanager shows the visibility. +A green-filled box means a visible Data-Element, an empty box means an invisible Data-Element (see Screenshot1). + +\subsection QmitkDataManagerPropertiesRepresentation Representation of Data-Elements + +There are different types of representations how to show the Data-Element inside the standard view. By right-clicking on the Data-Element all options are listed (see Screenshot2 and Screenshot 3). + +
    +
  • An arbitrary color can be chosen +
  • The opacity can be changed with a slide control +
  • In case of images a texture interpolation can be switched on or off. The texture interpolation smoothes the image, so that no single pixels are visible anymore. +
  • In case of surfaces the surface representation can be changed between points, wireframe or surface. +
  • Global reinit updates all windows to contain all the current data. Reinit updates a single data item fits the windows to contain this data item. +
+ +\image html Image_properties.png "Screenshot2: Properties for images" +\image html Surface_Properties.png "Screenshot3: Properties for surfaces" + + +\subsection QmitkDataManagerPropertiesPreferences Preferences + +For the datamanager there are already some default hotkeys like the del-key for deleting a Data-Element. The whole list is seen in Screenshot4. +From here the Hotkeys can also be changed. The preference page is found in "Window"->"Preferences". + +\image html Preferences.png "Screenshot4" + +\section QmitkDataManagerPropertyList Property List + +The Property List displays all the properties the currently selected Data-Element has. Which properties these are depends on the Data-Element. Examples are opacity, shader, visibility. These properties can be changed by clicking on the appropriate field in the "value" column. + +\image html PropertyList.png "Screenshot5: Property List" + +*/ diff --git a/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Surface_Properties.png b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Surface_Properties.png new file mode 100644 index 0000000000..1740d88ecb Binary files /dev/null and b/Plugins/org.mitk.gui.qt.datamanager/documentation/UserManual/Surface_Properties.png differ diff --git a/Plugins/org.mitk.gui.qt.datamanager/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.datamanager/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..a891bc10de --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_datamanager org.mitk.gui.qt.datamanager + \ingroup MITKPlugins + + \brief This is the datamanager plugin. It provides means to query mitk::DataStorage objects and to change properties of the contained nodes. + +*/ + +/** + \defgroup org_mitk_gui_qt_datamanager_internal Internal + \ingroup org_mitk_gui_qt_datamanager + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.datamanager plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/files.cmake b/Plugins/org.mitk.gui.qt.datamanager/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/files.cmake rename to Plugins/org.mitk.gui.qt.datamanager/files.cmake diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.datamanager/manifest_headers.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/manifest_headers.cmake rename to Plugins/org.mitk.gui.qt.datamanager/manifest_headers.cmake diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/plugin.xml b/Plugins/org.mitk.gui.qt.datamanager/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/plugin.xml rename to Plugins/org.mitk.gui.qt.datamanager/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/DataManager_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/DataManager_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/DataManager_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/DataManager_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/InvertShowSelectedNode_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/InvertShowSelectedNode_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/InvertShowSelectedNode_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/InvertShowSelectedNode_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Load_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/Load_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Load_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/Load_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Refresh_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/Refresh_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Refresh_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/Refresh_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Remove_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/Remove_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Remove_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/Remove_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Save_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/Save_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/Save_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/Save_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/ShowDataInfo_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/ShowDataInfo_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/ShowDataInfo_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/ShowDataInfo_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/ShowSelectedNode_48.png b/Plugins/org.mitk.gui.qt.datamanager/resources/ShowSelectedNode_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/ShowSelectedNode_48.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/ShowSelectedNode_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-invisible-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-invisible-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-invisible-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-invisible-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-visible-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-visible-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-visible-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-image-mask-visible-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-mesh-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-mesh-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-mesh-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-mesh-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometries-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometries-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometries-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometries-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry1-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry1-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry1-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry1-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry2-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry2-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry2-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry2-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry3-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry3-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry3-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-planegeometry3-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-pointset-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-pointset-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-pointset-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-pointset-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-unknown-24.png b/Plugins/org.mitk.gui.qt.datamanager/resources/data-type-unknown-24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/data-type-unknown-24.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/data-type-unknown-24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/datamanager.qrc b/Plugins/org.mitk.gui.qt.datamanager/resources/datamanager.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/datamanager.qrc rename to Plugins/org.mitk.gui.qt.datamanager/resources/datamanager.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/datamanager.xpm b/Plugins/org.mitk.gui.qt.datamanager/resources/datamanager.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/datamanager.xpm rename to Plugins/org.mitk.gui.qt.datamanager/resources/datamanager.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/propertylist.png b/Plugins/org.mitk.gui.qt.datamanager/resources/propertylist.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/propertylist.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/propertylist.png diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/save-chili.xpm b/Plugins/org.mitk.gui.qt.datamanager/resources/save-chili.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/save-chili.xpm rename to Plugins/org.mitk.gui.qt.datamanager/resources/save-chili.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/resources/show-data-info.png b/Plugins/org.mitk.gui.qt.datamanager/resources/show-data-info.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/resources/show-data-info.png rename to Plugins/org.mitk.gui.qt.datamanager/resources/show-data-info.png diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.cpp new file mode 100644 index 0000000000..81a9b97237 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.cpp @@ -0,0 +1,160 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ + Version: $Revision: 18019 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkDataManagerHotkeysPrefPage.h" +#include + +#include "berryIPreferencesService.h" +#include "berryPlatform.h" + +#include +#include +#include +#include +#include +#include + +#include + +using namespace berry; + +QmitkDataManagerHotkeysPrefPage::QmitkDataManagerHotkeysPrefPage() +: m_MainControl(0) +{ + +} + +void QmitkDataManagerHotkeysPrefPage::Init(berry::IWorkbench::Pointer ) +{ + +} + +void QmitkDataManagerHotkeysPrefPage::CreateQtControl(QWidget* parent) +{ + IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID); + berry::IPreferences::Pointer _DataManagerHotkeysPreferencesNode = prefService->GetSystemPreferences()->Node("/DataManager/Hotkeys"); + m_DataManagerHotkeysPreferencesNode = _DataManagerHotkeysPreferencesNode; + + m_HotkeyEditors["Make all nodes invisible"] = new QmitkHotkeyLineEdit("Ctrl+, V"); + + m_HotkeyEditors["Toggle visibility of selected nodes"] = new QmitkHotkeyLineEdit("V"); + + m_HotkeyEditors["Delete selected nodes"] = new QmitkHotkeyLineEdit("Del"); + + m_HotkeyEditors["Reinit selected nodes"] = new QmitkHotkeyLineEdit("R"); + + m_HotkeyEditors["Global Reinit"] = new QmitkHotkeyLineEdit("Ctrl+, R"); + + m_HotkeyEditors["Save selected nodes"] = new QmitkHotkeyLineEdit("Ctrl+, S"); + + m_HotkeyEditors["Load"] = new QmitkHotkeyLineEdit("Ctrl+, L"); + + m_HotkeyEditors["Show Node Information"] = new QmitkHotkeyLineEdit("Ctrl+, I"); + + m_MainControl = new QWidget(parent); + + QGridLayout* layout = new QGridLayout; + int i = 0; + for (std::map::iterator it = m_HotkeyEditors.begin() + ; it != m_HotkeyEditors.end(); ++it) + { + layout->addWidget(new QLabel(it->first), i,0); + layout->addWidget(it->second, i,1); + layout->setRowStretch(i,0); + ++i; + } + layout->setRowStretch(i+1,10); + + m_MainControl->setLayout(layout); + this->Update(); +} + +QWidget* QmitkDataManagerHotkeysPrefPage::GetQtControl() const +{ + return m_MainControl; +} + +bool QmitkDataManagerHotkeysPrefPage::PerformOk() +{ + IPreferences::Pointer _DataManagerHotkeysPreferencesNode = m_DataManagerHotkeysPreferencesNode.Lock(); + if(_DataManagerHotkeysPreferencesNode.IsNotNull()) + { + bool duplicate = false; + QString keyString; + QString errString; + for (std::map::iterator it = m_HotkeyEditors.begin() + ; it != m_HotkeyEditors.end(); ++it) + { + keyString = it->second->GetKeySequenceAsString(); + + if(keyString.isEmpty()) + errString = QString("No valid key sequence for \"%1\"").arg(it->first); + + if(errString.isEmpty()) + { + std::map::iterator it2; + // search for duplicated key + for (it2 = m_HotkeyEditors.begin(); it2 != m_HotkeyEditors.end(); ++it2) + { + if(it->first != it2->first && keyString == it2->second->GetKeySequenceAsString()) + { + duplicate = true; + break; + } + } + if(duplicate == true) + errString = QString("Duplicate hot key for \"%1\" and \"%2\"").arg(it->first).arg(it2->first); + } + + if(!errString.isEmpty()) + { + QMessageBox::critical(QApplication::activeWindow(), "Error", errString); + return false; + } + } + + //# no errors -> save all values and flush to file + for (std::map::iterator it = m_HotkeyEditors.begin() + ; it != m_HotkeyEditors.end(); ++it) + _DataManagerHotkeysPreferencesNode->Put(it->first.toStdString() + , it->second->GetKeySequenceAsString().toStdString()); + + _DataManagerHotkeysPreferencesNode->Flush(); + + return true; + } + return false; +} + +void QmitkDataManagerHotkeysPrefPage::PerformCancel() +{ + +} + +void QmitkDataManagerHotkeysPrefPage::Update() +{ + IPreferences::Pointer _DataManagerHotkeysPreferencesNode = m_DataManagerHotkeysPreferencesNode.Lock(); + if(_DataManagerHotkeysPreferencesNode.IsNotNull()) + { + for (std::map::iterator it = m_HotkeyEditors.begin() + ; it != m_HotkeyEditors.end(); ++it) + { + it->second->setText(QString::fromStdString(_DataManagerHotkeysPreferencesNode->Get(it->first.toStdString() + , it->second->text().toStdString()))); + } + } +} diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.h b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.h new file mode 100644 index 0000000000..dbc27406fa --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerHotkeysPrefPage.h @@ -0,0 +1,73 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ + Version: $Revision: 16224 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKDATAMANAGERHOTKEYSPREFPAGE_H_ +#define QMITKDATAMANAGERHOTKEYSPREFPAGE_H_ + +#include "berryIQtPreferencePage.h" +#include + +#include +#include + +class QmitkHotkeyLineEdit; + +struct MITK_QT_DATAMANAGER QmitkDataManagerHotkeysPrefPage : public QObject, public berry::IQtPreferencePage +{ + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) + +public: + QmitkDataManagerHotkeysPrefPage(); + + void Init(berry::IWorkbench::Pointer workbench); + + void CreateQtControl(QWidget* parent); + + QWidget* GetQtControl() const; + + /// + /// \see IPreferencePage::PerformOk() + /// + virtual bool PerformOk(); + + /// + /// \see IPreferencePage::PerformCancel() + /// + virtual void PerformCancel(); + + /// + /// \see IPreferencePage::Update() + /// + virtual void Update(); + +protected: + /// + /// The node from which the properties are taken (will be catched from the preferences service in ctor) + /// + berry::IPreferences::WeakPtr m_DataManagerHotkeysPreferencesNode; + + /// + /// Maps a label to hotkey lineedit, e.g. "Toggle Visibility of selected nodes" => QmitkHotkeyLineEdit + /// + std::map m_HotkeyEditors; + + QWidget* m_MainControl; +}; + +#endif /* QMITKDATAMANAGERHOTKEYSPREFPAGE_H_ */ diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.cpp new file mode 100644 index 0000000000..061b2aa57e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.cpp @@ -0,0 +1,98 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ + Version: $Revision: 18019 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkDataManagerPreferencePage.h" +#include "QmitkDataManagerView.h" + +#include +#include +#include +#include + +#include +#include + +QmitkDataManagerPreferencePage::QmitkDataManagerPreferencePage() +: m_MainControl(0) +{ + +} + +void QmitkDataManagerPreferencePage::Init(berry::IWorkbench::Pointer ) +{ + +} + +void QmitkDataManagerPreferencePage::CreateQtControl(QWidget* parent) +{ + berry::IPreferencesService::Pointer prefService + = berry::Platform::GetServiceRegistry() + .GetServiceById(berry::IPreferencesService::ID); + + m_DataManagerPreferencesNode = prefService->GetSystemPreferences()->Node(QmitkDataManagerView::VIEW_ID); + + m_MainControl = new QWidget(parent); + m_EnableSingleEditing = new QCheckBox; + m_PlaceNewNodesOnTop = new QCheckBox; + m_ShowHelperObjects = new QCheckBox; + m_ShowNodesContainingNoData = new QCheckBox; + m_UseSurfaceDecimation = new QCheckBox; + + QFormLayout *formLayout = new QFormLayout; + formLayout->addRow("&Single click property editing:", m_EnableSingleEditing); + formLayout->addRow("&Place new nodes on top:", m_PlaceNewNodesOnTop); + formLayout->addRow("&Show helper objects:", m_ShowHelperObjects); + formLayout->addRow("&Show nodes containing no data", m_ShowNodesContainingNoData); + formLayout->addRow("&Use surface decimation:", m_UseSurfaceDecimation); + + m_MainControl->setLayout(formLayout); + this->Update(); +} + +QWidget* QmitkDataManagerPreferencePage::GetQtControl() const +{ + return m_MainControl; +} + +bool QmitkDataManagerPreferencePage::PerformOk() +{ + m_DataManagerPreferencesNode->PutBool("Single click property editing" + , m_EnableSingleEditing->isChecked()); + m_DataManagerPreferencesNode->PutBool("Place new nodes on top" + , m_PlaceNewNodesOnTop->isChecked()); + m_DataManagerPreferencesNode->PutBool("Show helper objects" + , m_ShowHelperObjects->isChecked()); + m_DataManagerPreferencesNode->PutBool("Show nodes containing no data" + , m_ShowNodesContainingNoData->isChecked()); + m_DataManagerPreferencesNode->PutBool("Use surface decimation" + , m_UseSurfaceDecimation->isChecked()); + return true; +} + +void QmitkDataManagerPreferencePage::PerformCancel() +{ + +} + +void QmitkDataManagerPreferencePage::Update() +{ + m_EnableSingleEditing->setChecked(m_DataManagerPreferencesNode->GetBool("Single click property editing", true)); + m_PlaceNewNodesOnTop->setChecked(m_DataManagerPreferencesNode->GetBool("Place new nodes on top", true)); + m_ShowHelperObjects->setChecked(m_DataManagerPreferencesNode->GetBool("Show helper objects", false)); + m_ShowNodesContainingNoData->setChecked(m_DataManagerPreferencesNode->GetBool("Show nodes containing no data", false)); + m_UseSurfaceDecimation->setChecked(m_DataManagerPreferencesNode->GetBool("Use surface decimation", true)); +} diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.h b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.h new file mode 100644 index 0000000000..03d0679d6f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerPreferencePage.h @@ -0,0 +1,68 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ + Version: $Revision: 16224 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKDATAMANAGERPREFERENCEPAGE_H_ +#define QMITKDATAMANAGERPREFERENCEPAGE_H_ + +#include "berryIQtPreferencePage.h" +#include +#include + +class QWidget; +class QCheckBox; + +struct MITK_QT_DATAMANAGER QmitkDataManagerPreferencePage : public QObject, public berry::IQtPreferencePage +{ + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) + +public: + QmitkDataManagerPreferencePage(); + + void Init(berry::IWorkbench::Pointer workbench); + + void CreateQtControl(QWidget* widget); + + QWidget* GetQtControl() const; + + /// + /// \see IPreferencePage::PerformOk() + /// + virtual bool PerformOk(); + + /// + /// \see IPreferencePage::PerformCancel() + /// + virtual void PerformCancel(); + + /// + /// \see IPreferencePage::Update() + /// + virtual void Update(); + +protected: + QWidget* m_MainControl; + QCheckBox* m_EnableSingleEditing; + QCheckBox* m_PlaceNewNodesOnTop; + QCheckBox* m_ShowHelperObjects; + QCheckBox* m_ShowNodesContainingNoData; + QCheckBox* m_UseSurfaceDecimation; + berry::IPreferences::Pointer m_DataManagerPreferencesNode; +}; + +#endif /* QMITKDATAMANAGERPREFERENCEPAGE_H_ */ diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp new file mode 100644 index 0000000000..adbadf70d4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp @@ -0,0 +1,925 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkDataManagerView.h" + +#include + +//# Own Includes +//## mitk +#include "mitkDataStorageEditorInput.h" +#include "mitkIDataStorageReference.h" +#include "mitkNodePredicateDataType.h" +#include "mitkCoreObjectFactory.h" +#include "mitkPACSPlugin.h" +#include "mitkDataNodeFactory.h" +#include "mitkColorProperty.h" +#include "mitkCommon.h" +#include "mitkDelegateManager.h" +#include "mitkNodePredicateData.h" +#include "mitkNodePredicateNot.h" +#include "mitkNodePredicateProperty.h" +#include "mitkEnumerationProperty.h" +#include "mitkProperties.h" +#include +#include +#include +#include +//## Qmitk +#include +#include +#include +#include +#include +#include +#include +#include "src/internal/QmitkNodeTableViewKeyFilter.h" +#include "src/internal/QmitkInfoDialog.h" +//## Berry +#include +#include +#include +#include +#include +#include + +//# Toolkit Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mitkDataNodeObject.h" +#include "mitkIContextMenuAction.h" +#include "berryIExtensionPointService.h" + +const std::string QmitkDataManagerView::VIEW_ID = "org.mitk.views.datamanager"; + +QmitkDataManagerView::QmitkDataManagerView() +{ +} + +QmitkDataManagerView::~QmitkDataManagerView() +{ +} + +void QmitkDataManagerView::CreateQtPartControl(QWidget* parent) +{ + m_CurrentRowCount = 0; + m_Parent = parent; + //# Preferences + berry::IPreferencesService::Pointer prefService + = berry::Platform::GetServiceRegistry() + .GetServiceById(berry::IPreferencesService::ID); + + berry::IBerryPreferences::Pointer prefs + = (prefService->GetSystemPreferences()->Node(VIEW_ID)) + .Cast(); + assert( prefs ); + prefs->OnChanged.AddListener( berry::MessageDelegate1( this + , &QmitkDataManagerView::OnPreferencesChanged ) ); + + //# GUI + m_NodeTreeModel = new QmitkDataStorageTreeModel(this->GetDataStorage()); + m_NodeTreeModel->setParent( parent ); + m_NodeTreeModel->SetPlaceNewNodesOnTop( + prefs->GetBool("Place new nodes on top", true) ); + m_NodeTreeModel->SetShowHelperObjects( + prefs->GetBool("Show helper objects", false) ); + m_NodeTreeModel->SetShowNodesContainingNoData( + prefs->GetBool("Show nodes containing no data", false) ); + m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); + + //# Tree View (experimental) + m_NodeTreeView = new QTreeView; + m_NodeTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection ); + m_NodeTreeView->setSelectionBehavior( QAbstractItemView::SelectRows ); + m_NodeTreeView->setAlternatingRowColors(true); + m_NodeTreeView->setDragEnabled(true); + m_NodeTreeView->setDropIndicatorShown(true); + m_NodeTreeView->setAcceptDrops(true); + m_NodeTreeView->setContextMenuPolicy(Qt::CustomContextMenu); + m_NodeTreeView->setModel(m_NodeTreeModel); + m_NodeTreeView->installEventFilter(new QmitkNodeTableViewKeyFilter(this)); + QObject::connect( m_NodeTreeView, SIGNAL(customContextMenuRequested(const QPoint&)) + , this, SLOT(NodeTableViewContextMenuRequested(const QPoint&)) ); + QObject::connect( m_NodeTreeModel, SIGNAL(rowsInserted (const QModelIndex&, int, int)) + , this, SLOT(NodeTreeViewRowsInserted ( const QModelIndex&, int, int )) ); + QObject::connect( m_NodeTreeModel, SIGNAL(rowsRemoved (const QModelIndex&, int, int)) + , this, SLOT(NodeTreeViewRowsRemoved( const QModelIndex&, int, int )) ); + QObject::connect( m_NodeTreeView->selectionModel() + , SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection & ) ) + , this + , SLOT( NodeSelectionChanged ( const QItemSelection &, const QItemSelection & ) ) ); + + //# m_NodeMenu + m_NodeMenu = new QMenu(m_NodeTreeView); + + // # Actions + berry::IEditorRegistry* editorRegistry = berry::PlatformUI::GetWorkbench()->GetEditorRegistry(); + std::list editors = editorRegistry->GetEditors("*.mitk"); + if (editors.size() > 1) + { + m_ShowInMapper = new QSignalMapper(this); + foreach(berry::IEditorDescriptor::Pointer descriptor, editors) + { + QAction* action = new QAction(QString::fromStdString(descriptor->GetLabel()), this); + m_ShowInActions << action; + m_ShowInMapper->connect(action, SIGNAL(triggered()), m_ShowInMapper, SLOT(map())); + m_ShowInMapper->setMapping(action, QString::fromStdString(descriptor->GetId())); + } + connect(m_ShowInMapper, SIGNAL(mapped(QString)), this, SLOT(ShowIn(QString))); + } + + QmitkNodeDescriptor* unknownDataNodeDescriptor = + QmitkNodeDescriptorManager::GetInstance()->GetUnknownDataNodeDescriptor(); + + QmitkNodeDescriptor* imageDataNodeDescriptor = + QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Image"); + + QmitkNodeDescriptor* surfaceDataNodeDescriptor = + QmitkNodeDescriptorManager::GetInstance()->GetDescriptor("Surface"); + + m_GlobalReinitAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"), "Global Reinit", this); + QObject::connect( m_GlobalReinitAction, SIGNAL( triggered(bool) ) + , this, SLOT( GlobalReinit(bool) ) ); + unknownDataNodeDescriptor->AddAction(m_GlobalReinitAction); + + m_SaveAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Save_48.png"), "Save...", this); + QObject::connect( m_SaveAction, SIGNAL( triggered(bool) ) + , this, SLOT( SaveSelectedNodes(bool) ) ); + unknownDataNodeDescriptor->AddAction(m_SaveAction); + + m_RemoveAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Remove_48.png"), "Remove", this); + QObject::connect( m_RemoveAction, SIGNAL( triggered(bool) ) + , this, SLOT( RemoveSelectedNodes(bool) ) ); + unknownDataNodeDescriptor->AddAction(m_RemoveAction); + + m_ReinitAction = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/Refresh_48.png"), "Reinit", this); + QObject::connect( m_ReinitAction, SIGNAL( triggered(bool) ) + , this, SLOT( ReinitSelectedNodes(bool) ) ); + unknownDataNodeDescriptor->AddAction(m_ReinitAction); + + // find contextMenuAction extension points and add them to the node descriptor + berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); + berry::IConfigurationElement::vector cmActions( + extensionPointService->GetConfigurationElementsFor("org.mitk.gui.qt.datamanager.contextMenuActions") ); + berry::IConfigurationElement::vector::iterator cmActionsIt; + + std::string cmNodeDescriptorName; + std::string cmLabel; + std::string cmIcon; + std::string cmClass; + + QmitkNodeDescriptor* tmpDescriptor; + QAction* contextMenuAction; + QVariant cmActionDataIt; + m_ConfElements.clear(); + + int i=1; + for (cmActionsIt = cmActions.begin() + ; cmActionsIt != cmActions.end() + ; ++cmActionsIt) + { + cmIcon.erase(); + if((*cmActionsIt)->GetAttribute("nodeDescriptorName", cmNodeDescriptorName) + && (*cmActionsIt)->GetAttribute("label", cmLabel) + && (*cmActionsIt)->GetAttribute("class", cmClass)) + { + (*cmActionsIt)->GetAttribute("icon", cmIcon); + // create context menu entry here + tmpDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(QString::fromStdString(cmNodeDescriptorName)); + if(!tmpDescriptor) + { + MITK_WARN << "cannot add action \"" << cmLabel << "\" because descriptor " << cmNodeDescriptorName << " does not exist"; + continue; + } + contextMenuAction = new QAction( QString::fromStdString(cmLabel), parent); + tmpDescriptor->AddAction(contextMenuAction); + m_ConfElements[contextMenuAction] = *cmActionsIt; + + cmActionDataIt.setValue(i); + contextMenuAction->setData( cmActionDataIt ); + connect( contextMenuAction, SIGNAL( triggered(bool) ) , this, SLOT( ContextMenuActionTriggered(bool) ) ); + ++i; + } + } + + m_OpacitySlider = new QSlider; + m_OpacitySlider->setMinimum(0); + m_OpacitySlider->setMaximum(100); + m_OpacitySlider->setOrientation(Qt::Horizontal); + QObject::connect( m_OpacitySlider, SIGNAL( valueChanged(int) ) + , this, SLOT( OpacityChanged(int) ) ); + + QLabel* _OpacityLabel = new QLabel("Opacity: "); + QHBoxLayout* _OpacityWidgetLayout = new QHBoxLayout; + _OpacityWidgetLayout->setContentsMargins(4,4,4,4); + _OpacityWidgetLayout->addWidget(_OpacityLabel); + _OpacityWidgetLayout->addWidget(m_OpacitySlider); + QWidget* _OpacityWidget = new QWidget; + _OpacityWidget->setLayout(_OpacityWidgetLayout); + + m_OpacityAction = new QWidgetAction(this); + m_OpacityAction->setDefaultWidget(_OpacityWidget); + QObject::connect( m_OpacityAction, SIGNAL( changed() ) + , this, SLOT( OpacityActionChanged() ) ); + unknownDataNodeDescriptor->AddAction(m_OpacityAction, false); + + m_ColorButton = new QPushButton; + m_ColorButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + //m_ColorButton->setText("Change color"); + QObject::connect( m_ColorButton, SIGNAL( clicked() ) + , this, SLOT( ColorChanged() ) ); + + QLabel* _ColorLabel = new QLabel("Color: "); + _ColorLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + QHBoxLayout* _ColorWidgetLayout = new QHBoxLayout; + _ColorWidgetLayout->setContentsMargins(4,4,4,4); + _ColorWidgetLayout->addWidget(_ColorLabel); + _ColorWidgetLayout->addWidget(m_ColorButton); + QWidget* _ColorWidget = new QWidget; + _ColorWidget->setLayout(_ColorWidgetLayout); + + m_ColorAction = new QWidgetAction(this); + m_ColorAction->setDefaultWidget(_ColorWidget); + QObject::connect( m_ColorAction, SIGNAL( changed() ) + , this, SLOT( ColorActionChanged() ) ); + unknownDataNodeDescriptor->AddAction(m_ColorAction, false); + + m_TextureInterpolation = new QAction("Texture Interpolation", this); + m_TextureInterpolation->setCheckable ( true ); + QObject::connect( m_TextureInterpolation, SIGNAL( changed() ) + , this, SLOT( TextureInterpolationChanged() ) ); + QObject::connect( m_TextureInterpolation, SIGNAL( toggled(bool) ) + , this, SLOT( TextureInterpolationToggled(bool) ) ); + imageDataNodeDescriptor->AddAction(m_TextureInterpolation, false); + + m_SurfaceRepresentation = new QAction("Surface Representation", this); + m_SurfaceRepresentation->setMenu(new QMenu); + + QObject::connect( m_SurfaceRepresentation->menu(), SIGNAL( aboutToShow() ) + , this, SLOT( SurfaceRepresentationMenuAboutToShow() ) ); + surfaceDataNodeDescriptor->AddAction(m_SurfaceRepresentation, false); + + m_ShowOnlySelectedNodes + = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/ShowSelectedNode_48.png") + , "Show only selected nodes", this); + QObject::connect( m_ShowOnlySelectedNodes, SIGNAL( triggered(bool) ) + , this, SLOT( ShowOnlySelectedNodes(bool) ) ); + unknownDataNodeDescriptor->AddAction(m_ShowOnlySelectedNodes); + + m_ToggleSelectedVisibility + = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/InvertShowSelectedNode_48.png") + , "Toggle visibility", this); + QObject::connect( m_ToggleSelectedVisibility, SIGNAL( triggered(bool) ) + , this, SLOT( ToggleVisibilityOfSelectedNodes(bool) ) ); + unknownDataNodeDescriptor->AddAction(m_ToggleSelectedVisibility); + + m_ActionShowInfoDialog + = new QAction(QIcon(":/org.mitk.gui.qt.datamanager/ShowDataInfo_48.png") + , "Details...", this); + QObject::connect( m_ActionShowInfoDialog, SIGNAL( triggered(bool) ) + , this, SLOT( ShowInfoDialogForSelectedNodes(bool) ) ); + unknownDataNodeDescriptor->AddAction(m_ActionShowInfoDialog); + + m_OtsuFilterAction = new QAction("Apply Otsu Filter", this); + QObject::connect( m_OtsuFilterAction, SIGNAL( triggered(bool) ) + , this, SLOT( OtsuFilter(bool) ) ); + // Otsu filter does not work properly, remove it temporarily + // imageDataNodeDescriptor->AddAction(m_OtsuFilterAction); + + QGridLayout* _DndFrameWidgetLayout = new QGridLayout; + _DndFrameWidgetLayout->addWidget(m_NodeTreeView, 0, 0); + _DndFrameWidgetLayout->setContentsMargins(0,0,0,0); + + m_DndFrameWidget = new QmitkDnDFrameWidget(m_Parent); + m_DndFrameWidget->setLayout(_DndFrameWidgetLayout); + + QVBoxLayout* layout = new QVBoxLayout(parent); + layout->addWidget(m_DndFrameWidget); + layout->setContentsMargins(0,0,0,0); + + m_Parent->setLayout(layout); +} + +void QmitkDataManagerView::SetFocus() +{ +} + +void QmitkDataManagerView::ContextMenuActionTriggered( bool ) +{ + QAction* action = qobject_cast ( sender() ); + + std::map::iterator it + = m_ConfElements.find( action ); + if( it == m_ConfElements.end() ) + { + MITK_WARN << "associated conf element for action " << action->text().toStdString() << " not found"; + return; + } + berry::IConfigurationElement::Pointer confElem = it->second; + mitk::IContextMenuAction* contextMenuAction = confElem->CreateExecutableExtension("class"); + + std::string className; + std::string smoothed; + confElem->GetAttribute("class", className); + confElem->GetAttribute("smoothed", smoothed); + if(className == "QmitkThresholdAction") + { + contextMenuAction->SetDataStorage(this->GetDataStorage()); + } + else if(className == "QmitkCreatePolygonModelAction") + { + contextMenuAction->SetDataStorage(this->GetDataStorage()); + if(smoothed == "false") + { + contextMenuAction->SetSmoothed(false); + } + else + { + contextMenuAction->SetSmoothed(true); + } + contextMenuAction->SetDecimated(m_SurfaceDecimation); + } + else if(className == "QmitkStatisticsAction") + { + contextMenuAction->SetFunctionality(this); + } + contextMenuAction->Run( this->GetCurrentSelection() ); // run the action +} + +void QmitkDataManagerView::OnPreferencesChanged(const berry::IBerryPreferences* prefs) +{ + if( m_NodeTreeModel->GetPlaceNewNodesOnTopFlag() != prefs->GetBool("Place new nodes on top", true) ) + m_NodeTreeModel->SetPlaceNewNodesOnTop( !m_NodeTreeModel->GetPlaceNewNodesOnTopFlag() ); + + if( m_NodeTreeModel->GetShowHelperObjectsFlag()!= prefs->GetBool("Show helper objects", false) ) + m_NodeTreeModel->SetShowHelperObjects( !m_NodeTreeModel->GetShowHelperObjectsFlag() ); + + if( m_NodeTreeModel->GetShowNodesContainingNoDataFlag()!= prefs->GetBool("Show nodes containing no data", false) ) + m_NodeTreeModel->SetShowNodesContainingNoData( !m_NodeTreeModel->GetShowNodesContainingNoDataFlag() ); + + m_NodeTreeView->expandAll(); + + m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); + + this->GlobalReinit(); + + +} + +void QmitkDataManagerView::NodeTableViewContextMenuRequested( const QPoint & pos ) +{ + QModelIndex selected = m_NodeTreeView->indexAt ( pos ); + mitk::DataNode::Pointer node = m_NodeTreeModel->GetNode(selected); + QList selectedNodes = this->GetCurrentSelection(); + + if(!selectedNodes.isEmpty()) + { + m_NodeMenu->clear(); + QList actions; + if(selectedNodes.size() == 1 ) + { + actions = QmitkNodeDescriptorManager::GetInstance()->GetActions(node); + + for(QList::iterator it = actions.begin(); it != actions.end(); ++it) + { + (*it)->setData(QVariant::fromValue(node.GetPointer())); + } + } + else + actions = QmitkNodeDescriptorManager::GetInstance()->GetActions(selectedNodes); + + if (!m_ShowInActions.isEmpty()) + { + QMenu* showInMenu = m_NodeMenu->addMenu("Show In"); + showInMenu->addActions(m_ShowInActions); + } + m_NodeMenu->addActions(actions); + m_NodeMenu->popup(QCursor::pos()); + } +} + +void QmitkDataManagerView::OpacityChanged(int value) +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(node) + { + float opacity = static_cast(value)/100.0f; + node->SetFloatProperty("opacity", opacity); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + + MITK_INFO << "slider changed"; +} + +void QmitkDataManagerView::OpacityActionChanged() +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(node) + { + float opacity = 0.0; + if(node->GetFloatProperty("opacity", opacity)) + { + m_OpacitySlider->setValue(static_cast(opacity*100)); + } + } + MITK_INFO << "changed"; +} + +void QmitkDataManagerView::ColorChanged() +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(node) + { + QColor color = QColorDialog::getColor(); + m_ColorButton->setAutoFillBackground(true); + node->SetProperty("color",mitk::ColorProperty::New(color.red()/255.0,color.green()/255.0,color.blue()/255.0)); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + + MITK_INFO << "slider changed"; +} + +void QmitkDataManagerView::ColorActionChanged() +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(node) + { + mitk::Color color; + mitk::ColorProperty::Pointer colorProp; + node->GetProperty(colorProp,"color"); + if(colorProp.IsNull()) + return; + color = colorProp->GetValue(); + + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color[0]*255)); + styleSheet.append(","); + styleSheet.append(QString::number(color[1]*255)); + styleSheet.append(","); + styleSheet.append(QString::number(color[2]*255)); + styleSheet.append(")"); + m_ColorButton->setStyleSheet(styleSheet); + } + MITK_INFO << "changed"; +} + +void QmitkDataManagerView::TextureInterpolationChanged() +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(node) + { + bool textureInterpolation = false; + node->GetBoolProperty("texture interpolation", textureInterpolation); + m_TextureInterpolation->setChecked(textureInterpolation); + } +} + +void QmitkDataManagerView::TextureInterpolationToggled( bool checked ) +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(node) + { + node->SetBoolProperty("texture interpolation", checked); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + +} + +void QmitkDataManagerView::SurfaceRepresentationMenuAboutToShow() +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(!node) + return; + + mitk::EnumerationProperty* representationProp = + dynamic_cast (node->GetProperty("material.representation")); + if(!representationProp) + return; + + // clear menu + m_SurfaceRepresentation->menu()->clear(); + QAction* tmp; + + // create menu entries + for(mitk::EnumerationProperty::EnumConstIterator it=representationProp->Begin(); it!=representationProp->End() + ; it++) + { + tmp = m_SurfaceRepresentation->menu()->addAction(QString::fromStdString(it->second)); + tmp->setCheckable(true); + + if(it->second == representationProp->GetValueAsString()) + { + tmp->setChecked(true); + } + + QObject::connect( tmp, SIGNAL( triggered(bool) ) + , this, SLOT( SurfaceRepresentationActionToggled(bool) ) ); + } +} + +void QmitkDataManagerView::SurfaceRepresentationActionToggled( bool /*checked*/ ) +{ + mitk::DataNode* node = m_NodeTreeModel->GetNode(m_NodeTreeView->selectionModel()->currentIndex()); + if(!node) + return; + + mitk::EnumerationProperty* representationProp = + dynamic_cast (node->GetProperty("material.representation")); + if(!representationProp) + return; + + QAction* senderAction = qobject_cast ( QObject::sender() ); + + if(!senderAction) + return; + + std::string activatedItem = senderAction->text().toStdString(); + + if ( activatedItem != representationProp->GetValueAsString() ) + { + if ( representationProp->IsValidEnumerationValue( activatedItem ) ) + { + representationProp->SetValue( activatedItem ); + representationProp->InvokeEvent( itk::ModifiedEvent() ); + representationProp->Modified(); + + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + } + +} + +void QmitkDataManagerView::SaveSelectedNodes( bool ) +{ + QModelIndexList indexesOfSelectedRows = m_NodeTreeView->selectionModel()->selectedRows(); + + mitk::DataNode* node = 0; + unsigned int indexesOfSelectedRowsSize = indexesOfSelectedRows.size(); + for (unsigned int i = 0; iGetNode(indexesOfSelectedRows.at(i)); + // if node is not defined or if the node contains geometry data do not remove it + if ( node != 0 ) + { + mitk::BaseData::Pointer data = node->GetData(); + if (data.IsNotNull()) + { + QString error; + try + { + CommonFunctionality::SaveBaseData( data.GetPointer(), node->GetName().c_str() ); + } + catch(std::exception& e) + { + error = e.what(); + } + catch(...) + { + error = "Unknown error occured"; + } + if( !error.isEmpty() ) + QMessageBox::critical( m_Parent, "Error saving...", error ); + } + } + } +} + +void QmitkDataManagerView::ReinitSelectedNodes( bool ) +{ + mitk::IRenderWindowPart* renderWindow = this->OpenRenderWindowPart(); + + QList selectedNodes = this->GetCurrentSelection(); + + foreach(mitk::DataNode::Pointer node, selectedNodes) + { + mitk::BaseData::Pointer basedata = node->GetData(); + if (basedata.IsNotNull()) + { + renderWindow->GetRenderingManager()->InitializeViews( + basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + renderWindow->GetRenderingManager()->RequestUpdateAll(); + } + } +} + +void QmitkDataManagerView::RemoveSelectedNodes( bool ) +{ + QModelIndexList indexesOfSelectedRows = m_NodeTreeView->selectionModel()->selectedRows(); + if(indexesOfSelectedRows.size() < 1) + { + return; + } + std::vector selectedNodes; + + mitk::DataNode* node = 0; + QString question = tr("Do you really want to remove "); + + for (QModelIndexList::iterator it = indexesOfSelectedRows.begin() + ; it != indexesOfSelectedRows.end(); it++) + { + node = m_NodeTreeModel->GetNode(*it); + // if node is not defined or if the node contains geometry data do not remove it + if ( node != 0 /*& strcmp(node->GetData()->GetNameOfClass(), "Geometry2DData") != 0*/ ) + { + selectedNodes.push_back(node); + question.append(QString::fromStdString(node->GetName())); + question.append(", "); + } + } + // remove the last two characters = ", " + question = question.remove(question.size()-2, 2); + question.append(" from data storage?"); + + QMessageBox::StandardButton answerButton = QMessageBox::question( m_Parent + , tr("DataManager") + , question + , QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + + if(answerButton == QMessageBox::Yes) + { + for (std::vector::iterator it = selectedNodes.begin() + ; it != selectedNodes.end(); it++) + { + node = *it; + this->GetDataStorage()->Remove(node); + this->GlobalReinit(false); + } + } +} + +void QmitkDataManagerView::MakeAllNodesInvisible( bool ) +{ + QList nodes = m_NodeTreeModel->GetNodeSet(); + + foreach(mitk::DataNode::Pointer node, nodes) + { + node->SetVisibility(false); + } + //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkDataManagerView::ShowOnlySelectedNodes( bool ) +{ + QList selectedNodes = this->GetCurrentSelection(); + QList allNodes = m_NodeTreeModel->GetNodeSet(); + + foreach(mitk::DataNode::Pointer node, allNodes) + { + node->SetVisibility(selectedNodes.contains(node)); + } + //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkDataManagerView::ToggleVisibilityOfSelectedNodes( bool ) +{ + QList selectedNodes = this->GetCurrentSelection(); + + bool isVisible = false; + foreach(mitk::DataNode::Pointer node, selectedNodes) + { + isVisible = false; + node->GetBoolProperty("visible", isVisible); + node->SetVisibility(!isVisible); + } + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkDataManagerView::ShowInfoDialogForSelectedNodes( bool ) +{ + QList selectedNodes = this->GetCurrentSelection(); + + QmitkInfoDialog _QmitkInfoDialog(selectedNodes, this->m_Parent); + _QmitkInfoDialog.exec(); +} + +void QmitkDataManagerView::Load( bool ) +{ + QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Load data", "", mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); + for ( QStringList::Iterator it = fileNames.begin(); it != fileNames.end(); ++it ) + { + FileOpen((*it).toAscii(), 0); + } +} + +void QmitkDataManagerView::FileOpen( const char * fileName, mitk::DataNode* parentNode ) +{ + mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); + + try + { + factory->SetFileName( fileName ); + + QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); + + factory->Update(); + + for ( unsigned int i = 0 ; i < factory->GetNumberOfOutputs( ); ++i ) + { + mitk::DataNode::Pointer node = factory->GetOutput( i ); + if ( ( node.IsNotNull() ) && ( node->GetData() != NULL ) ) + { + this->GetDataStorage()->Add(node, parentNode); + mitk::BaseData::Pointer basedata = node->GetData(); + mitk::RenderingManager::GetInstance()->InitializeViews( + basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + } + } + catch ( itk::ExceptionObject & ex ) + { + itkGenericOutputMacro( << "Exception during file open: " << ex ); + } + + QApplication::restoreOverrideCursor(); +} + +QItemSelectionModel *QmitkDataManagerView::GetDataNodeSelectionModel() const +{ + return m_NodeTreeView->selectionModel(); +} + +void QmitkDataManagerView::GlobalReinit( bool ) +{ + mitk::IRenderWindowPart* renderWindow = this->OpenRenderWindowPart(); + // 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::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible"); + + // initialize the views to the bounding geometry + renderWindow->GetRenderingManager()->InitializeViews(bounds); +} + +void QmitkDataManagerView::OnSelectionChanged( berry::IWorkbenchPart::Pointer part , const QList& selection ) +{ + if(part.GetPointer() == this) + return; + + QItemSelection newSelection; + + m_NodeTreeView->selectionModel()->reset(); + + foreach(mitk::DataNode::Pointer node, selection) + { + QModelIndex treeIndex = m_NodeTreeModel->GetIndex(node); + if(treeIndex.isValid()) + newSelection.select(treeIndex, treeIndex); + } + m_NodeTreeView->selectionModel()->select(newSelection, QItemSelectionModel::SelectCurrent); +} + +void QmitkDataManagerView::OtsuFilter( bool ) +{ + QList selectedNodes = this->GetCurrentSelection(); + + mitk::Image::Pointer mitkImage = 0; + foreach(mitk::DataNode::Pointer node, selectedNodes) + { + mitkImage = dynamic_cast( node->GetData() ); + + if(mitkImage.IsNull()) + continue; + + try + { + // get selected mitk image + const unsigned short dim = 3; + typedef short InputPixelType; + typedef unsigned char OutputPixelType; + + typedef itk::Image< InputPixelType, dim > InputImageType; + typedef itk::Image< OutputPixelType, dim > OutputImageType; + + typedef itk::OtsuThresholdImageFilter< InputImageType, OutputImageType > FilterType; + FilterType::Pointer filter = FilterType::New(); + + filter->SetOutsideValue( 1 ); + filter->SetInsideValue( 0 ); + + InputImageType::Pointer itkImage; + mitk::CastToItkImage(mitkImage, itkImage); + + filter->SetInput( itkImage ); + + filter->Update(); + + mitk::DataNode::Pointer resultNode = mitk::DataNode::New(); + std::string nameOfResultImage = node->GetName(); + nameOfResultImage.append("Otsu"); + resultNode->SetProperty("name", mitk::StringProperty::New(nameOfResultImage) ); + resultNode->SetProperty("binary", mitk::BoolProperty::New(true) ); + resultNode->SetData( mitk::ImportItkImage ( filter->GetOutput() ) ); + + this->GetDataStorage()->Add(resultNode, node); + + } + catch( std::exception& err ) + { + MITK_ERROR(this->GetClassName()) << err.what(); + } + + } +} +void QmitkDataManagerView::NodeTreeViewRowsRemoved ( + const QModelIndex & /*parent*/, int /*start*/, int /*end*/ ) +{ + m_CurrentRowCount = m_NodeTreeModel->rowCount(); +} +void QmitkDataManagerView::NodeTreeViewRowsInserted( const QModelIndex & parent, int, int ) +{ + m_NodeTreeView->setExpanded(parent, true); + + // a new row was inserted + if( m_CurrentRowCount == 0 && m_NodeTreeModel->rowCount() == 1 ) + { + this->OpenRenderWindowPart(); + m_CurrentRowCount = m_NodeTreeModel->rowCount(); + /* + std::vector nodes = m_NodeTreeModel->GetNodeSet(); + if(nodes.size() == 1) + { + QModelIndex treeIndex = m_NodeTreeModel->GetIndex(nodes.front()); + m_NodeTreeView->selectionModel()->setCurrentIndex( treeIndex, QItemSelectionModel::ClearAndSelect ); + } + */ + } +} + +void QmitkDataManagerView::NodeSelectionChanged( const QItemSelection & /*selected*/, const QItemSelection & /*deselected*/ ) +{ + QList nodes = m_NodeTreeModel->GetNodeSet(); + + foreach(mitk::DataNode::Pointer node, nodes) + { + if ( node.IsNotNull() ) + node->SetBoolProperty("selected", false); + } + + nodes.clear(); + nodes = this->GetCurrentSelection(); + + foreach(mitk::DataNode::Pointer node, nodes) + { + if ( node.IsNotNull() ) + node->SetBoolProperty("selected", true); + } + //changing the selection does NOT require any rendering processes! + //mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkDataManagerView::ShowIn(const QString &editorId) +{ + berry::IWorkbenchPage::Pointer page = this->GetSite()->GetPage(); + berry::IEditorInput::Pointer input(new mitk::DataStorageEditorInput(this->GetDataStorageReference())); + page->OpenEditor(input, editorId.toStdString(), false, berry::IWorkbenchPage::MATCH_ID); +} + +mitk::IRenderWindowPart* QmitkDataManagerView::OpenRenderWindowPart() +{ + return this->GetRenderWindowPart(QmitkAbstractView::ACTIVATE | QmitkAbstractView::OPEN); +} diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h new file mode 100644 index 0000000000..e3d6cce6b3 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.h @@ -0,0 +1,270 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKDATAMANAGERVIEW_H_ +#define QMITKDATAMANAGERVIEW_H_ + +// BlueBerry includes +#include + +/// Qmitk +#include + +/// Qt +#include + +#include + +// Forward declarations +class QMenu; +class QAction; +class QComboBox; +class QWidgetAction; +class QSlider; +class QModelIndex; +class QTreeView; +class QPushButton; +class QToolBar; +class QMenu; +class QSignalMapper; + +class QmitkDnDFrameWidget; +class QmitkDataStorageTreeModel; + +/// +/// \ingroup org_mitk_gui_qt_datamanager_internal +/// +/// \brief A View class that can show all data tree nodes of a certain DataStorage +/// +/// \TODO: complete PACS support, in save dialog show regular filename +/// +class MITK_QT_DATAMANAGER QmitkDataManagerView : public QmitkAbstractView +{ + Q_OBJECT + +public: + + static const std::string VIEW_ID; // = "org.mitk.extapp.defaultperspective" + /// + /// \brief Standard ctor. + /// + QmitkDataManagerView(); + + /// + /// \brief Standard dtor. + /// + virtual ~QmitkDataManagerView(); + +public slots: + /// + /// Invoked when the opacity slider changed + /// + void OpacityChanged(int value); + /// + /// Invoked when the opacity action changed + /// In this function the the opacity slider is set to the selected nodes opacity value + /// + void OpacityActionChanged(); + /// + /// Invoked when the color button is pressed + /// + void ColorChanged(); + /// + /// Invoked when the color action changed + /// + void ColorActionChanged(); + /// + /// Invoked when the color button is pressed + /// + void TextureInterpolationChanged(); + /// + /// Invoked when the color action changed + /// + void TextureInterpolationToggled ( bool checked ); + /// + /// SurfaceRepresentationActionToggled + /// + void SurfaceRepresentationMenuAboutToShow (); + ///public + /// SurfaceRepresentationActionToggled + /// + void SurfaceRepresentationActionToggled ( bool checked ); + /// + /// \brief Shows a node context menu. + /// + void NodeTableViewContextMenuRequested( const QPoint & index ); + /// + /// \brief Invoked when an element should be saved. + /// + void SaveSelectedNodes( bool checked = false ); + /// + /// \brief Invoked when an element should be removed. + /// + void RemoveSelectedNodes( bool checked = false ); + /// + /// \brief Invoked when an element should be reinitiliased. + /// + void ReinitSelectedNodes( bool checked = false ); + /// + /// \brief Invoked when the visibility of the selected nodes should be toggled. + /// + void MakeAllNodesInvisible ( bool checked = false ); + /// + /// \brief Makes all selected nodes visible, all other nodes invisible. + /// + void ShowOnlySelectedNodes ( bool checked = false ); + /// + /// \brief Invoked when the visibility of the selected nodes should be toggled. + /// + void ToggleVisibilityOfSelectedNodes ( bool checked = false ); + /// + /// \brief Invoked when infos of the selected nodes should be shown in a dialog. + /// + void ShowInfoDialogForSelectedNodes ( bool checked = false ); + /// + /// \brief Shows a load dialog. + /// + void Load ( bool checked = false ); + /// + /// \brief Reinits everything. + /// + void GlobalReinit ( bool checked = false ); + /// + /// Invoked when the preferences were changed + /// + void OnPreferencesChanged(const berry::IBerryPreferences*); + /// + /// \brief will be toggled when a extension point context menu action is toggled + /// this is a proxy method which will load the corresponding extension class + /// and run IContextMenuAction + /// + void ContextMenuActionTriggered( bool ); + + /// + /// Invoked when the MITK workbench selection changed + /// + void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, + const QList& selection); + + /// Invoked when the median action is invoked + void OtsuFilter( bool checked = false ); + + /// When rows are inserted auto expand them + void NodeTreeViewRowsInserted ( const QModelIndex & parent, int start, int end ); + + /// will setup m_CurrentRowCount + void NodeTreeViewRowsRemoved ( const QModelIndex & parent, int start, int end ); + + /// Whenever the selection changes set the "selected" property respectively + void NodeSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ); + + /// Opens the editor with the given id using the current data storage + void ShowIn(const QString& editorId); + +protected: + + /// + /// \brief Create the view here. + /// + virtual void CreateQtPartControl(QWidget* parent); + + void SetFocus(); + + /// + /// \brief Shows a file open dialog. + /// + void FileOpen( const char * fileName, mitk::DataNode* parentNode ); + +protected: + + QWidget* m_Parent; + QmitkDnDFrameWidget* m_DndFrameWidget; + + /// + /// \brief A plain widget as the base pane. + /// + QmitkDataStorageTreeModel* m_NodeTreeModel; + /// + /// Holds the preferences for the datamanager. + /// + berry::IBerryPreferences::Pointer m_DataManagerPreferencesNode; + /// + /// saves the configuration elements for the context menu actions from extension points + /// + std::map m_ConfElements; + /// + /// \brief The Table view to show the selected nodes. + /// + QTreeView* m_NodeTreeView; + /// + /// \brief The context menu that shows up when right clicking on a node. + /// + QMenu* m_NodeMenu; + /// + /// \brief flag indicating whether a surface created from a selected decimation is decimated with vtkQuadricDecimation or not + /// + bool m_SurfaceDecimation; + + ///# Actions for the Context Menu + /// Global Reinit Action + QAction* m_GlobalReinitAction; + /// Save Action + QAction* m_SaveAction; + /// Remove Action + QAction* m_RemoveAction; + /// Reinit Action + QAction* m_ReinitAction; + /// A Slider widget to change the opacity of a node + QSlider* m_OpacitySlider; + /// Opacity action + QWidgetAction* m_OpacityAction; + /// button to change the color of a node + QPushButton* m_ColorButton; + /// Color action + QWidgetAction* m_ColorAction; + /// TextureInterpolation action + QAction* m_TextureInterpolation; + /// TextureInterpolation action + QAction* m_SurfaceRepresentation; + /// Show only selected nodes + QAction* m_ShowOnlySelectedNodes; + /// Toggles visibility of selected nodes + QAction* m_ToggleSelectedVisibility; + /// Shows infos for selected nodes + QAction* m_ActionShowInfoDialog; + + /// Special filter action for images + QAction* m_OtsuFilterAction; + + /// Maps "Show in" actions to editor ids + QSignalMapper* m_ShowInMapper; + + /// A list of "Show in" actions + QList m_ShowInActions; + + /// saves the current amount of rows shown in the datamanager + size_t m_CurrentRowCount; + +private: + + QItemSelectionModel* GetDataNodeSelectionModel() const; + + /// Reopen multi widget editor if it has been closed + mitk::IRenderWindowPart *OpenRenderWindowPart(); +}; + +#endif /*QMITKDATAMANAGERVIEW_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.cpp rename to Plugins/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.h b/Plugins/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.h rename to Plugins/org.mitk.gui.qt.datamanager/src/berrySingleNodeSelection.h diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDataManagerControls.ui b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkDataManagerControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDataManagerControls.ui rename to Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkDataManagerControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.cpp rename to Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.h rename to Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkDelKeyFilter.h diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp new file mode 100644 index 0000000000..4d461f7eba --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp @@ -0,0 +1,127 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkInfoDialog.h" + +#include "QmitkDataStorageComboBox.h" + +#include + +#include +#include +#include +#include +#include +#include + +QmitkInfoDialog::QmitkInfoDialog( const QList &_Nodes, QWidget * parent /*= 0*/, Qt::WindowFlags f /*= 0 */ ) +: QDialog(parent, f) +{ + // DIM + QGridLayout* parentLayout = new QGridLayout; + QmitkDataStorageComboBox* _QmitkDataStorageComboBox = new QmitkDataStorageComboBox(this, true); + m_KeyWord = new QLineEdit; + m_KeyWord->installEventFilter(this); + m_SearchButton = new QPushButton("Search (F3)", this); + m_SearchButton->installEventFilter(this); + m_TextBrowser = new QTextBrowser(this); + QPushButton* _CancelButton = new QPushButton("Cancel", this); + + // SET + this->setMinimumSize(512, 512); + this->setLayout(parentLayout); + this->setSizeGripEnabled(true); + this->setModal(true); + + parentLayout->addWidget(_QmitkDataStorageComboBox, 0, 0, 1, 2); + parentLayout->addWidget(m_KeyWord, 1, 0); + parentLayout->addWidget(m_SearchButton, 1, 1); + parentLayout->addWidget(m_TextBrowser, 2, 0, 1, 2); + parentLayout->addWidget(_CancelButton, 3, 0, 1, 2); + + QObject::connect( _QmitkDataStorageComboBox, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ) + , this, SLOT( OnSelectionChanged( const mitk::DataNode* ) ) ); + + foreach(mitk::DataNode::Pointer node, _Nodes) + { + _QmitkDataStorageComboBox->AddNode(node); + } + + QObject::connect( m_KeyWord, SIGNAL( textChanged ( const QString & ) ) + , this, SLOT( KeyWordTextChanged(const QString &) ) ); + + QObject::connect( m_SearchButton, SIGNAL( clicked ( bool ) ) + , this, SLOT( OnSearchButtonClicked( bool ) ) ); + + QObject::connect( _CancelButton, SIGNAL( clicked ( bool ) ) + , this, SLOT( OnCancelButtonClicked( bool ) ) ); + + _CancelButton->setDefault(true); + +} + +void QmitkInfoDialog::OnSelectionChanged( const mitk::DataNode* node ) +{ + std::ostringstream s; + itk::Indent i(2); + mitk::BaseData* _BaseData = node->GetData(); + if(_BaseData) + _BaseData->Print(s, i); + m_TextBrowser->setPlainText(QString::fromStdString(s.str())); +} + +void QmitkInfoDialog::OnSearchButtonClicked( bool /*checked*/ /*= false */ ) +{ + QString keyWord = m_KeyWord->text(); + QString text = m_TextBrowser->toPlainText(); + + if(keyWord.isEmpty() || text.isEmpty()) + return; + + m_TextBrowser->find(keyWord); + m_SearchButton->setText("Search Next(F3)"); +} + +void QmitkInfoDialog::OnCancelButtonClicked( bool /*checked*/ /*= false */ ) +{ + this->done(0); +} + +bool QmitkInfoDialog::eventFilter( QObject *obj, QEvent *event ) +{ + if (event->type() == QEvent::KeyPress) + { + QKeyEvent *keyEvent = static_cast(event); + if(keyEvent->key() == Qt::Key_F3 || keyEvent->key() == Qt::Key_Return) + { + // trigger deletion of selected node(s) + this->OnSearchButtonClicked(true); + // return true: this means the delete key event is not send to the table + return true; + } + } + // standard event processing + return QObject::eventFilter(obj, event); +} + +void QmitkInfoDialog::KeyWordTextChanged(const QString & /*text*/) +{ + QTextCursor textCursor = m_TextBrowser->textCursor(); + textCursor.setPosition(0); + m_TextBrowser->setTextCursor(textCursor); + m_SearchButton->setText("Search (F3)"); +} diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h new file mode 100644 index 0000000000..d8da23143d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h @@ -0,0 +1,51 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKINFODIALOG_H_ +#define QMITKINFODIALOG_H_ + +#include + +#include + +class QTextBrowser; +class QLineEdit; + +/// +/// A small class which "eats" all Del-Key-pressed events on the node table. +/// When the Del Key is pressed selected nodes should be removed. +/// +class QmitkInfoDialog : public QDialog +{ + Q_OBJECT + + public: + QmitkInfoDialog(const QList& _Nodes, QWidget * parent = 0, Qt::WindowFlags f = 0 ); + public slots: + void OnSelectionChanged(const mitk::DataNode*); + void OnSearchButtonClicked ( bool checked = false ); + void OnCancelButtonClicked ( bool checked = false ); + void KeyWordTextChanged(const QString & text); + protected: + bool eventFilter(QObject *obj, QEvent *event); + protected: + QLineEdit* m_KeyWord; + QPushButton* m_SearchButton; + QTextBrowser* m_TextBrowser; +}; + +#endif // QMITKINFODIALOG_H_ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.cpp rename to Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.h rename to Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkNodeTableViewKeyFilter.h diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.cpp new file mode 100644 index 0000000000..6b48081a14 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.cpp @@ -0,0 +1,59 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include +#include +#include +#include +#include "QmitkPropertyListView.h" +#include +#include +#include +#include + +const std::string QmitkPropertyListView::VIEW_ID = "org.mitk.views.propertylistview"; + +QmitkPropertyListView::QmitkPropertyListView() +{ +} + +QmitkPropertyListView::~QmitkPropertyListView() +{ +} + +void QmitkPropertyListView::CreateQtPartControl( QWidget* parent ) +{ + m_NodePropertiesTableEditor = new QmitkPropertiesTableEditor; + + QVBoxLayout* layout = new QVBoxLayout; + layout->addWidget(m_NodePropertiesTableEditor); + + parent->setLayout(layout); +} + +void QmitkPropertyListView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, + const QList &nodes) +{ + if (nodes.empty() || (nodes.front().IsNull())) return; + + m_NodePropertiesTableEditor->SetPropertyList(nodes.front()->GetPropertyList()); +} + +void QmitkPropertyListView::SetFocus() +{ + m_NodePropertiesTableEditor->setFocus(); +} diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.h new file mode 100644 index 0000000000..c7a5c75a95 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyListView.h @@ -0,0 +1,77 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkPropertyListView_h_ +#define QmitkPropertyListView_h_ + +// Own includes + +#include + +#include +#include + +class QmitkPropertiesTableEditor; + +/// +/// A view to show +/// +class QmitkPropertyListView : public QmitkAbstractView +{ + Q_OBJECT + +public: + berryObjectMacro(QmitkPropertyListView) + + /// + /// The unique ID of this view + /// + static const std::string VIEW_ID; + + /// + /// \brief Standard ctor. + /// + QmitkPropertyListView(); + + /// + /// \brief Standard dtor. + /// + virtual ~QmitkPropertyListView(); + /// + /// \brief Create the view here. + /// + void CreateQtPartControl(QWidget* parent); + + /// + /// Invoked when the DataManager selection changed + /// + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList& nodes); + +protected: + + void SetFocus(); + +private: + /// + /// \brief The properties table editor. + /// + QmitkPropertiesTableEditor* m_NodePropertiesTableEditor; + + friend struct berry::SelectionChangedAdapter; +}; + +#endif /*QmitkPropertyListView_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.h diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h b/Plugins/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h new file mode 100644 index 0000000000..d0b7ae1b70 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.datamanager/src/mitkIContextMenuAction.h @@ -0,0 +1,41 @@ +#ifndef mitkIContextMenuAction_H_ +#define mitkIContextMenuAction_H_ + +#include +#include + +#include +#include +#include "mitkDataStorage.h" + +class QmitkStdMultiWidget; + +namespace mitk +{ + /** + * A context menu action, which is linked to the context menu
+ * through an extension point. For an example check the
+ * plugin.xml and the connected classes of
+ * the the segmentation bundle and also the QmitkDataManagerView.cpp
+ * in this bundle. + */ + struct IContextMenuAction + { + berryInterfaceMacro(IContextMenuAction, mitk) + + /** + * @brief Executes the action, that linked to the context menu entry. + */ + virtual void Run( const QList& selectedNodes ) = 0; + + // Setters + virtual void SetDataStorage(mitk::DataStorage* dataStorage) = 0; + virtual void SetSmoothed(bool smoothed) = 0; + virtual void SetDecimated(bool decimated) = 0; + virtual void SetFunctionality(berry::QtViewPart* functionality) = 0; + }; +} + +Q_DECLARE_INTERFACE(mitk::IContextMenuAction, "org.mitk.datamanager.IContextMenuAction") + +#endif // mitkIContextMenuAction_H_ diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/CMakeLists.txt b/Plugins/org.mitk.gui.qt.diffusionimaging/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.diffusionimaging/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkDiffusionImagingUserManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkDiffusionImagingUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkDiffusionImagingUserManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkDiffusionImagingUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkFiberProcessingViewUserManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkFiberProcessingViewUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkFiberProcessingViewUserManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkFiberProcessingViewUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkGibbsTrackingViewUserManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkGibbsTrackingViewUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkGibbsTrackingViewUserManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkGibbsTrackingViewUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkOdfDetailsViewUserManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkOdfDetailsViewUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkOdfDetailsViewUserManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkOdfDetailsViewUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkPartialVolumeAnalysisViewManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkPartialVolumeAnalysisViewManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkPartialVolumeAnalysisViewManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkPartialVolumeAnalysisViewManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkScreenshotMakerManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkScreenshotMakerManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkScreenshotMakerManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkScreenshotMakerManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkStochasticTrackingViewUserManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkStochasticTrackingViewUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkStochasticTrackingViewUserManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkStochasticTrackingViewUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkUserIVIMViewManual.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkUserIVIMViewManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkUserIVIMViewManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/QmitkUserIVIMViewManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom1.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom1.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom1.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom1.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom2.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom2.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom2.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/dicom2.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/fiberprocessing.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/fiberprocessing.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/fiberprocessing.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/fiberprocessing.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/gibbstrackingview.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/gibbstrackingview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/gibbstrackingview.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/gibbstrackingview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/ivimview.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/ivimview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/ivimview.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/ivimview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/odfdetails.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/odfdetails.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/odfdetails.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/odfdetails.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/overview.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/overview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/overview.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/overview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/prepro1.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/prepro1.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/prepro1.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/prepro1.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/pvanalysisview.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/pvanalysisview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/pvanalysisview.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/pvanalysisview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs1.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs1.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs1.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs1.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs2.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs2.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs2.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs2.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs3.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs3.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs3.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/qballs3.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/quantification.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/quantification.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/quantification.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/quantification.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/screenshot_maker_interface.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/screenshot_maker_interface.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/screenshot_maker_interface.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/screenshot_maker_interface.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/segmentationview.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/segmentationview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/segmentationview.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/segmentationview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/stochastictrackingview.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/stochastictrackingview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/stochastictrackingview.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/stochastictrackingview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor1.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor1.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor1.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor1.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor4.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor4.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor4.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/tensor4.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization1.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization1.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization1.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization1.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization2.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization2.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization2.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization2.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization3.png b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization3.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization3.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/documentation/UserManual/visualization3.png diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..00788da074 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_diffusionimaging org.mitk.gui.qt.diffusionimaging + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_diffusionimaging_internal Internal + \ingroup org_mitk_gui_qt_diffusionimaging + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.diffusionimaging plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/files.cmake b/Plugins/org.mitk.gui.qt.diffusionimaging/files.cmake new file mode 100644 index 0000000000..e14681dec2 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/files.cmake @@ -0,0 +1,112 @@ +SET(SRC_CPP_FILES + QmitkODFDetailsWidget.cpp + QmitkODFRenderWidget.cpp + QmitkPartialVolumeAnalysisWidget.cpp + QmitkIVIMWidget.cpp + QmitkTbssRoiAnalysisWidget.cpp + QmitkResidualAnalysisWidget.cpp +) + +SET(INTERNAL_CPP_FILES + mitkPluginActivator.cpp + QmitkQBallReconstructionView.cpp + QmitkPreprocessingView.cpp + QmitkDiffusionDicomImportView.cpp + QmitkDiffusionQuantificationView.cpp + QmitkTensorReconstructionView.cpp + QmitkDiffusionImagingPublicPerspective.cpp + QmitkControlVisualizationPropertiesView.cpp + QmitkODFDetailsView.cpp + QmitkGibbsTrackingView.cpp + QmitkStochasticFiberTrackingView.cpp + QmitkFiberProcessingView.cpp + QmitkFiberBundleDeveloperView.cpp + QmitkPartialVolumeAnalysisView.cpp + QmitkIVIMView.cpp + QmitkTractbasedSpatialStatisticsView.cpp + QmitkTbssTableModel.cpp + QmitkTbssMetaTableModel.cpp + QmitkTbssSkeletonizationView.cpp +) + +SET(UI_FILES + src/internal/QmitkQBallReconstructionViewControls.ui + src/internal/QmitkPreprocessingViewControls.ui + src/internal/QmitkDiffusionDicomImportViewControls.ui + src/internal/QmitkDiffusionQuantificationViewControls.ui + src/internal/QmitkTensorReconstructionViewControls.ui + src/internal/QmitkControlVisualizationPropertiesViewControls.ui + src/internal/QmitkODFDetailsViewControls.ui + src/internal/QmitkGibbsTrackingViewControls.ui + src/internal/QmitkStochasticFiberTrackingViewControls.ui + src/internal/QmitkFiberProcessingViewControls.ui + src/internal/QmitkFiberBundleDeveloperViewControls.ui + src/internal/QmitkPartialVolumeAnalysisViewControls.ui + src/internal/QmitkIVIMViewControls.ui + src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui + src/internal/QmitkTbssSkeletonizationViewControls.ui +) + +SET(MOC_H_FILES + src/internal/mitkPluginActivator.h + src/internal/QmitkQBallReconstructionView.h + src/internal/QmitkPreprocessingView.h + src/internal/QmitkDiffusionDicomImportView.h + src/internal/QmitkDiffusionImagingPublicPerspective.h + src/internal/QmitkDiffusionQuantificationView.h + src/internal/QmitkTensorReconstructionView.h + src/internal/QmitkControlVisualizationPropertiesView.h + src/internal/QmitkODFDetailsView.h + src/QmitkODFRenderWidget.h + src/QmitkODFDetailsWidget.h + src/internal/QmitkGibbsTrackingView.h + src/internal/QmitkStochasticFiberTrackingView.h + src/internal/QmitkFiberProcessingView.h + src/internal/QmitkFiberBundleDeveloperView.h + src/internal/QmitkPartialVolumeAnalysisView.h + src/QmitkPartialVolumeAnalysisWidget.h + src/internal/QmitkIVIMView.h + src/internal/QmitkTractbasedSpatialStatisticsView.h + src/internal/QmitkTbssSkeletonizationView.h + src/QmitkTbssRoiAnalysisWidget.h + src/QmitkResidualAnalysisWidget.h +) + +SET(CACHED_RESOURCE_FILES +# list of resource files which can be used by the plug-in +# system without loading the plug-ins shared library, +# for example the icon used in the menu and tabs for the +# plug-in views in the workbench + plugin.xml + + resources/preprocessing.png + resources/dwiimport.png + resources/quantification.png + resources/reconodf.png + resources/recontensor.png + resources/vizControls.png + resources/OdfDetails.png + resources/GibbsTracking.png + resources/FiberBundleOperations.png + resources/PartialVolumeAnalysis_24.png + resources/IVIM_48.png + resources/stochFB.png + resources/tbss.png +) + +SET(QRC_FILES +# uncomment the following line if you want to use Qt resources + resources/QmitkDiffusionImaging.qrc + #resources/QmitkTractbasedSpatialStatisticsView.qrc +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.diffusionimaging/manifest_headers.cmake new file mode 100644 index 0000000000..587c6184fd --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Diffusion Imaging") +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 org.mitk.diffusionimaging) diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml b/Plugins/org.mitk.gui.qt.diffusionimaging/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml rename to Plugins/org.mitk.gui.qt.diffusionimaging/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/FiberBundle.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/FiberBundle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/FiberBundle.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/FiberBundle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleOperations.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleOperations.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleOperations.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleOperations.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleX.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleX.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleX.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/FiberBundleX.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/GibbsTracking.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/GibbsTracking.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/GibbsTracking.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/GibbsTracking.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/IVIM_48.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/IVIM_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/IVIM_48.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/IVIM_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/MapperEfx2D.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/MapperEfx2D.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/MapperEfx2D.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/MapperEfx2D.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/OdfDetails.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/OdfDetails.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/OdfDetails.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/OdfDetails.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_24.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_24.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.xcf b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.xcf similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.xcf rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_48.xcf diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_64.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_64.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_64.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/PartialVolumeAnalysis_64.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QBallData24.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/QBallData24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QBallData24.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/QBallData24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QBallData48.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/QBallData48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QBallData48.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/QBallData48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/Refresh_48.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/Refresh_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/Refresh_48.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/Refresh_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/circle.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/circle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/circle.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/circle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color24.gif b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/color24.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color24.gif rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/color24.gif diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color48.gif b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/color48.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color48.gif rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/color48.gif diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color64.gif b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/color64.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color64.gif rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/color64.gif diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/crosshair.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/crosshair.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/crosshair.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/crosshair.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/dwi.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/dwi.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/dwi.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/dwi.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/dwiimport.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/dwiimport.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/dwiimport.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/dwiimport.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_C.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_C.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_C.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_C.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_S.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_S.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_S.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_S.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_T.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_T.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_T.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphsoff_T.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson_C.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson_C.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson_C.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson_C.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson_S.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson_S.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson_S.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson_S.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson_T.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson_T.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/glyphson_T.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/glyphson_T.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/odf.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/odf.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/odf.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/odf.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/paint2.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/paint2.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/paint2.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/paint2.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/polygon.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/polygon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/polygon.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/polygon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.xcf b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.xcf similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.xcf rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/preprocessing.xcf diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/qball.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/qball.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/qball.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/qball.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/quantification.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/quantification.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/quantification.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/quantification.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/reconodf.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/reconodf.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/reconodf.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/reconodf.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/recontensor.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/recontensor.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/recontensor.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/recontensor.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/rectangle.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/rectangle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/rectangle.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/rectangle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/refresh.xpm b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/refresh.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/refresh.xpm rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/refresh.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/reset.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/reset.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/reset.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/reset.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/1002diffusion.cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/1002diffusion.cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/1002diffusion.cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/1002diffusion.cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/1002odf.cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/1002odf.cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/1002odf.cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/1002odf.cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/1002tensor.cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/1002tensor.cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/1002tensor.cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/1002tensor.cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/Generator.cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/Generator.cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/Generator.cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/Generator.cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/Thumbs.db b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/Thumbs.db similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/Thumbs.db rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/Thumbs.db diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/dwiimport.cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/dwiimport.cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/dwiimport.cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/dwiimport.cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/gear_wheel.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/gear_wheel.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/gear_wheel.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/gear_wheel.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_close.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_close.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_close.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_close.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.jpeg b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.jpeg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.jpeg rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.jpeg diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/one_eye_open.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/pfeil.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/pfeil.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/pfeil.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/pfeil.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/quantification.cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/quantification.cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/quantification.cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/quantification.cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/reconodf (+Generator.cpt).cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/reconodf (+Generator.cpt).cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/reconodf (+Generator.cpt).cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/reconodf (+Generator.cpt).cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/recontensor (+Generator.cpt).cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/recontensor (+Generator.cpt).cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/recontensor (+Generator.cpt).cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/recontensor (+Generator.cpt).cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/stats.cpt b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/stats.cpt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/stats.cpt rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/stats.cpt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/texIntOFF.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/texIntOFF.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/texIntOFF.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/texIntOFF.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/texIntON.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/texIntON.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/source/texIntON.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/source/texIntON.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/stats.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/stats.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/stats.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/stats.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/stochFB.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/stochFB.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/stochFB.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/stochFB.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/tbss.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/tbss.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/tbss.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/tbss.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/tensor.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/tensor.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/tensor.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/tensor.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/texIntOFFIcon.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/texIntOFFIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/texIntOFFIcon.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/texIntOFFIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/texIntONIcon.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/texIntONIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/texIntONIcon.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/texIntONIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/vizControls.png b/Plugins/org.mitk.gui.qt.diffusionimaging/resources/vizControls.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/vizControls.png rename to Plugins/org.mitk.gui.qt.diffusionimaging/resources/vizControls.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkIVIMWidget.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFDetailsWidget.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkODFRenderWidget.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkPartialVolumeAnalysisWidget.h diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkResidualAnalysisWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkResidualAnalysisWidget.cpp new file mode 100644 index 0000000000..40298ee687 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkResidualAnalysisWidget.cpp @@ -0,0 +1,125 @@ +/*========================================================================= +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkResidualAnalysisWidget.h" + + +#include +#include +#include + +#include +#include +#include +#include +#include + + +#include +#include + + +QmitkResidualAnalysisWidget::QmitkResidualAnalysisWidget( QWidget * parent ) + : QmitkPlotWidget(parent) +{ + m_PlotPicker = new QwtPlotPicker(m_Plot->canvas()); + m_PlotPicker->setSelectionFlags(QwtPicker::PointSelection | QwtPicker::ClickSelection | QwtPicker::DragSelection); + m_PlotPicker->setTrackerMode(QwtPicker::ActiveOnly); +} + + + +QmitkResidualAnalysisWidget::~QmitkResidualAnalysisWidget() +{ + delete m_PlotPicker; +} + + +void QmitkResidualAnalysisWidget::DrawMeans() +{ + this->Clear(); + this->SetPlotTitle("mean residual per volume"); + QPen pen( Qt::SolidLine ); + pen.setWidth(1); + + + // Create values for x-axis + std::vector xAxis; + for(int i=0; iInsertCurve( "Mean" ); + this->SetCurveData( curveId, xAxis, m_Means ); + this->SetCurvePen( curveId, pen ); + this->SetCurveStyle( curveId, QwtPlotCurve::Dots); + + pen.setColor(Qt::blue); + curveId = this->InsertCurve( "Q1" ); + this->SetCurveData( curveId, xAxis, m_Q1 ); + this->SetCurvePen( curveId, pen ); + this->SetCurveStyle( curveId, QwtPlotCurve::Dots); + + pen.setColor(Qt::red); + curveId = this->InsertCurve( "Q3" ); + this->SetCurveData( curveId, xAxis, m_Q3 ); + this->SetCurvePen( curveId, pen ); + this->SetCurveStyle( curveId, QwtPlotCurve::Dots); + + + this->m_Plot->setAxisTitle(0, "Residual"); + this->m_Plot->setAxisTitle(3, "DWI Volume"); + + + QwtLegend *legend = new QwtLegend; + this->SetLegend(legend, QwtPlot::RightLegend, 0.5); + + this->Replot(); + +} + +void QmitkResidualAnalysisWidget::DrawPercentagesOfOutliers() +{ + this->Clear(); + + + this->SetPlotTitle("Percentage of outliers"); + QPen pen( Qt::SolidLine ); + pen.setWidth(1); + + + // Create values for x-axis + std::vector xAxis; + for(int i=0; iInsertCurve( "Outliers" ); + this->SetCurveData( curveId, xAxis, m_PercentagesOfOutliers ); + this->SetCurvePen( curveId, pen ); + //this->SetCurveStyle( curveId, QwtPlotCurve::Fitted); + + this->m_Plot->setAxisTitle(0, "Percentage of outliers"); + this->m_Plot->setAxisTitle(3, "DWI Volume"); + + QwtLegend *legend = new QwtLegend; + this->SetLegend(legend, QwtPlot::RightLegend, 0.5); + + this->Replot(); +} + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkResidualAnalysisWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkResidualAnalysisWidget.h new file mode 100644 index 0000000000..29669ca28f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkResidualAnalysisWidget.h @@ -0,0 +1,98 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-05-15 18:09:46 +0200 (Fr, 15 Mai 2009) $ +Version: $Revision: 1.12 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkResidualAnalysisWidget_H_ +#define QmitkResidualAnalysisWidget_H_ + +#include "QmitkPlotWidget.h" + +#include + +//#include "QmitkHistogram.h" +#include "QmitkExtExports.h" +#include "mitkImage.h" +#include "mitkPlanarFigure.h" +#include "itkVectorImage.h" + + +//#include + + +#include +#include + + + +/** + * \brief Widget for displaying boxplots + * framework + */ +class DIFFUSIONIMAGING_EXPORT QmitkResidualAnalysisWidget : public QmitkPlotWidget +{ + +Q_OBJECT + +public: + + + QmitkResidualAnalysisWidget( QWidget * parent); + virtual ~QmitkResidualAnalysisWidget(); + + + + + QwtPlot* GetPlot() + { + return m_Plot; + } + + QwtPlotPicker* m_PlotPicker; + + + void SetMeans(std::vector< double > means) + { + m_Means = means; + } + + void SetQ1(std::vector< double > q1) + { + m_Q1 = q1; + } + + void SetQ3(std::vector< double > q3) + { + m_Q3 = q3; + } + + void SetPercentagesOfOutliers(std::vector< double > perc) + { + m_PercentagesOfOutliers = perc; + } + + + void DrawMeans(); + void DrawPercentagesOfOutliers(); + + +protected: + std::vector< double > m_Means; + std::vector< double > m_Q1; + std::vector< double > m_Q3; + std::vector< double > m_PercentagesOfOutliers; +}; + +#endif diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTbssRoiAnalysisWidget.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.cpp new file mode 100644 index 0000000000..fdcf725c3f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.cpp @@ -0,0 +1,755 @@ +/*========================================================================= +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkDiffusionDicomImportView.h" + +// qt includes +#include + +// itk includes +#include "itkTimeProbesCollectorBase.h" +#include "itkGDCMSeriesFileNames.h" +#include "itksys/SystemTools.hxx" + +// mitk includes +#include "mitkProgressBar.h" +#include "mitkStatusBar.h" +#include "mitkProperties.h" +#include "mitkRenderingManager.h" +#include "mitkMemoryUtilities.h" + +// diffusion module includes +#include "mitkDicomDiffusionImageHeaderReader.h" +#include "mitkGroupDiffusionHeadersFilter.h" +#include "mitkDicomDiffusionImageReader.h" +#include "mitkDiffusionImage.h" +#include "mitkNrrdDiffusionImageWriter.h" + +#include "gdcmDirectory.h" +#include "gdcmScanner.h" +#include "gdcmSorter.h" +#include "gdcmIPPSorter.h" +#include "gdcmAttribute.h" +#include "gdcmVersion.h" + +#include + +const std::string QmitkDiffusionDicomImport::VIEW_ID = "org.mitk.views.diffusiondicomimport"; + + +QmitkDiffusionDicomImport::QmitkDiffusionDicomImport(QObject* /*parent*/, const char* /*name*/) + : QmitkFunctionality(), m_Controls(NULL), m_MultiWidget(NULL), + m_OutputFolderName(""), m_OutputFolderNameSet(false) +{ +} + +QmitkDiffusionDicomImport::QmitkDiffusionDicomImport(const QmitkDiffusionDicomImport& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + +QmitkDiffusionDicomImport::~QmitkDiffusionDicomImport() +{} + +void QmitkDiffusionDicomImport::CreateQtPartControl(QWidget *parent) +{ + m_Parent = parent; + if (m_Controls == NULL) + { + m_Controls = new Ui::QmitkDiffusionDicomImportControls; + m_Controls->setupUi(parent); + this->CreateConnections(); + + m_Controls->m_DicomLoadRecursiveCheckbox->setChecked(true); + m_Controls->m_DicomLoadAverageDuplicatesCheckbox->setChecked(false); + + m_Controls->m_DicomLoadRecursiveCheckbox->setVisible(false); + + AverageClicked(); + AdvancedCheckboxClicked(); + } +} + + + +void QmitkDiffusionDicomImport::CreateConnections() +{ + if ( m_Controls ) + { + connect( m_Controls->m_AddFoldersButton, SIGNAL(clicked()), this, SLOT(DicomLoadAddFolderNames()) ); + connect( m_Controls->m_DeleteFoldersButton, SIGNAL(clicked()), this, SLOT(DicomLoadDeleteFolderNames()) ); + connect( m_Controls->m_DicomLoadStartLoadButton, SIGNAL(clicked()), this, SLOT(DicomLoadStartLoad()) ); + connect( m_Controls->m_DicomLoadAverageDuplicatesCheckbox, SIGNAL(clicked()), this, SLOT(AverageClicked()) ); + connect( m_Controls->m_OutputSetButton, SIGNAL(clicked()), this, SLOT(OutputSet()) ); + connect( m_Controls->m_OutputClearButton, SIGNAL(clicked()), this, SLOT(OutputClear()) ); + connect( m_Controls->m_Advanced, SIGNAL(clicked()), this, SLOT(AdvancedCheckboxClicked()) ); + connect( m_Controls->m_Remove, SIGNAL(clicked()), this, SLOT(Remove()) ); + } +} + + +void QmitkDiffusionDicomImport::Remove() +{ + int i = m_Controls->listWidget->currentRow(); + m_Controls->listWidget->takeItem(i); +} + +void QmitkDiffusionDicomImport::AdvancedCheckboxClicked() +{ + bool check = m_Controls-> + m_Advanced->isChecked(); + + m_Controls->m_AdvancedFrame->setVisible(check); +} + +void QmitkDiffusionDicomImport::OutputSet() +{ + // SELECT FOLDER DIALOG + QFileDialog* w = new QFileDialog( m_Parent, QString("Select folders containing DWI data") ); + w->setFileMode( QFileDialog::Directory ); + + // RETRIEVE SELECTION + if ( w->exec() != QDialog::Accepted ) + return; + + m_OutputFolderName = w->selectedFiles()[0]; + m_OutputFolderNameSet = true; + m_Controls->m_OutputLabel->setText(m_OutputFolderName); +} + +void QmitkDiffusionDicomImport::OutputClear() +{ + m_OutputFolderName = ""; + m_OutputFolderNameSet = false; + m_Controls->m_OutputLabel->setText("... optional out-folder ..."); +} + +void QmitkDiffusionDicomImport::AverageClicked() +{ + m_Controls->m_Blur->setEnabled(m_Controls->m_DicomLoadAverageDuplicatesCheckbox->isChecked()); +} + +void QmitkDiffusionDicomImport::Activated() +{ + QmitkFunctionality::Activated(); +} + +void QmitkDiffusionDicomImport::DicomLoadDeleteFolderNames() +{ + m_Controls->listWidget->clear(); +} + +void QmitkDiffusionDicomImport::DicomLoadAddFolderNames() +{ + // SELECT FOLDER DIALOG + QFileDialog* w = new QFileDialog( m_Parent, QString("Select folders containing DWI data") ); + w->setFileMode( QFileDialog::Directory ); + + // RETRIEVE SELECTION + if ( w->exec() != QDialog::Accepted ) + return; + + m_Controls->listWidget->addItems(w->selectedFiles()); +} + +bool SortBySeriesUID(gdcm::DataSet const & ds1, gdcm::DataSet const & ds2 ) +{ + gdcm::Attribute<0x0020,0x000e> at1; + at1.Set( ds1 ); + gdcm::Attribute<0x0020,0x000e> at2; + at2.Set( ds2 ); + return at1 < at2; +} + +bool SortByAcquisitionNumber(gdcm::DataSet const & ds1, gdcm::DataSet const & ds2 ) +{ + gdcm::Attribute<0x0020,0x0012> at1; + at1.Set( ds1 ); + gdcm::Attribute<0x0020,0x0012> at2; + at2.Set( ds2 ); + return at1 < at2; +} + +bool SortBySeqName(gdcm::DataSet const & ds1, gdcm::DataSet const & ds2 ) +{ + gdcm::Attribute<0x0018, 0x0024> at1; + at1.Set( ds1 ); + gdcm::Attribute<0x0018, 0x0024> at2; + at2.Set( ds2 ); + + std::string str1 = at1.GetValue().Trim(); + std::string str2 = at2.GetValue().Trim(); + return std::lexicographical_compare(str1.begin(), str1.end(), + str2.begin(), str2.end() ); +} + +void QmitkDiffusionDicomImport::Status(QString status) +{ + mitk::StatusBar::GetInstance()->DisplayText(status.toAscii()); + MITK_INFO << status.toStdString().c_str(); +} + +void QmitkDiffusionDicomImport::Status(std::string status) +{ + mitk::StatusBar::GetInstance()->DisplayText(status.c_str()); + MITK_INFO << status.c_str(); +} + +void QmitkDiffusionDicomImport::Status(const char* status) +{ + mitk::StatusBar::GetInstance()->DisplayText(status); + MITK_INFO << status; +} + +void QmitkDiffusionDicomImport::Error(QString status) +{ + mitk::StatusBar::GetInstance()->DisplayErrorText(status.toAscii()); + MITK_ERROR << status.toStdString().c_str(); +} + +void QmitkDiffusionDicomImport::Error(std::string status) +{ + mitk::StatusBar::GetInstance()->DisplayErrorText(status.c_str()); + MITK_ERROR << status.c_str(); +} + +void QmitkDiffusionDicomImport::Error(const char* status) +{ + mitk::StatusBar::GetInstance()->DisplayErrorText(status); + MITK_ERROR << status; +} + +void QmitkDiffusionDicomImport::PrintMemoryUsage() +{ + size_t processSize = mitk::MemoryUtilities::GetProcessMemoryUsage(); + size_t totalSize = mitk::MemoryUtilities::GetTotalSizeOfPhysicalRam(); + float percentage = ( (float) processSize / (float) totalSize ) * 100.0; + MITK_INFO << "Current memory usage: " << GetMemoryDescription( processSize, percentage ); +} + +std::string QmitkDiffusionDicomImport::FormatMemorySize( size_t size ) +{ + double val = size; + std::string descriptor("B"); + if ( val >= 1000.0 ) + { + val /= 1024.0; + descriptor = "KB"; + } + if ( val >= 1000.0 ) + { + val /= 1024.0; + descriptor = "MB"; + } + if ( val >= 1000.0 ) + { + val /= 1024.0; + descriptor = "GB"; + } + std::ostringstream str; + str << std::fixed << std::setprecision(2) << val << " " << descriptor; + return str.str(); +} + +std::string QmitkDiffusionDicomImport::FormatPercentage( double val ) +{ + std::ostringstream str; + str << std::fixed << std::setprecision(2) << val << " " << "%"; + return str.str(); +} + +std::string QmitkDiffusionDicomImport::GetMemoryDescription( size_t processSize, float percentage ) +{ + std::ostringstream str; + str << FormatMemorySize(processSize) << " (" << FormatPercentage( percentage ) <<")" ; + return str.str(); +} + +void QmitkDiffusionDicomImport::DicomLoadStartLoad() +{ + itk::TimeProbesCollectorBase clock; + bool imageSuccessfullySaved = true; + + try + { + const std::string& locale = "C"; + const std::string& currLocale = setlocale( LC_ALL, NULL ); + + if ( locale.compare(currLocale)!=0 ) + { + try + { + MITK_INFO << " ** Changing locale from " << setlocale(LC_ALL, NULL) << " to '" << locale << "'"; + setlocale(LC_ALL, locale.c_str()); + } + catch(...) + { + MITK_INFO << "Could not set locale " << locale; + } + } + + int nrFolders = m_Controls->listWidget->count(); + + if(!nrFolders) + { + Error(QString("No input folders were selected. ABORTING.")); + return; + } + + Status(QString("GDCM %1 used for DICOM parsing and sorting!").arg(gdcm::Version::GetVersion())); + + PrintMemoryUsage(); + QString status; + mitk::DataNode::Pointer node; + mitk::ProgressBar::GetInstance()->AddStepsToDo(2*nrFolders); + + + std::string folder = m_Controls->m_OutputLabel->text().toStdString(); + + + if(berry::Platform::IsWindows()) + { + folder.append("\\import.log"); + } + else + { + folder.append("/import.log"); + } + + ofstream logfile; + if(m_OutputFolderNameSet) logfile.open(folder.c_str()); + + while(m_Controls->listWidget->count()) + { + // RETREIVE FOLDERNAME + QListWidgetItem * item = m_Controls->listWidget->takeItem(0); + QString folderName = item->text(); + + if(m_OutputFolderNameSet) logfile << "Reading " << folderName.toStdString() << '\n'; + + // PARSING DIRECTORY + PrintMemoryUsage(); + clock.Start(folderName.toAscii()); + std::vector seriesUIDs(0); + std::vector > seriesFilenames(0); + + Status("== Initial Directory Scan =="); + if(m_OutputFolderNameSet) logfile << "== Initial Directory Scan ==\n"; + + gdcm::Directory d; + d.Load( folderName.toStdString().c_str(), true ); // recursive ! + const gdcm::Directory::FilenamesType &l1 = d.GetFilenames(); + const unsigned int ntotalfiles = l1.size(); + Status(QString(" ... found %1 different files").arg(ntotalfiles)); + if(m_OutputFolderNameSet)logfile << "...found " << ntotalfiles << " different files\n"; + + Status("Scanning Headers"); + if(m_OutputFolderNameSet) logfile << "Scanning Headers\n"; + + gdcm::Scanner s; + const gdcm::Tag t1(0x0020,0x000d); // Study Instance UID + const gdcm::Tag t2(0x0020,0x000e); // Series Instance UID + const gdcm::Tag t5(0x0028, 0x0010); // number rows + const gdcm::Tag t6(0x0028, 0x0011); // number cols + s.AddTag( t1 ); + s.AddTag( t2 ); + s.AddTag( t5 ); + s.AddTag( t6 ); + + bool b = s.Scan( d.GetFilenames() ); + if( !b ) + { + Error("Scanner failed"); + if(m_OutputFolderNameSet )logfile << "ERROR: scanner failed\n"; + continue; + } + + // Only get the DICOM files: + gdcm::Directory::FilenamesType l2 = s.GetKeys(); + const int nfiles = l2.size(); + if(nfiles < 1) + { + Error("No DICOM files found"); + if(m_OutputFolderNameSet)logfile << "ERROR: No DICOM files found\n"; + continue; + } + Status(QString(" ... successfully scanned %1 headers.").arg(nfiles)); + if(m_OutputFolderNameSet) logfile << "...succesfully scanned " << nfiles << " headers\n"; + + Status("Sorting"); + if(m_OutputFolderNameSet) logfile << "Sorting\n"; + + const gdcm::Scanner::ValuesType &values1 = s.GetValues(t1); + + int nvalues; + if(m_Controls->m_DuplicateID->isChecked()) + { + nvalues = 1; + } + else + { + nvalues = values1.size(); + } + + if(nvalues>1) + { + Error("Multiple sSeries tudies found. Please limit to 1 study per folder"); + if(m_OutputFolderNameSet) logfile << "Multiple series found. Limit to one. If you are convinced this is an error use the merge duplicate study IDs option \n"; + continue; + } + + const gdcm::Scanner::ValuesType &values5 = s.GetValues(t5); + const gdcm::Scanner::ValuesType &values6 = s.GetValues(t6); + if(values5.size()>1 || values6.size()>1) + { + Error("Folder contains images of unequal dimensions that cannot be combined in one 3d volume. ABORTING."); + if(m_OutputFolderNameSet) logfile << "Folder contains images of unequal dimensions that cannot be combined in one 3d volume. ABORTING\n."; + continue; + } + + const gdcm::Scanner::ValuesType &values2 = s.GetValues(t2); + + + int nSeries; + if(m_Controls->m_DuplicateID->isChecked()) + { + nSeries = 1; + } + else + { + nSeries = values2.size(); + } + + gdcm::Directory::FilenamesType files; + if(nSeries > 1) + { + gdcm::Sorter sorter; + sorter.SetSortFunction( SortBySeriesUID ); + sorter.StableSort( l2 ); + files = sorter.GetFilenames(); + } + else + { + files = l2; + } + + unsigned int nTotalAcquis = 0; + + if(nfiles % nSeries != 0) + { + Error("Number of files in series not equal, ABORTING"); + if(m_OutputFolderNameSet) logfile << "Number of files in series not equal, Some volumes are probably incomplete. ABORTING \n"; + continue; + } + + int filesPerSeries = nfiles / nSeries; + + gdcm::Scanner::ValuesType::const_iterator it2 = values2.begin(); + for(int i=0; i & list = ippsorter.GetFilenames(); + seriesFilenames.push_back(list); + seriesUIDs.push_back(identifier.c_str()); + } + ++it2; + } + + if(nfiles % nTotalAcquis != 0) + { + Error("Number of files per acquisition differs between series, ABORTING"); + if(m_OutputFolderNameSet) logfile << "Number of files per acquisition differs between series, ABORTING \n"; + continue; + } + + int slices = nfiles/nTotalAcquis; + Status(QString("Series is composed of %1 different 3D volumes with %2 slices.").arg(nTotalAcquis).arg(slices)); + if(m_OutputFolderNameSet) logfile << "Series is composed of " << nTotalAcquis << " different 3D volumes with " << slices << " slices\n"; + + // READING HEADER-INFOS + PrintMemoryUsage(); + Status(QString("Reading Headers %1").arg(folderName)); + if(m_OutputFolderNameSet) logfile << "Reading Headers "<< folderName.toStdString() << "\n"; + + mitk::DicomDiffusionImageHeaderReader::Pointer headerReader; + mitk::GroupDiffusionHeadersFilter::InputType inHeaders; + unsigned int size2 = seriesUIDs.size(); + for ( unsigned int i = 0 ; i < size2 ; ++i ) + { + Status(QString("Reading header image #%1/%2").arg(i+1).arg(size2)); + headerReader = mitk::DicomDiffusionImageHeaderReader::New(); + headerReader->SetSeriesDicomFilenames(seriesFilenames[i]); + headerReader->Update(); + inHeaders.push_back(headerReader->GetOutput()); + //Status(std::endl; + } + mitk::ProgressBar::GetInstance()->Progress(); + + // // GROUP HEADERS + // mitk::GroupDiffusionHeadersFilter::Pointer grouper + // = mitk::GroupDiffusionHeadersFilter::New(); + // mitk::GroupDiffusionHeadersFilter::OutputType outHeaders; + // grouper->SetInput(inHeaders); + // grouper->Update(); + // outHeaders = grouper->GetOutput(); + + // READ VOLUMES + PrintMemoryUsage(); + if(m_OutputFolderNameSet) logfile << "Loading volumes\n"; + Status(QString("Loading Volumes %1").arg(folderName)); + typedef short PixelValueType; + typedef mitk::DicomDiffusionImageReader< PixelValueType, 3 > VolumesReader; + VolumesReader::Pointer vReader = VolumesReader::New(); + VolumesReader::HeaderContainer hc = inHeaders; + + // hc.insert(hc.end(), outHeaders[1].begin(), outHeaders[1].end() ); + // hc.insert(hc.end(), outHeaders[2].begin(), outHeaders[2].end() ); + if(hc.size()>1) + { + vReader->SetHeaders(hc); + vReader->Update(); + VolumesReader::OutputImageType::Pointer vecImage; + vecImage = vReader->GetOutput(); + Status(QString("Volumes Loaded (%1)").arg(folderName)); + + // CONSTRUCT CONTAINER WITH DIRECTIONS + typedef vnl_vector_fixed< double, 3 > GradientDirectionType; + typedef itk::VectorContainer< unsigned int, + GradientDirectionType > GradientDirectionContainerType; + GradientDirectionContainerType::Pointer directions = + GradientDirectionContainerType::New(); + std::vector b_vals; + double maxb = 0; + for(unsigned int i=0; ibValue; + if(maxb vect = hc[i]->DiffusionVector; + vect.normalize(); + vect *= sqrt(b_vals[i]/maxb); + directions->push_back(vect); + } + + // DWI TO DATATREE + PrintMemoryUsage(); + Status(QString("Initializing Diffusion Image")); + if(m_OutputFolderNameSet) logfile << "Initializing Diffusion Image\n"; + typedef mitk::DiffusionImage DiffVolumesType; + DiffVolumesType::Pointer diffImage = DiffVolumesType::New(); + diffImage->SetDirections(directions); + diffImage->SetOriginalDirections(directions); + if(m_Controls->m_DicomLoadDKFZ->isChecked()) + { + diffImage->CorrectDKFZBrokenGradientScheme(m_Controls->m_Blur->value()); + } + diffImage->SetVectorImage(vecImage); + diffImage->SetB_Value(maxb); + diffImage->InitializeFromVectorImage(); + Status(QString("Diffusion Image initialized")); + if(m_OutputFolderNameSet) logfile << "Diffusion Image initialized\n"; + + if(m_Controls->m_DicomLoadAverageDuplicatesCheckbox->isChecked()) + { + PrintMemoryUsage(); + Status(QString("Averaging gradient directions")); + logfile << "Averaging gradient directions\n"; + diffImage->AverageRedundantGradients(m_Controls->m_Blur->value()); + } + + //if(m_Controls->m_DicomLoadDuplicateIfSingleSliceCheckbox->isChecked()) + // diffVolumes->DuplicateIfSingleSlice(); + + QString descr = QString("%1_%2_%3") + .arg(((inHeaders)[0])->seriesDescription.c_str()) + .arg(((inHeaders)[0])->seriesNumber) + .arg(((inHeaders)[0])->patientName.c_str()); + descr = descr.trimmed(); + descr = descr.replace(" ", "_"); + + if(!m_OutputFolderNameSet) + { + node=mitk::DataNode::New(); + node->SetData( diffImage ); + GetDefaultDataStorage()->Add(node); + SetDwiNodeProperties(node, descr.toStdString().c_str()); + Status(QString("Image %1 added to datastorage").arg(descr)); + } + else + { + typedef mitk::NrrdDiffusionImageWriter WriterType; + WriterType::Pointer writer = WriterType::New(); + QString fullpath = QString("%1/%2.dwi") + .arg(m_OutputFolderName) + .arg(descr); + //std::string pathstring = itksys::SystemTools::ConvertToOutputPath(fullpath.toStdString().c_str()); + + writer->SetFileName(fullpath.toStdString()); + writer->SetInput(diffImage); + try + { + writer->Update(); + } + catch (itk::ExceptionObject &ex) + { + imageSuccessfullySaved = false; + Error(QString("%1\n%2\n%3\n%4\n%5\n%6").arg(ex.GetNameOfClass()).arg(ex.GetFile()).arg(ex.GetLine()).arg(ex.GetLocation()).arg(ex.what()).arg(ex.GetDescription())); + logfile << QString("%1\n%2\n%3\n%4\n%5\n%6").arg(ex.GetNameOfClass()).arg(ex.GetFile()).arg(ex.GetLine()).arg(ex.GetLocation()).arg(ex.what()).arg(ex.GetDescription()).toStdString() << "\n"; + + node=mitk::DataNode::New(); + node->SetData( diffImage ); + GetDefaultDataStorage()->Add(node); + SetDwiNodeProperties(node, descr.toStdString().c_str()); + Status(QString("Image %1 added to datastorage").arg(descr)); + logfile << "Image " << descr.toStdString() << " added to datastorage\n"; + continue ; + } + Status(QString("Image %1 written to disc (%1)").arg(fullpath.toStdString().c_str())); + logfile << "Image " << fullpath.toStdString() << "\n"; + } + } + else + { + Status(QString("No diffusion information found (%1)").arg(folderName)); + if(m_OutputFolderNameSet) logfile << "No diffusion information found "<< folderName.toStdString(); + } + + Status(QString("Finished processing %1 with memory:").arg(folderName)); + if(m_OutputFolderNameSet) logfile << "Finished processing " << folderName.toStdString() << "\n"; + PrintMemoryUsage(); + clock.Stop(folderName.toAscii()); + mitk::ProgressBar::GetInstance()->Progress(); + int lwidget = m_Controls->listWidget->count(); + std::cout << lwidget <GetData(); + if (basedata.IsNotNull()) + { + mitk::RenderingManager::GetInstance()->InitializeViews( + basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + } + } + + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + + try + { + MITK_INFO << " ** Changing locale back from " << setlocale(LC_ALL, NULL) << " to '" << currLocale << "'"; + setlocale(LC_ALL, currLocale.c_str()); + } + catch(...) + { + MITK_INFO << "Could not reset locale " << currLocale; + } + } + catch (itk::ExceptionObject &ex) + { + Error(QString("%1\n%2\n%3\n%4\n%5\n%6").arg(ex.GetNameOfClass()).arg(ex.GetFile()).arg(ex.GetLine()).arg(ex.GetLocation()).arg(ex.what()).arg(ex.GetDescription())); + return ; + } + + if (!imageSuccessfullySaved) + QMessageBox::warning(NULL,"WARNING","One or more files could not be saved! The according files where moved to the datastorage."); + Status(QString("Finished import with memory:")); + + PrintMemoryUsage(); +} + +void QmitkDiffusionDicomImport::SetDwiNodeProperties(mitk::DataNode::Pointer node, std::string name) +{ + + node->SetProperty( "IsDWIRawVolume", mitk::BoolProperty::New( true ) ); + + // set foldername as string property + mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New( name ); + node->SetProperty( "name", nameProp ); +} diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionDicomImportViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionQuantificationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGibbsTrackingViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkIVIMViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkODFDetailsViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPartialVolumeAnalysisViewControls.ui diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.cpp new file mode 100644 index 0000000000..7ec76cd33d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.cpp @@ -0,0 +1,538 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Module: $RCSfile$ +Language: C++ +Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $ +Version: $Revision: 17495 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +//#define MBILOG_ENABLE_DEBUG + +#include "QmitkPreprocessingView.h" +#include "mitkDiffusionImagingConfigure.h" + +// qt includes +#include + +// itk includes +#include "itkTimeProbe.h" +#include "itkB0ImageExtractionImageFilter.h" +#include "itkBrainMaskExtractionImageFilter.h" +#include "itkCastImageFilter.h" +#include "itkVectorContainer.h" +#include + +// mitk includes +#include "QmitkDataStorageComboBox.h" +#include "QmitkStdMultiWidget.h" +#include "mitkProgressBar.h" +#include "mitkStatusBar.h" +#include "mitkNodePredicateDataType.h" +#include "mitkProperties.h" +#include "mitkVtkResliceInterpolationProperty.h" +#include "mitkLookupTable.h" +#include "mitkLookupTableProperty.h" +#include "mitkTransferFunction.h" +#include "mitkTransferFunctionProperty.h" +#include "mitkDataNodeObject.h" +#include "mitkOdfNormalizationMethodProperty.h" +#include "mitkOdfScaleByProperty.h" +#include + +#include "berryIStructuredSelection.h" +#include "berryIWorkbenchWindow.h" +#include "berryISelectionService.h" + +#include +#include + +const std::string QmitkPreprocessingView::VIEW_ID = +"org.mitk.views.preprocessing"; + +#define DI_INFO MITK_INFO("DiffusionImaging") + + +typedef float TTensorPixelType; + +using namespace berry; + +struct PrpSelListener : ISelectionListener +{ + + berryObjectMacro(PrpSelListener); + + PrpSelListener(QmitkPreprocessingView* view) + { + m_View = view; + } + + void DoSelectionChanged(ISelection::ConstPointer selection) + { + // save current selection in member variable + m_View->m_CurrentSelection = selection.Cast(); + + // do something with the selected items + if(m_View->m_CurrentSelection) + { + bool foundDwiVolume = false; + m_View->m_DiffusionImage = NULL; + + // iterate selection + for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); + i != m_View->m_CurrentSelection->End(); ++i) + { + + // extract datatree node + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + + // only look at interesting types + if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) + { + foundDwiVolume = true; + m_View->m_DiffusionImage = dynamic_cast*>(node->GetData()); + } + } + } + + m_View->m_Controls->m_ButtonBrainMask->setEnabled(foundDwiVolume); + m_View->m_Controls->m_ButtonAverageGradients->setEnabled(foundDwiVolume); + m_View->m_Controls->m_ButtonExtractB0->setEnabled(foundDwiVolume); + m_View->m_Controls->m_ModifyMeasurementFrame->setEnabled(foundDwiVolume); + m_View->m_Controls->m_MeasurementFrameTable->setEnabled(foundDwiVolume); + m_View->m_Controls->m_ReduceGradientsButton->setEnabled(foundDwiVolume); + m_View->m_Controls->m_ShowGradientsButton->setEnabled(foundDwiVolume); + m_View->m_Controls->m_MirrorGradientToHalfSphereButton->setEnabled(foundDwiVolume); + + if (foundDwiVolume) + { + vnl_matrix_fixed< double, 3, 3 > mf = m_View->m_DiffusionImage->GetMeasurementFrame(); + for (int r=0; r<3; r++) + for (int c=0; c<3; c++) + { + QTableWidgetItem* item = m_View->m_Controls->m_MeasurementFrameTable->item(r,c); + delete item; + item = new QTableWidgetItem(); + item->setTextAlignment(Qt::AlignCenter | Qt::AlignVCenter); + item->setText(QString::number(mf.get(r,c))); + m_View->m_Controls->m_MeasurementFrameTable->setItem(r,c,item); + } + m_View->m_Controls->m_GradientsLabel->setText(QString::number(m_View->m_DiffusionImage->GetNumDirections())); + + if (m_View->m_DiffusionImage->IsMultiBval()) + m_View->m_Controls->m_BvalLabel->setText("Acquisition with multiple b-values!"); + else + m_View->m_Controls->m_BvalLabel->setText(QString::number(m_View->m_DiffusionImage->GetB_Value())); + } + else + { + for (int r=0; r<3; r++) + for (int c=0; c<3; c++) + { + QTableWidgetItem* item = m_View->m_Controls->m_MeasurementFrameTable->item(r,c); + delete item; + item = new QTableWidgetItem(); + m_View->m_Controls->m_MeasurementFrameTable->setItem(r,c,item); + } + m_View->m_Controls->m_GradientsLabel->setText("-"); + m_View->m_Controls->m_BvalLabel->setText("-"); + } + } + } + + void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) + { + // check, if selection comes from datamanager + if (part) + { + QString partname(part->GetPartName().c_str()); + if(partname.compare("Datamanager")==0) + { + + // apply selection + DoSelectionChanged(selection); + + } + } + } + + QmitkPreprocessingView* m_View; +}; + +QmitkPreprocessingView::QmitkPreprocessingView() +: QmitkFunctionality(), +m_Controls(NULL), +m_MultiWidget(NULL), +m_DiffusionImage(NULL) +{ +} + +QmitkPreprocessingView::QmitkPreprocessingView(const QmitkPreprocessingView& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + +QmitkPreprocessingView::~QmitkPreprocessingView() +{ + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); +} + +void QmitkPreprocessingView::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkPreprocessingViewControls; + m_Controls->setupUi(parent); + this->CreateConnections(); + + m_Controls->m_MeasurementFrameTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + m_Controls->m_MeasurementFrameTable->verticalHeader()->setResizeMode(QHeaderView::Stretch); + } + + m_SelListener = berry::ISelectionListener::Pointer(new PrpSelListener(this)); + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); +} + +void QmitkPreprocessingView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) +{ + m_MultiWidget = &stdMultiWidget; +} + +void QmitkPreprocessingView::StdMultiWidgetNotAvailable() +{ + m_MultiWidget = NULL; +} + +void QmitkPreprocessingView::CreateConnections() +{ + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->m_ButtonAverageGradients), SIGNAL(clicked()), this, SLOT(AverageGradients()) ); + connect( (QObject*)(m_Controls->m_ButtonExtractB0), SIGNAL(clicked()), this, SLOT(ExtractB0()) ); + connect( (QObject*)(m_Controls->m_ButtonBrainMask), SIGNAL(clicked()), this, SLOT(BrainMask()) ); + connect( (QObject*)(m_Controls->m_ModifyMeasurementFrame), SIGNAL(clicked()), this, SLOT(DoApplyMesurementFrame()) ); + connect( (QObject*)(m_Controls->m_ReduceGradientsButton), SIGNAL(clicked()), this, SLOT(DoReduceGradientDirections()) ); + connect( (QObject*)(m_Controls->m_ShowGradientsButton), SIGNAL(clicked()), this, SLOT(DoShowGradientDirections()) ); + connect( (QObject*)(m_Controls->m_MirrorGradientToHalfSphereButton), SIGNAL(clicked()), this, SLOT(DoHalfSphereGradientDirections()) ); + } +} + +void QmitkPreprocessingView::Activated() +{ + QmitkFunctionality::Activated(); + + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); +} + +void QmitkPreprocessingView::Deactivated() +{ + QmitkFunctionality::Deactivated(); +} + +void QmitkPreprocessingView::DoHalfSphereGradientDirections() +{ + if (m_DiffusionImage.IsNull()) + return; + + GradientDirectionContainerType::Pointer gradientContainer = m_DiffusionImage->GetOriginalDirections(); + + for (int j=0; jSize(); j++) + if (gradientContainer->at(j)[0]<0) + gradientContainer->at(j) = -gradientContainer->at(j); +} + +void QmitkPreprocessingView::DoApplyMesurementFrame() +{ + if (m_DiffusionImage.IsNull()) + return; + vnl_matrix_fixed< double, 3, 3 > mf; + for (int r=0; r<3; r++) + for (int c=0; c<3; c++) + { + QTableWidgetItem* item = m_Controls->m_MeasurementFrameTable->item(r,c); + if (!item) + return; + mf[r][c] = item->text().toDouble(); + } + m_DiffusionImage->SetMeasurementFrame(mf); +} + +void QmitkPreprocessingView::DoShowGradientDirections() +{ + if (m_DiffusionImage.IsNull()) + return; + + GradientDirectionContainerType::Pointer gradientContainer = m_DiffusionImage->GetOriginalDirections(); + + mitk::PointSet::Pointer pointset = mitk::PointSet::New(); + for (int j=0; jSize(); j++) + { + mitk::Point3D p; + vnl_vector_fixed< double, 3 > v = gradientContainer->at(j); + if (fabs(v[0])>0.001 || fabs(v[1])>0.001 || fabs(v[2])>0.001) + { + p[0] = v[0]; + p[1] = v[1]; + p[2] = v[2]; + pointset->InsertPoint(j, p); + } + } + mitk::DataNode::Pointer node = mitk::DataNode::New(); + node->SetData(pointset); + node->SetName("gradient directions"); + node->SetProperty("pointsize", mitk::FloatProperty::New(0.05)); + node->SetProperty("color", mitk::ColorProperty::New(1,0,0)); + GetDefaultDataStorage()->Add(node); +} + +void QmitkPreprocessingView::DoReduceGradientDirections() +{ + if (m_DiffusionImage.IsNull()) + return; + + typedef mitk::DiffusionImage DiffusionImageType; + typedef itk::ReduceDirectionGradientsFilter FilterType; + + GradientDirectionContainerType::Pointer gradientContainer = m_DiffusionImage->GetOriginalDirections(); + FilterType::Pointer filter = FilterType::New(); + filter->SetInput(m_DiffusionImage->GetVectorImage()); + filter->SetOriginalGradientDirections(gradientContainer); + filter->SetNumGradientDirections(m_Controls->m_ReduceGradientsBox->value()); + filter->Update(); + + DiffusionImageType::Pointer image = DiffusionImageType::New(); + image->SetVectorImage( filter->GetOutput() ); + image->SetB_Value(m_DiffusionImage->GetB_Value()); + image->SetDirections(filter->GetGradientDirections()); + image->SetOriginalDirections(filter->GetGradientDirections()); + image->SetMeasurementFrame(m_DiffusionImage->GetMeasurementFrame()); + image->InitializeFromVectorImage(); + mitk::DataNode::Pointer imageNode = mitk::DataNode::New(); + imageNode->SetData( image ); + imageNode->SetName("reduced_image"); + GetDefaultDataStorage()->Add(imageNode); +} + +void QmitkPreprocessingView::ExtractB0() +{ + + if (m_CurrentSelection) + { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); + + int at = 0; + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { + + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) + { + set->InsertElement(at++, node); + } + } + } + + DoExtractB0(set); + + } +} + +void QmitkPreprocessingView::DoExtractB0 +(mitk::DataStorage::SetOfObjects::Pointer inImages) +{ + typedef mitk::DiffusionImage DiffusionImageType; + typedef DiffusionImageType::GradientDirectionContainerType GradientContainerType; + + int nrFiles = inImages->size(); + if (!nrFiles) return; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); + + std::vector nodes; + while ( itemiter != itemiterend ) // for all items + { + + DiffusionImageType* vols = + static_cast( + (*itemiter)->GetData()); + + std::string nodename; + (*itemiter)->GetStringProperty("name", nodename); + + // Extract image using found index + typedef itk::B0ImageExtractionImageFilter FilterType; + FilterType::Pointer filter = FilterType::New(); + filter->SetInput(vols->GetVectorImage()); + filter->SetDirections(vols->GetDirections()); + filter->Update(); + + mitk::Image::Pointer mitkImage = mitk::Image::New(); + mitkImage->InitializeByItk( filter->GetOutput() ); + mitkImage->SetVolume( filter->GetOutput()->GetBufferPointer() ); + mitk::DataNode::Pointer node=mitk::DataNode::New(); + node->SetData( mitkImage ); + node->SetProperty( "name", mitk::StringProperty::New(nodename + "_B0")); + + GetDefaultDataStorage()->Add(node); + + ++itemiter; + } + + +} + +void QmitkPreprocessingView::AverageGradients() +{ + + if (m_CurrentSelection) + { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); + + int at = 0; + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { + + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) + { + set->InsertElement(at++, node); + } + } + } + + DoAverageGradients(set); + + } + +} + +void QmitkPreprocessingView::DoAverageGradients +(mitk::DataStorage::SetOfObjects::Pointer inImages) +{ + int nrFiles = inImages->size(); + if (!nrFiles) return; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); + + std::vector nodes; + while ( itemiter != itemiterend ) // for all items + { + + mitk::DiffusionImage* vols = + static_cast*>( + (*itemiter)->GetData()); + + vols->AverageRedundantGradients(m_Controls->m_Blur->value()); + + ++itemiter; + } +} + +void QmitkPreprocessingView::BrainMask() +{ + + if (m_CurrentSelection) + { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); + + int at = 0; + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { + + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) + { + set->InsertElement(at++, node); + } + } + } + + DoBrainMask(set); + + } + +} + +void QmitkPreprocessingView::DoBrainMask +(mitk::DataStorage::SetOfObjects::Pointer inImages) +{ + int nrFiles = inImages->size(); + if (!nrFiles) return; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); + + while ( itemiter != itemiterend ) // for all items + { + + mitk::DiffusionImage* vols = + static_cast*>( + (*itemiter)->GetData()); + + std::string nodename; + (*itemiter)->GetStringProperty("name", nodename); + + // Extract image using found index + typedef itk::B0ImageExtractionImageFilter FilterType; + FilterType::Pointer filter = FilterType::New(); + filter->SetInput(vols->GetVectorImage()); + filter->SetDirections(vols->GetDirections()); + + typedef itk::CastImageFilter, itk::Image > CastFilterType; + CastFilterType::Pointer castfilter = CastFilterType::New(); + castfilter->SetInput(filter->GetOutput()); + + typedef itk::BrainMaskExtractionImageFilter MaskFilterType; + MaskFilterType::Pointer maskfilter = MaskFilterType::New(); + maskfilter->SetInput(castfilter->GetOutput()); + maskfilter->Update(); + + mitk::Image::Pointer mitkImage = mitk::Image::New(); + mitkImage->InitializeByItk( maskfilter->GetOutput() ); + mitkImage->SetVolume( maskfilter->GetOutput()->GetBufferPointer() ); + mitk::DataNode::Pointer node=mitk::DataNode::New(); + node->SetData( mitkImage ); + node->SetProperty( "name", mitk::StringProperty::New(nodename + "_Mask")); + + GetDefaultDataStorage()->Add(node); + + ++itemiter; + } +} diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.h new file mode 100644 index 0000000000..3577677361 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingView.h @@ -0,0 +1,114 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Module: $RCSfile$ +Language: C++ +Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $ +Version: $Revision: 17495 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef _QMITKPREPROCESSINGVIEW_H_INCLUDED +#define _QMITKPREPROCESSINGVIEW_H_INCLUDED + +#include + +#include + +#include "ui_QmitkPreprocessingViewControls.h" + +#include "mitkDiffusionImage.h" + +#include +#include +#include + +typedef short DiffusionPixelType; + +struct PrpSelListener; + +/*! + * \ingroup org_mitk_gui_qt_preprocessing_internal + * + * \brief QmitkPreprocessingView + * + * Document your class here. + * + * \sa QmitkFunctionality + */ +class QmitkPreprocessingView : public QmitkFunctionality +{ + + friend struct PrpSelListener; + + // 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; + + typedef vnl_vector_fixed< double, 3 > GradientDirectionType; + typedef itk::VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType; + + QmitkPreprocessingView(); + QmitkPreprocessingView(const QmitkPreprocessingView& other); + virtual ~QmitkPreprocessingView(); + + 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(); + + static const int nrconvkernels; + +protected slots: + + void AverageGradients(); + void DoAverageGradients(mitk::DataStorage::SetOfObjects::Pointer inImages); + + void ExtractB0(); + void DoExtractB0(mitk::DataStorage::SetOfObjects::Pointer inImages); + + void BrainMask(); + void DoBrainMask(mitk::DataStorage::SetOfObjects::Pointer inImages); + + void DoApplyMesurementFrame(); + void DoReduceGradientDirections(); + void DoShowGradientDirections(); + void DoHalfSphereGradientDirections(); + +protected: + + Ui::QmitkPreprocessingViewControls* m_Controls; + + QmitkStdMultiWidget* m_MultiWidget; + + void SetDefaultNodeProperties(mitk::DataNode::Pointer node, std::string name); + + berry::ISelectionListener::Pointer m_SelListener; + berry::IStructuredSelection::ConstPointer m_CurrentSelection; + mitk::DiffusionImage::Pointer m_DiffusionImage; +}; + + + + +#endif // _QMITKPREPROCESSINGVIEW_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingViewControls.ui new file mode 100644 index 0000000000..104e53d529 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkPreprocessingViewControls.ui @@ -0,0 +1,496 @@ + + + QmitkPreprocessingViewControls + + + + 0 + 0 + 389 + 913 + + + + + 0 + 0 + + + + true + + + QmitkPreprocessingViewControls + + + + + + Info + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Number of Gradients: + + + + + + + - + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + b-Value: + + + + + + + - + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + + + + + + + + + + Show gradients + + + + + + + + + + Reduce size + + + + + + + 0 + 70 + + + + Multiple acquistions of one gradient direction can be averaged. Due to rounding errors, similar gradients often differ in the last decimal positions. The Merge radius allows to average them anyway by taking into account all directions within a certain radius. + + + true + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + + + Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. + + + Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. + + + Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. + + + 6 + + + 2.000000000000000 + + + 0.000100000000000 + + + 0.001000000000000 + + + + + + + Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. + + + Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. + + + Accumulates the information that was acquired with multiple repetitions for one gradient. Vectors do not have to be precisely equal in order to be merged, if a "Merge radius" > 0 is configured. + + + Merge radius + + + + + + + + + + false + + + + + + + + + + + + Average redundant gradients + + + + + + + false + + + + + + + + + + + + Mirror gradients to half sphere + + + + + + + Qt::Horizontal + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + + + New number of gradients: + + + + + + + 1 + + + 30 + + + + + + + + + + false + + + + + + + + + + + + Reduce number of gradients + + + + + + + + + + Non diffusion weighted image + + + + + + + 0 + 30 + + + + Average and extract all images that were acquired without diffusion weighting. + + + true + + + + + + + false + + + + + + + + + + + + Extract B0 + + + + + + + + + + Brain mask + + + + + + false + + + + + + + + + + + + Estimate binary brain mask + + + + + + + + + + + 0 + 0 + + + + Measurment frame + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + + 10 + 10 + + + + IBeamCursor + + + true + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + false + + + false + + + true + + + true + + + false + + + true + + + true + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Column + + + + + New Column + + + + + New Column + + + + + + + + false + + + + + + + + + + + + Apply new mesurement frame + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkQBallReconstructionViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkStochasticFiberTrackingViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssMetaTableModel.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssSkeletonizationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTbssTableModel.h diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.cpp new file mode 100644 index 0000000000..30398cc9c0 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.cpp @@ -0,0 +1,1188 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Module: $RCSfile$ +Language: C++ +Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $ +Version: $Revision: 17495 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkTensorReconstructionView.h" +#include "mitkDiffusionImagingConfigure.h" + +// qt includes +#include +#include +#include +#include +#include + +// itk includes +#include "itkTimeProbe.h" +//#include "itkTensor.h" + +// mitk includes +#include "mitkProgressBar.h" +#include "mitkStatusBar.h" + +#include "mitkNodePredicateDataType.h" +#include "QmitkDataStorageComboBox.h" +#include "QmitkStdMultiWidget.h" + +#include "mitkTeemDiffusionTensor3DReconstructionImageFilter.h" +#include "itkDiffusionTensor3DReconstructionImageFilter.h" +#include "itkTensorImageToDiffusionImageFilter.h" +#include "itkPointShell.h" +#include "itkVector.h" +#include "itkB0ImageExtractionImageFilter.h" + +#include "mitkProperties.h" +#include "mitkDataNodeObject.h" +#include "mitkOdfNormalizationMethodProperty.h" +#include "mitkOdfScaleByProperty.h" +#include "mitkDiffusionImageMapper.h" +#include "mitkLookupTableProperty.h" +#include "mitkLookupTable.h" +#include "mitkImageStatisticsHolder.h" + +#include "berryIStructuredSelection.h" +#include "berryIWorkbenchWindow.h" +#include "berryISelectionService.h" + +#include +#include + + +const std::string QmitkTensorReconstructionView::VIEW_ID = +"org.mitk.views.tensorreconstruction"; + +#define DI_INFO MITK_INFO("DiffusionImaging") + +typedef float TTensorPixelType; + +using namespace berry; + +struct TrSelListener : ISelectionListener +{ + + berryObjectMacro(TrSelListener); + + TrSelListener(QmitkTensorReconstructionView* view) + { + m_View = view; + } + + void DoSelectionChanged(ISelection::ConstPointer selection) + { + // if(!m_View->IsVisible()) + // return; + // save current selection in member variable + m_View->m_CurrentSelection = selection.Cast(); + + // do something with the selected items + if(m_View->m_CurrentSelection) + { + bool foundDwiVolume = false; + bool foundTensorVolume = false; + + // iterate selection + for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); + i != m_View->m_CurrentSelection->End(); ++i) + { + + // extract datatree node + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + + // only look at interesting types + if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) + { + foundDwiVolume = true; + } + + // only look at interesting types + if(QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0) + { + foundTensorVolume = true; + } + } + } + + m_View->m_Controls->m_ItkReconstruction->setEnabled(foundDwiVolume); + m_View->m_Controls->m_TeemReconstruction->setEnabled(foundDwiVolume); + + m_View->m_Controls->m_TensorsToDWIButton->setEnabled(foundTensorVolume); + m_View->m_Controls->m_TensorsToQbiButton->setEnabled(foundTensorVolume); + + + m_View->m_Controls->m_ResidualButton->setEnabled(foundDwiVolume && foundTensorVolume); + m_View->m_Controls->m_PercentagesOfOutliers->setEnabled(foundDwiVolume && foundTensorVolume); + + } + } + + void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) + { + // check, if selection comes from datamanager + if (part) + { + QString partname(part->GetPartName().c_str()); + if(partname.compare("Datamanager")==0) + { + + // apply selection + DoSelectionChanged(selection); + + } + } + } + + QmitkTensorReconstructionView* m_View; +}; + +QmitkTensorReconstructionView::QmitkTensorReconstructionView() +: QmitkFunctionality(), +m_Controls(NULL), +m_MultiWidget(NULL) +{ + + + + + + +} + +QmitkTensorReconstructionView::QmitkTensorReconstructionView(const QmitkTensorReconstructionView& other) +{ + Q_UNUSED(other) + throw std::runtime_error("Copy constructor not implemented"); +} + +QmitkTensorReconstructionView::~QmitkTensorReconstructionView() +{ + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); +} + +void QmitkTensorReconstructionView::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkTensorReconstructionViewControls; + m_Controls->setupUi(parent); + this->CreateConnections(); + + QStringList items; + items << "LLS (Linear Least Squares)" + << "MLE (Maximum Likelihood)" + << "NLS (Nonlinear Least Squares)" + << "WLS (Weighted Least Squares)"; + m_Controls->m_TensorEstimationTeemEstimationMethodCombo->addItems(items); + m_Controls->m_TensorEstimationTeemEstimationMethodCombo->setCurrentIndex(0); + + m_Controls->m_TensorEstimationManualThreashold->setChecked(false); + m_Controls->m_TensorEstimationTeemSigmaEdit->setText("NaN"); + m_Controls->m_TensorEstimationTeemNumItsSpin->setValue(1); + m_Controls->m_TensorEstimationTeemFuzzyEdit->setText("0.0"); + m_Controls->m_TensorEstimationTeemMinValEdit->setText("1.0"); + + m_Controls->m_TensorEstimationTeemNumItsLabel_2->setEnabled(true); + m_Controls->m_TensorEstimationTeemNumItsSpin->setEnabled(true); + + m_Controls->m_TensorsToDWIBValueEdit->setText("1000"); + + Advanced1CheckboxClicked(); + Advanced2CheckboxClicked(); + TeemCheckboxClicked(); + +#ifndef DIFFUSION_IMAGING_EXTENDED + m_Controls->m_TeemToggle->setVisible(false); +#endif + + // define data type for combobox + //m_Controls->m_ImageSelector->SetDataStorage( this->GetDefaultDataStorage() ); + //m_Controls->m_ImageSelector->SetPredicate( mitk::NodePredicateDataType::New("DiffusionImage") ); + } + + m_SelListener = berry::ISelectionListener::Pointer(new TrSelListener(this)); + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); + + + + + + +} + +void QmitkTensorReconstructionView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) +{ + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); + m_MultiWidget = &stdMultiWidget; +} + +void QmitkTensorReconstructionView::StdMultiWidgetNotAvailable() +{ + m_MultiWidget = NULL; +} + +void QmitkTensorReconstructionView::CreateConnections() +{ + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->m_TeemToggle), SIGNAL(clicked()), this, SLOT(TeemCheckboxClicked()) ); + connect( (QObject*)(m_Controls->m_ItkReconstruction), SIGNAL(clicked()), this, SLOT(ItkReconstruction()) ); + connect( (QObject*)(m_Controls->m_TeemReconstruction), SIGNAL(clicked()), this, SLOT(TeemReconstruction()) ); + connect( (QObject*)(m_Controls->m_TensorEstimationTeemEstimationMethodCombo), SIGNAL(currentIndexChanged(int)), this, SLOT(MethodChoosen(int)) ); + connect( (QObject*)(m_Controls->m_Advanced1), SIGNAL(clicked()), this, SLOT(Advanced1CheckboxClicked()) ); + connect( (QObject*)(m_Controls->m_Advanced2), SIGNAL(clicked()), this, SLOT(Advanced2CheckboxClicked()) ); + connect( (QObject*)(m_Controls->m_TensorEstimationManualThreashold), SIGNAL(clicked()), this, SLOT(ManualThresholdClicked()) ); + connect( (QObject*)(m_Controls->m_TensorsToDWIButton), SIGNAL(clicked()), this, SLOT(TensorsToDWI()) ); + connect( (QObject*)(m_Controls->m_TensorsToQbiButton), SIGNAL(clicked()), this, SLOT(TensorsToQbi()) ); + connect( (QObject*)(m_Controls->m_ResidualButton), SIGNAL(clicked()), this, SLOT(ResidualCalculation()) ); + } +} + +void QmitkTensorReconstructionView::TeemCheckboxClicked() +{ + m_Controls->groupBox_3->setVisible(m_Controls-> + m_TeemToggle->isChecked()); +} + +void QmitkTensorReconstructionView::Advanced1CheckboxClicked() +{ + bool check = m_Controls-> + m_Advanced1->isChecked(); + + m_Controls->frame->setVisible(check); +} + +void QmitkTensorReconstructionView::Advanced2CheckboxClicked() +{ + bool check = m_Controls-> + m_Advanced2->isChecked(); + + m_Controls->frame_2->setVisible(check); +} + +void QmitkTensorReconstructionView::ManualThresholdClicked() +{ + m_Controls->m_TensorReconstructionThreasholdEdit_2->setEnabled( + m_Controls->m_TensorEstimationManualThreashold->isChecked()); +} + +void QmitkTensorReconstructionView::Activated() +{ + QmitkFunctionality::Activated(); +} + +void QmitkTensorReconstructionView::Deactivated() +{ + QmitkFunctionality::Deactivated(); +} + +void QmitkTensorReconstructionView::MethodChoosen(int method) +{ + m_Controls->m_TensorEstimationTeemNumItsLabel_2->setEnabled(method==3); + m_Controls->m_TensorEstimationTeemNumItsSpin->setEnabled(method==3); +} + +void QmitkTensorReconstructionView::ResidualCalculation() +{ + // Extract dwi and dti from current selection + // In case of multiple selections, take the first one, since taking all combinations is not meaningful + + + + if(m_CurrentSelection) + { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); + + mitk::DiffusionImage::Pointer diffImage + = mitk::DiffusionImage::New(); + + typedef float TTensorPixelType; + typedef itk::DiffusionTensor3D< TTensorPixelType > TensorPixelType; + typedef itk::Image< TensorPixelType, 3 > TensorImageType; + + TensorImageType::Pointer tensorImage; + + std::string nodename; + + + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { + + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) + { + diffImage = static_cast*>((node)->GetData()); + } + else if((QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0)) + { + mitk::TensorImage* mitkVol; + mitkVol = static_cast((node)->GetData()); + mitk::CastToItkImage(mitkVol, tensorImage); + node->GetStringProperty("name", nodename); + } + } + } + + + + typedef itk::TensorImageToDiffusionImageFilter< + TTensorPixelType, DiffusionPixelType > FilterType; + + FilterType::GradientListType gradientList; + mitk::DiffusionImage::GradientDirectionContainerType* gradients + = diffImage->GetDirections(); + + // Copy gradients vectors from gradients to gradientList + for(int i=0; iSize(); i++) + { + mitk::DiffusionImage::GradientDirectionType vec = gradients->at(i); + itk::Vector grad; + + grad[0] = vec[0]; + grad[1] = vec[1]; + grad[2] = vec[2]; + + gradientList.push_back(grad); + } + + // Find the min and the max values from a baseline image + mitk::ImageStatisticsHolder *stats = diffImage->GetStatistics(); + + //Initialize filter that calculates the modeled diffusion weighted signals + FilterType::Pointer filter = FilterType::New(); + filter->SetInput( tensorImage ); + filter->SetBValue(diffImage->GetB_Value()); + filter->SetGradientList(gradientList); + filter->SetMin(stats->GetScalarValueMin()); + filter->SetMax(500); + filter->Update(); + + + // TENSORS TO DATATREE + mitk::DiffusionImage::Pointer image = mitk::DiffusionImage::New(); + image->SetVectorImage( filter->GetOutput() ); + image->SetB_Value(diffImage->GetB_Value()); + image->SetDirections(gradientList); + image->SetOriginalDirections(gradientList); + image->InitializeFromVectorImage(); + mitk::DataNode::Pointer node = mitk::DataNode::New(); + node->SetData( image ); + mitk::DiffusionImageMapper::SetDefaultProperties(node); + + QString newname; + newname = newname.append(nodename.c_str()); + newname = newname.append("_dwi"); + node->SetName(newname.toAscii()); + + + GetDefaultDataStorage()->Add(node); + + + std::vector b0Indices = image->GetB0Indices(); + +/* + // Extract B0 + typedef itk::B0ImageExtractionImageFilter BaslineFilterType; + BaslineFilterType::Pointer baseFilter = BaslineFilterType::New(); + baseFilter->SetInput(image->GetVectorImage()); + baseFilter->SetDirections(image->GetDirections()); + baseFilter->Update(); + + mitk::Image::Pointer boImage = mitk::Image::New(); + boImage->InitializeByItk( baseFilter->GetOutput() ); + boImage->SetVolume( baseFilter->GetOutput()->GetBufferPointer() ); + mitk::DataNode::Pointer b0Node=mitk::DataNode::New(); + b0Node->SetData( boImage ); + b0Node->SetProperty( "name", mitk::StringProperty::New("baseline")); + + GetDefaultDataStorage()->Add(b0Node); +*/ + + typedef itk::ResidualImageFilter ResidualImageFilterType; + + ResidualImageFilterType::Pointer residualFilter = ResidualImageFilterType::New(); + residualFilter->SetInput(diffImage->GetVectorImage()); + residualFilter->SetSecondDiffusionImage(image->GetVectorImage()); + residualFilter->SetGradients(gradients); + residualFilter->SetB0Index(b0Indices[0]); + residualFilter->SetB0Threshold(30); + residualFilter->Update(); + + itk::Image::Pointer residualImage = itk::Image::New(); + residualImage = residualFilter->GetOutput(); + + mitk::Image::Pointer mitkResImg = mitk::Image::New(); + + mitk::CastToMitkImage(residualImage, mitkResImg); + + stats = mitkResImg->GetStatistics(); + float min = stats->GetScalarValueMin(); + float max = stats->GetScalarValueMax(); + + mitk::LookupTableProperty::Pointer lutProp = mitk::LookupTableProperty::New(); + mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); + + + vtkSmartPointer lookupTable = + vtkSmartPointer::New(); + + lookupTable->SetTableRange(min, max); + + + // If you don't want to use the whole color range, you can use + // SetValueRange, SetHueRange, and SetSaturationRange + lookupTable->Build(); + + int size = lookupTable->GetTable()->GetSize(); + + vtkSmartPointer reversedlookupTable = + vtkSmartPointer::New(); + reversedlookupTable->SetTableRange(min+1, max); + reversedlookupTable->Build(); + + for(int i=0; i<256; i++) + { + double* rgba = reversedlookupTable->GetTableValue(255-i); + + lookupTable->SetTableValue(i, rgba[0], rgba[1], rgba[2], rgba[3]); + } + + lut->SetVtkLookupTable(lookupTable); + lutProp->SetLookupTable(lut); + + // Create lookuptable + + mitk::DataNode::Pointer resNode=mitk::DataNode::New(); + resNode->SetData( mitkResImg ); + resNode->SetName("Residual Image"); + + resNode->SetProperty("LookupTable", lutProp); + + bool b; + resNode->GetBoolProperty("use color", b); + resNode->SetBoolProperty("use color", false); + + GetDefaultDataStorage()->Add(resNode); + + m_MultiWidget->RequestUpdate(); + + + + // Draw Graph + std::vector means = residualFilter->GetMeans(); + std::vector q1s = residualFilter->GetQ1(); + std::vector q3s = residualFilter->GetQ3(); + std::vector percentagesOfOUtliers = residualFilter->GetPercentagesOfOutliers(); + + m_Controls->m_ResidualAnalysis->SetMeans(means); + m_Controls->m_ResidualAnalysis->SetQ1(q1s); + m_Controls->m_ResidualAnalysis->SetQ3(q3s); + m_Controls->m_ResidualAnalysis->SetPercentagesOfOutliers(percentagesOfOUtliers); + + if(m_Controls->m_PercentagesOfOutliers->isChecked()) + { + m_Controls->m_ResidualAnalysis->DrawPercentagesOfOutliers(); + } + else + { + m_Controls->m_ResidualAnalysis->DrawMeans(); + } + + + + // Draw Graph for volumes per slice in the QGraphicsView + std::vector< std::vector > outliersPerSlice = residualFilter->GetOutliersPerSlice(); + int xSize = outliersPerSlice.size(); + if(xSize == 0) + { + return; + } + int ySize = outliersPerSlice[0].size(); + + + // Find maximum in outliersPerSlice + double maxOutlier= 0.0; + for(int i=0; imaxOutlier) + { + maxOutlier = outliersPerSlice[i][j]; + } + } + } + + + // Create some QImage + QImage qImage(xSize, ySize, QImage::Format_RGB32); + QRgb value; + + vtkSmartPointer lookup = + vtkSmartPointer::New(); + + lookup->SetTableRange(0.0, maxOutlier); + lookup->Build(); + + vtkIndent ind; + lookup->GetTable()->PrintSelf(std::cout, ind); + + + + // Fill qImage + for(int i=0; iGetTableValue(out); + double r = c[0] * 255; + double g = c[1] * 255; + double b = c[2] * 255; + + value = qRgb((int)r, (int)g, (int)b); + + std::cout << out << ": " << r << ' ' << g << ' ' << b << '\n'; + + qImage.setPixel(i,j,value); + } + } + std::cout << std::endl; + +/* + value = qRgb(122, 163, 39); // 0xff7aa327 + qImage.setColor(0, value); + + value = qRgb(237, 187, 51); // 0xffedba31 + qImage.setColor(1, value); + value = qRgb(189, 149, 39); // 0xffbd9527 + + qImage.setColor(2, value); + + + + int dotX = qImage.dotsPerMeterX(); + int dotY= qImage.dotsPerMeterY(); + + qImage.setDotsPerMeterX(10*dotX); + qImage.setDotsPerMeterY(10*dotY); + */ + + QGraphicsScene* scene = new QGraphicsScene; + + QGraphicsPixmapItem *item = new QGraphicsPixmapItem( QPixmap::fromImage(qImage), 0, scene); + + item->setScale(25); + + + //QGraphicsView view( &scene ); + m_Controls->m_PerSliceView->setRenderHints( QPainter::Antialiasing ); + + m_Controls->m_PerSliceView->setScene(scene); + m_Controls->m_PerSliceView->show(); + + m_Controls->m_PerSliceView->repaint(); + + } + + +} + +void QmitkTensorReconstructionView::ItkReconstruction() +{ + Reconstruct(0); +} + +void QmitkTensorReconstructionView::TeemReconstruction() +{ + Reconstruct(1); +} + +void QmitkTensorReconstructionView::Reconstruct(int method) +{ + if (m_CurrentSelection) + { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); + + int at = 0; + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { + + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0) + { + set->InsertElement(at++, node); + } + } + } + + if(method == 0) + { + ItkTensorReconstruction(set); + } + + if(method == 1) + { + TeemTensorReconstruction(set); + } + + } +} + +void QmitkTensorReconstructionView::ItkTensorReconstruction +(mitk::DataStorage::SetOfObjects::Pointer inImages) +{ + try + { + itk::TimeProbe clock; + + int nrFiles = inImages->size(); + if (!nrFiles) return; + + QString status; + mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles); + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); + + std::vector nodes; + while ( itemiter != itemiterend ) // for all items + { + + mitk::DiffusionImage* vols = + static_cast*>( + (*itemiter)->GetData()); + + std::string nodename; + (*itemiter)->GetStringProperty("name", nodename); + ++itemiter; + + // TENSOR RECONSTRUCTION + clock.Start(); + MBI_INFO << "Tensor reconstruction "; + mitk::StatusBar::GetInstance()->DisplayText(status.sprintf( + "Tensor reconstruction for %s", nodename.c_str()).toAscii()); + typedef itk::DiffusionTensor3DReconstructionImageFilter< + DiffusionPixelType, DiffusionPixelType, TTensorPixelType > TensorReconstructionImageFilterType; + TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter = + TensorReconstructionImageFilterType::New(); + tensorReconstructionFilter->SetGradientImage( vols->GetDirections(), vols->GetVectorImage() ); + tensorReconstructionFilter->SetBValue(vols->GetB_Value()); + tensorReconstructionFilter->SetThreshold( m_Controls->m_TensorReconstructionThreasholdEdit->text().toFloat() ); + tensorReconstructionFilter->Update(); + clock.Stop(); + MBI_DEBUG << "took " << clock.GetMeanTime() << "s."; + + // TENSORS TO DATATREE + mitk::TensorImage::Pointer image = mitk::TensorImage::New(); + + + typedef itk::Image, 3> TensorImageType; + + TensorImageType::Pointer tensorImage; + tensorImage = tensorReconstructionFilter->GetOutput(); + + + // Check the tensor for negative eigenvalues + if(m_Controls->m_CheckNegativeEigenvalues->isChecked()) + { + typedef itk::ImageRegionIterator TensorImageIteratorType; + TensorImageIteratorType tensorIt(tensorImage, tensorImage->GetRequestedRegion()); + tensorIt.GoToBegin(); + + while(!tensorIt.IsAtEnd()) + { + + typedef itk::DiffusionTensor3D TensorType; + //typedef itk::Tensor TensorType2; + + TensorType tensor = tensorIt.Get(); + // TensorType2 tensor2; + + /* + for(int i=0; i SymEigenSystemType; + SymEigenSystemType eig (tensor2.GetVnlMatrix()); + for(unsigned int i=0; iInitializeByItk( tensorImage.GetPointer() ); + image->SetVolume( tensorReconstructionFilter->GetOutput()->GetBufferPointer() ); + mitk::DataNode::Pointer node=mitk::DataNode::New(); + node->SetData( image ); + + QString newname; + newname = newname.append(nodename.c_str()); + newname = newname.append("_dti"); + + SetDefaultNodeProperties(node, newname.toStdString()); + nodes.push_back(node); + + mitk::ProgressBar::GetInstance()->Progress(); + + } + + std::vector::iterator nodeIt; + for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt) + GetDefaultDataStorage()->Add(*nodeIt); + + mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii()); + m_MultiWidget->RequestUpdate(); + + } + catch (itk::ExceptionObject &ex) + { + MBI_INFO << ex ; + return ; + } +} + + + +void QmitkTensorReconstructionView::TeemTensorReconstruction +(mitk::DataStorage::SetOfObjects::Pointer inImages) +{ + try + { + itk::TimeProbe clock; + + int nrFiles = inImages->size(); + if (!nrFiles) return; + + QString status; + mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles); + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); + + std::vector nodes; + while ( itemiter != itemiterend ) // for all items + { + + mitk::DiffusionImage* vols = + static_cast*>( + (*itemiter)->GetData()); + + std::string nodename; + (*itemiter)->GetStringProperty("name", nodename); + ++itemiter; + + // TENSOR RECONSTRUCTION + clock.Start(); + MBI_INFO << "Teem Tensor reconstruction "; + mitk::StatusBar::GetInstance()->DisplayText(status.sprintf( + "Teem Tensor reconstruction for %s", nodename.c_str()).toAscii()); + typedef mitk::TeemDiffusionTensor3DReconstructionImageFilter< + DiffusionPixelType, TTensorPixelType > TensorReconstructionImageFilterType; + TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter = + TensorReconstructionImageFilterType::New(); + tensorReconstructionFilter->SetInput( vols ); + if(!m_Controls->m_TensorEstimationTeemSigmaEdit->text().contains(QString("NaN"))) + tensorReconstructionFilter->SetSigma( m_Controls->m_TensorEstimationTeemSigmaEdit->text().toFloat() ); + switch(m_Controls->m_TensorEstimationTeemEstimationMethodCombo->currentIndex()) + { + // items << "LLS (Linear Least Squares)" + //<< "MLE (Maximum Likelihood)" + //<< "NLS (Nonlinear Least Squares)" + //<< "WLS (Weighted Least Squares)"; + case 0: + tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsLLS); + break; + case 1: + tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsMLE); + break; + case 2: + tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsNLS); + break; + case 3: + tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsWLS); + break; + default: + tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsLLS); + } + tensorReconstructionFilter->SetNumIterations( m_Controls->m_TensorEstimationTeemNumItsSpin->value() ); + if(m_Controls->m_TensorEstimationManualThreashold->isChecked()) + tensorReconstructionFilter->SetConfidenceThreshold( m_Controls->m_TensorReconstructionThreasholdEdit_2->text().toDouble() ); + tensorReconstructionFilter->SetConfidenceFuzzyness( m_Controls->m_TensorEstimationTeemFuzzyEdit->text().toFloat() ); + tensorReconstructionFilter->SetMinPlausibleValue( m_Controls->m_TensorEstimationTeemMinValEdit->text().toDouble() ); + tensorReconstructionFilter->Update(); + clock.Stop(); + MBI_DEBUG << "took " << clock.GetMeanTime() << "s." ; + + // TENSORS TO DATATREE + mitk::DataNode::Pointer node2=mitk::DataNode::New(); + node2->SetData( tensorReconstructionFilter->GetOutputItk() ); + + QString newname; + newname = newname.append(nodename.c_str()); + newname = newname.append("_dtix"); + + SetDefaultNodeProperties(node2, newname.toStdString()); + nodes.push_back(node2); + + mitk::ProgressBar::GetInstance()->Progress(); + + } + + std::vector::iterator nodeIt; + for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt) + GetDefaultDataStorage()->Add(*nodeIt); + + mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii()); + m_MultiWidget->RequestUpdate(); + + } + catch (itk::ExceptionObject &ex) + { + MBI_INFO << ex ; + return ; + } +} + +void QmitkTensorReconstructionView::SetDefaultNodeProperties(mitk::DataNode::Pointer node, std::string name) +{ + node->SetProperty( "ShowMaxNumber", mitk::IntProperty::New( 500 ) ); + node->SetProperty( "Scaling", mitk::FloatProperty::New( 1.0 ) ); + node->SetProperty( "Normalization", mitk::OdfNormalizationMethodProperty::New()); + node->SetProperty( "ScaleBy", mitk::OdfScaleByProperty::New()); + node->SetProperty( "IndexParam1", mitk::FloatProperty::New(2)); + node->SetProperty( "IndexParam2", mitk::FloatProperty::New(1)); + node->SetProperty( "visible", mitk::BoolProperty::New( true ) ); + node->SetProperty( "VisibleOdfs", mitk::BoolProperty::New( false ) ); + node->SetProperty ("layer", mitk::IntProperty::New(100)); + node->SetProperty( "DoRefresh", mitk::BoolProperty::New( true ) ); + //node->SetProperty( "opacity", mitk::FloatProperty::New(1.0f) ); + + node->SetProperty( "name", mitk::StringProperty::New(name) ); +} + + +//node->SetProperty( "volumerendering", mitk::BoolProperty::New( false ) ); +//node->SetProperty( "use color", mitk::BoolProperty::New( true ) ); +//node->SetProperty( "texture interpolation", mitk::BoolProperty::New( true ) ); +//node->SetProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ); +//node->SetProperty( "layer", mitk::IntProperty::New(0)); +//node->SetProperty( "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ); +//node->SetOpacity(1.0f); +//node->SetColor(1.0,1.0,1.0); +//node->SetVisibility(true); +//node->SetProperty( "IsTensorVolume", mitk::BoolProperty::New( true ) ); + +//mitk::LevelWindowProperty::Pointer levWinProp = mitk::LevelWindowProperty::New(); +//mitk::LevelWindow levelwindow; +//// levelwindow.SetAuto( image ); +//levWinProp->SetLevelWindow( levelwindow ); +//node->GetPropertyList()->SetProperty( "levelwindow", levWinProp ); + +//// add a default rainbow lookup table for color mapping +//if(!node->GetProperty("LookupTable")) +//{ +// mitk::LookupTable::Pointer mitkLut = mitk::LookupTable::New(); +// vtkLookupTable* vtkLut = mitkLut->GetVtkLookupTable(); +// vtkLut->SetHueRange(0.6667, 0.0); +// vtkLut->SetTableRange(0.0, 20.0); +// vtkLut->Build(); +// mitk::LookupTableProperty::Pointer mitkLutProp = mitk::LookupTableProperty::New(); +// mitkLutProp->SetLookupTable(mitkLut); +// node->SetProperty( "LookupTable", mitkLutProp ); +//} +//if(!node->GetProperty("binary")) +// node->SetProperty( "binary", mitk::BoolProperty::New( false ) ); + +//// add a default transfer function +//mitk::TransferFunction::Pointer tf = mitk::TransferFunction::New(); +//node->SetProperty ( "TransferFunction", mitk::TransferFunctionProperty::New ( tf.GetPointer() ) ); + +//// set foldername as string property +//mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New( name ); +//node->SetProperty( "name", nameProp ); + +void QmitkTensorReconstructionView::TensorsToDWI() +{ + if (m_CurrentSelection) + { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); + + int at = 0; + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { + + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + if(QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0) + { + set->InsertElement(at++, node); + } + } + } + + DoTensorsToDWI(set); + } +} + +void QmitkTensorReconstructionView::TensorsToQbi() +{ + std::vector nodes = this->GetDataManagerSelection(); + for (int i=0; i TensorPixelType; + typedef itk::Image< TensorPixelType, 3 > TensorImageType; + + TensorImageType::Pointer itkvol = TensorImageType::New(); + mitk::CastToItkImage(dynamic_cast(tensorImageNode->GetData()), itkvol); + + typedef itk::TensorImageToQBallImageFilter< TTensorPixelType, TTensorPixelType > FilterType; + FilterType::Pointer filter = FilterType::New(); + filter->SetInput( itkvol ); + filter->Update(); + + typedef itk::Vector OutputPixelType; + typedef itk::Image OutputImageType; + + mitk::QBallImage::Pointer image = mitk::QBallImage::New(); + OutputImageType::Pointer outimg = filter->GetOutput(); + image->InitializeByItk( outimg.GetPointer() ); + image->SetVolume( outimg->GetBufferPointer() ); + mitk::DataNode::Pointer node = mitk::DataNode::New(); + node->SetData( image ); + QString newname; + newname = newname.append(tensorImageNode->GetName().c_str()); + newname = newname.append("_qbi"); + node->SetName(newname.toAscii()); + GetDefaultDataStorage()->Add(node); + } +} + +void QmitkTensorReconstructionView::OnSelectionChanged( std::vector nodes ) +{ + if ( !this->IsVisible() ) + return; + +} + +template +std::vector > QmitkTensorReconstructionView::MakeGradientList() +{ + std::vector > retval; + vnl_matrix_fixed* U = + itk::PointShell >::DistributePointShell(); + + for(int i=0; i v; + v[0] = U->get(0,i); v[1] = U->get(1,i); v[2] = U->get(2,i); + retval.push_back(v); + } + // Add 0 vector for B0 + itk::Vector v; + v.Fill(0.0); + retval.push_back(v); + + return retval; +} + +void QmitkTensorReconstructionView::DoTensorsToDWI +(mitk::DataStorage::SetOfObjects::Pointer inImages) +{ + try + { + itk::TimeProbe clock; + + int nrFiles = inImages->size(); + if (!nrFiles) return; + + QString status; + mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles); + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() ); + + std::vector nodes; + while ( itemiter != itemiterend ) // for all items + { + + std::string nodename; + (*itemiter)->GetStringProperty("name", nodename); + + mitk::TensorImage* vol = + static_cast((*itemiter)->GetData()); + + ++itemiter; + + typedef float TTensorPixelType; + typedef itk::DiffusionTensor3D< TTensorPixelType > TensorPixelType; + typedef itk::Image< TensorPixelType, 3 > TensorImageType; + + + TensorImageType::Pointer itkvol = TensorImageType::New(); + mitk::CastToItkImage(vol, itkvol); + + typedef itk::TensorImageToDiffusionImageFilter< + TTensorPixelType, DiffusionPixelType > FilterType; + + FilterType::GradientListType gradientList; + + switch(m_Controls->m_TensorsToDWINumDirsSelect->currentIndex()) + { + case 0: + gradientList = MakeGradientList<12>(); + break; + case 1: + gradientList = MakeGradientList<42>(); + break; + case 2: + gradientList = MakeGradientList<92>(); + break; + case 3: + gradientList = MakeGradientList<162>(); + break; + case 4: + gradientList = MakeGradientList<252>(); + break; + case 5: + gradientList = MakeGradientList<362>(); + break; + case 6: + gradientList = MakeGradientList<492>(); + break; + case 7: + gradientList = MakeGradientList<642>(); + break; + case 8: + gradientList = MakeGradientList<812>(); + break; + case 9: + gradientList = MakeGradientList<1002>(); + break; + default: + gradientList = MakeGradientList<92>(); + + } + + double bVal = m_Controls->m_TensorsToDWIBValueEdit->text().toDouble(); + + // DWI ESTIMATION + clock.Start(); + MBI_INFO << "DWI Estimation "; + mitk::StatusBar::GetInstance()->DisplayText(status.sprintf( + "DWI Estimation for %s", nodename.c_str()).toAscii()); + FilterType::Pointer filter = FilterType::New(); + filter->SetInput( itkvol ); + filter->SetBValue(bVal); + filter->SetGradientList(gradientList); + //filter->SetNumberOfThreads(1); + filter->Update(); + clock.Stop(); + MBI_DEBUG << "took " << clock.GetMeanTime() << "s."; + + itk::Vector v; + v[0] = 0; v[1] = 0; v[2] = 0; + gradientList.push_back(v); + + // TENSORS TO DATATREE + mitk::DiffusionImage::Pointer image = mitk::DiffusionImage::New(); + image->SetVectorImage( filter->GetOutput() ); + image->SetB_Value(bVal); + image->SetDirections(gradientList); + image->SetOriginalDirections(gradientList); + image->InitializeFromVectorImage(); + mitk::DataNode::Pointer node=mitk::DataNode::New(); + node->SetData( image ); + + mitk::DiffusionImageMapper::SetDefaultProperties(node); + + QString newname; + newname = newname.append(nodename.c_str()); + newname = newname.append("_dwi"); + node->SetName(newname.toAscii()); + + nodes.push_back(node); + + mitk::ProgressBar::GetInstance()->Progress(); + + } + + std::vector::iterator nodeIt; + for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt) + GetDefaultDataStorage()->Add(*nodeIt); + + mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii()); + m_MultiWidget->RequestUpdate(); + + } + catch (itk::ExceptionObject &ex) + { + MBI_INFO << ex ; + return ; + } +} diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionView.h diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionViewControls.ui new file mode 100644 index 0000000000..fac9d3fa3e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTensorReconstructionViewControls.ui @@ -0,0 +1,622 @@ + + + QmitkTensorReconstructionViewControls + + + + 0 + 0 + 345 + 1303 + + + + + 0 + 0 + + + + true + + + QmitkTensorReconstructionViewControls + + + + + + ITK Reconstruction + + + + + + Advanced Settings + + + false + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + B0 Threshold + + + false + + + + + + + 0 + + + + + + + Check for negative eigenvalues + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + false + + + + + + + + + + + + ITK Tensor Reconstruction + + + + + + + + + + Estimate Diffusion Image from Tensors + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QFormLayout::AllNonFixedFieldsGrow + + + 6 + + + 6 + + + 9 + + + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + B-Value + + + false + + + + + + + + 0 + 0 + + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + + + + + # Gradient Directions + + + + + + + 3 + + + + 12 + + + + + 42 + + + + + 92 + + + + + 162 + + + + + 252 + + + + + 362 + + + + + 492 + + + + + 642 + + + + + 812 + + + + + 1002 + + + + + + + + + + + false + + + + + + + + + + + + Diffusion Image Estimation + + + + + + + + + + Estimate Q-Ball Image from Tensors + + + + + + false + + + Calculate ODF value as tensor value in the according direction + + + + + + + + + Q-Ball Image Estimation + + + + + + + + + + true + + + Teem Reconstruction + + + true + + + + + + + Teem Reconstruction + + + + + + Advanced Settings + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + important in case of method wls + + + # Iterations + + + false + + + + + + + + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + Fuzzy confidence + + + false + + + + + + + + 0 + 0 + + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + how fuzzy the confidence boundary should be. By default, confidence boundary is perfectly sharp (float); default: "0" + + + + + + + minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" + + + minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" + + + minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" + + + Min plausible value + + + false + + + + + + + Rician noise parameter (float) + + + Rician noise parameter (float) + + + Rician noise parameter (float) + + + Sigma + + + false + + + + + + + + 0 + 0 + + + + minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" + + + minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" + + + minimum plausible value (especially important for linear least squares estimation) (double); default: "1.0" + + + + + + + + 0 + 0 + + + + Rician noise parameter (float) + + + Rician noise parameter (float) + + + Rician noise parameter (float) + + + + + + + + + + Method + + + + + + + B0-Threshold + + + + + + + false + + + 0 + + + + + + + + + + false + + + Teem Tensor Reconstruction + + + + + + + + + + Residuals + + + true + + + true + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + false + + + Calculate the residual from a dti and a dwi iimage + + + + + + + + + Residual Image Calculation + + + + + + + 1 + + + + Per volume + + + + + + + 200 + 300 + + + + + + + + + Per slice + + + + + + + + + + + + + false + + + percentages of error + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 1150 + + + + + + + + + + QmitkResidualAnalysisWidget + QWidget +
QmitkResidualAnalysisWidget.h
+ 1 +
+
+ + +
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorEstimation.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorIcon.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorIcon.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorIcon.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/deprecated/QmitkDiffusionTensorIcon.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt b/Plugins/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/MitkDiffusionImagingAppQtHelpCollectionProject.qhcp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/MitkDiffusionImagingAppQtHelpCollectionProject.qhcp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/MitkDiffusionImagingAppQtHelpCollectionProject.qhcp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/MitkDiffusionImagingAppQtHelpCollectionProject.qhcp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/UserManual/QmitkDiffusionImagingAppUserManual.dox b/Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/UserManual/QmitkDiffusionImagingAppUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/UserManual/QmitkDiffusionImagingAppUserManual.dox rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/UserManual/QmitkDiffusionImagingAppUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/about-logo.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/about-logo.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/about-logo.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/about-logo.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/assistant-icon.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/assistant-icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/documentation/assistant-icon.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/assistant-icon.png diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..8dc3e71bf1 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_diffusionimagingapp org.mitk.diffusionimagingapp + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_diffusionimagingapp_internal Internal + \ingroup org_mitk_diffusionimagingapp + + \brief This subcategory includes the internal classes of the org.mitk.diffusionimagingapp plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/files.cmake b/Plugins/org.mitk.gui.qt.diffusionimagingapp/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/files.cmake rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/files.cmake diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.diffusionimagingapp/manifest_headers.cmake new file mode 100644 index 0000000000..3474a73b0d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/manifest_headers.cmake @@ -0,0 +1,8 @@ +set(Plugin-Name "MITK Diffusion") +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.ext org.mitk.gui.qt.stdmultiwidgeteditor) +set(Plugin-Activator QmitkDiffusionImagingAppApplicationPlugin) + + diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/plugin.xml b/Plugins/org.mitk.gui.qt.diffusionimagingapp/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/plugin.xml rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/ImageProcessing_48.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/ImageProcessing_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/ImageProcessing_48.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/ImageProcessing_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/Measurement_48.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/Measurement_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/Measurement_48.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/Measurement_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/RigidRegistration.xpm b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/RigidRegistration.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/RigidRegistration.xpm rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/RigidRegistration.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/app-icon.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/app-icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/app-icon.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/app-icon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/diffusionimaging.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/diffusionimaging.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/diffusionimaging.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/diffusionimaging.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/icon_dicom.xpm b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/icon_dicom.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/icon_dicom.xpm rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/icon_dicom.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/icon_vesseltreesegmentation.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/icon_vesseltreesegmentation.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/icon_vesseltreesegmentation.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/icon_vesseltreesegmentation.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/mintLogo.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/mintLogo.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/mintLogo.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/mintLogo.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/org_mitk_gui_qt_diffusionimagingapp.qrc b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/org_mitk_gui_qt_diffusionimagingapp.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/org_mitk_gui_qt_diffusionimagingapp.qrc rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/org_mitk_gui_qt_diffusionimagingapp.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/connectomics.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/connectomics.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/connectomics.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/connectomics.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/dicomimport.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/dicomimport.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/dicomimport.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/dicomimport.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/diffusionimaging.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/diffusionimaging.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/diffusionimaging.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/diffusionimaging.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/icon_home.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/icon_home.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/icon_home.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/icon_home.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/ivim.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/ivim.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/ivim.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/ivim.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/preprocessingreconstruction.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/preprocessingreconstruction.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/preprocessingreconstruction.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/preprocessingreconstruction.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/quantification.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/quantification.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/quantification.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/quantification.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/screenshotsmovies.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/screenshotsmovies.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/screenshotsmovies.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/screenshotsmovies.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tbss.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tbss.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tbss.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tbss.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tractography.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tractography.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tractography.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/tractography.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/volumevizualization.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/volumevizualization.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/volumevizualization.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/perspectives/volumevizualization.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/preprocessing.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/preprocessing.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/preprocessing.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/preprocessing.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/segmentation.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/segmentation.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/segmentation.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/segmentation.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/volvis.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/volvis.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/volvis.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/volvis.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/QmitkWelcomeScreenView.qrc b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/QmitkWelcomeScreenView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/QmitkWelcomeScreenView.qrc rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/QmitkWelcomeScreenView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/function.js b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/function.js similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/function.js rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/function.js diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/mitkdiffusionimagingappwelcomeview.html b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/mitkdiffusionimagingappwelcomeview.html similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/mitkdiffusionimagingappwelcomeview.html rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/mitkdiffusionimagingappwelcomeview.html diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01adicomimport.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01adicomimport.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01adicomimport.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01adicomimport.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01dicomimport.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01dicomimport.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01dicomimport.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/01dicomimport.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02apreprocessingreconstruction.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02apreprocessingreconstruction.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02apreprocessingreconstruction.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02apreprocessingreconstruction.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02preprocessingreconstruction.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02preprocessingreconstruction.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02preprocessingreconstruction.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/02preprocessingreconstruction.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03aquantification.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03aquantification.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03aquantification.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03aquantification.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03quantification.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03quantification.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03quantification.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/03quantification.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04atractography.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04atractography.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04atractography.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04atractography.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04tractography.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04tractography.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04tractography.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/04tractography.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05atbss.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05atbss.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05atbss.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05atbss.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05tbss.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05tbss.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05tbss.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/05tbss.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06aconnectomics.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06aconnectomics.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06aconnectomics.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06aconnectomics.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06connectomics.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06connectomics.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06connectomics.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/06connectomics.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07aivim.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07aivim.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07aivim.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07aivim.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07ivim.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07ivim.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07ivim.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/07ivim.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08avolumevisualization.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08avolumevisualization.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08avolumevisualization.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08avolumevisualization.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08volumevisualization.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08volumevisualization.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08volumevisualization.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/08volumevisualization.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09ascreenshotsmovies.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09ascreenshotsmovies.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09ascreenshotsmovies.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09ascreenshotsmovies.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09screenshotsmovies.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09screenshotsmovies.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09screenshotsmovies.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/09screenshotsmovies.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/background.jpg b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/background.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/background.jpg rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/background.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitk.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitk.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitk.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitk.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitka.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitka.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitka.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/button_mitka.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/experimental.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/experimental.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/experimental.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/experimental.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_bottom.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_bottom.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_bottom.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_bottom.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_middle.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_middle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_middle.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_middle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_top.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_top.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_top.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bg_top.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bttn_close.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bttn_close.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bttn_close.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/popup_bttn_close.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/shadow.png b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/shadow.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/shadow.png rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/pics/shadow.png diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/style.css b/Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/style.css similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/style.css rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/resources/welcome/style.css diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppApplication.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppConnectomicsPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppDicomImportPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppFiberTractographyPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppIVIMPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppPreprocessingReconstructionPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppQuantificationPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppScreenshotsMoviesPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTBSSPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppTrackingEvaluationPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDIAppVolumeVisualizationPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppApplication.h~bug-8511-DTI-atlas-app b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppApplication.h~bug-8511-DTI-atlas-app similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppApplication.h~bug-8511-DTI-atlas-app rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppApplication.h~bug-8511-DTI-atlas-app diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp new file mode 100644 index 0000000000..329abe8cc0 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp @@ -0,0 +1,245 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkDiffusionImagingAppIntroPart.h" + +#include "mitkNodePredicateDataType.h" +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#ifdef QT_WEBKIT +#include +#include +#endif +#include +#include +#include +#include +#include +#include + +#include "QmitkStdMultiWidget.h" +#include "QmitkStdMultiWidgetEditor.h" +#include "mitkPluginActivator.h" +#include "mitkDataStorageEditorInput.h" + +#include "mitkBaseDataIOFactory.h" +#include "mitkSceneIO.h" +#include "mitkProgressBar.h" +#include "mitkDataNodeFactory.h" +#include "mitkNodePredicateNot.h" +#include "mitkNodePredicateProperty.h" + +QmitkDiffusionImagingAppIntroPart::QmitkDiffusionImagingAppIntroPart() + : m_Controls(NULL) +{ + berry::IPreferences::Pointer workbenchPrefs = mitkPluginActivator::GetDefault()->GetPreferencesService()->GetSystemPreferences(); + workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); + workbenchPrefs->Flush(); +} + +QmitkDiffusionImagingAppIntroPart::~QmitkDiffusionImagingAppIntroPart() +{ + // if the workbench is not closing (that means, welcome screen was closed explicitly), set "Show_intro" false + if (!this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) + { + berry::IPreferences::Pointer workbenchPrefs = mitkPluginActivator::GetDefault()->GetPreferencesService()->GetSystemPreferences(); + workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); + workbenchPrefs->Flush(); + } + else + { + berry::IPreferences::Pointer workbenchPrefs = mitkPluginActivator::GetDefault()->GetPreferencesService()->GetSystemPreferences(); + workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); + workbenchPrefs->Flush(); + } + + // if workbench is not closing (Just welcome screen closing), open last used perspective + if (this->GetIntroSite()->GetPage()->GetPerspective()->GetId() + == "org.mitk.diffusionimagingapp.perspectives.welcome" && !this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) + { + berry::IPerspectiveDescriptor::Pointer perspective = this->GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->GetPerspectiveRegistry()->FindPerspectiveWithId("org.mitk.diffusionimagingapp.perspectives.diffusionimagingapp"); + if (perspective) + { + this->GetIntroSite()->GetPage()->SetPerspective(perspective); + } + } + +} + + +void QmitkDiffusionImagingAppIntroPart::CreateQtPartControl(QWidget* parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkWelcomeScreenViewControls; + m_Controls->setupUi(parent); +#ifdef QT_WEBKIT + + // create a QWebView as well as a QWebPage and QWebFrame within the QWebview + m_view = new QWebView(parent); + m_view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); + + QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/mitkdiffusionimagingappwelcomeview.html"), QUrl::TolerantMode ); + m_view->load( urlQtResource ); + + // adds the webview as a widget + parent->layout()->addWidget(m_view); + this->CreateConnections(); +#else + parent->layout()->addWidget(new QLabel("

Please install Qt with the WebKit option to see cool pictures!

")); +#endif + } +} + +#ifdef QT_WEBKIT +void QmitkDiffusionImagingAppIntroPart::CreateConnections() +{ + if ( m_Controls ) + { + connect( (QObject*)(m_view->page()), SIGNAL(linkClicked(const QUrl& )), this, SLOT(DelegateMeTo(const QUrl& )) ); + } +} + + +void QmitkDiffusionImagingAppIntroPart::DelegateMeTo(const QUrl& showMeNext) +{ + QString scheme = showMeNext.scheme(); + QByteArray urlHostname = showMeNext.encodedHost(); + QByteArray urlPath = showMeNext.encodedPath(); + QByteArray dataset = showMeNext.encodedQueryItemValue("dataset"); + QByteArray clear = showMeNext.encodedQueryItemValue("clear"); + + if (scheme.isEmpty()) MITK_INFO << " empty scheme of the to be delegated link" ; + + // if the scheme is set to mitk, it is to be tested which action should be applied + if (scheme.contains(QString("mitk")) ) + { + if(urlPath.isEmpty() ) MITK_INFO << " mitk path is empty " ; + + // searching for the perspective keyword within the host name + if(urlHostname.contains(QByteArray("perspectives")) ) + { + // the simplified method removes every whitespace + // ( whitespace means any character for which the standard C++ isspace() method returns true) + urlPath = urlPath.simplified(); + QString tmpPerspectiveId(urlPath.data()); + tmpPerspectiveId.replace(QString("/"), QString("") ); + std::string perspectiveId = tmpPerspectiveId.toStdString(); + + // is working fine as long as the perspective id is valid, if not the application crashes + GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); + + mitk::DataStorageEditorInput::Pointer editorInput; + editorInput = new mitk::DataStorageEditorInput(); + berry::IEditorPart::Pointer editor = GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); + + + QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; + mitk::DataStorage::Pointer dataStorage; + + if (editor.Cast().IsNull()) + { + editorInput = new mitk::DataStorageEditorInput(); + dataStorage = editorInput->GetDataStorageReference()->GetDataStorage(); + } + else + { + multiWidgetEditor = editor.Cast(); + multiWidgetEditor->GetStdMultiWidget()->RequestUpdate(); + dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); + } + + bool dsmodified = false; + if(dataStorage.IsNotNull() && dsmodified) + { + // 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 = dataStorage->GetSubset(pred); + + if(rs->Size() > 0) + { + // calculate bounding geometry of these nodes + mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); + // initialize the views to the bounding geometry + mitk::RenderingManager::GetInstance()->InitializeViews(bounds); + } + } + + } + // searching for the load + if(urlHostname.contains(QByteArray("perspectives")) ) + { + // the simplified method removes every whitespace + // ( whitespace means any character for which the standard C++ isspace() method returns true) + urlPath = urlPath.simplified(); + QString tmpPerspectiveId(urlPath.data()); + tmpPerspectiveId.replace(QString("/"), QString("") ); + std::string perspectiveId = tmpPerspectiveId.toStdString(); + + // is working fine as long as the perspective id is valid, if not the application crashes + GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); + + mitk::DataStorageEditorInput::Pointer editorInput; + editorInput = new mitk::DataStorageEditorInput(); + GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); + } + else + { + MITK_INFO << "Unkown mitk action keyword (see documentation for mitk links)" ; + } + } + // if the scheme is set to http, by default no action is performed, if an external webpage needs to be + // shown it should be implemented below + else if (scheme.contains(QString("http")) ) + { + QDesktopServices::openUrl(showMeNext); +// m_view->load( ) ; + } + else if(scheme.contains("qrc")) + { + m_view->load(showMeNext); + } + +} + +#endif + +void QmitkDiffusionImagingAppIntroPart::StandbyStateChanged(bool standby) +{ + +} + + +void QmitkDiffusionImagingAppIntroPart::SetFocus() +{ + +} diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkNavigationButtonsViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomePerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomeScreenViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomeScreenViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomeScreenViewControls.ui rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkWelcomeScreenViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt b/Plugins/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.dtiatlasapp/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/MitkDTIAtlasAppQtHelpCollectionProject.qhcp b/Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/MitkDTIAtlasAppQtHelpCollectionProject.qhcp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/MitkDTIAtlasAppQtHelpCollectionProject.qhcp rename to Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/MitkDTIAtlasAppQtHelpCollectionProject.qhcp diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/UserManual/QmitkDTIAtlasAppUserManual.dox b/Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/UserManual/QmitkDTIAtlasAppUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/UserManual/QmitkDTIAtlasAppUserManual.dox rename to Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/UserManual/QmitkDTIAtlasAppUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/about-logo.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/about-logo.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/about-logo.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/about-logo.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/assistant-icon.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/assistant-icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/documentation/assistant-icon.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/assistant-icon.png diff --git a/Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..3f32bf2c1e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.dtiatlasapp/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_dtiatlasapp org.mitk.dtiatlasapp + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_dtiatlasapp_internal Internal + \ingroup org_mitk_dtiatlasapp + + \brief This subcategory includes the internal classes of the org.mitk.dtiatlasapp plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/files.cmake b/Plugins/org.mitk.gui.qt.dtiatlasapp/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/files.cmake rename to Plugins/org.mitk.gui.qt.dtiatlasapp/files.cmake diff --git a/Plugins/org.mitk.gui.qt.dtiatlasapp/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.dtiatlasapp/manifest_headers.cmake new file mode 100644 index 0000000000..b0f46dfd20 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.dtiatlasapp/manifest_headers.cmake @@ -0,0 +1,8 @@ +set(Plugin-Name "DTI Atlas") +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.ext org.mitk.gui.qt.stdmultiwidgeteditor) +set(Plugin-Activator QmitkDTIAtlasAppApplicationPlugin) + + diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/plugin.xml b/Plugins/org.mitk.gui.qt.dtiatlasapp/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/plugin.xml rename to Plugins/org.mitk.gui.qt.dtiatlasapp/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/ImageProcessing_48.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/ImageProcessing_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/ImageProcessing_48.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/ImageProcessing_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/Measurement_48.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/Measurement_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/Measurement_48.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/Measurement_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/RigidRegistration.xpm b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/RigidRegistration.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/RigidRegistration.xpm rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/RigidRegistration.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/app-icon.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/app-icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/app-icon.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/app-icon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/diffusionimaging.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/diffusionimaging.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/diffusionimaging.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/diffusionimaging.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/icon_dicom.xpm b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/icon_dicom.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/icon_dicom.xpm rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/icon_dicom.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/icon_vesseltreesegmentation.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/icon_vesseltreesegmentation.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/icon_vesseltreesegmentation.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/icon_vesseltreesegmentation.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/mintLogo.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/mintLogo.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/mintLogo.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/mintLogo.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/org_mitk_gui_qt_dtiatlasapp.qrc b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/org_mitk_gui_qt_dtiatlasapp.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/org_mitk_gui_qt_dtiatlasapp.qrc rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/org_mitk_gui_qt_dtiatlasapp.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/segmentation.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/segmentation.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/segmentation.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/segmentation.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/volvis.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/volvis.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/volvis.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/volvis.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/QmitkWelcomeScreenView.qrc b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/QmitkWelcomeScreenView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/QmitkWelcomeScreenView.qrc rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/QmitkWelcomeScreenView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/function.js b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/function.js similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/function.js rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/function.js diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/mitkdtiatlasappwelcomeview.html b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/mitkdtiatlasappwelcomeview.html similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/mitkdtiatlasappwelcomeview.html rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/mitkdtiatlasappwelcomeview.html diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01CING.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01CING.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01CING.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01CING.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01aCING.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01aCING.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01aCING.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/01aCING.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02CORPUS.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02CORPUS.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02CORPUS.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02CORPUS.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02aCORPUS.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02aCORPUS.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02aCORPUS.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/02aCORPUS.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03CST.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03CST.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03CST.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03CST.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03aCST.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03aCST.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03aCST.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/03aCST.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04FORNIX.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04FORNIX.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04FORNIX.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04FORNIX.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04aFORNIX.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04aFORNIX.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04aFORNIX.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/04aFORNIX.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05ILF+IFO+UNCUS.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05ILF+IFO+UNCUS.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05ILF+IFO+UNCUS.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05ILF+IFO+UNCUS.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05aILF+IFO+UNCUS.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05aILF+IFO+UNCUS.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05aILF+IFO+UNCUS.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/05aILF+IFO+UNCUS.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06SLF+SOFF+ARCUATE.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06SLF+SOFF+ARCUATE.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06SLF+SOFF+ARCUATE.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06SLF+SOFF+ARCUATE.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06aSLF+SOFF+ARCUATE.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06aSLF+SOFF+ARCUATE.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06aSLF+SOFF+ARCUATE.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/06aSLF+SOFF+ARCUATE.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07PEDUNCLES.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07PEDUNCLES.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07PEDUNCLES.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07PEDUNCLES.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07aPEDUNCLES.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07aPEDUNCLES.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07aPEDUNCLES.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/07aPEDUNCLES.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aaref_alltracts.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aaref_alltracts.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aaref_alltracts.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aaref_alltracts.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aref_alltracts.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aref_alltracts.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aref_alltracts.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0aref_alltracts.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.gif b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.gif rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.gif diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0bref_colormap.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.gif b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.gif rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.gif diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/0cref_t1.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/background.jpg b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/background.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/background.jpg rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/background.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitk.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitk.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitk.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitk.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitka.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitka.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitka.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/button_mitka.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti.jpg b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti.jpg rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti_animated.gif b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti_animated.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti_animated.gif rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/dti_animated.gif diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/experimental.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/experimental.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/experimental.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/experimental.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_bottom.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_bottom.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_bottom.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_bottom.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_middle.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_middle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_middle.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_middle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_top.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_top.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_top.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bg_top.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bttn_close.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bttn_close.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bttn_close.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/popup_bttn_close.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/shadow.png b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/shadow.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/shadow.png rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/pics/shadow.png diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/style.css b/Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/style.css similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/resources/welcome/style.css rename to Plugins/org.mitk.gui.qt.dtiatlasapp/resources/welcome/style.css diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.cpp b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.cpp rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.h b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.h rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppApplication.h diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.cpp rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.h b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.h rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/QmitkDTIAtlasAppWorkbenchAdvisor.h diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplication.h~bug-8511-DTI-atlas-app b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplication.h~bug-8511-DTI-atlas-app similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplication.h~bug-8511-DTI-atlas-app rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplication.h~bug-8511-DTI-atlas-app diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.cpp b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.cpp rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.h b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.h rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppApplicationPlugin.h diff --git a/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.cpp b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.cpp new file mode 100644 index 0000000000..512e8ef5d7 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.cpp @@ -0,0 +1,294 @@ +/*========================================================================= + + Program: BlueBerry Platform + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkDTIAtlasAppIntroPart.h" + +#include "mitkNodePredicateDataType.h" +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#ifdef QT_WEBKIT +#include +#include +#endif +#include +#include +#include +#include +#include +#include + +#include "QmitkStdMultiWidget.h" +#include "QmitkStdMultiWidgetEditor.h" +#include "QmitkDTIAtlasAppApplicationPlugin.h" +#include "mitkDataStorageEditorInput.h" + +#include "mitkBaseDataIOFactory.h" +#include "mitkSceneIO.h" +#include "mitkProgressBar.h" +#include "mitkDataNodeFactory.h" +#include "mitkNodePredicateNot.h" +#include "mitkNodePredicateProperty.h" + +QmitkDTIAtlasAppIntroPart::QmitkDTIAtlasAppIntroPart() + : m_Controls(NULL) +{ + berry::IPreferences::Pointer workbenchPrefs = QmitkDTIAtlasAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); + workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); + workbenchPrefs->Flush(); +} + +QmitkDTIAtlasAppIntroPart::~QmitkDTIAtlasAppIntroPart() +{ + // if the workbench is not closing (that means, welcome screen was closed explicitly), set "Show_intro" false + if (!this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) + { + berry::IPreferences::Pointer workbenchPrefs = QmitkDTIAtlasAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); + workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false); + workbenchPrefs->Flush(); + } + else + { + berry::IPreferences::Pointer workbenchPrefs = QmitkDTIAtlasAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences(); + workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true); + workbenchPrefs->Flush(); + } + + // if workbench is not closing (Just welcome screen closing), open last used perspective + if (this->GetIntroSite()->GetPage()->GetPerspective()->GetId() + == "org.mitk.dtiatlasapp.perspectives.welcome" && !this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing()) + { + berry::IPerspectiveDescriptor::Pointer perspective = this->GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->GetPerspectiveRegistry()->FindPerspectiveWithId("org.mitk.dtiatlasapp.perspectives.dtiatlasapp"); + if (perspective) + { + this->GetIntroSite()->GetPage()->SetPerspective(perspective); + } + } + +} + + +void QmitkDTIAtlasAppIntroPart::CreateQtPartControl(QWidget* parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkWelcomeScreenViewControls; + m_Controls->setupUi(parent); +#ifdef QT_WEBKIT + + // create a QWebView as well as a QWebPage and QWebFrame within the QWebview + m_view = new QWebView(parent); + m_view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); + + QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/mitkdtiatlasappwelcomeview.html"), QUrl::TolerantMode ); + m_view->load( urlQtResource ); + + // adds the webview as a widget + parent->layout()->addWidget(m_view); + this->CreateConnections(); +#else + parent->layout()->addWidget(new QLabel("

Please install Qt with the WebKit option to see cool pictures!

")); +#endif + } +} + +#ifdef QT_WEBKIT +void QmitkDTIAtlasAppIntroPart::CreateConnections() +{ + if ( m_Controls ) + { + connect( (QObject*)(m_view->page()), SIGNAL(linkClicked(const QUrl& )), this, SLOT(DelegateMeTo(const QUrl& )) ); + } +} + + +void QmitkDTIAtlasAppIntroPart::DelegateMeTo(const QUrl& showMeNext) +{ + QString scheme = showMeNext.scheme(); + QByteArray urlHostname = showMeNext.encodedHost(); + QByteArray urlPath = showMeNext.encodedPath(); + QByteArray dataset = showMeNext.encodedQueryItemValue("dataset"); + QByteArray clear = showMeNext.encodedQueryItemValue("clear"); + + if (scheme.isEmpty()) MITK_INFO << " empty scheme of the to be delegated link" ; + + // if the scheme is set to mitk, it is to be tested which action should be applied + if (scheme.contains(QString("mitk")) ) + { + if(urlPath.isEmpty() ) MITK_INFO << " mitk path is empty " ; + + // searching for the perspective keyword within the host name + if(urlHostname.contains(QByteArray("perspectives")) ) + { + // the simplified method removes every whitespace + // ( whitespace means any character for which the standard C++ isspace() method returns true) + urlPath = urlPath.simplified(); + QString tmpPerspectiveId(urlPath.data()); + tmpPerspectiveId.replace(QString("/"), QString("") ); + std::string perspectiveId = tmpPerspectiveId.toStdString(); + + // is working fine as long as the perspective id is valid, if not the application crashes + GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); + + mitk::DataStorageEditorInput::Pointer editorInput; + editorInput = new mitk::DataStorageEditorInput(); + berry::IEditorPart::Pointer editor = GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); + + + QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; + mitk::DataStorage::Pointer dataStorage; + + if (editor.Cast().IsNull()) + { + editorInput = new mitk::DataStorageEditorInput(); + dataStorage = editorInput->GetDataStorageReference()->GetDataStorage(); + } + else + { + multiWidgetEditor = editor.Cast(); + multiWidgetEditor->GetStdMultiWidget()->RequestUpdate(); + dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage(); + } + + bool dsmodified = false; + + QString *fileName = new QString(dataset.data()); + + if ( fileName->right(5) == ".mitk" ) + { + mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); + + bool clearDataStorageFirst(false); + QString *sClear = new QString(clear.data()); + if ( sClear->right(4) == "true" ) + { + clearDataStorageFirst = true; + } + + mitk::ProgressBar::GetInstance()->AddStepsToDo(2); + dataStorage = sceneIO->LoadScene( fileName->toLocal8Bit().constData(), dataStorage, clearDataStorageFirst ); + dsmodified = true; + mitk::ProgressBar::GetInstance()->Progress(2); + } + else + { + mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); + try + { + nodeReader->SetFileName(fileName->toLocal8Bit().data()); + nodeReader->Update(); + for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i ) + { + mitk::DataNode::Pointer node; + node = nodeReader->GetOutput(i); + if ( node->GetData() != NULL ) + { + dataStorage->Add(node); + dsmodified = true; + } + } + } + catch(...) + { + MITK_INFO << "Could not open file!"; + } + } + + + + if(dataStorage.IsNotNull() && dsmodified) + { + // 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 = dataStorage->GetSubset(pred); + + if(rs->Size() > 0) + { + // calculate bounding geometry of these nodes + mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs); + // initialize the views to the bounding geometry + mitk::RenderingManager::GetInstance()->InitializeViews(bounds); + } + } + + + + + + } + // searching for the load + if(urlHostname.contains(QByteArray("perspectives")) ) + { + // the simplified method removes every whitespace + // ( whitespace means any character for which the standard C++ isspace() method returns true) + urlPath = urlPath.simplified(); + QString tmpPerspectiveId(urlPath.data()); + tmpPerspectiveId.replace(QString("/"), QString("") ); + std::string perspectiveId = tmpPerspectiveId.toStdString(); + + // is working fine as long as the perspective id is valid, if not the application crashes + GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() ); + + mitk::DataStorageEditorInput::Pointer editorInput; + editorInput = new mitk::DataStorageEditorInput(); + GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID); + } + else + { + MITK_INFO << "Unkown mitk action keyword (see documentation for mitk links)" ; + } + } + // if the scheme is set to http, by default no action is performed, if an external webpage needs to be + // shown it should be implemented below + else if (scheme.contains(QString("http")) ) + { + QDesktopServices::openUrl(showMeNext); +// m_view->load( ) ; + } + else if(scheme.contains("qrc")) + { + m_view->load(showMeNext); + } + +} + +#endif + +void QmitkDTIAtlasAppIntroPart::StandbyStateChanged(bool standby) +{ + +} + + +void QmitkDTIAtlasAppIntroPart::SetFocus() +{ + +} diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.h b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.h rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppIntroPart.h diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.cpp b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.cpp rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.h b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.h rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkDTIAtlasAppPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.cpp b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.cpp rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.h b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.h rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsViewControls.ui b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsViewControls.ui rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkNavigationButtonsViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.cpp b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.cpp rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.h b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.h rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomePerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomeScreenViewControls.ui b/Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomeScreenViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomeScreenViewControls.ui rename to Plugins/org.mitk.gui.qt.dtiatlasapp/src/internal/QmitkWelcomeScreenViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/CMakeLists.txt b/Plugins/org.mitk.gui.qt.examples/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.examples/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/ColorImageProcessing.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/ColorImageProcessing.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/ColorImageProcessing.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/ColorImageProcessing.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceGUI.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceGUI.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceGUI.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceGUI.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceIcon.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceIcon.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/IsoSurfaceIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/MITKExamples.dox b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/MITKExamples.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/MITKExamples.dox rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/MITKExamples.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkColourImageProcessing.dox b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkColourImageProcessing.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkColourImageProcessing.dox rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkColourImageProcessing.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkIsoSurfaceUserManual.dox b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkIsoSurfaceUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkIsoSurfaceUserManual.dox rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkIsoSurfaceUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkRegionGrowingUserManual.dox b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkRegionGrowingUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkRegionGrowingUserManual.dox rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkRegionGrowingUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleExampleUserManual.dox b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleExampleUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleExampleUserManual.dox rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleExampleUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleMeasurementUserManual.dox b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleMeasurementUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleMeasurementUserManual.dox rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/QmitkSimpleMeasurementUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/SimpleExample.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/SimpleExample.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/SimpleExample.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/SimpleExample.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementGUI.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementGUI.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementGUI.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementGUI.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementIcon.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementIcon.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/SimpleMeasurementIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/org_mitk_gui_qt_viewinitialization.dox b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/org_mitk_gui_qt_viewinitialization.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/org_mitk_gui_qt_viewinitialization.dox rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/org_mitk_gui_qt_viewinitialization.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.xpm b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.xpm rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/regiongrowing.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.png b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.png rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.xpm b/Plugins/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.xpm rename to Plugins/org.mitk.gui.qt.examples/documentation/Manual/viewInitializationIcon.xpm diff --git a/Plugins/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..ea1d4c1ab2 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.examples/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_examples org.mitk.gui.qt.examples + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_examples_internal Internal + \ingroup org_mitk_gui_qt_examples + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.examples plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/files.cmake b/Plugins/org.mitk.gui.qt.examples/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/files.cmake rename to Plugins/org.mitk.gui.qt.examples/files.cmake diff --git a/Plugins/org.mitk.gui.qt.examples/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.examples/manifest_headers.cmake new file mode 100644 index 0000000000..4c2e3fe85b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.examples/manifest_headers.cmake @@ -0,0 +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 diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/plugin.xml b/Plugins/org.mitk.gui.qt.examples/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/plugin.xml rename to Plugins/org.mitk.gui.qt.examples/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/ColorImageProcessing.png b/Plugins/org.mitk.gui.qt.examples/resources/ColorImageProcessing.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/ColorImageProcessing.png rename to Plugins/org.mitk.gui.qt.examples/resources/ColorImageProcessing.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/QmitkColourImageProcessingView.qrc b/Plugins/org.mitk.gui.qt.examples/resources/QmitkColourImageProcessingView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/QmitkColourImageProcessingView.qrc rename to Plugins/org.mitk.gui.qt.examples/resources/QmitkColourImageProcessingView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/QmitkSimpleExampleView.qrc b/Plugins/org.mitk.gui.qt.examples/resources/QmitkSimpleExampleView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/QmitkSimpleExampleView.qrc rename to Plugins/org.mitk.gui.qt.examples/resources/QmitkSimpleExampleView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/QmitkVolumetryView.qrc b/Plugins/org.mitk.gui.qt.examples/resources/QmitkVolumetryView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/QmitkVolumetryView.qrc rename to Plugins/org.mitk.gui.qt.examples/resources/QmitkVolumetryView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/SimpleExample.png b/Plugins/org.mitk.gui.qt.examples/resources/SimpleExample.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/SimpleExample.png rename to Plugins/org.mitk.gui.qt.examples/resources/SimpleExample.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/SimpleMeasurement.png b/Plugins/org.mitk.gui.qt.examples/resources/SimpleMeasurement.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/SimpleMeasurement.png rename to Plugins/org.mitk.gui.qt.examples/resources/SimpleMeasurement.png diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/isoSurface.xpm b/Plugins/org.mitk.gui.qt.examples/resources/isoSurface.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/isoSurface.xpm rename to Plugins/org.mitk.gui.qt.examples/resources/isoSurface.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/isosurface.qrc b/Plugins/org.mitk.gui.qt.examples/resources/isosurface.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/isosurface.qrc rename to Plugins/org.mitk.gui.qt.examples/resources/isosurface.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/viewInitializationIcon.xpm b/Plugins/org.mitk.gui.qt.examples/resources/viewInitializationIcon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/viewInitializationIcon.xpm rename to Plugins/org.mitk.gui.qt.examples/resources/viewInitializationIcon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/resources/volumetryIcon.xpm b/Plugins/org.mitk.gui.qt.examples/resources/volumetryIcon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/resources/volumetryIcon.xpm rename to Plugins/org.mitk.gui.qt.examples/resources/volumetryIcon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/ExamplesDll.h b/Plugins/org.mitk.gui.qt.examples/src/ExamplesDll.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/ExamplesDll.h rename to Plugins/org.mitk.gui.qt.examples/src/ExamplesDll.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h b/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui b/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui rename to Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/QmitkColourImageProcessingViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.h b/Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/colourimageprocessing/mitkColourImageProcessor.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.h b/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurface.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurfaceControls.ui b/Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurfaceControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurfaceControls.ui rename to Plugins/org.mitk.gui.qt.examples/src/internal/isosurface/QmitkIsoSurfaceControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.h b/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui b/Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui rename to Plugins/org.mitk.gui.qt.examples/src/internal/simpleexample/QmitkSimpleExampleViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.h b/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui b/Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui rename to Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurementControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.h b/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui b/Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui rename to Plugins/org.mitk.gui.qt.examples/src/internal/viewinitialization/QmitkViewInitializationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.cpp b/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.cpp rename to Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.h b/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.h rename to Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryViewControls.ui b/Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryViewControls.ui rename to Plugins/org.mitk.gui.qt.examples/src/internal/volumetry/QmitkVolumetryViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/CMakeLists.txt b/Plugins/org.mitk.gui.qt.examplesopencv/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.examplesopencv/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/UserManual/MITKExamplesOpenCV.dox b/Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/MITKExamplesOpenCV.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/UserManual/MITKExamplesOpenCV.dox rename to Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/MITKExamplesOpenCV.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/UserManual/VideoPlayerUserManual.dox b/Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/VideoPlayerUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/UserManual/VideoPlayerUserManual.dox rename to Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/VideoPlayerUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/UserManual/videoplayer.gif b/Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/videoplayer.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/documentation/UserManual/videoplayer.gif rename to Plugins/org.mitk.gui.qt.examplesopencv/documentation/UserManual/videoplayer.gif diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..b8bf31accf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.examplesopencv/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_examplesopencv org.mitk.gui.qt.examplesopencv + \ingroup MITKPlugins + + \brief This is the examplesopencv plugin. + +*/ + +/** + \defgroup org_mitk_gui_qt_examplesopencv_internal Internal + \ingroup org_mitk_gui_qt_examplesopencv + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.examplesopencv plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/files.cmake b/Plugins/org.mitk.gui.qt.examplesopencv/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/files.cmake rename to Plugins/org.mitk.gui.qt.examplesopencv/files.cmake diff --git a/Plugins/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake new file mode 100644 index 0000000000..d08127c1a3 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.examplesopencv/manifest_headers.cmake @@ -0,0 +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 diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/plugin.xml b/Plugins/org.mitk.gui.qt.examplesopencv/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/plugin.xml rename to Plugins/org.mitk.gui.qt.examplesopencv/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/resources/videoplayer.gif b/Plugins/org.mitk.gui.qt.examplesopencv/resources/videoplayer.gif similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/resources/videoplayer.gif rename to Plugins/org.mitk.gui.qt.examplesopencv/resources/videoplayer.gif diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.examplesopencv/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.cpp b/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.cpp rename to Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.h b/Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.h rename to Plugins/org.mitk.gui.qt.examplesopencv/src/internal/videoplayer/QmitkVideoPlayer.h diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/CMakeLists.txt b/Plugins/org.mitk.gui.qt.ext/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.ext/CMakeLists.txt diff --git a/Plugins/org.mitk.gui.qt.ext/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.ext/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..4c57b91e83 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_ext org.mitk.gui.qt.ext + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_ext_internal Internal + \ingroup org_mitk_gui_qt_ext + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.ext plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.ext/files.cmake b/Plugins/org.mitk.gui.qt.ext/files.cmake new file mode 100644 index 0000000000..4d0b3344c7 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/files.cmake @@ -0,0 +1,51 @@ +SET(SRC_CPP_FILES + QmitkExtActionBarAdvisor.cpp + QmitkExtWorkbenchWindowAdvisor.cpp + QmitkExtFileSaveProjectAction.cpp +) + +SET(INTERNAL_CPP_FILES + QmitkAppInstancesPreferencePage.cpp + QmitkCommonExtPlugin.cpp + QmitkInputDevicesPrefPage.cpp + QmitkModuleView.cpp +) + +SET(UI_FILES + src/internal/QmitkAppInstancesPreferencePage.ui +) + +SET(MOC_H_FILES + src/QmitkExtFileSaveProjectAction.h + src/QmitkExtWorkbenchWindowAdvisor.h + + src/internal/QmitkAppInstancesPreferencePage.h + src/internal/QmitkCommonExtPlugin.h + src/internal/QmitkExtWorkbenchWindowAdvisorHack.h + src/internal/QmitkInputDevicesPrefPage.h + src/internal/QmitkModuleView.h +) + +SET(CACHED_RESOURCE_FILES +# list of resource files which can be used by the plug-in +# system without loading the plug-ins shared library, +# for example the icon used in the menu and tabs for the +# plug-in views in the workbench + plugin.xml + resources/ModuleView.png +) + +SET(QRC_FILES +# uncomment the following line if you want to use Qt resources + resources/org_mitk_gui_qt_ext.qrc +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.ext/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.ext/manifest_headers.cmake new file mode 100644 index 0000000000..d1f170d72b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "Common Qt Ext Plugin") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.core.ext org.mitk.gui.qt.application) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/plugin.xml b/Plugins/org.mitk.gui.qt.ext/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/plugin.xml rename to Plugins/org.mitk.gui.qt.ext/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/DataManager.png b/Plugins/org.mitk.gui.qt.ext/resources/DataManager.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/DataManager.png rename to Plugins/org.mitk.gui.qt.ext/resources/DataManager.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/Load_48.png b/Plugins/org.mitk.gui.qt.ext/resources/Load_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/Load_48.png rename to Plugins/org.mitk.gui.qt.ext/resources/Load_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/ModuleView.png b/Plugins/org.mitk.gui.qt.ext/resources/ModuleView.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/ModuleView.png rename to Plugins/org.mitk.gui.qt.ext/resources/ModuleView.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/Redo_48.png b/Plugins/org.mitk.gui.qt.ext/resources/Redo_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/Redo_48.png rename to Plugins/org.mitk.gui.qt.ext/resources/Redo_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/Remove_48.png b/Plugins/org.mitk.gui.qt.ext/resources/Remove_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/Remove_48.png rename to Plugins/org.mitk.gui.qt.ext/resources/Remove_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/Save_48.png b/Plugins/org.mitk.gui.qt.ext/resources/Save_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/Save_48.png rename to Plugins/org.mitk.gui.qt.ext/resources/Save_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/Slider.png b/Plugins/org.mitk.gui.qt.ext/resources/Slider.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/Slider.png rename to Plugins/org.mitk.gui.qt.ext/resources/Slider.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/Slider_48.png b/Plugins/org.mitk.gui.qt.ext/resources/Slider_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/Slider_48.png rename to Plugins/org.mitk.gui.qt.ext/resources/Slider_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/Undo_48.png b/Plugins/org.mitk.gui.qt.ext/resources/Undo_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/Undo_48.png rename to Plugins/org.mitk.gui.qt.ext/resources/Undo_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/index.html b/Plugins/org.mitk.gui.qt.ext/resources/index.html similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/index.html rename to Plugins/org.mitk.gui.qt.ext/resources/index.html diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc b/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc rename to Plugins/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.cpp rename to Plugins/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h rename to Plugins/org.mitk.gui.qt.ext/src/QmitkExtActionBarAdvisor.h diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.cpp new file mode 100644 index 0000000000..f14f1ddb46 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.cpp @@ -0,0 +1,165 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-10-07 16:14:59 +0200 (Mi, 07 Okt 2009) $ +Version: $Revision: 19343 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkExtFileSaveProjectAction.h" + +#include "internal/QmitkCommonExtPlugin.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +QmitkExtFileSaveProjectAction::QmitkExtFileSaveProjectAction(berry::IWorkbenchWindow::Pointer window) +: QAction(0) +{ + m_Window = window; + this->setParent(static_cast(m_Window->GetShell()->GetControl())); + this->setText("&Save Project..."); + this->setToolTip("Save content of Data Manager as a .mitk project file"); + m_Window = window; + + this->connect(this, SIGNAL(triggered(bool)), this, SLOT(Run())); +} + +void QmitkExtFileSaveProjectAction::Run() +{ + try + { + /** + * @brief stores the last path of last saved file + */ + static QString m_LastPath; + + mitk::IDataStorageReference::Pointer dsRef; + + { + ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); + mitk::IDataStorageService* dss = 0; + ctkServiceReference dsServiceRef = context->getServiceReference(); + if (dsServiceRef) + { + dss = context->getService(dsServiceRef); + } + + if (!dss) + { + QString msg = "IDataStorageService service not available. Unable to open files."; + MITK_WARN << msg.toStdString(); + QMessageBox::warning(QApplication::activeWindow(), "Unable to open files", msg); + return; + } + + // Get the active data storage (or the default one, if none is active) + dsRef = dss->GetDataStorage(); + context->ungetService(dsServiceRef); + } + + mitk::DataStorage::Pointer storage = dsRef->GetDataStorage(); + + QString dialogTitle = "Save MITK Scene (%1)"; + QString fileName = QFileDialog::getSaveFileName(NULL, + dialogTitle.arg(dsRef->GetLabel()), + m_LastPath, + "MITK scene files (*.mitk)", + NULL ); + + if (fileName.isEmpty() ) + return; + + // remember the location + m_LastPath = fileName; + + if ( fileName.right(5) != ".mitk" ) + fileName += ".mitk"; + + mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); + + mitk::ProgressBar::GetInstance()->AddStepsToDo(2); + + /* Build list of nodes that should be saved */ + mitk::NodePredicateNot::Pointer isNotHelperObject = + mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true))); + mitk::DataStorage::SetOfObjects::ConstPointer nodesToBeSaved = storage->GetSubset(isNotHelperObject); + if ( !sceneIO->SaveScene( nodesToBeSaved, storage, fileName.toStdString() ) ) + { + QMessageBox::information(NULL, + "Scene saving", + "Scene could not be written completely. Please check the log.", + QMessageBox::Ok); + + } + mitk::ProgressBar::GetInstance()->Progress(2); + + mitk::SceneIO::FailedBaseDataListType::ConstPointer failedNodes = sceneIO->GetFailedNodes(); + if (!failedNodes->empty()) + { + std::stringstream ss; + ss << "The following nodes could not be serialized:" << std::endl; + for ( mitk::SceneIO::FailedBaseDataListType::const_iterator iter = failedNodes->begin(); + iter != failedNodes->end(); + ++iter ) + { + ss << " - "; + if ( mitk::BaseData* data =(*iter)->GetData() ) + { + ss << data->GetNameOfClass(); + } + else + { + ss << "(NULL)"; + } + + ss << " contained in node '" << (*iter)->GetName() << "'" << std::endl; + } + + MITK_WARN << ss.str(); + } + + mitk::PropertyList::ConstPointer failedProperties = sceneIO->GetFailedProperties(); + if (!failedProperties->GetMap()->empty()) + { + std::stringstream ss; + ss << "The following properties could not be serialized:" << std::endl; + const mitk::PropertyList::PropertyMap* propmap = failedProperties->GetMap(); + for ( mitk::PropertyList::PropertyMap::const_iterator iter = propmap->begin(); + iter != propmap->end(); + ++iter ) + { + ss << " - " << iter->second->GetNameOfClass() << " associated to key '" << iter->first << "'" << std::endl; + } + + MITK_WARN << ss.str(); + } + } + catch (std::exception& e) + { + MITK_ERROR << "Exception caught during scene saving: " << e.what(); + } +} diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h rename to Plugins/org.mitk.gui.qt.ext/src/QmitkExtFileSaveProjectAction.h diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp new file mode 100644 index 0000000000..5ba07d39aa --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp @@ -0,0 +1,1148 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkExtWorkbenchWindowAdvisor.h" +#include "QmitkExtActionBarAdvisor.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// UGLYYY +#include "internal/QmitkExtWorkbenchWindowAdvisorHack.h" +#include "internal/QmitkCommonExtPlugin.h" +#include "mitkUndoController.h" +#include "mitkVerboseLimitedLinearUndo.h" +#include +#include +#include +#include + +QmitkExtWorkbenchWindowAdvisorHack +* QmitkExtWorkbenchWindowAdvisorHack::undohack = +new QmitkExtWorkbenchWindowAdvisorHack(); + +QString QmitkExtWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME = "QtSettings.ini"; + +class PartListenerForTitle: public berry::IPartListener +{ +public: + + PartListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : + windowAdvisor(wa) + { + } + + Events::Types GetPartEventTypes() const + { + return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED + | Events::HIDDEN | Events::VISIBLE; + } + + void PartActivated(berry::IWorkbenchPartReference::Pointer ref) + { + if (ref.Cast ()) + { + windowAdvisor->UpdateTitle(false); + } + } + + void PartBroughtToTop(berry::IWorkbenchPartReference::Pointer ref) + { + if (ref.Cast ()) + { + windowAdvisor->UpdateTitle(false); + } + } + + void PartClosed(berry::IWorkbenchPartReference::Pointer /*ref*/) + { + windowAdvisor->UpdateTitle(false); + } + + void PartHidden(berry::IWorkbenchPartReference::Pointer ref) + { + if (!windowAdvisor->lastActiveEditor.Expired() && + ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) + { + windowAdvisor->UpdateTitle(true); + } + } + + void PartVisible(berry::IWorkbenchPartReference::Pointer ref) + { + if (!windowAdvisor->lastActiveEditor.Expired() && + ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) + { + windowAdvisor->UpdateTitle(false); + } + } + +private: + QmitkExtWorkbenchWindowAdvisor* windowAdvisor; + +}; + +class PartListenerForImageNavigator: public berry::IPartListener +{ +public: + + PartListenerForImageNavigator(QAction* act) : + imageNavigatorAction(act) + { + } + + Events::Types GetPartEventTypes() const + { + return Events::OPENED | Events::CLOSED | Events::HIDDEN | + Events::VISIBLE; + } + + void PartOpened(berry::IWorkbenchPartReference::Pointer ref) + { + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(true); + } + } + + void PartClosed(berry::IWorkbenchPartReference::Pointer ref) + { + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(false); + } + } + + void PartVisible(berry::IWorkbenchPartReference::Pointer ref) + { + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(true); + } + } + + void PartHidden(berry::IWorkbenchPartReference::Pointer ref) + { + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(false); + } + } + +private: + QAction* imageNavigatorAction; + +}; + +class PerspectiveListenerForTitle: public berry::IPerspectiveListener +{ +public: + + PerspectiveListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : + windowAdvisor(wa), perspectivesClosed(false) + { + } + + Events::Types GetPerspectiveEventTypes() const + { + return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED + // remove the following line when command framework is finished + | Events::CLOSED | Events::OPENED; + } + + void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + windowAdvisor->UpdateTitle(false); + } + + void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/, + berry::IPerspectiveDescriptor::Pointer /*newPerspective*/) + { + windowAdvisor->UpdateTitle(false); + } + + void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + windowAdvisor->UpdateTitle(false); + } + + void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + if (perspectivesClosed) + { + QListIterator i(windowAdvisor->viewActions); + while (i.hasNext()) + { + i.next()->setEnabled(true); + } + + windowAdvisor->fileSaveProjectAction->setEnabled(true); + windowAdvisor->closeProjectAction->setEnabled(true); + windowAdvisor->undoAction->setEnabled(true); + windowAdvisor->redoAction->setEnabled(true); + windowAdvisor->imageNavigatorAction->setEnabled(true); + windowAdvisor->resetPerspAction->setEnabled(true); + if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) + { + windowAdvisor->closePerspAction->setEnabled(true); + } + } + + perspectivesClosed = false; + } + + void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow(); + bool allClosed = true; + if (wnd->GetActivePage()) + { + std::vector perspectives(wnd->GetActivePage()->GetOpenPerspectives()); + allClosed = perspectives.empty(); + } + + if (allClosed) + { + perspectivesClosed = true; + + QListIterator i(windowAdvisor->viewActions); + while (i.hasNext()) + { + i.next()->setEnabled(false); + } + + windowAdvisor->fileSaveProjectAction->setEnabled(false); + windowAdvisor->closeProjectAction->setEnabled(false); + windowAdvisor->undoAction->setEnabled(false); + windowAdvisor->redoAction->setEnabled(false); + windowAdvisor->imageNavigatorAction->setEnabled(false); + windowAdvisor->resetPerspAction->setEnabled(false); + if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) + { + windowAdvisor->closePerspAction->setEnabled(false); + } + } + } + +private: + QmitkExtWorkbenchWindowAdvisor* windowAdvisor; + bool perspectivesClosed; +}; + +class PerspectiveListenerForMenu: public berry::IPerspectiveListener +{ +public: + + PerspectiveListenerForMenu(QmitkExtWorkbenchWindowAdvisor* wa) : + windowAdvisor(wa) + { + } + + Events::Types GetPerspectiveEventTypes() const + { + return Events::ACTIVATED | Events::DEACTIVATED; + } + + void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer perspective) + { + QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; + if (action) + { + action->setChecked(true); + } + } + + void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer perspective) + { + QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; + if (action) + { + action->setChecked(false); + } + } + +private: + QmitkExtWorkbenchWindowAdvisor* windowAdvisor; +}; + + + +QmitkExtWorkbenchWindowAdvisor::QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, + berry::IWorkbenchWindowConfigurer::Pointer configurer) : +berry::WorkbenchWindowAdvisor(configurer), +lastInput(0), +wbAdvisor(wbAdvisor), +showViewToolbar(true), +showPerspectiveToolbar(false), +showVersionInfo(true), +showMitkVersionInfo(true), +showViewMenuItem(true), +showNewWindowMenuItem(true), +showClosePerspectiveMenuItem(true), +dropTargetListener(new QmitkDefaultDropTargetListener) +{ + productName = berry::Platform::GetConfiguration().getString("application.baseName"); +} + +berry::ActionBarAdvisor::Pointer QmitkExtWorkbenchWindowAdvisor::CreateActionBarAdvisor( + berry::IActionBarConfigurer::Pointer configurer) +{ + berry::ActionBarAdvisor::Pointer actionBarAdvisor( + new QmitkExtActionBarAdvisor(configurer)); + return actionBarAdvisor; +} + +void* QmitkExtWorkbenchWindowAdvisor::CreateEmptyWindowContents(void* parent) +{ + QWidget* parentWidget = static_cast(parent); + QLabel* label = new QLabel(parentWidget); + label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu."); + label->setContentsMargins(10,10,10,10); + label->setAlignment(Qt::AlignTop); + label->setEnabled(false); + parentWidget->layout()->addWidget(label); + return label; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowClosePerspectiveMenuItem(bool show) +{ + showClosePerspectiveMenuItem = show; +} + +bool QmitkExtWorkbenchWindowAdvisor::GetShowClosePerspectiveMenuItem() +{ + return showClosePerspectiveMenuItem; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowNewWindowMenuItem(bool show) +{ + showNewWindowMenuItem = show; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowViewToolbar(bool show) +{ + showViewToolbar = show; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowViewMenuItem(bool show) +{ + showViewMenuItem = show; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowPerspectiveToolbar(bool show) +{ + showPerspectiveToolbar = show; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowVersionInfo(bool show) +{ + showVersionInfo = show; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowMitkVersionInfo(bool show) +{ + showMitkVersionInfo = show; +} + +void QmitkExtWorkbenchWindowAdvisor::SetProductName(const std::string& product) +{ + productName = product; +} + +void QmitkExtWorkbenchWindowAdvisor::SetWindowIcon(const std::string& wndIcon) +{ + windowIcon = wndIcon; +} + +void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() +{ + // very bad hack... + berry::IWorkbenchWindow::Pointer window = + this->GetWindowConfigurer()->GetWindow(); + QMainWindow* mainWindow = + static_cast (window->GetShell()->GetControl()); + + if (!windowIcon.empty()) + { + mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon))); + } + mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); + + /*mainWindow->setStyleSheet("color: white;" + "background-color: #808080;" + "selection-color: #659EC7;" + "selection-background-color: #808080;" + " QMenuBar {" + "background-color: #808080; }");*/ + + // ==== Application menu ============================ + QMenuBar* menuBar = mainWindow->menuBar(); + menuBar->setContextMenuPolicy(Qt::PreventContextMenu); + + QMenu* fileMenu = menuBar->addMenu("&File"); + fileMenu->setObjectName("FileMenu"); + + QAction* fileOpenAction = new QmitkFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window); + fileMenu->addAction(fileOpenAction); + fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); + fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png")); + fileMenu->addAction(fileSaveProjectAction); + closeProjectAction = new QmitkCloseProjectAction(window); + closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png")); + fileMenu->addAction(closeProjectAction); + fileMenu->addSeparator(); + QAction* fileExitAction = new QmitkFileExitAction(window); + fileExitAction->setObjectName("QmitkFileExitAction"); + fileMenu->addAction(fileExitAction); + + berry::IViewRegistry* viewRegistry = + berry::PlatformUI::GetWorkbench()->GetViewRegistry(); + const std::vector& viewDescriptors = + viewRegistry->GetViews(); + + // another bad hack to get an edit/undo menu... + QMenu* editMenu = menuBar->addMenu("&Edit"); + undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"), + "&Undo", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), + QKeySequence("CTRL+Z")); + undoAction->setToolTip("Undo the last action (not supported by all modules)"); + redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png") + , "&Redo", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), + QKeySequence("CTRL+Y")); + redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); + + imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL); + bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); + if (imageNavigatorViewFound) + { + QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); + imageNavigatorAction->setCheckable(true); + + // add part listener for image navigator + imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction); + window->GetPartService()->AddPartListener(imageNavigatorPartListener); + berry::IViewPart::Pointer imageNavigatorView = + window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); + imageNavigatorAction->setChecked(false); + if (imageNavigatorView) + { + bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); + if (isImageNavigatorVisible) + imageNavigatorAction->setChecked(true); + } + imageNavigatorAction->setToolTip("Open image navigator for navigating through image"); + } + + // toolbar for showing file open, undo, redo and other main actions + QToolBar* mainActionsToolBar = new QToolBar; + mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); +#ifdef __APPLE__ + mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); +#else + mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); +#endif + + mainActionsToolBar->addAction(fileOpenAction); + mainActionsToolBar->addAction(fileSaveProjectAction); + mainActionsToolBar->addAction(closeProjectAction); + mainActionsToolBar->addAction(undoAction); + mainActionsToolBar->addAction(redoAction); + if (imageNavigatorViewFound) + { + mainActionsToolBar->addAction(imageNavigatorAction); + } + mainWindow->addToolBar(mainActionsToolBar); + +#ifdef __APPLE__ + mainWindow->setUnifiedTitleAndToolBarOnMac(true); +#endif + + // ==== Window Menu ========================== + QMenu* windowMenu = menuBar->addMenu("Window"); + if (showNewWindowMenuItem) + { + windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); + windowMenu->addSeparator(); + } + + QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); + + QMenu* viewMenu; + if (showViewMenuItem) + { + viewMenu = windowMenu->addMenu("Show &View"); + viewMenu->setObjectName("Show View"); + } + windowMenu->addSeparator(); + resetPerspAction = windowMenu->addAction("&Reset Perspective", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); + + if(showClosePerspectiveMenuItem) + closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); + + windowMenu->addSeparator(); + windowMenu->addAction("&Preferences...", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), + QKeySequence("CTRL+P")); + + // fill perspective menu + berry::IPerspectiveRegistry* perspRegistry = + window->GetWorkbench()->GetPerspectiveRegistry(); + QActionGroup* perspGroup = new QActionGroup(menuBar); + + std::vector perspectives( + perspRegistry->GetPerspectives()); + + bool skip = false; + for (std::vector::iterator perspIt = + perspectives.begin(); perspIt != perspectives.end(); ++perspIt) + { + + // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which + // should not appear as an menu-entry in the perspective menu + if (perspectiveExcludeList.size() > 0) + { + for (unsigned int i=0; iGetId()) + { + skip = true; + break; + } + } + if (skip) + { + skip = false; + continue; + } + } + + QAction* perspAction = new berry::QtOpenPerspectiveAction(window, + *perspIt, perspGroup); + mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction)); + } + perspMenu->addActions(perspGroup->actions()); + + // sort elements (converting vector to map...) + std::vector::const_iterator iter; + std::map VDMap; + + skip = false; + for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) + { + + // if viewExcludeList is set, it contains the id-strings of view, which + // should not appear as an menu-entry in the menu + if (viewExcludeList.size() > 0) + { + for (unsigned int i=0; iGetId()) + { + skip = true; + break; + } + } + if (skip) + { + skip = false; + continue; + } + } + + if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") + continue; + if ((*iter)->GetId() == "org.mitk.views.imagenavigator") + continue; + + std::pair p( + (*iter)->GetLabel(), (*iter)); + VDMap.insert(p); + } + // ================================================== + + // ==== Perspective Toolbar ================================== + QToolBar* qPerspectiveToolbar = new QToolBar; + + if (showPerspectiveToolbar) + { + qPerspectiveToolbar->addActions(perspGroup->actions()); + mainWindow->addToolBar(qPerspectiveToolbar); + } + else + delete qPerspectiveToolbar; + + // ==== View Toolbar ================================== + QToolBar* qToolbar = new QToolBar; + + std::map::const_iterator + MapIter; + for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) + { + berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, + (*MapIter).second); + viewActions.push_back(viewAction); + if(showViewMenuItem) + viewMenu->addAction(viewAction); + if (showViewToolbar) + { + qToolbar->addAction(viewAction); + } + } + + if (showViewToolbar) + { + mainWindow->addToolBar(qToolbar); + } + else + delete qToolbar; + + QSettings settings(GetQSettingsFile(), QSettings::IniFormat); + mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); + + + // ==================================================== + + // ===== Help menu ==================================== + QMenu* helpMenu = menuBar->addMenu("Help"); + helpMenu->addAction("&Welcome",this, SLOT(onIntro())); + helpMenu->addAction("&Contents", this, SLOT(onHelpContents())); + helpMenu->addAction("Context &Help",this, SLOT(onHelp()), QKeySequence("F1")); + helpMenu->addAction("&About",this, SLOT(onAbout())); + // ===================================================== + + + QStatusBar* qStatusBar = new QStatusBar(); + + //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar + QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); + //disabling the SizeGrip in the lower right corner + statusBar->SetSizeGripEnabled(false); + + + + QmitkProgressBar *progBar = new QmitkProgressBar(); + + qStatusBar->addPermanentWidget(progBar, 0); + progBar->hide(); +// progBar->AddStepsToDo(2); +// progBar->Progress(1); + + mainWindow->setStatusBar(qStatusBar); + + QmitkMemoryUsageIndicatorView* memoryIndicator = + new QmitkMemoryUsageIndicatorView(); + qStatusBar->addPermanentWidget(memoryIndicator, 0); +} + +void QmitkExtWorkbenchWindowAdvisor::PreWindowOpen() +{ + berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); + + // show the shortcut bar and progress indicator, which are hidden by + // default + //configurer->SetShowPerspectiveBar(true); + //configurer->SetShowFastViewBars(true); + //configurer->SetShowProgressIndicator(true); + + // // add the drag and drop support for the editor area + // configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); + // configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); + // configurer.addEditorAreaTransfer(FileTransfer.getInstance()); + // configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); + // configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( + // configurer.getWindow())); + + this->HookTitleUpdateListeners(configurer); + + menuPerspectiveListener = new PerspectiveListenerForMenu(this); + configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener); + + configurer->AddEditorAreaTransfer(QStringList("text/uri-list")); + configurer->ConfigureEditorAreaDropListener(dropTargetListener); +} + +void QmitkExtWorkbenchWindowAdvisor::onIntro() +{ + QmitkExtWorkbenchWindowAdvisorHack::undohack->onIntro(); +} + +void QmitkExtWorkbenchWindowAdvisor::onHelp() +{ + QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelp(); +} + +void QmitkExtWorkbenchWindowAdvisor::onHelpContents() +{ + QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelpContents(); +} + +void QmitkExtWorkbenchWindowAdvisor::onAbout() +{ + QmitkExtWorkbenchWindowAdvisorHack::undohack->onAbout(); +} + +//-------------------------------------------------------------------------------- +// Ugly hack from here on. Feel free to delete when command framework +// and undo buttons are done. +//-------------------------------------------------------------------------------- + +QmitkExtWorkbenchWindowAdvisorHack::QmitkExtWorkbenchWindowAdvisorHack() : QObject() +{ + +} + +QmitkExtWorkbenchWindowAdvisorHack::~QmitkExtWorkbenchWindowAdvisorHack() +{ + +} + +void QmitkExtWorkbenchWindowAdvisorHack::onUndo() +{ + mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); + if (model) + { + if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) + { + mitk::VerboseLimitedLinearUndo::StackDescription descriptions = + verboseundo->GetUndoDescriptions(); + if (descriptions.size() >= 1) + { + MITK_INFO << "Undo " << descriptions.front().second; + } + } + model->Undo(); + } + else + { + MITK_ERROR << "No undo model instantiated"; + } +} + +void QmitkExtWorkbenchWindowAdvisorHack::onRedo() +{ + mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); + if (model) + { + if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) + { + mitk::VerboseLimitedLinearUndo::StackDescription descriptions = + verboseundo->GetRedoDescriptions(); + if (descriptions.size() >= 1) + { + MITK_INFO << "Redo " << descriptions.front().second; + } + } + model->Redo(); + } + else + { + MITK_ERROR << "No undo model instantiated"; + } +} + +void QmitkExtWorkbenchWindowAdvisorHack::onImageNavigator() +{ + // get ImageNavigatorView + berry::IViewPart::Pointer imageNavigatorView = + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); + if (imageNavigatorView) + { + bool isImageNavigatorVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(imageNavigatorView); + if (isImageNavigatorVisible) + { + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->HideView(imageNavigatorView); + return; + } + } + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagenavigator"); + //berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); +} + +void QmitkExtWorkbenchWindowAdvisorHack::onEditPreferences() +{ + QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow()); + _PreferencesDialog.exec(); +} + +void QmitkExtWorkbenchWindowAdvisorHack::onQuit() +{ + berry::PlatformUI::GetWorkbench()->Close(); +} + +void QmitkExtWorkbenchWindowAdvisorHack::onResetPerspective() +{ + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); +} + +void QmitkExtWorkbenchWindowAdvisorHack::onClosePerspective() +{ + berry::IWorkbenchPage::Pointer + page = + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); + page->ClosePerspective(page->GetPerspective(), true, true); +} + +void QmitkExtWorkbenchWindowAdvisorHack::onNewWindow() +{ + berry::PlatformUI::GetWorkbench()->OpenWorkbenchWindow(0); +} + +void QmitkExtWorkbenchWindowAdvisorHack::onIntro() +{ + bool hasIntro = + berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro(); + if (!hasIntro) + { + + QRegExp reg("(.*)(\\n)*"); + QRegExp reg2("(\\n)*(.*)"); + QFile file(":/org.mitk.gui.qt.ext/index.html"); + file.open(QIODevice::ReadOnly | QIODevice::Text); // Als Text-Datei nur zum Lesen öffnen + + QString text = QString(file.readAll()); + + file.close(); + + QString title = text; + title.replace(reg, ""); + title.replace(reg2, ""); + + std::cout << title.toStdString() << std::endl; + + QMessageBox::information(NULL, title, + text, "Close"); + + } + else + { + berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false); + } +} + +void QmitkExtWorkbenchWindowAdvisorHack::onHelp() +{ + ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); + if (context == 0) + { + MITK_WARN << "Plugin context not set, unable to open context help"; + return; + } + + // Check if the org.blueberry.ui.qt.help plug-in is installed and started + QList > plugins = context->getPlugins(); + foreach(QSharedPointer p, plugins) + { + if (p->getSymbolicName() == "org.blueberry.ui.qt.help") + { + if (p->getState() != ctkPlugin::ACTIVE) + { + // try to activate the plug-in explicitly + try + { + p->start(ctkPlugin::START_TRANSIENT); + } + catch (const ctkPluginException& pe) + { + MITK_ERROR << "Activating org.blueberry.ui.qt.help failed: " << pe.what(); + return; + } + } + } + } + + ctkServiceReference eventAdminRef = context->getServiceReference(); + ctkEventAdmin* eventAdmin = 0; + if (eventAdminRef) + { + eventAdmin = context->getService(eventAdminRef); + } + if (eventAdmin == 0) + { + MITK_WARN << "ctkEventAdmin service not found. Unable to open context help"; + } + else + { + ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); + eventAdmin->postEvent(ev); + } +} + +void QmitkExtWorkbenchWindowAdvisorHack::onHelpContents() +{ + berry::PlatformUI::GetWorkbench()->ShowPerspective("org.blueberry.perspectives.help", + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); +} + +void QmitkExtWorkbenchWindowAdvisorHack::onAbout() +{ + QmitkAboutDialog* aboutDialog = new QmitkAboutDialog(QApplication::activeWindow(),NULL); + aboutDialog->open(); +} + +void QmitkExtWorkbenchWindowAdvisor::HookTitleUpdateListeners( + berry::IWorkbenchWindowConfigurer::Pointer configurer) +{ + // hook up the listeners to update the window title + titlePartListener = new PartListenerForTitle(this); + titlePerspectiveListener = new PerspectiveListenerForTitle(this); + editorPropertyListener = new berry::PropertyChangeIntAdapter< + QmitkExtWorkbenchWindowAdvisor>(this, + &QmitkExtWorkbenchWindowAdvisor::PropertyChange); + + // configurer.getWindow().addPageListener(new IPageListener() { + // public void pageActivated(IWorkbenchPage page) { + // updateTitle(false); + // } + // + // public void pageClosed(IWorkbenchPage page) { + // updateTitle(false); + // } + // + // public void pageOpened(IWorkbenchPage page) { + // // do nothing + // } + // }); + + configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener); + configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener); +} + +std::string QmitkExtWorkbenchWindowAdvisor::ComputeTitle() +{ + berry::IWorkbenchWindowConfigurer::Pointer configurer = + GetWindowConfigurer(); + berry::IWorkbenchPage::Pointer currentPage = + configurer->GetWindow()->GetActivePage(); + berry::IEditorPart::Pointer activeEditor; + if (currentPage) + { + activeEditor = lastActiveEditor.Lock(); + } + + std::string title; + //TODO Product + // IProduct product = Platform.getProduct(); + // if (product != null) { + // title = product.getName(); + // } + // instead of the product name, we use a custom variable for now + title = productName; + + if(showMitkVersionInfo) + { + title += std::string(" ") + MITK_VERSION_STRING; + } + + if (showVersionInfo) + { + // add version informatioin + QString versions = QString(" (ITK %1.%2.%3 VTK %4.%5.%6 Qt %7 MITK %8)") + .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH) + .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION) + .arg(QT_VERSION_STR) + .arg(MITK_VERSION_STRING); + + title += versions.toStdString(); + } + + if (currentPage) + { + if (activeEditor) + { + lastEditorTitle = activeEditor->GetTitleToolTip(); + if (!lastEditorTitle.empty()) + title = lastEditorTitle + " - " + title; + } + berry::IPerspectiveDescriptor::Pointer persp = + currentPage->GetPerspective(); + std::string label = ""; + if (persp) + { + label = persp->GetLabel(); + } + berry::IAdaptable* input = currentPage->GetInput(); + if (input && input != wbAdvisor->GetDefaultPageInput()) + { + label = currentPage->GetLabel(); + } + if (!label.empty()) + { + title = label + " - " + title; + } + } + + title += " (Not for use in diagnosis or treatment of patients)"; + + return title; +} + +void QmitkExtWorkbenchWindowAdvisor::RecomputeTitle() +{ + berry::IWorkbenchWindowConfigurer::Pointer configurer = + GetWindowConfigurer(); + std::string oldTitle = configurer->GetTitle(); + std::string newTitle = ComputeTitle(); + if (newTitle != oldTitle) + { + configurer->SetTitle(newTitle); + } +} + +void QmitkExtWorkbenchWindowAdvisor::UpdateTitle(bool editorHidden) +{ + berry::IWorkbenchWindowConfigurer::Pointer configurer = + GetWindowConfigurer(); + berry::IWorkbenchWindow::Pointer window = configurer->GetWindow(); + berry::IEditorPart::Pointer activeEditor; + berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage(); + berry::IPerspectiveDescriptor::Pointer persp; + berry::IAdaptable* input = 0; + + if (currentPage) + { + activeEditor = currentPage->GetActiveEditor(); + persp = currentPage->GetPerspective(); + input = currentPage->GetInput(); + } + + if (editorHidden) + { + activeEditor = 0; + } + + // Nothing to do if the editor hasn't changed + if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock() + && persp == lastPerspective.Lock() && input == lastInput) + { + return; + } + + if (!lastActiveEditor.Expired()) + { + lastActiveEditor.Lock()->RemovePropertyListener(editorPropertyListener); + } + + lastActiveEditor = activeEditor; + lastActivePage = currentPage; + lastPerspective = persp; + lastInput = input; + + if (activeEditor) + { + activeEditor->AddPropertyListener(editorPropertyListener); + } + + RecomputeTitle(); +} + +void QmitkExtWorkbenchWindowAdvisor::PropertyChange(berry::Object::Pointer /*source*/, int propId) +{ + if (propId == berry::IWorkbenchPartConstants::PROP_TITLE) + { + if (!lastActiveEditor.Expired()) + { + std::string newTitle = lastActiveEditor.Lock()->GetPartName(); + if (lastEditorTitle != newTitle) + { + RecomputeTitle(); + } + } + } +} + + +void QmitkExtWorkbenchWindowAdvisor::SetPerspectiveExcludeList(std::vector v) +{ + this->perspectiveExcludeList = v; +} + +std::vector QmitkExtWorkbenchWindowAdvisor::GetPerspectiveExcludeList() +{ + return this->perspectiveExcludeList; +} + +void QmitkExtWorkbenchWindowAdvisor::SetViewExcludeList(std::vector v) +{ + this->viewExcludeList = v; +} + +std::vector QmitkExtWorkbenchWindowAdvisor::GetViewExcludeList() +{ + return this->viewExcludeList; +} + +void QmitkExtWorkbenchWindowAdvisor::PostWindowClose() +{ + berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); + QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); + + QSettings settings(GetQSettingsFile(), QSettings::IniFormat); + settings.setValue("ToolbarPosition", mainWindow->saveState()); +} + +QString QmitkExtWorkbenchWindowAdvisor::GetQSettingsFile() const +{ + QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME); + return settingsInfo.canonicalFilePath(); +} diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h new file mode 100644 index 0000000000..49a0f6c775 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h @@ -0,0 +1,166 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKEXTWORKBENCHWINDOWADVISOR_H_ +#define QMITKEXTWORKBENCHWINDOWADVISOR_H_ + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +class QAction; +class QMenu; + +class MITK_QT_COMMON_EXT_EXPORT QmitkExtWorkbenchWindowAdvisor : public QObject, public berry::WorkbenchWindowAdvisor +{ + Q_OBJECT + +public: + + QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, + berry::IWorkbenchWindowConfigurer::Pointer configurer); + + berry::ActionBarAdvisor::Pointer CreateActionBarAdvisor( + berry::IActionBarConfigurer::Pointer configurer); + + void* CreateEmptyWindowContents(void* parent); + + void PostWindowCreate(); + + void PreWindowOpen(); + + void PostWindowClose(); + + void ShowViewToolbar(bool show); + + void ShowPerspectiveToolbar(bool show); + + void ShowVersionInfo(bool show); + + void ShowMitkVersionInfo(bool show); + + void ShowViewMenuItem(bool show); + + void ShowNewWindowMenuItem(bool show); + + void ShowClosePerspectiveMenuItem(bool show); + + bool GetShowClosePerspectiveMenuItem(); + + //TODO should be removed when product support is here + void SetProductName(const std::string& product); + void SetWindowIcon(const std::string& wndIcon); + + void SetPerspectiveExcludeList(std::vector v); + std::vector GetPerspectiveExcludeList(); + + void SetViewExcludeList(std::vector v); + std::vector GetViewExcludeList(); + +protected slots: + + virtual void onIntro(); + virtual void onHelp(); + virtual void onHelpContents(); + virtual void onAbout(); + +private: + + /** + * Hooks the listeners needed on the window + * + * @param configurer + */ + void HookTitleUpdateListeners(berry::IWorkbenchWindowConfigurer::Pointer configurer); + + std::string ComputeTitle(); + + void RecomputeTitle(); + + QString GetQSettingsFile() const; + + /** + * Updates the window title. Format will be: [pageInput -] + * [currentPerspective -] [editorInput -] [workspaceLocation -] productName + * @param editorHidden TODO + */ + void UpdateTitle(bool editorHidden); + + void PropertyChange(berry::Object::Pointer /*source*/, int propId); + + static QString QT_SETTINGS_FILENAME; + + berry::IPartListener::Pointer titlePartListener; + berry::IPerspectiveListener::Pointer titlePerspectiveListener; + berry::IPerspectiveListener::Pointer menuPerspectiveListener; + berry::IPartListener::Pointer imageNavigatorPartListener; + berry::IPropertyChangeListener::Pointer editorPropertyListener; + friend struct berry::PropertyChangeIntAdapter; + friend class PartListenerForTitle; + friend class PerspectiveListenerForTitle; + friend class PerspectiveListenerForMenu; + friend class PartListenerForImageNavigator; + + berry::IEditorPart::WeakPtr lastActiveEditor; + berry::IPerspectiveDescriptor::WeakPtr lastPerspective; + berry::IWorkbenchPage::WeakPtr lastActivePage; + std::string lastEditorTitle; + berry::IAdaptable* lastInput; + + berry::WorkbenchAdvisor* wbAdvisor; + bool showViewToolbar; + bool showPerspectiveToolbar; + bool showVersionInfo; + bool showMitkVersionInfo; + bool showViewMenuItem; + bool showNewWindowMenuItem; + bool showClosePerspectiveMenuItem; + std::string productName; + std::string windowIcon; + + // enables DnD on the editor area + berry::IDropTargetListener::Pointer dropTargetListener; + + // stringlist for excluding perspectives from the perspective menu entry (e.g. Welcome Perspective) + std::vector perspectiveExcludeList; + + // stringlist for excluding views from the menu entry + std::vector viewExcludeList; + + // maps perspective ids to QAction objects + std::map mapPerspIdToAction; + + // actions which will be enabled/disabled depending on the application state + QList viewActions; + QAction* fileSaveProjectAction; + QAction* closeProjectAction; + QAction* undoAction; + QAction* redoAction; + QAction* imageNavigatorAction; + QAction* resetPerspAction; + QAction* closePerspAction; +}; + +#endif /*QMITKEXTWORKBENCHWINDOWADVISOR_H_*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.cpp b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.cpp rename to Plugins/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.h rename to Plugins/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.h diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.ui b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.ui rename to Plugins/org.mitk.gui.qt.ext/src/internal/QmitkAppInstancesPreferencePage.ui diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp new file mode 100644 index 0000000000..1109246ed4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp @@ -0,0 +1,253 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkCommonExtPlugin.h" + +#include + +#include "QmitkAppInstancesPreferencePage.h" +#include "QmitkInputDevicesPrefPage.h" + +#include "QmitkModuleView.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +ctkPluginContext* QmitkCommonExtPlugin::_context = 0; + +void QmitkCommonExtPlugin::start(ctkPluginContext* context) +{ + this->_context = context; + + QmitkExtRegisterClasses(); + + BERRY_REGISTER_EXTENSION_CLASS(QmitkAppInstancesPreferencePage, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkInputDevicesPrefPage, context) + + BERRY_REGISTER_EXTENSION_CLASS(QmitkModuleView, context) + + if (qApp->metaObject()->indexOfSignal("messageReceived(QByteArray)") > -1) + { + connect(qApp, SIGNAL(messageReceived(QByteArray)), this, SLOT(handleIPCMessage(QByteArray))); + } + + std::vector args = berry::Platform::GetApplicationArgs(); + QStringList qargs; + for (std::vector::const_iterator it = args.begin(); it != args.end(); ++it) + { + qargs << QString::fromStdString(*it); + } + // This is a potentially long running operation. + loadDataFromDisk(qargs, true); +} + +void QmitkCommonExtPlugin::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) + + this->_context = 0; +} + +ctkPluginContext* QmitkCommonExtPlugin::getContext() +{ + return _context; +} + +void QmitkCommonExtPlugin::loadDataFromDisk(const QStringList &arguments, bool globalReinit) +{ + if (!arguments.empty()) + { + ctkServiceReference serviceRef = _context->getServiceReference(); + if (serviceRef) + { + mitk::IDataStorageService* dataStorageService = _context->getService(serviceRef); + mitk::DataStorage::Pointer dataStorage = dataStorageService->GetDefaultDataStorage()->GetDataStorage(); + + int argumentsAdded = 0; + for (int i = 0; i < arguments.size(); ++i) + { + if (arguments[i].right(5) == ".mitk") + { + mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); + + bool clearDataStorageFirst(false); + mitk::ProgressBar::GetInstance()->AddStepsToDo(2); + dataStorage = sceneIO->LoadScene( arguments[i].toLocal8Bit().constData(), dataStorage, clearDataStorageFirst ); + mitk::ProgressBar::GetInstance()->Progress(2); + argumentsAdded++; + } + else + { + mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); + try + { + nodeReader->SetFileName(arguments[i].toStdString()); + nodeReader->Update(); + for (unsigned int j = 0 ; j < nodeReader->GetNumberOfOutputs( ); ++j) + { + mitk::DataNode::Pointer node = nodeReader->GetOutput(j); + if (node->GetData() != 0) + { + dataStorage->Add(node); + argumentsAdded++; + } + } + } + catch(...) + { + MITK_WARN << "Failed to load command line argument: " << arguments[i].toStdString(); + } + } + } // end for each command line argument + + if (argumentsAdded > 0 && globalReinit) + { + // calculate bounding geometry + mitk::RenderingManager::GetInstance()->InitializeViews(dataStorage->ComputeBoundingGeometry3D()); + } + } + else + { + MITK_ERROR << "A service reference for mitk::IDataStorageService does not exist"; + } + } +} + +void QmitkCommonExtPlugin::startNewInstance(const QStringList &args, const QStringList& files) +{ + QStringList newArgs(args); +#ifdef Q_OS_UNIX + newArgs << QString("--") + QString::fromStdString(berry::Platform::ARG_NEWINSTANCE); +#else + newArgs << QString("/") + QString::fromStdString(berry::Platform::ARG_NEWINSTANCE); +#endif + newArgs << files; + QProcess::startDetached(qApp->applicationFilePath(), newArgs); +} + +void QmitkCommonExtPlugin::handleIPCMessage(const QByteArray& msg) +{ + QDataStream ds(msg); + QString msgType; + ds >> msgType; + + // we only handle messages containing command line arguments + if (msgType != "$cmdLineArgs") return; + + // activate the current workbench window + berry::IWorkbenchWindow::Pointer window = + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(); + + QMainWindow* mainWindow = + static_cast (window->GetShell()->GetControl()); + + mainWindow->setWindowState(mainWindow->windowState() & ~Qt::WindowMinimized); + mainWindow->raise(); + mainWindow->activateWindow(); + + // Get the preferences for the instantiation behavior + berry::IPreferencesService::Pointer prefService + = berry::Platform::GetServiceRegistry() + .GetServiceById(berry::IPreferencesService::ID); + berry::IPreferences::Pointer prefs = prefService->GetSystemPreferences()->Node("/General"); + bool newInstanceAlways = prefs->GetBool("newInstance.always", false); + bool newInstanceScene = prefs->GetBool("newInstance.scene", true); + + QStringList args; + ds >> args; + + QStringList fileArgs; + QStringList sceneArgs; + + Poco::Util::OptionSet os; + berry::Platform::GetOptionSet(os); + Poco::Util::OptionProcessor processor(os); +#if !defined(POCO_OS_FAMILY_UNIX) + processor.setUnixStyle(false); +#endif + args.pop_front(); + QStringList::Iterator it = args.begin(); + while (it != args.end()) + { + std::string name; + std::string value; + if (processor.process(it->toStdString(), name, value)) + { + ++it; + } + else + { + if (it->endsWith(".mitk")) + { + sceneArgs << *it; + } + else + { + fileArgs << *it; + } + it = args.erase(it); + } + } + + if (newInstanceAlways) + { + if (newInstanceScene) + { + startNewInstance(args, fileArgs); + + foreach(QString sceneFile, sceneArgs) + { + startNewInstance(args, QStringList(sceneFile)); + } + } + else + { + fileArgs.append(sceneArgs); + startNewInstance(args, fileArgs); + } + } + else + { + loadDataFromDisk(fileArgs, false); + if (newInstanceScene) + { + foreach(QString sceneFile, sceneArgs) + { + startNewInstance(args, QStringList(sceneFile)); + } + } + else + { + loadDataFromDisk(sceneArgs, false); + } + } + +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_ext, QmitkCommonExtPlugin) diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h new file mode 100644 index 0000000000..8e10046865 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h @@ -0,0 +1,51 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITKCOMMONEXTPLUGIN_H_ +#define QMITKCOMMONEXTPLUGIN_H_ + +#include + +class QmitkCommonExtPlugin : public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + + static ctkPluginContext* getContext(); + +private: + + void loadDataFromDisk(const QStringList& args, bool globalReinit); + void startNewInstance(const QStringList& args, const QStringList &files); + +private Q_SLOTS: + + void handleIPCMessage(const QByteArray &msg); + +private: + + static ctkPluginContext* _context; + +}; + +#endif /* QMITKCOMMONEXTPLUGIN_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h rename to Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.cpp b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.cpp new file mode 100644 index 0000000000..5c33dcd749 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.cpp @@ -0,0 +1,189 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ +Version: $Revision: 18019 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkInputDevicesPrefPage.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +QmitkInputDevicesPrefPage::QmitkInputDevicesPrefPage() +: m_MainControl(0) +{ + // gets the old setting of the preferences and loads them into the preference node + berry::IPreferencesService::Pointer prefService + = berry::Platform::GetServiceRegistry() + .GetServiceById(berry::IPreferencesService::ID); + this->m_InputDevicesPrefNode = prefService->GetSystemPreferences()->Node(mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES); +} + +void QmitkInputDevicesPrefPage::Init(berry::IWorkbench::Pointer ) +{ +} + +void QmitkInputDevicesPrefPage::CreateQtControl(QWidget* parent) +{ + m_MainControl = new QWidget(parent); + QVBoxLayout *layout = new QVBoxLayout; + + mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry = + berry::Platform::GetServiceRegistry().GetServiceById(mitk::CoreExtConstants::INPUTDEVICE_SERVICE); + std::vector temp(inputDeviceRegistry->GetInputDevices()); + + for(std::vector::const_iterator it = temp.begin(); it != temp.end();++it) + { + QString inputDeviceName(QString::fromStdString((*it)->GetName())); + QCheckBox* checkBox = new QCheckBox((inputDeviceName),m_MainControl); + layout->addWidget(checkBox); + m_InputDevices.insert(checkBox,(*it)->GetID()); + + if(inputDeviceName == "WiiMote") + { + m_WiiMoteModes = new QGroupBox("WiiMote Modus"); + + m_WiiMoteHeadTracking = new QRadioButton + (QString::fromStdString(mitk::CoreExtConstants::WIIMOTE_HEADTRACKING)); + m_WiiMoteSurfaceInteraction = new QRadioButton + (QString::fromStdString(mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION)); + m_WiiMoteHeadTracking->setChecked(true); + + QVBoxLayout* vBoxLayout = new QVBoxLayout; + + vBoxLayout->addWidget(m_WiiMoteHeadTracking); + vBoxLayout->addWidget(m_WiiMoteSurfaceInteraction); + + m_WiiMoteModes->setLayout(vBoxLayout); + + layout->addWidget(m_WiiMoteModes); + } + + } + + layout->addStretch(); + m_MainControl->setLayout(layout); + this->Update(); +} + +QWidget* QmitkInputDevicesPrefPage::GetQtControl() const +{ + return m_MainControl; +} + +bool QmitkInputDevicesPrefPage::PerformOk() +{ + bool result = true; + + mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry = + berry::Platform::GetServiceRegistry(). + GetServiceById(mitk::CoreExtConstants::INPUTDEVICE_SERVICE); + + QHashIterator it(m_InputDevices); + while (it.hasNext()) + { + it.next(); + mitk::IInputDeviceDescriptor::Pointer inputdevice(inputDeviceRegistry->Find(it.value())); + + if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) + { + QString headTracking(m_WiiMoteHeadTracking->text()); + QString surfaceInteraction(m_WiiMoteSurfaceInteraction->text()); + + this->m_InputDevicesPrefNode->PutBool + (headTracking.toStdString(),m_WiiMoteHeadTracking->isChecked()); + this->m_InputDevicesPrefNode->PutBool + (surfaceInteraction.toStdString(),m_WiiMoteSurfaceInteraction->isChecked()); + + // forced flush of the preferences is needed + // because otherwise the mitk::WiiMoteActivator class + // cannot distinguish the two different modes without + // changing the interface for all input devices + berry::IPreferencesService::Pointer prefService = + berry::Platform::GetServiceRegistry(). + GetServiceById(berry::IPreferencesService::ID); + + if (prefService) + { + prefService->GetSystemPreferences()->Flush(); + } + } + + if(it.key()->isChecked()) + { + result &= inputdevice->CreateInputDevice()->RegisterInputDevice(); + } + else + { + result &= inputdevice->CreateInputDevice()->UnRegisterInputDevice(); + + // temporary fix, unclean solution: + // e.g. user activates SpaceNavigator and leaves the + // the wiimote deactivated, the user will get the warning + // despite the fact that it has never been activated + if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) + { + // until now 2010-09-06 there were some unfixed problems + // with reconnecting the wiimote after disconnecting it. + // It was suggested that it might have something to do + // with the type of stack, that is used for the pairing. + // MS-Stack for example does not work properly. + QMessageBox::information(NULL,"WiiMote supportproblem", + "A reconnect of the WiiMote is not yet supported! " + "Please restart the application, if you want to " + "activate the Wii remote/s again."); + } + } + + if(result) + { + this->m_InputDevicesPrefNode->PutBool(it.value(),it.key()->isChecked()); + } + } + return result; +} + +void QmitkInputDevicesPrefPage::PerformCancel() +{ + +} + +void QmitkInputDevicesPrefPage::Update() +{ + QHashIterator it(m_InputDevices); + while (it.hasNext()) + { + it.next(); + it.key()->setChecked(this->m_InputDevicesPrefNode->GetBool(it.value(), false)); + if(it.value() == mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME) + { + m_WiiMoteHeadTracking->setChecked( + this->m_InputDevicesPrefNode->GetBool(mitk::CoreExtConstants::WIIMOTE_HEADTRACKING,false)); + m_WiiMoteSurfaceInteraction->setChecked + (this->m_InputDevicesPrefNode->GetBool(mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION,false)); + } + } +} diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.h new file mode 100644 index 0000000000..d645157014 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkInputDevicesPrefPage.h @@ -0,0 +1,89 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ +Version: $Revision: 16224 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITK_INPUTDEVICESPREFPAGE_H_ +#define QMITK_INPUTDEVICESPREFPAGE_H_ + +#include "berryIQtPreferencePage.h" +#include + +#include +#include +#include + +class QWidget; +class QCheckBox; + +class QmitkInputDevicesPrefPage : public QObject, public berry::IQtPreferencePage +{ + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) + +public: + + /** + * Default constructor + */ + QmitkInputDevicesPrefPage(); + + /** + * @see berry::IPreferencePage::Init(berry::IWorkbench::Pointer workbench) + */ + void Init(berry::IWorkbench::Pointer workbench); + + /** + * @see berry::IPreferencePage::CreateQtControl(void* parent) + */ + void CreateQtControl(QWidget* widget); + + /** + * @see berry::IPreferencePage::CreateQtControl() + */ + QWidget* GetQtControl() const; + + /** + * @see berry::IPreferencePage::PerformOk() + */ + virtual bool PerformOk(); + + /** + * @see berry::IPreferencePage::PerformCancel() + */ + virtual void PerformCancel(); + + /** + * @see berry::IPreferencePage::Update() + */ + virtual void Update(); + +protected: + + QWidget* m_MainControl; + + QHash m_InputDevices; + + // specific for Wiimote + QGroupBox* m_WiiMoteModes; + QRadioButton* m_WiiMoteHeadTracking; + QRadioButton* m_WiiMoteSurfaceInteraction; + + berry::IPreferences::Pointer m_InputDevicesPrefNode; + +}; + +#endif // QMITK_INPUTDEVICESPREFPAGE_H_ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.cpp b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.cpp rename to Plugins/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.h rename to Plugins/org.mitk.gui.qt.ext/src/internal/QmitkModuleView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/CMakeLists.txt b/Plugins/org.mitk.gui.qt.extapplication/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.extapplication/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.extapplication/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/UserManual/QmitkExtapplicationUserManual.dox b/Plugins/org.mitk.gui.qt.extapplication/documentation/UserManual/QmitkExtapplicationUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.extapplication/documentation/UserManual/QmitkExtapplicationUserManual.dox rename to Plugins/org.mitk.gui.qt.extapplication/documentation/UserManual/QmitkExtapplicationUserManual.dox diff --git a/Plugins/org.mitk.gui.qt.extapplication/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.extapplication/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..468fe60327 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_extapplication org.mitk.gui.qt.extapplication + \ingroup MITKPlugins + + \brief This plug-in is responsible for initializing the "ExtApp". + +*/ + +/** + \defgroup org_mitk_gui_qt_extapplication_internal Internal + \ingroup org_mitk_gui_qt_extapplication + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.extapplication plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.extapplication/files.cmake b/Plugins/org.mitk.gui.qt.extapplication/files.cmake new file mode 100644 index 0000000000..273481bf06 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/files.cmake @@ -0,0 +1,40 @@ +SET(SRC_CPP_FILES +) + +SET(INTERNAL_CPP_FILES + QmitkExtApplication.cpp + QmitkExtApplicationPlugin.cpp + QmitkExtAppWorkbenchAdvisor.cpp + QmitkExtDefaultPerspective.cpp +) + +SET(MOC_H_FILES + src/internal/QmitkExtApplication.h + src/internal/QmitkExtApplicationPlugin.h + src/internal/QmitkExtDefaultPerspective.h +) + +SET(CACHED_RESOURCE_FILES +# list of resource files which can be used by the plug-in +# system without loading the plug-ins shared library, +# for example the icon used in the menu and tabs for the +# plug-in views in the workbench + plugin.xml + resources/icon_research.xpm +) + +SET(QRC_FILES +# uncomment the following line if you want to use Qt resources +# resources/QmitkExtApplication.qrc +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) + diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.extapplication/manifest_headers.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.extapplication/manifest_headers.cmake rename to Plugins/org.mitk.gui.qt.extapplication/manifest_headers.cmake diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/plugin.xml b/Plugins/org.mitk.gui.qt.extapplication/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.extapplication/plugin.xml rename to Plugins/org.mitk.gui.qt.extapplication/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/resources/icon_research.xpm b/Plugins/org.mitk.gui.qt.extapplication/resources/icon_research.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.extapplication/resources/icon_research.xpm rename to Plugins/org.mitk.gui.qt.extapplication/resources/icon_research.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.extapplication/src/QmitkExtAppWorkbenchAdvisor.cpp rename to Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.cpp diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.h b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.h new file mode 100644 index 0000000000..6e470bbb54 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.h @@ -0,0 +1,45 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#ifndef QMITKEXTAPPWORKBENCHADVISOR_H_ +#define QMITKEXTAPPWORKBENCHADVISOR_H_ + +#ifdef __MINGW32__ +// We need to inlclude winbase.h here in order to declare +// atomic intrinsics like InterlockedIncrement correctly. +// Otherwhise, they would be declared wrong within qatomic_windows.h . +#include +#endif + +#include + +class QmitkExtAppWorkbenchAdvisor: public berry::QtWorkbenchAdvisor +{ +public: + + static const std::string DEFAULT_PERSPECTIVE_ID; // = "org.mitk.extapp.defaultperspective" + + void Initialize(berry::IWorkbenchConfigurer::Pointer configurer); + + berry::WorkbenchWindowAdvisor* CreateWorkbenchWindowAdvisor( + berry::IWorkbenchWindowConfigurer::Pointer configurer); + + std::string GetInitialWindowPerspectiveId(); + +}; + +#endif /*QMITKEXTAPPWORKBENCHADVISOR_H_*/ diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplication.cpp b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplication.cpp new file mode 100644 index 0000000000..29dc6d4baf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplication.cpp @@ -0,0 +1,43 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkExtApplication.h" + +#include + +#include "QmitkExtAppWorkbenchAdvisor.h" + +QmitkExtApplication::QmitkExtApplication() +{ + +} + +int QmitkExtApplication::Start() +{ + berry::Display* display = berry::PlatformUI::CreateDisplay(); + + int code = berry::PlatformUI::CreateAndRunWorkbench(display, new QmitkExtAppWorkbenchAdvisor()); + + // exit the application with an appropriate return code + return code == berry::PlatformUI::RETURN_RESTART + ? EXIT_RESTART : EXIT_OK; +} + +void QmitkExtApplication::Stop() +{ + +} diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplication.h b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplication.h new file mode 100644 index 0000000000..3eddeaa7a4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplication.h @@ -0,0 +1,37 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKEXTAPPLICATION_H_ +#define QMITKEXTAPPLICATION_H_ + +#include + + +class QmitkExtApplication : public QObject, public berry::IApplication +{ + Q_OBJECT + Q_INTERFACES(berry::IApplication) + +public: + + QmitkExtApplication(); + + int Start(); + void Stop(); +}; + +#endif /*QMITKEXTAPPLICATION_H_*/ diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp new file mode 100644 index 0000000000..77b26ee77c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp @@ -0,0 +1,85 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkExtApplicationPlugin.h" +#include "QmitkExtDefaultPerspective.h" +#include "QmitkExtApplication.h" + +#include +#include + +#include +#include + +#include +#include +#include + +QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::inst = 0; + +QmitkExtApplicationPlugin::QmitkExtApplicationPlugin() +{ + inst = this; +} + +QmitkExtApplicationPlugin::~QmitkExtApplicationPlugin() +{ +} + +QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::GetDefault() +{ + return inst; +} + +void QmitkExtApplicationPlugin::start(ctkPluginContext* context) +{ + berry::AbstractUICTKPlugin::start(context); + + this->context = context; + + BERRY_REGISTER_EXTENSION_CLASS(QmitkExtDefaultPerspective, context); + BERRY_REGISTER_EXTENSION_CLASS(QmitkExtApplication, context); + + + ctkServiceReference cmRef = context->getServiceReference(); + ctkConfigurationAdmin* configAdmin = 0; + if (cmRef) + { + configAdmin = context->getService(cmRef); + } + + // Use the CTK Configuration Admin service to configure the BlueBerry help system + if (configAdmin) + { + ctkConfigurationPtr conf = configAdmin->getConfiguration("org.blueberry.services.help", QString()); + ctkDictionary helpProps; + helpProps.insert("homePage", "qthelp://org.mitk.gui.qt.extapplication/bundle/index.html"); + conf->update(helpProps); + context->ungetService(cmRef); + } + else + { + MITK_WARN << "Configuration Admin service unavailable, cannot set home page url."; + } +} + +ctkPluginContext* QmitkExtApplicationPlugin::GetPluginContext() const +{ + return context; +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_extapplication, QmitkExtApplicationPlugin) diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h new file mode 100644 index 0000000000..bf9076659c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h @@ -0,0 +1,53 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef QMITKEXTAPPLICATIONPLUGIN_H_ +#define QMITKEXTAPPLICATIONPLUGIN_H_ + +#include + +#include + +#include + +class QmitkExtApplicationPlugin : public QObject, public berry::AbstractUICTKPlugin +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + QmitkExtApplicationPlugin(); + ~QmitkExtApplicationPlugin(); + + static QmitkExtApplicationPlugin* GetDefault(); + + ctkPluginContext* GetPluginContext() const; + + void start(ctkPluginContext*); + + QString GetQtHelpCollectionFile() const; + +private: + + static QmitkExtApplicationPlugin* inst; + + ctkPluginContext* context; +}; + +#endif /* QMITKEXTAPPLICATIONPLUGIN_H_ */ diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp new file mode 100755 index 0000000000..ca63bf447d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.cpp @@ -0,0 +1,41 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkExtDefaultPerspective.h" +#include "berryIViewLayout.h" + +QmitkExtDefaultPerspective::QmitkExtDefaultPerspective() +{ +} + +void QmitkExtDefaultPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) +{ + std::string editorArea = layout->GetEditorArea(); + + layout->AddView("org.mitk.views.datamanager", + berry::IPageLayout::LEFT, 0.3f, editorArea); + + berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.datamanager"); + lo->SetCloseable(false); + + layout->AddView("org.mitk.views.imagenavigator", + berry::IPageLayout::BOTTOM, 0.5f, "org.mitk.views.datamanager"); + + berry::IFolderLayout::Pointer bottomFolder = layout->CreateFolder("bottom", berry::IPageLayout::BOTTOM, 0.7f, editorArea); + bottomFolder->AddView("org.mitk.views.propertylistview"); + bottomFolder->AddView("org.blueberry.views.logview"); +} diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h new file mode 100755 index 0000000000..6f0d1a0c0e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtDefaultPerspective.h @@ -0,0 +1,37 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKEXTDEFAULTPERSPECTIVE_H_ +#define QMITKEXTDEFAULTPERSPECTIVE_H_ + +#include + +class QmitkExtDefaultPerspective : public QObject, public berry::IPerspectiveFactory +{ + Q_OBJECT + Q_INTERFACES(berry::IPerspectiveFactory) + +public: + + QmitkExtDefaultPerspective(); + + void CreateInitialLayout(berry::IPageLayout::Pointer layout); + +}; + +#endif /* QMITKEXTDEFAULTPERSPECTIVE_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/CMakeLists.txt b/Plugins/org.mitk.gui.qt.igtexamples/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.igtexamples/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/ImageGuidedTherapy.png b/Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/ImageGuidedTherapy.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/ImageGuidedTherapy.png rename to Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/ImageGuidedTherapy.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/Manual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/Manual.dox rename to Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/Manual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTtrackingLab.dox b/Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTtrackingLab.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTtrackingLab.dox rename to Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTtrackingLab.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTutorial.dox b/Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTutorial.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTutorial.dox rename to Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/QmitkIGTTutorial.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/icon.png b/Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/documentation/UserManual/icon.png rename to Plugins/org.mitk.gui.qt.igtexamples/documentation/UserManual/icon.png diff --git a/Plugins/org.mitk.gui.qt.igtexamples/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.igtexamples/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..73c3a9d64d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.igtexamples/documentation/doxygen/modules.dox @@ -0,0 +1,24 @@ +/** + \defgroup org_mitk_gui_qt_igtexamples org.mitk.gui.qt.igtexamples + \ingroup MITKPlugins + + \brief QmitkIGTExamples shows a small typically navigation MITK functionality. + + Any kind of navigation application will start with the connection to a tracking system + and as we do image guided procedures we want to show something on the screen. In this + tutorial we connect to the NDI Polaris tracking system (or alternatively use a virtual tracking device) + and we will show the movement of a tool as cone in the StdMultiWidget editor. + + +*/ + +/** + \defgroup org_mitk_gui_qt_igtexamples_internal Internal + \ingroup org_mitk_gui_qt_igtexamples + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.igtexamples plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. + + QmitkIGTExamples does not contain any internal classes. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/files.cmake b/Plugins/org.mitk.gui.qt.igtexamples/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/files.cmake rename to Plugins/org.mitk.gui.qt.igtexamples/files.cmake diff --git a/Plugins/org.mitk.gui.qt.igtexamples/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.igtexamples/manifest_headers.cmake new file mode 100644 index 0000000000..9a11fcabbc --- /dev/null +++ b/Plugins/org.mitk.gui.qt.igtexamples/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "IGT 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 diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/plugin.xml b/Plugins/org.mitk.gui.qt.igtexamples/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/plugin.xml rename to Plugins/org.mitk.gui.qt.igtexamples/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/IGTTutorial.png b/Plugins/org.mitk.gui.qt.igtexamples/resources/IGTTutorial.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/IGTTutorial.png rename to Plugins/org.mitk.gui.qt.igtexamples/resources/IGTTutorial.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/IgtTrackingLab.png b/Plugins/org.mitk.gui.qt.igtexamples/resources/IgtTrackingLab.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/IgtTrackingLab.png rename to Plugins/org.mitk.gui.qt.igtexamples/resources/IgtTrackingLab.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTrackingLabView.qrc b/Plugins/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTrackingLabView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTrackingLabView.qrc rename to Plugins/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTrackingLabView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTutorialView.qrc b/Plugins/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTutorialView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTutorialView.qrc rename to Plugins/org.mitk.gui.qt.igtexamples/resources/QmitkIGTTutorialView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/start_rec.png b/Plugins/org.mitk.gui.qt.igtexamples/resources/start_rec.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/start_rec.png rename to Plugins/org.mitk.gui.qt.igtexamples/resources/start_rec.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/stop_rec.png b/Plugins/org.mitk.gui.qt.igtexamples/resources/stop_rec.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/resources/stop_rec.png rename to Plugins/org.mitk.gui.qt.igtexamples/resources/stop_rec.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.cpp b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.cpp rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.h b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.h rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabViewControls.ui b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabViewControls.ui rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTrackingLabViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.cpp b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.cpp rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.h b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.h rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialViewControls.ui b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialViewControls.ui rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/QmitkIGTTutorialViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.igtexamples/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/CMakeLists.txt b/Plugins/org.mitk.gui.qt.igtnavigation/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.igtnavigation/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.igtnavigation/documentation/UserManual/Manual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/documentation/UserManual/Manual.dox rename to Plugins/org.mitk.gui.qt.igtnavigation/documentation/UserManual/Manual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/documentation/UserManual/QmitkToolPairNavigation.dox b/Plugins/org.mitk.gui.qt.igtnavigation/documentation/UserManual/QmitkToolPairNavigation.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/documentation/UserManual/QmitkToolPairNavigation.dox rename to Plugins/org.mitk.gui.qt.igtnavigation/documentation/UserManual/QmitkToolPairNavigation.dox diff --git a/Plugins/org.mitk.gui.qt.igtnavigation/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.igtnavigation/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..c76997c747 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.igtnavigation/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_igtnavigation org.mitk.gui.qt.igtnavigation + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_igtnavigation_internal Internal + \ingroup org_mitk_gui_qt_igtnavigation + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.igtnavigation plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/files.cmake b/Plugins/org.mitk.gui.qt.igtnavigation/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/files.cmake rename to Plugins/org.mitk.gui.qt.igtnavigation/files.cmake diff --git a/Plugins/org.mitk.gui.qt.igtnavigation/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.igtnavigation/manifest_headers.cmake new file mode 100644 index 0000000000..7a6bfededb --- /dev/null +++ b/Plugins/org.mitk.gui.qt.igtnavigation/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "Igtnavigation") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "") +set(Require-Plugin org.mitk.gui.qt.common.legacy) diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/plugin.xml b/Plugins/org.mitk.gui.qt.igtnavigation/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/plugin.xml rename to Plugins/org.mitk.gui.qt.igtnavigation/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/resources/QmitkToolPairNavigationView.qrc b/Plugins/org.mitk.gui.qt.igtnavigation/resources/QmitkToolPairNavigationView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/resources/QmitkToolPairNavigationView.qrc rename to Plugins/org.mitk.gui.qt.igtnavigation/resources/QmitkToolPairNavigationView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/resources/toolpair.png b/Plugins/org.mitk.gui.qt.igtnavigation/resources/toolpair.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/resources/toolpair.png rename to Plugins/org.mitk.gui.qt.igtnavigation/resources/toolpair.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.cpp b/Plugins/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.cpp rename to Plugins/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.h b/Plugins/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.h rename to Plugins/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationViewControls.ui b/Plugins/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationViewControls.ui rename to Plugins/org.mitk.gui.qt.igtnavigation/src/internal/QmitkToolPairNavigationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.igtnavigation/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/CMakeLists.txt b/Plugins/org.mitk.gui.qt.igttracking/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.igttracking/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/Manual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/Manual.dox rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/Manual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagemantStartScreen.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagemantStartScreen.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagemantStartScreen.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagemantStartScreen.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagementAddTool.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagementAddTool.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagementAddTool.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/NavigationToolManagementAddTool.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTNavigationToolManager.dox b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTNavigationToolManager.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTNavigationToolManager.dox rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTNavigationToolManager.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTTrackingToolbox.dox b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTTrackingToolbox.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTTrackingToolbox.dox rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkMITKIGTTrackingToolbox.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkNavigationDataPlayer.dox b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkNavigationDataPlayer.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkNavigationDataPlayer.dox rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/QmitkNavigationDataPlayer.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/configurationWidget.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/configurationWidget.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/configurationWidget.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/configurationWidget.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationDataPlayer.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationDataPlayer.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationDataPlayer.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationDataPlayer.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationToolManager.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationToolManager.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationToolManager.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/iconNavigationToolManager.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/iconTrackingToolbox.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/iconTrackingToolbox.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/iconTrackingToolbox.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/iconTrackingToolbox.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_complete.jpg.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_complete.jpg.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_complete.jpg.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_complete.jpg.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_mitk.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_mitk.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_mitk.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/screenshot_mitk.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/trackingToolsWidget.png b/Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/trackingToolsWidget.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/documentation/UserManual/trackingToolsWidget.png rename to Plugins/org.mitk.gui.qt.igttracking/documentation/UserManual/trackingToolsWidget.png diff --git a/Plugins/org.mitk.gui.qt.igttracking/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.igttracking/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..ffb70f47ab --- /dev/null +++ b/Plugins/org.mitk.gui.qt.igttracking/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_igttracking org.mitk.gui.qt.igttracking + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_igttracking_internal Internal + \ingroup org_mitk_gui_qt_igttracking + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.igttracking plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/files.cmake b/Plugins/org.mitk.gui.qt.igttracking/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/files.cmake rename to Plugins/org.mitk.gui.qt.igttracking/files.cmake diff --git a/Plugins/org.mitk.gui.qt.igttracking/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.igttracking/manifest_headers.cmake new file mode 100644 index 0000000000..5216322fcc --- /dev/null +++ b/Plugins/org.mitk.gui.qt.igttracking/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "IGT Tracking") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "") +set(Require-Plugin org.mitk.gui.qt.common.legacy) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/plugin.xml b/Plugins/org.mitk.gui.qt.igttracking/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/plugin.xml rename to Plugins/org.mitk.gui.qt.igttracking/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/resources/iconNavigationDataPlayer.png b/Plugins/org.mitk.gui.qt.igttracking/resources/iconNavigationDataPlayer.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/resources/iconNavigationDataPlayer.png rename to Plugins/org.mitk.gui.qt.igttracking/resources/iconNavigationDataPlayer.png diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/resources/iconNavigationToolManager.xpm b/Plugins/org.mitk.gui.qt.igttracking/resources/iconNavigationToolManager.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/resources/iconNavigationToolManager.xpm rename to Plugins/org.mitk.gui.qt.igttracking/resources/iconNavigationToolManager.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/resources/iconTrackingToolBox.xpm b/Plugins/org.mitk.gui.qt.igttracking/resources/iconTrackingToolBox.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/resources/iconTrackingToolBox.xpm rename to Plugins/org.mitk.gui.qt.igttracking/resources/iconTrackingToolBox.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.cpp b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.cpp rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.h b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.h rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerViewControls.ui b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerViewControls.ui rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTNavigationToolManagerViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.h b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.h rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkMITKIGTTrackingToolboxViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.cpp b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.cpp rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.h b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.h rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerViewControls.ui b/Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerViewControls.ui rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/QmitkNavigationDataPlayerViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.igttracking/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/CMakeLists.txt b/Plugins/org.mitk.gui.qt.imagecropper/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.imagecropper/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/UserManual/QmitkImageCropperUserManual.dox b/Plugins/org.mitk.gui.qt.imagecropper/documentation/UserManual/QmitkImageCropperUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/UserManual/QmitkImageCropperUserManual.dox rename to Plugins/org.mitk.gui.qt.imagecropper/documentation/UserManual/QmitkImageCropperUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.png b/Plugins/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.png rename to Plugins/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.xpm rename to Plugins/org.mitk.gui.qt.imagecropper/documentation/UserManual/icon.xpm diff --git a/Plugins/org.mitk.gui.qt.imagecropper/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.imagecropper/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..83ddb2d2a1 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.imagecropper/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_imagecropper org.mitk.gui.qt.imagecropper + \ingroup MITKPlugins + + \brief This is the image cropper plugin. It can crop images. + +*/ + +/** + \defgroup org_mitk_gui_qt_imagecropper_internal Internal + \ingroup org_mitk_gui_qt_imagecropper + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.imagecropper plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/files.cmake b/Plugins/org.mitk.gui.qt.imagecropper/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/files.cmake rename to Plugins/org.mitk.gui.qt.imagecropper/files.cmake diff --git a/Plugins/org.mitk.gui.qt.imagecropper/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.imagecropper/manifest_headers.cmake new file mode 100644 index 0000000000..d5d8e19154 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.imagecropper/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Image Cropper") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common.legacy) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/plugin.xml b/Plugins/org.mitk.gui.qt.imagecropper/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/plugin.xml rename to Plugins/org.mitk.gui.qt.imagecropper/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/btn_ctrl.xpm b/Plugins/org.mitk.gui.qt.imagecropper/resources/btn_ctrl.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/btn_ctrl.xpm rename to Plugins/org.mitk.gui.qt.imagecropper/resources/btn_ctrl.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/icon.xpm b/Plugins/org.mitk.gui.qt.imagecropper/resources/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/icon.xpm rename to Plugins/org.mitk.gui.qt.imagecropper/resources/icon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/imagecropper.qrc b/Plugins/org.mitk.gui.qt.imagecropper/resources/imagecropper.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/imagecropper.qrc rename to Plugins/org.mitk.gui.qt.imagecropper/resources/imagecropper.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/mouse_left.xpm b/Plugins/org.mitk.gui.qt.imagecropper/resources/mouse_left.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/mouse_left.xpm rename to Plugins/org.mitk.gui.qt.imagecropper/resources/mouse_left.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/mouse_middle.xpm b/Plugins/org.mitk.gui.qt.imagecropper/resources/mouse_middle.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/mouse_middle.xpm rename to Plugins/org.mitk.gui.qt.imagecropper/resources/mouse_middle.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/mouse_right.xpm b/Plugins/org.mitk.gui.qt.imagecropper/resources/mouse_right.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/resources/mouse_right.xpm rename to Plugins/org.mitk.gui.qt.imagecropper/resources/mouse_right.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.cpp b/Plugins/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.cpp rename to Plugins/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.h b/Plugins/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.h rename to Plugins/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropper.h diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropperControls.ui b/Plugins/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropperControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropperControls.ui rename to Plugins/org.mitk.gui.qt.imagecropper/src/internal/QmitkImageCropperControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.cpp b/Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.cpp rename to Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.h b/Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.h rename to Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperEventInterface.h diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.cpp b/Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.h b/Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.h rename to Plugins/org.mitk.gui.qt.imagecropper/src/internal/mitkImageCropperPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/CMakeLists.txt b/Plugins/org.mitk.gui.qt.imagenavigator/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.imagenavigator/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/UserManual/ImageNavigator.png b/Plugins/org.mitk.gui.qt.imagenavigator/documentation/UserManual/ImageNavigator.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/UserManual/ImageNavigator.png rename to Plugins/org.mitk.gui.qt.imagenavigator/documentation/UserManual/ImageNavigator.png diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/UserManual/QmtikImageNavigator.dox b/Plugins/org.mitk.gui.qt.imagenavigator/documentation/UserManual/QmtikImageNavigator.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/UserManual/QmtikImageNavigator.dox rename to Plugins/org.mitk.gui.qt.imagenavigator/documentation/UserManual/QmtikImageNavigator.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/UserManual/Slider.png b/Plugins/org.mitk.gui.qt.imagenavigator/documentation/UserManual/Slider.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/documentation/UserManual/Slider.png rename to Plugins/org.mitk.gui.qt.imagenavigator/documentation/UserManual/Slider.png diff --git a/Plugins/org.mitk.gui.qt.imagenavigator/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.imagenavigator/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..09cdeee6fc --- /dev/null +++ b/Plugins/org.mitk.gui.qt.imagenavigator/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_imagenavigator org.mitk.gui.qt.imagenavigator + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_imagenavigator_internal Internal + \ingroup org_mitk_gui_qt_imagenavigator + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.imagenavigator plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/files.cmake b/Plugins/org.mitk.gui.qt.imagenavigator/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/files.cmake rename to Plugins/org.mitk.gui.qt.imagenavigator/files.cmake diff --git a/Plugins/org.mitk.gui.qt.imagenavigator/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.imagenavigator/manifest_headers.cmake new file mode 100644 index 0000000000..a24cc8713d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.imagenavigator/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Image Navigator") +set(Plugin-Version "0.9") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/plugin.xml b/Plugins/org.mitk.gui.qt.imagenavigator/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/plugin.xml rename to Plugins/org.mitk.gui.qt.imagenavigator/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/ImageNavigation_48.png b/Plugins/org.mitk.gui.qt.imagenavigator/resources/ImageNavigation_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/ImageNavigation_48.png rename to Plugins/org.mitk.gui.qt.imagenavigator/resources/ImageNavigation_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/QmitkImageNavigatorView.qrc b/Plugins/org.mitk.gui.qt.imagenavigator/resources/QmitkImageNavigatorView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/QmitkImageNavigatorView.qrc rename to Plugins/org.mitk.gui.qt.imagenavigator/resources/QmitkImageNavigatorView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/Slider.png b/Plugins/org.mitk.gui.qt.imagenavigator/resources/Slider.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/Slider.png rename to Plugins/org.mitk.gui.qt.imagenavigator/resources/Slider.png diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/Slider_48.png b/Plugins/org.mitk.gui.qt.imagenavigator/resources/Slider_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/resources/Slider_48.png rename to Plugins/org.mitk.gui.qt.imagenavigator/resources/Slider_48.png diff --git a/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.cpp b/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.cpp new file mode 100644 index 0000000000..cb04c179c4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.cpp @@ -0,0 +1,393 @@ +/*========================================================================= +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkImageNavigatorView.h" + +#include +#include + +#include + + +const std::string QmitkImageNavigatorView::VIEW_ID = "org.mitk.views.imagenavigator"; + + +QmitkImageNavigatorView::QmitkImageNavigatorView() + : m_TransversalStepper(0) + , m_SagittalStepper(0) + , m_FrontalStepper(0) + , m_TimeStepper(0) + , m_Parent(0) + , m_IRenderWindowPart(0) +{ +} + +QmitkImageNavigatorView::~QmitkImageNavigatorView() +{ +} + +void QmitkImageNavigatorView::CreateQtPartControl(QWidget *parent) +{ + // create GUI widgets + m_Parent = parent; + m_Controls.setupUi(parent); + m_Controls.m_SliceNavigatorTransversal->SetInverseDirection(true); + + connect(m_Controls.m_XWorldCoordinateSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnMillimetreCoordinateValueChanged())); + connect(m_Controls.m_YWorldCoordinateSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnMillimetreCoordinateValueChanged())); + connect(m_Controls.m_ZWorldCoordinateSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnMillimetreCoordinateValueChanged())); + + m_Parent->setEnabled(false); + + mitk::IRenderWindowPart* renderPart = this->GetRenderWindowPart(); + this->RenderWindowPartActivated(renderPart); +} + +void QmitkImageNavigatorView::SetFocus () +{ + m_Controls.m_XWorldCoordinateSpinBox->setFocus(); +} + +void QmitkImageNavigatorView::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) +{ + if (this->m_IRenderWindowPart != renderWindowPart) + { + this->m_IRenderWindowPart = renderWindowPart; + this->m_Parent->setEnabled(true); + + QmitkRenderWindow* renderWindow = renderWindowPart->GetRenderWindow("transversal"); + if (renderWindow) + { + if (m_TransversalStepper) m_TransversalStepper->deleteLater(); + m_TransversalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorTransversal, + renderWindow->GetSliceNavigationController()->GetSlice(), + "sliceNavigatorTransversalFromSimpleExample"); + m_Controls.m_SliceNavigatorTransversal->setEnabled(true); + m_Controls.m_TransversalLabel->setEnabled(true); + m_Controls.m_ZWorldCoordinateSpinBox->setEnabled(true); + connect(m_TransversalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); + } + else + { + m_Controls.m_SliceNavigatorTransversal->setEnabled(false); + m_Controls.m_TransversalLabel->setEnabled(false); + m_Controls.m_ZWorldCoordinateSpinBox->setEnabled(false); + } + + renderWindow = renderWindowPart->GetRenderWindow("sagittal"); + if (renderWindow) + { + if (m_SagittalStepper) m_SagittalStepper->deleteLater(); + m_SagittalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorSagittal, + renderWindow->GetSliceNavigationController()->GetSlice(), + "sliceNavigatorSagittalFromSimpleExample"); + m_Controls.m_SliceNavigatorSagittal->setEnabled(true); + m_Controls.m_SagittalLabel->setEnabled(true); + m_Controls.m_YWorldCoordinateSpinBox->setEnabled(true); + connect(m_SagittalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); + } + else + { + m_Controls.m_SliceNavigatorSagittal->setEnabled(false); + m_Controls.m_SagittalLabel->setEnabled(false); + m_Controls.m_YWorldCoordinateSpinBox->setEnabled(false); + } + + renderWindow = renderWindowPart->GetRenderWindow("coronal"); + if (renderWindow) + { + if (m_FrontalStepper) m_FrontalStepper->deleteLater(); + m_FrontalStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorFrontal, + renderWindow->GetSliceNavigationController()->GetSlice(), + "sliceNavigatorFrontalFromSimpleExample"); + m_Controls.m_SliceNavigatorFrontal->setEnabled(true); + m_Controls.m_CoronalLabel->setEnabled(true); + m_Controls.m_XWorldCoordinateSpinBox->setEnabled(true); + connect(m_FrontalStepper, SIGNAL(Refetch()), this, SLOT(OnRefetch())); + } + else + { + m_Controls.m_SliceNavigatorFrontal->setEnabled(false); + m_Controls.m_CoronalLabel->setEnabled(false); + m_Controls.m_XWorldCoordinateSpinBox->setEnabled(false); + } + + mitk::SliceNavigationController* timeController = renderWindowPart->GetTimeNavigationController(); + if (timeController) + { + if (m_TimeStepper) m_TimeStepper->deleteLater(); + m_TimeStepper = new QmitkStepperAdapter(m_Controls.m_SliceNavigatorTime, + timeController->GetSlice(), + "sliceNavigatorTimeFromSimpleExample"); + m_Controls.m_SliceNavigatorTime->setEnabled(true); + m_Controls.m_TimeLabel->setEnabled(true); + } + else + { + m_Controls.m_SliceNavigatorTime->setEnabled(false); + m_Controls.m_TimeLabel->setEnabled(false); + } + } +} + +void QmitkImageNavigatorView::RenderWindowPartDeactivated(mitk::IRenderWindowPart* /*renderWindowPart*/) +{ + m_IRenderWindowPart = 0; + m_Parent->setEnabled(false); +} + +int QmitkImageNavigatorView::GetSizeFlags(bool width) +{ + if(!width) + { + return berry::Constants::MIN | berry::Constants::MAX | berry::Constants::FILL; + } + else + { + return 0; + } +} + +int QmitkImageNavigatorView::ComputePreferredSize(bool width, int /*availableParallel*/, int /*availablePerpendicular*/, int preferredResult) +{ + if(width==false) + { + return 200; + } + else + { + return preferredResult; + } +} + +int QmitkImageNavigatorView::GetClosestAxisIndex(mitk::Vector3D normal) +{ + // cos(theta) = normal . axis + // cos(theta) = (a, b, c) . (d, e, f) + // cos(theta) = (a, b, c) . (1, 0, 0) = a + // cos(theta) = (a, b, c) . (0, 1, 0) = b + // cos(theta) = (a, b, c) . (0, 0, 1) = c + double absCosThetaWithAxis[3]; + + for (int i = 0; i < 3; i++) + { + absCosThetaWithAxis[i] = fabs(normal[i]); + } + int largestIndex = 0; + double largestValue = absCosThetaWithAxis[0]; + for (int i = 1; i < 3; i++) + { + if (absCosThetaWithAxis[i] > largestValue) + { + largestValue = absCosThetaWithAxis[i]; + largestIndex = i; + } + } + return largestIndex; +} + +void QmitkImageNavigatorView::SetBorderColors() +{ + if (m_IRenderWindowPart) + { + QmitkRenderWindow* renderWindow = m_IRenderWindowPart->GetRenderWindow("transversal"); + if (renderWindow) + { + mitk::PlaneGeometry::ConstPointer geometry = renderWindow->GetSliceNavigationController()->GetCurrentPlaneGeometry(); + if (geometry.IsNotNull()) + { + mitk::Vector3D normal = geometry->GetNormal(); + int axis = this->GetClosestAxisIndex(normal); + this->SetBorderColor(axis, QString("red")); + } + } + + renderWindow = m_IRenderWindowPart->GetRenderWindow("sagittal"); + if (renderWindow) + { + mitk::PlaneGeometry::ConstPointer geometry = renderWindow->GetSliceNavigationController()->GetCurrentPlaneGeometry(); + if (geometry.IsNotNull()) + { + mitk::Vector3D normal = geometry->GetNormal(); + int axis = this->GetClosestAxisIndex(normal); + this->SetBorderColor(axis, QString("green")); + } + } + + renderWindow = m_IRenderWindowPart->GetRenderWindow("coronal"); + if (renderWindow) + { + mitk::PlaneGeometry::ConstPointer geometry = renderWindow->GetSliceNavigationController()->GetCurrentPlaneGeometry(); + if (geometry.IsNotNull()) + { + mitk::Vector3D normal = geometry->GetNormal(); + int axis = this->GetClosestAxisIndex(normal); + this->SetBorderColor(axis, QString("blue")); + } + } + } +} + +void QmitkImageNavigatorView::SetBorderColor(int axis, QString colorAsStyleSheetString) +{ + if (axis == 0) + { + this->SetBorderColor(m_Controls.m_XWorldCoordinateSpinBox, colorAsStyleSheetString); + } + else if (axis == 1) + { + this->SetBorderColor(m_Controls.m_YWorldCoordinateSpinBox, colorAsStyleSheetString); + } + else if (axis == 2) + { + this->SetBorderColor(m_Controls.m_ZWorldCoordinateSpinBox, colorAsStyleSheetString); + } +} + +void QmitkImageNavigatorView::SetBorderColor(QDoubleSpinBox *spinBox, QString colorAsStyleSheetString) +{ + assert(spinBox); + spinBox->setStyleSheet(QString("border: 2px solid ") + colorAsStyleSheetString + ";"); +} + +void QmitkImageNavigatorView::SetStepSizes() +{ + this->SetStepSize(0); + this->SetStepSize(1); + this->SetStepSize(2); +} + +void QmitkImageNavigatorView::SetStepSize(int axis) +{ + if (m_IRenderWindowPart) + { + mitk::Geometry3D::ConstPointer geometry = m_IRenderWindowPart->GetActiveRenderWindow()->GetSliceNavigationController()->GetInputWorldGeometry(); + + if (geometry.IsNotNull()) + { + mitk::Point3D crossPositionInIndexCoordinates; + mitk::Point3D crossPositionInIndexCoordinatesPlus1; + mitk::Point3D crossPositionInMillimetresPlus1; + mitk::Vector3D transformedAxisDirection; + + mitk::Point3D crossPositionInMillimetres = m_IRenderWindowPart->GetSelectedPosition(); + geometry->WorldToIndex(crossPositionInMillimetres, crossPositionInIndexCoordinates); + + crossPositionInIndexCoordinatesPlus1 = crossPositionInIndexCoordinates; + crossPositionInIndexCoordinatesPlus1[axis] += 1; + + geometry->IndexToWorld(crossPositionInIndexCoordinatesPlus1, crossPositionInMillimetresPlus1); + + transformedAxisDirection = crossPositionInMillimetresPlus1 - crossPositionInMillimetres; + + int closestAxisInMillimetreSpace = this->GetClosestAxisIndex(transformedAxisDirection); + double stepSize = transformedAxisDirection.GetNorm(); + this->SetStepSize(closestAxisInMillimetreSpace, stepSize); + } + } +} + +void QmitkImageNavigatorView::SetStepSize(int axis, double stepSize) +{ + if (axis == 0) + { + m_Controls.m_XWorldCoordinateSpinBox->setSingleStep(stepSize); + } + else if (axis == 1) + { + m_Controls.m_YWorldCoordinateSpinBox->setSingleStep(stepSize); + } + else if (axis == 2) + { + m_Controls.m_ZWorldCoordinateSpinBox->setSingleStep(stepSize); + } +} + +void QmitkImageNavigatorView::OnMillimetreCoordinateValueChanged() +{ + if (m_IRenderWindowPart) + { + mitk::Geometry3D::ConstPointer geometry = m_IRenderWindowPart->GetActiveRenderWindow()->GetSliceNavigationController()->GetInputWorldGeometry(); + + if (geometry.IsNotNull()) + { + mitk::Point3D positionInWorldCoordinates; + positionInWorldCoordinates[0] = m_Controls.m_XWorldCoordinateSpinBox->value(); + positionInWorldCoordinates[1] = m_Controls.m_YWorldCoordinateSpinBox->value(); + positionInWorldCoordinates[2] = m_Controls.m_ZWorldCoordinateSpinBox->value(); + + m_IRenderWindowPart->SetSelectedPosition(positionInWorldCoordinates); + } + } +} + +void QmitkImageNavigatorView::OnRefetch() +{ + if (m_IRenderWindowPart) + { + mitk::Geometry3D::ConstPointer geometry = m_IRenderWindowPart->GetActiveRenderWindow()->GetSliceNavigationController()->GetInputWorldGeometry(); + + if (geometry.IsNotNull()) + { + mitk::Geometry3D::BoundsArrayType bounds = geometry->GetBounds(); + + mitk::Point3D cornerPoint1InIndexCoordinates; + cornerPoint1InIndexCoordinates[0] = bounds[0]; + cornerPoint1InIndexCoordinates[1] = bounds[2]; + cornerPoint1InIndexCoordinates[2] = bounds[4]; + + mitk::Point3D cornerPoint2InIndexCoordinates; + cornerPoint2InIndexCoordinates[0] = bounds[1]; + cornerPoint2InIndexCoordinates[1] = bounds[3]; + cornerPoint2InIndexCoordinates[2] = bounds[5]; + + if (!geometry->GetImageGeometry()) + { + cornerPoint1InIndexCoordinates[0] += 0.5; + cornerPoint1InIndexCoordinates[1] += 0.5; + cornerPoint1InIndexCoordinates[2] += 0.5; + cornerPoint2InIndexCoordinates[0] -= 0.5; + cornerPoint2InIndexCoordinates[1] -= 0.5; + cornerPoint2InIndexCoordinates[2] -= 0.5; + } + + mitk::Point3D crossPositionInWorldCoordinates = m_IRenderWindowPart->GetSelectedPosition(); + + mitk::Point3D cornerPoint1InWorldCoordinates; + mitk::Point3D cornerPoint2InWorldCoordinates; + + geometry->IndexToWorld(cornerPoint1InIndexCoordinates, cornerPoint1InWorldCoordinates); + geometry->IndexToWorld(cornerPoint2InIndexCoordinates, cornerPoint2InWorldCoordinates); + + m_Controls.m_XWorldCoordinateSpinBox->blockSignals(true); + m_Controls.m_YWorldCoordinateSpinBox->blockSignals(true); + m_Controls.m_ZWorldCoordinateSpinBox->blockSignals(true); + + m_Controls.m_XWorldCoordinateSpinBox->setMinimum(std::min(cornerPoint1InWorldCoordinates[0], cornerPoint2InWorldCoordinates[0])); + m_Controls.m_YWorldCoordinateSpinBox->setMinimum(std::min(cornerPoint1InWorldCoordinates[1], cornerPoint2InWorldCoordinates[1])); + m_Controls.m_ZWorldCoordinateSpinBox->setMinimum(std::min(cornerPoint1InWorldCoordinates[2], cornerPoint2InWorldCoordinates[2])); + m_Controls.m_XWorldCoordinateSpinBox->setMaximum(std::max(cornerPoint1InWorldCoordinates[0], cornerPoint2InWorldCoordinates[0])); + m_Controls.m_YWorldCoordinateSpinBox->setMaximum(std::max(cornerPoint1InWorldCoordinates[1], cornerPoint2InWorldCoordinates[1])); + m_Controls.m_ZWorldCoordinateSpinBox->setMaximum(std::max(cornerPoint1InWorldCoordinates[2], cornerPoint2InWorldCoordinates[2])); + + m_Controls.m_XWorldCoordinateSpinBox->setValue(crossPositionInWorldCoordinates[0]); + m_Controls.m_YWorldCoordinateSpinBox->setValue(crossPositionInWorldCoordinates[1]); + m_Controls.m_ZWorldCoordinateSpinBox->setValue(crossPositionInWorldCoordinates[2]); + + m_Controls.m_XWorldCoordinateSpinBox->blockSignals(false); + m_Controls.m_YWorldCoordinateSpinBox->blockSignals(false); + m_Controls.m_ZWorldCoordinateSpinBox->blockSignals(false); + } + + this->SetBorderColors(); + + } +} diff --git a/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.h b/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.h new file mode 100644 index 0000000000..d6a0fef2b8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorView.h @@ -0,0 +1,97 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 17495 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef _QMITKIMAGENAVIGATORVIEW_H_INCLUDED +#define _QMITKIMAGENAVIGATORVIEW_H_INCLUDED + +#include + +#include +#include + +#include "ui_QmitkImageNavigatorViewControls.h" + + +class QmitkStepperAdapter; + +/*! + * \ingroup org_mitk_gui_qt_imagenavigator_internal + * + * \class QmitkImageNavigatorView + * + * \brief Provides a means to scan quickly through a dataset via Transversal, + * Coronal and Sagittal sliders, displaying millimetre location and stepper position. + * + * For images, the stepper position corresponds to a voxel index. For other datasets + * such as a surface, it corresponds to a sub-division of the bounding box. + * + * \sa QmitkAbstractView + */ +class QmitkImageNavigatorView : + public QmitkAbstractView, public mitk::IRenderWindowPartListener, + public berry::ISizeProvider +{ + + // 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; + + QmitkImageNavigatorView(); + + virtual ~QmitkImageNavigatorView(); + + virtual void CreateQtPartControl(QWidget *parent); + + virtual int GetSizeFlags(bool width); + virtual int ComputePreferredSize(bool width, int /*availableParallel*/, int /*availablePerpendicular*/, int preferredResult); + +protected slots: + + void OnMillimetreCoordinateValueChanged(); + void OnRefetch(); + +protected: + + void SetFocus(); + + void RenderWindowPartActivated(mitk::IRenderWindowPart *renderWindowPart); + void RenderWindowPartDeactivated(mitk::IRenderWindowPart *renderWindowPart); + + void SetBorderColors(); + void SetBorderColor(QDoubleSpinBox *spinBox, QString colorAsStyleSheetString); + void SetBorderColor(int axis, QString colorAsStyleSheetString); + void SetStepSizes(); + void SetStepSize(int axis); + void SetStepSize(int axis, double stepSize); + int GetClosestAxisIndex(mitk::Vector3D normal); + + Ui::QmitkImageNavigatorViewControls m_Controls; + + QmitkStepperAdapter* m_TransversalStepper; + QmitkStepperAdapter* m_SagittalStepper; + QmitkStepperAdapter* m_FrontalStepper; + QmitkStepperAdapter* m_TimeStepper; + + QWidget* m_Parent; + + mitk::IRenderWindowPart* m_IRenderWindowPart; +}; + +#endif // _QMITKIMAGENAVIGATORVIEW_H_INCLUDED diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorViewControls.ui b/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorViewControls.ui rename to Plugins/org.mitk.gui.qt.imagenavigator/src/internal/QmitkImageNavigatorViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.cpp b/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.h b/Plugins/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.h rename to Plugins/org.mitk.gui.qt.imagenavigator/src/internal/mitkImageNavigatorPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/CMakeLists.txt b/Plugins/org.mitk.gui.qt.materialeditor/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.materialeditor/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditor.dox b/Plugins/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditor.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditor.dox rename to Plugins/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditor.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditorGui.png b/Plugins/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditorGui.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditorGui.png rename to Plugins/org.mitk.gui.qt.materialeditor/documentation/UserManual/QmitkSurfaceMaterialEditorGui.png diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/UserManual/SurfaceMaterialEditorIcon.png b/Plugins/org.mitk.gui.qt.materialeditor/documentation/UserManual/SurfaceMaterialEditorIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/documentation/UserManual/SurfaceMaterialEditorIcon.png rename to Plugins/org.mitk.gui.qt.materialeditor/documentation/UserManual/SurfaceMaterialEditorIcon.png diff --git a/Plugins/org.mitk.gui.qt.materialeditor/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.materialeditor/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..34c292bcfe --- /dev/null +++ b/Plugins/org.mitk.gui.qt.materialeditor/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_materialeditor org.mitk.gui.qt.materialeditor + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_materialeditor_internal Internal + \ingroup org_mitk_gui_qt_materialeditor + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.materialeditor plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/files.cmake b/Plugins/org.mitk.gui.qt.materialeditor/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/files.cmake rename to Plugins/org.mitk.gui.qt.materialeditor/files.cmake diff --git a/Plugins/org.mitk.gui.qt.materialeditor/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.materialeditor/manifest_headers.cmake new file mode 100644 index 0000000000..d0433db23a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.materialeditor/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Material Editor") +set(Plugin-Version "0.9") +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 diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/plugin.xml b/Plugins/org.mitk.gui.qt.materialeditor/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/plugin.xml rename to Plugins/org.mitk.gui.qt.materialeditor/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/resources/QmitkMITKSurfaceMaterialEditorView.qrc b/Plugins/org.mitk.gui.qt.materialeditor/resources/QmitkMITKSurfaceMaterialEditorView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/resources/QmitkMITKSurfaceMaterialEditorView.qrc rename to Plugins/org.mitk.gui.qt.materialeditor/resources/QmitkMITKSurfaceMaterialEditorView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/resources/SurfaceMaterialEditor.png b/Plugins/org.mitk.gui.qt.materialeditor/resources/SurfaceMaterialEditor.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/resources/SurfaceMaterialEditor.png rename to Plugins/org.mitk.gui.qt.materialeditor/resources/SurfaceMaterialEditor.png diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp rename to Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h rename to Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorViewControls.ui b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorViewControls.ui rename to Plugins/org.mitk.gui.qt.materialeditor/src/internal/QmitkMITKSurfaceMaterialEditorViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.cpp b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.h b/Plugins/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.h rename to Plugins/org.mitk.gui.qt.materialeditor/src/internal/mitkMaterialEditorPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/CMakeLists.txt b/Plugins/org.mitk.gui.qt.measurementtoolbox/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.measurementtoolbox/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/BasicScreen.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/BasicScreen.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/BasicScreen.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/BasicScreen.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.jpg b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.jpg rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Basic_Screen_edited.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/ImageStatistic_48.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/ImageStatistic_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/ImageStatistic_48.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/ImageStatistic_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_Loaded_Screen.jpg b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_Loaded_Screen.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_Loaded_Screen.jpg rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_Loaded_Screen.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed.jpg b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed.jpg rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed_Screen.jpg b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed_Screen.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed_Screen.jpg rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Image_processed_Screen.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.jpg b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.jpg rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementFigureButtonline.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementGUI.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementGUI.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementGUI.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementGUI.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementIcon.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementIcon.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/MeasurementIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_48.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_48.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_View.jpg b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_View.jpg similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_View.jpg rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Measurement_View.jpg diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/OpenButton.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/OpenButton.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/OpenButton.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/OpenButton.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkImageStatistics.dox b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkImageStatistics.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkImageStatistics.dox rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkImageStatistics.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurement.dox b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurement.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurement.dox rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurement.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurementToolbox.dox b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurementToolbox.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurementToolbox.dox rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/QmitkMeasurementToolbox.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Screenshot1.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Screenshot1.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Screenshot1.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Screenshot1.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Workflow.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Workflow.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Workflow.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/Workflow.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/doxygen.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/doxygen.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/doxygen.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/UserManual/doxygen.png diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..2d36577ce9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_measurementtoolbox org.mitk.gui.qt.measurementtoolbox + \ingroup MITKPlugins + + \brief This is the measurementtoolbox plugin. + +*/ + +/** + \defgroup org_mitk_gui_qt_measurementtoolbox_internal Internal + \ingroup org_mitk_gui_qt_measurementtoolbox + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.measurementtoolbox plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/files.cmake b/Plugins/org.mitk.gui.qt.measurementtoolbox/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/files.cmake rename to Plugins/org.mitk.gui.qt.measurementtoolbox/files.cmake diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.measurementtoolbox/manifest_headers.cmake new file mode 100644 index 0000000000..b318b8aca8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Measurement") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common) diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/plugin.xml b/Plugins/org.mitk.gui.qt.measurementtoolbox/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/plugin.xml rename to Plugins/org.mitk.gui.qt.measurementtoolbox/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_24.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_24.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_24.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_24.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_48.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_48.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_48.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_48.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_64.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_64.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_64.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/ImageStatistic_64.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/QmitkImageStatisticsView.qrc b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/QmitkImageStatisticsView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/QmitkImageStatisticsView.qrc rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/QmitkImageStatisticsView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/angle.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/angle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/angle.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/angle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/arrow.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/arrow.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/arrow.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/arrow.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/circle.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/circle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/circle.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/circle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/four-point-angle.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/four-point-angle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/four-point-angle.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/four-point-angle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/lena.xpm b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/lena.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/lena.xpm rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/lena.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/line.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/line.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/line.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/line.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/measurement.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/measurement.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/measurement.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/measurement.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/measurement.qrc b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/measurement.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/measurement.qrc rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/measurement.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/path.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/path.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/path.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/path.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/polygon.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/polygon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/polygon.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/polygon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/rectangle.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/rectangle.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/rectangle.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/rectangle.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/stats.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/stats.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/stats.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/stats.png diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/text.png b/Plugins/org.mitk.gui.qt.measurementtoolbox/resources/text.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/resources/text.png rename to Plugins/org.mitk.gui.qt.measurementtoolbox/resources/text.png diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp new file mode 100644 index 0000000000..0e068a49da --- /dev/null +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.cpp @@ -0,0 +1,795 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-05-22 11:00:35 +0200 (Fr, 22 Mai 2009) $ +Version: $Revision: 10185 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkImageStatisticsView.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +#include "QmitkStdMultiWidget.h" +#include "QmitkSliderNavigatorWidget.h" + +#include "mitkNodePredicateDataType.h" +#include "mitkImageTimeSelector.h" +#include "mitkProperties.h" + +#include "mitkProgressBar.h" + +// Includes for image processing +#include "mitkImageCast.h" +#include "mitkITKImageImport.h" + +#include "mitkDataNodeObject.h" +#include "mitkNodePredicateData.h" +#include "mitkPlanarFigureInteractor.h" + +#include + +const std::string QmitkImageStatisticsView::VIEW_ID = +"org.mitk.views.imagestatistics"; + +class QmitkRequestStatisticsUpdateEvent : public QEvent +{ +public: + enum Type + { + StatisticsUpdateRequest = QEvent::MaxUser - 1025 + }; + + QmitkRequestStatisticsUpdateEvent() + : QEvent( (QEvent::Type) StatisticsUpdateRequest ) {}; +}; + + + +typedef itk::Image ImageType; +typedef itk::Image FloatImageType; +typedef itk::Image, 3> VectorImageType; + +inline bool my_isnan(float x) + { + volatile float d = x; + + if(d!=d) + return true; + + if(d==d) + return false; + return d != d; + + } + +QmitkImageStatisticsView::QmitkImageStatisticsView(QObject* /*parent*/, const char* /*name*/) +: m_Controls( NULL ), + m_TimeStepperAdapter( NULL ), + m_SelectedImageNode( NULL ), + m_SelectedImage( NULL ), + m_SelectedMaskNode( NULL ), + m_SelectedImageMask( NULL ), + m_SelectedPlanarFigure( NULL ), + m_ImageObserverTag( -1 ), + m_ImageMaskObserverTag( -1 ), + m_PlanarFigureObserverTag( -1 ), + m_CurrentStatisticsValid( false ), + m_StatisticsUpdatePending( false ), + m_Visible(false) +{ +} + + +QmitkImageStatisticsView::~QmitkImageStatisticsView() +{ + if ( m_SelectedImage != NULL ) + m_SelectedImage->RemoveObserver( m_ImageObserverTag ); + if ( m_SelectedImageMask != NULL ) + m_SelectedImageMask->RemoveObserver( m_ImageMaskObserverTag ); + if ( m_SelectedPlanarFigure != NULL ) + m_SelectedPlanarFigure->RemoveObserver( m_PlanarFigureObserverTag ); +} + + +void QmitkImageStatisticsView::CreateQtPartControl(QWidget *parent) +{ + if (m_Controls == NULL) + { + m_Controls = new Ui::QmitkImageStatisticsViewControls; + m_Controls->setupUi(parent); + this->CreateConnections(); + + m_Controls->m_ErrorMessageLabel->hide(); + + m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 0 ); + m_Controls->m_LineProfileWidget->SetPathModeToPlanarFigure(); + } +} + + + +void QmitkImageStatisticsView::CreateConnections() +{ + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->m_ButtonCopyHistogramToClipboard), SIGNAL(clicked()),(QObject*) this, SLOT(ClipboardHistogramButtonClicked())); + connect( (QObject*)(m_Controls->m_ButtonCopyStatisticsToClipboard), SIGNAL(clicked()),(QObject*) this, SLOT(ClipboardStatisticsButtonClicked())); + connect( (QObject*)(m_Controls->m_IgnoreZerosCheckbox), SIGNAL(clicked()),(QObject*) this, SLOT(IgnoreZerosCheckboxClicked())); + } +} + +void QmitkImageStatisticsView::IgnoreZerosCheckboxClicked( ) +{ + UpdateStatistics(); +} + +void QmitkImageStatisticsView::ClipboardHistogramButtonClicked() +{ + if ( m_CurrentStatisticsValid && (m_CurrentStatisticsCalculator.IsNotNull()) ) + { + typedef mitk::ImageStatisticsCalculator::HistogramType HistogramType; + const HistogramType *histogram = m_CurrentStatisticsCalculator->GetHistogram(); + + QString clipboard( "Measurement \t Frequency\n" ); + for ( HistogramType::ConstIterator it = histogram->Begin(); + it != histogram->End(); + ++it ) + { + clipboard = clipboard.append( "%L1 \t %L2\n" ) + .arg( it.GetMeasurementVector()[0], 0, 'f', 2 ) + .arg( it.GetFrequency() ); + } + + QApplication::clipboard()->setText( + clipboard, QClipboard::Clipboard ); + } + else + { + QApplication::clipboard()->clear(); + } +} + + +void QmitkImageStatisticsView::ClipboardStatisticsButtonClicked() +{ + if ( m_CurrentStatisticsValid && (m_CurrentStatisticsCalculator.IsNotNull()) ) + { + const mitk::ImageStatisticsCalculator::Statistics &statistics = + m_CurrentStatisticsCalculator->GetStatistics(); + + // Copy statistics to clipboard ("%Ln" will use the default locale for + // number formatting) + QString clipboard( "Mean \t StdDev \t RMS \t Max \t Min \t N \t V (mm³)\n" ); + clipboard = clipboard.append( "%L1 \t %L2 \t %L3 \t %L4 \t %L5 \t %L6 \t %L7" ) + .arg( statistics.Mean, 0, 'f', 10 ) + .arg( statistics.Sigma, 0, 'f', 10 ) + .arg( statistics.RMS, 0, 'f', 10 ) + .arg( statistics.Max, 0, 'f', 10 ) + .arg( statistics.Min, 0, 'f', 10 ) + .arg( statistics.N ) + .arg( m_Controls->m_StatisticsTable->item( 0, 6 )->text() ); + + QApplication::clipboard()->setText( + clipboard, QClipboard::Clipboard ); + } + else + { + QApplication::clipboard()->clear(); + } +} + + +void QmitkImageStatisticsView::FillStatisticsTableView( + const mitk::ImageStatisticsCalculator::Statistics &s, + const mitk::Image *image ) +{ + m_Controls->m_StatisticsTable->setItem( 0, 0, new QTableWidgetItem( + QString("%1").arg(s.Mean, 0, 'f', 2) ) ); + + m_Controls->m_StatisticsTable->setItem( 0, 1, new QTableWidgetItem( + QString("%1").arg(s.Sigma, 0, 'f', 2) ) ); + + m_Controls->m_StatisticsTable->setItem( 0, 2, new QTableWidgetItem( + QString("%1").arg(s.RMS, 0, 'f', 2) ) ); + + m_Controls->m_StatisticsTable->setItem( 0, 3, new QTableWidgetItem( + QString("%1").arg(s.Max, 0, 'f', 2) ) ); + + m_Controls->m_StatisticsTable->setItem( 0, 4, new QTableWidgetItem( + QString("%1").arg(s.Min, 0, 'f', 2) ) ); + + m_Controls->m_StatisticsTable->setItem( 0, 5, new QTableWidgetItem( + QString("%1").arg(s.N) ) ); + + const mitk::Geometry3D *geometry = image->GetGeometry(); + if ( geometry != NULL ) + { + const mitk::Vector3D &spacing = image->GetGeometry()->GetSpacing(); + double volume = spacing[0] * spacing[1] * spacing[2] * (double) s.N; + m_Controls->m_StatisticsTable->setItem( 0, 6, new QTableWidgetItem( + QString("%1").arg(volume, 0, 'f', 2) ) ); + } + else + { + m_Controls->m_StatisticsTable->setItem( 0, 6, new QTableWidgetItem( + "NA" ) ); + } +} + + +void QmitkImageStatisticsView::InvalidateStatisticsTableView() +{ + for ( unsigned int i = 0; i < 7; ++i ) + { + m_Controls->m_StatisticsTable->setItem( 0, i, new QTableWidgetItem( "NA" ) ); + } +} + + +void QmitkImageStatisticsView::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*part*/, + const QList &selectedNodes ) +{ + // Clear any unreferenced images + this->RemoveOrphanImages(); + + if ( !m_Visible ) + { + return; + } + + // Check if selection makeup consists only of valid nodes: + // One image, segmentation or planarFigure + // One image and one of the other two + bool tooManyNodes( true ); + bool invalidNodes( true ); + + if ( selectedNodes.size() < 3 ) + { + tooManyNodes = false; + } + + QList nodes(selectedNodes); + if( !tooManyNodes ) + { + unsigned int numberImages = 0; + unsigned int numberSegmentations = 0; + unsigned int numberPlanarFigures = 0; + + for ( int index = 0; index < nodes.size(); index++ ) + { + m_SelectedImageMask = dynamic_cast< mitk::Image * >( nodes[ index ]->GetData() ); + m_SelectedPlanarFigure = dynamic_cast< mitk::PlanarFigure * >( nodes[ index ]->GetData() ); + + if ( m_SelectedImageMask != NULL ) + { + bool isMask( false ); + nodes[ index ]->GetPropertyValue("binary", isMask); + if ( !isMask ) + { + numberImages++; + } + else + { + numberSegmentations++; + if ( numberImages != 0 ) // image should be last element + { + std::swap( nodes[ index ], nodes[ index - 1 ] ); + } + } + } + else if ( m_SelectedPlanarFigure != NULL ) + { + numberPlanarFigures++; + if ( numberImages != 0 ) // image should be last element + { + std::swap( nodes[ index ], nodes[ index - 1 ] ); + } + } + } + + if ( ( numberPlanarFigures + numberSegmentations + numberImages ) == nodes.size() && //No invalid nodes + ( numberPlanarFigures + numberSegmentations ) < 2 && numberImages < 2 + // maximum of one image and/or one of either planar figure or segmentation + ) + { + invalidNodes = false; + } + } + + if ( nodes.empty() || tooManyNodes || invalidNodes ) + { + // Nothing to do: invalidate image, clear statistics, histogram, and GUI + m_SelectedImage = NULL; + this->InvalidateStatisticsTableView() ; + m_Controls->m_HistogramWidget->ClearItemModel(); + m_Controls->m_LineProfileWidget->ClearItemModel(); + + m_CurrentStatisticsValid = false; + m_Controls->m_ErrorMessageLabel->hide(); + m_Controls->m_SelectedMaskLabel->setText( "None" ); + return; + } + + // Get selected element + + mitk::DataNode *selectedNode = nodes.front(); + mitk::Image *selectedImage = dynamic_cast< mitk::Image * >( selectedNode->GetData() ); + + // Find the next parent/grand-parent node containing an image, if any + mitk::DataStorage::SetOfObjects::ConstPointer parentObjects; + mitk::DataNode *parentNode = NULL; + mitk::Image *parentImage = NULL; + + // Possibly previous change listeners + if ( (m_SelectedPlanarFigure != NULL) && (m_PlanarFigureObserverTag >= 0) ) + { + m_SelectedPlanarFigure->RemoveObserver( m_PlanarFigureObserverTag ); + m_PlanarFigureObserverTag = -1; + } + if ( (m_SelectedImage != NULL) && (m_ImageObserverTag >= 0) ) + { + m_SelectedImage->RemoveObserver( m_ImageObserverTag ); + m_ImageObserverTag = -1; + } + if ( (m_SelectedImageMask != NULL) && (m_ImageMaskObserverTag >= 0) ) + { + m_SelectedImageMask->RemoveObserver( m_ImageMaskObserverTag ); + m_ImageMaskObserverTag = -1; + } + + // Deselect all images and masks by default + m_SelectedImageNode = NULL; + m_SelectedImage = NULL; + m_SelectedMaskNode = NULL; + m_SelectedImageMask = NULL; + m_SelectedPlanarFigure = NULL; + + { + unsigned int parentObjectIndex = 0; + parentObjects = this->GetDataStorage()->GetSources( selectedNode ); + while( parentObjectIndex < parentObjects->Size() ) + { + // Use first parent object (if multiple parents are present) + parentNode = parentObjects->ElementAt( parentObjectIndex ); + parentImage = dynamic_cast< mitk::Image * >( parentNode->GetData() ); + if( parentImage != NULL ) + { + break; + } + parentObjectIndex++; + } + } + + if ( nodes.size() == 2 ) + { + parentNode = nodes.back(); + parentImage = dynamic_cast< mitk::Image * >( parentNode->GetData() ); + } + + if ( parentImage != NULL ) + { + m_SelectedImageNode = parentNode; + m_SelectedImage = parentImage; + + // Check if a valid mask has been selected (Image or PlanarFigure) + m_SelectedImageMask = dynamic_cast< mitk::Image * >( selectedNode->GetData() ); + m_SelectedPlanarFigure = dynamic_cast< mitk::PlanarFigure * >( selectedNode->GetData() ); + + // Check whether ImageMask is a binary segmentation + + if ( (m_SelectedImageMask != NULL) ) + { + bool isMask( false ); + selectedNode->GetPropertyValue("binary", isMask); + if ( !isMask ) + { + m_SelectedImageNode = selectedNode; + m_SelectedImage = selectedImage; + m_SelectedImageMask = NULL; + } + else + { + m_SelectedMaskNode = selectedNode; + } + } + else if ( (m_SelectedPlanarFigure != NULL) ) + { + m_SelectedMaskNode = selectedNode; + } + } + else if ( selectedImage != NULL ) + { + m_SelectedImageNode = selectedNode; + m_SelectedImage = selectedImage; + } + + + typedef itk::SimpleMemberCommand< QmitkImageStatisticsView > ITKCommandType; + ITKCommandType::Pointer changeListener; + changeListener = ITKCommandType::New(); + changeListener->SetCallbackFunction( this, &QmitkImageStatisticsView::RequestStatisticsUpdate ); + + // Add change listeners to selected objects + if ( m_SelectedImage != NULL ) + { + m_ImageObserverTag = m_SelectedImage->AddObserver( + itk::ModifiedEvent(), changeListener ); + } + + if ( m_SelectedImageMask != NULL ) + { + m_ImageMaskObserverTag = m_SelectedImageMask->AddObserver( + itk::ModifiedEvent(), changeListener ); + } + + if ( m_SelectedPlanarFigure != NULL ) + { + m_PlanarFigureObserverTag = m_SelectedPlanarFigure->AddObserver( + mitk::EndInteractionPlanarFigureEvent(), changeListener ); + } + + + // Clear statistics / histogram GUI if nothing is selected + if ( m_SelectedImage == NULL ) + { + // Clear statistics, histogram, and GUI + this->InvalidateStatisticsTableView(); + m_Controls->m_HistogramWidget->ClearItemModel(); + m_Controls->m_LineProfileWidget->ClearItemModel(); + m_CurrentStatisticsValid = false; + m_Controls->m_ErrorMessageLabel->hide(); + m_Controls->m_SelectedMaskLabel->setText( "None" ); + } + else + { + // Else, request statistics and GUI update + this->RequestStatisticsUpdate(); + } +} + + +void QmitkImageStatisticsView::UpdateStatistics() +{ + + // Remove any cached images that are no longer referenced elsewhere + this->RemoveOrphanImages(); + + mitk::IRenderWindowPart* renderPart = this->GetRenderWindowPart(); + if ( renderPart == NULL ) + { + return; + } + + unsigned int timeStep = renderPart->GetTimeNavigationController()->GetTime()->GetPos(); + + if ( m_SelectedImage != NULL ) + { + // Check if a the selected image is a multi-channel image. If yes, statistics + // cannot be calculated currently. + if ( m_SelectedImage->GetPixelType().GetNumberOfComponents() > 1 ) + { + std::stringstream message; + message << "Multi-component images not supported."; + m_Controls->m_ErrorMessageLabel->setText( message.str().c_str() ); + m_Controls->m_ErrorMessageLabel->show(); + + this->InvalidateStatisticsTableView(); + m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 0 ); + m_Controls->m_HistogramWidget->ClearItemModel(); + m_CurrentStatisticsValid = false; + return; + } + + // Retrieve ImageStatisticsCalculator from has map (or create a new one + // for this image if non-existant) + ImageStatisticsMapType::iterator it = + m_ImageStatisticsMap.find( m_SelectedImage ); + + if ( it != m_ImageStatisticsMap.end() ) + { + m_CurrentStatisticsCalculator = it->second; + MITK_INFO << "Retrieving StatisticsCalculator"; + } + else + { + m_CurrentStatisticsCalculator = mitk::ImageStatisticsCalculator::New(); + m_CurrentStatisticsCalculator->SetImage( m_SelectedImage ); + m_ImageStatisticsMap[m_SelectedImage] = m_CurrentStatisticsCalculator; + MITK_INFO << "Creating StatisticsCalculator"; + } + + std::string maskName; + std::string maskType; + unsigned int maskDimension; + + if ( m_SelectedImageMask != NULL ) + { + m_CurrentStatisticsCalculator->SetImageMask( m_SelectedImageMask ); + m_CurrentStatisticsCalculator->SetMaskingModeToImage(); + + maskName = m_SelectedMaskNode->GetName(); + maskType = m_SelectedImageMask->GetNameOfClass(); + maskDimension = 3; + } + else if ( m_SelectedPlanarFigure != NULL ) + { + m_CurrentStatisticsCalculator->SetPlanarFigure( m_SelectedPlanarFigure ); + m_CurrentStatisticsCalculator->SetMaskingModeToPlanarFigure(); + + maskName = m_SelectedMaskNode->GetName(); + maskType = m_SelectedPlanarFigure->GetNameOfClass(); + maskDimension = 2; + } + else + { + m_CurrentStatisticsCalculator->SetMaskingModeToNone(); + + maskName = "None"; + maskType = ""; + maskDimension = 0; + } + + if(m_Controls->m_IgnoreZerosCheckbox->isChecked()) + { + m_CurrentStatisticsCalculator->SetIgnorePixelValue(0); + m_CurrentStatisticsCalculator->SetDoIgnorePixelValue(true); + } + else + { + m_CurrentStatisticsCalculator->SetDoIgnorePixelValue(false); + } + + std::stringstream maskLabel; + maskLabel << maskName; + if ( maskDimension > 0 ) + { + maskLabel << " [" << maskDimension << "D " << maskType << "]"; + } + + m_Controls->m_SelectedMaskLabel->setText( maskLabel.str().c_str() ); + + bool statisticsChanged = false; + bool statisticsCalculationSuccessful = false; + + // Initialize progress bar + mitk::ProgressBar::GetInstance()->AddStepsToDo( 100 ); + + // Install listener for progress events and initialize progress bar + typedef itk::SimpleMemberCommand< QmitkImageStatisticsView > ITKCommandType; + ITKCommandType::Pointer progressListener; + progressListener = ITKCommandType::New(); + progressListener->SetCallbackFunction( this, &QmitkImageStatisticsView::UpdateProgressBar ); + unsigned long progressObserverTag = m_CurrentStatisticsCalculator + ->AddObserver( itk::ProgressEvent(), progressListener ); + + // show wait cursor + this->WaitCursorOn(); + + try + { + // Compute statistics + statisticsChanged = + m_CurrentStatisticsCalculator->ComputeStatistics( timeStep ); + + statisticsCalculationSuccessful = true; + } + catch ( const std::runtime_error &e ) + { + // In case of exception, print error message on GUI + std::stringstream message; + message << "" << e.what() << ""; + m_Controls->m_ErrorMessageLabel->setText( message.str().c_str() ); + m_Controls->m_ErrorMessageLabel->show(); + } + catch ( const std::exception &e ) + { + MITK_ERROR << "Caught exception: " << e.what(); + + // In case of exception, print error message on GUI + std::stringstream message; + message << "Error! Unequal Dimensions of Image and Segmentation. No recompute possible "; + m_Controls->m_ErrorMessageLabel->setText( message.str().c_str() ); + m_Controls->m_ErrorMessageLabel->show(); + } + + m_CurrentStatisticsCalculator->RemoveObserver( progressObserverTag ); + + // Make sure that progress bar closes + mitk::ProgressBar::GetInstance()->Progress( 100 ); + + // remove wait cursor + this->WaitCursorOff(); + + if ( statisticsCalculationSuccessful ) + { + if ( statisticsChanged ) + { + // Do not show any error messages + m_Controls->m_ErrorMessageLabel->hide(); + + m_CurrentStatisticsValid = true; + } + + m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 0 ); + m_Controls->m_HistogramWidget->SetHistogramModeToDirectHistogram(); + m_Controls->m_HistogramWidget->SetHistogram( + m_CurrentStatisticsCalculator->GetHistogram( timeStep ) ); + m_Controls->m_HistogramWidget->UpdateItemModelFromHistogram(); + + MITK_INFO << "UpdateItemModelFromHistogram()"; + + this->FillStatisticsTableView( + m_CurrentStatisticsCalculator->GetStatistics( timeStep ), + m_SelectedImage ); + } + else + { + m_Controls->m_SelectedMaskLabel->setText( "None" ); + + // Clear statistics and histogram + this->InvalidateStatisticsTableView(); + m_Controls->m_HistogramWidget->ClearItemModel(); + m_CurrentStatisticsValid = false; + + + // If a (non-closed) PlanarFigure is selected, display a line profile widget + if ( m_SelectedPlanarFigure != NULL ) + { + // check whether PlanarFigure is initialized + const mitk::Geometry2D *planarFigureGeometry2D = m_SelectedPlanarFigure->GetGeometry2D(); + if ( planarFigureGeometry2D == NULL ) + { + // Clear statistics, histogram, and GUI + this->InvalidateStatisticsTableView(); + m_Controls->m_HistogramWidget->ClearItemModel(); + m_Controls->m_LineProfileWidget->ClearItemModel(); + m_CurrentStatisticsValid = false; + m_Controls->m_ErrorMessageLabel->hide(); + m_Controls->m_SelectedMaskLabel->setText( "None" ); + return; + } + // TODO: enable line profile widget + m_Controls->m_StatisticsWidgetStack->setCurrentIndex( 1 ); + m_Controls->m_LineProfileWidget->SetImage( m_SelectedImage ); + m_Controls->m_LineProfileWidget->SetPlanarFigure( m_SelectedPlanarFigure ); + m_Controls->m_LineProfileWidget->UpdateItemModelFromPath(); + } + } + } +} + +void QmitkImageStatisticsView::UpdateProgressBar() +{ + mitk::ProgressBar::GetInstance()->Progress(); +} + + +void QmitkImageStatisticsView::RequestStatisticsUpdate() +{ + if ( !m_StatisticsUpdatePending ) + { + QApplication::postEvent( this, new QmitkRequestStatisticsUpdateEvent ); + m_StatisticsUpdatePending = true; + } +} + + +void QmitkImageStatisticsView::RemoveOrphanImages() +{ + ImageStatisticsMapType::iterator it = m_ImageStatisticsMap.begin(); + + while ( it != m_ImageStatisticsMap.end() ) + { + mitk::Image *image = it->first; + mitk::ImageStatisticsCalculator *calculator = it->second; + ++it; + + mitk::NodePredicateData::Pointer hasImage = mitk::NodePredicateData::New( image ); + if ( this->GetDataStorage()->GetNode( hasImage ) == NULL ) + { + if ( m_SelectedImage == image ) + { + m_SelectedImage = NULL; + m_SelectedImageNode = NULL; + } + if ( m_CurrentStatisticsCalculator == calculator ) + { + m_CurrentStatisticsCalculator = NULL; + } + m_ImageStatisticsMap.erase( image ); + it = m_ImageStatisticsMap.begin(); + } + } +} + + +bool QmitkImageStatisticsView::event( QEvent *event ) +{ + if ( event->type() == (QEvent::Type) QmitkRequestStatisticsUpdateEvent::StatisticsUpdateRequest ) + { + // Update statistics + + m_StatisticsUpdatePending = false; + + this->UpdateStatistics(); + return true; + } + + return false; +} + +void QmitkImageStatisticsView::ComputeIntensityProfile( mitk::PlanarLine* line ) +{ + double sampling = 300; + QmitkVtkHistogramWidget::HistogramType::Pointer histogram = QmitkVtkHistogramWidget::HistogramType::New(); + itk::Size<1> siz; + siz[0] = sampling; + itk::FixedArray lower, higher; + lower.Fill(0); + mitk::Point3D begin = line->GetWorldControlPoint(0); + mitk::Point3D end = line->GetWorldControlPoint(1); + itk::Vector direction = (end - begin); + higher.Fill(direction.GetNorm()); + histogram->Initialize(siz, lower, higher); + for(int i = 0; i < sampling; i++) + { + //mitk::Point3D location = begin + double(i)/sampling * direction; + double d = m_SelectedImage->GetPixelValueByWorldCoordinate(begin + double(i)/sampling * direction); + histogram->SetFrequency(i,d); + } + m_Controls->m_HistogramWidget->SetHistogramModeToDirectHistogram(); + m_Controls->m_HistogramWidget->SetHistogram( histogram ); + m_Controls->m_HistogramWidget->UpdateItemModelFromHistogram(); + +} + + +void QmitkImageStatisticsView::Activated() +{ +} + +void QmitkImageStatisticsView::Deactivated() +{ +} + +void QmitkImageStatisticsView::Visible() +{ + m_Visible = true; + this->OnSelectionChanged(this->GetSite()->GetPage()->FindView("org.mitk.views.datamanager"), + this->GetDataManagerSelection()); +} + +void QmitkImageStatisticsView::Hidden() +{ + m_Visible = false; +} + +void QmitkImageStatisticsView::SetFocus() +{ + +} diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.h b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.h new file mode 100644 index 0000000000..b68efa3921 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsView.h @@ -0,0 +1,167 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2009-05-28 20:08:26 +0200 (Do, 28 Mai 2009) $ +Version: $Revision: 10185 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkImageStatisticsView_H__INCLUDED +#define QmitkImageStatisticsView_H__INCLUDED + +#include "ui_QmitkImageStatisticsViewControls.h" + +#include +#include + +#include "QmitkStepperAdapter.h" + +#include "mitkImageStatisticsCalculator.h" + +#include +#include "mitkPlanarLine.h" + + +/*! +\brief QmitkImageStatisticsView + +\sa QmitkFunctionality +\ingroup Functionalities +*/ +class QmitkImageStatisticsView : public QmitkAbstractView, public mitk::ILifecycleAwarePart +{ + Q_OBJECT + +public: + + /*! + \ Convenient typedefs + */ + typedef mitk::DataStorage::SetOfObjects ConstVector; + typedef ConstVector::ConstPointer ConstVectorPointer; + typedef ConstVector::ConstIterator ConstVectorIterator; + + /*! + \brief default constructor + */ + QmitkImageStatisticsView(QObject *parent=0, const char *name=0); + + /*! + \brief default destructor + */ + virtual ~QmitkImageStatisticsView(); + + /*! + \brief method for creating the widget containing the application controls, like sliders, buttons etc. + */ + virtual void CreateQtPartControl(QWidget *parent); + + /*! + \brief method for creating the connections of main and control widget + */ + virtual void CreateConnections(); + + bool IsExclusiveFunctionality() const; + + virtual bool event( QEvent *event ); + + void OnSelectionChanged( berry::IWorkbenchPart::Pointer part, const QList &nodes ); + + static const std::string VIEW_ID; + +protected slots: + void ClipboardHistogramButtonClicked(); + + void ClipboardStatisticsButtonClicked(); + + void IgnoreZerosCheckboxClicked( ); + + +protected: + + void FillStatisticsTableView( const mitk::ImageStatisticsCalculator::Statistics &s, + const mitk::Image *image ); + + void InvalidateStatisticsTableView(); + + /** \brief Issues a request to update statistics by sending an event to the + * Qt event processing queue. + * + * Statistics update should only be executed after program execution returns + * to the Qt main loop. This mechanism also prevents multiple execution of + * updates where only one is required.*/ + void RequestStatisticsUpdate(); + + /** \brief Recalculate statistics for currently selected image and mask and + * update the GUI. */ + void UpdateStatistics(); + + /** \brief Listener for progress events to update progress bar. */ + void UpdateProgressBar(); + + + /** \brief Removes any cached images which are no longer referenced elsewhere. */ + void RemoveOrphanImages(); + + /** \brief Computes an Intensity Profile along line and updates the histogram widget with it. */ + void ComputeIntensityProfile( mitk::PlanarLine* line ); + + void Activated(); + void Deactivated(); + + void Visible(); + void Hidden(); + + void SetFocus(); + + + typedef std::map< mitk::Image *, mitk::ImageStatisticsCalculator::Pointer > + ImageStatisticsMapType; + + /*! + * controls containing sliders for scrolling through the slices + */ + Ui::QmitkImageStatisticsViewControls *m_Controls; + + QmitkStepperAdapter* m_TimeStepperAdapter; + unsigned int m_CurrentTime; + + QString m_Clipboard; + + // Image and mask data + mitk::DataNode *m_SelectedImageNode; + mitk::Image *m_SelectedImage; + + mitk::DataNode *m_SelectedMaskNode; + mitk::Image *m_SelectedImageMask; + mitk::PlanarFigure *m_SelectedPlanarFigure; + + long m_ImageObserverTag; + long m_ImageMaskObserverTag; + long m_PlanarFigureObserverTag; + + // Hash map for associating one image statistics calculator with each iamge + // (so that previously calculated histograms / statistics can be recovered + // if a recalculation is not required) + ImageStatisticsMapType m_ImageStatisticsMap; + + mitk::ImageStatisticsCalculator::Pointer m_CurrentStatisticsCalculator; + + bool m_CurrentStatisticsValid; + + bool m_StatisticsUpdatePending; + + bool m_Visible; +}; + + +#endif // QmitkImageStatisticsView_H__INCLUDED diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui rename to Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementControls.ui b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementControls.ui rename to Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementControls.ui diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.cpp b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.cpp new file mode 100644 index 0000000000..ff70e5656e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.cpp @@ -0,0 +1,1095 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 15412 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include +#include +#include + +#include "mitkGlobalInteraction.h" +#include "mitkPointSet.h" +#include "mitkProperties.h" +#include "mitkStringProperty.h" +#include "mitkIDataStorageService.h" +#include "mitkDataNodeObject.h" +#include +#include +#include +#include +#include +#include +#include + +#include "mitkPlanarCircle.h" +#include "mitkPlanarPolygon.h" +#include "mitkPlanarAngle.h" +#include "mitkPlanarRectangle.h" +#include "mitkPlanarLine.h" +#include "mitkPlanarCross.h" +#include "mitkPlanarFourPointAngle.h" +#include "mitkPlanarFigureInteractor.h" +#include "mitkPlaneGeometry.h" +#include "QmitkPlanarFiguresTableModel.h" + +#include "QmitkMeasurementView.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "mitkNodePredicateDataType.h" +#include "mitkPlanarFigure.h" + +#include +#include +#include +#include + +const std::string QmitkMeasurementView::VIEW_ID = +"org.mitk.views.measurement"; + +QmitkMeasurementView::QmitkMeasurementView() : +m_Parent(0), m_Layout(0), m_DrawActionsToolBar(0), +m_DrawActionsGroup(0), m_MeasurementInfoRenderer(0), +m_MeasurementInfoAnnotation(0), m_SelectedPlanarFigures(0), +m_SelectedImageNode(), +m_LineCounter(0), m_PathCounter(0), +m_AngleCounter(0), m_FourPointAngleCounter(0), m_EllipseCounter(0), + m_RectangleCounter(0), m_PolygonCounter(0), m_Visible(false), + m_CurrentFigureNodeInitialized(false), m_Activated(false), + m_LastRenderWindow(0) +{ + +} + +QmitkMeasurementView::~QmitkMeasurementView() +{ + m_MeasurementInfoRenderer->Delete(); + + this->GetDataStorage()->AddNodeEvent -= mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeAddedInDataStorage ); + + m_SelectedPlanarFigures->NodeChanged.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); + + m_SelectedPlanarFigures->NodeRemoved.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); + + m_SelectedPlanarFigures->PropertyChanged.RemoveListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); + + m_SelectedImageNode->NodeChanged.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); + + m_SelectedImageNode->NodeRemoved.RemoveListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); + + m_SelectedImageNode->PropertyChanged.RemoveListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); + +} + +void QmitkMeasurementView::CreateQtPartControl(QWidget* parent) +{ + m_Parent = parent; + m_MeasurementInfoRenderer = vtkRenderer::New(); + m_MeasurementInfoAnnotation = vtkCornerAnnotation::New(); + vtkTextProperty *textProp = vtkTextProperty::New(); + + m_MeasurementInfoAnnotation->SetMaximumFontSize(12); + textProp->SetColor(1.0, 1.0, 1.0); + m_MeasurementInfoAnnotation->SetTextProperty(textProp); + + m_MeasurementInfoRenderer->AddActor(m_MeasurementInfoAnnotation); + m_DrawActionsToolBar = new QToolBar; + m_DrawActionsGroup = new QActionGroup(this); + m_DrawActionsGroup->setExclusive(true); + + //# add actions + QAction* currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/measurement/line.png"), "Draw Line"); + m_DrawLine = currentAction; + m_DrawLine->setCheckable(true); + m_DrawActionsToolBar->addAction(currentAction); + m_DrawActionsGroup->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ActionDrawLineTriggered(bool) ) ); + + currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/measurement/path.png"), "Draw Path"); + m_DrawPath = currentAction; + m_DrawPath->setCheckable(true); + m_DrawActionsToolBar->addAction(currentAction); + m_DrawActionsGroup->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ActionDrawPathTriggered(bool) ) ); + + currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/measurement/angle.png"), "Draw Angle"); + m_DrawAngle = currentAction; + m_DrawAngle->setCheckable(true); + m_DrawActionsToolBar->addAction(currentAction); + m_DrawActionsGroup->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ActionDrawAngleTriggered(bool) ) ); + + currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/measurement/four-point-angle.png"), "Draw Four Point Angle"); + m_DrawFourPointAngle = currentAction; + m_DrawFourPointAngle->setCheckable(true); + m_DrawActionsToolBar->addAction(currentAction); + m_DrawActionsGroup->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ActionDrawFourPointAngleTriggered(bool) ) ); + + currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/measurement/circle.png"), "Draw Circle"); + m_DrawEllipse = currentAction; + m_DrawEllipse->setCheckable(true); + m_DrawActionsToolBar->addAction(currentAction); + m_DrawActionsGroup->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ActionDrawEllipseTriggered(bool) ) ); + + currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/measurement/rectangle.png"), "Draw Rectangle"); + m_DrawRectangle = currentAction; + m_DrawRectangle->setCheckable(true); + m_DrawActionsToolBar->addAction(currentAction); + m_DrawActionsGroup->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ActionDrawRectangleTriggered(bool) ) ); + + currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/measurement/polygon.png"), "Draw Polygon"); + m_DrawPolygon = currentAction; + m_DrawPolygon->setCheckable(true); + m_DrawActionsToolBar->addAction(currentAction); + m_DrawActionsGroup->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ActionDrawPolygonTriggered(bool) ) ); + + currentAction = m_DrawActionsToolBar->addAction(QIcon( + ":/Qmitk/Images_48.png"), "Reproduce potential bug"); + m_DrawActionsToolBar->addAction(currentAction); + QObject::connect( currentAction, SIGNAL( triggered(bool) ) + , this, SLOT( ReproducePotentialBug(bool) ) ); + + + QLabel* selectedImageLabel = new QLabel("Selected Image: "); + m_SelectedImage = new QLabel; + m_SelectedImage->setStyleSheet("font-weight: bold;"); + m_SelectedPlanarFiguresText = new QTextBrowser; + + m_CopyToClipboard = new QPushButton("Copy to Clipboard"); + QObject::connect( m_CopyToClipboard, SIGNAL( clicked(bool) ) + , this, SLOT( CopyToClipboard(bool) ) ); + + m_Layout = new QGridLayout; + m_Layout->addWidget(selectedImageLabel, 0, 0, 1, 1); + m_Layout->addWidget(m_SelectedImage, 0, 1, 1, 1); + m_Layout->addWidget(m_DrawActionsToolBar, 1, 0, 1, 2); + m_Layout->addWidget(m_SelectedPlanarFiguresText, 2, 0, 1, 2); + m_Layout->addWidget(m_CopyToClipboard, 3, 0, 1, 2); + m_Layout->setRowStretch(0, 1); + m_Layout->setRowStretch(1, 1); + m_Layout->setRowStretch(2, 10); + m_Layout->setRowStretch(3, 1); + m_Layout->setContentsMargins(2, 2, 2, 2); + + parent->setLayout(m_Layout); + + + m_SelectedPlanarFigures = mitk::DataStorageSelection::New(this->GetDataStorage(), false); + + m_SelectedPlanarFigures->NodeChanged.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); + + m_SelectedPlanarFigures->NodeRemoved.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); + + m_SelectedPlanarFigures->PropertyChanged.AddListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); + + m_SelectedImageNode = mitk::DataStorageSelection::New(this->GetDataStorage(), false); + + m_SelectedImageNode->PropertyChanged.AddListener( mitk::MessageDelegate2( this, &QmitkMeasurementView::PropertyChanged ) ); + + m_SelectedImageNode->NodeChanged.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeChanged ) ); + + m_SelectedImageNode->NodeRemoved.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeRemoved ) ); + + this->GetDataStorage()->AddNodeEvent.AddListener( mitk::MessageDelegate1( this, &QmitkMeasurementView::NodeAddedInDataStorage ) ); + +} + +void QmitkMeasurementView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, + const QList &nodes) +{ + if ( nodes.isEmpty() ) return; + + m_SelectedImageNode->RemoveAllNodes(); + + mitk::BaseData* _BaseData; + mitk::PlanarFigure* _PlanarFigure; + mitk::Image* selectedImage; + m_SelectedPlanarFigures->RemoveAllNodes(); + + foreach (mitk::DataNode::Pointer _DataNode, nodes) + { + _PlanarFigure = 0; + + if (!_DataNode) + continue; + + _BaseData = _DataNode->GetData(); + + if (!_BaseData) + continue; + + // planar figure selected + if ((_PlanarFigure = dynamic_cast (_BaseData))) + { + // add to the selected planar figures + m_SelectedPlanarFigures->AddNode(_DataNode); + // take parent image as the selected image + mitk::DataStorage::SetOfObjects::ConstPointer parents = + this->GetDataStorage()->GetSources(_DataNode); + if (parents->size() > 0) + { + mitk::DataNode::Pointer parent = parents->front(); + if ((selectedImage = dynamic_cast (parent->GetData()))) + { + *m_SelectedImageNode = parent; + } + } + + } + else if ((selectedImage = dynamic_cast (_BaseData))) + { + *m_SelectedImageNode = _DataNode; + /*mitk::RenderingManager::GetInstance()->InitializeViews( + selectedImage->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true );*/ + } + } // end for + + this->PlanarFigureSelectionChanged(); +} + +void QmitkMeasurementView::PlanarFigureSelectionChanged() +{ + if ( !this->m_Activated ) return; + + if (m_SelectedImageNode->GetNode().IsNotNull()) + { + mitk::Image* selectedImage = dynamic_cast(m_SelectedImageNode->GetNode()->GetData()); + if(selectedImage && selectedImage->GetDimension() > 3) + { + m_SelectedImageNode->RemoveAllNodes(); + m_SelectedImage->setText( "4D images are not supported." ); + m_DrawActionsToolBar->setEnabled(false); + } + else + { + m_SelectedImage->setText(QString::fromStdString( + m_SelectedImageNode->GetNode()->GetName())); + m_DrawActionsToolBar->setEnabled(true); + } + } + else + { + m_SelectedImage->setText( + "None. Please select an image."); + + m_DrawActionsToolBar->setEnabled(false); + } + + if (m_SelectedPlanarFigures->GetSize() == 0 && this->GetRenderWindowPart() != 0) + { + foreach (QmitkRenderWindow* renderWindow, this->GetRenderWindowPart()->GetRenderWindows().values()) + { + this->SetMeasurementInfoToRenderWindow("", renderWindow); + } + } + + unsigned int j = 1; + mitk::PlanarFigure* _PlanarFigure = 0; + mitk::PlanarAngle* planarAngle = 0; + mitk::PlanarFourPointAngle* planarFourPointAngle = 0; + mitk::DataNode::Pointer node = 0; + m_SelectedPlanarFiguresText->clear(); + QString infoText; + QString plainInfoText; + std::vector nodes = m_SelectedPlanarFigures->GetNodes(); + + for (std::vector::iterator it = nodes.begin(); it + != nodes.end(); ++it, ++j) + { + plainInfoText.clear(); + node = *it; + if(j>1) + infoText.append("
"); + + infoText.append(QString("%1
").arg(QString::fromStdString( + node->GetName()))); + plainInfoText.append(QString("%1").arg(QString::fromStdString( + node->GetName()))); + + _PlanarFigure = dynamic_cast (node->GetData()); + + planarAngle = dynamic_cast (_PlanarFigure); + if(!planarAngle) + { + planarFourPointAngle = dynamic_cast (_PlanarFigure); + } + + if(!_PlanarFigure) + continue; + + double featureQuantity = 0.0; + for (unsigned int i = 0; i < _PlanarFigure->GetNumberOfFeatures(); ++i) + { + if ( !_PlanarFigure->IsFeatureActive( i ) ) continue; + + featureQuantity = _PlanarFigure->GetQuantity(i); + if ((planarAngle && i == planarAngle->FEATURE_ID_ANGLE) + || (planarFourPointAngle && i == planarFourPointAngle->FEATURE_ID_ANGLE)) + featureQuantity = featureQuantity * 180 / vnl_math::pi; + + infoText.append( + QString("%1: %2 %3") .arg(QString( + _PlanarFigure->GetFeatureName(i))) .arg(featureQuantity, 0, 'f', + 2) .arg(QString(_PlanarFigure->GetFeatureUnit(i)))); + + plainInfoText.append( + QString("\n%1: %2 %3") .arg(QString(_PlanarFigure->GetFeatureName(i))) .arg( + featureQuantity, 0, 'f', 2) .arg(QString( + _PlanarFigure->GetFeatureUnit(i)))); + + if(i+1 != _PlanarFigure->GetNumberOfFeatures()) + infoText.append("
"); + } + + if (j != nodes.size()) + infoText.append("
"); + } + + m_SelectedPlanarFiguresText->setHtml(infoText); + + // for the last selected planar figure ... + if (_PlanarFigure) + { + const mitk::PlaneGeometry + * _PlaneGeometry = + dynamic_cast (_PlanarFigure->GetGeometry2D()); + + QmitkRenderWindow* selectedRenderWindow = 0; + bool PlanarFigureInitializedWindow = false; + mitk::IRenderWindowPart* renderPart = this->GetRenderWindowPart(); + if (renderPart) + { + foreach(QmitkRenderWindow* renderWindow, renderPart->GetRenderWindows().values()) + { + if (node->GetBoolProperty("PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + renderWindow->GetRenderer())) + { + selectedRenderWindow = renderWindow; + break; + } + } + } + + // make node visible + if (selectedRenderWindow) + { + mitk::Point3D centerP = _PlaneGeometry->GetOrigin(); + //selectedRenderWindow->GetSliceNavigationController()->ReorientSlices( + //centerP, _PlaneGeometry->GetNormal()); + selectedRenderWindow->GetSliceNavigationController()->SelectSliceByPoint( + centerP); + + // now paint infos also on renderwindow + this->SetMeasurementInfoToRenderWindow(plainInfoText, selectedRenderWindow); + } + } + // no last planarfigure + else + this->SetMeasurementInfoToRenderWindow("", 0); + + this->RequestRenderWindowUpdate(); +} + +void QmitkMeasurementView::NodeAddedInDataStorage(const mitk::DataNode* node) +{ + if(!m_Visible) + return; + mitk::DataNode* nonConstNode = const_cast(node); + mitk::PlanarFigure* figure = dynamic_cast(nonConstNode->GetData()); + if(figure) + { + mitk::PlanarFigureInteractor::Pointer figureInteractor + = dynamic_cast(node->GetInteractor()); + + if(figureInteractor.IsNull()) + figureInteractor = mitk::PlanarFigureInteractor::New("PlanarFigureInteractor", nonConstNode); + + // remove old interactor if present + if( m_CurrentFigureNode.IsNotNull() && m_CurrentFigureNodeInitialized == false ) + { + mitk::Interactor::Pointer oldInteractor = m_CurrentFigureNode->GetInteractor(); + if(oldInteractor.IsNotNull()) + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(oldInteractor); + + this->GetDataStorage()->Remove(m_CurrentFigureNode); + } + + mitk::GlobalInteraction::GetInstance()->AddInteractor(figureInteractor); + } +} + + +void QmitkMeasurementView::PlanarFigureInitialized() +{ + if(m_CurrentFigureNode.IsNull()) + return; + + m_CurrentFigureNodeInitialized = true; + + this->PlanarFigureSelectionChanged(); + + m_DrawLine->setChecked(false); + m_DrawPath->setChecked(false); + m_DrawAngle->setChecked(false); + m_DrawFourPointAngle->setChecked(false); + m_DrawEllipse->setChecked(false); + m_DrawRectangle->setChecked(false); + m_DrawPolygon->setChecked(false); + // enable the crosshair navigation + this->EnableCrosshairNavigation(); +} + + +void QmitkMeasurementView::PlanarFigureSelected( itk::Object* object, const itk::EventObject& /*event*/ ) +{ + // Mark to-be-edited PlanarFigure as selected + mitk::PlanarFigure* figure = dynamic_cast< mitk::PlanarFigure* >( object ); + if ( figure != NULL ) + { + // Get node corresponding to PlanarFigure + mitk::DataNode::Pointer figureNode = this->GetDataStorage()->GetNode( + mitk::NodePredicateData::New( figure ) ); + + // Select this node (and deselect all others) + QList< mitk::DataNode::Pointer > selectedNodes = this->GetDataManagerSelection(); + for ( int i = 0; i < selectedNodes.size(); i++ ) + { + selectedNodes[i]->SetSelected( false ); + } + std::vector< mitk::DataNode* > selectedNodes2 = m_SelectedPlanarFigures->GetNodes(); + for ( unsigned int i = 0; i < selectedNodes2.size(); i++ ) + { + selectedNodes2[i]->SetSelected( false ); + } + figureNode->SetSelected( true ); + + m_CurrentFigureNode = figureNode; + + *m_SelectedPlanarFigures = figureNode; + + // Re-initialize after selecting new PlanarFigure + this->PlanarFigureSelectionChanged(); + } +} + + +mitk::DataNode::Pointer QmitkMeasurementView::DetectTopMostVisibleImage() +{ + // get all images from the data storage + mitk::DataStorage::SetOfObjects::ConstPointer Images = this->GetDataStorage()->GetSubset( mitk::NodePredicateDataType::New("Image") ); + + mitk::DataNode::Pointer currentNode( m_SelectedImageNode->GetNode() ); + int maxLayer = itk::NumericTraits::min(); + + // iterate over selection + for (mitk::DataStorage::SetOfObjects::ConstIterator sofIt = Images->Begin(); sofIt != Images->End(); ++sofIt) + { + mitk::DataNode::Pointer node = sofIt->Value(); + if ( node.IsNull() ) + continue; + if (node->IsVisible(NULL) == false) + continue; + int layer = 0; + node->GetIntProperty("layer", layer); + if ( layer < maxLayer ) + continue; + + currentNode = node; + } + + return currentNode; +} + +void QmitkMeasurementView::AddFigureToDataStorage(mitk::PlanarFigure* figure, const QString& name, + const char *propertyKey, mitk::BaseProperty *property ) +{ + if ( m_CurrentFigureNode.IsNotNull() ) + { + m_CurrentFigureNode->GetData()->RemoveObserver( m_EndPlacementObserverTag ); + } + + mitk::DataNode::Pointer newNode = mitk::DataNode::New(); + newNode->SetName(name.toStdString()); + newNode->SetData(figure); + + // Add custom property, if available + if ( (propertyKey != NULL) && (property != NULL) ) + { + newNode->AddProperty( propertyKey, property ); + } + + // add observer for event when figure has been placed + typedef itk::SimpleMemberCommand< QmitkMeasurementView > SimpleCommandType; + SimpleCommandType::Pointer initializationCommand = SimpleCommandType::New(); + initializationCommand->SetCallbackFunction( this, &QmitkMeasurementView::PlanarFigureInitialized ); + m_EndPlacementObserverTag = figure->AddObserver( mitk::EndPlacementPlanarFigureEvent(), initializationCommand ); + + // add observer for event when figure is picked (selected) + typedef itk::MemberCommand< QmitkMeasurementView > MemberCommandType; + MemberCommandType::Pointer selectCommand = MemberCommandType::New(); + selectCommand->SetCallbackFunction( this, &QmitkMeasurementView::PlanarFigureSelected ); + m_SelectObserverTag = figure->AddObserver( mitk::SelectPlanarFigureEvent(), selectCommand ); + + // add observer for event when interaction with figure starts + SimpleCommandType::Pointer startInteractionCommand = SimpleCommandType::New(); + startInteractionCommand->SetCallbackFunction( this, &QmitkMeasurementView::DisableCrosshairNavigation); + m_StartInteractionObserverTag = figure->AddObserver( mitk::StartInteractionPlanarFigureEvent(), startInteractionCommand ); + + // add observer for event when interaction with figure starts + SimpleCommandType::Pointer endInteractionCommand = SimpleCommandType::New(); + endInteractionCommand->SetCallbackFunction( this, &QmitkMeasurementView::EnableCrosshairNavigation); + m_EndInteractionObserverTag = figure->AddObserver( mitk::EndInteractionPlanarFigureEvent(), endInteractionCommand ); + + + // figure drawn on the topmost layer / image + this->GetDataStorage()->Add(newNode, this->DetectTopMostVisibleImage() ); + QList selectedNodes = GetDataManagerSelection(); + for(int i = 0; i < selectedNodes.size(); i++) + { + selectedNodes[i]->SetSelected(false); + } + std::vector selectedNodes2 = m_SelectedPlanarFigures->GetNodes(); + for(unsigned int i = 0; i < selectedNodes2.size(); i++) + { + selectedNodes2[i]->SetSelected(false); + } + newNode->SetSelected(true); + + + m_CurrentFigureNodeInitialized = false; + m_CurrentFigureNode = newNode; + + *m_SelectedPlanarFigures = newNode; + + this->RequestRenderWindowUpdate(); +} + +bool QmitkMeasurementView::AssertDrawingIsPossible(bool checked) +{ + if (m_SelectedImageNode->GetNode().IsNull()) + { + checked = false; + this->HandleException("Please select an image!", this->m_Parent, true); + m_DrawLine->setChecked(false); + return false; + } + + mitk::ILinkedRenderWindowPart* linkedRenderWindow = + dynamic_cast(this->GetRenderWindowPart()); + if (linkedRenderWindow) + { + linkedRenderWindow->EnableSlicingPlanes(false); + } + // disable the crosshair navigation during the drawing + this->DisableCrosshairNavigation(); + + return checked; +} + +void QmitkMeasurementView::ActionDrawLineTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + mitk::PlanarLine::Pointer figure = mitk::PlanarLine::New(); + QString qString; + if(m_CurrentFigureNode.IsNull() || m_LineCounter == 0 || m_CurrentFigureNodeInitialized){ + qString = QString("Line%1").arg(++m_LineCounter); + } + else{ + qString = QString("Line%1").arg(m_LineCounter); + } + this->AddFigureToDataStorage(figure, qString); + + MITK_INFO << "PlanarLine initialized..."; +} + +void QmitkMeasurementView::ActionDrawPathTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + mitk::PlanarPolygon::Pointer figure = mitk::PlanarPolygon::New(); + figure->ClosedOff(); + + mitk::BoolProperty::Pointer closedProperty = mitk::BoolProperty::New( false ); + + QString qString; + if(m_CurrentFigureNode.IsNull() || m_PathCounter == 0 || m_CurrentFigureNodeInitialized){ + qString = QString("Path%1").arg(++m_PathCounter); + } + else{ + qString = QString("Path%1").arg(m_PathCounter); + } + this->AddFigureToDataStorage(figure, qString, + "ClosedPlanarPolygon", closedProperty); + + MITK_INFO << "PlanarPath initialized..."; +} + +void QmitkMeasurementView::ActionDrawAngleTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + mitk::PlanarAngle::Pointer figure = mitk::PlanarAngle::New(); + QString qString; + if(m_CurrentFigureNode.IsNull() || m_AngleCounter == 0 || m_CurrentFigureNodeInitialized){ + qString = QString("Angle%1").arg(++m_AngleCounter); + } + else{ + qString = QString("Angle%1").arg(m_AngleCounter); + } + this->AddFigureToDataStorage(figure, qString); + + MITK_INFO << "PlanarAngle initialized..."; +} + +void QmitkMeasurementView::ActionDrawFourPointAngleTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + mitk::PlanarFourPointAngle::Pointer figure = + mitk::PlanarFourPointAngle::New(); + QString qString; + if(m_CurrentFigureNode.IsNull() || m_FourPointAngleCounter == 0 || m_CurrentFigureNodeInitialized){ + qString = QString("Four Point Angle%1").arg(++m_FourPointAngleCounter); + } + else{ + qString = QString("Four Point Angle%1").arg(m_FourPointAngleCounter); + } + this->AddFigureToDataStorage(figure, qString); + + MITK_INFO << "PlanarFourPointAngle initialized..."; +} + +void QmitkMeasurementView::ActionDrawEllipseTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + mitk::PlanarCircle::Pointer figure = mitk::PlanarCircle::New(); + QString qString; + if(m_CurrentFigureNode.IsNull() || m_EllipseCounter == 0 || m_CurrentFigureNodeInitialized){ + qString = QString("Circle%1").arg(++m_EllipseCounter); + } + else{ + qString = QString("Circle%1").arg(m_EllipseCounter); + } + this->AddFigureToDataStorage(figure, qString); + + MITK_INFO << "PlanarCircle initialized..."; +} + +void QmitkMeasurementView::ActionDrawRectangleTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + mitk::PlanarRectangle::Pointer figure = mitk::PlanarRectangle::New(); + QString qString; + if(m_CurrentFigureNode.IsNull() || m_RectangleCounter == 0 || m_CurrentFigureNodeInitialized){ + qString = QString("Rectangle%1").arg(++m_RectangleCounter); + } + else{ + qString = QString("Rectangle%1").arg(m_RectangleCounter); + } + this->AddFigureToDataStorage(figure, qString); + + MITK_INFO << "PlanarRectangle initialized..."; +} + +void QmitkMeasurementView::ActionDrawPolygonTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + mitk::PlanarPolygon::Pointer figure = mitk::PlanarPolygon::New(); + figure->ClosedOn(); + QString qString; + if(m_CurrentFigureNode.IsNull() || m_PolygonCounter == 0 || m_CurrentFigureNodeInitialized){ + qString = QString("Polygon%1").arg(++m_PolygonCounter); + } + else{ + qString = QString("Polygon%1").arg(m_PolygonCounter); + } + this->AddFigureToDataStorage(figure, qString); + + MITK_INFO << "PlanarPolygon initialized..."; +} + +void QmitkMeasurementView::ActionDrawArrowTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + MITK_WARN << "Draw Arrow not implemented yet."; +} + +void QmitkMeasurementView::ActionDrawTextTriggered(bool checked) +{ + if(!this->AssertDrawingIsPossible(checked)) + return; + + MITK_WARN << "Draw Text not implemented yet."; +} + +void QmitkMeasurementView::Activated() +{ + m_Activated = true; + MITK_INFO << "QmitkMeasurementView::Activated"; + + if (mitk::ILinkedRenderWindowPart* linkedRenderWindow = + dynamic_cast(this->GetRenderWindowPart())) + { + linkedRenderWindow->EnableSlicingPlanes(false); + } + + mitk::TNodePredicateDataType::Pointer isPlanarFigure + = mitk::TNodePredicateDataType::New(); + + mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = this->GetDataStorage()->GetAll(); + mitk::DataNode* node = 0; + mitk::PlanarFigure* figure = 0; + mitk::PlanarFigureInteractor::Pointer figureInteractor = 0; + // finally add all nodes to the model + for(mitk::DataStorage::SetOfObjects::ConstIterator it=_NodeSet->Begin(); it!=_NodeSet->End() + ; it++) + { + node = const_cast(it->Value().GetPointer()); + figure = dynamic_cast(node->GetData()); + if(figure) + { + figureInteractor = dynamic_cast(node->GetInteractor()); + + if(figureInteractor.IsNull()) + figureInteractor = mitk::PlanarFigureInteractor::New("PlanarFigureInteractor", node); + + mitk::GlobalInteraction::GetInstance()->AddInteractor(figureInteractor); + } + } + + m_Visible = true; + +} + +void QmitkMeasurementView::Deactivated() +{ + MITK_INFO << "QmitkMeasurementView::Deactivated"; +} + +void QmitkMeasurementView::ActivatedZombieView(berry::IWorkbenchPartReference::Pointer /*newZombiePart*/) +{ + if (mitk::ILinkedRenderWindowPart* linkedRenderWindow = + dynamic_cast(this->GetRenderWindowPart())) + { + linkedRenderWindow->EnableSlicingPlanes(true); + } + + this->SetMeasurementInfoToRenderWindow("", m_LastRenderWindow); + this->EnableCrosshairNavigation(); + + mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = this->GetDataStorage()->GetAll(); + mitk::DataNode* node = 0; + mitk::PlanarFigure* figure = 0; + mitk::PlanarFigureInteractor::Pointer figureInteractor = 0; + // finally add all nodes to the model + for(mitk::DataStorage::SetOfObjects::ConstIterator it=_NodeSet->Begin(); it!=_NodeSet->End() + ; it++) + { + node = const_cast(it->Value().GetPointer()); + figure = dynamic_cast(node->GetData()); + if(figure) + { + + figure->RemoveAllObservers(); + figureInteractor = dynamic_cast(node->GetInteractor()); + + if(figureInteractor) + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(figureInteractor); + } + } + + m_Activated = false; +} + +void QmitkMeasurementView::Visible() +{ + m_Visible = true; + MITK_INFO << "QmitkMeasurementView::Visible"; +} + +void QmitkMeasurementView::Hidden() +{ + m_Visible = false; + MITK_INFO << "QmitkMeasurementView::Hidden"; +} + +void QmitkMeasurementView::PropertyChanged(const mitk::DataNode* /*node*/, const mitk::BaseProperty* /*prop*/) +{ + this->PlanarFigureSelectionChanged(); +} + +void QmitkMeasurementView::NodeChanged(const mitk::DataNode* /*node*/) +{ + this->PlanarFigureSelectionChanged(); +} + +void QmitkMeasurementView::NodeRemoved(const mitk::DataNode* /*node*/) +{ + this->PlanarFigureSelectionChanged(); +} + +void QmitkMeasurementView::CopyToClipboard(bool) +{ + std::vector headerRow; + std::vector > rows; + QString featureName; + QString featureQuantity; + std::vector newRow; + headerRow.push_back("Name"); + + std::vector nodes = m_SelectedPlanarFigures->GetNodes(); + + for (std::vector::iterator it = nodes.begin(); it + != nodes.end(); ++it) + { + mitk::PlanarFigure* planarFigure = + dynamic_cast ((*it)->GetData()); + if (!planarFigure) + continue; + + newRow.clear(); + newRow.push_back(QString::fromStdString((*it)->GetName())); + newRow.resize(headerRow.size()); + for (unsigned int i = 0; i < planarFigure->GetNumberOfFeatures(); ++i) + { + if ( !planarFigure->IsFeatureActive( i ) ) continue; + + featureName = planarFigure->GetFeatureName(i); + featureName.append(QString(" [%1]").arg(planarFigure->GetFeatureUnit(i))); + std::vector::iterator itColumn = std::find(headerRow.begin(), + headerRow.end(), featureName); + + featureQuantity + = QString("%1").arg(planarFigure->GetQuantity(i)).replace(QChar('.'), + ","); + if (itColumn == headerRow.end()) + { + headerRow.push_back(featureName); + newRow.push_back(featureQuantity); + } else + { + newRow[std::distance(headerRow.begin(), itColumn)] = featureQuantity; + } + + } + rows.push_back(newRow); + } + + QString clipboardText; + for (std::vector::iterator it = headerRow.begin(); it + != headerRow.end(); ++it) + clipboardText.append(QString("%1 \t").arg(*it)); + + for (std::vector >::iterator it = rows.begin(); it + != rows.end(); ++it) + { + clipboardText.append("\n"); + for (std::vector::iterator it2 = (*it).begin(); it2 != (*it).end(); ++it2) + { + clipboardText.append(QString("%1 \t").arg(*it2)); + } + } + + QApplication::clipboard()->setText(clipboardText, QClipboard::Clipboard); + +} + +void QmitkMeasurementView::SetMeasurementInfoToRenderWindow(const QString& text, + QmitkRenderWindow* _RenderWindow) +{ + if(m_LastRenderWindow != _RenderWindow) + { + + if(m_LastRenderWindow) + { + QObject::disconnect( m_LastRenderWindow, SIGNAL( destroyed(QObject*) ) + , this, SLOT( OnRenderWindowDelete(QObject*) ) ); + } + m_LastRenderWindow = _RenderWindow; + if(m_LastRenderWindow) + { + QObject::connect( m_LastRenderWindow, SIGNAL( destroyed(QObject*) ) + , this, SLOT( OnRenderWindowDelete(QObject*) ) ); + } + } + + if(m_LastRenderWindow) + { + if (!text.isEmpty() && m_SelectedPlanarFigures->GetNode()->IsSelected()) + { + m_MeasurementInfoAnnotation->SetText(1, text.toLatin1().data()); + mitk::VtkLayerController::GetInstance(m_LastRenderWindow->GetRenderWindow())->InsertForegroundRenderer( + m_MeasurementInfoRenderer, true); + } + else + { + if (mitk::VtkLayerController::GetInstance( + m_LastRenderWindow->GetRenderWindow()) ->IsRendererInserted( + m_MeasurementInfoRenderer)) + mitk::VtkLayerController::GetInstance(m_LastRenderWindow->GetRenderWindow())->RemoveRenderer( + m_MeasurementInfoRenderer); + } + } +} + +void QmitkMeasurementView::EnableCrosshairNavigation() +{ + // enable the crosshair navigation + if (mitk::ILinkedRenderWindowPart* linkedRenderWindow = + dynamic_cast(this->GetRenderWindowPart())) + { + linkedRenderWindow->EnableLinkedNavigation(true); + } +} + +void QmitkMeasurementView::DisableCrosshairNavigation() +{ + // disable the crosshair navigation during the drawing + if (mitk::ILinkedRenderWindowPart* linkedRenderWindow = + dynamic_cast(this->GetRenderWindowPart())) + { + linkedRenderWindow->EnableLinkedNavigation(false); + } +} + +void QmitkMeasurementView::SetFocus() +{ + +} + +void QmitkMeasurementView::OnRenderWindowDelete(QObject * obj) +{ + if(obj == m_LastRenderWindow) + m_LastRenderWindow = 0; +} + +void QmitkMeasurementView::ReproducePotentialBug(bool) +{ + std::vector nodes = m_SelectedPlanarFigures->GetNodes(); + QString output; + + for (std::vector::iterator it = nodes.begin(); it + != nodes.end(); ++it) + { + mitk::DataNode* node = *it; + if (!node) continue; + + mitk::PlanarFigure* pf = dynamic_cast( node->GetData() ); + if (!pf) continue; + + output.append("huhu"); + output.append( QString::fromStdString( node->GetName() ) ); + + /** + Bug reproduction: + + 1. get geometry of planar figure from object + + 2. use this geometry to initialize rendering manager via InitializeViews + + 3. see what is produced. the DisplayGeometry of the render window will NOT contain the planar figure nicely. + + */ + + mitk::PlaneGeometry::Pointer planarFigureGeometry = dynamic_cast( pf->GetGeometry() ); + if (planarFigureGeometry.IsNull()) continue; // not expected + + + mitk::PlaneGeometry::Pointer geometryForRendering = dynamic_cast( planarFigureGeometry->Clone().GetPointer() ); + + bool applyWorkaround(true); + geometryForRendering->SetImageGeometry( applyWorkaround ); + + + std::cout << "==== with" << (applyWorkaround?"":"OUT") << " workaround ====================================" << std::endl; + std::cout << "--- PlanarFigure geometry --------------" << std::endl; + planarFigureGeometry->Print(std::cout); + std::cout << "----------------------------------------" << std::endl; + + mitk::RenderingManager::GetInstance()->InitializeViews( geometryForRendering, mitk::RenderingManager::REQUEST_UPDATE_ALL, false ); + + QmitkRenderWindow* renderWindow = this->GetRenderWindowPart()->GetRenderWindows().values().front(); + if (renderWindow == 0) + { + std::cout << "** No QmitkkRenderWindow available **" << std::endl; + return; + } + + std::cout << "--- Renderer->GetDisplayGeometry() ------------" << std::endl; + + renderWindow->GetRenderer()->GetDisplayGeometry()->Print(std::cout); + std::cout << "--- Renderer->GetCurrentWorldGeometry2D() -----" << std::endl; + renderWindow->GetRenderer()->GetCurrentWorldGeometry2D()->Print(std::cout); + std::cout << "--- Renderer->GetWorldGeometry() --------------" << std::endl; + renderWindow->GetRenderer()->GetWorldGeometry()->Print(std::cout); + } + + m_SelectedPlanarFiguresText->setText(output); + +} + diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.h b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.h new file mode 100644 index 0000000000..e321d8d3d5 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.h @@ -0,0 +1,222 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 15412 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITK_MEASUREMENT_H__INCLUDED +#define QMITK_MEASUREMENT_H__INCLUDED + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +class QmitkPlanarFiguresTableModel; +class QGridLayout; +class QMainWindow; +class QToolBar; +class QLabel; +class QTableView; +class QTextBrowser; +class QActionGroup; +class QPushButton; + +class vtkRenderer; +class vtkCornerAnnotation; + + +/// +/// A view for doing measurements in digital images by means of +/// mitk::Planarfigures which can represent drawing primitives (Lines, circles, ...). +/// The view consists of only three main elements: +/// 1. A toolbar for activating PlanarFigure drawing +/// 2. A textbrowser which shows details for the selected PlanarFigures +/// 3. A button for copying all details to the clipboard +/// +class QmitkMeasurementView : public QmitkAbstractView, public mitk::IZombieViewPart +{ + Q_OBJECT + + public: + /// + /// Just a shortcut + /// + typedef std::vector DataNodes; + + /// + /// Initialize pointers to 0. The rest is done in CreateQtPartControl() + /// + QmitkMeasurementView(); + + /// + /// Remove all event listener from DataStorage, DataStorageSelection, Selection Service + /// + virtual ~QmitkMeasurementView(); + + static const std::string VIEW_ID; + + public: + /// + /// Initializes all variables. + /// Builds up GUI. + /// + void CreateQtPartControl(QWidget* parent); + /// + /// Set widget planes visibility to false. + /// Show only transversal view. + /// Add an interactor to all PlanarFigures in the DataStorage (if they dont have one yet). + /// Add their interactor to the global interaction. + /// + virtual void Activated(); + + virtual void Deactivated(); + + virtual void Visible(); + virtual void Hidden(); + + /// + /// Show widget planes and all renderwindows again. + /// Remove all planar figure interactors from the global interaction. + /// + virtual void ActivatedZombieView(berry::IWorkbenchPartReference::Pointer zombieView); + /// + /// Invoked from a DataStorage selection + /// + virtual void NodeChanged(const mitk::DataNode* node); + virtual void PropertyChanged(const mitk::DataNode* node, const mitk::BaseProperty* prop); + virtual void NodeRemoved(const mitk::DataNode* node); + virtual void NodeAddedInDataStorage(const mitk::DataNode* node); + virtual void PlanarFigureInitialized(); + virtual void PlanarFigureSelected( itk::Object* object, const itk::EventObject& event ); + virtual void AddFigureToDataStorage(mitk::PlanarFigure* figure, const QString& name, + const char *propertyKey = NULL, mitk::BaseProperty *property = NULL ); + + /// + /// Invoked when the DataManager selection changed. + /// If an image is in the selection it will be set as the selected one for measurement, + /// If a planarfigure is in the selection its parent image will be set as the selected one for measurement. + /// All selected planarfigures will be added to m_SelectedPlanarFigures. + /// Then PlanarFigureSelectionChanged is called + /// + virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes); + + public slots: + /// + /// Called when the renderwindow gets deleted + /// + void OnRenderWindowDelete(QObject * obj = 0); + + protected: + /// + /// Prints all features of the selected PlanarFigures into the TextBrowser. + /// For the last figure in the selection list: + /// - Go to the corresponding slice and show figure + /// - Draw info text on the bottom right side of the corresponding renderwindow + /// + void PlanarFigureSelectionChanged(); + /// Draws a string on the bottom left side of the render window + /// + void SetMeasurementInfoToRenderWindow(const QString& text, QmitkRenderWindow* _RenderWindow); + + bool AssertDrawingIsPossible(bool checked); + + void EnableCrosshairNavigation(); + void DisableCrosshairNavigation(); + + void SetFocus(); + + protected slots: + ///# draw actions + void ActionDrawLineTriggered( bool checked = false ); + void ActionDrawPathTriggered( bool checked = false ); + void ActionDrawAngleTriggered( bool checked = false ); + void ActionDrawFourPointAngleTriggered( bool checked = false ); + void ActionDrawEllipseTriggered( bool checked = false ); + void ActionDrawRectangleTriggered( bool checked = false ); + void ActionDrawPolygonTriggered( bool checked = false ); + void ActionDrawArrowTriggered( bool checked = false ); + void ActionDrawTextTriggered( bool checked = false ); + void CopyToClipboard( bool checked = false ); + + void ReproducePotentialBug(bool); + // fields + // widgets +protected: + QWidget* m_Parent; + QGridLayout* m_Layout; + QLabel* m_SelectedImage; + QAction* m_DrawLine; + QAction* m_DrawPath; + QAction* m_DrawAngle; + QAction* m_DrawFourPointAngle; + QAction* m_DrawEllipse; + QAction* m_DrawRectangle; + QAction* m_DrawPolygon; + QToolBar* m_DrawActionsToolBar; + QActionGroup* m_DrawActionsGroup; + QTextBrowser* m_SelectedPlanarFiguresText; + QPushButton* m_CopyToClipboard; + vtkRenderer * m_MeasurementInfoRenderer; + vtkCornerAnnotation *m_MeasurementInfoAnnotation; + + // Selection service + /// berry::SelectionChangedAdapter must be a friend to call + friend struct berry::SelectionChangedAdapter; + berry::ISelectionListener::Pointer m_SelectionListener; + + mitk::DataStorageSelection::Pointer m_SelectedPlanarFigures; + /// Selected image on which measurements will be performed + /// + mitk::DataStorageSelection::Pointer m_SelectedImageNode; + mitk::DataNode::Pointer m_CurrentFigureNode; + + /// Counter variables to give a newly created Figure a unique name. + /// + unsigned int m_LineCounter; + unsigned int m_PathCounter; + unsigned int m_AngleCounter; + unsigned int m_FourPointAngleCounter; + unsigned int m_EllipseCounter; + unsigned int m_RectangleCounter; + unsigned int m_PolygonCounter; + unsigned int m_EndPlacementObserverTag; + unsigned int m_SelectObserverTag; + unsigned int m_StartInteractionObserverTag; + unsigned int m_EndInteractionObserverTag; + bool m_Visible; + bool m_CurrentFigureNodeInitialized; + bool m_Activated; + + /// + /// Saves the last renderwindow any info data was inserted + /// + QmitkRenderWindow* m_LastRenderWindow; + + private: + mitk::DataNode::Pointer DetectTopMostVisibleImage(); + +}; + +#endif // QMITK_MEASUREMENT_H__INCLUDED diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.cpp b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.cpp rename to Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.h b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.h rename to Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkPlanarFiguresTableModel.h diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/CMakeLists.txt b/Plugins/org.mitk.gui.qt.moviemaker/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.moviemaker/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerControlArea.png b/Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerControlArea.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerControlArea.png rename to Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerControlArea.png diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerUserManual.dox b/Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerUserManual.dox rename to Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/QmitkMovieMakerUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.png b/Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.png rename to Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.xpm rename to Plugins/org.mitk.gui.qt.moviemaker/documentation/UserManual/icon.xpm diff --git a/Plugins/org.mitk.gui.qt.moviemaker/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.moviemaker/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..07f1421b2a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.moviemaker/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_moviemaker org.mitk.gui.qt.moviemaker + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_moviemaker_internal Internal + \ingroup org_mitk_gui_qt_moviemaker + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.moviemaker plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/files.cmake b/Plugins/org.mitk.gui.qt.moviemaker/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/files.cmake rename to Plugins/org.mitk.gui.qt.moviemaker/files.cmake diff --git a/Plugins/org.mitk.gui.qt.moviemaker/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.moviemaker/manifest_headers.cmake new file mode 100644 index 0000000000..33c96b326e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.moviemaker/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Movie Maker") +set(Plugin-Version "0.9") +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 diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/plugin.xml b/Plugins/org.mitk.gui.qt.moviemaker/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/plugin.xml rename to Plugins/org.mitk.gui.qt.moviemaker/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMaker.qrc b/Plugins/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMaker.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMaker.qrc rename to Plugins/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMaker.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerClasses.png b/Plugins/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerClasses.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerClasses.png rename to Plugins/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerClasses.png diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerGUI.png b/Plugins/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerGUI.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerGUI.png rename to Plugins/org.mitk.gui.qt.moviemaker/resources/QmitkMovieMakerGUI.png diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/icon.xpm b/Plugins/org.mitk.gui.qt.moviemaker/resources/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/icon.xpm rename to Plugins/org.mitk.gui.qt.moviemaker/resources/icon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/pause.xpm b/Plugins/org.mitk.gui.qt.moviemaker/resources/pause.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/pause.xpm rename to Plugins/org.mitk.gui.qt.moviemaker/resources/pause.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/play.xpm b/Plugins/org.mitk.gui.qt.moviemaker/resources/play.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/play.xpm rename to Plugins/org.mitk.gui.qt.moviemaker/resources/play.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/screenshot_maker.png b/Plugins/org.mitk.gui.qt.moviemaker/resources/screenshot_maker.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/screenshot_maker.png rename to Plugins/org.mitk.gui.qt.moviemaker/resources/screenshot_maker.png diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/stop.xpm b/Plugins/org.mitk.gui.qt.moviemaker/resources/stop.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/resources/stop.xpm rename to Plugins/org.mitk.gui.qt.moviemaker/resources/stop.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.cpp b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.cpp rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.h b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.h rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMaker.h diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMakerControls.ui b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMakerControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMakerControls.ui rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkMovieMakerControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.cpp b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.cpp rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.h b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.h rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMaker.h diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMakerControls.ui b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMakerControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMakerControls.ui rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/QmitkScreenshotMakerControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.cpp b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.h b/Plugins/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.h rename to Plugins/org.mitk.gui.qt.moviemaker/src/internal/mitkMovieMakerPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/CMakeLists.txt b/Plugins/org.mitk.gui.qt.pointsetinteraction/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.pointsetinteraction/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/AddPointSet.png b/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/AddPointSet.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/AddPointSet.png rename to Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/AddPointSet.png diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/CurrentPointSetArea.png b/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/CurrentPointSetArea.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/CurrentPointSetArea.png rename to Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/CurrentPointSetArea.png diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteraction.png b/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteraction.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteraction.png rename to Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteraction.png diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteractionUserManual.dox b/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteractionUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteractionUserManual.dox rename to Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/QmitkPointSetInteractionUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/pointset_interaction.png b/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/pointset_interaction.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/pointset_interaction.png rename to Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/UserManual/pointset_interaction.png diff --git a/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..cf8de9ef8c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pointsetinteraction/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_pointsetinteraction org.mitk.gui.qt.pointsetinteraction + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_pointsetinteraction_internal Internal + \ingroup org_mitk_gui_qt_pointsetinteraction + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.pointsetinteraction plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/files.cmake b/Plugins/org.mitk.gui.qt.pointsetinteraction/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/files.cmake rename to Plugins/org.mitk.gui.qt.pointsetinteraction/files.cmake diff --git a/Plugins/org.mitk.gui.qt.pointsetinteraction/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.pointsetinteraction/manifest_headers.cmake new file mode 100644 index 0000000000..71e38a204d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.pointsetinteraction/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Pointset Interaction") +set(Plugin-Version "0.9") +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 diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/plugin.xml b/Plugins/org.mitk.gui.qt.pointsetinteraction/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/plugin.xml rename to Plugins/org.mitk.gui.qt.pointsetinteraction/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/resources/QmitkPointSetInteractionView.qrc b/Plugins/org.mitk.gui.qt.pointsetinteraction/resources/QmitkPointSetInteractionView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/resources/QmitkPointSetInteractionView.qrc rename to Plugins/org.mitk.gui.qt.pointsetinteraction/resources/QmitkPointSetInteractionView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/resources/pointset_interaction.png b/Plugins/org.mitk.gui.qt.pointsetinteraction/resources/pointset_interaction.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/resources/pointset_interaction.png rename to Plugins/org.mitk.gui.qt.pointsetinteraction/resources/pointset_interaction.png diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cmake b/Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cmake rename to Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cmake diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cpp b/Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cpp rename to Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.h b/Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.h rename to Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionViewControls.ui b/Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionViewControls.ui rename to Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/QmitkPointSetInteractionViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.pointsetinteraction/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/CMakeLists.txt b/Plugins/org.mitk.gui.qt.python.console/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.python.console/CMakeLists.txt diff --git a/Plugins/org.mitk.gui.qt.python.console/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.python.console/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..d846545dc4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.python.console/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_python_console org.mitk.gui.qt.python.console + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_python_console_internal Internal + \ingroup org_mitk_gui_qt_python_console + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.python.console plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/files.cmake b/Plugins/org.mitk.gui.qt.python.console/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/files.cmake rename to Plugins/org.mitk.gui.qt.python.console/files.cmake diff --git a/Plugins/org.mitk.gui.qt.python.console/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.python.console/manifest_headers.cmake new file mode 100644 index 0000000000..b03312206e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.python.console/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Python Console") +set(Plugin-Version "0.9") +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 diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/mitkPythonPath.h.in b/Plugins/org.mitk.gui.qt.python.console/mitkPythonPath.h.in similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/mitkPythonPath.h.in rename to Plugins/org.mitk.gui.qt.python.console/mitkPythonPath.h.in diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/plugin.xml b/Plugins/org.mitk.gui.qt.python.console/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/plugin.xml rename to Plugins/org.mitk.gui.qt.python.console/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/resources/QmitkPythonConsoleView.qrc b/Plugins/org.mitk.gui.qt.python.console/resources/QmitkPythonConsoleView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/resources/QmitkPythonConsoleView.qrc rename to Plugins/org.mitk.gui.qt.python.console/resources/QmitkPythonConsoleView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/resources/icon.xpm b/Plugins/org.mitk.gui.qt.python.console/resources/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/resources/icon.xpm rename to Plugins/org.mitk.gui.qt.python.console/resources/icon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/resources/py.png b/Plugins/org.mitk.gui.qt.python.console/resources/py.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/resources/py.png rename to Plugins/org.mitk.gui.qt.python.console/resources/py.png diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkCTKPythonShell.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistory.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonCommandHistoryTreeWidget.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleViewControls.ui b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleViewControls.ui rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonConsoleViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.ui b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.ui rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonEditor.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonMediator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonPerspective.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditor.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonScriptEditorHighlighter.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.ui b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.ui rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonSnippets.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonTextEditor.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.ui b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.ui rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStack.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/QmitkPythonVariableStackTreeWidget.h diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.python.console/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/CMakeLists.txt b/Plugins/org.mitk.gui.qt.registration/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.registration/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/DisplayOptionsPointBased.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/DisplayOptionsPointBased.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/DisplayOptionsPointBased.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/DisplayOptionsPointBased.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/FixedDataPointBased.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/FixedDataPointBased.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/FixedDataPointBased.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/FixedDataPointBased.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/ImageArea.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/ImageArea.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/ImageArea.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/ImageArea.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/ImageSelectionDeformable.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/ImageSelectionDeformable.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/ImageSelectionDeformable.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/ImageSelectionDeformable.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/ManualRegistrationArea.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/ManualRegistrationArea.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/ManualRegistrationArea.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/ManualRegistrationArea.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/MovingDataPointBased.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/MovingDataPointBased.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/MovingDataPointBased.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/MovingDataPointBased.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.xpm b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.xpm rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration_small.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration_small.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration_small.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/PointBasedRegistration_small.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistrationUserManual.dox b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistrationUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistrationUserManual.dox rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistrationUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration_small.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration_small.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration_small.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkDeformableRegistration_small.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistration.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistration.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistration.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistration.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistrationUserManual.dox b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistrationUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistrationUserManual.dox rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkPointBasedRegistrationUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkRigidRegistrationUserManual.dox b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkRigidRegistrationUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/QmitkRigidRegistrationUserManual.dox rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/QmitkRigidRegistrationUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationArea.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationArea.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationArea.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationArea.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationDeformable.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationDeformable.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationDeformable.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationDeformable.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationModuleOverview.dox b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationModuleOverview.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationModuleOverview.dox rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationModuleOverview.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationPointBased.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationPointBased.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationPointBased.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RegistrationPointBased.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.xpm b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.xpm rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration_small.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration_small.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration_small.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/RigidRegistration_small.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/Tab2.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/Tab2.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/Tab2.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/Tab2.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/pointBasedIcon.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/pointBasedIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/pointBasedIcon.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/pointBasedIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/rigidRegistrationIcon.png b/Plugins/org.mitk.gui.qt.registration/documentation/UserManual/rigidRegistrationIcon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/documentation/UserManual/rigidRegistrationIcon.png rename to Plugins/org.mitk.gui.qt.registration/documentation/UserManual/rigidRegistrationIcon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/files.cmake b/Plugins/org.mitk.gui.qt.registration/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/files.cmake rename to Plugins/org.mitk.gui.qt.registration/files.cmake diff --git a/Plugins/org.mitk.gui.qt.registration/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.registration/manifest_headers.cmake new file mode 100644 index 0000000000..f58edb1651 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.registration/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Registration") +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) diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/plugin.xml b/Plugins/org.mitk.gui.qt.registration/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/plugin.xml rename to Plugins/org.mitk.gui.qt.registration/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/resources/DeformableRegistration.xpm b/Plugins/org.mitk.gui.qt.registration/resources/DeformableRegistration.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/resources/DeformableRegistration.xpm rename to Plugins/org.mitk.gui.qt.registration/resources/DeformableRegistration.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/resources/PointBasedRegistration.xpm b/Plugins/org.mitk.gui.qt.registration/resources/PointBasedRegistration.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/resources/PointBasedRegistration.xpm rename to Plugins/org.mitk.gui.qt.registration/resources/PointBasedRegistration.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/resources/QmitkDeformableRegistrationView.qrc b/Plugins/org.mitk.gui.qt.registration/resources/QmitkDeformableRegistrationView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/resources/QmitkDeformableRegistrationView.qrc rename to Plugins/org.mitk.gui.qt.registration/resources/QmitkDeformableRegistrationView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/resources/QmitkPointBasedRegistrationView.qrc b/Plugins/org.mitk.gui.qt.registration/resources/QmitkPointBasedRegistrationView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/resources/QmitkPointBasedRegistrationView.qrc rename to Plugins/org.mitk.gui.qt.registration/resources/QmitkPointBasedRegistrationView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/resources/QmitkRigidRegistrationView.qrc b/Plugins/org.mitk.gui.qt.registration/resources/QmitkRigidRegistrationView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/resources/QmitkRigidRegistrationView.qrc rename to Plugins/org.mitk.gui.qt.registration/resources/QmitkRigidRegistrationView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/resources/RigidRegistration.xpm b/Plugins/org.mitk.gui.qt.registration/resources/RigidRegistration.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/resources/RigidRegistration.xpm rename to Plugins/org.mitk.gui.qt.registration/resources/RigidRegistration.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/resources/btnReinit.xpm b/Plugins/org.mitk.gui.qt.registration/resources/btnReinit.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/resources/btnReinit.xpm rename to Plugins/org.mitk.gui.qt.registration/resources/btnReinit.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.h b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.h rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationViewControls.ui b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationViewControls.ui rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkDeformableRegistrationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.h b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.h rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkLoadPresetDialog.h diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationTesting.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationTesting.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationTesting.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationTesting.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.h b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.h rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationViewControls.ui b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationViewControls.ui rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkPointBasedRegistrationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelector.ui b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelector.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelector.ui rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelector.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.h b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.h rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationSelectorView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.h b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.h rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationViewControls.ui b/Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationViewControls.ui rename to Plugins/org.mitk.gui.qt.registration/src/internal/QmitkRigidRegistrationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.h b/Plugins/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.h rename to Plugins/org.mitk.gui.qt.registration/src/internal/mitkLandmarkWarping.h diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.registration/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/CMakeLists.txt b/Plugins/org.mitk.gui.qt.segmentation/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.segmentation/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentationTechnical.dox b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentationTechnical.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentationTechnical.dox rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/QmitkSegmentationTechnical.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/ToolExtensionsGeneralOverview.dox b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/ToolExtensionsGeneralOverview.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/ToolExtensionsGeneralOverview.dox rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/ToolExtensionsGeneralOverview.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.xcf b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.xcf similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.xcf rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/interactive_segmentation_classes.xcf diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentation.dox b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentation.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentation.dox rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentation.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGDataManagerContextMenu.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGDataManagerContextMenu.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGDataManagerContextMenu.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGDataManagerContextMenu.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGapplication.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGapplication.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGapplication.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGapplication.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGcorrectionActions.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGcorrectionActions.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGcorrectionActions.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGcorrectionActions.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGdatamanagerview.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGdatamanagerview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGdatamanagerview.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGdatamanagerview.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconAddSubtract.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconAddSubtract.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconAddSubtract.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconAddSubtract.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconCorrection.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconCorrection.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconCorrection.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconCorrection.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconErase.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconErase.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconErase.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconErase.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconFill.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconFill.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconFill.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconFill.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconPaintWipe.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconPaintWipe.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconPaintWipe.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconPaintWipe.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconRegionGrowing.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconRegionGrowing.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconRegionGrowing.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGiconRegionGrowing.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGleakage.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGleakage.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGleakage.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGleakage.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGselection.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGselection.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGselection.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/org_mitk_gui_qt_segmentationIMGselection.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentation.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentation.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentation.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentation.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceAfter.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceAfter.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceAfter.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceAfter.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceBefore.png b/Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceBefore.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceBefore.png rename to Plugins/org.mitk.gui.qt.segmentation/documentation/UserManual/segmentationFromSurfaceBefore.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/doxygen/SegmentationProperties.dox b/Plugins/org.mitk.gui.qt.segmentation/documentation/doxygen/SegmentationProperties.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/documentation/doxygen/SegmentationProperties.dox rename to Plugins/org.mitk.gui.qt.segmentation/documentation/doxygen/SegmentationProperties.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/files.cmake b/Plugins/org.mitk.gui.qt.segmentation/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/files.cmake rename to Plugins/org.mitk.gui.qt.segmentation/files.cmake diff --git a/Plugins/org.mitk.gui.qt.segmentation/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.segmentation/manifest_headers.cmake new file mode 100644 index 0000000000..6d9c997827 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Segmentation") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common.legacy org.mitk.gui.qt.datamanager) diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/plugin.xml b/Plugins/org.mitk.gui.qt.segmentation/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/plugin.xml rename to Plugins/org.mitk.gui.qt.segmentation/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/boolean.png b/Plugins/org.mitk.gui.qt.segmentation/resources/boolean.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/boolean.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/boolean.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/boolean.qrc b/Plugins/org.mitk.gui.qt.segmentation/resources/boolean.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/boolean.qrc rename to Plugins/org.mitk.gui.qt.segmentation/resources/boolean.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnDelete.png b/Plugins/org.mitk.gui.qt.segmentation/resources/btnDelete.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnDelete.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnDelete.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnDifference.png b/Plugins/org.mitk.gui.qt.segmentation/resources/btnDifference.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnDifference.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnDifference.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnIntersection.png b/Plugins/org.mitk.gui.qt.segmentation/resources/btnIntersection.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnIntersection.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnIntersection.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnLoad.png b/Plugins/org.mitk.gui.qt.segmentation/resources/btnLoad.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnLoad.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnLoad.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnNew.png b/Plugins/org.mitk.gui.qt.segmentation/resources/btnNew.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnNew.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnNew.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnReinit.xpm b/Plugins/org.mitk.gui.qt.segmentation/resources/btnReinit.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnReinit.xpm rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnReinit.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnSave.png b/Plugins/org.mitk.gui.qt.segmentation/resources/btnSave.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnSave.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnSave.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnUnion.png b/Plugins/org.mitk.gui.qt.segmentation/resources/btnUnion.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/btnUnion.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/btnUnion.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/deformablePlane.png b/Plugins/org.mitk.gui.qt.segmentation/resources/deformablePlane.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/deformablePlane.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/deformablePlane.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/regiongrowing.qrc b/Plugins/org.mitk.gui.qt.segmentation/resources/regiongrowing.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/regiongrowing.qrc rename to Plugins/org.mitk.gui.qt.segmentation/resources/regiongrowing.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/regiongrowing.xpm b/Plugins/org.mitk.gui.qt.segmentation/resources/regiongrowing.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/regiongrowing.xpm rename to Plugins/org.mitk.gui.qt.segmentation/resources/regiongrowing.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/segmentation.png b/Plugins/org.mitk.gui.qt.segmentation/resources/segmentation.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/segmentation.png rename to Plugins/org.mitk.gui.qt.segmentation/resources/segmentation.png diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/resources/segmentation.qrc b/Plugins/org.mitk.gui.qt.segmentation/resources/segmentation.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/resources/segmentation.qrc rename to Plugins/org.mitk.gui.qt.segmentation/resources/segmentation.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp rename to Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h new file mode 100644 index 0000000000..5b88637d5e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h @@ -0,0 +1,84 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date$ + Version: $Revision: 16224 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QmitkSegmentationPreferencePage_h_included +#define QmitkSegmentationPreferencePage_h_included + +#include "berryIQtPreferencePage.h" +#include "org_mitk_gui_qt_segmentation_Export.h" +#include + +class QWidget; +class QCheckBox; +class QRadioButton; +class QDoubleSpinBox; + +class MITK_QT_SEGMENTATION QmitkSegmentationPreferencePage : public QObject, public berry::IQtPreferencePage +{ + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) + +public: + + QmitkSegmentationPreferencePage(); + ~QmitkSegmentationPreferencePage(); + + void Init(berry::IWorkbench::Pointer workbench); + + void CreateQtControl(QWidget* widget); + + QWidget* GetQtControl() const; + + /// + /// \see IPreferencePage::PerformOk() + /// + virtual bool PerformOk(); + + /// + /// \see IPreferencePage::PerformCancel() + /// + virtual void PerformCancel(); + + /// + /// \see IPreferencePage::Update() + /// + virtual void Update(); + +protected slots: + + void OnVolumeRenderingCheckboxChecked(int); + void OnSmoothingCheckboxChecked(int); + +protected: + + QWidget* m_MainControl; + QRadioButton* m_RadioOutline; + QRadioButton* m_RadioOverlay; + QCheckBox* m_VolumeRenderingCheckBox; + QCheckBox* m_SmoothingCheckBox; + QDoubleSpinBox* m_SmoothingSpinBox; + QDoubleSpinBox* m_DecimationSpinBox; + QDoubleSpinBox* m_ClosingSpinBox; + + bool m_Initializing; + + berry::IPreferences::Pointer m_SegmentationPreferencesNode; +}; + +#endif /* QMITKDATAMANAGERPREFERENCEPAGE_H_ */ + diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp new file mode 100644 index 0000000000..d6612e12f6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.cpp @@ -0,0 +1,137 @@ +#include "QmitkAutocropAction.h" + +#include "mitkAutoCropImageFilter.h" +#include "mitkImageCast.h" +#include "mitkRenderingManager.h" +#include "mitkProgressBar.h" + +#include + +//needed for qApp +#include + +QmitkAutocropAction::QmitkAutocropAction() +{ +} + +QmitkAutocropAction::~QmitkAutocropAction() +{ +} + +void QmitkAutocropAction::Run( const QList &selectedNodes ) +{ + foreach ( mitk::DataNode::Pointer node, selectedNodes ) + { + if (node) + { + mitk::Image::Pointer image = dynamic_cast( node->GetData() ); + if (image.IsNull()) return; + + mitk::ProgressBar::GetInstance()->AddStepsToDo(10); + mitk::ProgressBar::GetInstance()->Progress(2); + + qApp->processEvents(); + + mitk::AutoCropImageFilter::Pointer cropFilter = mitk::AutoCropImageFilter::New(); + cropFilter->SetInput( image ); + cropFilter->SetBackgroundValue( 0 ); + try + { + cropFilter->Update(); + + image = cropFilter->GetOutput(); + + if (image.IsNotNull()) + { + node->SetData( this->IncreaseCroppedImageSize(image) ); // bug fix 3145 + // Reinit node + mitk::RenderingManager::GetInstance()->InitializeViews( + node->GetData()->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + + } + } + catch(...) + { + MITK_ERROR << "Cropping image failed..."; + } + mitk::ProgressBar::GetInstance()->Progress(8); + } + else + { + MITK_INFO << " a NULL node selected"; + } + } +} + +mitk::Image::Pointer QmitkAutocropAction::IncreaseCroppedImageSize( mitk::Image::Pointer image ) +{ + typedef itk::Image< short, 3 > ImageType; + typedef itk::Image< unsigned char, 3 > PADOutputImageType; + ImageType::Pointer itkTransformImage = ImageType::New(); + mitk::CastToItkImage( image, itkTransformImage ); + + typedef itk::ConstantPadImageFilter< ImageType, PADOutputImageType > PadFilterType; + PadFilterType::Pointer padFilter = PadFilterType::New(); + + unsigned long upperPad[3]; + unsigned long lowerPad[3]; + int borderLiner = 3; + + mitk::Point3D mitkOriginPoint; + double origin[3]; + origin[0]=0; + origin[1]=0; + origin[2]=0; + itkTransformImage->SetOrigin(origin); + + lowerPad[0]=borderLiner; + lowerPad[1]=borderLiner; + lowerPad[2]=borderLiner; + + upperPad[0]=borderLiner; + upperPad[1]=borderLiner; + upperPad[2]=borderLiner; + + padFilter->SetInput(itkTransformImage); + padFilter->SetConstant(0); + padFilter->SetPadUpperBound(upperPad); + padFilter->SetPadLowerBound(lowerPad); + padFilter->UpdateLargestPossibleRegion(); + + + mitk::Image::Pointer paddedImage = mitk::Image::New(); + paddedImage->InitializeByItk(padFilter->GetOutput()); + mitk::CastToMitkImage(padFilter->GetOutput(), paddedImage); + + //calculate translation according to padding to get the new origin + mitk::Point3D paddedOrigin = image->GetGeometry()->GetOrigin(); + mitk::Vector3D spacing = image->GetGeometry()->GetSpacing(); + paddedOrigin[0] -= (borderLiner)*spacing[0]; + paddedOrigin[1] -= (borderLiner)*spacing[1]; + paddedOrigin[2] -= (borderLiner)*spacing[2]; + + paddedImage->GetGeometry()->SetOrigin( paddedOrigin ); + + return paddedImage; +} + +void QmitkAutocropAction::SetSmoothed(bool /*smoothed*/) +{ + //not needed +} + +void QmitkAutocropAction::SetDecimated(bool /*decimated*/) +{ + //not needed +} + +void QmitkAutocropAction::SetDataStorage(mitk::DataStorage* /*dataStorage*/) +{ + //not needed +} + +void QmitkAutocropAction::SetFunctionality(berry::QtViewPart */*functionality*/) +{ + //not needed +} diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h new file mode 100644 index 0000000000..54e8556be9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkAutocropAction.h @@ -0,0 +1,41 @@ +#ifndef QMITK_AUTOCROPACTION_H +#define QMITK_AUTOCROPACTION_H + +#include "mitkIContextMenuAction.h" + +#include "org_mitk_gui_qt_segmentation_Export.h" + +#include "vector" +#include "mitkDataNode.h" +#include "mitkImage.h" + +class QmitkStdMultiWidget; + +class MITK_QT_SEGMENTATION QmitkAutocropAction : public QObject, public mitk::IContextMenuAction +{ + Q_OBJECT + Q_INTERFACES(mitk::IContextMenuAction) + +public: + + QmitkAutocropAction(); + virtual ~QmitkAutocropAction(); + + //interface methods + void Run( const QList& selectedNodes ); + void SetDataStorage(mitk::DataStorage* dataStorage); + void SetSmoothed(bool smoothed); + void SetDecimated(bool decimated); + void SetFunctionality(berry::QtViewPart* functionality); + +protected: + + mitk::Image::Pointer IncreaseCroppedImageSize( mitk::Image::Pointer image ); + +private: + + typedef QList NodeList; + +}; + +#endif // QMITK_AUTOCROPACTION_H diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.cpp rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.h rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.ui b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.ui rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkBooleanOperationsView.ui diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp new file mode 100644 index 0000000000..a467d1bd2f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.cpp @@ -0,0 +1,151 @@ +#include "QmitkCreatePolygonModelAction.h" + +// MITK +#include +#include +#include +#include +#include + +#include +#include + +// Blueberry +#include +#include +#include + +using namespace berry; +using namespace mitk; +using namespace std; + +QmitkCreatePolygonModelAction::QmitkCreatePolygonModelAction() +{ +} + +QmitkCreatePolygonModelAction::~QmitkCreatePolygonModelAction() +{ +} + +void QmitkCreatePolygonModelAction::Run(const QList &selectedNodes) +{ + DataNode::Pointer selectedNode = selectedNodes[0]; + Image::Pointer image = dynamic_cast(selectedNode->GetData()); + + if (image.IsNull()) + return; + + try + { + if (!m_IsSmoothed) + { + ShowSegmentationAsSurface::Pointer surfaceFilter = ShowSegmentationAsSurface::New(); + + itk::SimpleMemberCommand::Pointer successCommand = itk::SimpleMemberCommand::New(); + successCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); + surfaceFilter->AddObserver(ResultAvailable(), successCommand); + + itk::SimpleMemberCommand::Pointer errorCommand = itk::SimpleMemberCommand::New(); + errorCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); + surfaceFilter->AddObserver(ProcessingError(), errorCommand); + + surfaceFilter->SetDataStorage(*m_DataStorage); + surfaceFilter->SetPointerParameter("Input", image); + surfaceFilter->SetPointerParameter("Group node", selectedNode); + surfaceFilter->SetParameter("Show result", true); + surfaceFilter->SetParameter("Sync visibility", false); + surfaceFilter->SetParameter("Smooth", false); + surfaceFilter->SetParameter("Apply median", false); + surfaceFilter->SetParameter("Median kernel size", 3u); + surfaceFilter->SetParameter("Gaussian SD", 1.5f); + surfaceFilter->SetParameter("Decimate mesh", m_IsDecimated); + surfaceFilter->SetParameter("Decimation rate", 0.8f); + + StatusBar::GetInstance()->DisplayText("Surface creation started in background..."); + + surfaceFilter->StartAlgorithm(); + } + else + { + ShowSegmentationAsSmoothedSurface::Pointer surfaceFilter = ShowSegmentationAsSmoothedSurface::New(); + + itk::SimpleMemberCommand::Pointer successCommand = itk::SimpleMemberCommand::New(); + successCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); + surfaceFilter->AddObserver(mitk::ResultAvailable(), successCommand); + + itk::SimpleMemberCommand::Pointer errorCommand = itk::SimpleMemberCommand::New(); + errorCommand->SetCallbackFunction(this, &QmitkCreatePolygonModelAction::OnSurfaceCalculationDone); + surfaceFilter->AddObserver(mitk::ProcessingError(), errorCommand); + + surfaceFilter->SetDataStorage(*m_DataStorage); + surfaceFilter->SetPointerParameter("Input", image); + surfaceFilter->SetPointerParameter("Group node", selectedNode); + + berry::IWorkbenchPart::Pointer activePart = + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->GetActivePart(); + mitk::IRenderWindowPart* renderPart = dynamic_cast(activePart.GetPointer()); + mitk::SliceNavigationController* timeNavController = 0; + if (renderPart != 0) + { + timeNavController = renderPart->GetRenderingManager()->GetTimeNavigationController(); + } + + int timeNr = timeNavController != 0 ? timeNavController->GetTime()->GetPos() : 0; + surfaceFilter->SetParameter("TimeNr", timeNr); + + IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID); + IPreferences::Pointer segPref = prefService->GetSystemPreferences()->Node("/org.mitk.views.segmentation"); + + bool smoothingHint = segPref->GetBool("smoothing hint", true); + float smoothing = (float)segPref->GetDouble("smoothing value", 1.0); + float decimation = (float)segPref->GetDouble("decimation rate", 0.5); + float closing = (float)segPref->GetDouble("closing ratio", 0.0); + + if (smoothingHint) + { + smoothing = 0.0; + Vector3D spacing = image->GetGeometry()->GetSpacing(); + + for (Vector3D::Iterator iter = spacing.Begin(); iter != spacing.End(); ++iter) + smoothing = max(smoothing, *iter); + } + + surfaceFilter->SetParameter("Smoothing", smoothing); + surfaceFilter->SetParameter("Decimation", decimation); + surfaceFilter->SetParameter("Closing", closing); + + ProgressBar::GetInstance()->AddStepsToDo(8); + StatusBar::GetInstance()->DisplayText("Smoothed surface creation started in background..."); + + surfaceFilter->StartAlgorithm(); + } + } + catch(...) + { + MITK_ERROR << "Surface creation failed!"; + } +} + +void QmitkCreatePolygonModelAction::OnSurfaceCalculationDone() +{ + StatusBar::GetInstance()->Clear(); +} + +void QmitkCreatePolygonModelAction::SetDataStorage(DataStorage *dataStorage) +{ + m_DataStorage = dataStorage; +} + +void QmitkCreatePolygonModelAction::SetSmoothed(bool smoothed) +{ + m_IsSmoothed = smoothed; +} + +void QmitkCreatePolygonModelAction::SetDecimated(bool decimated) +{ + m_IsDecimated = decimated; +} + +void QmitkCreatePolygonModelAction::SetFunctionality(QtViewPart *) +{ +} diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h new file mode 100644 index 0000000000..cea5805fa9 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkCreatePolygonModelAction.h @@ -0,0 +1,42 @@ +#ifndef QMITKCREATEPOLYGONMODELACTION_H +#define QMITKCREATEPOLYGONMODELACTION_H + +#include + +// Parent classes +#include +#include + +// Data members +#include + +class QmitkStdMultiWidget; + +class MITK_QT_SEGMENTATION QmitkCreatePolygonModelAction : public QObject, public mitk::IContextMenuAction +{ + Q_OBJECT + Q_INTERFACES(mitk::IContextMenuAction) + +public: + QmitkCreatePolygonModelAction(); + ~QmitkCreatePolygonModelAction(); + + // IContextMenuAction + void Run(const QList &selectedNodes); + void SetDataStorage(mitk::DataStorage *dataStorage); + void SetSmoothed(bool smoothed); + void SetDecimated(bool decimated); + void SetFunctionality(berry::QtViewPart *functionality); + + void OnSurfaceCalculationDone(); + +private: + QmitkCreatePolygonModelAction(const QmitkCreatePolygonModelAction &); + QmitkCreatePolygonModelAction & operator=(const QmitkCreatePolygonModelAction &); + + mitk::DataStorage::Pointer m_DataStorage; + bool m_IsSmoothed; + bool m_IsDecimated; +}; + +#endif diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.cpp new file mode 100644 index 0000000000..1a4b831f15 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.cpp @@ -0,0 +1,537 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Module: $RCSfile$ +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkDeformableClippingPlaneView.h" + +#include "mitkClippingPlaneDeformationTool.h" +#include "mitkClippingPlaneRotationTool.h" +#include "mitkClippingPlaneTranslationTool.h" +#include "mitkHeightFieldSurfaceClipImageFilter.h" +#include "mitkImageToSurfaceFilter.h" +#include "mitkInteractionConst.h" +#include "mitkLabeledImageLookupTable.h" +#include "mitkLabeledImageVolumeCalculator.h" +#include "mitkLevelWindowProperty.h" +#include "mitkLookupTableProperty.h" +#include "mitkPlane.h" +#include "mitkRotationOperation.h" +#include "mitkSurfaceVtkMapper3D.h" +#include "mitkVtkRepresentationProperty.h" + +#include "vtkFloatArray.h" +#include "vtkPointData.h" +#include "vtkProperty.h" + + +const std::string QmitkDeformableClippingPlaneView::VIEW_ID = "org.mitk.views.deformableclippingplane"; + +QmitkDeformableClippingPlaneView::QmitkDeformableClippingPlaneView() +: QmitkFunctionality() +, m_MultiWidget(NULL) +, m_ToolManager(NULL) +{ + //Current fix for bug 10707. Waiting for a solution of bug 10834. + itk::Object::Pointer o; + o = mitk::ClippingPlaneRotationTool::New(); + o = mitk::ClippingPlaneDeformationTool::New(); + o = mitk::ClippingPlaneTranslationTool::New(); +} + +QmitkDeformableClippingPlaneView::~QmitkDeformableClippingPlaneView() +{ +} + +void QmitkDeformableClippingPlaneView::CreateQtPartControl(QWidget *parent) +{ + // create GUI widgets + m_Controls.setupUi(parent); + this->CreateConnections(); +} + +void QmitkDeformableClippingPlaneView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) +{ + m_MultiWidget = &stdMultiWidget; +} + +void QmitkDeformableClippingPlaneView::StdMultiWidgetNotAvailable() +{ + m_MultiWidget = NULL; +} + +void QmitkDeformableClippingPlaneView::CreateConnections() +{ + m_ToolManager = m_Controls.interactionToolSelectionBox->GetToolManager(); + m_ToolManager->SetDataStorage(*(this->GetDefaultDataStorage())); + assert(m_ToolManager); + + mitk::NodePredicateProperty::Pointer clipPredicate = mitk::NodePredicateProperty::New("clippingPlane",mitk::BoolProperty::New(true)); + //set only clipping planes in the list of the selector + m_Controls.clippingPlaneSelector->SetDataStorage(this->GetDefaultDataStorage()); + m_Controls.clippingPlaneSelector->SetPredicate(clipPredicate); + + //Shows and set the tool buttons + m_Controls.interactionToolSelectionBox->SetGenerateAccelerators(true); + m_Controls.interactionToolSelectionBox->SetDisplayedToolGroups("ClippingTool"); + m_Controls.interactionToolSelectionBox->SetLayoutColumns(3); + m_Controls.interactionToolSelectionBox->SetEnabledMode(QmitkToolSelectionBox::EnabledWithWorkingData); + + //No working data set, yet + m_Controls.volumeGroupBox->setEnabled(false); + m_Controls.noSelectedImageLabel->show(); + m_Controls.planesWarningLabel->hide(); + + connect (m_Controls.createNewPlanePushButton, SIGNAL(clicked()), this, SLOT(OnCreateNewClippingPlane())); + connect (m_Controls.updateVolumePushButton, SIGNAL(clicked()), this, SLOT(OnCalculateClippingVolume())); + connect (m_Controls.clippingPlaneSelector, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), + this, SLOT(OnComboBoxSelectionChanged(const mitk::DataNode*))); +} + +void QmitkDeformableClippingPlaneView::Activated() +{ + QmitkFunctionality::Activated(); +} + +void QmitkDeformableClippingPlaneView::Deactivated() +{ + QmitkFunctionality::Deactivated(); +} + +void QmitkDeformableClippingPlaneView::OnComboBoxSelectionChanged( const mitk::DataNode* node ) +{ + mitk::DataNode* selectedNode = const_cast(node); + if( selectedNode != NULL ) + { + //remember the active tool + int toolID = m_ToolManager->GetActiveToolID(); + + m_ToolManager->SetWorkingData(selectedNode); + + //reset Tool + m_ToolManager->ActivateTool(-1); + //set tool again with new working data (calls activated() in Tool) + m_ToolManager->ActivateTool(toolID); + } + this->UpdateView(); +} + +void QmitkDeformableClippingPlaneView::OnSelectionChanged(mitk::DataNode* node) +{ + std::vector nodes; + nodes.push_back(node); + this->OnSelectionChanged(nodes); +} + +void QmitkDeformableClippingPlaneView::OnSelectionChanged(std::vector nodes) +{ + bool isClippingPlane(false); + for(unsigned int i = 0; i < nodes.size(); ++i) + { + if(nodes.at(i)->GetBoolProperty("clippingPlane", isClippingPlane)) + m_Controls.clippingPlaneSelector->setCurrentIndex( m_Controls.clippingPlaneSelector->Find(nodes.at(i)) ); + + else + { + if(dynamic_cast (nodes.at(i)->GetData())&& nodes.at(i)) + { + if(m_ToolManager->GetReferenceData(0)!= NULL && nodes.at(i)->GetData()==m_ToolManager->GetReferenceData(0)->GetData()) + return; + + m_ToolManager->SetReferenceData(nodes.at(i)); + } + } + } + this->UpdateView(); +} + +void::QmitkDeformableClippingPlaneView::NodeChanged(const mitk::DataNode* /*node*/) +{ + this->UpdateView(); +} + +void QmitkDeformableClippingPlaneView::NodeRemoved(const mitk::DataNode* node) +{ + bool isClippingPlane(false); + + if (node->GetBoolProperty("clippingPlane", isClippingPlane)) + { + if(this->GetAllClippingPlanes()->empty()) + { + m_ToolManager->SetWorkingData(NULL); + this->UpdateView(); + } + else + this->OnSelectionChanged(GetAllClippingPlanes()->front()); + } + else + { + if(m_ToolManager->GetReferenceData(0)!= NULL) + { + if(node->GetData() == m_ToolManager->GetReferenceData(0)->GetData()) + { + m_ToolManager->SetReferenceData(NULL); + m_Controls.volumeList->clear(); + } + this->OnSelectionChanged(mitk::DataNode::New()); + } + } +} + +void QmitkDeformableClippingPlaneView::UpdateView() +{ + if (m_ToolManager->GetReferenceData(0)!= NULL) + { + m_Controls.volumeGroupBox->setEnabled(m_ToolManager->GetWorkingData(0)!= NULL); + m_Controls.noSelectedImageLabel->hide(); + m_Controls.selectedImageLabel->setText(QString::fromUtf8(m_ToolManager->GetReferenceData(0)->GetName().c_str())); + + //clear list --> than search for all shown clipping plans (max 7 planes) + m_Controls.selectedVolumePlanesLabel->setText(""); + m_Controls.planesWarningLabel->hide(); + int volumePlanes=0; + + mitk::DataStorage::SetOfObjects::ConstPointer allClippingPlanes = this->GetAllClippingPlanes(); + for (mitk::DataStorage::SetOfObjects::ConstIterator itPlanes = allClippingPlanes->Begin(); itPlanes != allClippingPlanes->End(); itPlanes++) + { + bool isVisible(false); + itPlanes.Value()->GetBoolProperty("visible",isVisible); + if (isVisible) + { + if (volumePlanes<7) + { + volumePlanes ++; + m_Controls.selectedVolumePlanesLabel->setText(m_Controls.selectedVolumePlanesLabel->text().append(QString::fromStdString(itPlanes.Value()->GetName()+"\n"))); + } + else + { + m_Controls.planesWarningLabel->show(); + return; + } + } + } + } + + else + { + m_Controls.volumeGroupBox->setEnabled(false); + m_Controls.noSelectedImageLabel->show(); + m_Controls.selectedImageLabel->setText(""); + m_Controls.selectedVolumePlanesLabel->setText(""); + m_Controls.planesWarningLabel->hide(); + } +} + +void QmitkDeformableClippingPlaneView::OnCreateNewClippingPlane() +{ + mitk::DataNode* referenceNode = m_ToolManager->GetReferenceData(0); + mitk::Image::Pointer referenceImage = mitk::Image::New(); + + //the new clipping plane + mitk::Plane::Pointer plane = mitk::Plane::New(); + + double imageDiagonal = 200; + + if (referenceNode != NULL) + { + referenceImage = dynamic_cast (referenceNode->GetData()); + + if (referenceImage.IsNotNull()) + { + // check if user wants a surface model + if(m_Controls.surfaceModelCheckBox->isChecked()) + { + //Check if there is a surface node from the image. If not, create one + bool createSurfaceFromImage(true); + + mitk::TNodePredicateDataType::Pointer isSurface = mitk::TNodePredicateDataType::New(); + mitk::DataStorage::SetOfObjects::ConstPointer childNodes = m_ToolManager->GetDataStorage()->GetDerivations(referenceNode,isSurface, true); + + for (mitk::DataStorage::SetOfObjects::ConstIterator itChildNodes = childNodes->Begin(); + itChildNodes != childNodes->End(); itChildNodes++) + { + if (itChildNodes.Value().IsNotNull()) + createSurfaceFromImage=false; + } + + if(createSurfaceFromImage) + { + //Lsg 2: Surface for the 3D-perspective + mitk::ImageToSurfaceFilter::Pointer surfaceFilter = mitk::ImageToSurfaceFilter::New(); + surfaceFilter->SetInput(referenceImage); + surfaceFilter->SetThreshold(1); + surfaceFilter->SetSmooth(true); + //Downsampling + surfaceFilter->SetDecimate(mitk::ImageToSurfaceFilter::DecimatePro); + + mitk::DataNode::Pointer surfaceNode = mitk::DataNode::New(); + surfaceNode->SetData(surfaceFilter->GetOutput()); + surfaceNode->SetProperty("color", referenceNode->GetProperty("color")); + surfaceNode->SetOpacity(0.5); + surfaceNode->SetName(referenceNode->GetName()); + m_ToolManager->GetDataStorage()->Add(surfaceNode, referenceNode); + } + } + + //If an image is selected trim the plane to this. + imageDiagonal = referenceImage->GetGeometry()->GetDiagonalLength(); + plane->SetOrigin( referenceImage->GetGeometry()->GetCenter()); + + // Rotate plane + mitk::Vector3D rotationAxis; + mitk::FillVector3D(rotationAxis, 0.0, 1.0, 0.0); + mitk::RotationOperation op(mitk::OpROTATE, referenceImage->GetGeometry()->GetCenter(), rotationAxis, 90.0); + plane->GetGeometry()->ExecuteOperation(&op); + } + } + + //set some properties for the clipping plane + plane->SetExtent(imageDiagonal * 0.9, imageDiagonal * 0.9); + plane->SetResolution(64, 64); + + // Set scalars (for colorization of plane) + vtkFloatArray *scalars = vtkFloatArray::New(); + scalars->SetName("Distance"); + scalars->SetNumberOfComponents(1); + + for ( unsigned int i = 0; i < plane->GetVtkPolyData(0)->GetNumberOfPoints(); ++i) + { + scalars->InsertNextValue(-1.0); + } + plane->GetVtkPolyData(0)->GetPointData()->SetScalars(scalars); + plane->GetVtkPolyData(0)->GetPointData()->Update(); + + mitk::DataNode::Pointer planeNode = mitk::DataNode::New(); + planeNode->SetData(plane); + + std::stringstream planeName; + planeName << "ClippingPlane "; + planeName << this->GetAllClippingPlanes()->Size() + 1; + + planeNode->SetName(planeName.str()); + planeNode->AddProperty("clippingPlane",mitk::BoolProperty::New(true)); + // Make plane pickable + planeNode->SetBoolProperty("pickable", true); + + mitk::SurfaceVtkMapper3D::SetDefaultProperties(planeNode); + + // Don't include plane in bounding box! + planeNode->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); + + // Set lookup table for plane surface visualization + vtkLookupTable *lookupTable = vtkLookupTable::New(); + lookupTable->SetHueRange(0.6, 0.0); + lookupTable->SetSaturationRange(1.0, 1.0); + lookupTable->SetValueRange(1.0, 1.0); + lookupTable->SetTableRange(-1.0, 1.0); + lookupTable->Build(); + + mitk::LookupTable::Pointer lut = mitk::LookupTable::New(); + lut->SetVtkLookupTable(lookupTable); + + mitk::LookupTableProperty::Pointer prop = mitk::LookupTableProperty::New(lut); + + planeNode->SetProperty("LookupTable", prop); + planeNode->SetBoolProperty("scalar visibility", true); + planeNode->SetBoolProperty("color mode", true); + planeNode->SetFloatProperty("ScalarsRangeMinimum", -1.0); + planeNode->SetFloatProperty("ScalarsRangeMaximum", 1.0); + + // Configure material so that only scalar colors are shown + planeNode->SetColor(0.0f,0.0f,0.0f); + planeNode->SetOpacity(1.0f); + planeNode->SetFloatProperty("material.wireframeLineWidth",2.0f); + + //Set view of plane to wireframe + planeNode->SetProperty("material.representation", mitk::VtkRepresentationProperty::New(VTK_WIREFRAME)); + + //Set the plane as working data for the tools and selected it + this->OnSelectionChanged (planeNode); + + //Add the plane to data storage + this->GetDataStorage()->Add(planeNode); + + //Change the index of the selector to the new generated node + m_Controls.clippingPlaneSelector->setCurrentIndex( m_Controls.clippingPlaneSelector->Find(planeNode) ); + + // set crosshair invisible + mitk::DataNode* dataNode; + + dataNode = this->GetDataStorage()->GetNamedNode("widget1Plane"); + if(dataNode) dataNode->SetVisibility(false); + dataNode = this->GetDataStorage()->GetNamedNode("widget2Plane"); + if(dataNode) dataNode->SetVisibility(false); + dataNode = this->GetDataStorage()->GetNamedNode("widget3Plane"); + if(dataNode) dataNode->SetVisibility(false); + + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkDeformableClippingPlaneView::OnCalculateClippingVolume() +{ + mitk::DataNode::Pointer imageNode = m_ToolManager->GetReferenceData(0); + bool isSegmentation(false); + imageNode->GetBoolProperty("binary", isSegmentation); + + if(imageNode.IsNull() || !isSegmentation) + { + MITK_INFO << "No segmentation selected! Can't calculate volume"; + return; + } + + std::vector clippingPlanes; + mitk::DataStorage::SetOfObjects::ConstPointer allClippingPlanes = this->GetAllClippingPlanes(); + for (mitk::DataStorage::SetOfObjects::ConstIterator itPlanes = allClippingPlanes->Begin(); itPlanes != allClippingPlanes->End(); itPlanes++) + { + bool isVisible(false); + itPlanes.Value()->GetBoolProperty("visible",isVisible); + mitk::Surface* plane = dynamic_cast(itPlanes.Value()->GetData()); + + if (isVisible && plane) + clippingPlanes.push_back(plane); + } + + if (clippingPlanes.empty()) + { + MITK_INFO << "No clipping plane selected! Can't calculate volume"; + return; + } + + + //deactivate Tools + m_ToolManager->ActivateTool(-1); + //Clear the list of volumes, before calculating the new values + m_Controls.volumeList->clear(); + + imageNode->SetBoolProperty("visible", false); + + //set some properties for clipping the image-->Output: labled Image + mitk::HeightFieldSurfaceClipImageFilter::Pointer surfaceClipFilter = mitk::HeightFieldSurfaceClipImageFilter::New(); + + surfaceClipFilter->SetInput(dynamic_cast (imageNode->GetData())); + surfaceClipFilter->SetClippingModeToMultiPlaneValue(); + surfaceClipFilter->SetClippingSurfaces(clippingPlanes); + surfaceClipFilter->Update(); + + //delete the old clipped image node + mitk::DataStorage::SetOfObjects::ConstPointer oldClippedNode = this->GetDataStorage()->GetSubset(mitk::NodePredicateProperty::New("name", mitk::StringProperty::New("Clipped Image"))); + if (oldClippedNode.IsNotNull()) + this->GetDataStorage()->Remove(oldClippedNode); + + //add the new clipped image node + mitk::DataNode::Pointer clippedNode = mitk::DataNode::New(); + mitk::Image::Pointer clippedImage = surfaceClipFilter->GetOutput(); + clippedImage->DisconnectPipeline(); + clippedNode->SetData(clippedImage); + //clippedNode->SetProperty("helper object", mitk::BoolProperty::New(true)); + clippedNode->SetName("Clipped Image"); + clippedNode->SetColor(1.0,1.0,1.0); // color property will not be used, labeled image lookuptable will be used instead + clippedNode->SetProperty ("use color", mitk::BoolProperty::New(false)); + clippedNode->SetOpacity(0.4); + this->GetDataStorage()->Add(clippedNode); + + mitk::LabeledImageVolumeCalculator::Pointer volumeCalculator = mitk::LabeledImageVolumeCalculator::New(); + volumeCalculator->SetImage(clippedImage); + volumeCalculator->Calculate(); + + std::vector volumes = volumeCalculator->GetVolumes(); + + mitk::LabeledImageLookupTable::Pointer lut = mitk::LabeledImageLookupTable::New(); + int lablesWithVolume=0; + + for(unsigned int i = 1; i < volumes.size(); ++i) + { + if(volumes.at(i)!=0) + { + lablesWithVolume++; + + mitk::Color color (GetLabelColor(lablesWithVolume)); + lut->SetColorForLabel(i,color.GetRed(), color.GetGreen(), color.GetBlue(), 1.0); + + QColor qcolor; + qcolor.setRgbF(color.GetRed(), color.GetGreen(), color.GetBlue(), 0.7); + + //output volume as string "x.xx ml" + std::stringstream stream; + stream<< std::fixed << std::setprecision(2)<setText(QString::fromStdString(stream.str())); + item->setBackgroundColor(qcolor); + m_Controls.volumeList->addItem(item); + } + } + + + mitk::LookupTableProperty::Pointer lutProp = mitk::LookupTableProperty::New(lut.GetPointer()); + clippedNode->SetProperty("LookupTable", lutProp); + // it is absolutely important, to use the LevelWindow settings provided by + // the LUT generator, otherwise, it is not guaranteed, that colors show + // up correctly. + clippedNode->SetProperty("levelwindow", mitk::LevelWindowProperty::New(lut->GetLevelWindow())); +} + +mitk::DataStorage::SetOfObjects::ConstPointer QmitkDeformableClippingPlaneView::GetAllClippingPlanes() +{ + mitk::NodePredicateProperty::Pointer clipPredicate= mitk::NodePredicateProperty::New("clippingPlane",mitk::BoolProperty::New(true)); + mitk::DataStorage::SetOfObjects::ConstPointer allPlanes = m_ToolManager->GetDataStorage()->GetSubset(clipPredicate); + return allPlanes; +} + +mitk::Color QmitkDeformableClippingPlaneView::GetLabelColor(int label) +{ + float red, green, blue; + switch ( label % 6 ) + { + case 0: + {red = 1.0; green = 0.0; blue = 0.0; break;} + case 1: + {red = 0.0; green = 1.0; blue = 0.0; break;} + case 2: + {red = 0.0; green = 0.0; blue = 1.0;break;} + case 3: + {red = 1.0; green = 1.0; blue = 0.0;break;} + case 4: + {red = 1.0; green = 0.0; blue = 1.0;break;} + case 5: + {red = 0.0; green = 1.0; blue = 1.0;break;} + default: + {red = 0.0; green = 0.0; blue = 0.0;} + } + + float tmp[3] = { red, green, blue }; + + double factor; + + int outerCycleNr = label / 6; + int cycleSize = pow(2.0,(int)(log((double)(outerCycleNr))/log( 2.0 ))); + if (cycleSize==0) + cycleSize = 1; + int insideCycleCounter = outerCycleNr % cycleSize; + + if ( outerCycleNr == 0) + factor = 255; + + else + factor = ( 256 / ( 2 * cycleSize ) ) + ( insideCycleCounter * ( 256 / cycleSize ) ); + + tmp[0]= tmp[0]/256*factor; + tmp[1]= tmp[1]/256*factor; + tmp[2]= tmp[2]/256*factor; + + return mitk::Color(tmp); +} diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.h rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneViewControls.ui b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneViewControls.ui rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkDeformableClippingPlaneViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationControls.ui b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationControls.ui rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationOrganNamesHandling.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationOrganNamesHandling.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationOrganNamesHandling.cpp rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationOrganNamesHandling.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.cpp rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.h rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationPostProcessing.h diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp new file mode 100644 index 0000000000..9bc3565463 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.cpp @@ -0,0 +1,1227 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 1.12 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "mitkDataNodeObject.h" +#include "mitkProperties.h" +#include "mitkSegTool2D.h" +#include "mitkGlobalInteraction.h" + +#include "QmitkStdMultiWidget.h" +#include "QmitkNewSegmentationDialog.h" + +#include + +#include + +#include "QmitkSegmentationView.h" +#include "QmitkSegmentationPostProcessing.h" +#include "QmitkSegmentationOrganNamesHandling.cpp" + +#include +#include + +//For Segmentation in rotated slices +//TODO clean up includes +#include "mitkVtkResliceInterpolationProperty.h" +#include "mitkPlanarCircle.h" + +#include "mitkGetModuleContext.h" +#include "mitkModule.h" +#include "mitkModuleRegistry.h" + +const std::string QmitkSegmentationView::VIEW_ID = +"org.mitk.views.segmentation"; + +// public methods + +QmitkSegmentationView::QmitkSegmentationView() +:m_Parent(NULL) +,m_Controls(NULL) +,m_MultiWidget(NULL) +,m_RenderingManagerObserverTag(0) +{ +} + +QmitkSegmentationView::~QmitkSegmentationView() +{ + // delete m_PostProcessing; + delete m_Controls; +} + +void QmitkSegmentationView::NewNodesGenerated() +{ +// ForceDisplayPreferencesUponAllImages(); +} + +void QmitkSegmentationView::NewNodeObjectsGenerated(mitk::ToolManager::DataVectorType* nodes) +{ + if (!nodes) return; + + mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); + if (!toolManager) return; + for (mitk::ToolManager::DataVectorType::iterator iter = nodes->begin(); iter != nodes->end(); ++iter) + { + this->FireNodeSelected( *iter ); + // only last iteration meaningful, multiple generated objects are not taken into account here + } +} + +void QmitkSegmentationView::Activated() +{ + // should be moved to ::BecomesVisible() or similar + if( m_Controls ) + { + m_Controls->m_ManualToolSelectionBox->setEnabled( true ); + m_Controls->m_OrganToolSelectionBox->setEnabled( true ); + m_Controls->m_LesionToolSelectionBox->setEnabled( true ); + + m_Controls->m_SlicesInterpolator->Enable3DInterpolation( m_Controls->widgetStack->currentWidget() == m_Controls->pageManual ); + + //TODO Remove Observer + itk::ReceptorMemberCommand::Pointer command1 = itk::ReceptorMemberCommand::New(); + command1->SetCallbackFunction( this, &QmitkSegmentationView::RenderingManagerReinitialized ); + m_RenderingManagerObserverTag = mitk::RenderingManager::GetInstance()->AddObserver( mitk::RenderingManagerViewsInitializedEvent(), command1 ); + + //Adding observers for node visibility to existing segmentations + mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); + mitk::NodePredicateProperty::Pointer isBinary = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)); + mitk::NodePredicateAnd::Pointer isSegmentation = mitk::NodePredicateAnd::New( isImage, isBinary ); + + mitk::DataStorage::SetOfObjects::ConstPointer segmentations = this->GetDefaultDataStorage()->GetSubset( isSegmentation ); + + for ( mitk::DataStorage::SetOfObjects::const_iterator iter = segmentations->begin(); + iter != segmentations->end(); + ++iter) + { + mitk::DataNode* node = *iter; + itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + command->SetCallbackFunction(this, &QmitkSegmentationView::OnWorkingNodeVisibilityChanged); + m_WorkingDataObserverTags.insert( std::pair( node, node->GetProperty("visible")->AddObserver( itk::ModifiedEvent(), command ) ) ); + } + + if(segmentations->Size() > 0) + { + FireNodeSelected(segmentations->ElementAt(0)); + segmentations->ElementAt(0)->GetProperty("visible")->Modified(); + } + } +} + +void QmitkSegmentationView::Deactivated() +{ + if( m_Controls ) + { + mitk::RenderingManager::GetInstance()->RemoveObserver( m_RenderingManagerObserverTag ); + m_Controls->m_ManualToolSelectionBox->setEnabled( false ); + //deactivate all tools + m_Controls->m_ManualToolSelectionBox->GetToolManager()->ActivateTool(-1); + m_Controls->m_OrganToolSelectionBox->setEnabled( false ); + m_Controls->m_LesionToolSelectionBox->setEnabled( false ); + m_Controls->m_SlicesInterpolator->EnableInterpolation( false ); + + //Removing all observers + for ( NodeTagMapType::iterator dataIter = m_WorkingDataObserverTags.begin(); dataIter != m_WorkingDataObserverTags.end(); ++dataIter ) + { + (*dataIter).first->GetProperty("visible")->RemoveObserver( (*dataIter).second ); + } + m_WorkingDataObserverTags.clear(); + + // gets the context of the "Mitk" (Core) module (always has id 1) + // TODO Workaround until CTL plugincontext is available + mitk::ModuleContext* context = mitk::ModuleRegistry::GetModule(1)->GetModuleContext(); + // Workaround end + mitk::ServiceReference serviceRef = context->GetServiceReference(); + //mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); + mitk::PlanePositionManagerService* service = dynamic_cast(context->GetService(serviceRef)); + service->RemoveAllPlanePositions(); + } +} + +void QmitkSegmentationView::StdMultiWidgetAvailable( QmitkStdMultiWidget& stdMultiWidget ) +{ + SetMultiWidget(&stdMultiWidget); +} + +void QmitkSegmentationView::StdMultiWidgetNotAvailable() +{ + SetMultiWidget(NULL); +} + +void QmitkSegmentationView::StdMultiWidgetClosed( QmitkStdMultiWidget& /*stdMultiWidget*/ ) +{ + SetMultiWidget(NULL); +} + +void QmitkSegmentationView::SetMultiWidget(QmitkStdMultiWidget* multiWidget) +{ + if (m_MultiWidget) + { + mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); + if (coordinator) + { + coordinator->RemoveObserver( m_SlicesRotationObserverTag1 ); + } + coordinator = m_MultiWidget->GetSlicesSwiveller(); + if (coordinator) + { + coordinator->RemoveObserver( m_SlicesRotationObserverTag2 ); + } + } + + // save the current multiwidget as the working widget + m_MultiWidget = multiWidget; + + //TODO Remove Observers + if (m_MultiWidget) + { + mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); + if (coordinator) + { + itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); + command2->SetCallbackFunction( this, &QmitkSegmentationView::SliceRotation ); + m_SlicesRotationObserverTag1 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + } + + coordinator = m_MultiWidget->GetSlicesSwiveller(); + if (coordinator) + { + itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); + command2->SetCallbackFunction( this, &QmitkSegmentationView::SliceRotation ); + m_SlicesRotationObserverTag2 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + } + } + //TODO End Remove Observers + + if (m_Parent) + { + m_Parent->setEnabled(m_MultiWidget); + } + + // tell the interpolation about toolmanager and multiwidget (and data storage) + if (m_Controls && m_MultiWidget) + { + mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); + m_Controls->m_SlicesInterpolator->SetDataStorage( *(this->GetDefaultDataStorage())); + m_Controls->m_SlicesInterpolator->Initialize( toolManager, m_MultiWidget ); + } +} + +void QmitkSegmentationView::OnPreferencesChanged(const berry::IBerryPreferences*) +{ + ForceDisplayPreferencesUponAllImages(); +} + +//TODO remove function +void QmitkSegmentationView::RenderingManagerReinitialized(const itk::EventObject&) +{ + CheckImageAlignment(); +} + +//TODO remove function +void QmitkSegmentationView::SliceRotation(const itk::EventObject&) +{ + CheckImageAlignment(); +} + + +// protected slots + +void QmitkSegmentationView::CreateNewSegmentation() +{ + mitk::DataNode::Pointer node = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); + if (node.IsNotNull()) + { + mitk::Image::Pointer image = dynamic_cast( node->GetData() ); + if (image.IsNotNull()) + { + if (image->GetDimension()>1) + { + // ask about the name and organ type of the new segmentation + QmitkNewSegmentationDialog* dialog = new QmitkNewSegmentationDialog( m_Parent ); // needs a QWidget as parent, "this" is not QWidget + + QString storedList = QString::fromStdString( this->GetPreferences()->GetByteArray("Organ-Color-List","") ); + QStringList organColors; + if (storedList.isEmpty()) + { + organColors = GetDefaultOrganColorString(); + } + else + { + /* + a couple of examples of how organ names are stored: + + a simple item is built up like 'name#AABBCC' where #AABBCC is the hexadecimal notation of a color as known from HTML + + items are stored separated by ';' + this makes it necessary to escape occurrences of ';' in name. + otherwise the string "hugo;ypsilon#AABBCC;eugen#AABBCC" could not be parsed as two organs + but we would get "hugo" and "ypsilon#AABBCC" and "eugen#AABBCC" + + so the organ name "hugo;ypsilon" is stored as "hugo\;ypsilon" + and must be unescaped after loading + + the following lines could be one split with Perl's negative lookbehind + */ + + // recover string list from BlueBerry view's preferences + QString storedString = QString::fromStdString( this->GetPreferences()->GetByteArray("Organ-Color-List","") ); + MITK_DEBUG << "storedString: " << storedString.toStdString(); + // match a string consisting of any number of repetitions of either "anything but ;" or "\;". This matches everything until the next unescaped ';' + QRegExp onePart("(?:[^;]|\\\\;)*"); + MITK_DEBUG << "matching " << onePart.pattern().toStdString(); + int count = 0; + int pos = 0; + while( (pos = onePart.indexIn( storedString, pos )) != -1 ) + { + ++count; + int length = onePart.matchedLength(); + if (length == 0) break; + QString matchedString = storedString.mid(pos, length); + MITK_DEBUG << " Captured length " << length << ": " << matchedString.toStdString(); + pos += length + 1; // skip separating ';' + + // unescape possible occurrences of '\;' in the string + matchedString.replace("\\;", ";"); + + // add matched string part to output list + organColors << matchedString; + } + MITK_DEBUG << "Captured " << count << " organ name/colors"; + } + + dialog->SetSuggestionList( organColors ); + + int dialogReturnValue = dialog->exec(); + + if ( dialogReturnValue == QDialog::Rejected ) return; // user clicked cancel or pressed Esc or something similar + + // ask the user about an organ type and name, add this information to the image's (!) propertylist + // create a new image of the same dimensions and smallest possible pixel type + mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); + mitk::Tool* firstTool = toolManager->GetToolById(0); + if (firstTool) + { + try + { + mitk::DataNode::Pointer emptySegmentation = + firstTool->CreateEmptySegmentationNode( image, dialog->GetSegmentationName().toStdString(), dialog->GetColor() ); + + //Here we change the reslice interpolation mode for a segmentation, so that contours in rotated slice can be shown correctly + emptySegmentation->SetProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New(VTK_RESLICE_LINEAR) ); + // initialize showVolume to false to prevent recalculating the volume while working on the segmentation + emptySegmentation->SetProperty( "showVolume", mitk::BoolProperty::New( false ) ); + + if (!emptySegmentation) return; // could be aborted by user + + UpdateOrganList( organColors, dialog->GetSegmentationName(), dialog->GetColor() ); + + /* + escape ';' here (replace by '\;'), see longer comment above + */ + std::string stringForStorage = organColors.replaceInStrings(";","\\;").join(";").toStdString(); + MITK_DEBUG << "Will store: " << stringForStorage; + this->GetPreferences()->PutByteArray("Organ-Color-List", stringForStorage ); + this->GetPreferences()->Flush(); + + if(m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)) + { + m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)->SetSelected(false); + } + //emptySegmentation->SetSelected(true); + this->GetDefaultDataStorage()->Add( emptySegmentation, node ); // add as a child, because the segmentation "derives" from the original + + this->FireNodeSelected( emptySegmentation ); + this->OnSelectionChanged( emptySegmentation ); + this->SetToolManagerSelection(node, emptySegmentation); + } + catch (std::bad_alloc) + { + QMessageBox::warning(NULL,"Create new segmentation","Could not allocate memory for new segmentation"); + } + } + } + else + { + QMessageBox::information(NULL,"Segmentation","Segmentation is currently not supported for 2D images"); + } + } + } + else + { + MITK_ERROR << "'Create new segmentation' button should never be clickable unless a patient image is selected..."; + } +} + +void QmitkSegmentationView::OnWorkingNodeVisibilityChanged(/*const itk::Object* caller, const itk::EventObject& e*/) +{ + if (!m_Parent || !m_Parent->isVisible()) return; + + // The new selection behaviour is: + // + // When clicking on the checkbox of a segmentation the node will e selected and its reference node either + // The previous selected segmentation (if there is one) will be deselected. Additionally a reinit on the + // selected segmenation will be performed. + // If more than one segmentation is selected the tools will be disabled. + + if (!m_Controls) return; // might happen on initialization (preferences loaded) + mitk::DataNode::Pointer referenceDataNew = mitk::DataNode::New(); + mitk::DataNode::Pointer workingData; + + bool workingNodeIsVisible (true); + + unsigned int numberOfSelectedSegmentations (0); + + // iterate all images + mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); + + mitk::DataStorage::SetOfObjects::ConstPointer allImages = this->GetDefaultDataStorage()->GetSubset( isImage ); + for ( mitk::DataStorage::SetOfObjects::const_iterator iter = allImages->begin(); + iter != allImages->end(); + ++iter) + { + mitk::DataNode* node = *iter; + // apply display preferences + ApplyDisplayOptions(node); + + bool isSegmentation(false); + node->GetBoolProperty("binary", isSegmentation); + if (node->IsSelected() && isSegmentation) + { + workingNodeIsVisible = node->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))); + if (!workingNodeIsVisible) + return; + numberOfSelectedSegmentations++; + + workingData = node; + + if (this->GetDefaultDataStorage()->GetSources(node)->Size() != 0) + { + referenceDataNew = this->GetDefaultDataStorage()->GetSources(node)->ElementAt(0); + } + + bool isBinary(false); + + //Find topmost source or first source which is no binary image + while (referenceDataNew && this->GetDefaultDataStorage()->GetSources(referenceDataNew)->Size() != 0) + { + referenceDataNew = this->GetDefaultDataStorage()->GetSources(referenceDataNew)->ElementAt(0); + + referenceDataNew->GetBoolProperty("binary",isBinary); + if (!isBinary) + break; + } + + if (workingNodeIsVisible && referenceDataNew) + { + //Since the binary property of a segmentation can be set to false and afterwards you can create a new segmentation out of it + //->could lead to a deadloop + NodeTagMapType::iterator searchIter = m_WorkingDataObserverTags.find( referenceDataNew ); + if ( searchIter != m_WorkingDataObserverTags.end()) + { + referenceDataNew->GetProperty("visible")->RemoveObserver( (*searchIter).second ); + } + referenceDataNew->SetVisibility(true); + } + + //set comboBox to reference image + disconnect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); + + m_Controls->refImageSelector->setCurrentIndex( m_Controls->refImageSelector->Find(referenceDataNew) ); + + connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); + + continue; + } + if (workingData.IsNull() || (workingNodeIsVisible && node != referenceDataNew)) + { + node->SetVisibility((false)); + } + } + if(numberOfSelectedSegmentations == 1) + SetToolManagerSelection(referenceDataNew, workingData); + + mitk::DataStorage::SetOfObjects::Pointer temp = mitk::DataStorage::SetOfObjects::New(); + temp->InsertElement(0,workingData); + mitk::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(temp); + + // initialize the views to the bounding geometry + /*mitk::RenderingManager::GetInstance()->InitializeViews(bounds); + mitk::RenderingManager::GetInstance()->RequestUpdateAll();*/ +} + +void QmitkSegmentationView::NodeRemoved(const mitk::DataNode* node) +{ + bool isSeg(false); + bool isHelperObject(false); + node->GetBoolProperty("helper object", isHelperObject); + node->GetBoolProperty("binary", isSeg); + if(isSeg && !isHelperObject) + { + mitk::DataStorage::SetOfObjects::ConstPointer allContourMarkers = this->GetDataStorage()->GetDerivations(node, mitk::NodePredicateProperty::New("isContourMarker" + , mitk::BoolProperty::New(true))); + + // gets the context of the "Mitk" (Core) module (always has id 1) + // TODO Workaround until CTL plugincontext is available + mitk::ModuleContext* context = mitk::ModuleRegistry::GetModule(1)->GetModuleContext(); + // Workaround end + mitk::ServiceReference serviceRef = context->GetServiceReference(); + //mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); + + mitk::PlanePositionManagerService* service = dynamic_cast(context->GetService(serviceRef)); + + for (mitk::DataStorage::SetOfObjects::ConstIterator it = allContourMarkers->Begin(); it != allContourMarkers->End(); ++it) + { + std::string nodeName = node->GetName(); + unsigned int t = nodeName.find_last_of(" "); + unsigned int id = atof(nodeName.substr(t+1).c_str())-1; + + service->RemovePlanePosition(id); + + this->GetDataStorage()->Remove(it->Value()); + } + mitk::DataNode* tempNode = const_cast(node); + node->GetProperty("visible")->RemoveObserver( m_WorkingDataObserverTags[tempNode] ); + m_WorkingDataObserverTags.erase(tempNode); + this->SetToolManagerSelection(NULL, NULL); + } +} + +void QmitkSegmentationView::CreateSegmentationFromSurface() +{ + mitk::DataNode::Pointer surfaceNode = + m_Controls->MaskSurfaces->GetSelectedNode(); + mitk::Surface::Pointer surface(0); + if(surfaceNode.IsNotNull()) + surface = dynamic_cast ( surfaceNode->GetData() ); + if(surface.IsNull()) + { + this->HandleException( "No surface selected.", m_Parent, true); + return; + } + + mitk::DataNode::Pointer imageNode + = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); + mitk::Image::Pointer image(0); + if (imageNode.IsNotNull()) + image = dynamic_cast( imageNode->GetData() ); + if(image.IsNull()) + { + this->HandleException( "No image selected.", m_Parent, true); + return; + } + + mitk::SurfaceToImageFilter::Pointer s2iFilter + = mitk::SurfaceToImageFilter::New(); + + s2iFilter->MakeOutputBinaryOn(); + s2iFilter->SetInput(surface); + s2iFilter->SetImage(image); + s2iFilter->Update(); + + mitk::DataNode::Pointer resultNode = mitk::DataNode::New(); + std::string nameOfResultImage = imageNode->GetName(); + nameOfResultImage.append(surfaceNode->GetName()); + resultNode->SetProperty("name", mitk::StringProperty::New(nameOfResultImage) ); + resultNode->SetProperty("binary", mitk::BoolProperty::New(true) ); + resultNode->SetData( s2iFilter->GetOutput() ); + + this->GetDataStorage()->Add(resultNode, imageNode); + +} + +void QmitkSegmentationView::ManualToolSelected(int id) +{ + // disable crosshair movement when a manual drawing tool is active (otherwise too much visual noise) + if (m_MultiWidget) + { + if (id >= 0) + { + m_MultiWidget->DisableNavigationControllerEventListening(); + } + else + { + m_MultiWidget->EnableNavigationControllerEventListening(); + } + } +} + +void QmitkSegmentationView::ToolboxStackPageChanged(int id) +{ + // interpolation only with manual tools visible + m_Controls->m_SlicesInterpolator->EnableInterpolation( id == 0 ); + + if( id == 0 ) + { + mitk::DataNode::Pointer workingData = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0); + if( workingData.IsNotNull() ) + { + m_Controls->lblSegmentation->setText( workingData->GetName().c_str() ); + m_Controls->lblSegImage->show(); + m_Controls->lblSegmentation->show(); + } + } + else + { + m_Controls->lblSegImage->hide(); + m_Controls->lblSegmentation->hide(); + } + + // this is just a workaround, should be removed when all tools support 3D+t + if (id==2) // lesions + { + mitk::DataNode::Pointer node = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); + if (node.IsNotNull()) + { + mitk::Image::Pointer image = dynamic_cast( node->GetData() ); + if (image.IsNotNull()) + { + if (image->GetDimension()>3) + { + m_Controls->widgetStack->setCurrentIndex(0); + QMessageBox::information(NULL,"Segmentation","Lesion segmentation is currently not supported for 4D images"); + } + } + } + } +} + +// protected + +void QmitkSegmentationView::OnComboBoxSelectionChanged( const mitk::DataNode* node ) +{ + mitk::DataNode* selectedNode = const_cast(node); + if( selectedNode != NULL ) + { + m_Controls->refImageSelector->show(); + m_Controls->lblReferenceImageSelectionWarning->hide(); + + bool isBinary(false); + selectedNode->GetBoolProperty("binary", isBinary); + if ( isBinary ) + { + FireNodeSelected(selectedNode); + selectedNode->SetVisibility(true); + } + else if (node != m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0)) + { + if (m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0)) + m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0)->SetVisibility(false); + if (m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)) + { + m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0)->SetVisibility(false); + } + FireNodeSelected(selectedNode); + selectedNode->SetVisibility(true); + SetToolManagerSelection(selectedNode, NULL); + } + } + else + { + m_Controls->refImageSelector->hide(); + m_Controls->lblReferenceImageSelectionWarning->show(); + } +} + + +void QmitkSegmentationView::OnShowMarkerNodes (bool state) +{ + mitk::SegTool2D::Pointer manualSegmentationTool; + + unsigned int numberOfExistingTools = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetTools().size(); + + for(unsigned int i = 0; i < numberOfExistingTools; i++) + { + manualSegmentationTool = dynamic_cast(m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetToolById(i)); + + if (manualSegmentationTool) + { + if(state == true) + { + manualSegmentationTool->SetShowMarkerNodes( true ); + } + else + { + manualSegmentationTool->SetShowMarkerNodes( false ); + } + } + } +} + +void QmitkSegmentationView::On3DInterpolationEnabled (bool state) +{ + mitk::SegTool2D::Pointer manualSegmentationTool; + + unsigned int numberOfExistingTools = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetTools().size(); + + for(unsigned int i = 0; i < numberOfExistingTools; i++) +{ + manualSegmentationTool = dynamic_cast(m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetToolById(i)); + + if (manualSegmentationTool) + { + manualSegmentationTool->Enable3DInterpolation( state ); + } + } +} + +void QmitkSegmentationView::OnSelectionChanged(mitk::DataNode* node) +{ + std::vector nodes; + nodes.push_back( node ); + this->OnSelectionChanged( nodes ); +} + +void QmitkSegmentationView::OnSurfaceSelectionChanged() +{ + // if Image and Surface are selected, enable button + if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || + (m_Controls->MaskSurfaces->GetSelectedNode().IsNull())) + m_Controls->CreateSegmentationFromSurface->setEnabled(false); + else + m_Controls->CreateSegmentationFromSurface->setEnabled(true); +} + +void QmitkSegmentationView::OnSelectionChanged(std::vector nodes) +{ + // if the selected node is a contourmarker + if ( !nodes.empty() ) + { + std::string markerName = "Position"; + unsigned int numberOfNodes = nodes.size(); + std::string nodeName = nodes.at( 0 )->GetName(); + if ( ( numberOfNodes == 1 ) && ( nodeName.find( markerName ) == 0) ) + { + this->OnContourMarkerSelected( nodes.at( 0 ) ); + } + } + + // if Image and Surface are selected, enable button + if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || + (m_Controls->MaskSurfaces->GetSelectedNode().IsNull())) + m_Controls->CreateSegmentationFromSurface->setEnabled(false); + else + m_Controls->CreateSegmentationFromSurface->setEnabled(true); + + if (!m_Parent || !m_Parent->isVisible()) return; + + // reaction to BlueBerry selection events + // this method will try to figure out if a relevant segmentation and its corresponding original image were selected + // a warning is issued if the selection is invalid + // appropriate reactions are triggered otherwise + + mitk::DataNode::Pointer referenceData = FindFirstRegularImage( nodes ); //m_Controls->refImageSelector->GetSelectedNode(); //FindFirstRegularImage( nodes ); + mitk::DataNode::Pointer workingData = FindFirstSegmentation( nodes ); + + if(referenceData.IsNull() && workingData.IsNull()) + return; + + bool invalidSelection( !nodes.empty() && + ( + nodes.size() > 2 || // maximum 2 selected nodes + (nodes.size() == 2 && (workingData.IsNull() || referenceData.IsNull()) ) || // with two nodes, one must be the original image, one the segmentation + ( workingData.GetPointer() == referenceData.GetPointer() ) //one node is selected as reference and working image + // one item is always ok (might be working or reference or nothing + ) + ); + + if (invalidSelection) + { + // TODO visible warning when two images are selected + MITK_ERROR << "WARNING: No image, too many (>2) or two equal images were selected."; + workingData = NULL; + + if( m_Controls->refImageSelector->GetSelectedNode().IsNull() ) + referenceData = NULL; + } + + if ( workingData.IsNotNull() && referenceData.IsNull() ) + { + // find the DataStorage parent of workingData + // try to find a "normal image" parent, select this as reference image + mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); + mitk::NodePredicateProperty::Pointer isBinary = mitk::NodePredicateProperty::New("binary", mitk::BoolProperty::New(true)); + mitk::NodePredicateNot::Pointer isNotBinary = mitk::NodePredicateNot::New( isBinary ); + mitk::NodePredicateAnd::Pointer isNormalImage = mitk::NodePredicateAnd::New( isImage, isNotBinary ); + + mitk::DataStorage::SetOfObjects::ConstPointer possibleParents = this->GetDefaultDataStorage()->GetSources( workingData, isNormalImage ); + + if (possibleParents->size() > 0) + { + if (possibleParents->size() > 1) + { + // TODO visible warning for this rare case + MITK_ERROR << "Selected binary image has multiple parents. Using arbitrary first one for segmentation."; + } + + referenceData = (*possibleParents)[0]; + } + + NodeTagMapType::iterator searchIter = m_WorkingDataObserverTags.find( workingData ); + if ( searchIter == m_WorkingDataObserverTags.end() ) + { + //MITK_INFO<<"Creating new observer"; + itk::SimpleMemberCommand::Pointer command = itk::SimpleMemberCommand::New(); + command->SetCallbackFunction(this, &QmitkSegmentationView::OnWorkingNodeVisibilityChanged); + m_WorkingDataObserverTags.insert( std::pair( workingData, workingData->GetProperty("visible")->AddObserver( itk::ModifiedEvent(), command ) ) ); + workingData->GetProperty("visible")->Modified(); + + return; + } + + if(workingData->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1")))) + { + //set comboBox to reference image + disconnect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); + + m_Controls->refImageSelector->setCurrentIndex( m_Controls->refImageSelector->Find(workingData) ); + + connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); + + + // if Image and Surface are selected, enable button + if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || + (m_Controls->MaskSurfaces->GetSelectedNode().IsNull()) || + (!referenceData)) + m_Controls->CreateSegmentationFromSurface->setEnabled(false); + else + m_Controls->CreateSegmentationFromSurface->setEnabled(true); + + SetToolManagerSelection(referenceData, workingData); + FireNodeSelected(workingData); + } + else + { + SetToolManagerSelection(NULL, NULL); + FireNodeSelected(workingData); + } + + } + else + { + //set comboBox to reference image + disconnect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); + + m_Controls->refImageSelector->setCurrentIndex( m_Controls->refImageSelector->Find(referenceData) ); + + connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); + + // if Image and Surface are selected, enable button + if ( (m_Controls->refImageSelector->GetSelectedNode().IsNull()) || + (m_Controls->MaskSurfaces->GetSelectedNode().IsNull()) || + (!referenceData)) + m_Controls->CreateSegmentationFromSurface->setEnabled(false); + else + m_Controls->CreateSegmentationFromSurface->setEnabled(true); + + SetToolManagerSelection(referenceData, workingData); + + FireNodeSelected(referenceData); + } +} + +void QmitkSegmentationView::OnContourMarkerSelected(const mitk::DataNode *node) +{ + //TODO renderWindow anders bestimmen, siehe CheckAlignment + QmitkRenderWindow* selectedRenderWindow = 0; + QmitkRenderWindow* RenderWindow1 = + this->GetActiveStdMultiWidget()->GetRenderWindow1(); + QmitkRenderWindow* RenderWindow2 = + this->GetActiveStdMultiWidget()->GetRenderWindow2(); + QmitkRenderWindow* RenderWindow3 = + this->GetActiveStdMultiWidget()->GetRenderWindow3(); + QmitkRenderWindow* RenderWindow4 = + this->GetActiveStdMultiWidget()->GetRenderWindow4(); + bool PlanarFigureInitializedWindow = false; + + // find initialized renderwindow + if (node->GetBoolProperty("PlanarFigureInitializedWindow", + PlanarFigureInitializedWindow, RenderWindow1->GetRenderer())) + { + selectedRenderWindow = RenderWindow1; + } + if (!selectedRenderWindow && node->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow2->GetRenderer())) + { + selectedRenderWindow = RenderWindow2; + } + if (!selectedRenderWindow && node->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow3->GetRenderer())) + { + selectedRenderWindow = RenderWindow3; + } + if (!selectedRenderWindow && node->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow4->GetRenderer())) + { + selectedRenderWindow = RenderWindow4; + } + + // make node visible + if (selectedRenderWindow) + { + std::string nodeName = node->GetName(); + unsigned int t = nodeName.find_last_of(" "); + unsigned int id = atof(nodeName.substr(t+1).c_str())-1; + + // gets the context of the "Mitk" (Core) module (always has id 1) + // TODO Workaround until CTL plugincontext is available + mitk::ModuleContext* context = mitk::ModuleRegistry::GetModule(1)->GetModuleContext(); + // Workaround end + mitk::ServiceReference serviceRef = context->GetServiceReference(); + //mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); + + mitk::PlanePositionManagerService* service = dynamic_cast(context->GetService(serviceRef)); + selectedRenderWindow->GetSliceNavigationController()->ExecuteOperation(service->GetPlanePosition(id)); + selectedRenderWindow->GetRenderer()->GetDisplayGeometry()->Fit(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } +} + + +mitk::DataNode::Pointer QmitkSegmentationView::FindFirstRegularImage( std::vector nodes ) +{ + if (nodes.empty()) return NULL; + + for(unsigned int i = 0; i < nodes.size(); ++i) + { + //mitk::DataNode::Pointer node = i.value() + bool isImage(false); + if (nodes.at(i)->GetData()) + { + isImage = dynamic_cast(nodes.at(i)->GetData()) != NULL; + } + + // make sure this is not a binary image + bool isSegmentation(false); + nodes.at(i)->GetBoolProperty("binary", isSegmentation); + + // return first proper mitk::Image + if (isImage && !isSegmentation) return nodes.at(i); + } + + return NULL; +} + + +mitk::DataNode::Pointer QmitkSegmentationView::FindFirstSegmentation( std::vector nodes ) +{ + if (nodes.empty()) return NULL; + + + for(unsigned int i = 0; i < nodes.size(); ++i) + { + bool isImage(false); + if (nodes.at(i)->GetData()) + { + isImage = dynamic_cast(nodes.at(i)->GetData()) != NULL; + } + + bool isSegmentation(false); + nodes.at(i)->GetBoolProperty("binary", isSegmentation); + + // return first proper binary mitk::Image + if (isImage && isSegmentation) + { + return nodes.at(i); + } + } + + return NULL; +} + +void QmitkSegmentationView::SetToolManagerSelection(const mitk::DataNode* referenceData, const mitk::DataNode* workingData) +{ + // called as a result of new BlueBerry selections + // tells the ToolManager for manual segmentation about new selections + // updates GUI information about what the user should select + mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); + toolManager->SetReferenceData(const_cast(referenceData)); + toolManager->SetWorkingData( const_cast(workingData)); + + + // check original image + m_Controls->btnNewSegmentation->setEnabled(referenceData != NULL); + if (referenceData) + { + m_Controls->lblReferenceImageSelectionWarning->hide(); + } + else + { + m_Controls->lblReferenceImageSelectionWarning->show(); + m_Controls->lblWorkingImageSelectionWarning->hide(); + m_Controls->lblSegImage->hide(); + m_Controls->lblSegmentation->hide(); + } + + //TODO remove statement + // check, wheter reference image is aligned like render windows. Otherwise display a visible warning (because 2D tools will probably not work) + CheckImageAlignment(); + + // check segmentation + if (referenceData) + { + if (!workingData) + { + m_Controls->lblWorkingImageSelectionWarning->show(); + + if( m_Controls->widgetStack->currentIndex() == 0 ) + { + m_Controls->lblSegImage->hide(); + m_Controls->lblSegmentation->hide(); + } + } + else + { + m_Controls->lblWorkingImageSelectionWarning->hide(); + this->FireNodeSelected(const_cast(workingData)); + + if( m_Controls->widgetStack->currentIndex() == 0 ) + { + m_Controls->lblSegmentation->setText( workingData->GetName().c_str() ); + m_Controls->lblSegmentation->show(); + m_Controls->lblSegImage->show(); + } + } + } +} + +//TODO remove function +void QmitkSegmentationView::CheckImageAlignment() +{ + bool wrongAlignment(true); + + mitk::DataNode::Pointer node = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); + if (node.IsNotNull()) + { + mitk::Image::Pointer image = dynamic_cast( node->GetData() ); + + if (image.IsNotNull() && m_MultiWidget) + { + + wrongAlignment = !( IsRenderWindowAligned(m_MultiWidget->GetRenderWindow1(), image ) + && IsRenderWindowAligned(m_MultiWidget->GetRenderWindow2(), image ) + && IsRenderWindowAligned(m_MultiWidget->GetRenderWindow3(), image ) + ); + } + + if (wrongAlignment) + { + m_Controls->lblAlignmentWarning->show(); + } + } +} + +//TODO remove function +bool QmitkSegmentationView::IsRenderWindowAligned(QmitkRenderWindow* renderWindow, mitk::Image* image) +{ + if (!renderWindow) return false; + + // for all 2D renderwindows of m_MultiWidget check alignment + mitk::PlaneGeometry::ConstPointer displayPlane = dynamic_cast( renderWindow->GetRenderer()->GetCurrentWorldGeometry2D() ); + if (displayPlane.IsNull()) return false; + + int affectedDimension(-1); + int affectedSlice(-1); + return mitk::SegTool2D::DetermineAffectedImageSlice( image, displayPlane, affectedDimension, affectedSlice ); +} + +//TODO remove function +void QmitkSegmentationView::ForceDisplayPreferencesUponAllImages() +{ + if (!m_Parent || !m_Parent->isVisible()) return; + + // check all images and segmentations in DataStorage: + // (items in brackets are implicitly done by previous steps) + // 1. + // if a reference image is selected, + // show the reference image + // and hide all other images (orignal and segmentation), + // (and hide all segmentations of the other original images) + // and show all the reference's segmentations + // if no reference image is selected, do do nothing + // + // 2. + // if a segmentation is selected, + // show it + // (and hide all all its siblings (childs of the same parent, incl, NULL parent)) + // if no segmentation is selected, do nothing + + if (!m_Controls) return; // might happen on initialization (preferences loaded) + mitk::DataNode::Pointer referenceData = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetReferenceData(0); + mitk::DataNode::Pointer workingData = m_Controls->m_ManualToolSelectionBox->GetToolManager()->GetWorkingData(0); + + // 1. + if (referenceData.IsNotNull()) + { + // iterate all images + mitk::TNodePredicateDataType::Pointer isImage = mitk::TNodePredicateDataType::New(); + + mitk::DataStorage::SetOfObjects::ConstPointer allImages = this->GetDefaultDataStorage()->GetSubset( isImage ); + //mitk::DataStorage::SetOfObjects::ConstPointer allSegmentationChilds = this->GetDefaultDataStorage()->GetDerivations(referenceData, isImage ); + for ( mitk::DataStorage::SetOfObjects::const_iterator iter = allImages->begin(); + iter != allImages->end(); + ++iter) + + { + mitk::DataNode* node = *iter; + // apply display preferences + ApplyDisplayOptions(node); + + // set visibility + if(!node->IsSelected() || (node->IsSelected() && !node->IsVisible(mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1"))))) + node->SetVisibility((node == referenceData) || node->IsSelected() ); + } + } + + // 2. + //if (workingData.IsNotNull() && !workingData->IsSelected()) + //{ + // workingData->SetVisibility(true); + //} + + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkSegmentationView::ApplyDisplayOptions(mitk::DataNode* node) +{ + if (!node) return; + + bool isBinary(false); + node->GetPropertyValue("binary", isBinary); + + if (isBinary) + { + node->SetProperty( "outline binary", mitk::BoolProperty::New( this->GetPreferences()->GetBool("draw outline", true)) ); + node->SetProperty( "outline width", mitk::FloatProperty::New( 2.0 ) ); + node->SetProperty( "opacity", mitk::FloatProperty::New( this->GetPreferences()->GetBool("draw outline", true) ? 1.0 : 0.3 ) ); + node->SetProperty( "volumerendering", mitk::BoolProperty::New( this->GetPreferences()->GetBool("volume rendering", false) ) ); + } +} + +void QmitkSegmentationView::CreateQtPartControl(QWidget* parent) +{ + // setup the basic GUI of this view + m_Parent = parent; + + m_Controls = new Ui::QmitkSegmentationControls; + m_Controls->setupUi(parent); + m_Controls->lblWorkingImageSelectionWarning->hide(); + m_Controls->lblAlignmentWarning->hide(); + m_Controls->lblSegImage->hide(); + m_Controls->lblSegmentation->hide(); + + m_Controls->refImageSelector->SetDataStorage(this->GetDefaultDataStorage()); + m_Controls->refImageSelector->SetPredicate(mitk::NodePredicateDataType::New("Image")); + + if( m_Controls->refImageSelector->GetSelectedNode().IsNotNull() ) + m_Controls->lblReferenceImageSelectionWarning->hide(); + else + m_Controls->refImageSelector->hide(); + + + mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); + toolManager->SetDataStorage( *(this->GetDefaultDataStorage()) ); + assert ( toolManager ); + + // all part of open source MITK + m_Controls->m_ManualToolSelectionBox->SetGenerateAccelerators(true); + m_Controls->m_ManualToolSelectionBox->SetToolGUIArea( m_Controls->m_ManualToolGUIContainer ); + m_Controls->m_ManualToolSelectionBox->SetDisplayedToolGroups("Add Subtract Paint Wipe 'Region Growing' Correction Fill Erase"); + m_Controls->m_ManualToolSelectionBox->SetEnabledMode( QmitkToolSelectionBox::EnabledWithReferenceAndWorkingData ); + + // available only in the 3M application + if ( !m_Controls->m_OrganToolSelectionBox->children().count() ) + { + m_Controls->widgetStack->setItemEnabled( 1, false ); + } + m_Controls->m_OrganToolSelectionBox->SetToolManager( *toolManager ); + m_Controls->m_OrganToolSelectionBox->SetToolGUIArea( m_Controls->m_OrganToolGUIContainer ); + m_Controls->m_OrganToolSelectionBox->SetDisplayedToolGroups("'Hippocampus left' 'Hippocampus right' 'Lung left' 'Lung right' 'Liver' 'Heart LV' 'Endocard LV' 'Epicard LV' 'Prostate'"); + m_Controls->m_OrganToolSelectionBox->SetEnabledMode( QmitkToolSelectionBox::EnabledWithReferenceData ); + + // available only in the 3M application + if ( !m_Controls->m_LesionToolSelectionBox->children().count() ) + { + m_Controls->widgetStack->setItemEnabled( 2, false ); + } + m_Controls->m_LesionToolSelectionBox->SetToolManager( *toolManager ); + m_Controls->m_LesionToolSelectionBox->SetToolGUIArea( m_Controls->m_LesionToolGUIContainer ); + m_Controls->m_LesionToolSelectionBox->SetDisplayedToolGroups("'Lymph Node'"); + m_Controls->m_LesionToolSelectionBox->SetEnabledMode( QmitkToolSelectionBox::EnabledWithReferenceData ); + + toolManager->NewNodesGenerated += + mitk::MessageDelegate( this, &QmitkSegmentationView::NewNodesGenerated ); // update the list of segmentations + toolManager->NewNodeObjectsGenerated += + mitk::MessageDelegate1( this, &QmitkSegmentationView::NewNodeObjectsGenerated ); // update the list of segmentations + + // create signal/slot connections + connect( m_Controls->refImageSelector, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnComboBoxSelectionChanged( const mitk::DataNode* ) ) ); + connect( m_Controls->btnNewSegmentation, SIGNAL(clicked()), this, SLOT(CreateNewSegmentation()) ); + connect( m_Controls->CreateSegmentationFromSurface, SIGNAL(clicked()), this, SLOT(CreateSegmentationFromSurface()) ); + connect( m_Controls->m_ManualToolSelectionBox, SIGNAL(ToolSelected(int)), this, SLOT(ManualToolSelected(int)) ); + connect( m_Controls->widgetStack, SIGNAL(currentChanged(int)), this, SLOT(ToolboxStackPageChanged(int)) ); + + connect(m_Controls->MaskSurfaces, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnSurfaceSelectionChanged( ) ) ); + + connect(m_Controls->MaskSurfaces, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ), + this, SLOT( OnSurfaceSelectionChanged( ) ) ); + + connect(m_Controls->m_SlicesInterpolator, SIGNAL(SignalShowMarkerNodes(bool)), this, SLOT(OnShowMarkerNodes(bool))); + connect(m_Controls->m_SlicesInterpolator, SIGNAL(Signal3DInterpolationEnabled(bool)), this, SLOT(On3DInterpolationEnabled(bool))); + + m_Controls->MaskSurfaces->SetDataStorage(this->GetDefaultDataStorage()); + m_Controls->MaskSurfaces->SetPredicate(mitk::NodePredicateDataType::New("Surface")); + + //// create helper class to provide context menus for segmentations in data manager + // m_PostProcessing = new QmitkSegmentationPostProcessing(this->GetDefaultDataStorage(), this, m_Parent); + +} + +//void QmitkSegmentationView::OnPlaneModeChanged(int i) +//{ +// //if plane mode changes, disable all tools +// if (m_MultiWidget) +// { +// mitk::ToolManager* toolManager = m_Controls->m_ManualToolSelectionBox->GetToolManager(); +// +// if (toolManager) +// { +// if (toolManager->GetActiveToolID() >= 0) +// { +// toolManager->ActivateTool(-1); +// } +// else +// { +// m_MultiWidget->EnableNavigationControllerEventListening(); +// } +// } +// } +//} + + +// ATTENTION some methods for handling the known list of (organ names, colors) are defined in QmitkSegmentationOrganNamesHandling.cpp + diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h new file mode 100644 index 0000000000..4da59269b7 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkSegmentationView.h @@ -0,0 +1,168 @@ +/*====================================================================== +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 1.12 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkSegmentationView_h +#define QmitkSegmentationView_h + +#include "QmitkFunctionality.h" + +#include + +#include "ui_QmitkSegmentationControls.h" + + +class QmitkRenderWindow; +// class QmitkSegmentationPostProcessing; + +/** + * \ingroup ToolManagerEtAl + * \ingroup org_mitk_gui_qt_segmentation_internal + * \warning Implementation of this class is split up into two .cpp files to make things more compact. Check both this file and QmitkSegmentationOrganNamesHandling.cpp + */ +class QmitkSegmentationView : public QmitkFunctionality +{ + Q_OBJECT + +public: + + QmitkSegmentationView(); + + virtual ~QmitkSegmentationView(); + + typedef std::map NodeTagMapType; + + /*! + \brief Invoked when the DataManager selection changed + */ + virtual void OnSelectionChanged(mitk::DataNode* node); + virtual void OnSelectionChanged(std::vector nodes); + + // reaction to new segmentations being created by segmentation tools + void NewNodesGenerated(); + void NewNodeObjectsGenerated(mitk::ToolManager::DataVectorType*); + + // QmitkFunctionality's activate/deactivate + virtual void Activated(); + virtual void Deactivated(); + + // QmitkFunctionality's changes regarding THE QmitkStdMultiWidget + virtual void StdMultiWidgetAvailable(QmitkStdMultiWidget& stdMultiWidget); + virtual void StdMultiWidgetNotAvailable(); + virtual void StdMultiWidgetClosed(QmitkStdMultiWidget& stdMultiWidget); + + // BlueBerry's notification about preference changes (e.g. from a dialog) + virtual void OnPreferencesChanged(const berry::IBerryPreferences*); + + // observer to mitk::RenderingManager's RenderingManagerViewsInitializedEvent event + void RenderingManagerReinitialized(const itk::EventObject&); + + // observer to mitk::SliceController's SliceRotation event + void SliceRotation(const itk::EventObject&); + + static const std::string VIEW_ID; + +protected slots: + + void OnComboBoxSelectionChanged(const mitk::DataNode* node); + + // reaction to the button "New segmentation" + void CreateNewSegmentation(); + + // reaction to the button "New segmentation" + void CreateSegmentationFromSurface(); + + // called when a segmentation tool is activated + void ManualToolSelected(int id); + + // called when one of "Manual", "Organ", "Lesion" pages of the QToolbox is selected + void ToolboxStackPageChanged(int id); + + void OnSurfaceSelectionChanged(); + + //called when the checkbox Remember Contour Positions is selected/deselected + + void OnWorkingNodeVisibilityChanged(); + + void OnShowMarkerNodes(bool); + + void On3DInterpolationEnabled(bool); + +protected: + + // a type for handling lists of DataNodes + typedef std::vector NodeList; + + // set available multiwidget + void SetMultiWidget(QmitkStdMultiWidget* multiWidget); + + // actively query the current selection of data manager + //void PullCurrentDataManagerSelection(); + + // reactions to selection events from data manager (and potential other senders) + //void BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection); + mitk::DataNode::Pointer FindFirstRegularImage( std::vector nodes ); + mitk::DataNode::Pointer FindFirstSegmentation( std::vector nodes ); + + // propagate BlueBerry selection to ToolManager for manual segmentation + void SetToolManagerSelection(const mitk::DataNode* referenceData, const mitk::DataNode* workingData); + + // checks if selected reference image is aligned with the slices stack orientation of the StdMultiWidget + void CheckImageAlignment(); + + // checks if given render window aligns with the slices of given image + bool IsRenderWindowAligned(QmitkRenderWindow* renderWindow, mitk::Image* image); + + // make sure all images/segmentations look as selected by the users in this view's preferences + void ForceDisplayPreferencesUponAllImages(); + + // decorates a DataNode according to the user preference settings + void ApplyDisplayOptions(mitk::DataNode* node); + + // GUI setup + void CreateQtPartControl(QWidget* parent); + + // handling of a list of known (organ name, organ color) combination + // ATTENTION these methods are defined in QmitkSegmentationOrganNamesHandling.cpp + QStringList GetDefaultOrganColorString(); + void UpdateOrganList(QStringList& organColors, const QString& organname, mitk::Color colorname); + void AppendToOrganList(QStringList& organColors, const QString& organname, int r, int g, int b); + + // If a contourmarker is selected, the plane in the related widget will be reoriented according to the marker`s geometry + void OnContourMarkerSelected (const mitk::DataNode* node); + + void NodeRemoved(const mitk::DataNode* node); + + // the Qt parent of our GUI (NOT of this object) + QWidget* m_Parent; + + // our GUI + Ui::QmitkSegmentationControls * m_Controls; + + // THE currently existing QmitkStdMultiWidget + QmitkStdMultiWidget * m_MultiWidget; + + // QmitkSegmentationPostProcessing* m_PostProcessing; + + unsigned long m_RenderingManagerObserverTag; + unsigned long m_SlicesRotationObserverTag1; + unsigned long m_SlicesRotationObserverTag2; + unsigned long m_VisibilityChangedObserverTag; + + NodeTagMapType m_WorkingDataObserverTags; +}; + +#endif /*QMITKsegmentationVIEW_H_*/ + diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp new file mode 100644 index 0000000000..8ae4b2ceaf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.cpp @@ -0,0 +1,40 @@ +#include "QmitkStatisticsAction.h" + +QmitkStatisticsAction::QmitkStatisticsAction(): m_BlueBerryView(NULL) +{ +} + +QmitkStatisticsAction::~QmitkStatisticsAction() +{ +} + +void QmitkStatisticsAction::Run(const QList& /*selectedNodes*/) +{ + berry::IBundle::Pointer imageStatisticsBundle = berry::Platform::GetBundle("org.mitk.gui.qt.imagestatistics"); + + if (m_BlueBerryView && imageStatisticsBundle.IsNotNull()) + { + m_BlueBerryView->GetSite()->GetWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagestatistics"); + } +} + +void QmitkStatisticsAction::SetFunctionality(berry::QtViewPart* functionality) +{ + this->m_BlueBerryView = functionality; +} + +void QmitkStatisticsAction::SetDataStorage(mitk::DataStorage* /*dataStorage*/) +{ + //not needed +} + +void QmitkStatisticsAction::SetSmoothed(bool /*smoothed*/) +{ + //not needed +} + +void QmitkStatisticsAction::SetDecimated(bool /*decimated*/) +{ + //not needed +} + diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h new file mode 100644 index 0000000000..21a181da3a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkStatisticsAction.h @@ -0,0 +1,35 @@ +#ifndef QMITK_STATISTICSACTION_H +#define QMITK_STATISTICSACTION_H + +#include +#include "berryQtViewPart.h" + +#include "mitkIContextMenuAction.h" + +#include "org_mitk_gui_qt_segmentation_Export.h" + +class QmitkStdMultiWidget; + +class MITK_QT_SEGMENTATION QmitkStatisticsAction: public QObject, public mitk::IContextMenuAction +{ + Q_OBJECT + Q_INTERFACES(mitk::IContextMenuAction) + +public: + + QmitkStatisticsAction(); + virtual ~QmitkStatisticsAction(); + + //interface methods + void Run( const QList& selectedNodes ); + void SetDataStorage(mitk::DataStorage* dataStorage); + void SetSmoothed(bool smoothed); + void SetDecimated(bool decimated); + void SetFunctionality(berry::QtViewPart* functionality); + +protected: + + //needs to be set over the IContextMenuAction (with this - QmitkDataManagerView - as parameter) + berry::QtViewPart* m_BlueBerryView; +}; +#endif // QMITK_STATISTICSACTION_H diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp new file mode 100644 index 0000000000..e48fdcad33 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp @@ -0,0 +1,99 @@ +#include "QmitkThresholdAction.h" + +// MITK +#include +#include +#include + +// Qt +#include +#include + +using namespace berry; +using namespace mitk; +using namespace std; + +QmitkThresholdAction::QmitkThresholdAction() + : m_ThresholdingDialog(NULL) +{ +} + +QmitkThresholdAction::~QmitkThresholdAction() +{ +} + +void QmitkThresholdAction::Run(const QList &selectedNodes) +{ + m_ThresholdingToolManager = ToolManager::New(m_DataStorage); + + m_ThresholdingToolManager->RegisterClient(); + m_ThresholdingToolManager->ActiveToolChanged += mitk::MessageDelegate(this, &QmitkThresholdAction::OnThresholdingToolManagerToolModified); + + m_ThresholdingDialog = new QDialog; + connect(m_ThresholdingDialog, SIGNAL(finished(int)), this, SLOT(ThresholdingDone(int))); + + QVBoxLayout *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + + Tool *binaryThresholdTool = m_ThresholdingToolManager->GetToolById(m_ThresholdingToolManager->GetToolIdByToolType()); + + if (binaryThresholdTool != NULL) + { + QmitkToolGUI *gui = dynamic_cast(binaryThresholdTool->GetGUI("Qmitk", "GUI").GetPointer()); + + if (gui != NULL) + { + gui->SetTool(binaryThresholdTool); + gui->setParent(m_ThresholdingDialog); + + layout->addWidget(gui); + + m_ThresholdingDialog->setLayout(layout); + m_ThresholdingDialog->setFixedSize(300, 80); + + m_ThresholdingDialog->open(); + } + + m_ThresholdingToolManager->SetReferenceData(selectedNodes[0]); + m_ThresholdingToolManager->ActivateTool(m_ThresholdingToolManager->GetToolIdByToolType()); + } +} + +void QmitkThresholdAction::ThresholdingDone(int result) +{ + if (result == QDialog::Rejected) + m_ThresholdingToolManager->ActivateTool(-1); + + m_ThresholdingDialog->deleteLater(); + m_ThresholdingDialog = NULL; + + m_ThresholdingToolManager->SetReferenceData(NULL); + m_ThresholdingToolManager->SetWorkingData(NULL); + + RenderingManager::GetInstance()->RequestUpdateAll(); +} + +void QmitkThresholdAction::OnThresholdingToolManagerToolModified() +{ + if (m_ThresholdingToolManager.IsNotNull()) + if (m_ThresholdingToolManager->GetActiveToolID() < 0) + if (m_ThresholdingDialog != NULL) + m_ThresholdingDialog->accept(); +} + +void QmitkThresholdAction::SetDataStorage(DataStorage *dataStorage) +{ + m_DataStorage = dataStorage; +} + +void QmitkThresholdAction::SetSmoothed(bool) +{ +} + +void QmitkThresholdAction::SetDecimated(bool) +{ +} + +void QmitkThresholdAction::SetFunctionality(QtViewPart */*functionality*/) +{ +} diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h new file mode 100644 index 0000000000..467469e44a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h @@ -0,0 +1,47 @@ +#ifndef QMITKTHRESHOLDACTION_H +#define QMITKTHRESHOLDACTION_H + +#include + +// Parent classes +#include +#include + +// Data members +#include +#include + +class QDialog; +class QmitkStdMultiWidget; + +class MITK_QT_SEGMENTATION QmitkThresholdAction : public QObject, public mitk::IContextMenuAction +{ + Q_OBJECT + Q_INTERFACES(mitk::IContextMenuAction) + +public: + QmitkThresholdAction(); + ~QmitkThresholdAction(); + + // IContextMenuAction + void Run(const QList &selectedNodes); + void SetDataStorage(mitk::DataStorage *dataStorage); + void SetSmoothed(bool smoothed); + void SetDecimated(bool decimated); + void SetFunctionality(berry::QtViewPart *functionality); + + void OnThresholdingToolManagerToolModified(); + +private slots: + void ThresholdingDone(int); + +private: + QmitkThresholdAction(const QmitkThresholdAction &); + QmitkThresholdAction & operator=(const QmitkThresholdAction &); + + mitk::DataStorage::Pointer m_DataStorage; + mitk::ToolManager::Pointer m_ThresholdingToolManager; + QDialog *m_ThresholdingDialog; +}; + +#endif diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.cpp new file mode 100644 index 0000000000..c3b2bbcd69 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.cpp @@ -0,0 +1,88 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 17495 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +// Blueberry +#include +#include + +// Qmitk +#include "QmitkRegionGrowingView.h" +#include "QmitkStdMultiWidget.h" + +const std::string QmitkRegionGrowingView::VIEW_ID = "org.mitk.views.regiongrowing"; + +QmitkRegionGrowingView::QmitkRegionGrowingView() +: QmitkFunctionality() +, m_Controls( 0 ) +, m_MultiWidget( NULL ) +{ +} + +QmitkRegionGrowingView::~QmitkRegionGrowingView() +{ +} + +void QmitkRegionGrowingView::Deactivated() +{ +} + +void QmitkRegionGrowingView::CreateQtPartControl( QWidget *parent ) +{ + // build up qt view, unless already done + if ( !m_Controls ) + { + // create GUI widgets from the Qt Designer's .ui file + m_Controls = new Ui::QmitkRegionGrowingViewControls; + m_Controls->setupUi( parent ); + + m_Controls->m_AdaptiveRGWidget->SetDataStorage(this->GetDataStorage()); + m_Controls->m_AdaptiveRGWidget->CreateConnections(); + } +} + +void QmitkRegionGrowingView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) +{ + m_MultiWidget = &stdMultiWidget; + m_Controls->m_AdaptiveRGWidget->SetMultiWidget(&stdMultiWidget); +} + + +void QmitkRegionGrowingView::StdMultiWidgetNotAvailable() +{ + m_MultiWidget = NULL; +} + + +void QmitkRegionGrowingView::OnSelectionChanged( std::vector nodes ) +{ + // iterate all selected objects, adjust warning visibility + for( std::vector::iterator it = nodes.begin(); + it != nodes.end(); + ++it ) + { + mitk::DataNode::Pointer node = *it; + + if( node.IsNotNull() && dynamic_cast(node->GetData()) ) + { + m_Controls->lblWarning->setVisible( false ); + m_Controls->m_AdaptiveRGWidget->SetInputImageNode(node); + return; + } + } + + m_Controls->lblWarning->setVisible( true ); +} diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.h new file mode 100644 index 0000000000..f286d80523 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingView.h @@ -0,0 +1,82 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 17495 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QmitkRegionGrowingView_h +#define QmitkRegionGrowingView_h + +#include + +#include + +#include "ui_QmitkRegionGrowingViewControls.h" + + +/*! + \brief QmitkRegionGrowingView + + Functionality for demonstration of MITK basics. + + This functionality allows the user to set some seed points that are used for a simple region growing algorithm from ITK. + + \warning This is only for demonstration, it is NOT meant to be useful! + + \sa QmitkFunctionality + \ingroup Functionalities +*/ +class QmitkRegionGrowingView : public QmitkFunctionality +{ + // this is needed for all Qt objects that should have a Qt meta-object + // (everything that derives from QObject and wants to have signal/slots) + Q_OBJECT + + public: + + static const std::string VIEW_ID; + + QmitkRegionGrowingView(); + virtual ~QmitkRegionGrowingView(); + + virtual void CreateQtPartControl(QWidget *parent); + + virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); + virtual void StdMultiWidgetNotAvailable(); + virtual void Deactivated(); + + protected slots: + + protected: + + /*! + \brief ITK image processing function + This function is templated like an ITK image. The MITK-Macro AccessByItk determines the actual pixel type and dimensionality of + a given MITK image and calls this function for further processing (in our case region growing) + */ + template < typename TPixel, unsigned int VImageDimension > + void ItkImageProcessing( itk::Image< TPixel, VImageDimension >* itkImage, mitk::Geometry3D* imageGeometry, mitk::DataNode* parent, int thresholdOffset, unsigned int t ); + + /// \brief called by QmitkFunctionality when DataManager's selection has changed + virtual void OnSelectionChanged( std::vector nodes ); + + Ui::QmitkRegionGrowingViewControls* m_Controls; + + QmitkStdMultiWidget* m_MultiWidget; +}; + + + +#endif // _QMITKREGIONGROWINGVIEW_H_INCLUDED + diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingViewControls.ui b/Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingViewControls.ui rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/regiongrowing/QmitkRegionGrowingViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/segmentation.h b/Plugins/org.mitk.gui.qt.segmentation/src/internal/segmentation.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/segmentation.h rename to Plugins/org.mitk.gui.qt.segmentation/src/internal/segmentation.h diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/CMakeLists.txt b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/CMakeLists.txt new file mode 100755 index 0000000000..68c6d2852f --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/CMakeLists.txt @@ -0,0 +1,8 @@ +PROJECT(org_mitk_gui_qt_stdmultiwidgeteditor) + +MACRO_CREATE_MITK_CTK_PLUGIN( + EXPORT_DIRECTIVE ORG_MITK_GUI_QT_STDMULTIWIDGETEDITOR + EXPORTED_INCLUDE_SUFFIXES src + MODULE_DEPENDENCIES Qmitk + SUBPROJECTS MITK-CoreUI + ) diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/documentation/doxygen/modules.dox new file mode 100755 index 0000000000..2434b657bb --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_stdmultiwidgeteditor org.mitk.gui.qt.stdmultiwidgeteditor + \ingroup MITKPlugins + + \brief Contributes a QmitkStdMultiWidget based render window editor to the MITK Workbench. + +*/ + +/** + \defgroup org_mitk_gui_qt_stdmultiwidgeteditor_internal Internal + \ingroup org_mitk_gui_qt_stdmultiwidgeteditor + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.stdmultiwidgeteditor plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/files.cmake b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/files.cmake new file mode 100755 index 0000000000..4829f1df58 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/files.cmake @@ -0,0 +1,36 @@ +SET(SRC_CPP_FILES + QmitkStdMultiWidgetEditor.cpp +) + +SET(INTERNAL_CPP_FILES + org_mitk_gui_qt_stdmultiwidgeteditor_Activator.cpp + QmitkStdMultiWidgetEditorPreferencePage.cpp +) + +SET(MOC_H_FILES + src/QmitkStdMultiWidgetEditor.h + + src/internal/org_mitk_gui_qt_stdmultiwidgeteditor_Activator.h + src/internal/QmitkStdMultiWidgetEditorPreferencePage.h +) + +SET(UI_FILES + +) + +SET(CACHED_RESOURCE_FILES + plugin.xml +) + +SET(QRC_FILES +) + +SET(CPP_FILES ) + +foreach(file ${SRC_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/${file}) +endforeach(file ${SRC_CPP_FILES}) + +foreach(file ${INTERNAL_CPP_FILES}) + SET(CPP_FILES ${CPP_FILES} src/internal/${file}) +endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/manifest_headers.cmake new file mode 100644 index 0000000000..4f9014d2b5 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/manifest_headers.cmake @@ -0,0 +1,6 @@ +set(Plugin-Name "MITK StdMultiWidget Editor") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common) + diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/plugin.xml b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/plugin.xml new file mode 100644 index 0000000000..754a1a2286 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/plugin.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/QmitkStdMultiWidgetEditor.cpp b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/QmitkStdMultiWidgetEditor.cpp new file mode 100644 index 0000000000..4e0fd1b0cd --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/QmitkStdMultiWidgetEditor.cpp @@ -0,0 +1,410 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QmitkStdMultiWidgetEditor.h" + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + + +class QmitkStdMultiWidgetEditorPrivate +{ +public: + + QmitkStdMultiWidgetEditorPrivate(); + ~QmitkStdMultiWidgetEditorPrivate(); + + QmitkStdMultiWidget* m_StdMultiWidget; + QmitkMouseModeSwitcher* m_MouseModeToolbar; + std::string m_FirstBackgroundColor; + std::string m_SecondBackgroundColor; + berry::IPartListener::Pointer m_PartListener; + + QHash m_RenderWindows; +}; + +struct QmitkStdMultiWidgetPartListener : public berry::IPartListener +{ + berryObjectMacro(QmitkStdMultiWidgetPartListener) + + QmitkStdMultiWidgetPartListener(QmitkStdMultiWidgetEditorPrivate* dd) + : d(dd) + {} + + Events::Types GetPartEventTypes() const + { + return Events::CLOSED | Events::HIDDEN | Events::VISIBLE; + } + + void PartClosed (berry::IWorkbenchPartReference::Pointer partRef) + { + if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) + { + QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); + + if (d->m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) + { + d->m_StdMultiWidget->RemovePlanesFromDataStorage(); + } + } + } + + void PartHidden (berry::IWorkbenchPartReference::Pointer partRef) + { + if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) + { + QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); + + if (d->m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) + { + d->m_StdMultiWidget->RemovePlanesFromDataStorage(); + } + } + } + + void PartVisible (berry::IWorkbenchPartReference::Pointer partRef) + { + if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) + { + QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); + + if (d->m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) + { + d->m_StdMultiWidget->AddPlanesToDataStorage(); + } + } + } + +private: + + QmitkStdMultiWidgetEditorPrivate* const d; + +}; + +QmitkStdMultiWidgetEditorPrivate::QmitkStdMultiWidgetEditorPrivate() + : m_StdMultiWidget(0), m_MouseModeToolbar(0) + , m_PartListener(new QmitkStdMultiWidgetPartListener(this)) +{} + +QmitkStdMultiWidgetEditorPrivate::~QmitkStdMultiWidgetEditorPrivate() +{ +} + +const std::string QmitkStdMultiWidgetEditor::EDITOR_ID = "org.mitk.editors.stdmultiwidget"; + +QmitkStdMultiWidgetEditor::QmitkStdMultiWidgetEditor() + : d(new QmitkStdMultiWidgetEditorPrivate) +{ +} + +QmitkStdMultiWidgetEditor::~QmitkStdMultiWidgetEditor() +{ + this->GetSite()->GetPage()->RemovePartListener(d->m_PartListener); +} + +QmitkStdMultiWidget* QmitkStdMultiWidgetEditor::GetStdMultiWidget() +{ + return d->m_StdMultiWidget; +} + +QmitkRenderWindow *QmitkStdMultiWidgetEditor::GetActiveRenderWindow() const +{ + if (d->m_StdMultiWidget) return d->m_StdMultiWidget->GetRenderWindow1(); + return 0; +} + +QHash QmitkStdMultiWidgetEditor::GetRenderWindows() const +{ + return d->m_RenderWindows; +} + +QmitkRenderWindow *QmitkStdMultiWidgetEditor::GetRenderWindow(const QString &id) const +{ + if (d->m_RenderWindows.contains(id)) return d->m_RenderWindows[id]; + return 0; +} + +mitk::Point3D QmitkStdMultiWidgetEditor::GetSelectedPosition(const QString & /*id*/) const +{ + return d->m_StdMultiWidget->GetCrossPosition(); +} + +void QmitkStdMultiWidgetEditor::SetSelectedPosition(const mitk::Point3D &pos, const QString &/*id*/) +{ + d->m_StdMultiWidget->MoveCrossToPosition(pos); +} + +void QmitkStdMultiWidgetEditor::EnableDecorations(bool enable, const QStringList &decorations) +{ + if (decorations.isEmpty() || decorations.contains(DECORATION_BORDER)) + { + enable ? d->m_StdMultiWidget->EnableColoredRectangles() + : d->m_StdMultiWidget->DisableColoredRectangles(); + } + if (decorations.isEmpty() || decorations.contains(DECORATION_LOGO)) + { + enable ? d->m_StdMultiWidget->EnableDepartmentLogo() + : d->m_StdMultiWidget->DisableDepartmentLogo(); + } + if (decorations.isEmpty() || decorations.contains(DECORATION_MENU)) + { + d->m_StdMultiWidget->ActivateMenuWidget(enable); + } + if (decorations.isEmpty() || decorations.contains(DECORATION_BACKGROUND)) + { + enable ? d->m_StdMultiWidget->EnableGradientBackground() + : d->m_StdMultiWidget->DisableGradientBackground(); + } +} + +bool QmitkStdMultiWidgetEditor::IsDecorationEnabled(const QString &decoration) const +{ + if (decoration == DECORATION_BORDER) + { + return d->m_StdMultiWidget->IsColoredRectanglesEnabled(); + } + else if (decoration == DECORATION_LOGO) + { + return d->m_StdMultiWidget->IsColoredRectanglesEnabled(); + } + else if (decoration == DECORATION_MENU) + { + return d->m_StdMultiWidget->IsMenuWidgetEnabled(); + } + else if (decoration == DECORATION_BACKGROUND) + { + return d->m_StdMultiWidget->GetGradientBackgroundFlag(); + } + return false; +} + +QStringList QmitkStdMultiWidgetEditor::GetDecorations() const +{ + QStringList decorations; + decorations << DECORATION_BORDER << DECORATION_LOGO << DECORATION_MENU << DECORATION_BACKGROUND; + return decorations; +} + +mitk::SlicesRotator* QmitkStdMultiWidgetEditor::GetSlicesRotator() const +{ + return d->m_StdMultiWidget->GetSlicesRotator(); +} + +mitk::SlicesSwiveller* QmitkStdMultiWidgetEditor::GetSlicesSwiveller() const +{ + return d->m_StdMultiWidget->GetSlicesSwiveller(); +} + +void QmitkStdMultiWidgetEditor::EnableSlicingPlanes(bool enable) +{ + d->m_StdMultiWidget->SetWidgetPlanesVisibility(enable); +} + +bool QmitkStdMultiWidgetEditor::IsSlicingPlanesEnabled() const +{ + // The QmitkStdMultiWidget has no API for this. Do a poor mans check. + mitk::DataStorage::Pointer ds = GetDataStorage(); + if (ds.IsNull()) return false; + mitk::DataNode::Pointer node = ds->GetNamedNode("widget1Plane"); + if (node.IsNotNull()) + { + bool visible = false; + node->GetVisibility(visible, 0); + return visible; + } + else + { + return false; + } +} + +void QmitkStdMultiWidgetEditor::EnableLinkedNavigation(bool enable) +{ + enable ? d->m_StdMultiWidget->EnableNavigationControllerEventListening() + : d->m_StdMultiWidget->DisableNavigationControllerEventListening(); +} + +bool QmitkStdMultiWidgetEditor::IsLinkedNavigationEnabled() const +{ + return d->m_StdMultiWidget->IsCrosshairNavigationEnabled(); +} + +void QmitkStdMultiWidgetEditor::CreateQtPartControl(QWidget* parent) +{ + if (d->m_StdMultiWidget == 0) + { + QVBoxLayout* layout = new QVBoxLayout(parent); + layout->setContentsMargins(0,0,0,0); + + if (d->m_MouseModeToolbar == NULL) + { + d->m_MouseModeToolbar = new QmitkMouseModeSwitcher(parent); // delete by Qt via parent + layout->addWidget(d->m_MouseModeToolbar); + } + + d->m_StdMultiWidget = new QmitkStdMultiWidget(parent); + + d->m_RenderWindows.insert("transversal", d->m_StdMultiWidget->GetRenderWindow1()); + d->m_RenderWindows.insert("sagittal", d->m_StdMultiWidget->GetRenderWindow2()); + d->m_RenderWindows.insert("coronal", d->m_StdMultiWidget->GetRenderWindow3()); + d->m_RenderWindows.insert("3d", d->m_StdMultiWidget->GetRenderWindow4()); + + d->m_MouseModeToolbar->setMouseModeSwitcher( d->m_StdMultiWidget->GetMouseModeSwitcher() ); + connect( d->m_MouseModeToolbar, SIGNAL( MouseModeSelected(mitk::MouseModeSwitcher::MouseMode) ), + d->m_StdMultiWidget, SLOT( MouseModeSelected(mitk::MouseModeSwitcher::MouseMode) ) ); + + layout->addWidget(d->m_StdMultiWidget); + + mitk::DataStorage::Pointer ds = this->GetDataStorage(); + + // Tell the multiWidget which (part of) the tree to render + d->m_StdMultiWidget->SetDataStorage(ds); + + // Initialize views as transversal, sagittal, coronar to all data objects in DataStorage + // (from top-left to bottom) + mitk::TimeSlicedGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll()); + mitk::RenderingManager::GetInstance()->InitializeViews(geo); + + // Initialize bottom-right view as 3D view + d->m_StdMultiWidget->GetRenderWindow4()->GetRenderer()->SetMapperID( + mitk::BaseRenderer::Standard3D ); + + // Enable standard handler for levelwindow-slider + d->m_StdMultiWidget->EnableStandardLevelWindow(); + + // Add the displayed views to the tree to see their positions + // in 2D and 3D + d->m_StdMultiWidget->AddDisplayPlaneSubTree(); + + d->m_StdMultiWidget->EnableNavigationControllerEventListening(); + + this->GetSite()->GetPage()->AddPartListener(d->m_PartListener); + + berry::IPreferences::Pointer prefs = this->GetPreferences(); + this->OnPreferencesChanged(dynamic_cast(prefs.GetPointer())); + + this->RequestUpdate(); + } +} + +void QmitkStdMultiWidgetEditor::OnPreferencesChanged(const berry::IBerryPreferences* prefs) +{ + // enable change of logo + std::string departmentLogoLocation = prefs->Get("DepartmentLogo",""); + if (departmentLogoLocation.empty()) + { + d->m_StdMultiWidget->DisableDepartmentLogo(); + } + else + { + d->m_StdMultiWidget->SetDepartmentLogoPath(departmentLogoLocation.c_str()); + d->m_StdMultiWidget->EnableDepartmentLogo(); + } + + // preferences for gradient background + float color = 255.0; + QString firstColorName = QString::fromStdString (prefs->GetByteArray("first background color", "")); + QColor firstColor(firstColorName); + mitk::Color upper; + if (firstColorName=="") // default values + { + upper[0] = 0.1; + upper[1] = 0.1; + upper[2] = 0.1; + } + else + { + upper[0] = firstColor.red() / color; + upper[1] = firstColor.green() / color; + upper[2] = firstColor.blue() / color; + } + + QString secondColorName = QString::fromStdString (prefs->GetByteArray("second background color", "")); + QColor secondColor(secondColorName); + mitk::Color lower; + if (secondColorName=="") // default values + { + lower[0] = 0.5; + lower[1] = 0.5; + lower[2] = 0.5; + } + else + { + lower[0] = secondColor.red() / color; + lower[1] = secondColor.green() / color; + lower[2] = secondColor.blue() / color; + } + d->m_StdMultiWidget->SetGradientBackgroundColors(upper, lower); + d->m_StdMultiWidget->EnableGradientBackground(); + + // Set preferences respecting zooming and padding + bool constrainedZooming = prefs->GetBool("Use constrained zooming and padding", false); + + mitk::RenderingManager::GetInstance()->SetConstrainedPaddingZooming(constrainedZooming); + + 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::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible"); + + + // initialize the views to the bounding geometry + mitk::RenderingManager::GetInstance()->InitializeViews(bounds); + + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + + // level window setting + bool showLevelWindowWidget = prefs->GetBool("Show level/window widget", true); + if (showLevelWindowWidget) + { + d->m_StdMultiWidget->EnableStandardLevelWindow(); + } + else + { + d->m_StdMultiWidget->DisableStandardLevelWindow(); + } + + // mouse modes toolbar + bool newMode = prefs->GetBool("PACS like mouse interaction", false); + d->m_MouseModeToolbar->setVisible( newMode ); + d->m_StdMultiWidget->GetMouseModeSwitcher()->SetInteractionScheme( newMode ? mitk::MouseModeSwitcher::PACS : mitk::MouseModeSwitcher::MITK ); +} + +void QmitkStdMultiWidgetEditor::SetFocus() +{ + if (d->m_StdMultiWidget != 0) + d->m_StdMultiWidget->setFocus(); +} diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/QmitkStdMultiWidgetEditor.h b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/QmitkStdMultiWidgetEditor.h new file mode 100644 index 0000000000..81632f42c4 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/QmitkStdMultiWidgetEditor.h @@ -0,0 +1,117 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QMITKSTDMULTIWIDGETEDITOR_H_ +#define QMITKSTDMULTIWIDGETEDITOR_H_ + +#include + +#include + +#include + +class QmitkStdMultiWidget; +class QmitkMouseModeSwitcher; +class QmitkStdMultiWidgetEditorPrivate; + +/** + * \ingroup org_mitk_gui_qt_stdmultiwidgeteditor + */ +class ORG_MITK_GUI_QT_STDMULTIWIDGETEDITOR QmitkStdMultiWidgetEditor + : public QmitkAbstractRenderEditor, public mitk::ILinkedRenderWindowPart +{ + Q_OBJECT + +public: + + berryObjectMacro(QmitkStdMultiWidgetEditor) + + static const std::string EDITOR_ID; + + QmitkStdMultiWidgetEditor(); + ~QmitkStdMultiWidgetEditor(); + + QmitkStdMultiWidget* GetStdMultiWidget(); + + // ------------------- mitk::IRenderWindowPart ---------------------- + + /** + * \see mitk::IRenderWindowPart::GetActiveRenderWindow() + */ + QmitkRenderWindow* GetActiveRenderWindow() const; + + /** + * \see mitk::IRenderWindowPart::GetRenderWindows() + */ + QHash GetRenderWindows() const; + + /** + * \see mitk::IRenderWindowPart::GetRenderWindow(QString) + */ + QmitkRenderWindow* GetRenderWindow(const QString& id) const; + + /** + * \see mitk::IRenderWindowPart::GetSelectionPosition() + */ + mitk::Point3D GetSelectedPosition(const QString& id = QString()) const; + + /** + * \see mitk::IRenderWindowPart::SetSelectedPosition() + */ + void SetSelectedPosition(const mitk::Point3D& pos, const QString& id = QString()); + + /** + * \see mitk::IRenderWindowPart::EnableDecorations() + */ + void EnableDecorations(bool enable, const QStringList& decorations = QStringList()); + + /** + * \see mitk::IRenderWindowPart::IsDecorationEnabled() + */ + bool IsDecorationEnabled(const QString& decoration) const; + + /** + * \see mitk::IRenderWindowPart::GetDecorations() + */ + QStringList GetDecorations() const; + + // ------------------- mitk::ILinkedRenderWindowPart ---------------------- + + mitk::SlicesRotator* GetSlicesRotator() const; + mitk::SlicesSwiveller* GetSlicesSwiveller() const; + + void EnableSlicingPlanes(bool enable); + bool IsSlicingPlanesEnabled() const; + + void EnableLinkedNavigation(bool enable); + bool IsLinkedNavigationEnabled() const; + +protected: + + void SetFocus(); + + void OnPreferencesChanged(const berry::IBerryPreferences*); + + void CreateQtPartControl(QWidget* parent); + +private: + + const QScopedPointer d; + +}; + +#endif /*QMITKSTDMULTIWIDGETEDITOR_H_*/ diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp new file mode 100644 index 0000000000..9aa9d871f0 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp @@ -0,0 +1,222 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ + Version: $Revision: 18019 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + +#include "QmitkStdMultiWidgetEditorPreferencePage.h" +#include "QmitkStdMultiWidgetEditor.h" + +#include +#include +#include +#include +#include + +#include +#include + +QmitkStdMultiWidgetEditorPreferencePage::QmitkStdMultiWidgetEditorPreferencePage() +: m_MainControl(0) +{ + +} + +void QmitkStdMultiWidgetEditorPreferencePage::Init(berry::IWorkbench::Pointer ) +{ + +} + +void QmitkStdMultiWidgetEditorPreferencePage::CreateQtControl(QWidget* parent) +{ + berry::IPreferencesService::Pointer prefService + = berry::Platform::GetServiceRegistry() + .GetServiceById(berry::IPreferencesService::ID); + + m_StdMultiWidgetEditorPreferencesNode = prefService->GetSystemPreferences()->Node(QmitkStdMultiWidgetEditor::EDITOR_ID); + + m_MainControl = new QWidget(parent); + m_EnableFlexibleZooming = new QCheckBox; + m_ShowLevelWindowWidget = new QCheckBox; + m_PACSLikeMouseMode = new QCheckBox; + + QFormLayout *formLayout = new QFormLayout; + formLayout->addRow("&Use constrained zooming and padding", m_EnableFlexibleZooming); + formLayout->addRow("&Show level/window widget", m_ShowLevelWindowWidget); + formLayout->addRow("&PACS like mouse interactions (select left mouse button action)", m_PACSLikeMouseMode); + + // gradient background + QLabel* gBName = new QLabel; + gBName->setText("Gradient background"); + formLayout->addRow(gBName); + + // color + m_ColorButton1 = new QPushButton; + m_ColorButton1->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + m_ColorButton2 = new QPushButton; + m_ColorButton2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + QPushButton* resetButton = new QPushButton; + resetButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); + resetButton->setText("Reset"); + + QLabel* colorLabel1 = new QLabel("first color : "); + colorLabel1->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + QLabel* colorLabel2 = new QLabel("second color: "); + colorLabel2->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + + QHBoxLayout* colorWidgetLayout = new QHBoxLayout; + colorWidgetLayout->setContentsMargins(4,4,4,4); + colorWidgetLayout->addWidget(colorLabel1); + colorWidgetLayout->addWidget(m_ColorButton1); + colorWidgetLayout->addWidget(colorLabel2); + colorWidgetLayout->addWidget(m_ColorButton2); + colorWidgetLayout->addWidget(resetButton); + + QWidget* colorWidget = new QWidget; + colorWidget->setLayout(colorWidgetLayout); + + //spacer + QSpacerItem *spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + QVBoxLayout* vBoxLayout = new QVBoxLayout; + vBoxLayout->addLayout(formLayout); + vBoxLayout->addWidget(colorWidget); + vBoxLayout->addSpacerItem(spacer); + + m_MainControl->setLayout(vBoxLayout); + + QObject::connect( m_ColorButton1, SIGNAL( clicked() ) + , this, SLOT( FirstColorChanged() ) ); + + QObject::connect( m_ColorButton2, SIGNAL( clicked() ) + , this, SLOT( SecondColorChanged() ) ); + + QObject::connect( resetButton, SIGNAL( clicked() ) + , this, SLOT( ResetColors() ) ); + + this->Update(); +} + +QWidget* QmitkStdMultiWidgetEditorPreferencePage::GetQtControl() const +{ + return m_MainControl; +} + +bool QmitkStdMultiWidgetEditorPreferencePage::PerformOk() +{ + m_StdMultiWidgetEditorPreferencesNode->Put("first background color style sheet", m_FirstColorStyleSheet.toStdString()); + m_StdMultiWidgetEditorPreferencesNode->Put("second background color style sheet", m_SecondColorStyleSheet.toStdString()); + m_StdMultiWidgetEditorPreferencesNode->PutByteArray("first background color", m_FirstColor); + m_StdMultiWidgetEditorPreferencesNode->PutByteArray("second background color", m_SecondColor); + m_StdMultiWidgetEditorPreferencesNode->PutBool("Use constrained zooming and padding" + , m_EnableFlexibleZooming->isChecked()); + m_StdMultiWidgetEditorPreferencesNode->PutBool("Show level/window widget", m_ShowLevelWindowWidget->isChecked()); + m_StdMultiWidgetEditorPreferencesNode->PutBool("PACS like mouse interaction", m_PACSLikeMouseMode->isChecked()); + + return true; +} + +void QmitkStdMultiWidgetEditorPreferencePage::PerformCancel() +{ + +} + +void QmitkStdMultiWidgetEditorPreferencePage::Update() +{ + m_EnableFlexibleZooming->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("Use constrained zooming and padding", true)); + m_ShowLevelWindowWidget->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("Show level/window widget", true)); + m_PACSLikeMouseMode->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("PACS like mouse interaction", false)); + m_FirstColorStyleSheet = QString::fromStdString(m_StdMultiWidgetEditorPreferencesNode->Get("first background color style sheet", "")); + m_SecondColorStyleSheet = QString::fromStdString(m_StdMultiWidgetEditorPreferencesNode->Get("second background color style sheet", "")); + m_FirstColor = m_StdMultiWidgetEditorPreferencesNode->GetByteArray("first background color", ""); + m_SecondColor = m_StdMultiWidgetEditorPreferencesNode->GetByteArray("second background color", ""); + if (m_FirstColorStyleSheet=="") + { + m_FirstColorStyleSheet = "background-color:rgb(25,25,25)"; + } + if (m_SecondColorStyleSheet=="") + { + m_SecondColorStyleSheet = "background-color:rgb(127,127,127)"; + } + if (m_FirstColor=="") + { + m_FirstColor = "#191919"; + } + if (m_SecondColor=="") + { + m_SecondColor = "#7F7F7F"; + } + m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet); + m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet); +} + +void QmitkStdMultiWidgetEditorPreferencePage::FirstColorChanged() +{ + QColor color = QColorDialog::getColor(); + m_ColorButton1->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + + styleSheet.append(QString::number(color.red())); + styleSheet.append(","); + styleSheet.append(QString::number(color.green())); + styleSheet.append(","); + styleSheet.append(QString::number(color.blue())); + styleSheet.append(")"); + m_ColorButton1->setStyleSheet(styleSheet); + + m_FirstColorStyleSheet = styleSheet; + QStringList firstColor; + firstColor << color.name(); + m_FirstColor = firstColor.replaceInStrings(";","\\;").join(";").toStdString(); + } + +void QmitkStdMultiWidgetEditorPreferencePage::SecondColorChanged() +{ + QColor color = QColorDialog::getColor(); + m_ColorButton2->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + + styleSheet.append(QString::number(color.red())); + styleSheet.append(","); + styleSheet.append(QString::number(color.green())); + styleSheet.append(","); + styleSheet.append(QString::number(color.blue())); + styleSheet.append(")"); + m_ColorButton2->setStyleSheet(styleSheet); + + m_SecondColorStyleSheet = styleSheet; + QStringList secondColor; + secondColor << color.name(); + m_SecondColor = secondColor.replaceInStrings(";","\\;").join(";").toStdString(); + } + +void QmitkStdMultiWidgetEditorPreferencePage::ResetColors() +{ + m_FirstColorStyleSheet = "background-color:rgb(25,25,25)"; + m_SecondColorStyleSheet = "background-color:rgb(127,127,127)"; + m_FirstColor = "#191919"; + m_SecondColor = "#7F7F7F"; + m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet); + m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet); +} + +void QmitkStdMultiWidgetEditorPreferencePage::UseGradientBackgroundSelected() +{ + +} + +void QmitkStdMultiWidgetEditorPreferencePage::ColorActionChanged() +{ + +} + diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.h b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.h new file mode 100644 index 0000000000..726897c82a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.h @@ -0,0 +1,86 @@ +/*========================================================================= + + Program: Medical Imaging & Interaction Toolkit + Language: C++ + Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ + Version: $Revision: 16224 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef QMITKSTDMULTIWIDGETEDITORPREFERENCEPAGE_H_ +#define QMITKSTDMULTIWIDGETEDITORPREFERENCEPAGE_H_ + +#include "berryIQtPreferencePage.h" +#include + +class QWidget; +class QCheckBox; +class QPushButton; +class QWidgetAction; + +struct QmitkStdMultiWidgetEditorPreferencePage : public QObject, public berry::IQtPreferencePage +{ + Q_OBJECT + Q_INTERFACES(berry::IPreferencePage) + +public: + QmitkStdMultiWidgetEditorPreferencePage(); + + void Init(berry::IWorkbench::Pointer workbench); + + void CreateQtControl(QWidget* widget); + + QWidget* GetQtControl() const; + + /// + /// \see IPreferencePage::PerformOk() + /// + virtual bool PerformOk(); + + /// + /// \see IPreferencePage::PerformCancel() + /// + virtual void PerformCancel(); + + /// + /// \see IPreferencePage::Update() + /// + virtual void Update(); + +public slots: + void FirstColorChanged(); + + void SecondColorChanged(); + + void UseGradientBackgroundSelected(); + + void ColorActionChanged(); + + void ResetColors(); + +protected: + QWidget* m_MainControl; + QCheckBox* m_EnableFlexibleZooming; + QCheckBox* m_ShowLevelWindowWidget; + QCheckBox* m_UseGradientBackground; + QCheckBox* m_ChangeBackgroundColors; + QCheckBox* m_PACSLikeMouseMode; + QPushButton* m_ColorButton1; + QPushButton* m_ColorButton2; + std::string m_FirstColor; + std::string m_SecondColor; + QString m_FirstColorStyleSheet; + QString m_SecondColorStyleSheet; + berry::IPreferences::Pointer m_StdMultiWidgetEditorPreferencesNode; +}; + +#endif /* QMITKDATAMANAGERPREFERENCEPAGE_H_ */ diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/org_mitk_gui_qt_stdmultiwidgeteditor_Activator.cpp b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/org_mitk_gui_qt_stdmultiwidgeteditor_Activator.cpp new file mode 100644 index 0000000000..345d66e9b2 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/org_mitk_gui_qt_stdmultiwidgeteditor_Activator.cpp @@ -0,0 +1,39 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision: 18127 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "org_mitk_gui_qt_stdmultiwidgeteditor_Activator.h" + +#include "../QmitkStdMultiWidgetEditor.h" +#include "QmitkStdMultiWidgetEditorPreferencePage.h" + + +void +org_mitk_gui_qt_stdmultiwidgeteditor_Activator::start(ctkPluginContext* context) +{ + Q_UNUSED(context) + + BERRY_REGISTER_EXTENSION_CLASS(QmitkStdMultiWidgetEditor, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkStdMultiWidgetEditorPreferencePage, context) +} + +void +org_mitk_gui_qt_stdmultiwidgeteditor_Activator::stop(ctkPluginContext* context) +{ + Q_UNUSED(context) +} + +Q_EXPORT_PLUGIN2(org_mitk_gui_qt_stdmultiwidgeteditor, org_mitk_gui_qt_stdmultiwidgeteditor_Activator) diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/org_mitk_gui_qt_stdmultiwidgeteditor_Activator.h b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/org_mitk_gui_qt_stdmultiwidgeteditor_Activator.h new file mode 100644 index 0000000000..d3a5631cca --- /dev/null +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/org_mitk_gui_qt_stdmultiwidgeteditor_Activator.h @@ -0,0 +1,40 @@ +/*========================================================================= + + Program: MITK Platform + Language: C++ + Date: $Date$ + Version: $Revision: 17020 $ + + Copyright (c) German Cancer Research Center, Division of Medical and + Biological Informatics. All rights reserved. + See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ + + +#ifndef org_mitk_gui_qt_stdmultiwidgeteditor_Activator_H_ +#define org_mitk_gui_qt_stdmultiwidgeteditor_Activator_H_ + +#include + +/** + * \ingroup org_mitk_gui_qt_stdmultiwidgeteditor + */ +class org_mitk_gui_qt_stdmultiwidgeteditor_Activator : public QObject, public ctkPluginActivator +{ + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + +public: + + void start(ctkPluginContext* context); + void stop(ctkPluginContext* context); + +}; + +#endif /* org_mitk_gui_qt_stdmultiwidgeteditor_Activator_H_ */ + diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/CMakeLists.txt b/Plugins/org.mitk.gui.qt.toftutorial/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.toftutorial/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/documentation/Manual/Manual.dox b/Plugins/org.mitk.gui.qt.toftutorial/documentation/Manual/Manual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/documentation/Manual/Manual.dox rename to Plugins/org.mitk.gui.qt.toftutorial/documentation/Manual/Manual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/documentation/Manual/icon.png b/Plugins/org.mitk.gui.qt.toftutorial/documentation/Manual/icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/documentation/Manual/icon.png rename to Plugins/org.mitk.gui.qt.toftutorial/documentation/Manual/icon.png diff --git a/Plugins/org.mitk.gui.qt.toftutorial/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.toftutorial/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..c43d5e743e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.toftutorial/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_toftutorial org.mitk.gui.qt.toftutorial + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_toftutorial_internal Internal + \ingroup org_mitk_gui_qt_toftutorial + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.toftutorial plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/files.cmake b/Plugins/org.mitk.gui.qt.toftutorial/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/files.cmake rename to Plugins/org.mitk.gui.qt.toftutorial/files.cmake diff --git a/Plugins/org.mitk.gui.qt.toftutorial/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.toftutorial/manifest_headers.cmake new file mode 100644 index 0000000000..08ce034999 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.toftutorial/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK-ToF Tutorial") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "www.mitk.org/wiki/MITK-ToF") +set(Require-Plugin org.mitk.gui.qt.common.legacy) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/plugin.xml b/Plugins/org.mitk.gui.qt.toftutorial/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/plugin.xml rename to Plugins/org.mitk.gui.qt.toftutorial/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/resources/QmitkToFTutorialView.qrc b/Plugins/org.mitk.gui.qt.toftutorial/resources/QmitkToFTutorialView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/resources/QmitkToFTutorialView.qrc rename to Plugins/org.mitk.gui.qt.toftutorial/resources/QmitkToFTutorialView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/resources/icon.xpm b/Plugins/org.mitk.gui.qt.toftutorial/resources/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/resources/icon.xpm rename to Plugins/org.mitk.gui.qt.toftutorial/resources/icon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp b/Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp rename to Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.h b/Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.h rename to Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialViewControls.ui b/Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialViewControls.ui rename to Plugins/org.mitk.gui.qt.toftutorial/src/internal/QmitkToFTutorialViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.toftutorial/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/CMakeLists.txt b/Plugins/org.mitk.gui.qt.tofutil/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.tofutil/CMakeLists.txt diff --git a/Plugins/org.mitk.gui.qt.tofutil/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.tofutil/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..8fbc17780b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.tofutil/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_tofutil org.mitk.gui.qt.tofutil + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_tofutil_internal Internal + \ingroup org_mitk_gui_qt_tofutil + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.tofutil plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/files.cmake b/Plugins/org.mitk.gui.qt.tofutil/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/files.cmake rename to Plugins/org.mitk.gui.qt.tofutil/files.cmake diff --git a/Plugins/org.mitk.gui.qt.tofutil/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.tofutil/manifest_headers.cmake new file mode 100644 index 0000000000..85937418a8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.tofutil/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK-ToF Util") +set(Plugin-Version "0.1") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "www.mitk.org/wiki/MITK-ToF") +set(Require-Plugin org.mitk.gui.qt.common.legacy) \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/plugin.xml b/Plugins/org.mitk.gui.qt.tofutil/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/plugin.xml rename to Plugins/org.mitk.gui.qt.tofutil/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/resources/QmitkToFUtilView.qrc b/Plugins/org.mitk.gui.qt.tofutil/resources/QmitkToFUtilView.qrc similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/resources/QmitkToFUtilView.qrc rename to Plugins/org.mitk.gui.qt.tofutil/resources/QmitkToFUtilView.qrc diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/resources/icon.xpm b/Plugins/org.mitk.gui.qt.tofutil/resources/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/resources/icon.xpm rename to Plugins/org.mitk.gui.qt.tofutil/resources/icon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.cpp b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.cpp rename to Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.h b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.h rename to Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFImageBackground.h diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp rename to Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h rename to Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilViewControls.ui b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilViewControls.ui rename to Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFUtilViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.tofutil/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/CMakeLists.txt b/Plugins/org.mitk.gui.qt.ugvisualization/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.ugvisualization/CMakeLists.txt diff --git a/Plugins/org.mitk.gui.qt.ugvisualization/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.ugvisualization/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..cee668d667 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ugvisualization/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_ugvisualization org.mitk.gui.qt.ugvisualization + \ingroup MITKPlugins + + \brief Describe your plugin here. + +*/ + +/** + \defgroup org_mitk_gui_qt_ugvisualization_internal Internal + \ingroup org_mitk_gui_qt_ugvisualization + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.ugvisualization plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/files.cmake b/Plugins/org.mitk.gui.qt.ugvisualization/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/files.cmake rename to Plugins/org.mitk.gui.qt.ugvisualization/files.cmake diff --git a/Plugins/org.mitk.gui.qt.ugvisualization/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.ugvisualization/manifest_headers.cmake new file mode 100644 index 0000000000..0f09b22c2d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ugvisualization/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK UG Visualization") +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) diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/plugin.xml b/Plugins/org.mitk.gui.qt.ugvisualization/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/plugin.xml rename to Plugins/org.mitk.gui.qt.ugvisualization/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/resources/icon.png b/Plugins/org.mitk.gui.qt.ugvisualization/resources/icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/resources/icon.png rename to Plugins/org.mitk.gui.qt.ugvisualization/resources/icon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp b/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp rename to Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.h b/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.h rename to Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationViewControls.ui b/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationViewControls.ui rename to Plugins/org.mitk.gui.qt.ugvisualization/src/internal/QmitkUGVisualizationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.ugvisualization/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/CMakeLists.txt b/Plugins/org.mitk.gui.qt.volumevisualization/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/CMakeLists.txt rename to Plugins/org.mitk.gui.qt.volumevisualization/CMakeLists.txt diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/QmitkVolumeVisualizationUserManual.dox b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/QmitkVolumeVisualizationUserManual.dox similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/QmitkVolumeVisualizationUserManual.dox rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/QmitkVolumeVisualizationUserManual.dox diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/bell.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/bell.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/bell.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/bell.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/checkboxen.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/checkboxen.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/checkboxen.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/checkboxen.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/color.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/color.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/color.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/color.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/gradient.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/gradient.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/gradient.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/gradient.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.xpm rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/icon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/mitkInternalPresets.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/mitkInternalPresets.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/mitkInternalPresets.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/mitkInternalPresets.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/opacity.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/opacity.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/opacity.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/opacity.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/slider.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/slider.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/slider.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/slider.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/threshold.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/threshold.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/threshold.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/threshold.png diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/vroverview.png b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/vroverview.png similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/documentation/UserManual/vroverview.png rename to Plugins/org.mitk.gui.qt.volumevisualization/documentation/UserManual/vroverview.png diff --git a/Plugins/org.mitk.gui.qt.volumevisualization/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..9c97ab3efa --- /dev/null +++ b/Plugins/org.mitk.gui.qt.volumevisualization/documentation/doxygen/modules.dox @@ -0,0 +1,16 @@ +/** + \defgroup org_mitk_gui_qt_volumevisualization org.mitk.gui.qt.volumevisualization + \ingroup MITKPlugins + + \brief This is the volume visualization plugin. + +*/ + +/** + \defgroup org_mitk_gui_qt_volumevisualization_internal Internal + \ingroup org_mitk_gui_qt_volumevisualization + + \brief This subcategory includes the internal classes of the org.mitk.gui.qt.volumevisualization plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ \ No newline at end of file diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/files.cmake b/Plugins/org.mitk.gui.qt.volumevisualization/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/files.cmake rename to Plugins/org.mitk.gui.qt.volumevisualization/files.cmake diff --git a/Plugins/org.mitk.gui.qt.volumevisualization/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.volumevisualization/manifest_headers.cmake new file mode 100644 index 0000000000..0026ff9058 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.volumevisualization/manifest_headers.cmake @@ -0,0 +1,5 @@ +set(Plugin-Name "MITK Volume Visualization") +set(Plugin-Version "1.0.0") +set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") +set(Plugin-ContactAddress "http://www.mitk.org") +set(Require-Plugin org.mitk.gui.qt.common.legacy) diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/plugin.xml b/Plugins/org.mitk.gui.qt.volumevisualization/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/plugin.xml rename to Plugins/org.mitk.gui.qt.volumevisualization/plugin.xml diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/resources/icon.xpm b/Plugins/org.mitk.gui.qt.volumevisualization/resources/icon.xpm similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/resources/icon.xpm rename to Plugins/org.mitk.gui.qt.volumevisualization/resources/icon.xpm diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.cpp b/Plugins/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.cpp rename to Plugins/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.h b/Plugins/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.h rename to Plugins/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationView.h diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationViewControls.ui b/Plugins/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationViewControls.ui similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationViewControls.ui rename to Plugins/org.mitk.gui.qt.volumevisualization/src/internal/QmitkVolumeVisualizationViewControls.ui diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.cpp rename to Plugins/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.cpp diff --git a/Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.h rename to Plugins/org.mitk.gui.qt.volumevisualization/src/internal/mitkPluginActivator.h diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/CMakeLists.txt b/Plugins/org.mitk.inputdevices.spacenavigator/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.spacenavigator/CMakeLists.txt rename to Plugins/org.mitk.inputdevices.spacenavigator/CMakeLists.txt diff --git a/Plugins/org.mitk.inputdevices.spacenavigator/META-INF/MANIFEST.MF b/Plugins/org.mitk.inputdevices.spacenavigator/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..12eba5d4f7 --- /dev/null +++ b/Plugins/org.mitk.inputdevices.spacenavigator/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-Name: MITK Input Device Space Navigator +Bundle-SymbolicName: org.mitk.inputdevices.spacenavigator +Bundle-Version: 0.1 +Bundle-Vendor: DKFZ, Medical and Biological Informatics +Require-Bundle: org.mitk.core.ext, org.mitk.gui.qt.common.legacy +Bundle-Activator: diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/files.cmake b/Plugins/org.mitk.inputdevices.spacenavigator/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.spacenavigator/files.cmake rename to Plugins/org.mitk.inputdevices.spacenavigator/files.cmake diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/manifest.cpp b/Plugins/org.mitk.inputdevices.spacenavigator/manifest.cpp similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.spacenavigator/manifest.cpp rename to Plugins/org.mitk.inputdevices.spacenavigator/manifest.cpp diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/plugin.xml b/Plugins/org.mitk.inputdevices.spacenavigator/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.spacenavigator/plugin.xml rename to Plugins/org.mitk.inputdevices.spacenavigator/plugin.xml diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/src/SpacenavigatorDll.h b/Plugins/org.mitk.inputdevices.spacenavigator/src/SpacenavigatorDll.h similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.spacenavigator/src/SpacenavigatorDll.h rename to Plugins/org.mitk.inputdevices.spacenavigator/src/SpacenavigatorDll.h diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.cpp b/Plugins/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.cpp rename to Plugins/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.cpp diff --git a/Modules/Bundles/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.h b/Plugins/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.h rename to Plugins/org.mitk.inputdevices.spacenavigator/src/internal/mitkSpaceNavigatorActivator.h diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/CMakeLists.txt b/Plugins/org.mitk.inputdevices.wiimote/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.wiimote/CMakeLists.txt rename to Plugins/org.mitk.inputdevices.wiimote/CMakeLists.txt diff --git a/Plugins/org.mitk.inputdevices.wiimote/META-INF/MANIFEST.MF b/Plugins/org.mitk.inputdevices.wiimote/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..4cbb2ae1ad --- /dev/null +++ b/Plugins/org.mitk.inputdevices.wiimote/META-INF/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Bundle-Name: MITK Input Device WiiMote +Bundle-SymbolicName: org.mitk.inputdevices.wiimote +Bundle-Version: 0.1 +Bundle-Vendor: DKFZ, Medical and Biological Informatics +Require-Bundle: org.mitk.core.ext, org.mitk.gui.qt.common.legacy +Bundle-Activator: diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/files.cmake b/Plugins/org.mitk.inputdevices.wiimote/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.wiimote/files.cmake rename to Plugins/org.mitk.inputdevices.wiimote/files.cmake diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/manifest.cpp b/Plugins/org.mitk.inputdevices.wiimote/manifest.cpp similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.wiimote/manifest.cpp rename to Plugins/org.mitk.inputdevices.wiimote/manifest.cpp diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/plugin.xml b/Plugins/org.mitk.inputdevices.wiimote/plugin.xml similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.wiimote/plugin.xml rename to Plugins/org.mitk.inputdevices.wiimote/plugin.xml diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/src/WiimoteDll.h b/Plugins/org.mitk.inputdevices.wiimote/src/WiimoteDll.h similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.wiimote/src/WiimoteDll.h rename to Plugins/org.mitk.inputdevices.wiimote/src/WiimoteDll.h diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.cpp b/Plugins/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.cpp rename to Plugins/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.cpp diff --git a/Modules/Bundles/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.h b/Plugins/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.h rename to Plugins/org.mitk.inputdevices.wiimote/src/internal/mitkWiiMoteActivator.h diff --git a/Modules/Bundles/org.mitk.planarfigure/CMakeLists.txt b/Plugins/org.mitk.planarfigure/CMakeLists.txt similarity index 100% rename from Modules/Bundles/org.mitk.planarfigure/CMakeLists.txt rename to Plugins/org.mitk.planarfigure/CMakeLists.txt diff --git a/Plugins/org.mitk.planarfigure/documentation/doxygen/modules.dox b/Plugins/org.mitk.planarfigure/documentation/doxygen/modules.dox new file mode 100644 index 0000000000..36087c2397 --- /dev/null +++ b/Plugins/org.mitk.planarfigure/documentation/doxygen/modules.dox @@ -0,0 +1,19 @@ +/** + \defgroup org_mitk_planarfigure org.mitk.planarfigure + \ingroup MITKPlugins + + \brief This small plug-in is responsible for initializing the PlanarFigure module. + + It is started with an "eager" Bundle-ActivationPolicy, such that the plug-ins + activator is executed before any other (non-eager) plug-ins. + +*/ + +/** + \defgroup org_mitk_planarfigure_internal Internal + \ingroup org_mitk_planarfigure + + \brief This subcategory includes the internal classes of the org.mitk.planarfigure plugin. Other + plugins must not rely on these classes. They contain implementation details and their interface + may change at any time. We mean it. +*/ diff --git a/Modules/Bundles/org.mitk.planarfigure/files.cmake b/Plugins/org.mitk.planarfigure/files.cmake similarity index 100% rename from Modules/Bundles/org.mitk.planarfigure/files.cmake rename to Plugins/org.mitk.planarfigure/files.cmake diff --git a/Modules/Bundles/org.mitk.planarfigure/manifest_headers.cmake b/Plugins/org.mitk.planarfigure/manifest_headers.cmake similarity index 100% rename from Modules/Bundles/org.mitk.planarfigure/manifest_headers.cmake rename to Plugins/org.mitk.planarfigure/manifest_headers.cmake diff --git a/Modules/Bundles/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp b/Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp similarity index 100% rename from Modules/Bundles/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp rename to Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.cpp diff --git a/Modules/Bundles/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.h b/Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.h similarity index 100% rename from Modules/Bundles/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.h rename to Plugins/org.mitk.planarfigure/src/internal/mitkPlanarFigureActivator.h diff --git a/Utilities/qtsingleapplication/qthandlenewappinstance.cpp b/Utilities/qtsingleapplication/qthandlenewappinstance.cpp index 00f6692a9a..8b1da575d3 100644 --- a/Utilities/qtsingleapplication/qthandlenewappinstance.cpp +++ b/Utilities/qtsingleapplication/qthandlenewappinstance.cpp @@ -1,120 +1,116 @@ -/*============================================================================= - - Library: CTK - - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #include "qthandlenewappinstance.h" #include "qtsingleapplication.h" #include #include // mkdtemp #ifdef Q_OS_WIN #include //#include #endif bool createTemporaryDir(QString& path) { QString baseName = QCoreApplication::applicationName(); if (baseName.isEmpty()) { baseName = QLatin1String("mitk_temp"); } QString templateName = QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX"); bool success = false; #ifdef Q_OS_WIN QString buffer = templateName; // Windows' mktemp believes 26 temp files per process ought to be enough for everyone (!) // Let's add a few random chars then, before the XXXXXX template. for (int i = 0 ; i < 4 ; ++i) buffer += QChar((qrand() & 0xffff) % (26) + 'A'); if (!buffer.endsWith(QLatin1String("XXXXXX"))) buffer += QLatin1String("XXXXXX"); //QFileSystemEntry baseEntry(buffer); //QFileSystemEntry::NativePath basePath = baseEntry.nativeFilePath(); QString basePath = QDir::toNativeSeparators(buffer); wchar_t* array = (wchar_t*)basePath.utf16(); if (_wmktemp(array) && ::CreateDirectoryW(array, 0)) { success = true; //QFileSystemEntry entry(QString::fromWCharArray(array), QFileSystemEntry::FromNativePath()); //path = entry.filePath(); path = QDir::fromNativeSeparators(QString::fromUtf16((const ushort*)array)); } #else QByteArray buffer = QFile::encodeName(templateName); if (!buffer.endsWith("XXXXXX")) buffer += "XXXXXX"; if (mkdtemp(buffer.data())) { // modifies buffer success = true; path = QFile::decodeName(buffer.constData()); } #endif return success; } QString handleNewAppInstance(QtSingleApplication* singleApp, int argc, char** argv, const QString& newInstanceArg) { if (singleApp->isRunning()) { QStringList args; bool newInstance = false; for (int i = 0; i < argc; ++i) { args << argv[i]; if (args.back().endsWith(newInstanceArg)) { newInstance = true; } } if (newInstance) { QString path; if (!createTemporaryDir(path)) { qCritical("Could not create temporary storage path for new application instance."); exit(EXIT_FAILURE); } qWarning("Forcing new application instance. The application data will be written to a temporary directory."); return path; } else { QByteArray ba; QDataStream msg(&ba, QIODevice::WriteOnly); msg << QString("$cmdLineArgs"); // This message contains command line arguments msg << args; if(singleApp->sendMessage(ba)) { exit(EXIT_SUCCESS); } else { qCritical("The running application seems to be frozen."); exit(EXIT_FAILURE); } } } return QString(); } diff --git a/Utilities/qtsingleapplication/qthandlenewappinstance.h b/Utilities/qtsingleapplication/qthandlenewappinstance.h index e901c956c6..11743f08cc 100644 --- a/Utilities/qtsingleapplication/qthandlenewappinstance.h +++ b/Utilities/qtsingleapplication/qthandlenewappinstance.h @@ -1,34 +1,30 @@ -/*============================================================================= - - Library: CTK - - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #ifndef QTHANDLENEWAPPINSTANCE_H #define QTHANDLENEWAPPINSTANCE_H #include class QtSingleApplication; bool createTemporaryDir(QString& path); QString handleNewAppInstance(QtSingleApplication* singleApp, int argc, char** argv, const QString& newInstanceArg); #endif // QTHANDLENEWAPPINSTANCE_H