mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make SAC values in planner settings respect unit settings
So far, the fields for the two SAC rates did not show a unit and were implictly l/min. Now they respect the settings for volume units. This was harder than I thought for two reasons: 1) Imperial units for SAC are cuft/min but a typical value would be .70. So I made the point the field prefix and what is entered is actually hundreth of cuft per minute. 2) I had to get the rounding right in order not to get effects like 20l/min become .70 cuft/min (19800 ml/min internally) which would then become 19l/min when switching back. While being at it, I gave the gradient factors '%'-signs as units. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d453d5cb37
commit
ecf0408aae
4 changed files with 52 additions and 8 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue