diff options
author | Jan Darowski <jan.darowski@gmail.com> | 2015-07-03 23:07:58 +0200 |
---|---|---|
committer | Jan Darowski <jan.darowski@gmail.com> | 2015-07-03 23:07:58 +0200 |
commit | 500fbe499411bfa96192626c8a6213916190aaae (patch) | |
tree | 2d10ae563e3f39173a622aa63054512175a7050b | |
parent | 2435d79c0e6e4e30ace3b23765005c90181ddae5 (diff) | |
download | subsurface-500fbe499411bfa96192626c8a6213916190aaae.tar.gz |
VPM-B: add deco choice to the ui.
Removed recreational mode from ui and pref and replaced it with
new deco_mode enum.
Added radio button ui selection.
Set default deco_mode to Buehlmann algorithm.
Signed-off-by: Jan Darowski <jan.darowski@gmail.com>
-rw-r--r-- | planner.c | 3 | ||||
-rw-r--r-- | pref.h | 8 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 6 | ||||
-rw-r--r-- | qt-models/diveplannermodel.h | 2 | ||||
-rw-r--r-- | qt-ui/diveplanner.cpp | 20 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 2 | ||||
-rw-r--r-- | qt-ui/plannerSettings.ui | 23 | ||||
-rw-r--r-- | subsurfacestartup.c | 4 |
8 files changed, 53 insertions, 15 deletions
@@ -955,7 +955,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool /* Keep time during the ascend */ bottom_time = clock = previous_point_time = displayed_dive.dc.sample[displayed_dive.dc.samples - 1].time.seconds; gi = gaschangenr - 1; - if(prefs.recreational_mode) { + + if(prefs.deco_mode == RECREATIONAL) { bool safety_stop = prefs.safetystop && max_depth >= 10000; track_ascent_gas(depth, &displayed_dive.cylinder[current_cylinder], avg_depth, bottom_time, safety_stop); // How long can we stay at the current depth and still directly ascent to the surface? @@ -32,6 +32,12 @@ typedef struct { enum taxonomy_category category[3]; } geocoding_prefs_t; +enum deco_mode { + BUEHLMANN, + RECREATIONAL, + VPMB +}; + struct preferences { const char *divelist_font; const char *default_filename; @@ -89,7 +95,6 @@ struct preferences { bool display_runtime; bool display_duration; bool display_transitions; - bool recreational_mode; bool safetystop; bool switch_at_req_stop; int reserve_gas; @@ -110,6 +115,7 @@ struct preferences { short cloud_verification_status; bool cloud_background_sync; geocoding_prefs_t geocoding; + enum deco_mode deco_mode; }; enum unit_system_values { METRIC, diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index adbcdba9a..e28b4d146 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -449,10 +449,10 @@ void DivePlannerPointsModel::setDisplayTransitions(bool value) emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); } -void DivePlannerPointsModel::setRecreationalMode(bool value) +void DivePlannerPointsModel::setDecoMode(int mode) { - prefs.recreational_mode = value; - emit recreationChanged(value); + prefs.deco_mode = deco_mode(mode); + emit recreationChanged(mode == int(RECREATIONAL)); emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS -1)); } diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h index 422499084..a8524393a 100644 --- a/qt-models/diveplannermodel.h +++ b/qt-models/diveplannermodel.h @@ -78,7 +78,7 @@ slots: void setDisplayRuntime(bool value); void setDisplayDuration(bool value); void setDisplayTransitions(bool value); - void setRecreationalMode(bool value); + void setDecoMode(int mode); void setSafetyStop(bool value); void savePlan(); void saveDuplicatePlan(); diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 8b0e93cd8..684ef44aa 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -243,7 +243,7 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) prefs.display_duration = s.value("display_duration", prefs.display_duration).toBool(); prefs.display_runtime = s.value("display_runtime", prefs.display_runtime).toBool(); prefs.display_transitions = s.value("display_transitions", prefs.display_transitions).toBool(); - prefs.recreational_mode = s.value("recreational_mode", prefs.recreational_mode).toBool(); + prefs.deco_mode = deco_mode(s.value("deco_mode", prefs.deco_mode).toInt()); prefs.safetystop = s.value("safetystop", prefs.safetystop).toBool(); prefs.reserve_gas = s.value("reserve_gas", prefs.reserve_gas).toInt(); prefs.ascrate75 = s.value("ascrate75", prefs.ascrate75).toInt(); @@ -269,7 +269,6 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) ui.display_duration->setChecked(prefs.display_duration); ui.display_runtime->setChecked(prefs.display_runtime); ui.display_transitions->setChecked(prefs.display_transitions); - ui.recreational_mode->setChecked(prefs.recreational_mode); ui.safetystop->setChecked(prefs.safetystop); ui.reserve_gas->setValue(prefs.reserve_gas / 1000); ui.bottompo2->setValue(prefs.bottompo2 / 1000.0); @@ -278,17 +277,30 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f) ui.drop_stone_mode->setChecked(prefs.drop_stone_mode); ui.switch_at_req_stop->setChecked(prefs.switch_at_req_stop); ui.min_switch_duration->setValue(prefs.min_switch_duration / 60); + ui.recreational_deco->setChecked(prefs.deco_mode == RECREATIONAL); + ui.buehlmann_deco->setChecked(prefs.deco_mode == BUEHLMANN); + ui.vpmb_deco->setChecked(prefs.deco_mode == VPMB); + // should be the same order as in dive_comp_type! rebreater_modes << tr("Open circuit") << tr("CCR") << tr("pSCR"); ui.rebreathermode->insertItems(0, rebreater_modes); + modeMapper = new QSignalMapper(this); + connect(modeMapper, SIGNAL(mapped(int)) , plannerModel, SLOT(setDecoMode(int))); + modeMapper->setMapping(ui.recreational_deco, int(RECREATIONAL)); + modeMapper->setMapping(ui.buehlmann_deco, int(BUEHLMANN)); + modeMapper->setMapping(ui.vpmb_deco, int(VPMB)); + + connect(ui.recreational_deco, SIGNAL(clicked()), modeMapper, SLOT(map())); + connect(ui.buehlmann_deco, SIGNAL(clicked()), modeMapper, SLOT(map())); + connect(ui.vpmb_deco, SIGNAL(clicked()), modeMapper, SLOT(map())); + 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.safetystop, SIGNAL(toggled(bool)), plannerModel, SLOT(setSafetyStop(bool))); - connect(ui.recreational_mode, SIGNAL(toggled(bool)), plannerModel, SLOT(setRecreationalMode(bool))); connect(ui.reserve_gas, SIGNAL(valueChanged(int)), plannerModel, SLOT(setReserveGas(int))); connect(ui.ascRate75, SIGNAL(valueChanged(int)), this, SLOT(setAscRate75(int))); connect(ui.ascRate75, SIGNAL(valueChanged(int)), plannerModel, SLOT(emitDataChanged())); @@ -341,7 +353,6 @@ PlannerSettingsWidget::~PlannerSettingsWidget() s.setValue("display_duration", prefs.display_duration); s.setValue("display_runtime", prefs.display_runtime); s.setValue("display_transitions", prefs.display_transitions); - s.setValue("recreational_mode", prefs.recreational_mode); s.setValue("safetystop", prefs.safetystop); s.setValue("reserve_gas", prefs.reserve_gas); s.setValue("ascrate75", prefs.ascrate75); @@ -357,6 +368,7 @@ PlannerSettingsWidget::~PlannerSettingsWidget() s.setValue("min_switch_duration", prefs.min_switch_duration); s.setValue("bottomsac", prefs.bottomsac); s.setValue("decosac", prefs.decosac); + s.setValue("deco_mode", int(prefs.deco_mode)); s.endGroup(); } diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 8c7ff9c46..c4210aadf 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -5,6 +5,7 @@ #include <QAbstractTableModel> #include <QAbstractButton> #include <QDateTime> +#include <QSignalMapper> #include "dive.h" @@ -84,6 +85,7 @@ slots: private: Ui::plannerSettingsWidget ui; void updateUnitsUI(); + QSignalMapper *modeMapper; }; #include "ui_plannerDetails.h" diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui index 55ca83a9b..5916b2777 100644 --- a/qt-ui/plannerSettings.ui +++ b/qt-ui/plannerSettings.ui @@ -359,13 +359,30 @@ </widget> </item> <item row="0" column="1"> - <widget class="QCheckBox" name="recreational_mode"> + <widget class="QRadioButton" name="recreational_deco"> <property name="text"> <string>Recreational mode</string> </property> </widget> </item> <item row="1" column="1"> + <widget class="QRadioButton" name="buehlmann_deco"> + <property name="text"> + <string>Buehlmann deco</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QRadioButton" name="vpmb_deco"> + <property name="text"> + <string>VPM-B deco</string> + </property> + </widget> + </item> + <item row="3" column="1"> <widget class="QCheckBox" name="safetystop"> <property name="text"> <string>Safety stop</string> @@ -375,14 +392,14 @@ </property> </widget> </item> - <item row="2" column="1"> + <item row="4" column="1"> <widget class="QLabel" name="label_3"> <property name="text"> <string>Reserve gas</string> </property> </widget> </item> - <item row="2" column="2"> + <item row="4" column="2"> <widget class="QSpinBox" name="reserve_gas"> <property name="suffix"> <string>bar</string> diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 3005e7e04..17bd43e45 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -54,7 +54,6 @@ struct preferences default_prefs = { .display_runtime = true, .display_duration = true, .display_transitions = true, - .recreational_mode = false, .safetystop = true, .bottomsac = 20000, .decosac = 17000, @@ -75,7 +74,8 @@ struct preferences default_prefs = { .parse_dive_without_gps = false, .tag_existing_dives = false, .category = { 0 } - } + }, + .deco_mode = BUEHLMANN }; int run_survey; |