]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To avoid run-time OpenGL inititalization errors
authorapo <apo@opencascade.com>
Tue, 6 Sep 2005 06:40:18 +0000 (06:40 +0000)
committerapo <apo@opencascade.com>
Tue, 6 Sep 2005 06:40:18 +0000 (06:40 +0000)
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_View.h
src/SVTK/SVTK_ViewWindow.cxx

index 2f3ec29160f24f91356231d509b3b9727589f8a4..d90c7147981c35b95feeb99a3fbc84d316d8a608 100644 (file)
@@ -132,6 +132,8 @@ QVTK_RenderWindowInteractor
   myInteractor(QtRenderWindowInteractor::New())
 {
   myInteractor->Delete();
+
+  setMouseTracking(true);
 }
 
 
@@ -157,15 +159,7 @@ QVTK_RenderWindowInteractor
 ::SetRenderWindow(vtkRenderWindow *theRenderWindow)
 {
   myInteractor->SetRenderWindow(theRenderWindow);
-#ifndef WNT
-  theRenderWindow->SetDisplayId((void*)x11Display());
-#endif
-  theRenderWindow->SetWindowId((void*)winId());
   theRenderWindow->DoubleBufferOn();
-  setMouseTracking(true);
-
-  // To avoid UnbindContext: Assertion `vb.context == ctx' failed
-  // Initialize();
 }
 
 vtkRenderWindow*
@@ -178,23 +172,39 @@ QVTK_RenderWindowInteractor
 //----------------------------------------------------------------------------
 void
 QVTK_RenderWindowInteractor
-::Initialize() 
+::InvokeEvent(unsigned long theEvent, void* theCallData)
 {
-  myInteractor->Initialize();
+  myInteractor->InvokeEvent(theEvent,theCallData);
 }
 
 //----------------------------------------------------------------------------
 void
 QVTK_RenderWindowInteractor
-::InvokeEvent(unsigned long theEvent, void* theCallData)
+::show()
 {
-  myInteractor->InvokeEvent(theEvent,theCallData);
+  QWidget::show();
+  update(); // needed for initial contents display on Win32
 }
 
 //----------------------------------------------------------------------------
 void
 QVTK_RenderWindowInteractor
-::UpdateSize(int w, int h) 
+::polish()
+{
+  // Final initialization just before the widget is displayed.
+  myInteractor->SetSize(width(),height());
+#ifndef WNT
+  GetRenderWindow()->SetDisplayId((void*)x11Display());
+#endif
+  GetRenderWindow()->SetWindowId((void*)winId());
+  myInteractor->Enable();
+  myInteractor->ConfigureEvent();
+}
+
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::resize(int w, int h) 
 {
   myInteractor->UpdateSize(w,h);
 }
@@ -204,7 +214,12 @@ void
 QVTK_RenderWindowInteractor
 ::paintEvent( QPaintEvent* theEvent ) 
 {
-  myInteractor->Render();
+  if(myInteractor->GetEnabled()){
+    if(!myInteractor->GetInitialized())
+      myInteractor->Initialize();
+    else
+      myInteractor->Render();
+  }
 }
 
 
@@ -217,7 +232,9 @@ QVTK_RenderWindowInteractor
   int aWidth = aSize[0];
   int aHeight = aSize[1];
 
-  UpdateSize( width(), height() );
+  //myInteractor->SetSize(width(),height());
+  myInteractor->UpdateSize(width(),height());
+  myInteractor->ConfigureEvent();
 
   if( aWidth != width() || aHeight != height() )
   {
@@ -235,6 +252,8 @@ QVTK_RenderWindowInteractor
       aCamera->SetParallelScale(aScale*aCoeff);
     }
   }
+
+  update(); 
 }
 
 
index 0a07e43327b64b77f0cd6422ada0bd6508a0da5d..cd5ddbfee27f044877f605c40f09373591c5c2f8 100644 (file)
@@ -108,22 +108,14 @@ class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget
   vtkRenderWindow*
   GetRenderWindow();
 
-  // Description:
-  // Initializes the event handlers without an XtAppContext.  This is
-  // good for when you don`t have a user interface, but you still
-  // want to have mouse interaction.
-  void
-  Initialize();
-
   virtual
   void
   InvokeEvent(unsigned long theEvent, void* theCallData);
 
-  // Description:
-  // Event loop notification member for Window size change
-  virtual
-  void
-  UpdateSize(int x,int y);
+ public slots:
+  virtual void show();
+  virtual void polish();
+  virtual void resize(int w, int h);
 
  protected:
   virtual void paintEvent( QPaintEvent* );
index 4cef4ea32b9ce5a47661156053b9da6f4bbb258e..c3665f6f0fa024a690731f3cc68e241333f52f4f 100644 (file)
@@ -563,8 +563,6 @@ SVTK_InteractorHolder
   myInteractor = theInteractor;
 
   if(myInteractor){
-    myInteractor->SetRenderWindow(myRenderWindow.GetPointer());
-
     connect(myInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
            this,SIGNAL(KeyPressed(QKeyEvent*)) );
     connect(myInteractor,SIGNAL(KeyReleased(QKeyEvent*)),
@@ -589,6 +587,8 @@ SVTK_InteractorHolder
     myInteractor->setFocusPolicy(StrongFocus);
     myInteractor->setFocus();
     setFocusProxy(myInteractor);
+
+    myInteractor->SetRenderWindow(myRenderWindow.GetPointer());
   }
 }
 
@@ -635,14 +635,6 @@ SVTK_InteractorHolder
   myInteractor->InvokeEvent(theEvent,theCallData);
 }
 
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorHolder
-::Initialize()
-{
-  myInteractor->Initialize();
-}
-
 //----------------------------------------------------------------------------
 void
 SVTK_InteractorHolder
index da0c89e14f0d0b02119aa272c31296816b69e9de..87525dab7b24f366629f8179881b8236695d867e 100644 (file)
@@ -173,9 +173,6 @@ public:
   void
   InvokeEvent(unsigned long theEvent, void* theCallData);
 
-  void
-  Initialize();
-
   void
   SetRenderWindow(vtkRenderWindow *theRenderWindow);
 
index 948d80f098e4c72bed5a3eefcfcabf100b433f27..037340fab7d6fe966cba4ec3e8c9786a4c1c4f80 100755 (executable)
@@ -64,8 +64,6 @@ SVTK_ViewWindow
 ::Initialize(SVTK_View* theView,
             SVTK_ViewModelBase* theModel)
 {
-  theView->Initialize();
-
   onResetView();
 
   connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),