From b9f787f180253cafe326c4cecef69d296b161924 Mon Sep 17 00:00:00 2001 From: mzernova Date: Fri, 2 Sep 2022 18:08:46 +0300 Subject: [PATCH] 0033114: Visualization - AIS_Animation returns 0 elapsed time after finishing playback Added -elapsedTime option to DRAW vanim command --- src/AIS/AIS_Animation.cxx | 2 ++ src/ViewerTest/ViewerTest_ViewerCommands.cxx | 34 ++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/AIS/AIS_Animation.cxx b/src/AIS/AIS_Animation.cxx index 26c6f9ba9e..ae9eb7574a 100644 --- a/src/AIS/AIS_Animation.cxx +++ b/src/AIS/AIS_Animation.cxx @@ -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::Iterator anIter (myAnimations); anIter.More(); anIter.Next()) diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index c26d53e340..dd2389fa33 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -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] -- 2.39.5