These two patches implement suggestions from trac. Best Robert
From 040b804c1c451963531db6d0da31e61b853747ae Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Thu, 15 Dec 2016 23:02:32 +0100 Subject: [PATCH 1/2] Set surface pressure and salinity correctly when replanning To: [email protected] We need to initialize the UI elements accordingly. Fixes #1094 Signed-off-by: Robert C. Helling <[email protected]> --- desktop-widgets/diveplanner.cpp | 10 ++++++++++ desktop-widgets/diveplanner.h | 2 ++ desktop-widgets/mainwindow.cpp | 2 ++ 3 files changed, 14 insertions(+) diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index b12feab..ee85d12 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -181,6 +181,16 @@ void DivePlannerWidget::setupStartTime(QDateTime startTime) ui.dateEdit->setDate(startTime.date()); } +void DivePlannerWidget::setSurfacePressure(int surface_pressure) +{ + ui.ATMPressure->setValue(surface_pressure); +} + +void DivePlannerWidget::setSalinity(int salinity) +{ + ui.salinity->setValue(salinity / 10000.0); +} + void DivePlannerWidget::settingsChanged() { // Adopt units diff --git a/desktop-widgets/diveplanner.h b/desktop-widgets/diveplanner.h index cf3a172..91501ce 100644 --- a/desktop-widgets/diveplanner.h +++ b/desktop-widgets/diveplanner.h @@ -52,6 +52,8 @@ slots: void heightChanged(const int height); void salinityChanged(const double salinity); void printDecoPlan(); + void setSurfacePressure(int surface_pressure); + void setSalinity(int salinity); private: Ui::DivePlanner ui; diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 2143663..5231961 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -914,6 +914,8 @@ void MainWindow::on_actionReplanDive_triggered() setApplicationState("PlanDive"); divePlannerWidget()->setReplanButton(true); divePlannerWidget()->setupStartTime(QDateTime::fromMSecsSinceEpoch(1000 * current_dive->when, Qt::UTC)); + divePlannerWidget()->setSurfacePressure(current_dive->surface_pressure.mbar); + divePlannerWidget()->setSalinity(current_dive->salinity); DivePlannerPointsModel::instance()->loadFromDive(current_dive); reset_cylinders(&displayed_dive, true); } -- 2.10.1 (Apple Git-78)
From af3dd29ddc3b4edd60fb9fed19fc2d0995e80346 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Thu, 15 Dec 2016 23:22:54 +0100 Subject: [PATCH 2/2] Indicate a repetitive dive in the diveplan To: [email protected] Fixes #1095 Signed-off-by: Robert C. Helling <[email protected]> --- core/dive.h | 1 + core/divelist.c | 9 ++++++--- core/divelist.h | 2 +- core/planner.c | 18 +++++++++++------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/core/dive.h b/core/dive.h index 4a314da..aa6352d 100644 --- a/core/dive.h +++ b/core/dive.h @@ -860,6 +860,7 @@ struct diveplan { short vpmb_conservatism; struct divedatapoint *dp; int eff_gflow, eff_gfhigh; + bool repetitive; }; struct divedatapoint *plan_add_segment(struct diveplan *diveplan, int duration, int depth, int cylinderid, int po2, bool entered); diff --git a/core/divelist.c b/core/divelist.c index fa100c2..f4762dd 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -360,7 +360,8 @@ int get_divesite_idx(struct dive_site *ds) static struct gasmix air = { .o2.permille = O2_IN_AIR, .he.permille = 0 }; /* take into account previous dives until there is a 48h gap between dives */ -double init_decompression(struct dive *dive) +/* return true if this is a repetitive dive */ +bool init_decompression(struct dive *dive) { int i, divenr = -1; unsigned int surface_time; @@ -369,7 +370,7 @@ double init_decompression(struct dive *dive) double surface_pressure; if (!dive) - return 0.0; + return false; surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0; divenr = get_divenr(dive); @@ -445,7 +446,9 @@ double init_decompression(struct dive *dive) dump_tissues(); #endif } - return tissue_tolerance_calc(dive, surface_pressure); + // I do not dare to remove this call. We don't need the result but it might have side effects. Bummer. + tissue_tolerance_calc(dive, surface_pressure); + return deco_init; } void update_cylinder_related_info(struct dive *dive) diff --git a/core/divelist.h b/core/divelist.h index 7a35fb2..f36766f 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -14,7 +14,7 @@ extern void update_cylinder_related_info(struct dive *); extern void mark_divelist_changed(int); extern int unsaved_changes(void); extern void remove_autogen_trips(void); -extern double init_decompression(struct dive *dive); +extern bool init_decompression(struct dive *dive); /* divelist core logic functions */ extern void process_dives(bool imported, bool prefer_imported); diff --git a/core/planner.c b/core/planner.c index ccb71c3..5bc7e82 100644 --- a/core/planner.c +++ b/core/planner.c @@ -128,7 +128,7 @@ void interpolate_transition(struct dive *dive, duration_t t0, duration_t t1, dep } /* returns the tissue tolerance at the end of this (partial) dive */ -void tissue_at_end(struct dive *dive, char **cached_datap) +bool tissue_at_end(struct dive *dive, char **cached_datap) { struct divecomputer *dc; struct sample *sample, *psample; @@ -136,18 +136,19 @@ void tissue_at_end(struct dive *dive, char **cached_datap) depth_t lastdepth = {}; duration_t t0 = {}, t1 = {}; struct gasmix gas; + bool repetitive = false; if (!dive) - return; + return false; if (*cached_datap) { restore_deco_state(*cached_datap); } else { - init_decompression(dive); + repetitive = init_decompression(dive); cache_deco_state(cached_datap); } dc = &dive->dc; if (!dc->samples) - return; + return false; psample = sample = dc->sample; for (i = 0; i < dc->samples; i++, sample++) { @@ -190,6 +191,7 @@ void tissue_at_end(struct dive *dive, char **cached_datap) psample = sample; t0 = t1; } + return repetitive; } @@ -594,8 +596,10 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool snprintf(temp, sz_temp, translate("gettextFromC", "recreational mode based on Bühlmann ZHL-16B with GFlow = %d and GFhigh = %d"), diveplan->gflow, diveplan->gfhigh); } - len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s</b><br>%s</div>", - translate("gettextFromC", "Subsurface dive plan"), temp); + len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s%s</b><br>%s</div>", + translate("gettextFromC", "Subsurface dive plan"), + diveplan->repetitive ? translate("gettextFromC", " (repetitive)") : "", + temp); len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>Runtime: %dmin</div><br>"), diveplan_duration(diveplan)); @@ -1082,7 +1086,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool gi = gaschangenr - 1; /* Set tissue tolerance and initial vpmb gradient at start of ascent phase */ - tissue_at_end(&displayed_dive, cached_datap); + diveplan->repetitive = tissue_at_end(&displayed_dive, cached_datap); nuclear_regeneration(clock); vpmb_start_gradient(); -- 2.10.1 (Apple Git-78)
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
