aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.c11
-rw-r--r--dive.h1
-rw-r--r--qt-ui/diveplanner.cpp26
-rw-r--r--qt-ui/plannerSettings.ui22
4 files changed, 52 insertions, 8 deletions
diff --git a/dive.c b/dive.c
index 4f42e48d6..4e81f8a70 100644
--- a/dive.c
+++ b/dive.c
@@ -188,6 +188,17 @@ double get_volume_units(unsigned int ml, int *frac, const char **units)
return vol;
}
+int units_to_sac(int volume)
+{
+ if(get_units()->volume == CUFT)
+ if (volume < 10)
+ return cuft_to_l(volume) * 100;
+ else
+ return cuft_to_l(volume) * 10;
+ else
+ return volume * 1000;
+}
+
unsigned int units_to_depth(double depth)
{
if (get_units()->length == METERS)
diff --git a/dive.h b/dive.h
index 7cd67fa27..144726135 100644
--- a/dive.h
+++ b/dive.h
@@ -99,6 +99,7 @@ extern double get_weight_units(unsigned int grams, int *frac, const char **units
extern double get_vertical_speed_units(unsigned int mms, int *frac, const char **units);
extern unsigned int units_to_depth(double depth);
+extern int units_to_sac(int volume);
/* Volume in mliter of a cylinder at pressure 'p' */
extern int gas_volume(cylinder_t *cyl, pressure_t p);
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 09320cafe..e51400ac0 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -416,8 +416,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow()));
connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
- ui.bottomSAC->setValue(prefs.bottomsac / 1000.0);
- ui.decoStopSAC->setValue(prefs.decosac / 1000.0);
+ ui.bottomSAC->setValue(rint(get_volume_units(prefs.bottomsac, NULL, NULL)));
+ ui.decoStopSAC->setValue(rint(get_volume_units(prefs.decosac, NULL, NULL)));
ui.gflow->setValue(prefs.gflow);
ui.gfhigh->setValue(prefs.gfhigh);
@@ -466,6 +466,21 @@ void PlannerSettingsWidget::settingsChanged()
ui.asc50to6->setText(tr("50% avg. depth to 6m"));
ui.asc6toSurf->setText(tr("6m to surface"));
}
+ if(get_units()->volume == units::CUFT) {
+ ui.bottomSAC->setSuffix(tr("cuft/min"));
+ ui.decoStopSAC->setSuffix(tr("cuft/min"));
+ ui.bottomSAC->setPrefix(".");
+ ui.decoStopSAC->setPrefix(".");
+ ui.bottomSAC->setValue(rint(ml_to_cuft(prefs.bottomsac) * 100.0));
+ ui.decoStopSAC->setValue(rint(ml_to_cuft(prefs.decosac) * 100.0));
+ } else {
+ ui.bottomSAC->setSuffix(tr("ℓ/min"));
+ ui.decoStopSAC->setSuffix(tr("ℓ/min"));
+ ui.bottomSAC->setPrefix("");
+ ui.decoStopSAC->setPrefix("");
+ ui.bottomSAC->setValue(rint((double) prefs.bottomsac / 1000.0));
+ ui.decoStopSAC->setValue(rint((double) prefs.decosac / 1000.0));
+ }
updateUnitsUI();
ui.ascRate75->setSuffix(vs);
ui.ascRate50->setSuffix(vs);
@@ -690,14 +705,17 @@ void DivePlannerPointsModel::emitDataChanged()
void DivePlannerPointsModel::setBottomSac(int sac)
{
- diveplan.bottomsac = sac * 1000;
+ volume_t newSAC;
+ newSAC.mliter = units_to_sac(sac);
+ diveplan.bottomsac = newSAC.mliter;
prefs.bottomsac = diveplan.bottomsac;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDecoSac(int sac)
{
- diveplan.decosac = sac * 1000;
+ volume_t newSAC;
+ diveplan.decosac = units_to_sac(sac);
prefs.decosac = diveplan.decosac;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui
index 0ad0f5b70..a28453c01 100644
--- a/qt-ui/plannerSettings.ui
+++ b/qt-ui/plannerSettings.ui
@@ -30,8 +30,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1089</width>
- <height>404</height>
+ <width>1078</width>
+ <height>418</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -271,6 +271,9 @@
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="gflow">
+ <property name="suffix">
+ <string>%</string>
+ </property>
<property name="minimum">
<number>1</number>
</property>
@@ -288,6 +291,9 @@
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="gfhigh">
+ <property name="suffix">
+ <string>%</string>
+ </property>
<property name="minimum">
<number>1</number>
</property>
@@ -362,7 +368,11 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QSpinBox" name="bottomSAC"/>
+ <widget class="QSpinBox" name="bottomSAC">
+ <property name="suffix">
+ <string>ℓ/min</string>
+ </property>
+ </widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_14">
@@ -372,7 +382,11 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QSpinBox" name="decoStopSAC"/>
+ <widget class="QSpinBox" name="decoStopSAC">
+ <property name="suffix">
+ <string>ℓ/min</string>
+ </property>
+ </widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">