summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-26 08:23:22 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-26 08:23:22 -0700
commitcfe865dd0c78a81717993b479894fd0e823767d3 (patch)
tree5abcefc1e943daec1241d59f1dd753685124d635 /qt-ui/diveplanner.cpp
parentd14a531510e22baa236f661e2235e20dac6d7f6d (diff)
parent04b6b6aaf9cc194a698c2302abc2032f730aecb4 (diff)
downloadsubsurface-cfe865dd0c78a81717993b479894fd0e823767d3.tar.gz
Merge branch 'atdotde'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Conflicts: qt-ui/diveplanner.cpp qt-ui/models.cpp
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 3ffacdd2b..ada2b4e73 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -79,8 +79,8 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
CylindersModel::instance()->setDive(stagingDive);
int lasttime = 0;
// we start with the first gas and see if it was changed
- int o2 = backupDive.cylinder[0].gasmix.o2.permille;
- int he = backupDive.cylinder[0].gasmix.he.permille;
+ int o2 = get_o2(&backupDive.cylinder[0].gasmix);
+ int he = get_he(&backupDive.cylinder[0].gasmix);
for (int i = 0; i < backupDive.dc.samples - 1; i++) {
const sample &s = backupDive.dc.sample[i];
if (s.time.seconds == 0)
@@ -118,7 +118,7 @@ QStringList &DivePlannerPointsModel::getGasList()
cylinder_t *cyl = &activeDive->cylinder[i];
if (cylinder_nodata(cyl))
break;
- list.push_back(gasToStr(cyl->gasmix.o2.permille, cyl->gasmix.he.permille));
+ list.push_back(gasToStr(get_o2(&cyl->gasmix), get_he(&cyl->gasmix)));
}
}
return list;
@@ -488,6 +488,12 @@ bool divePointsLessThan(const divedatapoint &p1, const divedatapoint &p2)
bool DivePlannerPointsModel::addGas(int o2, int he)
{
+ struct gasmix mix;
+
+ mix.o2.permille = o2;
+ mix.he.permille = he;
+ sanitize_gasmix(&mix);
+
if (is_air(o2, he))
o2 = 0;
@@ -497,6 +503,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he)
fill_default_cylinder(cyl);
cyl->gasmix.o2.permille = o2;
cyl->gasmix.he.permille = he;
+ sanitize_gasmix(&cyl->gasmix);
/* The depth to change to that gas is given by the depth where its pO2 is 1.6 bar.
* The user should be able to change this depth manually. */
pressure_t modppO2;
@@ -505,7 +512,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he)
CylindersModel::instance()->setDive(stagingDive);
return true;
}
- if (cyl->gasmix.o2.permille == o2 && cyl->gasmix.he.permille == he)
+ if (!gasmix_distance(&cyl->gasmix, &mix))
return true;
}
qDebug("too many gases");
@@ -540,8 +547,8 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he,
//Default to the first defined gas, if we got one.
cylinder_t *cyl = &stagingDive->cylinder[0];
if (cyl) {
- o2 = cyl->gasmix.o2.permille;
- he = cyl->gasmix.he.permille;
+ o2 = get_o2(&cyl->gasmix);
+ he = get_he(&cyl->gasmix);
}
}
if (o2 != -1)
@@ -661,7 +668,7 @@ QVector<QPair<int, int> > DivePlannerPointsModel::collectGases(struct dive *d)
for (int i = 0; i < MAX_CYLINDERS; i++) {
cylinder_t *cyl = &d->cylinder[i];
if (!cylinder_nodata(cyl))
- l.push_back(qMakePair(cyl->gasmix.o2.permille, cyl->gasmix.he.permille));
+ l.push_back(qMakePair(get_o2(&cyl->gasmix), get_he(&cyl->gasmix)));
}
return l;
}
@@ -761,7 +768,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
for (int i = 0; i < MAX_CYLINDERS; i++) {
cylinder_t *cyl = &stagingDive->cylinder[i];
if (cyl->depth.mm) {
- dp = create_dp(0, cyl->depth.mm, cyl->gasmix.o2.permille, cyl->gasmix.he.permille, 0);
+ dp = create_dp(0, cyl->depth.mm, get_o2(&cyl->gasmix), get_he(&cyl->gasmix), 0);
if (diveplan.dp) {
dp->next = diveplan.dp->next;
diveplan.dp->next = dp;