]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To use the right way for render window update
authorapo <apo@opencascade.com>
Thu, 18 Aug 2005 12:52:12 +0000 (12:52 +0000)
committerapo <apo@opencascade.com>
Thu, 18 Aug 2005 12:52:12 +0000 (12:52 +0000)
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h
src/SVTK/SVTK_ViewWindow.cxx

index 4624e1da03ccd815a59c432d532932278c6beb49..52a26e8c0f1d322a9cd6b9a1b1fdbc7ffa539997 100644 (file)
@@ -169,9 +169,9 @@ SVTK_InteractorStyle
 //----------------------------------------------------------------------------
 void
 SVTK_InteractorStyle
-::setGUIWindow(QWidget* theWindow)
+::SetRenderWidget(QWidget* theWidget)
 {
-  myGUIWindow = theWindow;
+  myRenderWidget = theWidget;
 }
 
 //----------------------------------------------------------------------------
@@ -200,8 +200,7 @@ SVTK_InteractorStyle
   cam->Elevation(ryf);
   cam->OrthogonalizeViewUp();
   ::ResetCameraClippingRange(this->CurrentRenderer); 
-  //this->Interactor->Render();
-  myGUIWindow->update();
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 //----------------------------------------------------------------------------
@@ -210,8 +209,7 @@ SVTK_InteractorStyle
 ::PanXY(int x, int y, int oldX, int oldY)
 {
   TranslateView(x, y, oldX, oldY);   
-  //this->Interactor->Render();
-  myGUIWindow->update();
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 
@@ -235,8 +233,7 @@ SVTK_InteractorStyle
     ::ResetCameraClippingRange(this->CurrentRenderer);
   }
 
-  //this->Interactor->Render();
-  myGUIWindow->update();
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 //----------------------------------------------------------------------------
@@ -263,8 +260,7 @@ SVTK_InteractorStyle
   cam->Roll(newAngle - oldAngle);
   cam->OrthogonalizeViewUp();
       
-  //this->Interactor->Render();
-  myGUIWindow->update();
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 
@@ -370,9 +366,6 @@ SVTK_InteractorStyle
     onOperation(QPoint(x, y));
   else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE)
     onCursorMove(QPoint(x, y));
-
-  if( needsRedrawing() )
-    emit RenderWindowModified() ; 
 }
 
 
@@ -628,8 +621,8 @@ bool
 SVTK_InteractorStyle
 ::eventFilter(QObject* object, QEvent* event)
 {
-  if (!myGUIWindow) return false;
-  if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myGUIWindow)
+  if (!myRenderWidget) return false;
+  if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myRenderWidget)
   {
     qApp->removeEventFilter(this);
     startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
@@ -743,26 +736,12 @@ SVTK_InteractorStyle
 
   if (myViewWindow) myViewWindow->onFitAll();
 
-  if (myGUIWindow) myGUIWindow->update();
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
   
   qApp->installEventFilter(this);
 }
 
 
-//----------------------------------------------------------------------------
-// returns TRUE if needs redrawing
-bool
-SVTK_InteractorStyle
-::needsRedrawing()
-{
-  return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM   ||
-         State == VTK_INTERACTOR_STYLE_CAMERA_PAN    ||
-         State == VTK_INTERACTOR_STYLE_CAMERA_ROTATE ||
-         State == VTK_INTERACTOR_STYLE_CAMERA_SPIN   ||
-         State == VTK_INTERACTOR_STYLE_CAMERA_NONE;
-}
-
-
 //----------------------------------------------------------------------------
 // fits viewer contents to rect
 void
@@ -795,7 +774,7 @@ SVTK_InteractorStyle
     ::ResetCameraClippingRange(this->CurrentRenderer);
   }
   
