From 727248111900fd31970c68cc66ff3c609b68e49d Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 13 Nov 2018 11:28:52 +0300 Subject: [PATCH] Python API: add function to get list of all components in the current GUI session --- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 30 +++++++++++++++++++++++ src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 1 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 1 + 3 files changed, 32 insertions(+) diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 7466927b9..c99438ab9 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -813,6 +813,36 @@ void SalomePyQt::hideNotification( const int id ) ProcessVoidEvent( new THideNotifyEvent( id ) ); } +/*! + \fn QStringList SalomePyQt::getComponents(); + \brief Get all modules used in current GUI session. + \return List of modules +*/ + +class TGetComponentsEvent: public SALOME_Event +{ +public: + typedef QStringList TResult; + TResult myResult; + TGetComponentsEvent() {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) + { + QStringList titles; + anApp->modules( titles, false ); + foreach ( QString title, titles ) + { + myResult << anApp->moduleName( title ); + } + } + } +}; +QStringList SalomePyQt::getComponents() +{ + return ProcessEvent( new TGetComponentsEvent() ); +} + /*! \fn const QString SalomePyQt::getActiveComponent(); \brief Get the currently active module name (for the current study). diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 843e639d8..0e463d0ff 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -188,6 +188,7 @@ public: static void enableSelector(); static void disableSelector(); static SALOME_Selection* getSelection(); + static QStringList getComponents(); static void setSelection( const QStringList& ); static const QString getActiveComponent(); static PyObject* getActivePythonModule(); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 42d7f574b..2dd132ac2 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -300,6 +300,7 @@ public: static void disableSelector() /ReleaseGIL/ ; static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ; static void setSelection( const QStringList& ) /ReleaseGIL/ ; + static QStringList getComponents() /ReleaseGIL/ ; static const QString getActiveComponent() /ReleaseGIL/ ; static SIP_PYOBJECT getActivePythonModule() /ReleaseGIL/ ; static bool activateModule( const QString& ) /ReleaseGIL/ ; -- 2.30.2