CustusX  2021.04.21-dev+develop.337f9
An IGT application
cxPlaybackTime.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXPLAYBACKTIME_H_
13 #define CXPLAYBACKTIME_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include <QObject>
18 #include <QDateTime>
19 #include <QColor>
20 #include <QTimer>
21 #include <boost/shared_ptr.hpp>
22 
23 namespace cx
24 {
25 
38 class cxResource_EXPORT PlaybackTime : public QObject
39 {
40  Q_OBJECT
41 public:
42  PlaybackTime();
43  virtual ~PlaybackTime();
44 
45  void initialize(QDateTime start, qint64 length);
46 
47  void forward(qint64 msecs);
48  void rewind(qint64 msecs);
49  bool isPlaying() const;
50 
51  void setTime(QDateTime time);
52  QDateTime getTime() const;
53  void setOffset(qint64 val);
54  void moveOffset(qint64 delta);
55  qint64 getOffset() const;
56  qint64 getLength() const;
57  QDateTime getStartTime() const;
58  void setSpeed(double val);
59  double getSpeed() const;
60  void setResolution(qint64 val);
61  double getResolution();
62 
63 public slots:
64  void start();
65  void stop();
66  void pause();
67 
68 signals:
69  void changed();
70 private slots:
71  void timeoutSlot();
72 
73 private:
74  QDateTime mStartTime;
75 // QDateTime mTime;
76  qint64 mOffset;
77  qint64 mLength;
78  QTimer* mTimer;
79  double mSpeed;
80 
81  QDateTime mPlayStart;
82  qint64 mLastPlayOffset;
83 
84 };
85 
86 typedef boost::shared_ptr<PlaybackTime> PlaybackTimePtr;
87 
92 class cxResource_EXPORT TimelineEvent
93 {
94 public:
95  TimelineEvent() : mStartTime(0), mEndTime(0), mColor("black") {}
96  TimelineEvent(QString description, double start, double end) : mDescription(description), mStartTime(start), mEndTime(end) {}
97  TimelineEvent(QString description, double time) : mDescription(description), mStartTime(time), mEndTime(time) {}
98  QString mUid;
99  QString mDescription;
100  double mStartTime;
101  double mEndTime;
102  QColor mColor;
103  QString mGroup;
104  bool isInside(double time, double tol_ms=0) const;
105  bool isSingular() const;
106  bool isOverlap(const TimelineEvent& rhs) const;
107  bool operator<(const TimelineEvent& rhs) const;
108 };
109 
110 
111 } /* namespace cx */
112 #endif /* CXPLAYBACKTIME_H_ */
bool operator<(const Landmark &lhs, const Landmark &rhs)
Definition: cxLandmark.cpp:73
Scalar * end()
Description of one event in time.
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
TimelineEvent(QString description, double start, double end)
RealScalar length() const
TimelineEvent(QString description, double time)
Controller for historic time, playback etc.
Namespace for all CustusX production code.