diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-31 16:21:39 +1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-31 17:31:53 +1000 |
commit | 6f7467de7a073178c0593673b9e0b697cb265d0a (patch) | |
tree | de5ac32efcbba4f552c0e3a59a0289448a2e3a97 | |
parent | abb43f0f1debd70bf69fde9599e1500e1c726f74 (diff) | |
download | subsurface-6f7467de7a073178c0593673b9e0b697cb265d0a.tar.gz |
Show the gas with the pressure diagram
This is a feature that had been requested a few times in the past and when
debugging my "show only used gases" commit I realized that this would have
been extremely useful to have...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | profile.c | 20 | ||||
-rw-r--r-- | profile.h | 1 | ||||
-rw-r--r-- | qt-ui/profilegraphics.cpp | 16 | ||||
-rw-r--r-- | qt-ui/profilegraphics.h | 1 |
4 files changed, 32 insertions, 6 deletions
@@ -389,7 +389,7 @@ static struct plot_info *analyze_plot_info(struct plot_info *pi) /* Linus wants to smooth this - let's at least look at the samples that aren't FAST or CRAZY */ if (entry[0].sec - entry[-1].sec) { entry->velocity = velocity((entry[0].depth - entry[-1].depth) / (entry[0].sec - entry[-1].sec)); - /* if our samples are short and we aren't too FAST*/ + /* if our samples are short and we aren't too FAST*/ if (entry[0].sec - entry[-1].sec < 15 && entry->velocity < FAST) { int past = -2; while (i+past > 0 && entry[0].sec - entry[past].sec < 15) @@ -832,6 +832,8 @@ static struct plot_data *populate_plot_entries(struct dive *dive, struct divecom entry->po2 = sample->po2 / 1000.0; /* FIXME! sensor index -> cylinder index translation! */ entry->cylinderindex = sample->sensor; + entry->o2 = dive->cylinder[entry->cylinderindex].gasmix.o2.permille; + entry->he = dive->cylinder[entry->cylinderindex].gasmix.he.permille; SENSOR_PRESSURE(entry) = sample->cylinderpressure.mbar; entry->temperature = sample->temperature.mkelvin; @@ -845,6 +847,12 @@ static struct plot_data *populate_plot_entries(struct dive *dive, struct divecom plot_data[idx++].sec = lasttime+20; pi->nr = idx; + /* make sure the first two entries have the correct gas */ + plot_data[0].o2 = plot_data[2].o2; + plot_data[0].he = plot_data[2].he; + plot_data[1].o2 = plot_data[2].o2; + plot_data[1].he = plot_data[2].he; + return plot_data; } @@ -996,10 +1004,10 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d entry->pn2 = (1000 - fo2 - fhe) / 1000.0 * amb_pressure; } - /* Calculate MOD, EAD, END and EADD based on partial pressures calculated before - * so there is no difference in calculating between OC and CC - * EAD takes O2 + N2 (air) into account - * END just uses N2 */ + /* Calculate MOD, EAD, END and EADD based on partial pressures calculated before + * so there is no difference in calculating between OC and CC + * EAD takes O2 + N2 (air) into account + * END just uses N2 */ entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000; entry->ead = (entry->depth + 10000) * (entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure - 10000; @@ -1007,7 +1015,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d (amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 - 10000; entry->eadd = (entry->depth + 10000) * (entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure * - N2_DENSITY + entry->phe / amb_pressure * HE_DENSITY) / + N2_DENSITY + entry->phe / amb_pressure * HE_DENSITY) / (O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -10000; if (entry->mod < 0) entry->mod = 0; @@ -15,6 +15,7 @@ struct plot_info; struct plot_data { unsigned int in_deco:1; int cylinderindex; + int o2, he; int sec; /* pressure[0] is sensor pressure * pressure[1] is interpolated pressure */ diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 82477b201..375d8b6d3 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -577,6 +577,8 @@ void ProfileGraphicsView::plot_cylinder_pressure_text() cyl = entry->cylinderindex; if (!seen_cyl[cyl]) { plot_pressure_value(mbar, entry->sec, LEFT, BOTTOM); + plot_gas_value(mbar, entry->sec, LEFT, TOP, + entry->o2, entry->he); seen_cyl[cyl] = TRUE; } } @@ -601,6 +603,20 @@ void ProfileGraphicsView::plot_pressure_value(int mbar, int sec, double xalign, plot_text(&tro, QPointF(sec, mbar), QString("%1 %2").arg(pressure).arg(unit)); } +void ProfileGraphicsView::plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he) +{ + QString gas; + if (is_air(o2, he)) + gas = tr("air"); + else if (he == 0) + gas = QString(tr("EAN%1")).arg((o2 + 5) / 10); + else + gas = QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10); + static text_render_options_t tro = {PRESSURE_TEXT_SIZE, PRESSURE_TEXT, xalign, yalign}; + plot_text(&tro, QPointF(sec, mbar), gas); + +} + void ProfileGraphicsView::plot_depth_text() { int maxtime, maxdepth; diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index 963dd7d90..b440adf5d 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -89,6 +89,7 @@ private: void plot_depth_sample(struct plot_data *entry, text_render_options_t *tro); void plot_cylinder_pressure_text(); void plot_pressure_value(int mbar, int sec, double xalign, double yalign); + void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he); void plot_deco_text(); void plot_pp_gas_profile(); void plot_pp_text(); |