0027764: Visualization - add functionality for animation of 3D camera and interactive...
[occt.git] / src / AIS / AIS_AnimationTimer.hxx
diff --git a/src/AIS/AIS_AnimationTimer.hxx b/src/AIS/AIS_AnimationTimer.hxx
new file mode 100644 (file)
index 0000000..14add51
--- /dev/null
@@ -0,0 +1,74 @@
+// Created by: Kirill Gavrilov
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_AnimationTimer_HeaderFile
+#define _AIS_AnimationTimer_HeaderFile
+
+#include <OSD_Timer.hxx>
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
+
+//! Auxiliary class defining the animation timer.
+class AIS_AnimationTimer : public Standard_Transient
+{
+  DEFINE_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient)
+public:
+
+  //! Empty constructor.
+  AIS_AnimationTimer() : myTimerFrom (0.0), myTimerSpeed (1.0) {}
+
+  //! Return elapsed time in seconds.
+  Standard_Real ElapsedTime() const
+  {
+    return myTimerFrom + myTimer.ElapsedTime() * myTimerSpeed;
+  }
+
+  //! Return playback speed coefficient (1.0 means normal speed).
+  Standard_Real PlaybackSpeed() const { return myTimerSpeed; }
+
+  //! Setup playback speed coefficient.
+  Standard_EXPORT void SetPlaybackSpeed (const Standard_Real theSpeed);
+
+  //! Return true if timer has been started.
+  Standard_Boolean IsStarted() const
+  {
+    return myTimer.IsStarted();
+  }
+
+  //! Start the timer.
+  void Start()
+  {
+    myTimer.Start();
+  }
+
+  //! Pause the timer.
+  Standard_EXPORT void Pause();
+
+  //! Stop the timer.
+  Standard_EXPORT void Stop();
+
+  //! Seek the timer to specified position.
+  Standard_EXPORT void Seek (const Standard_Real theTime);
+
+protected:
+
+  OSD_Timer     myTimer;
+  Standard_Real myTimerFrom;
+  Standard_Real myTimerSpeed;
+
+};
+
+DEFINE_STANDARD_HANDLE(AIS_AnimationTimer, Standard_Transient)
+
+#endif // _AIS_AnimationTimer_HeaderFile