diff --git a/Framework/Kernel/CMakeLists.txt b/Framework/Kernel/CMakeLists.txt index 37e30a7cf846e26e56f7998a971e2ec7092431d7..aee3079477c7cdd7c16f3f210be8dace374d8d07 100644 --- a/Framework/Kernel/CMakeLists.txt +++ b/Framework/Kernel/CMakeLists.txt @@ -560,8 +560,10 @@ if ( ${CMAKE_PROJECT_NAME} STREQUAL "MantidFramework" ) endif () set ( PLUGINS "./plugins" ) +# %V will be replaced with the major version of Qt at runtime +set ( QTPLUGINS "./plugins/qt%V" ) if ( MAKE_VATES ) - set ( PV_PLUGINS "./${PVPLUGINS_DIR}" ) + set ( PV_PLUGINS "./plugins/paraview/qt%V" ) if ( MSVC ) set (PARAVIEW_PYTHON_PATHS "${ParaView_DIR}/bin/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>;${ParaView_DIR}/lib/$<$<CONFIG:Release>:Release>$<$<CONFIG:Debug>:Debug>;${ParaView_DIR}/lib/site-packages;${ParaView_DIR}/lib/site-packages/vtk") else() @@ -572,7 +574,6 @@ else () set ( PARAVIEW_PYTHON_PATHS "") endif () set ( IGNORE_PARAVIEW "0" ) -set ( QTPLUGINS "." ) set ( UPDATE_INSTRUMENT_DEFINTITIONS "0" ) set ( CHECK_FOR_NEW_MANTID_VERSION "0" ) set ( ENABLE_USAGE_REPORTS "0" ) @@ -727,9 +728,9 @@ if ( ${CMAKE_PROJECT_NAME} MATCHES "MantidFramework" ) set ( PV_PLUGINS "" ) set ( IGNORE_PARAVIEW "1" ) else () - set ( QTPLUGINS ${MANTID_ROOT}/plugins/qtplugins/mantid ) + set ( QTPLUGINS "${MANTID_ROOT}/plugins/qt%V" ) + set ( PV_PLUGINS "${MANTID_ROOT}/${PLUGINS_DIR}/${PVPLUGINS_SUBDIR}/qt%V" ) set ( COLORMAPS_FOLDER ${MANTID_ROOT}/colormaps ) - set ( PV_PLUGINS ${MANTID_ROOT}/${PVPLUGINS_SUBDIR} ) endif () set ( CONSOLECHANNELCLASS "StdoutChannel" ) diff --git a/Framework/Kernel/inc/MantidKernel/ConfigService.h b/Framework/Kernel/inc/MantidKernel/ConfigService.h index 04a73d8a817e8228c1284b107d821924e23e5cfd..bf14c00ff5314363e992028a72da0888b1a9ad1e 100644 --- a/Framework/Kernel/inc/MantidKernel/ConfigService.h +++ b/Framework/Kernel/inc/MantidKernel/ConfigService.h @@ -255,12 +255,6 @@ public: // Starts up the logging void configureLogging(); - /// Return true if ParaView plugins are available - bool pvPluginsAvailable() const; - - /// Return the path to the pv plugins - const std::string getPVPluginsPath() const; - /// Gets the proxy for the system Kernel::ProxyInfo &getProxy(const std::string &url); diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index fa32c5bad5a6d7ff7c4d54f38e2106e8cacea41d..d4fc884102b1eb15937a6fe245937b6ad3ec09f1 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -195,8 +195,8 @@ ConfigServiceImpl::ConfigServiceImpl() // absolute paths m_ConfigPaths.emplace("mantidqt.python_interfaces_directory", true); m_ConfigPaths.emplace("plugins.directory", true); - m_ConfigPaths.emplace("pvplugins.directory", true); - m_ConfigPaths.emplace("mantidqt.plugins.directory", true); + m_ConfigPaths.emplace("pvplugins.directory", false); + m_ConfigPaths.emplace("mantidqt.plugins.directory", false); m_ConfigPaths.emplace("instrumentDefinition.directory", true); m_ConfigPaths.emplace("instrumentDefinition.vtpDirectory", true); m_ConfigPaths.emplace("groupingFiles.directory", true); @@ -1994,25 +1994,6 @@ void ConfigServiceImpl::removeObserver( m_notificationCenter.removeObserver(observer); } -/* -Checks to see whether the pvplugins.directory variable is set. If it is set, -assume -we have built Mantid with ParaView -@return True if paraview is available or not disabled. -*/ -bool ConfigServiceImpl::pvPluginsAvailable() const { - std::string pvpluginsDir = getString("pvplugins.directory"); - return !pvpluginsDir.empty(); -} - -/** - * Gets the path to the ParaView plugins - * @returns A string giving the directory of the ParaView plugins - */ -const std::string ConfigServiceImpl::getPVPluginsPath() const { - return getString("pvplugins.directory"); -} - /* Gets the system proxy information @url A url to match the proxy to diff --git a/Framework/Kernel/src/UsageService.cpp b/Framework/Kernel/src/UsageService.cpp index ba44dd00eab5678e61c693a2078f122f7b2f3d57..353a31ef34e86f1df2f56b20892c87fb55503043 100644 --- a/Framework/Kernel/src/UsageService.cpp +++ b/Framework/Kernel/src/UsageService.cpp @@ -216,7 +216,7 @@ std::string UsageServiceImpl::generateStartupMessage() { message["osReadable"] = ConfigService::Instance().getOSVersionReadable(); // paraview version or zero - if (ConfigService::Instance().pvPluginsAvailable()) { + if (MAKE_VATES) { message["ParaView"] = Kernel::ParaViewVersion::targetVersion(); } else { message["ParaView"] = 0; diff --git a/MantidPlot/src/ApplicationWindow.cpp b/MantidPlot/src/ApplicationWindow.cpp index 535b670f8aec649111daa92d248d63dd9c53a5bc..2d27ef98b0952d7e29ee2bd6d22c9b9f093fa13d 100644 --- a/MantidPlot/src/ApplicationWindow.cpp +++ b/MantidPlot/src/ApplicationWindow.cpp @@ -376,21 +376,10 @@ void ApplicationWindow::init(bool factorySettings, const QStringList &args) { // splash screen after the 3D visualization dialog has closed qApp->processEvents(); - auto &config = ConfigService::Instance(); // Starts logging + ConfigService::Instance(); // Starts logging resultsLog->attachLoggingChannel(); // Must be done after logging starts // Load Mantid core libraries by starting the framework FrameworkManager::Instance(); - // Load Paraview plugin libraries if possible - if (config.pvPluginsAvailable()) { - // load paraview plugins - if (g_log.getLevel() == Logger::Priority::PRIO_DEBUG) { - g_log.debug("Loading libraries from \"" + config.getPVPluginsPath() + - "\""); - } - LibraryManager::Instance().OpenAllLibraries(config.getPVPluginsPath(), - false); - } - #ifdef MAKE_VATES if (!vtkPVDisplayInformation::SupportsOpenGLLocally()) g_log.error("The OpenGL configuration does not support the VSI."); diff --git a/buildconfig/CMake/DarwinSetup.cmake b/buildconfig/CMake/DarwinSetup.cmake index 33f09b2c68ee640ec3a6fbdb0b72b8dc539ac07f..449863c1c49e573f97e6a4b0b668d704356ee690 100644 --- a/buildconfig/CMake/DarwinSetup.cmake +++ b/buildconfig/CMake/DarwinSetup.cmake @@ -102,9 +102,12 @@ endif () set ( BIN_DIR MantidPlot.app/Contents/MacOS ) set ( LIB_DIR MantidPlot.app/Contents/MacOS ) +# This is the root of the plugins directory set ( PLUGINS_DIR MantidPlot.app/plugins ) -set ( PVPLUGINS_DIR MantidPlot.app/pvplugins ) -set ( PVPLUGINS_SUBDIR pvplugins ) # Need to tidy these things up! +# Separate directory of plugins to be discovered by the ParaView framework +# These cannot be mixed with our other plugins. Further sub-directories +# based on the Qt version will also be created by the installation targets +set ( PVPLUGINS_SUBDIR paraview ) set(CMAKE_MACOSX_RPATH 1) # Assume we are using homebrew for now diff --git a/buildconfig/CMake/LinuxPackageScripts.cmake b/buildconfig/CMake/LinuxPackageScripts.cmake index d0f9ac0eecb5c9eaaeca3588495a02ef6c08a64d..014b963dced0427029534c809c7e35b208118706 100644 --- a/buildconfig/CMake/LinuxPackageScripts.cmake +++ b/buildconfig/CMake/LinuxPackageScripts.cmake @@ -12,15 +12,18 @@ set ( BIN_DIR bin ) set ( ETC_DIR etc ) set ( LIB_DIR lib ) +# This is the root of the plugins directory set ( PLUGINS_DIR plugins ) -set ( PVPLUGINS_DIR pvplugins ) -set ( PVPLUGINS_SUBDIR pvplugins ) # Need to tidy these things up! +# Separate directory of plugins to be discovered by the ParaView framework +# These cannot be mixed with our other plugins. Further sub-directories +# based on the Qt version will also be created by the installation targets +set ( PVPLUGINS_SUBDIR paraview ) if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) set ( CMAKE_INSTALL_PREFIX /opt/Mantid CACHE PATH "Install path" FORCE ) endif() -set ( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIB_DIR};${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR};${CMAKE_INSTALL_PREFIX}/${PVPLUGINS_DIR} ) +set ( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIB_DIR};${CMAKE_INSTALL_PREFIX}/${PLUGINS_DIR} ) # Tell rpm that this package does not own /opt /usr/share/{applications,pixmaps} # Required for Fedora >= 18 and RHEL >= 7 diff --git a/buildconfig/CMake/MSVCSetup.cmake b/buildconfig/CMake/MSVCSetup.cmake index 13217cf6a047e0ef48ed0144a7d33918f99acbb9..fb794d069365d3ec110e96a0c8e9522e89901667 100644 --- a/buildconfig/CMake/MSVCSetup.cmake +++ b/buildconfig/CMake/MSVCSetup.cmake @@ -131,6 +131,9 @@ configure_file ( ${PACKAGING_DIR}/mantidpython.bat.in ########################################################################### set ( BIN_DIR bin ) set ( LIB_DIR ${BIN_DIR} ) +# This is the root of the plugins directory set ( PLUGINS_DIR plugins ) -set ( PVPLUGINS_DIR PVPlugins ) -set ( PVPLUGINS_SUBDIR PVPlugins ) # Need to tidy these things up! +# Separate directory of plugins to be discovered by the ParaView framework +# These cannot be mixed with our other plugins. Further sub-directories +# based on the Qt version will also be created by the installation targets +set ( PVPLUGINS_SUBDIR paraview ) # Need to tidy these things up! diff --git a/qt/paraview_ext/CMakeLists.txt b/qt/paraview_ext/CMakeLists.txt index af3546e35ad3c73f3b10f3bb1e0bab0b204f9e97..93cd76e183064282b113d1b44f76e6d53a1a2410 100644 --- a/qt/paraview_ext/CMakeLists.txt +++ b/qt/paraview_ext/CMakeLists.txt @@ -11,8 +11,19 @@ if( ParaView_FOUND AND USE_PARAVIEW ) message( STATUS "Using ParaView ${PARAVIEW_VERSION_FULL}" ) include( ${PARAVIEW_USE_FILE} ) - # Output PV plugins to a separate directory - set ( PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY ${PLUGINS_LIBRARY_OUTPUT_DIRECTORY}/qt4/pvplugins ) + function (set_pvplugin_properties target QT_VERSION vers) + set_target_properties ( ${target} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${PLUGINS_LIBRARY_OUTPUT_DIRECTORY}/${PVPLUGINS_SUBDIR}/qt${vers} + FOLDER "MantidVatesParaViewPlugins" + ) + endfunction() + + function (install_pvplugin target QT_VERSION vers) + install( TARGETS ${target} ${SYSTEM_PACKAGE_TARGET} + DESTINATION ${PLUGINS_DIR}/${PVPLUGINS_SUBDIR}/qt${vers} + ) + endfunction() + add_subdirectory( VatesAPI ) add_subdirectory( VatesAlgorithms ) add_subdirectory( PVPlugins ) diff --git a/qt/paraview_ext/PVPlugins/CMakeLists.txt b/qt/paraview_ext/PVPlugins/CMakeLists.txt index f5427b4af1438bdf392db70d1c28de4174e312d9..b68a62d3c5e8659ef31a265578ae3b73a31d3883 100644 --- a/qt/paraview_ext/PVPlugins/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/CMakeLists.txt @@ -20,15 +20,17 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio") else () set ( _pv_library_output_dir ${ParaView_DIR}/lib ) endif() -add_custom_command ( OUTPUT ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY}/${_plugin_filename} +add_custom_command ( OUTPUT ${PLUGINS_LIBRARY_OUTPUT_DIRECTORY}/${PVPLUGINS_SUBDIR}/qt4/${_plugin_filename} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_pv_library_output_dir}/${CMAKE_CFG_INTDIR}/${_plugin_filename} - ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY}/${_plugin_filename} + ${PLUGINS_LIBRARY_OUTPUT_DIRECTORY}/${PVPLUGINS_SUBDIR}/qt${vers}/${_plugin_filename} ) -add_custom_target ( copy_nonorthogonal_plugin DEPENDS ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY}/${_plugin_filename} ) +add_custom_target ( copy_nonorthogonal_plugin DEPENDS ${PLUGINS_LIBRARY_OUTPUT_DIRECTORY}/${PVPLUGINS_SUBDIR}/qt4/${_plugin_filename} ) add_dependencies ( MantidParaViewMDEWSourceSMPlugin copy_nonorthogonal_plugin ) if ( (NOT APPLE) AND NonOrthogonalSourcePlugin_LOCATION) # make_package.rb handles this for OSX - install( FILES ${NonOrthogonalSourcePlugin_LOCATION} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) + install( FILES ${NonOrthogonalSourcePlugin_LOCATION} ${SYSTEM_PACKAGE_TARGET} + DESTINATION ${PLUGINS_DIR}/${PVPLUGINS_SUBDIR}/qt4 + ) endif() diff --git a/qt/paraview_ext/PVPlugins/Filters/PeaksFilter/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Filters/PeaksFilter/CMakeLists.txt index 522b5d664013afd05d1a10699a33318e9c54979a..bdf31ea473753538b099aa1abc2b1bb6c8b0159a 100644 --- a/qt/paraview_ext/PVPlugins/Filters/PeaksFilter/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Filters/PeaksFilter/CMakeLists.txt @@ -3,10 +3,7 @@ include_directories( SYSTEM ${PARAVIEW_INCLUDE_DIRS} ) ADD_PARAVIEW_PLUGIN(MantidParaViewPeaksFilterSMPlugin "1.0" SERVER_MANAGER_XML PeaksFilter.xml SERVER_MANAGER_SOURCES vtkPeaksFilter.cxx vtkPeaksFilter.h) -set_target_properties ( MantidParaViewPeaksFilterSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewPeaksFilterSMPlugin QT_VERSION 4) target_link_libraries( MantidParaViewPeaksFilterSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${CORE_MANTIDLIBS} @@ -21,4 +18,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewPeaksFilterSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewPeaksFilterSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR}) +install_pvplugin (MantidParaViewPeaksFilterSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Filters/ScaleWorkspace/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Filters/ScaleWorkspace/CMakeLists.txt index fe00dff13612ea8234e2164a1883ded6c7d6e80a..f6b7870c06e5c68ca6d84760819b447e989179a0 100644 --- a/qt/paraview_ext/PVPlugins/Filters/ScaleWorkspace/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Filters/ScaleWorkspace/CMakeLists.txt @@ -3,10 +3,7 @@ include_directories( SYSTEM ${PARAVIEW_INCLUDE_DIRS} ) ADD_PARAVIEW_PLUGIN(MantidParaViewScaleWorkspaceSMPlugin "1.0" SERVER_MANAGER_XML ScaleWorkspace.xml SERVER_MANAGER_SOURCES vtkScaleWorkspace.cxx) -set_target_properties ( MantidParaViewScaleWorkspaceSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewScaleWorkspaceSMPlugin QT_VERSION 4) target_link_libraries( MantidParaViewScaleWorkspaceSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${CORE_MANTIDLIBS} @@ -19,4 +16,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewScaleWorkspaceSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewScaleWorkspaceSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR}) +install_pvplugin (MantidParaViewScaleWorkspaceSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Filters/SplatterPlot/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Filters/SplatterPlot/CMakeLists.txt index 011fc2d943c2dec55c3783e1284b7d3027956655..10439287ced9abe8a71fe574947dd83b753df825 100644 --- a/qt/paraview_ext/PVPlugins/Filters/SplatterPlot/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Filters/SplatterPlot/CMakeLists.txt @@ -4,10 +4,8 @@ ADD_PARAVIEW_PLUGIN(MantidParaViewSplatterPlotSMPlugin "1.0" SERVER_MANAGER_XML SplatterPlot.xml SERVER_MANAGER_SOURCES vtkSplatterPlot.cxx GUI_RESOURCES SplatterPlot.qrc) -set_target_properties ( MantidParaViewSplatterPlotSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewSplatterPlotSMPlugin QT_VERSION 4) + include_directories ( SYSTEM ${QWT5_INCLUDE_DIR} ) @@ -25,5 +23,5 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewSplatterPlotSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewSplatterPlotSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) +install_pvplugin (MantidParaViewSplatterPlotSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Readers/MDEWNexusReader/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Readers/MDEWNexusReader/CMakeLists.txt index 2513d82f83f82c2e9171bf9de07f09295467f9d6..c075e2a9d5ca3e0bb0aabf8f669e64efcb3bcf23 100644 --- a/qt/paraview_ext/PVPlugins/Readers/MDEWNexusReader/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Readers/MDEWNexusReader/CMakeLists.txt @@ -4,10 +4,7 @@ add_paraview_plugin( MantidParaViewMDEWNexusReaderSMPlugin "1.0" SERVER_MANAGER_XML MDEWNexusReader.xml SERVER_MANAGER_SOURCES vtkMDEWNexusReader.cxx ) -set_target_properties ( MantidParaViewMDEWNexusReaderSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewMDEWNexusReaderSMPlugin QT_VERSION 4) include_directories ( SYSTEM ${QWT5_INCLUDE_DIR} ) @@ -26,6 +23,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewMDEWNexusReaderSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewMDEWNexusReaderSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) - - +install_pvplugin (MantidParaViewMDEWNexusReaderSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Readers/MDHWNexusReader/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Readers/MDHWNexusReader/CMakeLists.txt index b17006863d511ba7e8c32bf5a8038868ea2f315b..ad7c97bd5e9af99e68cf8890388ec8f9de4bed7b 100644 --- a/qt/paraview_ext/PVPlugins/Readers/MDHWNexusReader/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Readers/MDHWNexusReader/CMakeLists.txt @@ -4,10 +4,7 @@ add_paraview_plugin( MantidParaViewMDHWNexusReaderSMPlugin "1.0" SERVER_MANAGER_XML MDHWNexusReader.xml SERVER_MANAGER_SOURCES vtkMDHWNexusReader.cxx ) -set_target_properties ( MantidParaViewMDHWNexusReaderSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewMDHWNexusReaderSMPlugin QT_VERSION 4) include_directories ( SYSTEM ${QWT5_INCLUDE_DIR} ) @@ -26,6 +23,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewMDHWNexusReaderSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewMDHWNexusReaderSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) - - +install_pvplugin (MantidParaViewMDHWNexusReaderSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Readers/NexusPeaksReader/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Readers/NexusPeaksReader/CMakeLists.txt index bc29718064edf88e6549f63550119fe942ddf384..65556f90ef5ed0fa7f6d0908acfe8ef22ffa7588 100644 --- a/qt/paraview_ext/PVPlugins/Readers/NexusPeaksReader/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Readers/NexusPeaksReader/CMakeLists.txt @@ -4,10 +4,7 @@ add_paraview_plugin( MantidParaViewNexusPeaksReaderSMPlugin "1.0" SERVER_MANAGER_XML NexusPeaksReader.xml SERVER_MANAGER_SOURCES vtkNexusPeaksReader.cxx ) -set_target_properties ( MantidParaViewNexusPeaksReaderSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewNexusPeaksReaderSMPlugin QT_VERSION 4) target_link_libraries( MantidParaViewNexusPeaksReaderSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${CORE_MANTIDLIBS} @@ -22,6 +19,6 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewNexusPeaksReaderSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewNexusPeaksReaderSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) +install_pvplugin (MantidParaViewNexusPeaksReaderSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Readers/PeaksReader/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Readers/PeaksReader/CMakeLists.txt index 13103750aa0a19c71b9777d359e3c5f9c369f16f..5d41d63321e57c26049436c73ab874a0c1ef3fd9 100644 --- a/qt/paraview_ext/PVPlugins/Readers/PeaksReader/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Readers/PeaksReader/CMakeLists.txt @@ -4,10 +4,7 @@ add_paraview_plugin( MantidParaViewPeaksReaderSMPlugin "1.0" SERVER_MANAGER_XML PeaksReader.xml SERVER_MANAGER_SOURCES vtkPeaksReader.cxx ) -set_target_properties ( MantidParaViewPeaksReaderSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewPeaksReaderSMPlugin QT_VERSION 4) # Add to the 'VatesParaViewPlugins' group in VS set_property( TARGET MantidParaViewPeaksReaderSMPlugin PROPERTY FOLDER "MantidVatesParaViewPlugins" ) @@ -24,6 +21,6 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewPeaksReaderSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewPeaksReaderSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) +install_pvplugin (MantidParaViewPeaksReaderSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Representations/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Representations/CMakeLists.txt index ee6bca0a62d6d0a4d17e3e780f54c55e3ad18983..1123b78a4af44beebbb2bdefb0d20959dcf92160 100644 --- a/qt/paraview_ext/PVPlugins/Representations/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Representations/CMakeLists.txt @@ -6,9 +6,6 @@ ADD_PARAVIEW_PLUGIN(MantidParaViewRepresentationSMPlugin "1.0" vtkAlignedGeometrySliceRepresentation.cxx AlignedThreeSliceFilter.cxx AlignedCutter.cxx) -set_target_properties ( MantidParaViewRepresentationSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" - ) +set_pvplugin_properties (MantidParaViewRepresentationSMPlugin QT_VERSION 4) install( TARGETS MantidParaViewRepresentationSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR}) diff --git a/qt/paraview_ext/PVPlugins/Sources/MDEWSource/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Sources/MDEWSource/CMakeLists.txt index ca603867a4246b60c3737d35e46f9e12755b48ca..dde772aa9b83c90df90a833dc9b60ec4ac253227 100644 --- a/qt/paraview_ext/PVPlugins/Sources/MDEWSource/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Sources/MDEWSource/CMakeLists.txt @@ -3,10 +3,7 @@ include_directories( SYSTEM ${PARAVIEW_INCLUDE_DIRS} ) ADD_PARAVIEW_PLUGIN(MantidParaViewMDEWSourceSMPlugin "1.0" SERVER_MANAGER_XML MDEWSource.xml SERVER_MANAGER_SOURCES vtkMDEWSource.cxx) -set_target_properties ( MantidParaViewMDEWSourceSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewMDEWSourceSMPlugin QT_VERSION 4) include_directories ( SYSTEM ${QWT5_INCLUDE_DIR} ) target_link_libraries( MantidParaViewMDEWSourceSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} @@ -24,4 +21,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewMDEWSourceSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewMDEWSourceSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) +install_pvplugin (MantidParaViewMDEWSourceSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Sources/MDHWSource/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Sources/MDHWSource/CMakeLists.txt index e7c0baccbb8690a95cb3e0bbfc86a962a8d6a0ca..1cd98e35cd042f20bf6eba67736057cebc41d31e 100644 --- a/qt/paraview_ext/PVPlugins/Sources/MDHWSource/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Sources/MDHWSource/CMakeLists.txt @@ -3,10 +3,8 @@ include_directories( SYSTEM ${PARAVIEW_INCLUDE_DIRS} ) ADD_PARAVIEW_PLUGIN(MantidParaViewMDHWSourceSMPlugin "1.0" SERVER_MANAGER_XML MDHWSource.xml SERVER_MANAGER_SOURCES vtkMDHWSource.cxx) -set_target_properties ( MantidParaViewMDHWSourceSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewMDHWSourceSMPlugin QT_VERSION 4) + include_directories ( SYSTEM ${QWT5_INCLUDE_DIR} ) target_link_libraries( MantidParaViewMDHWSourceSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} @@ -24,4 +22,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewMDHWSourceSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewMDHWSourceSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) +install_pvplugin (MantidParaViewMDHWSourceSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Sources/PeaksSource/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Sources/PeaksSource/CMakeLists.txt index 75ea33d8cacbf715eafbfa50cbbc6c2168781689..f4adb80d4e526f1bac66149e273b4379119fa39f 100644 --- a/qt/paraview_ext/PVPlugins/Sources/PeaksSource/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Sources/PeaksSource/CMakeLists.txt @@ -3,11 +3,9 @@ include_directories( SYSTEM ${PARAVIEW_INCLUDE_DIRS} ) ADD_PARAVIEW_PLUGIN(MantidParaViewPeaksSourceSMPlugin "1.0" SERVER_MANAGER_XML PeaksSource.xml SERVER_MANAGER_SOURCES vtkPeaksSource.cxx) -set_target_properties ( MantidParaViewPeaksSourceSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) -target_link_libraries( MantidParaViewPeaksSourceSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} +set_pvplugin_properties (MantidParaViewPeaksSourceSMPlugin QT_VERSION 4) + +target_link_libraries( MantidParaViewPeaksSourceSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${CORE_MANTIDLIBS} DataObjects VatesAPI @@ -19,4 +17,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewPeaksSourceSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewPeaksSourceSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) +install_pvplugin (MantidParaViewPeaksSourceSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/PVPlugins/Sources/SinglePeakMarkerSource/CMakeLists.txt b/qt/paraview_ext/PVPlugins/Sources/SinglePeakMarkerSource/CMakeLists.txt index 67337b7839db109f58999b2b980ce7320cc3468a..eb0f3a52f02f04111f9c21ea79a8351bf64d2448 100644 --- a/qt/paraview_ext/PVPlugins/Sources/SinglePeakMarkerSource/CMakeLists.txt +++ b/qt/paraview_ext/PVPlugins/Sources/SinglePeakMarkerSource/CMakeLists.txt @@ -3,10 +3,7 @@ include_directories( SYSTEM ${PARAVIEW_INCLUDE_DIRS} ) ADD_PARAVIEW_PLUGIN(MantidParaViewSinglePeakMarkerSourceSMPlugin "1.0" SERVER_MANAGER_XML SinglePeakMarkerSource.xml SERVER_MANAGER_SOURCES vtkSinglePeakMarkerSource.cxx) -set_target_properties ( MantidParaViewSinglePeakMarkerSourceSMPlugin PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${PVPLUGIN_LIBRARY_OUTPUT_DIRECTORY} - FOLDER "MantidVatesParaViewPlugins" -) +set_pvplugin_properties (MantidParaViewSinglePeakMarkerSourceSMPlugin QT_VERSION 4) target_link_libraries( MantidParaViewSinglePeakMarkerSourceSMPlugin LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${CORE_MANTIDLIBS} VatesAPI ) @@ -14,4 +11,4 @@ if (OSX_VERSION VERSION_GREATER 10.8) set_target_properties ( MantidParaViewSinglePeakMarkerSourceSMPlugin PROPERTIES INSTALL_RPATH "@loader_path/../../Contents/Libraries;@loader_path/../../Contents/MacOS") endif () -install( TARGETS MantidParaViewSinglePeakMarkerSourceSMPlugin ${SYSTEM_PACKAGE_TARGET} DESTINATION ${PVPLUGINS_DIR}/${PVPLUGINS_SUBDIR} ) +install_pvplugin (MantidParaViewSinglePeakMarkerSourceSMPlugin QT_VERSION 4) diff --git a/qt/paraview_ext/VatesSimpleGui/QtWidgets/CMakeLists.txt b/qt/paraview_ext/VatesSimpleGui/QtWidgets/CMakeLists.txt index 86f345e177d26d68c046db4e50b2fd0c2b31f2d5..046f21e12bd4f0e7bfca11bf618e9cccbe90cde6 100644 --- a/qt/paraview_ext/VatesSimpleGui/QtWidgets/CMakeLists.txt +++ b/qt/paraview_ext/VatesSimpleGui/QtWidgets/CMakeLists.txt @@ -49,7 +49,7 @@ mtd_add_qt_library (TARGET_NAME VatesSimpleGuiQtWidgets OUTPUT_DIR_BASE ${PLUGINS_LIBRARY_OUTPUT_DIRECTORY} INSTALL_DIR - ${PVPLUGINS_DIR} + ${PLUGINS_DIR}/qtplugins/mantid OSX_INSTALL_RPATH @loader_path/../Contents/Libraries @loader_path/../Contents/MacOS diff --git a/qt/paraview_ext/VatesSimpleGui/ViewWidgets/CMakeLists.txt b/qt/paraview_ext/VatesSimpleGui/ViewWidgets/CMakeLists.txt index 610794c47f949808da7e0adec4b27ee1b307d97d..7f43baf1fc5206e6e31afdf2ebb3b1e15b46a3a1 100644 --- a/qt/paraview_ext/VatesSimpleGui/ViewWidgets/CMakeLists.txt +++ b/qt/paraview_ext/VatesSimpleGui/ViewWidgets/CMakeLists.txt @@ -133,7 +133,7 @@ mtd_add_qt_library (TARGET_NAME VatesSimpleGuiViewWidgets OUTPUT_DIR_BASE ${PLUGINS_LIBRARY_OUTPUT_DIRECTORY} INSTALL_DIR - ${PVPLUGINS_DIR} + ${PLUGINS_DIR}/qtplugins/mantid OSX_INSTALL_RPATH @loader_path/../Contents/MacOS @loader_path/../Contents/Libraries diff --git a/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/VatesParaViewApplication.cpp b/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/VatesParaViewApplication.cpp index b1cd83c72a181568f2018fa98278b49bfba0be2a..3cd0a33790b9da36037975866f5d7331ad86607b 100644 --- a/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/VatesParaViewApplication.cpp +++ b/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/VatesParaViewApplication.cpp @@ -1,5 +1,6 @@ #include "MantidVatesSimpleGuiViewWidgets/VatesParaViewApplication.h" #include "MantidKernel/ConfigService.h" +#include "MantidQtWidgets/Common/PluginLibraries.h" #include "pqPVApplicationCore.h" #include "pqInterfaceTracker.h" @@ -33,12 +34,10 @@ namespace SimpleGui { VatesParaViewApplication::VatesParaViewApplication() : m_logger("VatesParaViewApplication"), m_behaviorsSetup(false) { // Get the plugin path that we set in the ConfigService. - auto &configSvc = Kernel::ConfigService::Instance(); - // This currently points at the top pvplugins directory and not the - // subdirectory. - // Needs tidying up!! - std::string pvPluginPathTop = configSvc.getPVPluginsPath(); - if (pvPluginPathTop.empty()) { + const auto &configSvc = Kernel::ConfigService::Instance(); + const auto pvPluginsPath = + MantidQt::API::qtPluginPathFromCfg("pvplugins.directory"); + if (pvPluginsPath.empty()) { throw std::runtime_error( "pvplugins.directory key not setup.\nVates plugins will not be " "available.\n" @@ -58,9 +57,8 @@ VatesParaViewApplication::VatesParaViewApplication() m_logger.debug("Intialize pqApplicationCore with " + exePath + "\n"); // We need to manually set the PV_PLUGIN_PATH because it's // not going to be picked up from the paraview/vtk side otherwise. - Poco::Path pluginsDir(pvPluginPathTop, "pvplugins"); - m_logger.debug("Setting PV_PLUGIN_PATH=" + pluginsDir.toString() + "\n"); - vtksys::SystemTools::PutEnv("PV_PLUGIN_PATH=" + pluginsDir.toString()); + m_logger.debug("Setting PV_PLUGIN_PATH=" + pvPluginsPath + "\n"); + vtksys::SystemTools::PutEnv("PV_PLUGIN_PATH=" + pvPluginsPath); new pqPVApplicationCore(argc, argv); } diff --git a/qt/widgets/common/CMakeLists.txt b/qt/widgets/common/CMakeLists.txt index c7c934b7bc3c47134dcb1752557f6e29e17c8ced..549b29820566ef32a00243432d5bc167a37e913d 100644 --- a/qt/widgets/common/CMakeLists.txt +++ b/qt/widgets/common/CMakeLists.txt @@ -27,6 +27,7 @@ set ( SRC_FILES src/OptionsPropertyWidget.cpp src/pixmaps.cpp src/PlotAxis.cpp + src/PluginLibraries.cpp src/PropertyWidget.cpp src/PropertyWidgetFactory.cpp src/PythonRunner.cpp @@ -260,6 +261,7 @@ set ( INC_FILES inc/MantidQtWidgets/Common/NonOrthogonal.h inc/MantidQtWidgets/Common/pixmaps.h inc/MantidQtWidgets/Common/PlotAxis.h + inc/MantidQtWidgets/Common/PluginLibraries.h inc/MantidQtWidgets/Common/PropertyWidgetFactory.h inc/MantidQtWidgets/Common/PythonSystemHeader.h inc/MantidQtWidgets/Common/PythonThreading.h diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h new file mode 100644 index 0000000000000000000000000000000000000000..671336f44d27e2f064f8ad583d224870521fcaf5 --- /dev/null +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PluginLibraries.h @@ -0,0 +1,44 @@ +#ifndef MANTIDQT_WIDGETS_COMMON_PLUGINLIBRARIES_H +#define MANTIDQT_WIDGETS_COMMON_PLUGINLIBRARIES_H +/** + Copyright © 2017 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + National Laboratory & European Spallation Source + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + File change history is stored at: <https://github.com/mantidproject/mantid> + Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ + +#include "MantidQtWidgets/Common/DllOption.h" + +#include <string> + +namespace MantidQt { +namespace API { + +EXPORT_OPT_MANTIDQT_COMMON std::string qtPluginPathFromCfg(std::string key); + +/// Load plugins from a path given by the key in the config service +EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromCfgPath(std::string key); + +/// Load plugins from a path +EXPORT_OPT_MANTIDQT_COMMON int loadPluginsFromPath(std::string path); + +} +} + +#endif // PLUGINLIBRARYLOADER_H diff --git a/qt/widgets/common/src/InterfaceManager.cpp b/qt/widgets/common/src/InterfaceManager.cpp index 4d19bb43ebf3ec2f7a9142a90a86f895eccf1fae..97b7c6133b4db4e81c1a50c0d2606d82f317969a 100644 --- a/qt/widgets/common/src/InterfaceManager.cpp +++ b/qt/widgets/common/src/InterfaceManager.cpp @@ -1,29 +1,32 @@ //---------------------------------- // Includes //---------------------------------- -#include <Poco/Environment.h> #include "MantidQtWidgets/Common/InterfaceManager.h" -#include "MantidQtWidgets/Common/InterfaceFactory.h" #include "MantidQtWidgets/Common/AlgorithmDialog.h" +#include "MantidQtWidgets/Common/InterfaceFactory.h" #include "MantidQtWidgets/Common/GenericDialog.h" +#include "MantidQtWidgets/Common/PluginLibraries.h" #include "MantidQtWidgets/Common/UserSubWindow.h" #include "MantidQtWidgets/Common/VatesViewerInterface.h" #include "MantidQtWidgets/Common/MantidHelpInterface.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/LibraryManager.h" -#include "MantidKernel/ConfigService.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/IAlgorithm.h" #include "MantidKernel/Exception.h" +#include <Poco/Environment.h> #include <QStringList> using namespace MantidQt::API; +using Mantid::Kernel::AbstractInstantiator; namespace { // static logger Mantid::Kernel::Logger g_log("InterfaceManager"); + +// Load libraries once +std::once_flag DLLS_LOADED; } // initialise VATES factory @@ -177,25 +180,9 @@ QStringList InterfaceManager::getUserSubWindowKeys() const { /// Default Constructor InterfaceManager::InterfaceManager() { // Attempt to load libraries that may contain custom interface classes - const std::string libpath = - Mantid::Kernel::ConfigService::Instance().getString( - "mantidqt.plugins.directory"); - if (!libpath.empty()) { - // Lazy loading. Avoid loading libraries every time a new instance is - // created. - static bool isLoaded; - if (!isLoaded) { - int nloaded = - Mantid::Kernel::LibraryManager::Instance().OpenAllLibraries(libpath); - if (nloaded == 0) { - g_log.warning() << "Unable to load Qt plugin libraries.\n" - << "Please check that the 'mantidqt.plugins.directory' " - "variable in the .properties file points to " - << "the correct location.\n"; - } - isLoaded = true; - } - } + std::call_once(DLLS_LOADED, []() { + loadPluginsFromCfgPath("mantidqt.plugins.directory"); + }); } /// Destructor diff --git a/qt/widgets/common/src/PluginLibraries.cpp b/qt/widgets/common/src/PluginLibraries.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4f31d59591adaa720da51c5e334f6739a36bddb7 --- /dev/null +++ b/qt/widgets/common/src/PluginLibraries.cpp @@ -0,0 +1,50 @@ +#include "MantidQtWidgets/Common/PluginLibraries.h" +#include "MantidKernel/ConfigService.h" +#include "MantidKernel/LibraryManager.h" +#include "MantidKernel/Strings.h" + +#include <QtGlobal> + +using Mantid::Kernel::ConfigService; +using Mantid::Kernel::LibraryManager; + +namespace MantidQt { +namespace API { + +/** + * Retrieve the path to some qt-related plugins from the mantid configuration + * If the value contains %V then this sequence is replaced with the major + * version of Qt + * @param key The name of a key in the Mantid config + * @return The value of the key + */ +std::string qtPluginPathFromCfg(std::string key) { + static std::string qtMajorVersion; + static std::string qtTag("%V"); + if (qtMajorVersion.empty()) { + qtMajorVersion = std::string(QT_VERSION_STR, 0, 1); + } + using Mantid::Kernel::Strings::replace; + return replace(ConfigService::Instance().getString(key), qtTag, + qtMajorVersion); +} + +/** + * Load all plugins from the path specified by the given configuration key. + * @param key The name of a key in the Mantid config. It's value may contain + * %V to specify the Qt version + * @return The number of libraries successfully loaded + */ +int loadPluginsFromCfgPath(std::string key) { + return loadPluginsFromPath(qtPluginPathFromCfg(key)); +} + +/** + * Load all plugins from the path specified. + * @return The number of libraries successfully loaded + */ +int loadPluginsFromPath(std::string path) { + return LibraryManager::Instance().OpenAllLibraries(path); +} +} +}