From 0d96f93bfd75f84194460bdcb8ee55c37cbee081 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 4 Sep 2013 13:13:27 +0000 Subject: [PATCH] Improvements for HYDRO module: 1. General mechanism for activation of GUI Geometry operations. 2. Plugins mechanism in Geometry module. --- src/CAM/CAM_Application.cxx | 65 +++++++++++++++++++++++++++++++++++-- src/CAM/CAM_Application.h | 5 +++ src/CAM/CAM_Module.cxx | 31 ++++++++++++++++++ src/CAM/CAM_Module.h | 4 +++ 4 files changed, 103 insertions(+), 2 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 8ad3c0119..cfad9e9cd 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include "CAM_Application.h" @@ -44,6 +43,7 @@ #endif #include +#include namespace { @@ -384,7 +384,7 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show */ bool CAM_Application::activateModule( const QString& modName ) { - if ( !modName.isEmpty() && !activeStudy() || myBlocked ) + if ( (!modName.isEmpty() && !activeStudy()) || myBlocked ) return false; // VSR 25/10/2011: prevent nested activation/deactivation @@ -457,6 +457,67 @@ bool CAM_Application::activateModule( CAM_Module* mod ) return true; } +/*! + \brief Load module \a modName and activate its operation, corresponding to \a actionId. + This method is dedicated to run operations of some module from any other module. + \param modName module name + \param actionId is a numerical unique operation identifier + \return \c true in case of success and \c false otherwise +*/ +bool CAM_Application::activateOperation( const QString& modName, int actionId ) +{ + if (isModuleAccessible(modName)) { + CAM_Module* mod = loadModule(modName, false); + if (mod) { + addModule(mod); + return mod->activateOperation(actionId); + } + } + return false; +} + +/*! + \brief Load module \a modName and activate its operation, corresponding to \a actionId. + This method is dedicated to run operations of some module from any other module. + \param modName module name + \param actionId is a string unique operation identifier + \return \c true in case of success and \c false otherwise +*/ +bool CAM_Application::activateOperation( const QString& modName, const QString& actionId ) +{ + if (isModuleAccessible(modName)) { + CAM_Module* mod = loadModule(modName, false); + if (mod) { + addModule(mod); + return mod->activateOperation(actionId); + } + } + return false; +} + +/*! + \brief Load module \a modName and activate its operation, + corresponding to \a actionId and \a pluginName. + This method is dedicated to run operations of some module from any other module. + \param modName module name + \param actionId is a string unique operation identifier + \param pluginName is a name of a plugin where the operation is implemented + \return \c true in case of success and \c false otherwise +*/ +bool CAM_Application::activateOperation( const QString& modName, + const QString& actionId, + const QString& pluginName ) +{ + if (isModuleAccessible(modName)) { + CAM_Module* mod = loadModule(modName, false); + if (mod) { + addModule(mod); + return mod->activateOperation(actionId, pluginName); + } + } + return false; +} + /*! \brief Create new study. \return study object pointer diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index 147723812..045aacd7c 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -64,6 +64,11 @@ public: virtual bool activateModule( const QString& ); + bool activateOperation( const QString& modName, int actionId ); + bool activateOperation( const QString& modName, const QString& actionId ); + bool activateOperation( const QString& modName, const QString& actionId, + const QString& pluginName ); + virtual void contextMenuPopup( const QString&, QMenu*, QString& ); static QString moduleName( const QString& ); diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index e24b70a2d..aa45c36c1 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -1046,6 +1046,37 @@ void CAM_Module::updateModuleVisibilityState() { } +/*! + \brief Activate GUI operation of module by its ID. + This method is called from CAM_Application::startOperation(). + \param actionId is a numerical unique operation id. +*/ +bool CAM_Module::activateOperation( int actionId ) +{ + return false; +} + +/*! + \brief Activate GUI operation of module by its ID. + This method is called from CAM_Application::startOperation(). + \param actionId is a string unique operation id. +*/ +bool CAM_Module::activateOperation( const QString& actionId ) +{ + return false; +} + +/*! + \brief Activate GUI operation of module by its ID and \a pluginName. + This method is called from CAM_Application::startOperation(). + \param actionId is a string unique operation id. + \param pluginName is a name of a plugin where the operation is implemented. +*/ +bool CAM_Module::activateOperation( const QString& actionId, const QString& pluginName ) +{ + return false; +} + /*! \brief Connect data model of the module to the active study diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index 138bb5da8..ae5f6f391 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -83,6 +83,10 @@ public: virtual void updateModuleVisibilityState(); + virtual bool activateOperation( int actionId ); + virtual bool activateOperation( const QString& actionId ); + virtual bool activateOperation( const QString& actionId, const QString& pluginName ); + // actions/menu/toolbars management QtxActionMenuMgr* menuMgr() const; -- 2.39.2