From cb38710b89d8023fbc95df88834c37260a1414bb Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Mon, 20 Mar 2017 20:47:00 +0100 Subject: [PATCH] PyQt methods for enabling or disabling PyQt_Selector --- .../SALOME_PYQT_ModuleLight.cxx | 16 +++++++ .../SALOME_PYQT_ModuleLight.h | 2 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 44 +++++++++++++++++++ src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 2 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 2 + 5 files changed, 66 insertions(+) diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx index 9e53d0350..29620a41a 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx @@ -656,3 +656,19 @@ void SALOME_PYQT_ModuleLight::setLocalSelected(const QStringList & entries) emit localSelectionChanged(); } +void SALOME_PYQT_ModuleLight::enableSelector() +{ + MESSAGE("enableSelector"); + if (!mySelector) + { + mySelector = new SALOME_PYQT_Selector(this, this->getApp()->selectionMgr()); + } + mySelector->setEnabled(true); +} + +void SALOME_PYQT_ModuleLight::disableSelector() +{ + MESSAGE("disableSelector"); + if (mySelector) + mySelector->setEnabled(false); +} diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h index 02fd4ae3a..8cb5393a9 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.h @@ -98,6 +98,8 @@ public: QStringList getChildren( const QString&, const bool = false ) const; + void enableSelector(); + void disableSelector(); void setLocalSelected(const QStringList &); void getSelected( DataObjectList& ) const; unsigned long getModifiedTime() const; diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 53c374059..4748bde69 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -586,6 +586,50 @@ void SalomePyQt::setSelection( const QStringList& entryList) return ProcessVoidEvent( new TSetSelectionEvent(entryList) ); } +/*! + \fn void SalomePyQt::enableSelector(); + \brief enable PyQt_Selector (on module activation, for instance) +*/ + +class TEnableSelectorEvent: public SALOME_Event +{ +public: + TEnableSelectorEvent() {} + virtual void Execute() + { + SALOME_PYQT_ModuleLight* module = dynamic_cast( getActiveModule() ); + if ( !module ) return; + module->enableSelector(); + } +}; +void SalomePyQt::enableSelector() +{ + return ProcessVoidEvent( new TEnableSelectorEvent() ); +} + + +/*! + \fn void SalomePyQt::disableSelector(); + \brief disable PyQt_Selector (on module activation, for instance) +*/ + +class TdisableSelectorEvent: public SALOME_Event +{ +public: + TdisableSelectorEvent() {} + virtual void Execute() + { + SALOME_PYQT_ModuleLight* module = dynamic_cast( getActiveModule() ); + if ( !module ) return; + module->disableSelector(); + } +}; +void SalomePyQt::disableSelector() +{ + return ProcessVoidEvent( new TdisableSelectorEvent() ); +} + + /*! \fn void SalomePyQt::putInfo( const QString& msg, const int sec ); \brief Put an information message to the current application's diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 213d86488..d31a8600f 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -168,6 +168,8 @@ public: static QMenu* getPopupMenu( const MenuName ); static QMenu* getPopupMenu( const QString& ); static QTreeView* getObjectBrowser(); + static void enableSelector(); + static void disableSelector(); static SALOME_Selection* getSelection(); static void setSelection( const QStringList& ); static int getStudyId(); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 637bbd280..59309bcfd 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -270,6 +270,8 @@ public: static QMenu* getPopupMenu( const MenuName ) /ReleaseGIL/ ; static QMenu* getPopupMenu( const QString& ) /ReleaseGIL/ ; static QTreeView* getObjectBrowser() /ReleaseGIL/ ; + static void enableSelector() /ReleaseGIL/ ; + static void disableSelector() /ReleaseGIL/ ; static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ; static void setSelection( const QStringList& ) /ReleaseGIL/ ; static int getStudyId() /ReleaseGIL/ ; -- 2.39.2