-  myGUIWindow->update();
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 
@@ -836,37 +815,37 @@ void
 SVTK_InteractorStyle
 ::setCursor(const int operation)
 {
-  if (!myGUIWindow) return;
+  if (!myRenderWidget) return;
   switch (operation)
   {
     case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
-      myGUIWindow->setCursor(myZoomCursor); 
+      myRenderWidget->setCursor(myZoomCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_PAN:
-      myGUIWindow->setCursor(myPanCursor); 
+      myRenderWidget->setCursor(myPanCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
-      myGUIWindow->setCursor(myRotateCursor); 
+      myRenderWidget->setCursor(myRotateCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
-      myGUIWindow->setCursor(mySpinCursor); 
+      myRenderWidget->setCursor(mySpinCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
-      myGUIWindow->setCursor(myGlobalPanCursor); 
+      myRenderWidget->setCursor(myGlobalPanCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
-      myGUIWindow->setCursor(myHandCursor); 
+      myRenderWidget->setCursor(myHandCursor); 
       myCursorState = true;
       break;
     case VTK_INTERACTOR_STYLE_CAMERA_NONE:
     default:
-      myGUIWindow->setCursor(myDefCursor); 
+      myRenderWidget->setCursor(myDefCursor); 
       myCursorState = false;
       break;
   }
@@ -879,14 +858,14 @@ void
 SVTK_InteractorStyle
 ::onStartOperation()
 {
-  if (!myGUIWindow) return;
+  if (!myRenderWidget) return;
   // VSV: LOD actor activisation
   //  this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
   switch (State) {
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myGUIWindow);
+      QPainter p(myRenderWidget);
       p.setPen(Qt::lightGray);
       p.setRasterOp(Qt::XorROP);
       p.drawRect(QRect(myPoint, myOtherPoint));
@@ -908,7 +887,7 @@ void
 SVTK_InteractorStyle
 ::onFinishOperation() 
 {
-  if (!myGUIWindow
+  if (!myRenderWidget
     return;
 
   // VSV: LOD actor activisation
@@ -920,7 +899,7 @@ SVTK_InteractorStyle
     case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
     case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myGUIWindow);
+      QPainter p(myRenderWidget);
       p.setPen(Qt::lightGray);
       p.setRasterOp(Qt::XorROP);
       QRect rect(myPoint, myOtherPoint);
@@ -1017,8 +996,8 @@ SVTK_InteractorStyle
     }
     break;
   }
-  if (myGUIWindow) myGUIWindow->update();
 
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 
@@ -1028,38 +1007,30 @@ void
 SVTK_InteractorStyle
 ::onOperation(QPoint mousePos) 
 {
-  if (!myGUIWindow) return;
-  int w, h;
-  GetInteractor()->GetSize(w, h);
+  if (!myRenderWidget) 
+    return;
+
   switch (State) {
   case VTK_INTERACTOR_STYLE_CAMERA_PAN: 
     {
-      // processing panning
-      //this->FindPokedCamera(mousePos.x(), mousePos.y());
       this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y());
       myPoint = mousePos;
       break;
     }
   case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: 
     {    
-      // processing zooming
-      //this->FindPokedCamera(mousePos.x(), mousePos.y());
       this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y());
       myPoint = mousePos;
       break;
     }
   case VTK_INTERACTOR_STYLE_CAMERA_ROTATE: 
     {
-      // processing rotation
-      //this->FindPokedCamera(mousePos.x(), mousePos.y());
       this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y());
       myPoint = mousePos;
       break;
     }
   case VTK_INTERACTOR_STYLE_CAMERA_SPIN: 
     {
-      // processing spinning
-      //this->FindPokedCamera(mousePos.x(), mousePos.y());
       this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y());
       myPoint = mousePos;
       break;
@@ -1075,7 +1046,7 @@ SVTK_InteractorStyle
     }
   case VTK_INTERACTOR_STYLE_CAMERA_FIT:
     {
-      QPainter p(myGUIWindow);
+      QPainter p(myRenderWidget);
       p.setPen(Qt::lightGray);
       p.setRasterOp(Qt::XorROP);
       p.drawRect(QRect(myPoint, myOtherPoint));
@@ -1084,8 +1055,6 @@ SVTK_InteractorStyle
       break;
     }
   }
-  this->LastPos[0] = mousePos.x();
-  this->LastPos[1] = h - mousePos.y() - 1;
 }
 
 // called when user moves mouse inside viewer window and there is no active viewer operation 
@@ -1120,13 +1089,8 @@ SVTK_InteractorStyle
   
   Interactor->EndPickCallback();
 
-  if(anIsChanged){
-    Interactor->CreateTimer(VTKI_TIMER_FIRST);
-    //Interactor->Render();
-  }
-  
-  this->LastPos[0] = x;
-  this->LastPos[1] = y;
+  if(anIsChanged)
+    this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 // called on finsh GlobalPan operation 
@@ -1151,8 +1115,7 @@ SVTK_InteractorStyle
   cam->SetParallelScale(myScale);
   ::ResetCameraClippingRange(this->CurrentRenderer);
 
-  if (myGUIWindow) myGUIWindow->update();
-
+  this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
 }
 
 
index aae56d379b23be8d0af4c2b0b1f7df0a8347a671..8c3b00d052256a50b9db981e1a8ab959d2c057ba 100644 (file)
@@ -81,17 +81,12 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   vtkTypeMacro(SVTK_InteractorStyle, vtkInteractorStyle);
 
   void setViewWindow(SVTK_ViewWindow* theViewWindow);
-  void setGUIWindow(QWidget* theWindow);
+  void SetRenderWidget(QWidget* theRenderWidget);
 
   virtual int GetState();
 
   SVTK_SelectionEvent GetSelectionEvent();
 
-  void setPreselectionProp(const double& theRed = 0, 
-                          const double& theGreen = 1,
-                          const double& theBlue = 1, 
-                          const int& theWidth = 5);
-
   // redefined in order to add an observer (callback) for custorm event (space mouse event)
   virtual void SetInteractor( vtkRenderWindowInteractor* );
 
@@ -174,7 +169,6 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   void startRotate();
   void startFitArea();
   void startSpin();
-  bool needsRedrawing();
 
  protected:
   void loadCursors();
@@ -194,9 +188,6 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   void IncreaseGaussPointMagnification();
   void DominantCombinedSwitch();
   
- signals:
-  void RenderWindowModified() ;
-
  protected:
   QCursor                   myDefCursor;
   QCursor                   myPanCursor;
@@ -212,7 +203,7 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   int                       ForcedState;
   
   SVTK_ViewWindow*          myViewWindow;
-  QWidget*                  myGUIWindow;
+  QWidget*                  myRenderWidget;
 
   vtkSmartPointer<vtkPicker> myPicker;
   vtkSmartPointer<VTKViewer_RectPicker> myRectPicker;
@@ -222,7 +213,6 @@ class SVTK_EXPORT SVTK_InteractorStyle :
   //  members from old version
   double                    DeltaElevation;
   double                    DeltaAzimuth;
-  int                       LastPos[2];
 };
 
 #endif
index 77f183465e0cde58885499bf42572d610ebf06eb..bdbe7b1fee2e0316d0b354d171c82d540609e5ae 100755 (executable)
@@ -60,7 +60,7 @@ SVTK_ViewWindow
   bottomView->Initialize();
   */
   myInteractorStyle = SVTK_InteractorStyle::New();
-  myInteractorStyle->setGUIWindow( myView );
+  myInteractorStyle->SetRenderWidget( myView );
   myInteractorStyle->setViewWindow( this );
 
   myView->SetInteractorStyle( myInteractorStyle );
@@ -75,23 +75,6 @@ SVTK_ViewWindow
   myView->setFocusPolicy( StrongFocus );
   myView->setFocus();
 
-  /*
-  connect( myRenderWindow, SIGNAL(KeyPressed( QKeyEvent* )),
-           this,           SLOT(onKeyPressed( QKeyEvent* )) );
-  connect( myRenderWindow, SIGNAL(KeyReleased( QKeyEvent* )),
-           this,           SLOT(onKeyReleased( QKeyEvent* )) );
-  connect( myRenderWindow, SIGNAL(MouseButtonPressed( QMouseEvent* )),
-           this,           SLOT(onMousePressed( QMouseEvent* )) );
-  connect( myRenderWindow, SIGNAL(MouseButtonReleased( QMouseEvent* )),
-           this,           SLOT(onMouseReleased( QMouseEvent* )) );
-  connect( myRenderWindow, SIGNAL(MouseDoubleClicked( QMouseEvent* )),
-           this,           SLOT(onMouseDoubleClicked( QMouseEvent* )) );
-  connect( myRenderWindow, SIGNAL(MouseMove( QMouseEvent* )),
-           this,           SLOT(onMouseMoving( QMouseEvent* )) );
-  */
-
-  connect( myInteractorStyle, SIGNAL(RenderWindowModified()),
-           myView, SLOT(update()) );
   connect( myView, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
            this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );