From 73e9b10646d6e93e539e17d6d2d4ce5790d98800 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 29 Sep 2020 14:03:15 +0300 Subject: [PATCH] Add method to Python API (SalomePyQt) to register module in the study tree --- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 22 ++++++++++++++++++++++ src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 1 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 1 + 3 files changed, 24 insertions(+) diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 45deaf352..04b9bece8 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -942,6 +942,28 @@ bool SalomePyQt::activateModule( const QString& modName ) return ProcessEvent( new TActivateModuleEvent( modName ) ); } +/*! + \fn void SalomePyQt::registerModule( const QString& modName); + \brief Registers module in the study tree +*/ + +void SalomePyQt::registerModule( const QString& modName) +{ + class TEvent: public SALOME_Event + { + QString myName; + public: + TEvent(const QString& name): myName(name) {} + virtual void Execute() + { + if ( LightApp_Application* anApp = getApplication() ) { + anApp->desktop()->emitMessage(QString("register_module_in_study/%1").arg(myName)); + } + } + }; + ProcessVoidEvent( new TEvent(modName) ); +} + /*! \brief Update an Object Browser of the study. */ diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 89f312ab0..34089b95b 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -196,6 +196,7 @@ public: static const QString getActiveComponent(); static PyObject* getActivePythonModule(); static bool activateModule( const QString& ); + static void registerModule( const QString& ); static void updateObjBrowser(); static void putInfo( const QString&, const int = 0 ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index f78e4e409..ed20aafac 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -307,6 +307,7 @@ public: static const QString getActiveComponent() /ReleaseGIL/ ; static SIP_PYOBJECT getActivePythonModule() /ReleaseGIL/ ; static bool activateModule( const QString& ) /ReleaseGIL/ ; + static void registerModule( const QString& ) /ReleaseGIL/ ; static void updateObjBrowser() /ReleaseGIL/ ; static void putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ; -- 2.30.2