mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Show altitude corresponding to surface pressure
In the information tab, presenting atmospheric pressure is a bit unintuitive because the diver cannot easily relate that to altitude. For the Atm. Pressure widget in the Information tab this code does: If the atmospheric pressure for a dive exists and the user selects the 'm' or 'ft' option from the combobox, then the estimated altitude is shown in the text box. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
This commit is contained in:
parent
e434b5aa40
commit
ebaac21ef5
1 changed files with 12 additions and 2 deletions
|
@ -249,9 +249,11 @@ void TabDiveInformation::updateTextBox(int event) // Either the text box has bee
|
||||||
double altitudeVal; // maintained even though two independent events trigger saving the text box contents.
|
double altitudeVal; // maintained even though two independent events trigger saving the text box contents.
|
||||||
if (current_dive) {
|
if (current_dive) {
|
||||||
switch (ui->atmPressType->currentIndex()) {
|
switch (ui->atmPressType->currentIndex()) {
|
||||||
case 0: // If an atm pressure has been specified in mbar:
|
case 0: // If atm pressure in mbar has been selected:
|
||||||
if (event == TEXT_EDITED) // this is only triggered by on_atmPressVal_editingFinished()
|
if (event == TEXT_EDITED) // this is only triggered by on_atmPressVal_editingFinished()
|
||||||
atmpress.mbar = ui->atmPressVal->text().toInt(); // use the specified mbar pressure
|
atmpress.mbar = ui->atmPressVal->text().toInt(); // use the specified mbar pressure
|
||||||
|
else // if no pressure has been typed, then show existing dive pressure
|
||||||
|
ui->atmPressVal->setText(QString::number(current_dive->surface_pressure.mbar));
|
||||||
break;
|
break;
|
||||||
case 1: // If an altitude has been specified:
|
case 1: // If an altitude has been specified:
|
||||||
if (event == TEXT_EDITED) { // this is only triggered by on_atmPressVal_editingFinished()
|
if (event == TEXT_EDITED) { // this is only triggered by on_atmPressVal_editingFinished()
|
||||||
|
@ -264,7 +266,15 @@ void TabDiveInformation::updateTextBox(int event) // Either the text box has bee
|
||||||
ui->atmPressVal->setText(ui->atmPressVal->text().sprintf("%d",atmpress.mbar));
|
ui->atmPressVal->setText(ui->atmPressVal->text().sprintf("%d",atmpress.mbar));
|
||||||
ui->atmPressType->setCurrentIndex(0); // reset combobox to mbar
|
ui->atmPressType->setCurrentIndex(0); // reset combobox to mbar
|
||||||
} else { // i.e. event == COMBO_CHANGED, that is, "m" or "ft" was selected from combobox
|
} else { // i.e. event == COMBO_CHANGED, that is, "m" or "ft" was selected from combobox
|
||||||
ui->atmPressVal->clear(); // Clear the text box so that altitude can be typed
|
// Show estimated altitude
|
||||||
|
bool ok;
|
||||||
|
double convertVal = 0.0010; // Metric conversion fro mm to m
|
||||||
|
int pressure_as_integer = ui->atmPressVal->text().toInt(&ok,10);
|
||||||
|
if (ok && ui->atmPressVal->text().length()) { // Show existing atm press as an altitude:
|
||||||
|
if (prefs.units.length == units::FEET) // For imperial units
|
||||||
|
convertVal = mm_to_feet(1); // convert from mm to ft
|
||||||
|
ui->atmPressVal->setText(QString::number((int)(pressure_to_altitude(pressure_as_integer) * convertVal)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: // i.e. event = COMBO_CHANGED, that is, the option "Use dc" was selected from combobox
|
case 2: // i.e. event = COMBO_CHANGED, that is, the option "Use dc" was selected from combobox
|
||||||
|
|
Loading…
Add table
Reference in a new issue