diff --git a/Applications/CoreApp/CMakeLists.txt b/Applications/CoreApp/CMakeLists.txt index fee4eb37b2..e4a845e992 100644 --- a/Applications/CoreApp/CMakeLists.txt +++ b/Applications/CoreApp/CMakeLists.txt @@ -1,37 +1,27 @@ 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}/MitkCoreApp.provisioning" CACHE INTERNAL "CoreApp provisioning file" FORCE) set(_plugins 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 ) mitkFunctionCreateBlueBerryApplication( NAME MitkCoreApp DESCRIPTION "MITK - CoreApp Application" PLUGINS ${_plugins} - ${_app_options} -) - -mitk_use_modules(TARGET MitkCoreApp - MODULES MitkAppUtil ) # subproject support add_dependencies(MITK-CoreUI MitkCoreApp) diff --git a/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/CMakeLists.txt b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/CMakeLists.txt index fc1a393c38..2a75238441 100644 --- a/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/CMakeLists.txt +++ b/Applications/PluginGenerator/ProjectTemplate/Apps/TemplateApp/CMakeLists.txt @@ -1,26 +1,15 @@ -set(_app_options) -if(${MY_PROJECT_NAME}_SHOW_CONSOLE_WINDOW) - list(APPEND _app_options SHOW_CONSOLE) -endif() - # 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 ) mitkFunctionCreateBlueBerryApplication( NAME ${MY_APP_NAME} DESCRIPTION "MITK - ${MY_APP_NAME} Application" EXCLUDE_PLUGINS ${_exclude_plugins} - ${_app_options} -) - -mitk_use_modules(TARGET ${MY_APP_NAME} - MODULES MitkAppUtil - PACKAGES Qt5|Widgets ) diff --git a/Applications/Solstice/CMakeLists.txt b/Applications/Solstice/CMakeLists.txt index 53779edb5f..5ed2c29b1c 100644 --- a/Applications/Solstice/CMakeLists.txt +++ b/Applications/Solstice/CMakeLists.txt @@ -1,68 +1,62 @@ project(Solstice) -set(_app_options) -if(MITK_SHOW_CONSOLE_WINDOW) - list(APPEND _app_options SHOW_CONSOLE) -endif() - set(MITK_EXTAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MitkWorkbench.provisioning") # Plug-ins listed below will not be # - added as a build-time dependency to the executable # - listed in the provisioning file for the executable # - installed if they are external plug-ins set(_exclude_plugins org.blueberry.test org.blueberry.uitest org.mitk.gui.qt.coreapplication org.mitk.gui.qt.diffusionimagingapp ) FunctionCreateBlueBerryApplication( NAME MitkSolstice DESCRIPTION "MITK Workbench" EXCLUDE_PLUGINS ${_exclude_plugins} - ${_app_options} ) add_executable(${OSGI_APP} MACOSX_BUNDLE "src/application/berryMain.cpp") target_link_libraries(${OSGI_APP} PRIVATE ${PROJECT_NAME} mbilog) if(_ctk_test_plugins) add_dependencies(${OSGI_APP} ${_ctk_test_plugins}) add_dependencies(BlueBerry ${OSGI_APP}) set_property(TARGET ${OSGI_APP} APPEND PROPERTY LABELS BlueBerry) endif() configure_file(src/application/solstice.ini ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_APP}.ini) add_executable(${OSGI_UI_APP} MACOSX_BUNDLE "src/application/berryMainUI.cpp") target_link_libraries(${OSGI_UI_APP} PRIVATE ${PROJECT_NAME} mbilog) if(MITK_USE_Qt5) target_link_libraries(${OSGI_UI_APP} PRIVATE Qt5::Widgets) endif() if(_ctk_test_plugins) add_dependencies(${OSGI_UI_APP} ${_ctk_test_plugins}) add_dependencies(BlueBerry ${OSGI_UI_APP}) set_property(TARGET ${OSGI_UI_APP} APPEND PROPERTY LABELS BlueBerry) endif() configure_file(src/application/solstice.ini ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_UI_APP}.ini) # Add meta dependencies (e.g. on auto-load modules from depending modules) if(TARGET ${CMAKE_PROJECT_NAME}-autoload) add_dependencies(MitkWorkbench ${CMAKE_PROJECT_NAME}-autoload) endif() #Setting application icon for macOS systems set_target_properties(MitkWorkbench PROPERTIES MACOSX_BUNDLE_ICON_FILE "icon.icns") if(APPLE) install(FILES "icons/icon.icns" DESTINATION "MitkWorkbench.app/Contents/Resources") endif(APPLE) diff --git a/Applications/Workbench/CMakeLists.txt b/Applications/Workbench/CMakeLists.txt index c2ad329f0f..0c24e5d70b 100644 --- a/Applications/Workbench/CMakeLists.txt +++ b/Applications/Workbench/CMakeLists.txt @@ -1,57 +1,50 @@ project(Workbench) -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_EXTAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MitkWorkbench.provisioning" CACHE INTERNAL "MitkWorkbench provisioning file" FORCE) # Plug-ins listed below will not be # - added as a build-time dependency to the executable # - listed in the provisioning file for the executable # - installed if they are external plug-ins set(_exclude_plugins org.blueberry.test org.blueberry.uitest org.mitk.gui.qt.coreapplication org.mitk.gui.qt.diffusionimagingapp org.mitk.example.gui.customviewer org.mitk.example.gui.customviewer.views org.mitk.example.gui.selectionservicemitk org.mitk.example.gui.selectionservicemitk.views org.mitk.example.gui.selectionserviceqt org.mitk.example.gui.extensionpointcontribution org.mitk.example.gui.extensionpointdefinition org.mitk.example.gui.minimalapplication org.mitk.example.gui.multipleperspectives ) mitkFunctionCreateBlueBerryApplication( NAME MitkWorkbench DESCRIPTION "MITK Workbench" EXCLUDE_PLUGINS ${_exclude_plugins} - ${_app_options} ) -mitk_use_modules(TARGET MitkWorkbench MODULES MitkAppUtil) # Add meta dependencies (e.g. on auto-load modules from depending modules) if(TARGET ${CMAKE_PROJECT_NAME}-autoload) add_dependencies(MitkWorkbench ${CMAKE_PROJECT_NAME}-autoload) endif() #Setting application icon for macOS systems set_target_properties(MitkWorkbench PROPERTIES MACOSX_BUNDLE_ICON_FILE "icon.icns") if(APPLE) install(FILES "icons/icon.icns" DESTINATION "MitkWorkbench.app/Contents/Resources") endif(APPLE) # Add a build time dependency to legacy BlueBerry bundles. if(MITK_MODULES_ENABLED_PLUGINS) add_dependencies(MitkWorkbench ${MITK_MODULES_ENABLED_PLUGINS}) endif() diff --git a/CMake/mitkFunctionCreateBlueBerryApplication.cmake b/CMake/mitkFunctionCreateBlueBerryApplication.cmake index f344380651..5bafd3813f 100644 --- a/CMake/mitkFunctionCreateBlueBerryApplication.cmake +++ b/CMake/mitkFunctionCreateBlueBerryApplication.cmake @@ -1,218 +1,216 @@ #! #! Create a BlueBerry application. #! #! \brief This function will create a BlueBerry application together with all #! necessary provisioning and configuration data and install support. #! #! \param NAME (required) The name of the executable. #! \param DESCRIPTION (optional) A human-readable description of your application. #! The usage depends on the CPack generator (on Windows, this is a descriptive #! text for the created shortcuts). #! \param SOURCES (optional) A list of source files to compile into your executable. Defaults #! to .cpp. #! \param PLUGINS (optional) A list of required plug-ins. Defaults to all known plug-ins. #! \param EXCLUDE_PLUGINS (optional) A list of plug-ins which should not be used. Mainly #! useful if PLUGINS was not used. #! \param LINK_LIBRARIES A list of libraries to be linked with the executable. #! \param LIBRARY_DIRS A list of directories to pass through to MITK_INSTALL_TARGETS -#! \param SHOW_CONSOLE (option) Show the console output window (on Windows). #! \param NO_PROVISIONING (option) Do not create provisioning files. #! \param NO_INSTALL (option) Do not install this executable #! #! Assuming that there exists a file called MyApp.cpp, an example call looks like: #! \code #! mitkFunctionCreateBlueBerryApplication( #! NAME MyApp #! DESCRIPTION "MyApp - New ways to explore medical data" #! EXCLUDE_PLUGINS org.mitk.gui.qt.extapplication -#! SHOW_CONSOLE #! ) #! \endcode #! function(mitkFunctionCreateBlueBerryApplication) -cmake_parse_arguments(_APP "SHOW_CONSOLE;NO_PROVISIONING;NO_INSTALL" "NAME;DESCRIPTION" "SOURCES;PLUGINS;EXCLUDE_PLUGINS;LINK_LIBRARIES;LIBRARY_DIRS" ${ARGN}) +cmake_parse_arguments(_APP "NO_PROVISIONING;NO_INSTALL" "NAME;DESCRIPTION" "SOURCES;PLUGINS;EXCLUDE_PLUGINS;LINK_LIBRARIES;LIBRARY_DIRS" ${ARGN}) if(NOT _APP_NAME) message(FATAL_ERROR "NAME argument cannot be empty.") endif() if(NOT _APP_SOURCES) set(_APP_SOURCES ${_APP_NAME}.cpp) endif() if(NOT _APP_PLUGINS) ctkFunctionGetAllPluginTargets(_APP_PLUGINS) else() set(_plugins ${_APP_PLUGINS}) set(_APP_PLUGINS) foreach(_plugin ${_plugins}) string(REPLACE "." "_" _plugin_target ${_plugin}) list(APPEND _APP_PLUGINS ${_plugin_target}) endforeach() # get all plug-in dependencies ctkFunctionGetPluginDependencies(_plugin_deps PLUGINS ${_APP_PLUGINS} ALL) # add the dependencies to the list of application plug-ins list(APPEND _APP_PLUGINS ${_plugin_deps}) endif() # ----------------------------------------------------------------------- # Set up include and link dirs for the executable # ----------------------------------------------------------------------- include_directories( ${org_blueberry_core_runtime_INCLUDE_DIRS} ) # ----------------------------------------------------------------------- # Add executable icon (Windows) # ----------------------------------------------------------------------- set(WINDOWS_ICON_RESOURCE_FILE "") if(WIN32) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc") set(WINDOWS_ICON_RESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc") endif() endif() # ----------------------------------------------------------------------- # Create the executable and link libraries # ----------------------------------------------------------------------- set(_app_compile_flags ) if(WIN32) set(_app_compile_flags "${_app_compile_flags} -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN") endif() -if(_APP_SHOW_CONSOLE) +if(MITK_SHOW_CONSOLE_WINDOW) add_executable(${_APP_NAME} MACOSX_BUNDLE ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE}) else() add_executable(${_APP_NAME} MACOSX_BUNDLE WIN32 ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE}) endif() -mitk_use_modules(TARGET ${_APP_NAME} MODULES mbilog PACKAGES Poco Qt5|Core) +mitk_use_modules(TARGET ${_APP_NAME} MODULES MitkAppUtil) set_target_properties(${_APP_NAME} PROPERTIES COMPILE_FLAGS "${_app_compile_flags}") target_link_libraries(${_APP_NAME} PRIVATE org_blueberry_core_runtime ${_APP_LINK_LIBRARIES}) if(WIN32) target_link_libraries(${_APP_NAME} PRIVATE ${QT_QTMAIN_LIBRARY}) endif() # ----------------------------------------------------------------------- # Add executable icon and bundle name (Mac) # ----------------------------------------------------------------------- if(APPLE) if( _APP_DESCRIPTION) set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_DESCRIPTION}") else() set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_NAME}") endif() set(icon_name "icon.icns") set(icon_full_path "${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon_name}") if(EXISTS "${icon_full_path}") set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE "${icon_name}") file(COPY ${icon_full_path} DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.app/Contents/Resources/") INSTALL (FILES ${icon_full_path} DESTINATION "${_APP_NAME}.app/Contents/Resources/") endif() endif() # ----------------------------------------------------------------------- # Set build time dependencies # ----------------------------------------------------------------------- # This ensures that all enabled plug-ins are up-to-date when the # executable is build. if(_APP_PLUGINS) ctkMacroGetAllProjectTargetLibraries("${_APP_PLUGINS}" _project_plugins) if(_APP_EXCLUDE_PLUGINS AND _project_plugins) set(_exclude_targets) foreach(_exclude_plugin ${_APP_EXCLUDE_PLUGINS}) string(REPLACE "." "_" _exclude_target ${_exclude_plugin}) list(APPEND _exclude_targets ${_exclude_target}) endforeach() list(REMOVE_ITEM _project_plugins ${_exclude_targets}) endif() if(_project_plugins) add_dependencies(${_APP_NAME} ${_project_plugins}) endif() endif() # ----------------------------------------------------------------------- # Additional files needed for the executable # ----------------------------------------------------------------------- if(NOT _APP_NO_PROVISIONING) # Create a provisioning file, listing all plug-ins set(_prov_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.provisioning") mitkFunctionCreateProvisioningFile(FILE ${_prov_file} PLUGINS ${_APP_PLUGINS} EXCLUDE_PLUGINS ${_APP_EXCLUDE_PLUGINS} ) endif() # Create a .ini file for initial parameters if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_APP_NAME}.ini") configure_file(${_APP_NAME}.ini ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.ini) endif() # Create batch and VS user files for Windows platforms include(mitkFunctionCreateWindowsBatchScript) if(WIN32) set(template_name "start${_APP_NAME}.bat.in") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${template_name}") foreach(BUILD_TYPE debug release) mitkFunctionCreateWindowsBatchScript(${template_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/start${_APP_NAME}_${BUILD_TYPE}.bat ${BUILD_TYPE}) endforeach() endif() mitkFunctionConfigureVisualStudioUserProjectFile( NAME ${_APP_NAME} ) endif(WIN32) # ----------------------------------------------------------------------- # Install support # ----------------------------------------------------------------------- if(NOT _APP_NO_INSTALL) # This installs all third-party CTK plug-ins mitkFunctionInstallThirdPartyCTKPlugins(${_APP_PLUGINS} EXCLUDE ${_APP_EXCLUDE_PLUGINS}) if(COMMAND BlueBerryApplicationInstallHook) set(_real_app_plugins ${_APP_PLUGINS}) if(_APP_EXCLUDE_PLUGINS) list(REMOVE_ITEM _real_app_plugins ${_APP_EXCLUDE_PLUGINS}) endif() BlueBerryApplicationInstallHook(APP_NAME ${_APP_NAME} PLUGINS ${_real_app_plugins}) endif() # Install the executable MITK_INSTALL_TARGETS(EXECUTABLES ${_APP_NAME} LIBRARY_DIRS ${_APP_LIBRARY_DIRS} GLOB_PLUGINS ) if(NOT _APP_NO_PROVISIONING) # Install the provisioning file mitkFunctionInstallProvisioningFiles(${_prov_file}) endif() # On Linux, create a shell script to start a relocatable application if(UNIX AND NOT APPLE) install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${_APP_NAME}.sh) endif() # Tell cpack the executables that you want in the start menu as links set(MITK_CPACK_PACKAGE_EXECUTABLES ${MITK_CPACK_PACKAGE_EXECUTABLES} "${_APP_NAME};${_APP_DESCRIPTION}" CACHE INTERNAL "Collecting windows shortcuts to executables") endif() endfunction() function(FunctionCreateBlueBerryApplication) message(SEND_ERROR "The function FunctionCreateBlueBerryApplication was renamed to mitkFunctionCreateBlueBerryApplication in MITK 2015.05") endfunction() diff --git a/Examples/BlueBerryExampleLauncher/CMakeLists.txt b/Examples/BlueBerryExampleLauncher/CMakeLists.txt index e74077fe11..06111f4d8c 100644 --- a/Examples/BlueBerryExampleLauncher/CMakeLists.txt +++ b/Examples/BlueBerryExampleLauncher/CMakeLists.txt @@ -1,85 +1,82 @@ project(BlueBerryExampleLauncher) set(_source_files BlueBerryExampleLauncher.cpp BlueBerryExampleLauncherDialog.cpp ) set(_source_moc_h_files BlueBerryExampleLauncherDialog.h ) set(_source_ui_files BlueBerryExampleLauncherDialog.ui ) # this is a workaround for Visual Studio. The relative include paths in the generated # moc files can get very long and can't be resolved by the MSVC compiler. foreach(_moc_src ${_source_moc_h_files}) qt5_wrap_cpp(_source_files ${_moc_src} OPTIONS -f${_moc_src}) endforeach() qt5_wrap_ui(_source_files ${_source_ui_files}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) #----------------------------------------------------------------------------- # Create provisioning files #----------------------------------------------------------------------------- set(_plugins_for_all_demos ) file(GLOB _demo_configurations Configurations/*.cmake) set(ALL_REQUIRED_PLUGINS ${_plugins_for_all_demos}) foreach(_demo_config_file ${_demo_configurations}) set(REQUIRED_PLUGINS ) set(DESCRIPTION ) include(${_demo_config_file}) get_filename_component(_name ${_demo_config_file} NAME_WE) mitkFunctionCreateProvisioningFile(FILE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_${_name}.provisioning PLUGINS ${REQUIRED_PLUGINS} ${_plugins_for_all_demos} NO_INSTALL ) if(DESCRIPTION) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/BlueBerryExampleDescription.txt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_${_name}.txt @ONLY) endif() list(APPEND ALL_REQUIRED_PLUGINS ${REQUIRED_PLUGINS}) endforeach() list(REMOVE_DUPLICATES ALL_REQUIRED_PLUGINS) set(ALL_REQUIRED_PLUGIN_TARGETS ) foreach(req_plugin ${ALL_REQUIRED_PLUGINS}) string(REPLACE "." "_" _plugin_target ${req_plugin}) if(TARGET ${_plugin_target}) list(APPEND ALL_REQUIRED_PLUGIN_TARGETS ${_plugin_target}) endif() endforeach() #----------------------------------------------------------------------------- # Create the example launcher #----------------------------------------------------------------------------- mitkFunctionCreateBlueBerryApplication( NAME ${PROJECT_NAME} DESCRIPTION "MITK Application Framework Demo" SOURCES ${_source_files} # PLUGINS ${ALL_REQUIRED_PLUGIN_TARGETS} NO_PROVISIONING NO_INSTALL - SHOW_CONSOLE ) -mitk_use_modules(TARGET ${PROJECT_NAME} MODULES MitkAppUtil PACKAGES Qt5|Widgets) - add_dependencies(${PROJECT_NAME} ${ALL_REQUIRED_PLUGIN_TARGETS}) # subproject support set_property(TARGET ${PROJECT_NAME} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) add_dependencies(${subproject} ${PROJECT_NAME}) endforeach() diff --git a/Modules/CppMicroServices/cmake/usCMakeResourceDependencies.cpp b/Modules/CppMicroServices/cmake/usCMakeResourceDependencies.cpp index c1aa3719ea..7276b1a4b1 100644 --- a/Modules/CppMicroServices/cmake/usCMakeResourceDependencies.cpp +++ b/Modules/CppMicroServices/cmake/usCMakeResourceDependencies.cpp @@ -1,30 +1,33 @@ /*============================================================================= Library: CppMicroServices 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. =============================================================================*/ -#include - namespace { // This is dummy code to silence some linkers warning about // empty object files. -struct CMakeResourceDependencies { CMakeResourceDependencies() { std::cout << std::flush; } }; +struct CMakeResourceDependencies +{ + CMakeResourceDependencies() + { + } +}; } diff --git a/Modules/CppMicroServices/core/src/service/usServiceListeners.cpp b/Modules/CppMicroServices/core/src/service/usServiceListeners.cpp index 39217e79ea..29b46e008a 100644 --- a/Modules/CppMicroServices/core/src/service/usServiceListeners.cpp +++ b/Modules/CppMicroServices/core/src/service/usServiceListeners.cpp @@ -1,334 +1,334 @@ /*============================================================================= Library: CppMicroServices 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. =============================================================================*/ #include "usUtils_p.h" #include "usServiceListeners_p.h" #include "usServiceReferenceBasePrivate.h" #include "usCoreModuleContext_p.h" #include "usModule.h" #include "usModuleContext.h" US_BEGIN_NAMESPACE const int ServiceListeners::OBJECTCLASS_IX = 0; const int ServiceListeners::SERVICE_ID_IX = 1; ServiceListeners::ServiceListeners(CoreModuleContext* coreCtx) : coreCtx(coreCtx) { hashedServiceKeys.push_back(ServiceConstants::OBJECTCLASS()); hashedServiceKeys.push_back(ServiceConstants::SERVICE_ID()); } void ServiceListeners::AddServiceListener(ModuleContext* mc, const ServiceListenerEntry::ServiceListener& listener, void* data, const std::string& filter) { US_UNUSED(Lock(this)); ServiceListenerEntry sle(mc, listener, data, filter); RemoveServiceListener_unlocked(sle); serviceSet.insert(sle); coreCtx->serviceHooks.HandleServiceListenerReg(sle); CheckSimple(sle); } void ServiceListeners::RemoveServiceListener(ModuleContext* mc, const ServiceListenerEntry::ServiceListener& listener, void* data) { ServiceListenerEntry entryToRemove(mc, listener, data); US_UNUSED(Lock(this)); RemoveServiceListener_unlocked(entryToRemove); } void ServiceListeners::RemoveServiceListener_unlocked(const ServiceListenerEntry& entryToRemove) { ServiceListenerEntries::const_iterator it = serviceSet.find(entryToRemove); if (it != serviceSet.end()) { it->SetRemoved(true); coreCtx->serviceHooks.HandleServiceListenerUnreg(*it); RemoveFromCache(*it); serviceSet.erase(it); } } void ServiceListeners::AddModuleListener(ModuleContext* mc, const ModuleListener& listener, void* data) { MutexLock lock(moduleListenerMapMutex); ModuleListenerMap::value_type::second_type& listeners = moduleListenerMap[mc]; - if (std::find_if(listeners.begin(), listeners.end(), std::bind1st(ModuleListenerCompare(), std::make_pair(listener, data))) == listeners.end()) + if (std::find_if(listeners.begin(), listeners.end(), std::bind(ModuleListenerCompare(), std::make_pair(listener, data), std::placeholders::_1)) == listeners.end()) { listeners.push_back(std::make_pair(listener, data)); } } void ServiceListeners::RemoveModuleListener(ModuleContext* mc, const ModuleListener& listener, void* data) { MutexLock lock(moduleListenerMapMutex); - moduleListenerMap[mc].remove_if(std::bind1st(ModuleListenerCompare(), std::make_pair(listener, data))); + moduleListenerMap[mc].remove_if(std::bind(ModuleListenerCompare(), std::make_pair(listener, data), std::placeholders::_1)); } void ServiceListeners::ModuleChanged(const ModuleEvent& evt) { ModuleListenerMap filteredModuleListeners; coreCtx->moduleHooks.FilterModuleEventReceivers(evt, filteredModuleListeners); for(ModuleListenerMap::iterator iter = filteredModuleListeners.begin(), end = filteredModuleListeners.end(); iter != end; ++iter) { for (ModuleListenerMap::mapped_type::iterator iter2 = iter->second.begin(), end2 = iter->second.end(); iter2 != end2; ++iter2) { try { (iter2->first)(evt); } catch (const std::exception& e) { US_WARN << "Module listener threw an exception: " << e.what(); } } } } void ServiceListeners::RemoveAllListeners(ModuleContext* mc) { { US_UNUSED(Lock(this)); for (ServiceListenerEntries::iterator it = serviceSet.begin(); it != serviceSet.end(); ) { if (it->GetModuleContext() == mc) { RemoveFromCache(*it); serviceSet.erase(it++); } else { ++it; } } } { MutexLock lock(moduleListenerMapMutex); moduleListenerMap.erase(mc); } } void ServiceListeners::HooksModuleStopped(ModuleContext* mc) { US_UNUSED(Lock(this)); std::vector entries; for (ServiceListenerEntries::iterator it = serviceSet.begin(); it != serviceSet.end(); ) { if (it->GetModuleContext() == mc) { entries.push_back(*it); } } coreCtx->serviceHooks.HandleServiceListenerUnreg(entries); } void ServiceListeners::ServiceChanged(ServiceListenerEntries& receivers, const ServiceEvent& evt) { ServiceListenerEntries matchBefore; ServiceChanged(receivers, evt, matchBefore); } void ServiceListeners::ServiceChanged(ServiceListenerEntries& receivers, const ServiceEvent& evt, ServiceListenerEntries& matchBefore) { int n = 0; if (!matchBefore.empty()) { for (ServiceListenerEntries::const_iterator l = receivers.begin(); l != receivers.end(); ++l) { matchBefore.erase(*l); } } for (ServiceListenerEntries::const_iterator l = receivers.begin(); l != receivers.end(); ++l) { if (!l->IsRemoved()) { try { ++n; l->CallDelegate(evt); } catch (...) { US_WARN << "Service listener" << " in " << l->GetModuleContext()->GetModule()->GetName() << " threw an exception!"; } } } //US_DEBUG << "Notified " << n << " listeners"; } void ServiceListeners::GetMatchingServiceListeners(const ServiceEvent& evt, ServiceListenerEntries& set, bool lockProps) { US_UNUSED(Lock(this)); // Filter the original set of listeners ServiceListenerEntries receivers = serviceSet; coreCtx->serviceHooks.FilterServiceEventReceivers(evt, receivers); // Check complicated or empty listener filters for (std::list::const_iterator sse = complicatedListeners.begin(); sse != complicatedListeners.end(); ++sse) { if (receivers.count(*sse) == 0) continue; const LDAPExpr& ldapExpr = sse->GetLDAPExpr(); if (ldapExpr.IsNull() || ldapExpr.Evaluate(evt.GetServiceReference().d->GetProperties(), false)) { set.insert(*sse); } } //US_DEBUG << "Added " << set.size() << " out of " << n // << " listeners with complicated filters"; // Check the cache const std::vector c(any_cast > (evt.GetServiceReference().d->GetProperty(ServiceConstants::OBJECTCLASS(), lockProps))); for (std::vector::const_iterator objClass = c.begin(); objClass != c.end(); ++objClass) { AddToSet(set, receivers, OBJECTCLASS_IX, *objClass); } long service_id = any_cast(evt.GetServiceReference().d->GetProperty(ServiceConstants::SERVICE_ID(), lockProps)); std::stringstream ss; ss << service_id; AddToSet(set, receivers, SERVICE_ID_IX, ss.str()); } std::vector ServiceListeners::GetListenerInfoCollection() const { US_UNUSED(Lock(this)); std::vector result; result.reserve(serviceSet.size()); for (ServiceListenerEntries::const_iterator iter = serviceSet.begin(), iterEnd = serviceSet.end(); iter != iterEnd; ++iter) { result.push_back(*iter); } return result; } void ServiceListeners::RemoveFromCache(const ServiceListenerEntry& sle) { if (!sle.GetLocalCache().empty()) { for (std::size_t i = 0; i < hashedServiceKeys.size(); ++i) { CacheType& keymap = cache[i]; std::vector& l = sle.GetLocalCache()[i]; for (std::vector::const_iterator it = l.begin(); it != l.end(); ++it) { std::list& sles = keymap[*it]; sles.remove(sle); if (sles.empty()) { keymap.erase(*it); } } } } else { complicatedListeners.remove(sle); } } void ServiceListeners::CheckSimple(const ServiceListenerEntry& sle) { if (sle.GetLDAPExpr().IsNull()) { complicatedListeners.push_back(sle); } else { LDAPExpr::LocalCache local_cache; if (sle.GetLDAPExpr().IsSimple(hashedServiceKeys, local_cache, false)) { sle.GetLocalCache() = local_cache; for (std::size_t i = 0; i < hashedServiceKeys.size(); ++i) { for (std::vector::const_iterator it = local_cache[i].begin(); it != local_cache[i].end(); ++it) { std::list& sles = cache[i][*it]; sles.push_back(sle); } } } else { //US_DEBUG << "Too complicated filter: " << sle.GetFilter(); complicatedListeners.push_back(sle); } } } void ServiceListeners::AddToSet(ServiceListenerEntries& set, const ServiceListenerEntries& receivers, int cache_ix, const std::string& val) { std::list& l = cache[cache_ix][val]; if (!l.empty()) { //US_DEBUG << hashedServiceKeys[cache_ix] << " matches " << l.size(); for (std::list::const_iterator entry = l.begin(); entry != l.end(); ++entry) { if (receivers.count(*entry)) { set.insert(*entry); } } } else { //US_DEBUG << hashedServiceKeys[cache_ix] << " matches none"; } } US_END_NAMESPACE diff --git a/Modules/CppMicroServices/core/src/util/usListenerFunctors_p.h b/Modules/CppMicroServices/core/src/util/usListenerFunctors_p.h index 8bbe3a2d8a..581d281ed8 100644 --- a/Modules/CppMicroServices/core/src/util/usListenerFunctors_p.h +++ b/Modules/CppMicroServices/core/src/util/usListenerFunctors_p.h @@ -1,89 +1,89 @@ /*============================================================================= Library: CppMicroServices 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. =============================================================================*/ #ifndef USLISTENERFUNCTORS_P_H #define USLISTENERFUNCTORS_P_H #include #include #include #include #ifdef US_HAVE_STD_FUNCTION #ifdef US_HAVE_FUNCTIONAL_H #include #elif defined(US_HAVE_TR1_FUNCTIONAL_H) #include #endif #define US_FUNCTION_TYPE std::function #elif defined(US_HAVE_TR1_FUNCTION) #ifdef US_HAVE_TR1_FUNCTIONAL_H #include #elif defined(US_HAVE_FUNCTIONAL_H) #include #endif #define US_FUNCTION_TYPE std::tr1::function #endif #define US_MODULE_LISTENER_FUNCTOR US_FUNCTION_TYPE #define US_SERVICE_LISTENER_FUNCTOR US_FUNCTION_TYPE US_BEGIN_NAMESPACE template US_MODULE_LISTENER_FUNCTOR ModuleListenerMemberFunctor(X* x, void (X::*memFn)(const US_PREPEND_NAMESPACE(ModuleEvent))) - { return std::bind1st(std::mem_fun(memFn), x); } + { return std::bind(std::mem_fn(memFn), x, std::placeholders::_1); } struct ModuleListenerCompare : std::binary_function, std::pair, bool> { bool operator()(const std::pair& p1, const std::pair& p2) const { return p1.second == p2.second && p1.first.target() == p2.first.target(); } }; template US_SERVICE_LISTENER_FUNCTOR ServiceListenerMemberFunctor(X* x, void (X::*memFn)(const US_PREPEND_NAMESPACE(ServiceEvent))) - { return std::bind1st(std::mem_fun(memFn), x); } + { return std::bind(std::mem_fn(memFn), x, std::placeholders::_1); } struct ServiceListenerCompare : std::binary_function { bool operator()(const US_SERVICE_LISTENER_FUNCTOR& f1, const US_SERVICE_LISTENER_FUNCTOR& f2) const { return f1.target() == f2.target(); } }; US_END_NAMESPACE US_HASH_FUNCTION_NAMESPACE_BEGIN US_HASH_FUNCTION_BEGIN(US_SERVICE_LISTENER_FUNCTOR) void(*targetFunc)(const US_PREPEND_NAMESPACE(ServiceEvent)&) = arg.target(); void* targetPtr = nullptr; std::memcpy(&targetPtr, &targetFunc, sizeof(void*)); return US_HASH_FUNCTION(void*, targetPtr); US_HASH_FUNCTION_END US_HASH_FUNCTION_NAMESPACE_END #endif // USLISTENERFUNCTORS_P_H diff --git a/Modules/Gizmo/src/mitkGizmoInteractor.cpp b/Modules/Gizmo/src/mitkGizmoInteractor.cpp index 10f7332b3a..b32bc99a62 100644 --- a/Modules/Gizmo/src/mitkGizmoInteractor.cpp +++ b/Modules/Gizmo/src/mitkGizmoInteractor.cpp @@ -1,457 +1,460 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkGizmoInteractor.h" #include "mitkGizmoMapper2D.h" // MITK includes #include #include #include #include #include #include #include #include #include #include // VTK includes #include #include #include #include #include #include #include #include #include mitk::GizmoInteractor::GizmoInteractor() { m_ColorForHighlight[0] = 1.0; m_ColorForHighlight[1] = 0.5; m_ColorForHighlight[2] = 0.0; m_ColorForHighlight[3] = 1.0; // TODO if we want to get this configurable, the this is the recipe: // - make the 2D mapper add corresponding properties to control "enabled" and "color" // - make the interactor evaluate those properties // - in an ideal world, modify the state machine on the fly and skip mouse move handling } mitk::GizmoInteractor::~GizmoInteractor() { } void mitk::GizmoInteractor::ConnectActionsAndFunctions() { CONNECT_CONDITION("PickedHandle", HasPickedHandle); CONNECT_FUNCTION("DecideInteraction", DecideInteraction); CONNECT_FUNCTION("MoveAlongAxis", MoveAlongAxis); CONNECT_FUNCTION("RotateAroundAxis", RotateAroundAxis); CONNECT_FUNCTION("MoveFreely", MoveFreely); CONNECT_FUNCTION("ScaleEqually", ScaleEqually); CONNECT_FUNCTION("FeedUndoStack", FeedUndoStack); } void mitk::GizmoInteractor::SetGizmoNode(DataNode *node) { DataInteractor::SetDataNode(node); m_Gizmo = dynamic_cast(node->GetData()); // setup picking from just this object m_Picker.clear(); } void mitk::GizmoInteractor::SetManipulatedObjectNode(DataNode *node) { if (node && node->GetData()) { m_ManipulatedObjectGeometry = node->GetData()->GetGeometry(); } } bool mitk::GizmoInteractor::HasPickedHandle(const InteractionEvent *interactionEvent) { auto positionEvent = dynamic_cast(interactionEvent); if (positionEvent == nullptr || m_Gizmo.IsNull() || m_ManipulatedObjectGeometry.IsNull() || interactionEvent->GetSender()->GetRenderWindow()->GetNeverRendered()) { return false; } if (interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D) { m_PickedHandle = PickFrom2D(positionEvent); } else { m_PickedHandle = PickFrom3D(positionEvent); } UpdateHandleHighlight(); return m_PickedHandle != Gizmo::NoHandle; } void mitk::GizmoInteractor::DecideInteraction(StateMachineAction *, InteractionEvent *interactionEvent) { assert(m_PickedHandle != Gizmo::NoHandle); auto positionEvent = dynamic_cast(interactionEvent); if (positionEvent == nullptr) { return; } // if something relevant was picked, we calculate a number of // important points and axes for the upcoming geometry manipulations // note initial state m_InitialClickPosition2D = positionEvent->GetPointerPositionOnScreen(); m_InitialClickPosition3D = positionEvent->GetPositionInWorld(); auto renderer = positionEvent->GetSender()->GetVtkRenderer(); renderer->SetWorldPoint(m_InitialClickPosition3D[0], m_InitialClickPosition3D[1], m_InitialClickPosition3D[2], 0); renderer->WorldToDisplay(); m_InitialClickPosition2DZ = renderer->GetDisplayPoint()[2]; m_InitialGizmoCenter3D = m_Gizmo->GetCenter(); positionEvent->GetSender()->WorldToDisplay(m_InitialGizmoCenter3D, m_InitialGizmoCenter2D); m_InitialManipulatedObjectGeometry = m_ManipulatedObjectGeometry->Clone(); switch ( m_PickedHandle ) { case Gizmo::MoveAlongAxisX: case Gizmo::RotateAroundAxisX: case Gizmo::ScaleX: m_AxisOfMovement = m_InitialManipulatedObjectGeometry->GetAxisVector(0); break; case Gizmo::MoveAlongAxisY: case Gizmo::RotateAroundAxisY: case Gizmo::ScaleY: m_AxisOfMovement = m_InitialManipulatedObjectGeometry->GetAxisVector(1); break; case Gizmo::MoveAlongAxisZ: case Gizmo::RotateAroundAxisZ: case Gizmo::ScaleZ: m_AxisOfMovement = m_InitialManipulatedObjectGeometry->GetAxisVector(2); break; default: break; } m_AxisOfMovement.Normalize(); m_AxisOfRotation = m_AxisOfMovement; // for translation: test whether the user clicked into the "object's real" axis direction // or into the other one Vector3D intendedAxis = m_InitialClickPosition3D - m_InitialGizmoCenter3D; if ( intendedAxis * m_AxisOfMovement < 0 ) { m_AxisOfMovement *= -1.0; } // for rotation: test whether the axis of rotation is more looking in the direction // of the camera or in the opposite vtkCamera *camera = renderer->GetActiveCamera(); vtkVector3d cameraDirection(camera->GetDirectionOfProjection()); double angle_rad = vtkMath::AngleBetweenVectors(cameraDirection.GetData(), m_AxisOfRotation.GetDataPointer()); if ( angle_rad < vtkMath::Pi() / 2.0 ) { m_AxisOfRotation *= -1.0; } InternalEvent::Pointer decision; switch (m_PickedHandle) { case Gizmo::MoveAlongAxisX: case Gizmo::MoveAlongAxisY: case Gizmo::MoveAlongAxisZ: decision = InternalEvent::New(interactionEvent->GetSender(), this, "StartTranslationAlongAxis"); break; case Gizmo::RotateAroundAxisX: case Gizmo::RotateAroundAxisY: case Gizmo::RotateAroundAxisZ: decision = InternalEvent::New(interactionEvent->GetSender(), this, "StartRotationAroundAxis"); break; case Gizmo::MoveFreely: decision = InternalEvent::New(interactionEvent->GetSender(), this, "MoveFreely"); break; case Gizmo::ScaleX: case Gizmo::ScaleY: case Gizmo::ScaleZ: + // Implementation note: Why didn't we implement per-axis scaling yet? + // When this was implemented, the mitk::ScaleOperation was able to only describe + // uniform scaling around a central point. Since we use operations for all modifications + // in order to have undo/redo working, any axis-specific scaling should also + // use operations. + // Consequence: enhance ScaleOperation when there is need to have scaling per axis. decision = InternalEvent::New(interactionEvent->GetSender(), this, "ScaleEqually"); break; default: break; } interactionEvent->GetSender()->GetDispatcher()->QueueEvent(decision); } void mitk::GizmoInteractor::MoveAlongAxis(StateMachineAction *, InteractionEvent *interactionEvent) { auto positionEvent = dynamic_cast(interactionEvent); if (positionEvent == nullptr) { return; } Vector3D mouseMovement3D = positionEvent->GetPositionInWorld() - m_InitialClickPosition3D; double projectedMouseMovement3D = mouseMovement3D * m_AxisOfMovement; Vector3D movement3D = projectedMouseMovement3D * m_AxisOfMovement; ApplyTranslationToManipulatedObject(movement3D); RenderingManager::GetInstance()->ForceImmediateUpdateAll(); } void mitk::GizmoInteractor::RotateAroundAxis(StateMachineAction *, InteractionEvent *interactionEvent) { auto positionEvent = dynamic_cast(interactionEvent); if (positionEvent == nullptr) { return; } Vector2D originalVector = m_InitialClickPosition2D - m_InitialGizmoCenter2D; Vector2D currentVector = positionEvent->GetPointerPositionOnScreen() - m_InitialGizmoCenter2D; originalVector.Normalize(); currentVector.Normalize(); double angle_rad = std::atan2(currentVector[1], currentVector[0]) - std::atan2(originalVector[1], originalVector[0]); ApplyRotationToManipulatedObject(vtkMath::DegreesFromRadians(angle_rad)); RenderingManager::GetInstance()->ForceImmediateUpdateAll(); } void mitk::GizmoInteractor::MoveFreely(StateMachineAction *, InteractionEvent *interactionEvent) { auto positionEvent = dynamic_cast(interactionEvent); if (positionEvent == nullptr) { return; } Point2D currentPosition2D = positionEvent->GetPointerPositionOnScreen(); // re-use the initial z value to really move parallel to the camera plane auto renderer = positionEvent->GetSender()->GetVtkRenderer(); renderer->SetDisplayPoint(currentPosition2D[0], currentPosition2D[1], m_InitialClickPosition2DZ); renderer->DisplayToWorld(); vtkVector3d worldPointVTK(renderer->GetWorldPoint()); Point3D worldPointITK(worldPointVTK.GetData()); Vector3D movementITK(worldPointITK - m_InitialClickPosition3D); ApplyTranslationToManipulatedObject(movementITK); RenderingManager::GetInstance()->ForceImmediateUpdateAll(); } void mitk::GizmoInteractor::ScaleEqually(StateMachineAction *, InteractionEvent *interactionEvent) { auto positionEvent = dynamic_cast(interactionEvent); if (positionEvent == nullptr) { return; } Point2D currentPosition2D = positionEvent->GetPointerPositionOnScreen(); double relativeSize = (currentPosition2D - m_InitialGizmoCenter2D).GetNorm() / (m_InitialClickPosition2D - m_InitialGizmoCenter2D).GetNorm(); ApplyEqualScalingToManipulatedObject(relativeSize); RenderingManager::GetInstance()->ForceImmediateUpdateAll(); } void mitk::GizmoInteractor::ApplyTranslationToManipulatedObject(const Vector3D &translation) { assert(m_ManipulatedObjectGeometry.IsNotNull()); auto manipulatedGeometry = m_InitialManipulatedObjectGeometry->Clone(); m_FinalDoOperation.reset(new PointOperation(OpMOVE, translation)); if (m_UndoEnabled) { m_FinalUndoOperation.reset(new PointOperation(OpMOVE, -translation)); } manipulatedGeometry->ExecuteOperation(m_FinalDoOperation.get()); - m_ManipulatedObjectGeometry->SetIdentity(); - m_ManipulatedObjectGeometry->Compose(manipulatedGeometry->GetIndexToWorldTransform()); + m_ManipulatedObjectGeometry->SetIndexToWorldTransform(manipulatedGeometry->GetIndexToWorldTransform()); } void mitk::GizmoInteractor::ApplyEqualScalingToManipulatedObject(double scalingFactor) { assert(m_ManipulatedObjectGeometry.IsNotNull()); auto manipulatedGeometry = m_InitialManipulatedObjectGeometry->Clone(); m_FinalDoOperation.reset(new ScaleOperation(OpSCALE, scalingFactor - 1.0, m_InitialGizmoCenter3D)); if (m_UndoEnabled) { m_FinalUndoOperation.reset(new ScaleOperation(OpSCALE, -(scalingFactor - 1.0), m_InitialGizmoCenter3D)); } manipulatedGeometry->ExecuteOperation(m_FinalDoOperation.get()); - m_ManipulatedObjectGeometry->SetIdentity(); - m_ManipulatedObjectGeometry->Compose(manipulatedGeometry->GetIndexToWorldTransform()); + m_ManipulatedObjectGeometry->SetIndexToWorldTransform(manipulatedGeometry->GetIndexToWorldTransform()); } void mitk::GizmoInteractor::ApplyRotationToManipulatedObject(double angle_deg) { assert(m_ManipulatedObjectGeometry.IsNotNull()); auto manipulatedGeometry = m_InitialManipulatedObjectGeometry->Clone(); m_FinalDoOperation.reset(new RotationOperation(OpROTATE, m_InitialGizmoCenter3D, m_AxisOfRotation, angle_deg)); if (m_UndoEnabled) { m_FinalUndoOperation.reset(new RotationOperation(OpROTATE, m_InitialGizmoCenter3D, m_AxisOfRotation, -angle_deg)); } manipulatedGeometry->ExecuteOperation(m_FinalDoOperation.get()); - m_ManipulatedObjectGeometry->SetIdentity(); - m_ManipulatedObjectGeometry->Compose(manipulatedGeometry->GetIndexToWorldTransform()); + m_ManipulatedObjectGeometry->SetIndexToWorldTransform(manipulatedGeometry->GetIndexToWorldTransform()); } void mitk::GizmoInteractor::FeedUndoStack(StateMachineAction *, InteractionEvent *) { if (m_UndoEnabled) { OperationEvent *operationEvent = new OperationEvent(m_ManipulatedObjectGeometry, // OperationEvent will destroy operations! // --> release() and not get() m_FinalDoOperation.release(), m_FinalUndoOperation.release(), "Direct geometry manipulation"); mitk::OperationEvent::IncCurrObjectEventId(); // save each modification individually m_UndoController->SetOperationEvent(operationEvent); } } mitk::Gizmo::HandleType mitk::GizmoInteractor::PickFrom2D(const InteractionPositionEvent *positionEvent) { BaseRenderer *renderer = positionEvent->GetSender(); auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard2D); auto gizmo_mapper = dynamic_cast(mapper); auto &picker = m_Picker[renderer]; if (picker == nullptr) { picker = vtkSmartPointer::New(); picker->SetTolerance(0.005); if (gizmo_mapper) { // doing this each time is bizarre picker->AddPickList(gizmo_mapper->GetVtkProp(renderer)); picker->PickFromListOn(); } } auto displayPosition = positionEvent->GetPointerPositionOnScreen(); picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); vtkIdType pickedPointID = picker->GetPointId(); if (pickedPointID == -1) { return Gizmo::NoHandle; } vtkPolyData *polydata = gizmo_mapper->GetVtkPolyData(renderer); if (polydata && polydata->GetPointData() && polydata->GetPointData()->GetScalars()) { double dataValue = polydata->GetPointData()->GetScalars()->GetTuple1(pickedPointID); return m_Gizmo->GetHandleFromPointDataValue(dataValue); } return Gizmo::NoHandle; } mitk::Gizmo::HandleType mitk::GizmoInteractor::PickFrom3D(const InteractionPositionEvent *positionEvent) { BaseRenderer *renderer = positionEvent->GetSender(); auto &picker = m_Picker[renderer]; if (picker == nullptr) { picker = vtkSmartPointer::New(); picker->SetTolerance(0.005); auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard3D); auto vtk_mapper = dynamic_cast(mapper); if (vtk_mapper) { // doing this each time is bizarre picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); picker->PickFromListOn(); } } auto displayPosition = positionEvent->GetPointerPositionOnScreen(); picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); vtkIdType pickedPointID = picker->GetPointId(); if (pickedPointID == -1) { return Gizmo::NoHandle; } // _something_ picked return m_Gizmo->GetHandleFromPointID(pickedPointID); } void mitk::GizmoInteractor::UpdateHandleHighlight() { if (m_HighlightedHandle != m_PickedHandle) { auto node = GetDataNode(); if (node == nullptr) return; auto base_prop = node->GetProperty("LookupTable"); if (base_prop == nullptr) return; auto lut_prop = dynamic_cast(base_prop); if (lut_prop == nullptr) return; auto lut = lut_prop->GetLookupTable(); if (lut == nullptr) return; // Table size is expected to constructed as one entry per gizmo-part enum value assert(lut->GetVtkLookupTable()->GetNumberOfTableValues() > std::max(m_PickedHandle, m_HighlightedHandle)); // Reset previously overwritten color if (m_HighlightedHandle != Gizmo::NoHandle) { lut->SetTableValue(m_HighlightedHandle, m_ColorReplacedByHighlight); } // Overwrite currently highlighted color if (m_PickedHandle != Gizmo::NoHandle) { lut->GetTableValue(m_PickedHandle, m_ColorReplacedByHighlight); lut->SetTableValue(m_PickedHandle, m_ColorForHighlight); } // Mark node modified to allow repaint node->Modified(); RenderingManager::GetInstance()->RequestUpdateAll(RenderingManager::REQUEST_UPDATE_ALL); m_HighlightedHandle = m_PickedHandle; } } diff --git a/Plugins/org.blueberry.core.runtime/CMakeLists.txt b/Plugins/org.blueberry.core.runtime/CMakeLists.txt index 91029832dc..89f0868d11 100644 --- a/Plugins/org.blueberry.core.runtime/CMakeLists.txt +++ b/Plugins/org.blueberry.core.runtime/CMakeLists.txt @@ -1,21 +1,21 @@ project(org_blueberry_core_runtime) -set(QT_USE_QTXML 1) - -mitk_create_plugin(EXPORT_DIRECTIVE org_blueberry_core_runtime_EXPORT - EXPORTED_INCLUDE_SUFFIXES src - src/application - src/dynamichelpers - src/registry +mitk_create_plugin( + EXPORT_DIRECTIVE org_blueberry_core_runtime_EXPORT + EXPORTED_INCLUDE_SUFFIXES + src + src/application + src/dynamichelpers + src/registry MODULE_DEPENDS PUBLIC mbilog ) target_link_libraries(${PLUGIN_TARGET} PUBLIC Poco::Foundation Poco::Util Poco::XML) + if(MITK_USE_Qt5) target_link_libraries(${PLUGIN_TARGET} PRIVATE Qt5::Gui Qt5::Xml) endif() -# Set compiler flags target_compile_definitions(${PLUGIN_TARGET} PUBLIC "$<$:POCO_NO_UNWINDOWS;WIN32_LEAN_AND_MEAN>") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/berryConfig.h.in" "${CMAKE_CURRENT_BINARY_DIR}/berryConfig.h" @ONLY)