summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-25 21:36:30 +0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-25 21:41:58 +0800
commit7f3efbdc98deeb4e4bcd481335761b6439b9552c (patch)
tree429daf20fa70a9148a4253914e705d444ea58bf8
parent65c5d6815cf7c78231abd76440bb5bab54d9d51c (diff)
downloadsubsurface-7f3efbdc98deeb4e4bcd481335761b6439b9552c.tar.gz
Make gas mod be reasonable for users of imperial units as well
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--equipment.c2
-rw-r--r--helpers.h2
-rw-r--r--qt-ui/diveplanner.cpp2
-rw-r--r--qt-ui/models.cpp2
-rw-r--r--subsurface.pro1
-rw-r--r--units.h6
6 files changed, 10 insertions, 5 deletions
diff --git a/equipment.c b/equipment.c
index 6d09e6fab..51020e5a3 100644
--- a/equipment.c
+++ b/equipment.c
@@ -241,7 +241,7 @@ void reset_cylinders(struct dive *dive)
if (cylinder_none(cyl))
continue;
if (cyl->depth.mm == 0) /* if the gas doesn't give a mod, assume conservative pO2 */
- cyl->depth = gas_mod(&cyl->gasmix, pO2, 3000);
+ cyl->depth = gas_mod(&cyl->gasmix, pO2, M_OR_FT(3,10));
if (cyl->type.workingpressure.mbar)
cyl->start.mbar = cyl->end.mbar = cyl->type.workingpressure.mbar;
cyl->gas_used.mliter = 0;
diff --git a/helpers.h b/helpers.h
index 392dcb5ac..4d9684e9c 100644
--- a/helpers.h
+++ b/helpers.h
@@ -35,8 +35,6 @@ QString get_trip_date_string(timestamp_t when, int nr);
QString uiLanguage(QLocale *callerLoc);
void selectedDivesGasUsed(QVector<QPair<QString, int> > &gasUsed);
-#define M_OR_FT(_m, _f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
-
#if defined __APPLE__
#define TITLE_OR_TEXT(_t, _m) "", _t + "\n" + _m
#else
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 57438eb39..0708b6aef 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -694,7 +694,7 @@ bool DivePlannerPointsModel::addGas(struct gasmix mix)
* The user should be able to change this depth manually. */
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&mix, modpO2, 3000);
+ cyl->depth = gas_mod(&mix, modpO2, M_OR_FT(3,10));
CylindersModel::instance()->setDive(stagingDive);
return true;
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index a5a1f5bff..823619f64 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -251,7 +251,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data());
pressure_t modpO2;
modpO2.mbar = prefs.decopo2;
- cyl->depth = gas_mod(&cyl->gasmix, modpO2, 3000);
+ cyl->depth = gas_mod(&cyl->gasmix, modpO2, M_OR_FT(3,10));
changed = true;
}
break;
diff --git a/subsurface.pro b/subsurface.pro
index 86d19cd71..3dec531c2 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -35,6 +35,7 @@ HEADERS = \
profile.h \
qt-gui.h \
qthelper.h \
+ units.h \
divecomputer.h \
qt-ui/about.h \
qt-ui/completionmodels.h \
diff --git a/units.h b/units.h
index 4b32d5237..a8c0d7dbc 100644
--- a/units.h
+++ b/units.h
@@ -16,6 +16,12 @@ extern "C" {
#define SURFACE_PRESSURE_STRING "1013"
#define ZERO_C_IN_MKELVIN 273150 // mKelvin
+#ifdef __cplusplus
+#define M_OR_FT(_m, _f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
+#else
+#define M_OR_FT(_m, _f) ((prefs.units.length == METERS) ? ((_m) * 1000) : (feet_to_mm(_f)))
+#endif
+
/* Salinity is expressed in weight in grams per 10l */
#define SEAWATER_SALINITY 10300
#define FRESHWATER_SALINITY 10000