]> OCCT Git - occt.git/commitdiff
0033114: Visualization - AIS_Animation returns 0 elapsed time after finishing playback
authormzernova <mzernova@opencascade.com>
Fri, 2 Sep 2022 15:08:46 +0000 (18:08 +0300)
committermzernova <mzernova@opencascade.com>
Tue, 20 Sep 2022 09:03:58 +0000 (12:03 +0300)
Added -elapsedTime option to DRAW vanim command

src/AIS/AIS_Animation.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx

index 26c6f9ba9e7ba235c0972d66ea1d793b27efc90a..ae9eb7574a91109689f716c8c6186f0ee123efd4 100644 (file)
@@ -251,7 +251,9 @@ void AIS_Animation::Stop()
   myState = AnimationState_Stopped;
   if (!myTimer.IsNull())
   {
+    const Standard_Real anElapsedTime = ElapsedTime();
     myTimer->Stop();
+    myTimer->Seek (Min (Duration(), anElapsedTime));
   }
 
   for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
index c26d53e3405a9a8c0a20c7324808f53a8cb36f33..dd2389fa337d3b72702b4a413b01e6820b17394e 100644 (file)
@@ -7296,9 +7296,10 @@ static Standard_Integer VAnimation (Draw_Interpretor& theDI,
   Standard_Real aPlaySpeed     = 1.0;
   Standard_Real aPlayStartTime = anAnimation->StartPts();
   Standard_Real aPlayDuration  = anAnimation->Duration();
-  Standard_Boolean isFreeCamera = Standard_False;
+  Standard_Boolean isFreeCamera   = Standard_False;
   Standard_Boolean toPauseOnClick = Standard_True;
-  Standard_Boolean isLockLoop   = Standard_False;
+  Standard_Boolean isLockLoop     = Standard_False;
+  Standard_Boolean toPrintElapsedTime = Standard_False;
 
   // video recording parameters
   TCollection_AsciiString aRecFile;
@@ -7352,6 +7353,11 @@ static Standard_Integer VAnimation (Draw_Interpretor& theDI,
         }
       }
     }
+    else if (anArg == "-elapsedtime"
+          || anArg == "-elapsed")
+    {
+      toPrintElapsedTime = Standard_True;
+    }
     else if (anArg == "-resume")
     {
       toPlay = Standard_True;
@@ -7760,8 +7766,17 @@ static Standard_Integer VAnimation (Draw_Interpretor& theDI,
     }
   }
 
-  ViewerTest::CurrentEventManager()->AbortViewAnimation();
-  ViewerTest::CurrentEventManager()->SetObjectsAnimation (Handle(AIS_Animation)());
+  if (anAnimation.IsNull() || anAnimation->IsStopped())
+  {
+    ViewerTest::CurrentEventManager()->AbortViewAnimation();
+    ViewerTest::CurrentEventManager()->SetObjectsAnimation(Handle(AIS_Animation)());
+  }
+
+  if (toPrintElapsedTime)
+  {
+    theDI << "Elapsed Time: " << anAnimation->ElapsedTime() << " s\n";
+  }
+
   if (!toPlay && aRecFile.IsEmpty())
   {
     return 0;
@@ -14338,13 +14353,14 @@ List existing animations:
   vanim
 
 Animation playback:
-  vanim name {-play|-resume|-pause|-stop} [playFrom [playDuration]]
-             [-speed Coeff] [-freeLook] [-noPauseOnClick] [-lockLoop]
+  vanim name {-play|-resume|-pause|-stop} [playFrom [playDuration]] [-speed Coeff]
+             [-freeLook] [-noPauseOnClick] [-lockLoop] [-elapsedTime]
 
-  -speed    playback speed (1.0 is normal speed)
-  -freeLook skip camera animations
+  -speed          playback speed (1.0 is normal speed)
+  -freeLook       skip camera animations
   -noPauseOnClick do not pause animation on mouse click
-  -lockLoop disable any interactions
+  -lockLoop       disable any interactions
+  -elapsedTime    prints elapsed time in seconds"
 
 Animation definition:
   vanim Name/sub/name [-clear] [-delete]