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 int sample = 0;
51 QColor color;
52 QString label;
53};
54
55//=============================================================================================================
60 int sample = 0;
61 QColor color;
62 QString label;
63};
64
65//=============================================================================================================
74class DISPSHARED_EXPORT TimeRulerWidget : public QWidget
75{
76 Q_OBJECT
77
78public:
79 explicit TimeRulerWidget(QWidget *parent = nullptr);
80
81 //=========================================================================================================
87 void setSfreq(double sfreq);
88
89 //=========================================================================================================
96 void setFirstFileSample(int firstFileSample);
97
98 static constexpr int kStimZoneH = 16;
99 static constexpr int kTimeZoneH = 28;
100 static constexpr int kTotalH = kStimZoneH + kTimeZoneH;
101
102 QSize sizeHint() const override { return QSize(100, kTotalH); }
103 QSize minimumSizeHint() const override { return QSize(50, kTotalH); }
104
105 //=========================================================================================================
112 void setEvents(const QVector<TimeRulerEventMark> &events);
113
114 //=========================================================================================================
120 void setReferenceMarkers(const QVector<TimeRulerReferenceMark> &markers);
121
122 //=========================================================================================================
126 void toggleTimeFormat();
127
128 //=========================================================================================================
134 void setClockTimeFormat(bool useClock);
135 bool clockTimeFormat() const { return m_useClockTime; }
136
137public slots:
138 //=========================================================================================================
144 void setScrollSample(float sample);
145
146 //=========================================================================================================
152 void setSamplesPerPixel(float spp);
153
154signals:
155 //=========================================================================================================
160
161 //=========================================================================================================
166
167 //=========================================================================================================
172
173protected:
174 void paintEvent(QPaintEvent *event) override;
175 void contextMenuEvent(QContextMenuEvent *event) override;
176
177private:
178 //=========================================================================================================
186 static double niceTickInterval(double visibleSeconds, int targetTicks = 7);
187
188 //=========================================================================================================
195 static QString formatTime(double seconds);
196
197 //=========================================================================================================
204 int sampleAtX(int x) const;
205
206 //=========================================================================================================
214 int nearestReferenceMarkerIndex(int sample, int tolerancePixels = 8) const;
215
216 double m_sfreq = 1.0;
217 int m_firstFileSample = 0;
218 float m_scrollSample = 0.f;
219 float m_spp = 1.f; // samples per pixel
220 bool m_useClockTime = false; // false = float seconds, true = HH:MM:SS
221
222 QVector<TimeRulerEventMark> m_events;
223 QVector<TimeRulerReferenceMark> m_referenceMarkers;
224};
225
226} // namespace DISPLIB
227
228#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