Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / VTKViewer / VTKViewer_InteractorStyle.cxx
index 1f69e6085d76aa66a8681c7474371e4dfb807a97..c40cf8d900c0da31e3cea8d81a0987e9c29244a7 100644 (file)
 #include "VTKViewer_Actor.h"
 #include "VTKViewer_Utilities.h"
 #include "VTKViewer_Trihedron.h"
-#include "VTKViewer_RectPicker.h"
 #include "VTKViewer_ViewWindow.h"
 #include "VTKViewer_RenderWindow.h"
-#include "VTKViewer_CellRectPicker.h"
 #include "VTKViewer_RenderWindowInteractor.h"
 
 //#include "SALOME_Actor.h"
@@ -86,10 +84,10 @@ static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId)
   return anEdgeId;
 }
 */
-//----------------------------------------------------------------------------
+
 vtkStandardNewMacro(VTKViewer_InteractorStyle);
 
-//----------------------------------------------------------------------------
+
 /*!Constructor.*/
 VTKViewer_InteractorStyle::VTKViewer_InteractorStyle()
 {
@@ -108,14 +106,14 @@ VTKViewer_InteractorStyle::VTKViewer_InteractorStyle()
   OnSelectionModeChanged();
 }
 
-//----------------------------------------------------------------------------
+
 /*!Destructor.*/
 VTKViewer_InteractorStyle::~VTKViewer_InteractorStyle() 
 {
   m_ViewWnd->RemoveActor(myPreSelectionActor);
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set preselection properties.
  *\param theRed   - red color.
  *\param theGreen - green color.
@@ -132,7 +130,7 @@ void VTKViewer_InteractorStyle::setPreselectionProp(const double& theRed, const
   myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set render window interactor
  *\param theInteractor - interactor.
  */
@@ -141,7 +139,7 @@ void VTKViewer_InteractorStyle::SetInteractor(vtkRenderWindowInteractor *theInte
   Superclass::SetInteractor(theInteractor);
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set view window.
  *\param theViewWnd - SALOME VTKViewer_ViewWindow
  */
@@ -151,7 +149,7 @@ void VTKViewer_InteractorStyle::setViewWnd(VTKViewer_ViewWindow* theViewWnd ){
   myPreSelectionActor->Delete();
 }
 
-//----------------------------------------------------------------------------
+
 /*!Set GUI window.
  *\param theWindow - QWidget window.
  */
@@ -159,15 +157,14 @@ void VTKViewer_InteractorStyle::setGUIWindow(QWidget* theWindow){
   myGUIWindow = theWindow;
 }
 
-//----------------------------------------------------------------------------
-/*!Set triedron.
+
+/*!Set trihedron.
  *\param theTrihedron - SALOME VTKViewer_Trihedron
  */
 void VTKViewer_InteractorStyle::setTriedron(VTKViewer_Trihedron* theTrihedron){
   m_Trihedron = theTrihedron;
 }
 
-//----------------------------------------------------------------------------
 /*!Rotate camera.
  *\param dx - 
  *\param dy - 
@@ -199,7 +196,6 @@ void VTKViewer_InteractorStyle::RotateXY(int dx, int dy)
   myGUIWindow->update();
 }
 
-//----------------------------------------------------------------------------
 void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
 {
   TranslateView(x, y, oldX, oldY);   
@@ -208,7 +204,6 @@ void VTKViewer_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
 }
 
 
-//----------------------------------------------------------------------------
 /*! Move the position of the camera along the direction of projection. (dx,dy)*/
 void VTKViewer_InteractorStyle::DollyXY(int dx, int dy)
 {
@@ -231,8 +226,6 @@ void VTKViewer_InteractorStyle::DollyXY(int dx, int dy)
   myGUIWindow->update();
 }
 
-//----------------------------------------------------------------------------
-/*!*/
 void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
 {
   vtkCamera *cam;
@@ -259,7 +252,6 @@ void VTKViewer_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
 }
 
 
-//----------------------------------------------------------------------------
 /*!On mouse move event.
  *\param ctrl  - CTRL (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -278,7 +270,6 @@ void VTKViewer_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
 }
 
 
-//----------------------------------------------------------------------------
 /*!On Left button down event.
  *\param ctrl  - CTRL  (on/off - integer 0/1)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -315,7 +306,6 @@ void VTKViewer_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
 }
 
 
-//----------------------------------------------------------------------------
 /*!On left button up event.
  *\param ctrl  - CTRL  (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -336,7 +326,6 @@ void VTKViewer_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
 }
 
 
-//----------------------------------------------------------------------------
 /*!On left button up event.
  *\param ctrl  - CTRL  (on/off - integer 0/1)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -374,7 +363,6 @@ void VTKViewer_InteractorStyle::OnMiddleButtonDown(int ctrl,
 }
 
 
-//----------------------------------------------------------------------------
 /*!On middle button up event.
  *\param ctrl  - CTRL  (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -395,7 +383,6 @@ void VTKViewer_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
 }
 
 
-//----------------------------------------------------------------------------
 /*!On right button down event.
  *\param ctrl  - CTRL  (on/off - integer 0/1)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -432,7 +419,6 @@ void VTKViewer_InteractorStyle::OnRightButtonDown(int ctrl,
   }
 }
 
-//----------------------------------------------------------------------------
 /*!On right button up event.
  *\param ctrl  - CTRL  (not used)
  *\param shift - SHIFT (on/off - integer 0/1)
@@ -452,8 +438,7 @@ void VTKViewer_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
   }
 }
 
-//----------------------------------------------------------------------------
-/** @name XPM - x pixmaps. */
+/*! @name XPM - x pixmaps. */
 //@{
 /*!Image Zoom cursor*/
 const char* imageZoomCursor[] = { 
@@ -534,7 +519,6 @@ const char* imageRotateCursor[] = {
 "................................"};
 //@}
 
-//----------------------------------------------------------------------------
 /*! Loads cursors for viewer operations - zoom, pan, etc...*/
 void VTKViewer_InteractorStyle::loadCursors()
 {
@@ -549,7 +533,6 @@ void VTKViewer_InteractorStyle::loadCursors()
 }
 
 
-//----------------------------------------------------------------------------
 /*! event filter - controls mouse and keyboard events during viewer operations*/
 bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
 {
@@ -563,7 +546,6 @@ bool VTKViewer_InteractorStyle::eventFilter(QObject* object, QEvent* event)
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Zoom operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startZoom()
 {
@@ -578,7 +560,6 @@ void VTKViewer_InteractorStyle::startZoom()
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Pan operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startPan()
 {
@@ -592,7 +573,6 @@ void VTKViewer_InteractorStyle::startPan()
   qApp->installEventFilter(this);
 }
 
-//----------------------------------------------------------------------------
 /*! starts Rotate operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startRotate()
 {
@@ -607,7 +587,6 @@ void VTKViewer_InteractorStyle::startRotate()
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Spin operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startSpin()
 {
@@ -623,7 +602,6 @@ void VTKViewer_InteractorStyle::startSpin()
 
 
 
-//----------------------------------------------------------------------------
 /*! starts Fit Area operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startFitArea()
 {
@@ -638,7 +616,6 @@ void VTKViewer_InteractorStyle::startFitArea()
 }
 
 
-//----------------------------------------------------------------------------
 /*!View fit all.*/
 void  VTKViewer_InteractorStyle::ViewFitAll() {
   int aTriedronWasVisible = false;
@@ -660,7 +637,6 @@ void  VTKViewer_InteractorStyle::ViewFitAll() {
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts Global Panning operation (e.g. through menu command)*/
 void VTKViewer_InteractorStyle::startGlobalPan()
 {
@@ -684,7 +660,6 @@ void VTKViewer_InteractorStyle::startGlobalPan()
 }
 
 
-//----------------------------------------------------------------------------
 /*!\retval TRUE if needs redrawing*/
 bool VTKViewer_InteractorStyle::needsRedrawing()
 {
@@ -696,7 +671,6 @@ bool VTKViewer_InteractorStyle::needsRedrawing()
 }
 
 
-//----------------------------------------------------------------------------
 /*! fits viewer contents to rectangle
  *\param left - left side
  *\param top  - top side
@@ -735,7 +709,6 @@ void VTKViewer_InteractorStyle::fitRect(const int left,
 }
 
 
-//----------------------------------------------------------------------------
 /*! starts viewer operation (!internal usage!)*/
 void VTKViewer_InteractorStyle::startOperation(int operation)
 {
@@ -764,7 +737,6 @@ void VTKViewer_InteractorStyle::startOperation(int operation)
 }
 
 
-//----------------------------------------------------------------------------
 /*! sets proper cursor for window when viewer operation is activated*/
 void VTKViewer_InteractorStyle::setCursor(const int operation)
 {
@@ -805,7 +777,6 @@ void VTKViewer_InteractorStyle::setCursor(const int operation)
 }
 
 
-//----------------------------------------------------------------------------
 /*! called when viewer operation started (!put necessary initialization here!)*/
 void VTKViewer_InteractorStyle::onStartOperation()
 {
@@ -832,7 +803,6 @@ void VTKViewer_InteractorStyle::onStartOperation()
 }
 
 
-//----------------------------------------------------------------------------
 /*! called when viewer operation finished (!put necessary post-processing here!)*/
 void VTKViewer_InteractorStyle::onFinishOperation() 
 {
@@ -1366,17 +1336,17 @@ void VTKViewer_InteractorStyle::Place(const int theX, const int theY)
 void VTKViewer_InteractorStyle::TranslateView(int toX, int toY, int fromX, int fromY)
 {
   vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
-  double viewFocus[4], focalDepth, viewPoint[3];
-  float newPickPoint[4], oldPickPoint[4], motionVector[3];
+  vtkFloatingPointType viewFocus[4], focalDepth, viewPoint[3];
+  vtkFloatingPointType newPickPoint[4], oldPickPoint[4], motionVector[3];
   cam->GetFocalPoint(viewFocus);
 
   this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1],
                              viewFocus[2], viewFocus);
   focalDepth = viewFocus[2];
 
-  this->ComputeDisplayToWorld(double(toX), double(toY),
+  this->ComputeDisplayToWorld(vtkFloatingPointType(toX), vtkFloatingPointType(toY),
                              focalDepth, newPickPoint);
-  this->ComputeDisplayToWorld(double(fromX),double(fromY),
+  this->ComputeDisplayToWorld(vtkFloatingPointType(fromX),vtkFloatingPointType(fromY),
                              focalDepth, oldPickPoint);
   
   // camera motion is reversed
@@ -1400,17 +1370,17 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkActor* theActor,
                                               const int left, const int top, 
                                               const int right, const int bottom)
 {
-  float* aBounds = theActor->GetBounds();
-  float aMin[3], aMax[3];
+  vtkFloatingPointType* aBounds = theActor->GetBounds();
+  vtkFloatingPointType aMin[3], aMax[3];
   ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
   ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
   if (aMin[0] > aMax[0]) {
-    float aBuf = aMin[0];
+    vtkFloatingPointType aBuf = aMin[0];
     aMin[0] = aMax[0];
     aMax[0] = aBuf;
   }
   if (aMin[1] > aMax[1]) {
-    float aBuf = aMin[1];
+    vtkFloatingPointType aBuf = aMin[1];
     aMin[1] = aMax[1];
     aMax[1] = aBuf;    
   }
@@ -1424,17 +1394,17 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell,
                                               const int left, const int top, 
                                               const int right, const int bottom)
 {
-  float* aBounds = theCell->GetBounds();
-  float aMin[3], aMax[3];
+  vtkFloatingPointType* aBounds = theCell->GetBounds();
+  vtkFloatingPointType aMin[3], aMax[3];
   ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
   ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
   if (aMin[0] > aMax[0]) {
-    float aBuf = aMin[0];
+    vtkFloatingPointType aBuf = aMin[0];
     aMin[0] = aMax[0];
     aMax[0] = aBuf;
   }
   if (aMin[1] > aMax[1]) {
-    float aBuf = aMin[1];
+    vtkFloatingPointType aBuf = aMin[1];
     aMin[1] = aMax[1];
     aMax[1] = aBuf;    
   }
@@ -1443,11 +1413,11 @@ bool VTKViewer_InteractorStyle::IsInRect(vtkCell* theCell,
 }
 
 /*!Checks: is given point \a thePoint in rectangle*/
-bool VTKViewer_InteractorStyle::IsInRect(float* thePoint, 
-                                              const int left, const int top, 
-                                              const int right, const int bottom)
+bool VTKViewer_InteractorStyle::IsInRect(vtkFloatingPointType* thePoint, 
+                                        const int left, const int top, 
+                                        const int right, const int bottom)
 {
-  float aPnt[3];
+  vtkFloatingPointType aPnt[3];
   ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
 
   return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));