v2.0.0
Loading...
Searching...
No Matches
timerulerwidget.h
Go to the documentation of this file.
1//=============================================================================================================
18
19#ifndef TIMERULERWIDGET_H
20#define TIMERULERWIDGET_H
21
22//=============================================================================================================
23// INCLUDES
24//=============================================================================================================
25
26#include "../../disp_global.h"
27
28//=============================================================================================================
29// QT INCLUDES
30//=============================================================================================================
31
32#include <QWidget>
33#include <QColor>
34#include <QVector>
35
36class QContextMenuEvent;
37
38//=============================================================================================================
39// DEFINE NAMESPACE DISPLIB
40//=============================================================================================================
41
42namespace DISPLIB
43{
44
45//=============================================================================================================
50{
51 int sample = 0;
52 QColor color;
53 QString label;
54};
55
56//=============================================================================================================
61{
62 int sample = 0;
63 QColor color;
64 QString label;
65};
66
67//=============================================================================================================
76class DISPSHARED_EXPORT TimeRulerWidget : public QWidget
77{
78 Q_OBJECT
79
80public:
81 explicit TimeRulerWidget(QWidget* parent = nullptr);
82
83 //=========================================================================================================
89 void setSfreq(double sfreq);
90
91 //=========================================================================================================
98 void setFirstFileSample(int firstFileSample);
99
100 static constexpr int kStimZoneH = 16;
101 static constexpr int kTimeZoneH = 28;
102 static constexpr int kTotalH = kStimZoneH + kTimeZoneH;
103
104 QSize sizeHint() const override
105 {
106 return QSize(100, kTotalH);
107 }
108 QSize minimumSizeHint() const override
109 {
110 return QSize(50, kTotalH);
111 }
112
113 //=========================================================================================================
120 void setEvents(const QVector<TimeRulerEventMark>& events);
121
122 //=========================================================================================================
128 void setReferenceMarkers(const QVector<TimeRulerReferenceMark>& markers);
129
130 //=========================================================================================================
134 void toggleTimeFormat();
135
136 //=========================================================================================================
142 void setClockTimeFormat(bool useClock);
143 bool clockTimeFormat() const
144 {
145 return m_useClockTime;
146 }
147
148public slots:
149 //=========================================================================================================
155 void setScrollSample(float sample);
156
157 //=========================================================================================================
163 void setSamplesPerPixel(float spp);
164
165signals:
166 //=========================================================================================================
171
172 //=========================================================================================================
177
178 //=========================================================================================================
183
184protected:
185 void paintEvent(QPaintEvent* event) override;
186 void contextMenuEvent(QContextMenuEvent* event) override;
187
188private:
189 //=========================================================================================================
197 static double niceTickInterval(double visibleSeconds, int targetTicks = 7);
198
199 //=========================================================================================================
206 static QString formatTime(double seconds);
207
208 //=========================================================================================================
215 int sampleAtX(int x) const;
216
217 //=========================================================================================================
225 int nearestReferenceMarkerIndex(int sample, int tolerancePixels = 8) const;
226
227 double m_sfreq = 1.0;
228 int m_firstFileSample = 0;
229 float m_scrollSample = 0.f;
230 float m_spp = 1.f; // samples per pixel
231 bool m_useClockTime = false; // false = float seconds, true = HH:MM:SS
232
233 QVector<TimeRulerEventMark> m_events;
234 QVector<TimeRulerReferenceMark> m_referenceMarkers;
235};
236
237} // namespace DISPLIB
238
239#endif // TIMERULERWIDGET_H
Export macros and build-info hooks for the DISPLIB shared library.
#define DISPSHARED_EXPORT
Definition disp_global.h:38
2-D display widgets and visualisation helpers (charts, topography, colour maps).
Lightweight event mark passed to TimeRulerWidget for the stim lane.
QColor color
Display colour.
QString label
Short text (event type number).
int sample
Absolute sample index.
Lightweight reference/sample marker passed to TimeRulerWidget.
QString label
Short text identifier, e.g. M1.
int sample
Absolute sample index.
static constexpr int kTotalH
Total widget height (px).
void setSfreq(double sfreq)
TimeRulerWidget(QWidget *parent=nullptr)
void contextMenuEvent(QContextMenuEvent *event) override
static constexpr int kTimeZoneH
Height of the time-tick zone (px).
static constexpr int kStimZoneH
Height of the stimulus lane (px).
void setFirstFileSample(int firstFileSample)
void removeReferenceMarkerRequested(int sample)
QSize sizeHint() const override
void addReferenceMarkerRequested(int sample)
QSize minimumSizeHint() const override
void paintEvent(QPaintEvent *event) override