1beb58d7 |
1 | // Created by: Kirill Gavrilov |
2 | // Copyright (c) 2016 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
15 | #include <AIS_AnimationTimer.hxx> |
16 | |
17 | IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationTimer, Standard_Transient) |
18 | |
19 | //============================================================================= |
20 | //function : Pause |
21 | //purpose : |
22 | //============================================================================= |
23 | void AIS_AnimationTimer::Pause() |
24 | { |
25 | myTimer.Stop(); |
26 | myTimerFrom += myTimer.ElapsedTime() * myTimerSpeed; |
27 | myTimer.Reset(); |
28 | } |
29 | |
30 | //============================================================================= |
31 | //function : Stop |
32 | //purpose : |
33 | //============================================================================= |
34 | void AIS_AnimationTimer::Stop() |
35 | { |
36 | myTimer.Stop(); |
37 | myTimer.Reset(); |
38 | myTimerFrom = 0.0; |
39 | } |
40 | |
41 | //============================================================================= |
42 | //function : SetPlaybackSpeed |
43 | //purpose : |
44 | //============================================================================= |
45 | void AIS_AnimationTimer::SetPlaybackSpeed (const Standard_Real theSpeed) |
46 | { |
47 | if (!myTimer.IsStarted()) |
48 | { |
49 | myTimerSpeed = theSpeed; |
50 | return; |
51 | } |
52 | |
53 | myTimer.Stop(); |
54 | myTimerFrom += myTimer.ElapsedTime() * myTimerSpeed; |
55 | myTimer.Reset(); |
56 | myTimerSpeed = theSpeed; |
57 | myTimer.Start(); |
58 | } |
59 | |
60 | //============================================================================= |
61 | //function : SetPlaybackSpeed |
62 | //purpose : |
63 | //============================================================================= |
64 | void AIS_AnimationTimer::Seek (const Standard_Real theTime) |
65 | { |
66 | const Standard_Boolean isStarted = myTimer.IsStarted(); |
67 | myTimer.Stop(); |
68 | myTimer.Reset(); |
69 | myTimerFrom = theTime; |
70 | if (isStarted) |
71 | { |
72 | myTimer.Start(); |
73 | } |
74 | } |