From: vsr Date: Mon, 7 Nov 2011 14:41:21 +0000 (+0000) Subject: Merge from BR_PPGP_Dev branch (07/11/2011) X-Git-Tag: RELIQUAT_6x_15112011~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=83fdd2ba8425e3cbc26e15d989d990ea4e25454e;p=modules%2Fgui.git Merge from BR_PPGP_Dev branch (07/11/2011) --- diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 023840207..3429ec9b8 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -519,6 +519,56 @@ const QString SalomePyQt::getActiveComponent() return ProcessEvent( new TGetActiveComponentEvent() ); } +/*! + \fn PyObject* SalomePyQt::getActivePythonModule() + \brief Access to Python module object currently loaded into SALOME_PYQT_ModuleLight container. + \return Python module object currently loaded into SALOME_PYQT_ModuleLight container +*/ + +class TGetActivePyModuleEvent: public SALOME_Event +{ +public: + typedef PyObject* TResult; + TResult myResult; + TGetActivePyModuleEvent() : myResult( 0 ) {} + virtual void Execute() + { + SALOME_PYQT_ModuleLight* module = getActiveModule(); + if ( module ) + myResult = (PyObject*)module->getPythonModule(); + } +}; +PyObject* SalomePyQt::getActivePythonModule() +{ + return ProcessEvent( new TGetActivePyModuleEvent() ); +} + +/*! + \fn bool SalomePyQt::activateModule( const QString& modName ) + \brief Activates SALOME module with the given name + \return True if the module has been activated and False otherwise. +*/ + +class TActivateModuleEvent: public SALOME_Event +{ +public: + typedef bool TResult; + TResult myResult; + QString myModuleName; + TActivateModuleEvent( const QString& modName ) + : myResult( false ), myModuleName( modName ) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + myResult = anApp->activateModule( myModuleName ); + } + } +}; +bool SalomePyQt::activateModule( const QString& modName ) +{ + return ProcessEvent( new TActivateModuleEvent( modName ) ); +} + /*! \brief Update an Object Browser of the specified (by identifier) study. diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 41ca60456..5114bb024 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -26,6 +26,8 @@ #ifndef SALOME_PYQT_H #define SALOME_PYQT_H +#include + #include #include #include @@ -127,6 +129,8 @@ public: static int getStudyId(); static void putInfo( const QString&, const int = 0 ); static const QString getActiveComponent(); + static PyObject* getActivePythonModule(); + static bool activateModule( const QString& ); static void updateObjBrowser( const int = 0, bool = true ); static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index ad092f66a..9b7c7b1f5 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -213,6 +213,8 @@ public: static int getStudyId() /ReleaseGIL/ ; static void putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ; static const QString getActiveComponent() /ReleaseGIL/ ; + static SIP_PYOBJECT getActivePythonModule() /ReleaseGIL/ ; + static bool activateModule( const QString& ) /ReleaseGIL/ ; static void updateObjBrowser( const int = 0, bool = true ) /ReleaseGIL/ ; static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ;