From 1a429d9b17e55160babc569d475ed32658f895c8 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 9 Oct 2021 15:05:27 +0200 Subject: [PATCH] profile: don't plot event-icons outside of range Do this by extending the isInteresting() function for dive event items. Signed-off-by: Berthold Stoeger --- profile-widget/diveeventitem.cpp | 9 ++++++++- profile-widget/diveeventitem.h | 3 ++- profile-widget/profilescene.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index f756e2f33..b713b01a1 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -191,8 +191,15 @@ static int depthAtTime(const plot_info &pi, duration_t time) } bool DiveEventItem::isInteresting(const struct dive *d, const struct divecomputer *dc, - const struct event *ev, const plot_info &pi) + const struct event *ev, const plot_info &pi, + int firstSecond, int lastSecond) { + /* + * Ignore items outside of plot range + */ + if (ev->time.seconds < firstSecond || ev->time.seconds >= lastSecond) + return false; + /* * Some gas change events are special. Some dive computers just tell us the initial gas this way. * Don't bother showing those diff --git a/profile-widget/diveeventitem.h b/profile-widget/diveeventitem.h index 82e1773fb..d340f9cb9 100644 --- a/profile-widget/diveeventitem.h +++ b/profile-widget/diveeventitem.h @@ -23,7 +23,8 @@ public: void setHorizontalAxis(DiveCartesianAxis *axis); bool shouldBeHidden(); static bool isInteresting(const struct dive *d, const struct divecomputer *dc, - const struct event *ev, const struct plot_info &pi); + const struct event *ev, const struct plot_info &pi, + int firstSecond, int lastSecond); private: void setupToolTipString(struct gasmix lastgasmix); diff --git a/profile-widget/profilescene.cpp b/profile-widget/profilescene.cpp index ef5541519..8d422a52f 100644 --- a/profile-widget/profilescene.cpp +++ b/profile-widget/profilescene.cpp @@ -487,7 +487,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM continue; } } - if (DiveEventItem::isInteresting(d, currentdc, event, plotInfo)) { + if (DiveEventItem::isInteresting(d, currentdc, event, plotInfo, firstSecond, lastSecond)) { auto item = new DiveEventItem(d, event, lastgasmix, plotInfo, timeAxis, profileYAxis, animSpeed, *pixmaps); item->setZValue(2);