From 7d0c3e7bd3da1bfbb9024e2a36a793012e7b53f7 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Tue, 24 Jan 2017 16:22:53 +0100 Subject: [PATCH] add menthod activateViewManagerAndView in SALOME_PYQT, for embedded VTK view in AsterStudy --- src/LightApp/LightApp_Application.cxx | 22 ++++++++++--- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 38 ++++++++++++++++++++++- src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 1 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 1 + src/STD/STD_Application.h | 4 +-- 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 37ca6fd0f..c998c9f13 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1461,19 +1461,31 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c { SUIT_ViewManager* aVM = viewManager( vmType ); SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager(); - + MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM ); if ( anActiveVM && anActiveVM->getType() == vmType ) - aVM = anActiveVM; + { + MESSAGE("aVM = anActiveVM"); + aVM = anActiveVM; + } if ( aVM && create ) { if ( !aVM->getActiveView() ) - aVM->createView(); + { + MESSAGE("aVM->createView()"); + aVM->createView(); + } else - desktop()->setActiveWindow( aVM->getActiveView() ); + { + MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView()); + desktop()->setActiveWindow( aVM->getActiveView() ); + } } else if ( create ) - aVM = createViewManager( vmType ); + { + MESSAGE("aVM = createViewManager( vmType )"); + aVM = createViewManager( vmType ); + } return aVM; } diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 81f274046..53776e264 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -68,6 +68,7 @@ #include #include +#include namespace { /*! @@ -2809,7 +2810,10 @@ public: for ( int i = 0, n = vec.size(); i < n; i++ ) { SUIT_ViewWindow* wnd = vec[ i ]; if ( wnd ) - myResult.append( wnd->getId() ); + { + MESSAGE("SUIT_ViewWindow*: "<< wnd << " id: " << wnd->getId()); + myResult.append( wnd->getId() ); + } } } } @@ -2839,6 +2843,7 @@ public: virtual void Execute() { SUIT_ViewWindow* wnd = getWnd( myWndId ); + MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd); if ( wnd ) { wnd->setFocus(); myResult = true; @@ -2850,6 +2855,37 @@ bool SalomePyQt::activateView( const int id ) return ProcessEvent( new TActivateView( id ) ); } +/*! + * + */ + +class TActivateViewManagerAndView: public SALOME_Event +{ +public: + typedef bool TResult; + TResult myResult; + int myWndId; + TActivateViewManagerAndView( const int id ) + : myResult( false ), + myWndId( id ) {} + virtual void Execute() + { + SUIT_ViewWindow* wnd = getWnd( myWndId ); + MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd); + if ( wnd ) + { + LightApp_Application* app = getApplication(); + app->setActiveViewManager(wnd->getViewManager()); + wnd->setFocus(); + myResult = true; + } + } +}; +bool SalomePyQt::activateViewManagerAndView( const int id ) +{ + return ProcessEvent( new TActivateViewManagerAndView( id ) ); +} + /*! * */ diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index dac525e79..4953dbe7e 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -287,6 +287,7 @@ public: static bool setViewSize( const int, const int, const int = 0 ); static QList findViews( const QString& ); static bool activateView( const int ); + static bool activateViewManagerAndView( const int ); static QWidget* getViewWidget( const int ); static int createView( const QString&, bool visible = true, const int width = 0, const int height = 0 ); static int createView( const QString&, QWidget* ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index cc09d9038..492050d3d 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -404,6 +404,7 @@ public: static bool setViewSize( const int, const int, const int = 0 ) /ReleaseGIL/ ; static QList findViews( const QString& ) /ReleaseGIL/ ; static bool activateView( const int ) /ReleaseGIL/ ; + static bool activateViewManagerAndView( const int ) /ReleaseGIL/ ; static QWidget* getViewWidget( const int ) /ReleaseGIL/ ; static int createView( const QString&, bool visible = true, const int width = 0, const int height = 0 ) /ReleaseGIL/ ; static int createView( const QString&, QWidget* ) /ReleaseGIL/ ; diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 06ad40df9..be2c85389 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -104,6 +104,8 @@ public: virtual void updateDesktopTitle(); + virtual void setActiveViewManager( SUIT_ViewManager* ); + signals: /*!emit that view manager added*/ void viewManagerAdded( SUIT_ViewManager* ); @@ -161,8 +163,6 @@ protected: virtual void beforeCloseDoc( SUIT_Study* theDoc ); virtual void afterCloseDoc(); - virtual void setActiveViewManager( SUIT_ViewManager* ); - virtual int openChoice( const QString& ); virtual bool openAction( const int, const QString& ); -- 2.39.2