summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-06-23 19:21:29 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-24 17:26:31 +0800
commitccfdcca6e63336fddf4444e7bcf56c009c6195f7 (patch)
treeb49d1107430b386e84ede52a65d404dd28ce18aa /qt-ui/diveplanner.cpp
parent5904be2e0681a20be23a5190c4bd3d183db8689f (diff)
downloadsubsurface-ccfdcca6e63336fddf4444e7bcf56c009c6195f7.tar.gz
Drop like a stone mode in planner
Most of my dives i plan i know it will just be full speed down a line in the beginning and thus the planner can figure out that leg of the plan by it self. The config box added here isn't connected, because i saw that the other planner boxes wasn't connected ether, so i left it in the same state as they where. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index c17758547..516b36b0f 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -276,6 +276,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(emitDataChanged()));
connect(ui.printPlan, SIGNAL(pressed()), this, SLOT(printDecoPlan()));
+ connect(ui.drop_stone_mode, SIGNAL(toggled(bool)), plannerModel, SLOT(setDropStoneMode(bool)));
#ifdef NO_PRINTING
ui.printPlan->hide();
#endif
@@ -583,6 +584,28 @@ void DivePlannerPointsModel::setDisplayTransitions(bool value)
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
+void DivePlannerPointsModel::setDropStoneMode(bool value)
+{
+ drop_stone_mode = value;
+ if (drop_stone_mode) {
+ /* Remove the first entry if we enable drop_stone_mode */
+ if (rowCount() >= 2) {
+ beginRemoveRows(QModelIndex(), 0, 0);
+ divepoints.remove(0);
+ endRemoveRows();
+ }
+ } else {
+ /* Add a first entry if we disable drop_stone_mode */
+ beginInsertRows(QModelIndex(), 0, 0);
+ /* Copy the first current point */
+ divedatapoint p = divepoints.at(0);
+ p.time = p.depth / 300;
+ divepoints.push_front(p);
+ endInsertRows();
+ }
+ emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
+}
+
void DivePlannerPointsModel::setStartTime(const QTime &t)
{
diveplan.when = (t.msec() + QDateTime::currentMSecsSinceEpoch()) / 1000 - gettimezoneoffset();
@@ -860,6 +883,12 @@ void DivePlannerPointsModel::createTemporaryPlan()
divedatapoint p = at(i);
int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time;
lastIndex = i;
+ if (i == 0 && drop_stone_mode) {
+ /* Okay, we add a fist segment where we go down to depth */
+ /* FIXME: make this configurable, now hard-coded to 18 m/s */
+ plan_add_segment(&diveplan, p.depth / 300, p.depth, p.gasmix, p.po2, false);
+ deltaT -= p.depth / 300;
+ }
if (p.entered)
plan_add_segment(&diveplan, deltaT, p.depth, p.gasmix, p.po2, true);
}