Salome HOME
[bos#35158][EDF] (2023-T1) Automatic rotation of shapes. Fixed problem to trigger...
authormbs <martin.bernhard@opencascade.com>
Wed, 22 Nov 2023 19:20:18 +0000 (19:20 +0000)
committermbs <martin.bernhard@opencascade.com>
Wed, 22 Nov 2023 19:20:18 +0000 (19:20 +0000)
src/OCCViewer/OCCViewer_AutoRotate.cxx
src/OCCViewer/OCCViewer_ViewPort3d.cxx

index 2c03bee21d208da75198e514603ae942edd42133..f973fac552406d0baa00a104170a1e47e6871def 100644 (file)
@@ -59,8 +59,11 @@ bool OCCViewer_AutoRotate::startAnimation()
   const int PrevIdx = 10;
   if (myLog.myHistorySize > PrevIdx) {
     qint64 aStopTime = (QDateTime::currentMSecsSinceEpoch() - myLog.myTime[LastIdx]);
-    qint64 delta = (myLog.myTime[LastIdx] - myLog.myTime[PrevIdx]);
-    if (aStopTime < (qint64)100 && delta < (qint64)100) {
+    // Compute the maximum time spent between two distinct mouse move events until we consider the
+    // mouse being move at the time, the manual rotation action stops (mouse button released).
+    // If the mouse was moving, then we trigger the continuous view animation.
+    qint64 maxTime = qint64((myLog.myTime[LastIdx] - myLog.myTime[PrevIdx]) * 1.2);
+    if (aStopTime < (qint64)maxTime) {
       OCCViewer_ViewWindow *aWnd = dynamic_cast<OCCViewer_ViewWindow*>(myWindow);
       if (aWnd) {
         OCCViewer_ViewPort3d* aViewPort = aWnd->getViewPort();
@@ -74,7 +77,7 @@ bool OCCViewer_AutoRotate::startAnimation()
             dx = (Standard_Real(this->myLog.myPosition[LastIdx].x()) - this->myLog.myPosition[PrevIdx].x()) * M_PI / rx;
             dy = (this->myLog.myPosition[PrevIdx].y() - Standard_Real(this->myLog.myPosition[LastIdx].y())) * M_PI / ry;
             dz = atan2(Standard_Real(this->myLog.myPosition[LastIdx].x())-rx/2., ry/2.-Standard_Real(this->myLog.myPosition[LastIdx].y()))
-               - atan2(this->myLog.myPosition[PrevIdx].x()-rx/2.,ry/2.-this->myLog.myPosition[PrevIdx].y());
+               - atan2(Standard_Real(this->myLog.myPosition[PrevIdx].x())-rx/2., ry/2.-Standard_Real(this->myLog.myPosition[PrevIdx].y()));
 
             Handle(Graphic3d_Camera) aCamera = aView->Camera();
             gp_Pnt aRCenter = aView->GravityPoint();
@@ -96,10 +99,10 @@ bool OCCViewer_AutoRotate::startAnimation()
             quat.GetVectorAndAngle(aAxis, anAngle);
             aScale = aView->Scale();
             // std::cout << "Axis=[" << aAxis.X() << " , " << aAxis.Y() << " , " << aAxis.Z()
-            //           << "]   Angle=" << anAngle * 180. / M_PI 
-            //           << " deg   z-Angle=" << dz * 180. / M_PI << " deg   Scale=" << aScale << std::endl;
+            //           << "]   Angle=" << anAngle * 180. * 3./aScale / M_PI 
+            //           << " deg   z-Angle=" << dz * 180. * 12./aScale / M_PI << " deg   Scale=" << aScale << std::endl;
             if (anAngle != 0.)
-              aViewPort->setRotationAxis(aAxis, anAngle*3./aScale, dz*3./aScale);
+              aViewPort->setRotationAxis(aAxis, anAngle*3./aScale, dz*12./aScale);
           }
         }
         return true;
index 49c2250e7c91bce111e96b342ad2a9a7c1222272..552c00dff92bb7bd3698a0fd1af80c0abde9bcc7 100644 (file)
@@ -68,8 +68,8 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
     myBusy( true ),
     myScale( 1.0 ),
     myIsAdvancedZoomingEnabled( false ),
-    myIsRotating( false ),
-    myRotAngle( 0.0 )
+    myRotAngle( 0.0 ),
+    myIsRotating( false )
 {
   // VSR: 01/07/2010 commented to avoid SIGSEGV at SALOME exit
   //selectVisualId();