v2.0.0
Loading...
Searching...
No Matches
timerulerwidget.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef TIMERULERWIDGET_H
36#define TIMERULERWIDGET_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "../../disp_global.h"
43
44//=============================================================================================================
45// QT INCLUDES
46//=============================================================================================================
47
48#include <QWidget>
49#include <QColor>
50#include <QVector>
51
52class QContextMenuEvent;
53
54//=============================================================================================================
55// DEFINE NAMESPACE DISPLIB
56//=============================================================================================================
57
58namespace DISPLIB
59{
60
61//=============================================================================================================
66 int sample = 0;
67 QColor color;
68 QString label;
69};
70
71//=============================================================================================================
76 int sample = 0;
77 QColor color;
78 QString label;
79};
80
81//=============================================================================================================
95class DISPSHARED_EXPORT TimeRulerWidget : public QWidget
96{
97 Q_OBJECT
98
99public:
100 explicit TimeRulerWidget(QWidget *parent = nullptr);
101
102 //=========================================================================================================
108 void setSfreq(double sfreq);
109
110 //=========================================================================================================
117 void setFirstFileSample(int firstFileSample);
118
119 static constexpr int kStimZoneH = 16;
120 static constexpr int kTimeZoneH = 28;
121 static constexpr int kTotalH = kStimZoneH + kTimeZoneH;
122
123 QSize sizeHint() const override { return QSize(100, kTotalH); }
124 QSize minimumSizeHint() const override { return QSize(50, kTotalH); }
125
126 //=========================================================================================================
133 void setEvents(const QVector<TimeRulerEventMark> &events);
134
135 //=========================================================================================================
141 void setReferenceMarkers(const QVector<TimeRulerReferenceMark> &markers);
142
143 //=========================================================================================================
147 void toggleTimeFormat();
148
149 //=========================================================================================================
155 void setClockTimeFormat(bool useClock);
156 bool clockTimeFormat() const { return m_useClockTime; }
157
158public slots:
159 //=========================================================================================================
165 void setScrollSample(float sample);
166
167 //=========================================================================================================
173 void setSamplesPerPixel(float spp);
174
175signals:
176 //=========================================================================================================
181
182 //=========================================================================================================
187
188 //=========================================================================================================
193
194protected:
195 void paintEvent(QPaintEvent *event) override;
196 void contextMenuEvent(QContextMenuEvent *event) override;
197
198private:
199 //=========================================================================================================
207 static double niceTickInterval(double visibleSeconds, int targetTicks = 7);
208
209 //=========================================================================================================
216 static QString formatTime(double seconds);
217
218 //=========================================================================================================
225 int sampleAtX(int x) const;
226
227 //=========================================================================================================
235 int nearestReferenceMarkerIndex(int sample, int tolerancePixels = 8) const;
236
237 double m_sfreq = 1.0;
238 int m_firstFileSample = 0;
239 float m_scrollSample = 0.f;
240 float m_spp = 1.f; // samples per pixel
241 bool m_useClockTime = false; // false = float seconds, true = HH:MM:SS
242
243 QVector<TimeRulerEventMark> m_events;
244 QVector<TimeRulerReferenceMark> m_referenceMarkers;
245};
246
247} // namespace DISPLIB
248
249#endif // TIMERULERWIDGET_H
disp library export/import macros.
#define DISPSHARED_EXPORT
Definition disp_global.h:51
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