aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-07-30 10:08:33 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-06 09:14:34 -0700
commit3aaf8b1f5af275f3b1d26ff7c21c6b47448d76c0 (patch)
treeb2af74456c55e53750c8aae8671c0a244437d9ad /qt-ui
parentd982096144f2f9d0ef9e230f82a30792cca05654 (diff)
downloadsubsurface-3aaf8b1f5af275f3b1d26ff7c21c6b47448d76c0.tar.gz
Make gas use statistics be coherent and more complete
The gas use logic in the dive statistics page is confused. The SAC case had a special case for "unknown", but only for the first gas. Other gases had the normal empty case. Also, the logic was really odd - if you had gases that weren't used (or pressures not known) intermixed with gases you *did* have pressure for, the statistics got really confused. The list of gases showed all gases that we know about during the dive, but then the gas use and SAC-rate lists wouldn't necessarily match, because the loops that computed those stopped after the first gas that didn't have any pressure change. To make things worse, the first cylinder was special-cased again, so it all lined up for the single-cylinder case. This makes all the cylinders act the same way, leaving unknown gas use (and thus SAC) just empty for that gas. It also fixes the SAC calculation case where we don't have real samples, and the profile is a fake profile - possibly with gas changes in between the fake points. We now make the SAC calculations match what we show - which is admittedly not at all necessarily what the dive was, but at least we're consistent. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 075bfb734..ed65a1943 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -472,28 +472,30 @@ void MainTab::updateDiveInfo(bool clear)
ui.airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, true));
volume_t gases[MAX_CYLINDERS] = {};
get_gas_used(&displayed_dive, gases);
- QString volumes = get_volume_string(gases[0], true);
+ QString volumes;
int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS];
per_cylinder_mean_depth(&displayed_dive, select_dc(&displayed_dive), mean, duration);
volume_t sac;
- QString SACs;
- if (mean[0] && duration[0] && gases[0].mliter) {
- sac.mliter = gases[0].mliter / (depth_to_atm(mean[0], &displayed_dive) * duration[0] / 60.0);
- SACs = get_volume_string(sac, true).append(tr("/min"));
- } else {
- SACs = QString(tr("unknown"));
- }
- for (int i = 1; i < MAX_CYLINDERS && gases[i].mliter != 0; i++) {
- volumes.append("\n" + get_volume_string(gases[i], true));
- if (duration[i] && gases[i].mliter) {
+ QString gaslist, SACs, separator;
+
+ gaslist = ""; SACs = ""; volumes = ""; separator = "";
+ for (int i = 0; i < MAX_CYLINDERS; i++) {
+ if (!is_cylinder_used(&displayed_dive, i))
+ continue;
+ gaslist.append(separator); volumes.append(separator); SACs.append(separator);
+ separator = "\n";
+
+ gaslist.append(gasname(&displayed_dive.cylinder[i].gasmix));
+ if (!gases[i].mliter)
+ continue;
+ volumes.append(get_volume_string(gases[i], true));
+ if (duration[i]) {
sac.mliter = gases[i].mliter / (depth_to_atm(mean[i], &displayed_dive) * duration[i] / 60);
- SACs.append("\n" + get_volume_string(sac, true).append(tr("/min")));
- } else {
- SACs.append("\n");
+ SACs.append(get_volume_string(sac, true).append(tr("/min")));
}
}
ui.gasUsedText->setText(volumes);
- ui.oxygenHeliumText->setText(get_gaslist(&displayed_dive));
+ ui.oxygenHeliumText->setText(gaslist);
ui.dateText->setText(get_short_dive_date_string(displayed_dive.when));
ui.diveTimeText->setText(QString::number((int)((displayed_dive.duration.seconds + 30) / 60)));
if (prevd)