From e4ca636fd09c3e9dc4ecb0c210db146d2efc900c Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Fri, 17 Mar 2017 21:03:35 +0100 Subject: [PATCH] try to avoid to add detached viewer on desktop viewer tab --- src/LightApp/LightApp_Application.cxx | 3 ++- src/LightApp/LightApp_Application.h | 2 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 12 +++++++----- src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 2 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 2 +- src/STD/STD_TabDesktop.cxx | 7 +++++++ src/SUIT/SUIT_ViewManager.cxx | 15 ++++++++++++++- src/SUIT/SUIT_ViewManager.h | 3 +++ 8 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 626bbc6b3..9aee3eebe 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1495,7 +1495,7 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c Creates view manager of some type \param vmType - type of view manager */ -SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType ) +SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached ) { SUIT_ResourceMgr* resMgr = resourceMgr(); @@ -1653,6 +1653,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType if ( !viewMgr ) return 0; + viewMgr->setDetached(detached); addViewManager( viewMgr ); SUIT_ViewWindow* viewWin = viewMgr->createViewWindow(); diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 5f98a8794..4d26aef25 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -131,7 +131,7 @@ public: SUIT_ViewManager* getViewManager( const QString&, const bool ); virtual void addViewManager( SUIT_ViewManager* ); virtual void removeViewManager( SUIT_ViewManager* ); - virtual SUIT_ViewManager* createViewManager( const QString& vmType ); + virtual SUIT_ViewManager* createViewManager( const QString& vmType, bool detached = false ); virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w ); virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index f674cbf18..53c374059 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -2961,17 +2961,19 @@ public: bool myVisible; int myWidth; int myHeight; - TCreateView( const QString& theType, bool visible, const int width, const int height ) + bool myDetached; + TCreateView( const QString& theType, bool visible, const int width, const int height, bool detached ) : myResult( -1 ), myType( theType ), myVisible(visible), myWidth(width), - myHeight(height) {} + myHeight(height), + myDetached(detached) {} virtual void Execute() { LightApp_Application* app = getApplication(); if ( app ) { - SUIT_ViewManager* viewMgr = app->createViewManager( myType ); + SUIT_ViewManager* viewMgr = app->createViewManager( myType, myDetached ); if ( viewMgr ) { QWidget* wnd = viewMgr->getActiveView(); myResult = viewMgr->getActiveView()->getId(); @@ -2994,9 +2996,9 @@ public: } } }; -int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height ) +int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height, bool detached ) { - int ret = ProcessEvent( new TCreateView( type, visible, width, height ) ); + int ret = ProcessEvent( new TCreateView( type, visible, width, height, detached ) ); QCoreApplication::processEvents(); return ret; } diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index a5413019f..213d86488 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -290,7 +290,7 @@ public: 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&, bool visible = true, const int width = 0, const int height = 0, bool detached = false ); static int createView( const QString&, QWidget* ); static bool closeView( const int ); static int cloneView( const int ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index a01c11840..637bbd280 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -407,7 +407,7 @@ public: 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&, bool visible = true, const int width = 0, const int height = 0, bool detached = false ) /ReleaseGIL/ ; static int createView( const QString&, QWidget* ) /ReleaseGIL/ ; static bool closeView( const int ) /ReleaseGIL/ ; static int cloneView( const int ) /ReleaseGIL/ ; diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 37766d63d..f41b9aaf1 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -23,6 +23,7 @@ #include "STD_TabDesktop.h" #include +#include #include #include @@ -133,6 +134,12 @@ void STD_TabDesktop::addWindow( QWidget* w ) { if ( !w || !workstack() ) return; + if ( w && w->inherits( "SUIT_ViewWindow" ) ) + { + SUIT_ViewWindow* wid = (SUIT_ViewWindow*)w; + if ( wid->getViewManager()->getDetached() ) + return; + } workstack()->addWindow( w ); } diff --git a/src/SUIT/SUIT_ViewManager.cxx b/src/SUIT/SUIT_ViewManager.cxx index 85d50eb4f..b9e850cdf 100755 --- a/src/SUIT/SUIT_ViewManager.cxx +++ b/src/SUIT/SUIT_ViewManager.cxx @@ -49,7 +49,8 @@ SUIT_ViewManager::SUIT_ViewManager( SUIT_Study* theStudy, : QObject( 0 ), myDesktop( theDesktop ), myTitle( "Default: %M - viewer %V" ), - myStudy( NULL ) + myStudy( NULL ), + myIsDetached( false ) { myViewModel = 0; myActiveView = 0; @@ -398,3 +399,15 @@ void SUIT_ViewManager::contextMenuPopup( QMenu* popup ) if ( vm ) vm->contextMenuPopup( popup ); } + +/*! option detached (false by default) to set before the viewWindow is added to Desktop TabBar */ +void SUIT_ViewManager::setDetached(bool detached) +{ + myIsDetached = detached; +} + +/*! get option detached (false by default) to decide if the viewWindow is to be added to Desktop TabBar */ +bool SUIT_ViewManager::getDetached() const +{ + return myIsDetached; +} diff --git a/src/SUIT/SUIT_ViewManager.h b/src/SUIT/SUIT_ViewManager.h index 1edce5243..767100dee 100755 --- a/src/SUIT/SUIT_ViewManager.h +++ b/src/SUIT/SUIT_ViewManager.h @@ -84,6 +84,8 @@ public: int getId() const; int getGlobalId() const; + void setDetached(bool detached); + bool getDetached() const; public slots: void createView(); @@ -143,6 +145,7 @@ protected: QPixmap myIcon; QString myTitle; SUIT_Study* myStudy; + bool myIsDetached; static QMap _ViewMgrId; }; -- 2.39.2