From 772727fc7f44faaf94afc24bd1f151e40ddaefef Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Wed, 25 Jun 2014 00:08:36 +0200 Subject: Hook up UI elements for ascent rates to planner That provides some UI elements that were recently introduced with function of allowing the ascent rates of the planner to be configured by the user. I tried to make it work both with senisble as well as with imperial units. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- planner.c | 19 ++++--- pref.h | 7 +++ qt-ui/diveplanner.cpp | 49 ++++++++++++++++++ qt-ui/diveplanner.h | 5 ++ qt-ui/plannerSettings.ui | 128 ++++++++++++++++++++++++----------------------- subsurfacestartup.c | 7 ++- 6 files changed, 144 insertions(+), 71 deletions(-) diff --git a/planner.c b/planner.c index 3168f0ff9..13a9a489a 100644 --- a/planner.c +++ b/planner.c @@ -687,13 +687,18 @@ int ascend_velocity(int depth, int avg_depth, int bottom_time) /* As an example (and possibly reasonable default) this is the Tech 1 provedure according * to http://www.globalunderwaterexplorers.org/files/Standards_and_Procedures/SOP_Manual_Ver2.0.2.pdf */ - if (depth <= 6000) - return 1000 / 60; - - if (depth * 4 > avg_depth * 3) - return 9000 / 60; - else - return 6000 / 60; + if (depth * 4 > avg_depth * 3) { + return prefs.ascrate75; + } else { + if (depth * 2 > avg_depth) { + return prefs.ascrate50; + } else { + if (depth > 6000) + return prefs.ascratestops; + else + return prefs.ascratelast6m; + } + } } void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, struct dive *master_dive, bool add_deco, bool show_disclaimer) diff --git a/pref.h b/pref.h index 811ca3366..076441867 100644 --- a/pref.h +++ b/pref.h @@ -46,6 +46,13 @@ struct preferences { short rulergraph; short save_userid_local; char *userid; + int ascrate75; + int ascrate50; + int ascratestops; + int ascratelast6m; + int descrate; + int bottompo2; + int decopo2; }; enum unit_system_values { METRIC, diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 516b36b0f..249b03773 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -31,6 +31,8 @@ #define MAX_DEPTH M_OR_FT(150, 450) #define MIN_DEPTH M_OR_FT(20, 60) +#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0) + QString gasToStr(struct gasmix gas) { uint o2 = (gas.o2.permille + 5) / 10, he = (gas.he.permille + 5) / 10; @@ -333,11 +335,34 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) { ui.setupUi(this); + if (prefs.units.METERS == units::FEET) { + ui.ascRate75->setSuffix("ft/min"); + ui.ascRate50->setSuffix("ft/min"); + ui.ascRateStops->setSuffix("ft/min"); + ui.ascRateLast6m->setSuffix("ft/min"); + ui.descRate->setSuffix("ft/min"); + } + ui.ascRate75->setValue(prefs.ascrate75 / UNIT_FACTOR); + ui.ascRate50->setValue(prefs.ascrate50 / UNIT_FACTOR); + ui.ascRateStops->setValue(prefs.ascratestops / UNIT_FACTOR); + ui.ascRateLast6m->setValue(prefs.ascratelast6m / UNIT_FACTOR); + ui.descRate->setValue(prefs.descrate / UNIT_FACTOR); + connect(ui.lastStop, SIGNAL(toggled(bool)), plannerModel, SLOT(setLastStop6m(bool))); connect(ui.verbatim_plan, SIGNAL(toggled(bool)), plannerModel, SLOT(setVerbatim(bool))); connect(ui.display_duration, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayDuration(bool))); connect(ui.display_runtime, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayRuntime(bool))); connect(ui.display_transitions, SIGNAL(toggled(bool)), plannerModel, SLOT(setDisplayTransitions(bool))); + connect(ui.ascRate75, SIGNAL(valueChanged(int)), this, SLOT(setAscRate75(int))); + connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.ascRate50, SIGNAL(valueChanged(int)), this, SLOT(setAscRate50(int))); + connect(ui.ascRate50, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.ascRateStops, SIGNAL(valueChanged(int)), this, SLOT(setAscRateStops(int))); + connect(ui.ascRateStops, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), this, SLOT(setAscRateLast6m(int))); + connect(ui.ascRateLast6m, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); + connect(ui.descRate, SIGNAL(valueChanged(int)), this, SLOT(setDescRate())); + connect(ui.descRate, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); setMinimumWidth(0); setMinimumHeight(0); @@ -363,6 +388,30 @@ void PlannerSettingsWidget::printDecoPlan() { } +void PlannerSettingsWidget::setAscRate75(int rate) +{ + prefs.ascrate75 = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setAscRate50(int rate) +{ + prefs.ascrate50 = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setAscRateStops(int rate) +{ + prefs.ascratestops = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setAscRateLast6m(int rate) +{ + prefs.ascratelast6m = rate * UNIT_FACTOR; +} + +void PlannerSettingsWidget::setDescRate(int rate) +{ + prefs.descrate = rate * UNIT_FACTOR; +} void DivePlannerPointsModel::setPlanMode(Mode m) { diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 0b4e783cb..9f6052b4a 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -159,6 +159,11 @@ slots: void bottomSacChanged(const int bottomSac); void decoSacChanged(const int decosac); void printDecoPlan(); + void setAscRate75(int rate); + void setAscRate50(int rate); + void setAscRateStops(int rate); + void setAscRateLast6m(int rate); + void setDescRate(int rate); private: Ui::plannerSettingsWidget ui; diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui index 82584fa0e..519f3ea7c 100644 --- a/qt-ui/plannerSettings.ui +++ b/qt-ui/plannerSettings.ui @@ -19,7 +19,7 @@ 20 20 872 - 203 + 463 @@ -62,6 +62,9 @@ QFrame::Raised + + QFormLayout::FieldsStayAtSizeHint + @@ -69,15 +72,8 @@ - - - - deco pO₂ - - - - + 16777215 @@ -86,8 +82,15 @@ + + + + deco pO₂ + + + - + 16777215 @@ -176,67 +179,27 @@ - - - - - 16777215 - 20 - - - - - + 75%-50% avg. depth - + 50% avg. depth - 6m/20ft - + 6m/20ft to surface - - - - - 16777215 - 20 - - - - - - - - - 16777215 - 20 - - - - - - - - - 16777215 - 20 - - - - @@ -244,21 +207,21 @@ - + - Decent rate + Descent rate - + surface to the bottom - + @@ -272,6 +235,9 @@ 20 + + m/min + 1 @@ -280,6 +246,46 @@ + + + + m/min + + + 1 + + + + + + + m/min + + + 1 + + + + + + + m/min + + + 1 + + + + + + + m/min + + + 1 + + + @@ -291,14 +297,10 @@ display_runtime display_duration display_transitions - ascRate75 - ascRate50 - ascRateStops - ascRateLast6m lastStop backgasBreaks - ascRate75_2 - ascRate75_3 + bottompo2 + decopo2 descRate diff --git a/subsurfacestartup.c b/subsurfacestartup.c index da9fc2358..463aea63a 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -32,7 +32,12 @@ struct preferences default_prefs = { .display_invalid_dives = false, .show_sac = false, .display_unused_tanks = false, - .show_average_depth = true + .show_average_depth = true, + .ascrate75 = 9000 / 60, + .ascrate50 = 6000 / 60, + .ascratestops = 6000 / 60, + .ascratelast6m = 1000 / 60, + .descrate = 18000 / 60 }; int run_survey; -- cgit v1.2.3-70-g09d2