Salome HOME
Python API: add function to get list of all components in the current GUI session
authorvsr <vsr@opencascade.com>
Tue, 13 Nov 2018 08:28:52 +0000 (11:28 +0300)
committervsr <vsr@opencascade.com>
Tue, 13 Nov 2018 08:28:52 +0000 (11:28 +0300)
src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip

index 7466927b9ed60e1d329c2d4e4ddfb7d596ecc802..c99438ab9cc359b97d9e11a1029365c4169e8a8f 100644 (file)
@@ -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).
index 843e639d8c4cf69ba4bddb50191c0784f1f3a971..0e463d0ff29b855a84b0cd9bc01512a8b23a6460 100644 (file)
@@ -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();
index 42d7f574b775b715df038804dfe72f2a99c483b3..2dd132ac22b4f2ba048a202c2950226ea0bcf18a 100644 (file)
@@ -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/ ;