diff --git a/CMake/smtkConfig.cmake.in b/CMake/smtkConfig.cmake.in index 66ab5a58d889031c132a536399257b4a8307dcb7..c11ddf6d4d4184b3a0d9ae1c98a2a74ef7526e08 100644 --- a/CMake/smtkConfig.cmake.in +++ b/CMake/smtkConfig.cmake.in @@ -162,9 +162,13 @@ endif () # Now include the ParaView-specific targets and information. if (SMTK_ENABLE_PARAVIEW_SUPPORT) - include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionPlugins-smtk_paraview_extension_plugin-targets-depends.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionPlugins-targets.cmake") - include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionPlugins-paraview-plugin-properties.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionCorePlugins-smtk_paraview_extension_core_plugins-targets-depends.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionCorePlugins-targets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionCorePlugins-paraview-plugin-properties.cmake") + + include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionGuiPlugins-smtk_paraview_extension_gui_plugins-targets-depends.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionGuiPlugins-targets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewExtensionGuiPlugins-paraview-plugin-properties.cmake") include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewPlugins-smtk_paraview_plugins-targets-depends.cmake") include("${CMAKE_CURRENT_LIST_DIR}/SMTKParaViewPlugins-targets.cmake") diff --git a/doc/release/notes/paraview-plugin-reorg.rst b/doc/release/notes/paraview-plugin-reorg.rst new file mode 100644 index 0000000000000000000000000000000000000000..09ca6e8ac39042f8a89991b3525d74797bb039eb --- /dev/null +++ b/doc/release/notes/paraview-plugin-reorg.rst @@ -0,0 +1,15 @@ +ParaView plugins reorganized +---------------------------- + +SMTK's ParaView plugins have been reorganized into ++ a subset (``core``) which, while they may register new UI elements, + do not introduce persistent user interface elements (panels, menus, + toolbars) to ParaView's default interface. ++ a subset (``gui``) which do register new user interface elements + that appear in ParaView-based applications by default. + +This also involves splitting the auto-start class into two classes, +one for each set of plugins. + +Going forward, if you add a plugin (or new functionality to an existing +plugin) please ensure you choose the correct target. diff --git a/smtk/extension/paraview/CMakeLists.txt b/smtk/extension/paraview/CMakeLists.txt index 18d16baffc8a61f2fea342d1c289ab103d1f33d6..3da67e4c6983d1df3c1a5cd72fddf3aeda186d9d 100644 --- a/smtk/extension/paraview/CMakeLists.txt +++ b/smtk/extension/paraview/CMakeLists.txt @@ -34,25 +34,29 @@ vtk_module_build( HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${SMTK_VERSION}" TEST_DIRECTORY_NAME "NONE") -set(plugin_files - server/plugin/paraview.plugin) +set(core_plugin_files + server/plugin/paraview.plugin +) +set(gui_plugin_files) if (TARGET ParaView::pqApplicationComponents) - list(APPEND plugin_files - appcomponents/plugin-panel-defaults/paraview.plugin - appcomponents/plugin-legacy-operations/paraview.plugin - appcomponents/plugin-operations-panel/paraview.plugin + list(APPEND core_plugin_files appcomponents/plugin-core/paraview.plugin - appcomponents/plugin-grouping/paraview.plugin - appcomponents/plugin-gui/paraview.plugin appcomponents/plugin-readers/paraview.plugin mesh/plugin/paraview.plugin model/plugin/paraview.plugin project/plugin-core/paraview.plugin + ) + list(APPEND gui_plugin_files + appcomponents/plugin-panel-defaults/paraview.plugin + appcomponents/plugin-legacy-operations/paraview.plugin + appcomponents/plugin-operations-panel/paraview.plugin + appcomponents/plugin-grouping/paraview.plugin + appcomponents/plugin-gui/paraview.plugin project/plugin-gui/paraview.plugin ) if (ParaView_VERSION VERSION_GREATER_EQUAL "5.10.0") - list(APPEND plugin_files + list(APPEND core_plugin_files widgets/plugin/paraview.plugin operators/plugin/paraview.plugin ) @@ -65,20 +69,36 @@ if (TARGET ParaView::pqApplicationComponents) endif () paraview_plugin_scan( - PLUGIN_FILES ${plugin_files} - PROVIDES_PLUGINS paraview_plugins + PLUGIN_FILES ${core_plugin_files} + PROVIDES_PLUGINS core_paraview_plugins + ENABLE_BY_DEFAULT ON + HIDE_PLUGINS_FROM_CACHE ON) +paraview_plugin_build( + HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${SMTK_VERSION}" + LIBRARY_SUBDIRECTORY "${PROJECT_NAME}-${SMTK_VERSION}" + PLUGINS ${core_paraview_plugins} + AUTOLOAD ${core_paraview_plugins} + PLUGINS_FILE_NAME "smtk.extensions.core.xml" + TARGET smtk_paraview_extension_core_plugins + CMAKE_DESTINATION ${SMTK_INSTALL_CONFIG_DIR} + ADD_INSTALL_RPATHS ON + INSTALL_EXPORT SMTKParaViewExtensionCorePlugins) + + paraview_plugin_scan( + PLUGIN_FILES ${gui_plugin_files} + PROVIDES_PLUGINS gui_paraview_plugins ENABLE_BY_DEFAULT ON HIDE_PLUGINS_FROM_CACHE ON) paraview_plugin_build( HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${SMTK_VERSION}" LIBRARY_SUBDIRECTORY "${PROJECT_NAME}-${SMTK_VERSION}" - PLUGINS ${paraview_plugins} - AUTOLOAD ${paraview_plugins} - PLUGINS_FILE_NAME "smtk.extensions.xml" - TARGET smtk_paraview_extension_plugin + PLUGINS ${gui_paraview_plugins} + AUTOLOAD ${gui_paraview_plugins} + PLUGINS_FILE_NAME "smtk.extensions.gui.xml" + TARGET smtk_paraview_extension_gui_plugins CMAKE_DESTINATION ${SMTK_INSTALL_CONFIG_DIR} ADD_INSTALL_RPATHS ON - INSTALL_EXPORT SMTKParaViewExtensionPlugins) + INSTALL_EXPORT SMTKParaViewExtensionGuiPlugins) if (SMTK_ENABLE_PYTHON_WRAPPING) add_subdirectory(pybind11) diff --git a/smtk/extension/paraview/appcomponents/CMakeLists.txt b/smtk/extension/paraview/appcomponents/CMakeLists.txt index 3a38f1e09d83554147fd9bf690ddd5e67b629d3e..2eb8b23a3172afbddf4d39d0a522847202cd3ee5 100644 --- a/smtk/extension/paraview/appcomponents/CMakeLists.txt +++ b/smtk/extension/paraview/appcomponents/CMakeLists.txt @@ -16,6 +16,7 @@ set(classes pqSMTKResourceRepresentation pqSMTKWrapper pqSMTKAppComponentsAutoStart + pqSMTKGuiAppComponentsAutoStart pqSMTKCallObserversOnMainThreadBehavior pqSMTKCloseResourceBehavior pqSMTKGroupComponentsBehavior diff --git a/smtk/extension/paraview/appcomponents/plugin-gui/CMakeLists.txt b/smtk/extension/paraview/appcomponents/plugin-gui/CMakeLists.txt index db67744587e908ff86a83ee61bf5e5892fce69e2..78cbfd75a17289a4943f70ea0be4d3db8170bd25 100644 --- a/smtk/extension/paraview/appcomponents/plugin-gui/CMakeLists.txt +++ b/smtk/extension/paraview/appcomponents/plugin-gui/CMakeLists.txt @@ -1,5 +1,10 @@ set(sources) +paraview_plugin_add_auto_start( + CLASS_NAME pqSMTKGuiAppComponentsAutoStart + INTERFACES auto_start_interfaces + SOURCES auto_start_sources) + paraview_plugin_add_action_group( CLASS_NAME pqSMTKSelectionFilterBehavior GROUP_NAME "ToolBar/SMTK Selection Filters" @@ -22,6 +27,7 @@ paraview_plugin_add_dock_window( SOURCES resource_dock_sources) set(interfaces + ${auto_start_interfaces} ${action_group_interfaces} ${toolbar_interfaces} ${proxy_interfaces} @@ -29,6 +35,7 @@ set(interfaces ${resource_dock_interfaces} ) list(APPEND sources + ${auto_start_sources} ${action_group_sources} ${toolbar_sources} ${proxy_sources} diff --git a/smtk/extension/paraview/appcomponents/pqSMTKAppComponentsAutoStart.cxx b/smtk/extension/paraview/appcomponents/pqSMTKAppComponentsAutoStart.cxx index 68c11ffc0a5f5c9dd0b9e96b677b595b983b5244..d4b8435036a24ec759a2f8f9d4126700180370a5 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKAppComponentsAutoStart.cxx +++ b/smtk/extension/paraview/appcomponents/pqSMTKAppComponentsAutoStart.cxx @@ -13,17 +13,13 @@ #include "smtk/extension/paraview/appcomponents/pqSMTKBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKCallObserversOnMainThreadBehavior.h" -#include "smtk/extension/paraview/appcomponents/pqSMTKCloseResourceBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKCloseWithActiveOperationBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKDisplayAttributeOnLoadBehavior.h" -#include "smtk/extension/paraview/appcomponents/pqSMTKImportIntoResourceBehavior.h" -#include "smtk/extension/paraview/appcomponents/pqSMTKNewResourceBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKOperationHintsBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKPipelineSelectionBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKRegisterImportersBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKRenderResourceBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKSaveOnCloseResourceBehavior.h" -#include "smtk/extension/paraview/appcomponents/pqSMTKSaveResourceBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKWrapper.h" #include "smtk/extension/paraview/appcomponents/pqToolboxEventPlayer.h" #include "smtk/extension/paraview/appcomponents/pqToolboxEventTranslator.h" @@ -31,8 +27,6 @@ #include "smtk/extension/paraview/server/vtkSMSMTKWrapperProxy.h" #ifdef SMTK_PYTHON_ENABLED -#include "smtk/extension/paraview/appcomponents/pqSMTKExportSimulationBehavior.h" -#include "smtk/extension/paraview/appcomponents/pqSMTKImportOperationBehavior.h" #include "smtk/extension/paraview/appcomponents/pqSMTKPythonTrace.h" #endif @@ -101,23 +95,9 @@ void pqSMTKAppComponentsAutoStart::startup() auto* behavior = pqSMTKBehavior::instance(this); auto* renderResourceBehavior = pqSMTKRenderResourceBehavior::instance(this); - auto* closeResourceBehavior = pqSMTKCloseResourceBehavior::instance(this); auto* callObserversOnMainThread = pqSMTKCallObserversOnMainThreadBehavior::instance(this); -#ifdef SMTK_PYTHON_ENABLED - auto* rsrcImportOpMgr = pqSMTKImportOperationBehavior::instance(this); - auto* rsrcExportSimMgr = pqSMTKExportSimulationBehavior::instance(this); -#endif auto* pipelineSync = pqSMTKPipelineSelectionBehavior::instance(this); auto* displayOnLoad = pqSMTKDisplayAttributeOnLoadBehavior::instance(this); - - // The "New Resource" menu item keys off of the "Save Resource" menu item, - // so the order of initialization for the following two global statics is - // important! - // - // TODO: There must be a better way to do this. - auto* rsrcSaveMgr = pqSMTKSaveResourceBehavior::instance(this); - auto* rsrcNewMgr = pqSMTKNewResourceBehavior::instance(this); - auto* rsrcImportIntoMgr = pqSMTKImportIntoResourceBehavior::instance(this); auto* registerImportersBehavior = pqSMTKRegisterImportersBehavior::instance(this); auto* mainWindow = pqCoreUtilities::mainWidget(); @@ -139,14 +119,6 @@ void pqSMTKAppComponentsAutoStart::startup() pqCore->registerManager("smtk close with active operation", closeWithActiveOperationBehavior); } pqCore->registerManager("call observers on main thread", callObserversOnMainThread); - pqCore->registerManager("smtk close resource", closeResourceBehavior); -#ifdef SMTK_PYTHON_ENABLED - pqCore->registerManager("smtk import operation", rsrcImportOpMgr); - pqCore->registerManager("smtk export simulation", rsrcExportSimMgr); -#endif - pqCore->registerManager("smtk save resource", rsrcSaveMgr); - pqCore->registerManager("smtk new resource", rsrcNewMgr); - pqCore->registerManager("smtk import into resource", rsrcImportIntoMgr); pqCore->registerManager("smtk register importers", registerImportersBehavior); pqCore->registerManager("smtk pipeline selection sync", pipelineSync); pqCore->registerManager("smtk display attribute on load", displayOnLoad); @@ -203,14 +175,6 @@ void pqSMTKAppComponentsAutoStart::shutdown() pqCore->unRegisterManager("smtk close with active operation"); } pqCore->unRegisterManager("call observers on main thread"); - pqCore->unRegisterManager("smtk close resource"); -#ifdef SMTK_PYTHON_ENABLED - pqCore->unRegisterManager("smtk import operation"); - pqCore->unRegisterManager("smtk export simulation"); -#endif - pqCore->unRegisterManager("smtk save resource"); - pqCore->unRegisterManager("smtk new resource"); - pqCore->unRegisterManager("smtk import into resource"); pqCore->unRegisterManager("smtk register importers"); pqCore->unRegisterManager("smtk pipeline selection sync"); pqCore->unRegisterManager("smtk display attribute on load"); diff --git a/smtk/extension/paraview/appcomponents/pqSMTKGuiAppComponentsAutoStart.cxx b/smtk/extension/paraview/appcomponents/pqSMTKGuiAppComponentsAutoStart.cxx new file mode 100644 index 0000000000000000000000000000000000000000..97be9ff86f3f72e3b5ba5fa44f6d0b8d55fa12ec --- /dev/null +++ b/smtk/extension/paraview/appcomponents/pqSMTKGuiAppComponentsAutoStart.cxx @@ -0,0 +1,74 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// 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 notice for more information. +//========================================================================= +#include "smtk/extension/paraview/appcomponents/pqSMTKGuiAppComponentsAutoStart.h" + +#include "smtk/extension/paraview/appcomponents/pqSMTKCloseResourceBehavior.h" +#include "smtk/extension/paraview/appcomponents/pqSMTKImportIntoResourceBehavior.h" +#include "smtk/extension/paraview/appcomponents/pqSMTKNewResourceBehavior.h" +#include "smtk/extension/paraview/appcomponents/pqSMTKSaveResourceBehavior.h" +#ifdef SMTK_PYTHON_ENABLED +#include "smtk/extension/paraview/appcomponents/pqSMTKExportSimulationBehavior.h" +#include "smtk/extension/paraview/appcomponents/pqSMTKImportOperationBehavior.h" +#endif + +#include + +pqSMTKGuiAppComponentsAutoStart::pqSMTKGuiAppComponentsAutoStart(QObject* parent) + : QObject(parent) +{ + // Does nothing +} + +void pqSMTKGuiAppComponentsAutoStart::startup() +{ + auto* closeResourceBehavior = pqSMTKCloseResourceBehavior::instance(this); +#ifdef SMTK_PYTHON_ENABLED + auto* rsrcImportOpMgr = pqSMTKImportOperationBehavior::instance(this); + auto* rsrcExportSimMgr = pqSMTKExportSimulationBehavior::instance(this); +#endif + + // The "New Resource" menu item keys off of the "Save Resource" menu item, + // so the order of initialization for the following two global statics is + // important! + // + // TODO: There must be a better way to do this. + auto* rsrcSaveMgr = pqSMTKSaveResourceBehavior::instance(this); + auto* rsrcNewMgr = pqSMTKNewResourceBehavior::instance(this); + auto* rsrcImportIntoMgr = pqSMTKImportIntoResourceBehavior::instance(this); + + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + pqCore->registerManager("smtk close resource", closeResourceBehavior); +#ifdef SMTK_PYTHON_ENABLED + pqCore->registerManager("smtk import operation", rsrcImportOpMgr); + pqCore->registerManager("smtk export simulation", rsrcExportSimMgr); +#endif + pqCore->registerManager("smtk save resource", rsrcSaveMgr); + pqCore->registerManager("smtk new resource", rsrcNewMgr); + pqCore->registerManager("smtk import into resource", rsrcImportIntoMgr); + } +} + +void pqSMTKGuiAppComponentsAutoStart::shutdown() +{ + auto* pqCore = pqApplicationCore::instance(); + if (pqCore) + { + pqCore->unRegisterManager("smtk close resource"); +#ifdef SMTK_PYTHON_ENABLED + pqCore->unRegisterManager("smtk import operation"); + pqCore->unRegisterManager("smtk export simulation"); +#endif + pqCore->unRegisterManager("smtk save resource"); + pqCore->unRegisterManager("smtk new resource"); + pqCore->unRegisterManager("smtk import into resource"); + } +} diff --git a/smtk/extension/paraview/appcomponents/pqSMTKGuiAppComponentsAutoStart.h b/smtk/extension/paraview/appcomponents/pqSMTKGuiAppComponentsAutoStart.h new file mode 100644 index 0000000000000000000000000000000000000000..722227ade27f0ed4cecc16ee288f5aea5c35b89a --- /dev/null +++ b/smtk/extension/paraview/appcomponents/pqSMTKGuiAppComponentsAutoStart.h @@ -0,0 +1,37 @@ +//========================================================================= +// Copyright (c) Kitware, Inc. +// 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 notice for more information. +//========================================================================= +#ifndef smtk_extension_paraview_appcomponents_pqSMTKGuiAppComponentsAutoStart_h +#define smtk_extension_paraview_appcomponents_pqSMTKGuiAppComponentsAutoStart_h + +#include "smtk/extension/paraview/appcomponents/smtkPQComponentsExtModule.h" + +#include "smtk/extension/paraview/appcomponents/pqQtKeywordWrapping.h" + +#include + +class pqSMTKWrapper; +class pqServer; +class vtkSMProxy; + +class SMTKPQCOMPONENTSEXT_EXPORT pqSMTKGuiAppComponentsAutoStart : public QObject +{ + Q_OBJECT +public: + pqSMTKGuiAppComponentsAutoStart(QObject* parent = nullptr); + ~pqSMTKGuiAppComponentsAutoStart() override = default; + + void startup(); + void shutdown(); + +private: + Q_DISABLE_COPY(pqSMTKGuiAppComponentsAutoStart); +}; + +#endif diff --git a/smtk/extension/paraview/appcomponents/pqSMTKNewResourceBehavior.cxx b/smtk/extension/paraview/appcomponents/pqSMTKNewResourceBehavior.cxx index d8464325514e87ba6ada593c25f7a0ba90c9f107..6267dfaff4699711020c1fe47751451a9c4d4782 100644 --- a/smtk/extension/paraview/appcomponents/pqSMTKNewResourceBehavior.cxx +++ b/smtk/extension/paraview/appcomponents/pqSMTKNewResourceBehavior.cxx @@ -350,10 +350,17 @@ pqSMTKNewResourceBehavior::~pqSMTKNewResourceBehavior() if (g_instance == this) { pqServer* server = pqActiveObjects::instance().activeServer(); - pqSMTKWrapper* wrapper = pqSMTKBehavior::instance()->resourceManagerForServer(server); - if (wrapper != nullptr) + if (server) { - wrapper->smtkOperationManager()->groupObservers().erase(m_key); + pqSMTKWrapper* wrapper = pqSMTKBehavior::instance()->resourceManagerForServer(server); + if (wrapper != nullptr) + { + auto opMgr = wrapper->smtkOperationManager(); + if (opMgr) + { + opMgr->groupObservers().erase(m_key); + } + } } g_instance = nullptr;