diff options
author | Jan Mulder <jlmulder@xs4all.nl> | 2017-04-20 08:43:48 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-04-20 10:57:11 -0700 |
commit | abbb0a244d22b9d83ed65496f75f388aea73d999 (patch) | |
tree | 3e586a5e469ceba864534b5b9fe3a51168c1d8e9 /qt-models/diveplannermodel.cpp | |
parent | 89b914e47dc2f996e5bd0d80dfba5e9b00b28631 (diff) | |
download | subsurface-abbb0a244d22b9d83ed65496f75f388aea73d999.tar.gz |
Handle CCR setpoint when replanning a dive
When replanning a dive, the setpoint information from the profile waypoints
were reset to 0, resulting in a dive that has a dive mode of CCR, but only with
OC legs in the profile. This is just wrong, and is corrected here. Notice
that there is no averaging involved (in the reduction of a replanned real
dive that has more than 100 waypoints) as is done for depth. This is just
fine for setpoint data.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 29dda8c6a..dc0fe9ffa 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -69,6 +69,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) { int depthsum = 0; int samplecount = 0; + o2pressure_t last_sp; bool oldRec = recalc; struct divecomputer *dc = &(d->dc); recalc = false; @@ -97,11 +98,13 @@ void DivePlannerPointsModel::loadFromDive(dive *d) int plansamples = dc->samples <= 100 ? dc->samples : 100; int j = 0; int cylinderid = 0; + last_sp.mbar = 0; for (int i = 0; i < plansamples - 1; i++) { while (j * plansamples <= i * dc->samples) { const sample &s = dc->sample[j]; if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) { depthsum += s.depth.mm; + last_sp = s.setpoint; ++samplecount; newtime = s.time; } @@ -110,7 +113,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) if (samplecount) { cylinderid = get_cylinderid_at_time(d, dc, lasttime); if (newtime.seconds - lastrecordedtime.seconds > 10) { - addStop(depthsum / samplecount, newtime.seconds, cylinderid, 0, true); + addStop(depthsum / samplecount, newtime.seconds, cylinderid, last_sp.mbar, true); lastrecordedtime = newtime; } lasttime = newtime; @@ -119,7 +122,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) } } // make sure we get the last point right so the duration is correct - if (!hasMarkedSamples) addStop(0, d->dc.duration.seconds,cylinderid, 0, true); + if (!hasMarkedSamples) addStop(0, d->dc.duration.seconds,cylinderid, last_sp.mbar, true); recalc = oldRec; emitDataChanged(); } |