diff --git a/core/profile.cpp b/core/profile.cpp index 605f9a4c8..29a2244da 100644 --- a/core/profile.cpp +++ b/core/profile.cpp @@ -903,11 +903,11 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_ if (!first_iteration || 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) current_ceiling = deco_allowed_depth(tissue_tolerance_calc(ds, dive, dive->depth_to_bar(entry.depth), in_planner), surface_pressure, dive, true); else - current_ceiling.mm = entry.ceiling; + current_ceiling = entry.ceiling; last_ceiling = current_ceiling; /* If using VPM-B, take first_ceiling_pressure as the deepest ceiling */ 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++) { 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]; - entry.ceilings[j] = deco_allowed_depth(ds->tolerated_by_tissue[j], surface_pressure, dive, 1).mm; - if (entry.ceilings[j] > max_ceiling.mm) - max_ceiling.mm = entry.ceilings[j]; + entry.ceilings[j] = deco_allowed_depth(ds->tolerated_by_tissue[j], surface_pressure, dive, 1); + if (entry.ceilings[j].mm > max_ceiling.mm) + max_ceiling = entry.ceilings[j]; double current_gf = (ds->tissue_inertgas_saturation[j] - entry.ambpressure) / (m_value - entry.ambpressure); entry.percentages[j] = ds->tissue_inertgas_saturation[j] < entry.ambpressure ? lrint(ds->tissue_inertgas_saturation[j] / entry.ambpressure * AMB_PERCENTAGE) : @@ -1388,14 +1388,14 @@ static std::vector plot_string(const struct dive *d, const struct p res.push_back(casprintf_loc(translate("gettextFromC", "GF %d%%"), (int)(100.0 * entry.current_gf))); if (entry.surface_gf > 0.0) res.push_back(casprintf_loc(translate("gettextFromC", "Surface GF %.0f%%"), entry.surface_gf)); - if (entry.ceiling) { - depthvalue = get_depth_units(entry.ceiling, NULL, &depth_unit); + if (entry.ceiling.mm > 0) { + depthvalue = get_depth_units(entry.ceiling.mm, NULL, &depth_unit); res.push_back(casprintf_loc(translate("gettextFromC", "Calculated ceiling %.1f%s"), depthvalue, depth_unit)); if (prefs.calcalltissues) { int k; for (k = 0; k < 16; k++) { - if (entry.ceilings[k]) { - depthvalue = get_depth_units(entry.ceilings[k], NULL, &depth_unit); + if (entry.ceilings[k].mm > 0) { + 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)); } } diff --git a/core/profile.h b/core/profile.h index f211e91aa..3b3d84c77 100644 --- a/core/profile.h +++ b/core/profile.h @@ -42,8 +42,8 @@ struct plot_data { int temperature = 0; /* Depth info */ depth_t depth; - int ceiling = 0; - std::array ceilings; + depth_t ceiling; + std::array ceilings; std::array percentages; int ndl = 0; int tts = 0; diff --git a/core/save-profiledata.cpp b/core/save-profiledata.cpp index e35bb5127..096f5215a 100644 --- a/core/save-profiledata.cpp +++ b/core/save-profiledata.cpp @@ -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.depth.mm); - put_int(b, entry.ceiling); + put_int(b, entry.ceiling.mm); 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++) put_int(b, entry.percentages[i]); 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]", ""); } - if (entry.ceiling) { - value = get_depth_units(entry.ceiling, &decimals, &unit); + if (entry.ceiling.mm > 0) { + value = get_depth_units(entry.ceiling.mm, &decimals, &unit); replace_all(format_string,"[ceiling]", format_string_std("%02.2f %s", value, unit)); } else { replace_all(format_string, "[ceiling]", ""); diff --git a/profile-widget/profilescene.cpp b/profile-widget/profilescene.cpp index f104967ff..b1e609b89 100644 --- a/profile-widget/profilescene.cpp +++ b/profile-widget/profilescene.cpp @@ -71,7 +71,7 @@ PartialPressureGasItem *ProfileScene::createPPGas(DataAccessor accessor, color_i template double accessTissue(const plot_data &item) { - return item.ceilings[IDX]; + return static_cast(item.ceilings[IDX].mm); } // 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)), diveComputerText(new DiveTextItem(dpr, 1.0, Qt::AlignRight | Qt::AlignTop, nullptr)), reportedCeiling(createItem(*profileYAxis, - [](const plot_data &item) { return (double)item.ceiling; }, + [](const plot_data &item) { return (double)item.ceiling.mm; }, 1, dpr)), pn2GasItem(createPPGas([](const plot_data &item) { return (double)item.pressures.n2; }, 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; }, SCR_OCPO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)), diveCeiling(createItem(*profileYAxis, - [](const plot_data &item) { return (double)item.ceiling; }, + [](const plot_data &item) { return (double)item.ceiling.mm; }, 1, dpr)), decoModelParameters(new DiveTextItem(dpr, 1.0, Qt::AlignHCenter | Qt::AlignTop, nullptr)), heartBeatItem(createItem(*heartBeatAxis,