]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
add menthod activateViewManagerAndView in SALOME_PYQT, for embedded VTK view in Aster...
authorPaul RASCLE <paul.rascle@edf.fr>
Tue, 24 Jan 2017 15:22:53 +0000 (16:22 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Tue, 24 Jan 2017 15:22:53 +0000 (16:22 +0100)
src/LightApp/LightApp_Application.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip
src/STD/STD_Application.h

index 37ca6fd0f769c8d0acde36547ff6f8d4556b7233..c998c9f1344ff775c72f9118bbffb7ec02e2d94e 100644 (file)
@@ -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;
 }
index 81f2740464786e9a8a766344b2510a7b07bacb27..53776e2647da7df232d0ee5c54489fbac5026d4d 100644 (file)
@@ -68,6 +68,7 @@
 #include <QPaintEvent>
 #include <QCoreApplication>
 
+#include <utilities.h>
 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 ) );
+}
+
 /*!
  *
  */
index dac525e79b28b948864505f1722ec692256dfc18..4953dbe7ef7e601f187611e126b8d9ad3d82ac91 100644 (file)
@@ -287,6 +287,7 @@ public:
   static bool              setViewSize( const int, const int, const int = 0 );
   static QList<int>        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* );
index cc09d9038541504151d2f6d863000172003fb55d..492050d3d5baf586ca496000a77037a599ee4bc7 100644 (file)
@@ -404,6 +404,7 @@ public:
   static bool              setViewSize( const int, const int, const int = 0 ) /ReleaseGIL/ ;
   static QList<int>        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/ ;
index 06ad40df96b1b01ed08ecb1276d3b2b5907242db..be2c85389b46ddb2226d6104a1d3663991eefd18 100755 (executable)
@@ -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& );