summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2016-05-21 19:32:08 +1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-05-21 07:03:30 -0700
commit67dda48c884b7413e46acde4e890c0fa19640f67 (patch)
tree1e8f650062b284dc86075ae4cfcaf7a9a3ad6b5b /qt-models
parentb61b3a8d2891c93b1ee95a826133ede2f3a9ca6d (diff)
downloadsubsurface-67dda48c884b7413e46acde4e890c0fa19640f67.tar.gz
Add best mix function to planner cylinder model
This allows calculation and selection of best mix in the planner cylinder entry, by entering the gas depth, followed by "b" for best (trimix) mix, or "bn" for best nitrox mix. The UI is not intuitive, but it is quick and easy. At the very least, it should be documented. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/cylindermodel.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index 350d15aa4..1ad03f94d 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -267,6 +267,15 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
break;
case DEPTH:
if (CHANGED()) {
+ /* Calculate best nitrox mix for cylinder depth if input text ends with "bn",
+ * or best (trimix) mix if input text ends with "b" */
+ if (vString.toLower().endsWith("bn")) {
+ cyl->gasmix.o2 = best_o2(string_to_depth(vString.toUtf8().data()), &displayed_dive);
+ cyl->gasmix.he.permille = 0;
+ } else if (vString.toLower().endsWith("b")) {
+ cyl->gasmix.o2 = best_o2(string_to_depth(vString.toUtf8().data()), &displayed_dive);
+ cyl->gasmix.he = best_He(string_to_depth(vString.toUtf8().data()), &displayed_dive);
+ }
cyl->depth = string_to_depth(vString.toUtf8().data());
changed = true;
}