DiscussionsIssue archiveOCCT:Visualization

Archived issue #0033114

Visualization - AIS_Animation returns 0 elapsed time after finishing playback

Open CASCADEOCCT:Visualizationclosed15 public notes

Search issues

Description

After complication of playback AIS_Animation implicitly stops timer and resets it's value to 0.0.
This behavior is misleading as reported elapsed time becomes inconsistent to what user actually sees - it would be better setting timer exactly to animation's duration.

Steps to reproduce

pload MODELING VISUALIZATION
vinit View1
vaxo
psphere s 50
box b1 -50 -50 0 100 100 100
vdisplay -dispMode 1 b1 s
vviewparams -scale 2.499 -proj 0.546611 -0.600024 -0.584114 -up -0.411832 0.414728 -0.811415 -at -5.3425 -2.983 49.216
vanimation anim -clear
vanimation anim/obj1 -objectTrsf b1 -loc1 0 0 0 -loc2 -100 0 -100 -start 0 -duration 2
vanimation anim/obj2 -objectTrsf s  -loc1 0 0 0 -loc2  100 0  100 -start 1 -duration 2
vanimation anim -play
vanimation anim -elapsedTime

Public activity

15 archived notes

Participants are labeled by their role within this record.

01Author
Random image deviations on v3d anim videorecorder (videorecorder_10.png) might be related to this issue.
Attachment 1 (PNG) (62,280 bytes)   
02Commenter 2
Branch [archived branch] has been created by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Fri Sep 2 18:08:46 2022 +0300

    0033114: Visualization - AIS_Animation returns 0 elapsed time after finishing playback
03Commenter 2
Branch [archived branch] has been updated forcibly by Commenter 1.

[revision removed]
04Commenter 2
Branch [archived branch] has been updated forcibly by Commenter 1.

[revision removed]
05Commenter 1
06Commenter 1
The patch CR33114 is ready to review
07Author
@@ -220,6 +220,7 @@ void AIS_Animation::Start (const Standard_Boolean theToUpdate)
 
   if (!myTimer.IsNull())
   {
+    myTimer->Seek (0.0);
     myTimer->Start();

It is better to keep old behavior of AIS_Animation::Start() to avoid disruption of existing applications relying on it.

+    theAnimationNew->SetTimer (theAnimation->Timer());
     theAnimation = theAnimationNew;

Please bring some comment here (in the bugtracker or commit message) to clarify a reason for this change.

+  Standard_Boolean isShowElapsedTime = Standard_False;

`toPrintElapsedTime`

+    if (isShowElapsedTime && !anAnimation->Timer().IsNull())
+    {
+      theDI << "Elapsed Time, sec: " << anAnimation->ElapsedTime() << "\n";
+    }

If timer is NULL, then elapsed time is `0`.

@@ -252,6 +253,7 @@ void AIS_Animation::Stop()
   if (!myTimer.IsNull())
   {
     myTimer->Stop();
+    myTimer->Seek (Duration());

This looks like a wrong place to forcefully set Duration() here - user may call Stop() in the middle of animation as well.
But in this place you may put something like clamping - e.g. if Duration() > 0.0 then Seek(Min (Duration(), Elapsed)).
08Commenter 2
Branch [archived branch] has been updated forcibly by Commenter 1.

[revision removed]
09Commenter 2
Branch [archived branch] has been created by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Fri Sep 2 18:08:46 2022 +0300

    0033114: Visualization - AIS_Animation returns 0 elapsed time after finishing playback
    
    Added -elapsedTime option to DRAW vanim command
10Author
+      theDI << "Elapsed Time, sec: " << anAnimation->ElapsedTime() << "\n";

theDI << "Elapsed Time: " << anAnimation->ElapsedTime() << " s\n";

-  ViewerTest::CurrentEventManager()->AbortViewAnimation();
-  ViewerTest::CurrentEventManager()->SetObjectsAnimation (Handle(AIS_Animation)());
   if (!toPlay && aRecFile.IsEmpty())
   {
+    if (toPrintElapsedTime)
+    {
+      theDI << "Elapsed Time, sec: " << anAnimation->ElapsedTime() << "\n";
+    }
     return 0;
   }
 
+  ViewerTest::CurrentEventManager()->AbortViewAnimation();
+  ViewerTest::CurrentEventManager()->SetObjectsAnimation (Handle(AIS_Animation)());

Please restore logic with stopping playback and move `if (toPrintElapsedTime)` block outside of `toPlay` checks.

+Standard_Real AIS_Animation::ElapsedTime() const

I'm not sure it worth putting this logic into this method, as it would lead to different values with the timer.
Is there a reason why we cannot Seek() timer instead?
11Commenter 2
Branch [archived branch] has been updated forcibly by Commenter 1.

[revision removed]
12Commenter 2
Branch [archived branch] has been updated forcibly by Commenter 1.

[revision removed]
13Commenter 13
Combination -
OCCT branch : [archived branch]
master SHA - changes and them, and you can discard any commits you make in this
[revision removed]
changes and them, and you can discard any commits you make in this
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18666.730000000585 / 18776.180000000597 [-0.58%]
Products
Total CPU difference: 11867.75000000012 / 11959.870000000119 [-0.77%]
Windows-64-VC14:
OCCT
Total CPU difference: 20851.8125 / 20857.796875 [-0.03%]
Products
Total CPU difference: 14092.984375 / 14084.640625 [+0.06%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
14Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
15Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]