From 4bb8368a20ad03cb5c1c9134df0a55a653c10cf0 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Tue, 12 Nov 2013 23:09:57 +0100 Subject: Introduce an on/off switch for calculating ndl/tts Let the user choose if the calculation of ndl and tts is worth the time it takes. Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- pref.h | 1 + profile.c | 5 +++++ qt-ui/mainwindow.cpp | 1 + qt-ui/preferences.cpp | 4 ++++ qt-ui/preferences.ui | 26 ++++++++++++++++++++++++++ subsurfacestartup.c | 1 + 6 files changed, 38 insertions(+) diff --git a/pref.h b/pref.h index e59ad1c6a..29c9df2f0 100644 --- a/pref.h +++ b/pref.h @@ -28,6 +28,7 @@ struct preferences { short profile_calc_ceiling; short calc_ceiling_3m_incr; short calc_all_tissues; + short calc_ndl_tts; short gflow; short gfhigh; int map_provider; diff --git a/profile.c b/profile.c index edeb17a9d..303da6998 100644 --- a/profile.c +++ b/profile.c @@ -1014,6 +1014,11 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d entry->ceilings[k] = deco_allowed_depth(tolerated_by_tissue[k], surface_pressure, dive, 1); /* calculate DECO STOP / TTS / NDL */ + + /* bail if we shouldn't */ + if (!prefs.calc_ndl_tts) + continue; + /* We are going to mess up deco state, so store it for later restore */ char *cache_data = NULL; cache_deco_state(tissue_tolerance, &cache_data); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index c111f3926..0b3eea424 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -618,6 +618,7 @@ void MainWindow::readSettings() GET_BOOL("dcceiling", profile_dc_ceiling); GET_BOOL("calcceiling", profile_calc_ceiling); GET_BOOL("calcceiling3m", calc_ceiling_3m_incr); + GET_BOOL("calcndltts", calc_ndl_tts); GET_BOOL("calcalltissues", calc_all_tissues); GET_INT("gflow", gflow); GET_INT("gfhigh", gfhigh); diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 4ba8739a3..f35901709 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -46,6 +46,8 @@ void PreferencesDialog::setUiFromPrefs() ui.increment_3m->setChecked(prefs.calc_ceiling_3m_incr); ui.all_tissues->setEnabled(ui.calculated_ceiling->isChecked()); ui.all_tissues->setChecked(prefs.calc_all_tissues); + ui.calc_ndl_tts->setEnabled(ui.calculated_ceiling->isChecked()); + ui.calc_ndl_tts->setChecked(prefs.calc_ndl_tts); ui.groupBox->setEnabled(ui.personalize->isChecked()); ui.gflow->setValue(prefs.gflow); @@ -104,6 +106,7 @@ void PreferencesDialog::setPrefsFromUi() SP(profile_red_ceiling, ui.red_ceiling); SP(profile_calc_ceiling, ui.calculated_ceiling); SP(calc_ceiling_3m_incr, ui.increment_3m); + SP(calc_ndl_tts, ui.calc_ndl_tts); SP(calc_all_tissues, ui.all_tissues); prefs.gflow = ui.gflow->value(); prefs.gfhigh = ui.gfhigh->value(); @@ -142,6 +145,7 @@ void PreferencesDialog::syncSettings() SB("redceiling", ui.red_ceiling); SB("calcceiling", ui.calculated_ceiling); SB("calcceiling3m", ui.increment_3m); + SB("calcndltts", ui.calc_ndl_tts); SB("calcalltissues", ui.all_tissues); s.setValue("gflow", ui.gflow->value()); s.setValue("gfhigh", ui.gfhigh->value()); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index df7333837..b02e7f13a 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -711,6 +711,16 @@ + + + + false + + + Calculate NDL/TTS + + + @@ -997,6 +1007,22 @@ + + calculated_ceiling + clicked(bool) + calc_ndl_tts + setEnabled(bool) + + + 298 + 327 + + + 668 + 327 + + + dc_reported_ceiling clicked(bool) diff --git a/subsurfacestartup.c b/subsurfacestartup.c index bc5cd42f4..8530b2f3a 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -22,6 +22,7 @@ struct preferences default_prefs = { .profile_red_ceiling = FALSE, .profile_calc_ceiling = FALSE, .calc_ceiling_3m_incr = FALSE, + .calc_ndl_tts = FALSE, .gflow = 30, .gfhigh = 75, .font_size = 14.0, -- cgit v1.2.3-70-g09d2