Don't creat zero minute legs for gas switchen when replanning

Gas switches appear as special samples with zero or one second duration.
Those can be confusing when they appear as zero duration in the dive plan
when replanning, so better suppress theose.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2017-01-23 16:37:04 +01:00 committed by Subsurface
parent 4cc4f5dd7b
commit 79bba04fd4

View file

@ -72,6 +72,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
recalc = false;
CylindersModel::instance()->updateDive();
duration_t lasttime = {};
duration_t lastrecordedtime = {};
duration_t newtime = {};
free_dps(&diveplan);
diveplan.when = d->when;
@ -103,7 +104,10 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
}
if (samplecount) {
int cylinderid = get_cylinderid_at_time(d, dc, lasttime);
addStop(depthsum / samplecount, newtime.seconds, cylinderid, 0, true);
if (newtime.seconds - lastrecordedtime.seconds > 10) {
addStop(depthsum / samplecount, newtime.seconds, cylinderid, 0, true);
lastrecordedtime = newtime;
}
lasttime = newtime;
depthsum = 0;
samplecount = 0;