18 #include "data/model/Model.h" 19 #include "base/ZoomConstraint.h" 21 #include <QPaintEvent> 23 #include <QPainterPath> 31 m_clickedInRange(false),
34 setObjectName(tr(
"Overview"));
50 bool zoomChanged =
false;
53 ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) };
54 if (zoomLevel.level < 1) zoomLevel.level = 1;
64 auto model = ModelById::get((*i)->getModel());
65 if (model && (!model->isOK() || !model->isReady())) {
100 #ifdef DEBUG_OVERVIEW
105 #ifdef DEBUG_OVERVIEW 106 cerr <<
"Overview::globalCentreFrameChanged: " << f << endl;
113 #ifdef DEBUG_OVERVIEW
118 #ifdef DEBUG_OVERVIEW 119 cerr <<
"Overview[" <<
this <<
"]::viewCentreFrameChanged(" << v <<
"): " << f << endl;
129 if (v ==
this)
return;
138 #ifdef DEBUG_OVERVIEW 139 cerr <<
"Overview[" <<
this <<
"]::viewManagerPlaybackFrameChanged(" << f <<
"): " << f << endl;
142 bool changed =
false;
149 if (changed) update();
155 return Qt::transparent;
161 QColor c = palette().window().color();
179 #ifdef DEBUG_OVERVIEW 180 cerr <<
"Overview::paintEvent: width is " << width() <<
", centre frame " <<
m_centreFrame << endl;
185 ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) };
186 if (zoomLevel.level < 1) zoomLevel.level = 1;
193 sv_frame_t centreFrame = startFrame +
194 sv_frame_t(round(
m_zoomLevel.pixelsToFrames(width()/2)));
200 #ifdef DEBUG_OVERVIEW 201 cerr <<
"Overview::paintEvent: Centre frame changed from " 205 #ifdef DEBUG_OVERVIEW 215 paint.setClipRegion(e->region());
216 paint.setRenderHints(QPainter::Antialiasing);
224 std::set<std::pair<int, int> > extents;
225 std::vector<QRect> rects;
230 for (ViewSet::iterator i =
m_views.begin(); i !=
m_views.end(); ++i) {
250 if (x1 <= x0) x1 = x0 + 1;
252 std::pair<int, int> extent(x0, x1);
254 if (extents.find(extent) == extents.end()) {
256 y += height() / 10 + 1;
257 extents.insert(extent);
259 QRect vr(x0, y, x1 - x0, height() - 2 * y);
265 QPainterPath without;
266 without.addRoundedRect(primary, 4, 4);
267 without.addRect(rect());
268 paint.setPen(Qt::NoPen);
270 paint.drawPath(without);
273 paint.drawRoundedRect(primary, 4, 4);
275 foreach (QRect vr, rects) {
276 paint.setBrush(Qt::NoBrush);
278 paint.drawRoundedRect(vr, 4, 4);
293 for (ViewSet::iterator i =
m_views.begin(); i !=
m_views.end(); ++i) {
316 sv_frame_t frameOff = sv_frame_t(round(
m_zoomLevel.pixelsToFrames(xoff)));
320 newCentreFrame += frameOff;
321 }
else if (newCentreFrame >= -frameOff) {
322 newCentreFrame += frameOff;
329 if (newCentreFrame > 0) --newCentreFrame;
332 sv_frame_t pixel = sv_frame_t(round(
m_zoomLevel.pixelsToFrames(1)));
338 #ifdef DEBUG_OVERVIEW 339 cerr <<
"Overview::mouseMoveEvent: x " << e->x() <<
" and click x " <<
m_clickPos.x() <<
" -> frame " << newCentreFrame <<
" -> rf " << rf << endl;
356 #ifdef DEBUG_OVERVIEW 357 cerr <<
"Overview::mouseDoubleClickEvent: frame " << frame <<
" -> rf " << rf << endl;
QElapsedTimer m_modelTestTimer
void paintEvent(QPaintEvent *e) override
sv_frame_t m_dragCentreFrame
void viewCentreFrameChanged(View *, sv_frame_t) override
sv_frame_t alignFromReference(sv_frame_t) const
sv_frame_t m_playPointerFrame
virtual void modelChangedWithin(ModelId, sv_frame_t startFrame, sv_frame_t endFrame)
View scrolls continuously during playback, keeping the playback position at the centre.
ZoomLevel getZoomConstraintLevel(ZoomLevel level, ZoomConstraint::RoundingDirection dir=ZoomConstraint::RoundNearest) const
virtual void modelReplaced()
sv_frame_t alignToReference(sv_frame_t) const
void mouseMoveEvent(QMouseEvent *e) override
void leaveEvent(QEvent *) override
void centreFrameChanged(sv_frame_t frame, bool globalScroll, PlaybackFollowMode followMode)
void mouseReleaseEvent(QMouseEvent *e) override
void mousePressEvent(QMouseEvent *e) override
View follows playback page-by-page, but dragging the view relocates playback to the centre frame...
void enterEvent(QEvent *) override
sv_frame_t getFrameForX(int x) const override
Return the closest frame to the given pixel x-coordinate.
sv_frame_t getAlignedPlaybackFrame() const
void viewManagerPlaybackFrameChanged(sv_frame_t) override
void mouseDoubleClickEvent(QMouseEvent *e) override
QColor getFillWithout() const
View is detached from playback.
ModelId getAligningModel() const
!!
void viewZoomLevelChanged(View *, ZoomLevel, bool) override
QColor getFillWithin() const
void globalCentreFrameChanged(sv_frame_t) override
Overview(QWidget *parent=0)
PlaybackFollowMode m_followPlay
void contextHelpChanged(const QString &)
sv_frame_t getModelsStartFrame() const override
bool hasLightBackground() const override
void unregisterView(View *view)
virtual void setPlaybackFollow(PlaybackFollowMode m)
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
void paintEvent(QPaintEvent *e) override
void modelReplaced() override
sv_frame_t getStartFrame() const override
Retrieve the first visible sample frame on the widget.
void modelChangedWithin(ModelId, sv_frame_t startFrame, sv_frame_t endFrame) override
sv_frame_t getModelsEndFrame() const override
virtual void setBoxColour(QColor)
void registerView(View *view)
void zoomLevelChanged(ZoomLevel level, bool locked)
int getXForFrame(sv_frame_t frame) const override
Return the pixel x-coordinate corresponding to a given sample frame.