Choreonoid  1.8
TimeBar.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_TIME_BAR_H
6 #define CNOID_BASE_TIME_BAR_H
7 
8 #include <cnoid/ToolBar>
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
13 class ExtensionManager;
14 
15 class CNOID_EXPORT TimeBar : public ToolBar
16 {
17 public:
18  static void initialize(ExtensionManager* ext);
19  static TimeBar* instance();
20 
21  ~TimeBar();
22 
27  SignalProxy<bool(double time), LogicalProduct> sigPlaybackInitialized();
28 
29  SignalProxy<void(double time)> sigPlaybackStarted();
30 
31  SignalProxy<bool(double time), LogicalSum> sigTimeChanged();
32 
33  SignalProxy<void(double time, bool isStoppedManually)> sigPlaybackStopped();
34 
35  inline double time() const { return time_; }
36 
37  bool setTime(double time);
38 
39  double realPlaybackTime() const;
40 
41  double minTime() const;
42  double maxTime() const;
43 
44  void setTimeRange(double min, double max);
45 
46  inline double frameRate() const { return frameRate_; }
47  void setFrameRate(double rate);
48 
49  inline double timeStep() const { return 1.0 / frameRate_; }
50 
51  inline bool isBeatMode() const { return isBeatMode_; }
52  inline double beatOffset() const { return beatOffset_; }
53  inline double tempo() const { return tempo_; }
54  double timeOfBeatLocation(double beatLocation) const;
55  double beatLocationOfTime(double time) const;
56  inline int beatNumerator() const { return beatNumerator_; }
57  inline int beatDenominator() const { return beatDenominator_; }
58 
59  double playbackSpeedScale() const;
60  void setPlaybackSpeedScale(double scale);
61 
62  double playbackFrameRate() const;
63  void setPlaybackFrameRate(double rate);
64 
65  void setRepeatMode(bool on);
66 
67  void startPlayback();
68  void startPlayback(double time);
69  void stopPlayback(bool isStoppedManually = false);
70  bool isDoingPlayback();
71 
72  int startOngoingTimeUpdate(double time = 0.0);
73  void updateOngoingTime(int id, double time);
74  void stopOngoingTimeUpdate(int id);
75  void setOngoingTimeSyncEnabled(bool on);
76 
77  [[deprecated]]
78  void startPlaybackFromFillLevel() { startPlayback(); }
79  [[deprecated]]
80  int startFillLevelUpdate(double time = 0.0) { return startOngoingTimeUpdate(time); }
81  [[deprecated]]
82  void updateFillLevel(int id, double time) { updateOngoingTime(id, time); }
83  [[deprecated]]
84  void stopFillLevelUpdate(int id) { stopOngoingTimeUpdate(id); }
85  [[deprecated]]
86  void setFillLevelSync(bool on) { setOngoingTimeSyncEnabled(on); }
87 
88  virtual int stretchableDefaultWidth() const;
89 
90 protected:
91 
92  virtual bool storeState(Archive& archive);
93  virtual bool restoreState(const Archive& archive);
94 
95 private:
96  TimeBar();
97 
98  class Impl;
99  Impl* impl;
100  double time_;
101  double frameRate_;
102  bool isBeatMode_;
103  double beatOffset_;
104  double tempo_;
105  int beatNumerator_;
106  int beatDenominator_;
107 };
108 
109 }
110 
111 #endif
cnoid::TimeBar::frameRate
double frameRate() const
Definition: TimeBar.h:46
cnoid::TimeBar::isBeatMode
bool isBeatMode() const
Definition: TimeBar.h:51
cnoid::TimeBar::updateFillLevel
void updateFillLevel(int id, double time)
Definition: TimeBar.h:82
cnoid::TimeBar::startPlaybackFromFillLevel
void startPlaybackFromFillLevel()
Definition: TimeBar.h:78
cnoid::TimeBar::beatOffset
double beatOffset() const
Definition: TimeBar.h:52
cnoid::ToolBar
Definition: ToolBar.h:22
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::TimeBar
Definition: TimeBar.h:15
cnoid::Archive
Definition: Archive.h:22
cnoid::TimeBar::tempo
double tempo() const
Definition: TimeBar.h:53
cnoid::TimeBar::setFillLevelSync
void setFillLevelSync(bool on)
Definition: TimeBar.h:86
cnoid::TimeBar::beatDenominator
int beatDenominator() const
Definition: TimeBar.h:57
cnoid::TimeBar::stopFillLevelUpdate
void stopFillLevelUpdate(int id)
Definition: TimeBar.h:84
cnoid::TimeBar::startFillLevelUpdate
int startFillLevelUpdate(double time=0.0)
Definition: TimeBar.h:80
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::LogicalProduct
Definition: Signal.h:429
cnoid::TimeBar::timeStep
double timeStep() const
Definition: TimeBar.h:49
cnoid::TimeBar::time
double time() const
Definition: TimeBar.h:35
cnoid::SignalProxy
Definition: Signal.h:470
cnoid::TimeBar::beatNumerator
int beatNumerator() const
Definition: TimeBar.h:56
cnoid::LogicalSum
Definition: Signal.h:447