mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
planner: pass in_planner argument to decoMode()
To remove reliance on global state, pass an "in_planner" argument to decoMode(). Thus, calls to in_planner() can be removed. This is a more-or-less automated change. Ultimately it would probably be better to pass the current deco-mode to the affected functions instead of calling decoMode() with an in_planner parameter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
03a7e65cf0
commit
642d9c80b3
12 changed files with 51 additions and 51 deletions
12
core/deco.c
12
core/deco.c
|
@ -217,7 +217,7 @@ static double vpmb_tolerated_ambient_pressure(struct deco_state *ds, double refe
|
|||
return ds->tissue_n2_sat[ci] + ds->tissue_he_sat[ci] + vpmb_config.other_gases_pressure - total_gradient;
|
||||
}
|
||||
|
||||
double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, double pressure)
|
||||
double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, double pressure, bool in_planner)
|
||||
{
|
||||
int ci = -1;
|
||||
double ret_tolerance_limit_ambient_pressure = 0.0;
|
||||
|
@ -232,7 +232,7 @@ double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, dou
|
|||
ds->buehlmann_inertgas_b[ci] = ((buehlmann_N2_b[ci] * ds->tissue_n2_sat[ci]) + (buehlmann_He_b[ci] * ds->tissue_he_sat[ci])) / ds->tissue_inertgas_saturation[ci];
|
||||
}
|
||||
|
||||
if (decoMode() != VPMB) {
|
||||
if (decoMode(in_planner) != VPMB) {
|
||||
for (ci = 0; ci < 16; ci++) {
|
||||
|
||||
/* tolerated = (tissue_inertgas_saturation - buehlmann_inertgas_a) * buehlmann_inertgas_b; */
|
||||
|
@ -310,7 +310,7 @@ static double factor(int period_in_seconds, int ci, enum gas_component gas)
|
|||
|
||||
static double calc_surface_phase(double surface_pressure, double he_pressure, double n2_pressure, double he_time_constant, double n2_time_constant, bool in_planner)
|
||||
{
|
||||
double inspired_n2 = (surface_pressure - ((in_planner && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * NITROGEN_FRACTION;
|
||||
double inspired_n2 = (surface_pressure - ((in_planner && (decoMode(true) == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * NITROGEN_FRACTION;
|
||||
|
||||
if (n2_pressure > inspired_n2)
|
||||
return (he_pressure / he_time_constant + (n2_pressure - inspired_n2) / n2_time_constant) / (he_pressure + n2_pressure - inspired_n2);
|
||||
|
@ -450,7 +450,7 @@ void add_segment(struct deco_state *ds, double pressure, struct gasmix gasmix, i
|
|||
int ci;
|
||||
struct gas_pressures pressures;
|
||||
bool icd = false;
|
||||
fill_pressures(&pressures, pressure - ((in_planner && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE),
|
||||
fill_pressures(&pressures, pressure - ((in_planner && (decoMode(true) == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE),
|
||||
gasmix, (double) ccpo2 / 1000.0, divemode);
|
||||
|
||||
for (ci = 0; ci < 16; ci++) {
|
||||
|
@ -471,7 +471,7 @@ void add_segment(struct deco_state *ds, double pressure, struct gasmix gasmix, i
|
|||
ds->tissue_inertgas_saturation[ci] = ds->tissue_n2_sat[ci] + ds->tissue_he_sat[ci];
|
||||
|
||||
}
|
||||
if (decoMode() == VPMB)
|
||||
if (decoMode(in_planner) == VPMB)
|
||||
calc_crushing_pressure(ds, pressure);
|
||||
ds->icd_warning = icd;
|
||||
return;
|
||||
|
@ -510,7 +510,7 @@ void clear_deco(struct deco_state *ds, double surface_pressure, bool in_planner)
|
|||
memset(ds, 0, sizeof(*ds));
|
||||
clear_vpmb_state(ds);
|
||||
for (ci = 0; ci < 16; ci++) {
|
||||
ds->tissue_n2_sat[ci] = (surface_pressure - ((in_planner && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * N2_IN_AIR / 1000;
|
||||
ds->tissue_n2_sat[ci] = (surface_pressure - ((in_planner && (decoMode(true) == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * N2_IN_AIR / 1000;
|
||||
ds->tissue_he_sat[ci] = 0.0;
|
||||
ds->max_n2_crushing_pressure[ci] = 0.0;
|
||||
ds->max_he_crushing_pressure[ci] = 0.0;
|
||||
|
|
|
@ -61,7 +61,7 @@ extern void restore_deco_state(struct deco_state *data, struct deco_state *targe
|
|||
extern void nuclear_regeneration(struct deco_state *ds, double time);
|
||||
extern void vpmb_start_gradient(struct deco_state *ds);
|
||||
extern void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_pressure, bool in_planner);
|
||||
extern double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, double pressure);
|
||||
extern double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, double pressure, bool in_planner);
|
||||
extern void calc_crushing_pressure(struct deco_state *ds, double pressure);
|
||||
extern void vpmb_start_gradient(struct deco_state *ds);
|
||||
extern void clear_vpmb_state(struct deco_state *ds);
|
||||
|
|
|
@ -580,7 +580,7 @@ int init_decompression(struct deco_state *ds, const struct dive *dive, bool in_p
|
|||
}
|
||||
|
||||
// I do not dare to remove this call. We don't need the result but it might have side effects. Bummer.
|
||||
tissue_tolerance_calc(ds, dive, surface_pressure);
|
||||
tissue_tolerance_calc(ds, dive, surface_pressure, in_planner);
|
||||
return surface_time;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,12 +158,12 @@ static int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_s
|
|||
* portion of the dive.
|
||||
* Remember the value for later.
|
||||
*/
|
||||
if ((decoMode() == VPMB) && (lastdepth.mm > sample->depth.mm)) {
|
||||
if ((decoMode(true) == VPMB) && (lastdepth.mm > sample->depth.mm)) {
|
||||
pressure_t ceiling_pressure;
|
||||
nuclear_regeneration(ds, t0.seconds);
|
||||
vpmb_start_gradient(ds);
|
||||
ceiling_pressure.mbar = depth_to_mbar(deco_allowed_depth(tissue_tolerance_calc(ds, dive,
|
||||
depth_to_bar(lastdepth.mm, dive)),
|
||||
depth_to_bar(lastdepth.mm, dive), true),
|
||||
dive->surface_pressure.mbar / 1000.0,
|
||||
dive,
|
||||
1),
|
||||
|
@ -534,8 +534,8 @@ static bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth,
|
|||
add_segment(ds, depth_to_bar(trial_depth, dive),
|
||||
gasmix,
|
||||
wait_time, po2, divemode, prefs.decosac, true);
|
||||
if (decoMode() == VPMB) {
|
||||
double tolerance_limit = tissue_tolerance_calc(ds, dive, depth_to_bar(stoplevel, dive));
|
||||
if (decoMode(true) == VPMB) {
|
||||
double tolerance_limit = tissue_tolerance_calc(ds, dive, depth_to_bar(stoplevel, dive), true);
|
||||
update_regression(ds, dive);
|
||||
if (deco_allowed_depth(tolerance_limit, surface_pressure, dive, 1) > stoplevel) {
|
||||
restore_deco_state(trial_cache, ds, false);
|
||||
|
@ -552,8 +552,8 @@ static bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth,
|
|||
add_segment(ds, depth_to_bar(trial_depth, dive),
|
||||
gasmix,
|
||||
TIMESTEP, po2, divemode, prefs.decosac, true);
|
||||
tolerance_limit = tissue_tolerance_calc(ds, dive, depth_to_bar(trial_depth, dive));
|
||||
if (decoMode() == VPMB)
|
||||
tolerance_limit = tissue_tolerance_calc(ds, dive, depth_to_bar(trial_depth, dive), true);
|
||||
if (decoMode(true) == VPMB)
|
||||
update_regression(ds, dive);
|
||||
if (deco_allowed_depth(tolerance_limit, surface_pressure, dive, 1) > trial_depth - deltad) {
|
||||
/* We should have stopped */
|
||||
|
@ -759,7 +759,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
diveplan->surface_interval = tissue_at_end(ds, dive, cached_datap);
|
||||
nuclear_regeneration(ds, clock);
|
||||
vpmb_start_gradient(ds);
|
||||
if (decoMode() == RECREATIONAL) {
|
||||
if (decoMode(true) == RECREATIONAL) {
|
||||
bool safety_stop = prefs.safetystop && max_depth >= 10000;
|
||||
track_ascent_gas(depth, dive, current_cylinder, avg_depth, bottom_time, safety_stop, divemode);
|
||||
// How long can we stay at the current depth and still directly ascent to the surface?
|
||||
|
@ -847,7 +847,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
//CVA
|
||||
do {
|
||||
decostopcounter = 0;
|
||||
is_final_plan = (decoMode() == BUEHLMANN) || (previous_deco_time - ds->deco_time < 10); // CVA time converges
|
||||
is_final_plan = (decoMode(true) == BUEHLMANN) || (previous_deco_time - ds->deco_time < 10); // CVA time converges
|
||||
if (ds->deco_time != 10000000)
|
||||
vpmb_next_gradient(ds, ds->deco_time, diveplan->surface_pressure / 1000.0, true);
|
||||
|
||||
|
@ -863,7 +863,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
first_stop_depth = 0;
|
||||
stopidx = bottom_stopidx;
|
||||
ds->first_ceiling_pressure.mbar = depth_to_mbar(
|
||||
deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(depth, dive)),
|
||||
deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(depth, dive), true),
|
||||
diveplan->surface_pressure / 1000.0, dive, 1),
|
||||
dive);
|
||||
if (ds->max_bottom_ceiling_pressure.mbar > ds->first_ceiling_pressure.mbar)
|
||||
|
@ -1074,7 +1074,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
decostoptable[decostopcounter].depth = 0;
|
||||
|
||||
plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false, divemode);
|
||||
if (decoMode() == VPMB) {
|
||||
if (decoMode(true) == VPMB) {
|
||||
diveplan->eff_gfhigh = lrint(100.0 * regressionb(ds));
|
||||
diveplan->eff_gflow = lrint(100.0 * (regressiona(ds) * first_stop_depth + regressionb(ds)));
|
||||
}
|
||||
|
|
|
@ -86,8 +86,8 @@ const char *get_planner_disclaimer()
|
|||
char *get_planner_disclaimer_formatted()
|
||||
{
|
||||
struct membuffer buf = { 0 };
|
||||
const char *deco = decoMode() == VPMB ? translate("gettextFromC", "VPM-B")
|
||||
: translate("gettextFromC", "BUHLMANN");
|
||||
const char *deco = decoMode(true) == VPMB ? translate("gettextFromC", "VPM-B")
|
||||
: translate("gettextFromC", "BUHLMANN");
|
||||
put_format(&buf, get_planner_disclaimer(), deco);
|
||||
return detach_cstring(&buf);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
}
|
||||
put_string(&buf, "<br/>\n");
|
||||
|
||||
if (prefs.display_variations && decoMode() != RECREATIONAL)
|
||||
if (prefs.display_variations && decoMode(true) != RECREATIONAL)
|
||||
put_format_loc(&buf, translate("gettextFromC", "Runtime: %dmin%s"),
|
||||
diveplan_duration(diveplan), "VARIATIONS");
|
||||
else
|
||||
|
@ -420,16 +420,16 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
|
||||
/* Print the settings for the diveplan next. */
|
||||
put_string(&buf, "<div>\n");
|
||||
if (decoMode() == BUEHLMANN) {
|
||||
if (decoMode(true) == BUEHLMANN) {
|
||||
put_format_loc(&buf, translate("gettextFromC", "Deco model: Bühlmann ZHL-16C with GFLow = %d%% and GFHigh = %d%%"), diveplan->gflow, diveplan->gfhigh);
|
||||
} else if (decoMode() == VPMB){
|
||||
} else if (decoMode(true) == VPMB) {
|
||||
if (diveplan->vpmb_conservatism == 0)
|
||||
put_string(&buf, translate("gettextFromC", "Deco model: VPM-B at nominal conservatism"));
|
||||
else
|
||||
put_format_loc(&buf, translate("gettextFromC", "Deco model: VPM-B at +%d conservatism"), diveplan->vpmb_conservatism);
|
||||
if (diveplan->eff_gflow)
|
||||
put_format_loc(&buf, translate("gettextFromC", ", effective GF=%d/%d"), diveplan->eff_gflow, diveplan->eff_gfhigh);
|
||||
} else if (decoMode() == RECREATIONAL){
|
||||
} else if (decoMode(true) == RECREATIONAL) {
|
||||
put_format_loc(&buf, translate("gettextFromC", "Deco model: Recreational mode based on Bühlmann ZHL-16B with GFLow = %d%% and GFHigh = %d%%"),
|
||||
diveplan->gflow, diveplan->gfhigh);
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
/* not for recreational mode and if no other warning was set before. */
|
||||
else
|
||||
if (lastbottomdp && gasidx == lastbottomdp->cylinderid
|
||||
&& dive->dc.divemode == OC && decoMode() != RECREATIONAL) {
|
||||
&& dive->dc.divemode == OC && decoMode(true) != RECREATIONAL) {
|
||||
/* Calculate minimum gas volume. */
|
||||
volume_t mingasv;
|
||||
mingasv.mliter = lrint(prefs.sacfactor / 100.0 * prefs.problemsolvingtime * prefs.bottomsac
|
||||
|
|
|
@ -919,7 +919,7 @@ static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, st
|
|||
const int deco_stepsize = 3000;
|
||||
/* at what depth is the current deco-step? */
|
||||
int next_stop = ROUND_UP(deco_allowed_depth(
|
||||
tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive)),
|
||||
tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive), in_planner),
|
||||
surface_pressure, dive, 1), deco_stepsize);
|
||||
int ascent_depth = entry->depth;
|
||||
/* at what time should we give up and say that we got enuff NDL? */
|
||||
|
@ -935,7 +935,7 @@ static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, st
|
|||
}
|
||||
/* stop if the ndl is above max_ndl seconds, and call it plenty of time */
|
||||
while (entry->ndl_calc < MAX_PROFILE_DECO &&
|
||||
deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive)),
|
||||
deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive), in_planner),
|
||||
surface_pressure, dive, 1) <= 0
|
||||
) {
|
||||
entry->ndl_calc += time_stepsize;
|
||||
|
@ -953,7 +953,7 @@ static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, st
|
|||
for (; ascent_depth > next_stop; ascent_depth -= ascent_s_per_step * ascent_velocity(ascent_depth, entry->running_sum / entry->sec, 0), entry->tts_calc += ascent_s_per_step) {
|
||||
add_segment(ds, depth_to_bar(ascent_depth, dive),
|
||||
gasmix, ascent_s_per_step, entry->o2pressure.mbar, divemode, prefs.decosac, in_planner);
|
||||
next_stop = ROUND_UP(deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(ascent_depth, dive)),
|
||||
next_stop = ROUND_UP(deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(ascent_depth, dive), in_planner),
|
||||
surface_pressure, dive, 1), deco_stepsize);
|
||||
}
|
||||
ascent_depth = next_stop;
|
||||
|
@ -975,7 +975,7 @@ static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, st
|
|||
add_segment(ds, depth_to_bar(ascent_depth, dive),
|
||||
gasmix, time_stepsize, entry->o2pressure.mbar, divemode, prefs.decosac, in_planner);
|
||||
|
||||
if (deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(ascent_depth,dive)), surface_pressure, dive, 1) <= next_stop) {
|
||||
if (deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(ascent_depth,dive), in_planner), surface_pressure, dive, 1) <= next_stop) {
|
||||
/* move to the next stop and add the travel between stops */
|
||||
for (; ascent_depth > next_stop; ascent_depth -= ascent_s_per_deco_step * ascent_velocity(ascent_depth, entry->running_sum / entry->sec, 0), entry->tts_calc += ascent_s_per_deco_step)
|
||||
add_segment(ds, depth_to_bar(ascent_depth, dive),
|
||||
|
@ -1007,7 +1007,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
struct deco_state *cache_data_initial = NULL;
|
||||
lock_planner();
|
||||
/* For VPM-B outside the planner, cache the initial deco state for CVA iterations */
|
||||
if (decoMode() == VPMB) {
|
||||
if (decoMode(in_planner) == VPMB) {
|
||||
cache_deco_state(ds, &cache_data_initial);
|
||||
}
|
||||
/* For VPM-B outside the planner, iterate until deco time converges (usually one or two iterations after the initial)
|
||||
|
@ -1015,7 +1015,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
|
||||
while ((abs(prev_deco_time - ds->deco_time) >= 30) && (count_iteration < 10)) {
|
||||
int last_ndl_tts_calc_time = 0, first_ceiling = 0, current_ceiling, last_ceiling = 0, final_tts = 0 , time_clear_ceiling = 0;
|
||||
if (decoMode() == VPMB)
|
||||
if (decoMode(in_planner) == VPMB)
|
||||
ds->first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive);
|
||||
struct gasmix gasmix = gasmix_invalid;
|
||||
const struct event *ev = NULL, *evd = NULL;
|
||||
|
@ -1050,21 +1050,21 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
entry->ceiling = (entry - 1)->ceiling;
|
||||
} else {
|
||||
/* Keep updating the VPM-B gradients until the start of the ascent phase of the dive. */
|
||||
if (decoMode() == VPMB && last_ceiling >= first_ceiling && first_iteration == true) {
|
||||
if (decoMode(in_planner) == VPMB && last_ceiling >= first_ceiling && first_iteration == true) {
|
||||
nuclear_regeneration(ds, t1);
|
||||
vpmb_start_gradient(ds);
|
||||
/* For CVA iterations, calculate next gradient */
|
||||
if (!first_iteration || !planner_ds)
|
||||
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0, in_planner);
|
||||
}
|
||||
entry->ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive)), surface_pressure, dive, !prefs.calcceiling3m);
|
||||
entry->ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive), in_planner), surface_pressure, dive, !prefs.calcceiling3m);
|
||||
if (prefs.calcceiling3m)
|
||||
current_ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive)), surface_pressure, dive, true);
|
||||
current_ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, depth_to_bar(entry->depth, dive), in_planner), surface_pressure, dive, true);
|
||||
else
|
||||
current_ceiling = entry->ceiling;
|
||||
last_ceiling = current_ceiling;
|
||||
/* If using VPM-B, take first_ceiling_pressure as the deepest ceiling */
|
||||
if (decoMode() == VPMB) {
|
||||
if (decoMode(in_planner) == VPMB) {
|
||||
if (current_ceiling >= first_ceiling ||
|
||||
(time_deep_ceiling == t0 && entry->depth == (entry - 1)->depth)) {
|
||||
time_deep_ceiling = t1;
|
||||
|
@ -1125,8 +1125,8 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
* We don't for print-mode because this info doesn't show up there
|
||||
* If the ceiling hasn't cleared by the last data point, we need tts for VPM-B CVA calculation
|
||||
* It is not necessary to do these calculation on the first VPMB iteration, except for the last data point */
|
||||
if ((prefs.calcndltts && (decoMode() != VPMB || !planner_ds || !first_iteration)) ||
|
||||
(decoMode() == VPMB && !planner_ds && i == pi->nr - 1)) {
|
||||
if ((prefs.calcndltts && (decoMode(in_planner) != VPMB || !planner_ds || !first_iteration)) ||
|
||||
(decoMode(in_planner) == VPMB && !planner_ds && i == pi->nr - 1)) {
|
||||
/* only calculate ndl/tts on every 30 seconds */
|
||||
if ((entry->sec - last_ndl_tts_calc_time) < 30 && i != pi->nr - 1) {
|
||||
struct plot_data *prev_entry = (entry - 1);
|
||||
|
@ -1142,14 +1142,14 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
|
|||
struct deco_state *cache_data = NULL;
|
||||
cache_deco_state(ds, &cache_data);
|
||||
calculate_ndl_tts(ds, dive, entry, gasmix, surface_pressure, current_divemode, in_planner);
|
||||
if (decoMode() == VPMB && !planner_ds && i == pi->nr - 1)
|
||||
if (decoMode(in_planner) == VPMB && !planner_ds && i == pi->nr - 1)
|
||||
final_tts = entry->tts_calc;
|
||||
/* Restore "real" deco state for next real time step */
|
||||
restore_deco_state(cache_data, ds, decoMode() == VPMB);
|
||||
restore_deco_state(cache_data, ds, decoMode(in_planner) == VPMB);
|
||||
free(cache_data);
|
||||
}
|
||||
}
|
||||
if (decoMode() == VPMB && !planner_ds) {
|
||||
if (decoMode(in_planner) == VPMB && !planner_ds) {
|
||||
int this_deco_time;
|
||||
prev_deco_time = ds->deco_time;
|
||||
// Do we need to update deco_time?
|
||||
|
|
|
@ -1489,9 +1489,9 @@ extern "C" bool in_planner()
|
|||
return getAppState() == ApplicationState::PlanDive || getAppState() == ApplicationState::EditPlannedDive;
|
||||
}
|
||||
|
||||
extern "C" enum deco_mode decoMode()
|
||||
extern "C" enum deco_mode decoMode(bool in_planner)
|
||||
{
|
||||
return in_planner() ? prefs.planner_deco_mode : prefs.display_deco_mode;
|
||||
return in_planner ? prefs.planner_deco_mode : prefs.display_deco_mode;
|
||||
}
|
||||
|
||||
void init_proxy()
|
||||
|
|
|
@ -151,7 +151,7 @@ char *cloud_url();
|
|||
char *hashfile_name_string();
|
||||
char *picturedir_string();
|
||||
const char *subsurface_user_agent();
|
||||
enum deco_mode decoMode();
|
||||
enum deco_mode decoMode(bool in_planner);
|
||||
void parse_seabear_header(const char *filename, struct xml_params *params);
|
||||
char *get_current_date();
|
||||
time_t get_dive_datetime_from_isostring(char *when);
|
||||
|
|
|
@ -217,7 +217,7 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis)
|
|||
timeAxis = axis;
|
||||
}
|
||||
|
||||
void ToolTipItem::refresh(const dive *d, const QPointF &pos)
|
||||
void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner)
|
||||
{
|
||||
static QPixmap tissues(16,60);
|
||||
static QPainter painter(&tissues);
|
||||
|
@ -249,7 +249,7 @@ void ToolTipItem::refresh(const dive *d, const QPointF &pos)
|
|||
|
||||
const struct plot_data *entry = &pInfo.entry[idx];
|
||||
painter.setPen(QColor(0, 0, 0, 255));
|
||||
if (decoMode() == BUEHLMANN)
|
||||
if (decoMode(inPlanner) == BUEHLMANN)
|
||||
painter.drawLine(0, lrint(60 - entry->gfline / 2), 16, lrint(60 - entry->gfline / 2));
|
||||
painter.drawLine(0, lrint(60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure / 2),
|
||||
16, lrint(60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure /2));
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
void collapse();
|
||||
void expand();
|
||||
void clear();
|
||||
void refresh(const dive *d, const QPointF &pos);
|
||||
void refresh(const dive *d, const QPointF &pos, bool inPlanner);
|
||||
bool isExpanded() const;
|
||||
void persistPos();
|
||||
void readPos();
|
||||
|
|
|
@ -543,7 +543,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
|||
// this copies the dive and makes copies of all the relevant additional data
|
||||
copy_dive(d, &displayed_dive);
|
||||
|
||||
if (decoMode() == VPMB)
|
||||
if (decoMode(false) == VPMB)
|
||||
decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.vpmb_conservatism));
|
||||
else
|
||||
decoModelParameters->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
|
||||
|
@ -556,7 +556,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
|||
plannerModel->deleteTemporaryPlan();
|
||||
return;
|
||||
}
|
||||
if (decoMode() == VPMB)
|
||||
if (decoMode(currentState == PLAN) == VPMB)
|
||||
decoModelParameters->setText(QString("VPM-B +%1").arg(diveplan.vpmb_conservatism));
|
||||
else
|
||||
decoModelParameters->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh));
|
||||
|
@ -800,7 +800,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
|
|||
else
|
||||
plotPicturesInternal(d, instant);
|
||||
|
||||
toolTipItem->refresh(&displayed_dive, mapToScene(mapFromGlobal(QCursor::pos())));
|
||||
toolTipItem->refresh(&displayed_dive, mapToScene(mapFromGlobal(QCursor::pos())), currentState == PLAN);
|
||||
#endif
|
||||
|
||||
// OK, how long did this take us? Anything above the second is way too long,
|
||||
|
@ -1027,7 +1027,7 @@ void ProfileWidget2::scrollViewTo(const QPoint &pos)
|
|||
void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
toolTipItem->refresh(&displayed_dive, mapToScene(mapFromGlobal(QCursor::pos())));
|
||||
toolTipItem->refresh(&displayed_dive, mapToScene(mapFromGlobal(QCursor::pos())), currentState == PLAN);
|
||||
|
||||
if (zoomLevel == 0) {
|
||||
QGraphicsView::mouseMoveEvent(event);
|
||||
|
|
|
@ -1118,7 +1118,7 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, c
|
|||
struct divedatapoint *last_segment;
|
||||
struct deco_state ds = *previous_ds;
|
||||
|
||||
if (isPlanner() && prefs.display_variations && decoMode() != RECREATIONAL) {
|
||||
if (isPlanner() && prefs.display_variations && decoMode(true) != RECREATIONAL) {
|
||||
int my_instance = ++instanceCounter;
|
||||
cache_deco_state(&ds, &save);
|
||||
|
||||
|
|
Loading…
Reference in a new issue