profile: fix instant logic

There was logic to disable animation when switching from "no dive"
to "show dive". However, that has bit-rotted away: the plotted
dive was set before plotting the dive and therefore the check
for "change from empty" did not work. Introduce an explicit
empty flag instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-12-03 08:50:52 +01:00 committed by Dirk Hohndel
parent e7b078a7fd
commit f13768fe65
2 changed files with 8 additions and 7 deletions

View file

@ -56,6 +56,7 @@ ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double dp
#endif
d(nullptr),
dc(0),
empty(true),
#ifndef SUBSURFACE_MOBILE
mouseFollowerVertical(new DiveLineItem()),
mouseFollowerHorizontal(new DiveLineItem()),
@ -187,10 +188,6 @@ void ProfileWidget2::resetZoom()
// Currently just one dive, but the plan is to enable All of the selected dives.
void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, int flags)
{
// If there was no previously displayed dive, turn off animations
if (!d)
flags |= RenderFlags::Instant;
d = dIn;
dc = dcIn;
if (!d) {
@ -198,6 +195,11 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, int flags)
return;
}
// If there was no previously displayed dive, turn off animations
if (empty)
flags |= RenderFlags::Instant;
empty = false;
QElapsedTimer measureDuration; // let's measure how long this takes us (maybe we'll turn of TTL calculation later
measureDuration.start();
@ -390,6 +392,7 @@ void ProfileWidget2::clear()
profileScene->clear();
handles.clear();
gases.clear();
empty = true;
}
void ProfileWidget2::setProfileState(const dive *dIn, int dcIn)

View file

@ -146,11 +146,9 @@ private:
#ifndef SUBSURFACE_MOBILE
ToolTipItem *toolTipItem;
#endif
// All those here should probably be merged into one structure,
// So it's esyer to replicate for more dives later.
// In the meantime, keep it here.
const struct dive *d;
int dc;
bool empty; // No dive shown.
#ifndef SUBSURFACE_MOBILE
DiveLineItem *mouseFollowerVertical;
DiveLineItem *mouseFollowerHorizontal;