mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Mark manually entered waypoints as such
With this information, when we re-plan a dive we can bring the user right back to the point where they ended - they have the waypoints in the dive pointes table and handles are shown on the right points in the profile - and the rest of the dive is once again calculated by the planning algorithm. For now this state is lost when saving the dive file as we don't add this flag in the sample to our saved files. So if we don't find any samples marked as manually added we add ALL of the samples as way points on the diveplan and the user has to manually remove the ones that were calculated. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f7119bdccf
commit
5b0f4e79c4
3 changed files with 13 additions and 2 deletions
4
dive.h
4
dive.h
|
@ -163,7 +163,9 @@ struct sample // BASE TYPE BYTES UNITS RANGE DE
|
|||
uint8_t cns; // uint8_t 1 % (0-255 %) cns% accumulated
|
||||
uint8_t heartbeat; // uint8_t 1 beats/m (0-255) heart rate measurement
|
||||
bool in_deco; // bool 1 y/n y/n this sample is part of deco
|
||||
}; // Total size of structure: 48 bytes, excluding padding at end
|
||||
bool manually_entered; // bool 1 y/n y/n this sample was entered by the user,
|
||||
// not calculated when planning a dive
|
||||
}; // Total size of structure: 53 bytes, excluding padding at end
|
||||
|
||||
struct divetag {
|
||||
/*
|
||||
|
|
|
@ -278,6 +278,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas)
|
|||
sample->po2.mbar = dp->po2;
|
||||
if (track_gas && cyl->type.workingpressure.mbar)
|
||||
sample->cylinderpressure.mbar = cyl->end.mbar;
|
||||
sample->manually_entered = true;
|
||||
finish_sample(dc);
|
||||
while (dp) {
|
||||
struct gasmix gasmix = dp->gasmix;
|
||||
|
@ -316,6 +317,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas)
|
|||
sample[-1].po2.mbar = po2;
|
||||
sample->time.seconds = lasttime + 1;
|
||||
sample->depth.mm = lastdepth;
|
||||
sample->manually_entered = dp->entered;
|
||||
if (track_gas && cyl->type.workingpressure.mbar)
|
||||
sample->cylinderpressure.mbar = cyl->sample_end.mbar;
|
||||
finish_sample(dc);
|
||||
|
@ -329,6 +331,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, bool track_gas)
|
|||
sample->po2.mbar = po2;
|
||||
sample->time.seconds = lasttime = time;
|
||||
sample->depth.mm = lastdepth = depth;
|
||||
sample->manually_entered = dp->entered;
|
||||
if (track_gas) {
|
||||
update_cylinder_pressure(&displayed_dive, sample[-1].depth.mm, depth, time - sample[-1].time.seconds,
|
||||
dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl, !dp->entered);
|
||||
|
|
|
@ -111,10 +111,16 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
|
|||
CylindersModel::instance()->updateDive();
|
||||
duration_t lasttime = {};
|
||||
struct gasmix gas;
|
||||
free_dps(&diveplan);
|
||||
diveplan.when = d->when;
|
||||
// is this a "new" dive where we marked manually entered samples?
|
||||
// if yes then the first sample should be marked
|
||||
// if it is we only add the manually entered samples as waypoints to the diveplan
|
||||
// otherwise we have to add all of them
|
||||
bool hasMarkedSamples = d->dc.sample[0].manually_entered;
|
||||
for (int i = 0; i < d->dc.samples - 1; i++) {
|
||||
const sample &s = d->dc.sample[i];
|
||||
if (s.time.seconds == 0)
|
||||
if (s.time.seconds == 0 || (hasMarkedSamples && !s.manually_entered))
|
||||
continue;
|
||||
get_gas_at_time(d, &d->dc, lasttime, &gas);
|
||||
plannerModel->addStop(s.depth.mm, s.time.seconds, &gas, 0, true);
|
||||
|
|
Loading…
Add table
Reference in a new issue