profile: turn plotdata::ceiling into depth_t

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-12-14 20:36:38 +01:00 committed by Michael Keller
parent 9cf753fa56
commit 58d096adfc
4 changed files with 18 additions and 18 deletions

View file

@ -903,11 +903,11 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
if (!first_iteration || in_planner) if (!first_iteration || in_planner)
vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0, in_planner); vpmb_next_gradient(ds, ds->deco_time, surface_pressure / 1000.0, in_planner);
} }
entry.ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, dive->depth_to_bar(entry.depth), in_planner), surface_pressure, dive, !prefs.calcceiling3m).mm; entry.ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, dive->depth_to_bar(entry.depth), in_planner), surface_pressure, dive, !prefs.calcceiling3m);
if (prefs.calcceiling3m) if (prefs.calcceiling3m)
current_ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, dive->depth_to_bar(entry.depth), in_planner), surface_pressure, dive, true); current_ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, dive->depth_to_bar(entry.depth), in_planner), surface_pressure, dive, true);
else else
current_ceiling.mm = entry.ceiling; current_ceiling = entry.ceiling;
last_ceiling = current_ceiling; last_ceiling = current_ceiling;
/* If using VPM-B, take first_ceiling_pressure as the deepest ceiling */ /* If using VPM-B, take first_ceiling_pressure as the deepest ceiling */
if (decoMode(in_planner) == VPMB) { if (decoMode(in_planner) == VPMB) {
@ -939,9 +939,9 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
double m_value = ds->buehlmann_inertgas_a[j] + entry.ambpressure / ds->buehlmann_inertgas_b[j]; double m_value = ds->buehlmann_inertgas_a[j] + entry.ambpressure / ds->buehlmann_inertgas_b[j];
double surface_m_value = ds->buehlmann_inertgas_a[j] + surface_pressure / ds->buehlmann_inertgas_b[j]; double surface_m_value = ds->buehlmann_inertgas_a[j] + surface_pressure / ds->buehlmann_inertgas_b[j];
entry.ceilings[j] = deco_allowed_depth(ds->tolerated_by_tissue[j], surface_pressure, dive, 1).mm; entry.ceilings[j] = deco_allowed_depth(ds->tolerated_by_tissue[j], surface_pressure, dive, 1);
if (entry.ceilings[j] > max_ceiling.mm) if (entry.ceilings[j].mm > max_ceiling.mm)
max_ceiling.mm = entry.ceilings[j]; max_ceiling = entry.ceilings[j];
double current_gf = (ds->tissue_inertgas_saturation[j] - entry.ambpressure) / (m_value - entry.ambpressure); double current_gf = (ds->tissue_inertgas_saturation[j] - entry.ambpressure) / (m_value - entry.ambpressure);
entry.percentages[j] = ds->tissue_inertgas_saturation[j] < entry.ambpressure ? entry.percentages[j] = ds->tissue_inertgas_saturation[j] < entry.ambpressure ?
lrint(ds->tissue_inertgas_saturation[j] / entry.ambpressure * AMB_PERCENTAGE) : lrint(ds->tissue_inertgas_saturation[j] / entry.ambpressure * AMB_PERCENTAGE) :
@ -1388,14 +1388,14 @@ static std::vector<std::string> plot_string(const struct dive *d, const struct p
res.push_back(casprintf_loc(translate("gettextFromC", "GF %d%%"), (int)(100.0 * entry.current_gf))); res.push_back(casprintf_loc(translate("gettextFromC", "GF %d%%"), (int)(100.0 * entry.current_gf)));
if (entry.surface_gf > 0.0) if (entry.surface_gf > 0.0)
res.push_back(casprintf_loc(translate("gettextFromC", "Surface GF %.0f%%"), entry.surface_gf)); res.push_back(casprintf_loc(translate("gettextFromC", "Surface GF %.0f%%"), entry.surface_gf));
if (entry.ceiling) { if (entry.ceiling.mm > 0) {
depthvalue = get_depth_units(entry.ceiling, NULL, &depth_unit); depthvalue = get_depth_units(entry.ceiling.mm, NULL, &depth_unit);
res.push_back(casprintf_loc(translate("gettextFromC", "Calculated ceiling %.1f%s"), depthvalue, depth_unit)); res.push_back(casprintf_loc(translate("gettextFromC", "Calculated ceiling %.1f%s"), depthvalue, depth_unit));
if (prefs.calcalltissues) { if (prefs.calcalltissues) {
int k; int k;
for (k = 0; k < 16; k++) { for (k = 0; k < 16; k++) {
if (entry.ceilings[k]) { if (entry.ceilings[k].mm > 0) {
depthvalue = get_depth_units(entry.ceilings[k], NULL, &depth_unit); depthvalue = get_depth_units(entry.ceilings[k].mm, NULL, &depth_unit);
res.push_back(casprintf_loc(translate("gettextFromC", "Tissue %.0fmin: %.1f%s"), buehlmann_N2_t_halflife[k], depthvalue, depth_unit)); res.push_back(casprintf_loc(translate("gettextFromC", "Tissue %.0fmin: %.1f%s"), buehlmann_N2_t_halflife[k], depthvalue, depth_unit));
} }
} }

View file

@ -42,8 +42,8 @@ struct plot_data {
int temperature = 0; int temperature = 0;
/* Depth info */ /* Depth info */
depth_t depth; depth_t depth;
int ceiling = 0; depth_t ceiling;
std::array<int, 16> ceilings; std::array<depth_t, 16> ceilings;
std::array<int, 16> percentages; std::array<int, 16> percentages;
int ndl = 0; int ndl = 0;
int tts = 0; int tts = 0;

View file

@ -70,9 +70,9 @@ static void put_pd(struct membuffer *b, const struct plot_info &pi, int idx)
} }
put_int(b, entry.temperature); put_int(b, entry.temperature);
put_int(b, entry.depth.mm); put_int(b, entry.depth.mm);
put_int(b, entry.ceiling); put_int(b, entry.ceiling.mm);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
put_int(b, entry.ceilings[i]); put_int(b, entry.ceilings[i].mm);
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
put_int(b, entry.percentages[i]); put_int(b, entry.percentages[i]);
put_int(b, entry.ndl); put_int(b, entry.ndl);
@ -209,8 +209,8 @@ static std::string format_st_event(const plot_data &entry, const plot_data &next
replace_all(format_string, "[temperature]", ""); replace_all(format_string, "[temperature]", "");
} }
if (entry.ceiling) { if (entry.ceiling.mm > 0) {
value = get_depth_units(entry.ceiling, &decimals, &unit); value = get_depth_units(entry.ceiling.mm, &decimals, &unit);
replace_all(format_string,"[ceiling]", format_string_std("%02.2f %s", value, unit)); replace_all(format_string,"[ceiling]", format_string_std("%02.2f %s", value, unit));
} else { } else {
replace_all(format_string, "[ceiling]", ""); replace_all(format_string, "[ceiling]", "");

View file

@ -71,7 +71,7 @@ PartialPressureGasItem *ProfileScene::createPPGas(DataAccessor accessor, color_i
template <int IDX> template <int IDX>
double accessTissue(const plot_data &item) double accessTissue(const plot_data &item)
{ {
return item.ceilings[IDX]; return static_cast<double>(item.ceilings[IDX].mm);
} }
// For now, the accessor functions for the profile data do not possess a payload. // For now, the accessor functions for the profile data do not possess a payload.
@ -124,7 +124,7 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
1, dpr)), 1, dpr)),
diveComputerText(new DiveTextItem(dpr, 1.0, Qt::AlignRight | Qt::AlignTop, nullptr)), diveComputerText(new DiveTextItem(dpr, 1.0, Qt::AlignRight | Qt::AlignTop, nullptr)),
reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis, reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis,
[](const plot_data &item) { return (double)item.ceiling; }, [](const plot_data &item) { return (double)item.ceiling.mm; },
1, dpr)), 1, dpr)),
pn2GasItem(createPPGas([](const plot_data &item) { return (double)item.pressures.n2; }, pn2GasItem(createPPGas([](const plot_data &item) { return (double)item.pressures.n2; },
PN2, PN2_ALERT, NULL, &prefs.pp_graphs.pn2_threshold)), PN2, PN2_ALERT, NULL, &prefs.pp_graphs.pn2_threshold)),
@ -143,7 +143,7 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
ocpo2GasItem(createPPGas([](const plot_data &item) { return item.scr_OC_pO2.mbar / 1000.0; }, ocpo2GasItem(createPPGas([](const plot_data &item) { return item.scr_OC_pO2.mbar / 1000.0; },
SCR_OCPO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)), SCR_OCPO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis, diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis,
[](const plot_data &item) { return (double)item.ceiling; }, [](const plot_data &item) { return (double)item.ceiling.mm; },
1, dpr)), 1, dpr)),
decoModelParameters(new DiveTextItem(dpr, 1.0, Qt::AlignHCenter | Qt::AlignTop, nullptr)), decoModelParameters(new DiveTextItem(dpr, 1.0, Qt::AlignHCenter | Qt::AlignTop, nullptr)),
heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis,