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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2014-06-25 00:08:36 +02:00 committed by Dirk Hohndel
parent 2ae6f8078a
commit 772727fc7f
6 changed files with 146 additions and 73 deletions

View file

@ -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)

7
pref.h
View file

@ -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,

View file

@ -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)
{

View file

@ -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;

View file

@ -19,7 +19,7 @@
<x>20</x>
<y>20</y>
<width>872</width>
<height>203</height>
<height>463</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -62,6 +62,9 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@ -69,6 +72,16 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="bottompo2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
@ -76,18 +89,8 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="ascRate75_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPlainTextEdit" name="ascRate75_3">
<widget class="QPlainTextEdit" name="decopo2">
<property name="maximumSize">
<size>
<width>16777215</width>
@ -176,67 +179,27 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="ascRate75">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>75%-50% avg. depth</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>50% avg. depth - 6m/20ft</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>6m/20ft to surface</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPlainTextEdit" name="ascRate50">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPlainTextEdit" name="ascRateStops">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPlainTextEdit" name="ascRateLast6m">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
@ -244,21 +207,21 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Decent rate</string>
<string>Descent rate</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>surface to the bottom</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="8" column="1">
<widget class="QSpinBox" name="descRate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -272,6 +235,9 @@
<height>20</height>
</size>
</property>
<property name="suffix">
<string>m/min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
@ -280,6 +246,46 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="ascRate75">
<property name="suffix">
<string>m/min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="ascRate50">
<property name="suffix">
<string>m/min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="ascRateStops">
<property name="suffix">
<string>m/min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="ascRateLast6m">
<property name="suffix">
<string>m/min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -291,14 +297,10 @@
<tabstop>display_runtime</tabstop>
<tabstop>display_duration</tabstop>
<tabstop>display_transitions</tabstop>
<tabstop>ascRate75</tabstop>
<tabstop>ascRate50</tabstop>
<tabstop>ascRateStops</tabstop>
<tabstop>ascRateLast6m</tabstop>
<tabstop>lastStop</tabstop>
<tabstop>backgasBreaks</tabstop>
<tabstop>ascRate75_2</tabstop>
<tabstop>ascRate75_3</tabstop>
<tabstop>bottompo2</tabstop>
<tabstop>decopo2</tabstop>
<tabstop>descRate</tabstop>
</tabstops>
<resources/>

View file

@ -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;