From 65c5d6815cf7c78231abd76440bb5bab54d9d51c Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Wed, 25 Jun 2014 14:00:03 +0200 Subject: Make pO2 settings functional in planner Spin boxes for pO2 are now hooked up to preference values. Adding new cylinders (or changing their fo2) computes the MOD accordin to the current value of decopo2. Note that chaning the limits for deco pO2 does _not_ automatically update the switch depth of all cylinders as those might have been manually entered. Furthermore, MOD has now to option of rounding to multiples of a given depth. That is used for the automatic switch depth which are now always multiples of 3m (so that EAN50 is switched to at 21m rather than 22m). Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 20 ++++++++++++++++++-- qt-ui/diveplanner.h | 2 ++ qt-ui/models.cpp | 4 ++-- qt-ui/plannerSettings.ui | 46 ++++++++++++++++++++++++++++------------------ 4 files changed, 50 insertions(+), 22 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 1ba00a7f9..57438eb39 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -347,6 +347,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) ui.ascRateStops->setValue(prefs.ascratestops / UNIT_FACTOR); ui.ascRateLast6m->setValue(prefs.ascratelast6m / UNIT_FACTOR); ui.descRate->setValue(prefs.descrate / UNIT_FACTOR); + ui.bottompo2->setValue(prefs.bottompo2 / 1000.0); + ui.decopo2->setValue(prefs.decopo2 / 1000.0); connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool))); @@ -363,6 +365,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); connect(ui.descRate, SIGNAL(valueChanged(int)), this, SLOT(setDescRate(int))); connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.bottompo2, SIGNAL(valueChanged(double)), this, SLOT(setBottomPo2(double))); + connect(ui.decopo2, SIGNAL(valueChanged(double)), this, SLOT(setDecoPo2(double))); setMinimumWidth(0); setMinimumHeight(0); @@ -413,6 +417,17 @@ void PlannerSettingsWidget::setDescRate(int rate) prefs.descrate = rate * UNIT_FACTOR; } +void PlannerSettingsWidget::setBottomPo2(double po2) +{ + prefs.bottompo2 = (int) (po2 * 1000.0); +} + +void PlannerSettingsWidget::setDecoPo2(double po2) +{ + prefs.decopo2 = (int) (po2 * 1000.0); +} + + void DivePlannerPointsModel::setPlanMode(Mode m) { mode = m; @@ -678,8 +693,9 @@ bool DivePlannerPointsModel::addGas(struct gasmix mix) /* The depth to change to that gas is given by the depth where its pO₂ is 1.6 bar. * The user should be able to change this depth manually. */ pressure_t modpO2; - modpO2.mbar = 1600; - cyl->depth = gas_mod(&mix, modpO2); + modpO2.mbar = prefs.decopo2; + cyl->depth = gas_mod(&mix, modpO2, 3000); + CylindersModel::instance()->setDive(stagingDive); return true; } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 9f6052b4a..5955a5a8f 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -164,6 +164,8 @@ slots: void setAscRateStops(int rate); void setAscRateLast6m(int rate); void setDescRate(int rate); + void setBottomPo2(double po2); + void setDecoPo2(double po2); private: Ui::plannerSettingsWidget ui; diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 167f54813..a5a1f5bff 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -250,8 +250,8 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in if (CHANGED()) { cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data()); pressure_t modpO2; - modpO2.mbar = 1600; - cyl->depth = gas_mod(&cyl->gasmix, modpO2); + modpO2.mbar = prefs.decopo2; + cyl->depth = gas_mod(&cyl->gasmix, modpO2, 3000); changed = true; } break; diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui index 519f3ea7c..57814eabb 100644 --- a/qt-ui/plannerSettings.ui +++ b/qt-ui/plannerSettings.ui @@ -72,16 +72,6 @@ - - - - - 16777215 - 20 - - - - @@ -90,12 +80,34 @@ - - - - 16777215 - 20 - + + + bar + + + 2.000000000000000 + + + 0.100000000000000 + + + 1.600000000000000 + + + + + + + bar + + + 2.000000000000000 + + + 0.100000000000000 + + + 1.400000000000000 @@ -299,8 +311,6 @@ display_transitions lastStop backgasBreaks - bottompo2 - decopo2 descRate -- cgit v1.2.3-70-g09d2