diff options
author | Robert Helling <helling@lmu.de> | 2014-04-17 10:54:55 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-04-17 07:29:44 -0700 |
commit | 9ddef367b5120e630af9334553dc4b320a09590b (patch) | |
tree | 0afadb4086ddc733999a671c0b1b25b88245633e /qt-ui/diveplanner.h | |
parent | 8380f096199d4da1e89789c9bd67974e550f2bf3 (diff) | |
download | subsurface-9ddef367b5120e630af9334553dc4b320a09590b.tar.gz |
Improvement for various bits of the planner
Rewrite of the actual planner logic. Now ascend to the next potential stop
depth. There the state is cached and we try to ascend to the next stop
depth. If we hit the ceiling while doing that we go back to the cached
state and wait there for a minute. Then we try again. Then loop.
Converted all depth related variables from unsigned int to int. During
planning, in a time step the current depth can temporarily be negative and
comparisons of a negative int with an unsigned it have not the result I
expected ( (int) -2 < (unsigned int) 3 turns out to be false). And we
don’t really need the 32nd bit that unsigned buys us for depths.
Deco stops are now shown in the same table as manually entered stops in
boldface (I removed the second table to save screen estate).
The gas shown in the table is still misleading as it means the gas used on
the segment leading up to that event.
The update of the profile only works partially upon changes in the list of
available gases.
Treatment of various gases is basically there but needs some more love.
The ascent velocity is now provided by a function that takes the current
depth as argument. Currently it always returns 10m/min but that will later
be variable (and hopefully user configurable).
The profile is not redrawn while deco is computed (avoiding an infinite
recursion).
The table got a new column for the duration of a segment while the old
“duration” column was renamed “Runtime” to reflect what it actually shows.
Currently, only the run time but not the duration are editable.
All deco gases are used from the depth where their pO2 is 1.4bar. This
should become more flexible.
Calculation of the pressure drop in cylinders without configured volumes
is suppressed. This solves a problem with the planner crashing when saving
a dive where not all cylinders had been manually given a volume.
[Short rant break: Treating 0/0 as air bites back at so many places. E.g.
Cylinder data is initialized with memsetting the whole structures to 0.
Then later suddenly this totally unconfigured cylinder is being treated as
it would contain air. Maybe at some point this was a feature. But it lead
to a naughty bug which took me over an hour to resolve. We should
seriously reconsider this choice and better move to 209/0 being air if
changing this everywhere is not too much trouble]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.h')
-rw-r--r-- | qt-ui/diveplanner.h | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 4d3f0cbaf..8352d6a69 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -12,48 +12,6 @@ class QListView; class QModelIndex; -struct computedPoint { - int computedTime; - unsigned int computedDepth; - computedPoint(int computedTime_, unsigned int computedDepth_) { - computedTime = computedTime_; - computedDepth = computedDepth_; - }; - computedPoint() {}; -}; - -class DivePlannerDisplay : public QAbstractTableModel { - Q_OBJECT -private: - explicit DivePlannerDisplay(QObject *parent = 0); - QVector<computedPoint> computedPoints; - -public: - static DivePlannerDisplay *instance(); - enum Sections { - REMOVE, - COMPUTED_DEPTH, - COMPUTED_DURATION, - COLUMNS - }; - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - void clear(); - computedPoint at(int row); - int size(); - void removeStops(); - void addStops(); - void insertPoint(const struct computedPoint &p); - -public -slots: - void remove(const QModelIndex &index); -}; - class DivePlannerPointsModel : public QAbstractTableModel { Q_OBJECT public: @@ -62,6 +20,7 @@ public: REMOVE, DEPTH, DURATION, + RUNTIME, GAS, CCSETPOINT, COLUMNS @@ -83,6 +42,8 @@ public: void createSimpleDive(); void clear(); Mode currentMode() const; + bool setRecalc(bool recalc); + bool recalcQ(); void tanksUpdated(); void rememberTanks(); bool tankInUse(int o2, int he); @@ -96,6 +57,8 @@ public: struct diveplan getDiveplan(); QStringList &getGasList(); QVector<QPair<int, int> > collectGases(dive *d); + int lastEnteredPoint(); + static bool addingDeco; public slots: @@ -115,6 +78,7 @@ slots: void deleteTemporaryPlan(); void loadFromDive(dive *d); void restoreBackupDive(); + signals: void planCreated(); void planCanceled(); @@ -124,6 +88,7 @@ private: bool addGas(int o2, int he); struct diveplan diveplan; Mode mode; + bool recalc; QVector<divedatapoint> divepoints; struct dive *tempDive; struct dive backupDive; |