Salome HOME
try to avoid to add detached viewer on desktop viewer tab
authorPaul RASCLE <paul.rascle@edf.fr>
Fri, 17 Mar 2017 20:03:35 +0000 (21:03 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Fri, 17 Mar 2017 20:03:35 +0000 (21:03 +0100)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip
src/STD/STD_TabDesktop.cxx
src/SUIT/SUIT_ViewManager.cxx
src/SUIT/SUIT_ViewManager.h

index 626bbc6b3559b1de3df12a529218f8e836a494f5..9aee3eebe7872746afec3282da25038bd6146a30 100644 (file)
@@ -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();
 
index 5f98a8794e378ca63ffad2add20e228cf3c9c1d4..4d26aef25136332b08dce9e20443b3e313f4af2a 100644 (file)
@@ -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* );
 
index f674cbf1890f45234e027cd8dd92f75a95976c00..53c3740594586c69b32992a8aeb21678299de29a 100644 (file)
@@ -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;
 }
index a5413019fabced06b83ed60e98ce0866aebfa9dc..213d864887c8ab8249acfa1dbacbb43cae10d0b2 100644 (file)
@@ -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 );
index a01c11840039498faeac65312de6d38996c640c9..637bbd28029620fa3b83225c243556461f171f9b 100644 (file)
@@ -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/ ;
index 37766d63ddc559b286710df09b9f4a13e71c0c2f..f41b9aaf1d21d5dcf503bf2d4dc9151e835cac42 100644 (file)
@@ -23,6 +23,7 @@
 #include "STD_TabDesktop.h"
 
 #include <SUIT_Session.h>
+#include <SUIT_ViewManager.h>
 #include <SUIT_ViewWindow.h>
 #include <SUIT_ResourceMgr.h>
 
@@ -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 );
 }
index 85d50eb4f974ff962183e5b1b02eb3e80a643e55..b9e850cdf61d6c8a9d1ba6a0b7343b6f5d383d61 100755 (executable)
@@ -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;
+}
index 1edce5243b26b17cc25f1b23c8d91ff9b0331300..767100dee72c38cec1d7e168759ab8fee619c596 100755 (executable)
@@ -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<QString, int>   _ViewMgrId;
 };