[PATCH] Drop like a stone mode in planner

Anton Lundin glance at acc.umu.se
Mon Jun 23 10:21:29 PDT 2014


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 at acc.umu.se>
---
 qt-ui/diveplanner.cpp    | 29 +++++++++++++++++++++++++++++
 qt-ui/diveplanner.h      |  2 ++
 qt-ui/diveplanner.ui     |  7 +++++++
 qt-ui/plannerSettings.ui | 37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+)

diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index e8542da..3081210 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)));
 
 	// Creating (and canceling) the plan
 	connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan()));
@@ -580,6 +581,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();
@@ -857,6 +880,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);
 	}
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 9672555..0b4e783 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -73,6 +73,7 @@ slots:
 	void setDecoSac(int sac);
 	void setStartTime(const QTime &t);
 	void setLastStop6m(bool value);
+	void setDropStoneMode(bool value);
 	void setVerbatim(bool value);
 	void setDisplayRuntime(bool value);
 	void setDisplayDuration(bool value);
@@ -104,6 +105,7 @@ private:
 	QVector<sample> backupSamples; // For editing added dives.
 	struct dive *stagingDive;
 	QVector<QPair<int, int> > oldGases;
+	bool drop_stone_mode;
 };
 
 class DiveHandler : public QObject, public QGraphicsEllipseItem {
diff --git a/qt-ui/diveplanner.ui b/qt-ui/diveplanner.ui
index 1aa4376..33ec33c 100644
--- a/qt-ui/diveplanner.ui
+++ b/qt-ui/diveplanner.ui
@@ -185,6 +185,13 @@
          </property>
         </widget>
        </item>
+       <item row="6" column="0">
+        <widget class="QCheckBox" name="drop_stone_mode">
+         <property name="text">
+          <string>Drop like a stone mode</string>
+         </property>
+        </widget>
+       </item>
        <item row="6" column="1">
         <widget class="QPushButton" name="printPlan">
          <property name="text">
diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui
index 547bd81..82584fa 100644
--- a/qt-ui/plannerSettings.ui
+++ b/qt-ui/plannerSettings.ui
@@ -244,6 +244,42 @@
          </property>
         </widget>
        </item>
+       <item row="5" column="0">
+        <widget class="QLabel" name="label_8">
+         <property name="text">
+          <string>Decent rate</string>
+         </property>
+        </widget>
+       </item>
+       <item row="6" 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">
+        <widget class="QSpinBox" name="descRate">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>20</height>
+          </size>
+         </property>
+         <property name="minimum">
+          <number>1</number>
+         </property>
+         <property name="value">
+          <number>18</number>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
     </item>
@@ -263,6 +299,7 @@
   <tabstop>backgasBreaks</tabstop>
   <tabstop>ascRate75_2</tabstop>
   <tabstop>ascRate75_3</tabstop>
+  <tabstop>descRate</tabstop>
  </tabstops>
  <resources/>
  <connections/>
-- 
1.9.1



More information about the subsurface mailing list