summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-12-02 08:45:41 +0100
committerGravatar Robert C. Helling <helling@atdotde.de>2017-12-02 20:48:02 +0100
commit1bd2f3fe3e780f642b1c0b9c11dca793e19c40ab (patch)
tree9ffbb4cab955a42e48df6b4c0f29a6b26bfc2b6e /qt-models
parent8f3ac0402c95ae983ce5a35c2b1367fc01ac9872 (diff)
downloadsubsurface-1bd2f3fe3e780f642b1c0b9c11dca793e19c40ab.tar.gz
Planner variations stop time calculation cover all stops
Simplify the sum up of the deco stop times for analysis of the planner variations. Plus rename define for deco stop variations debug output Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/diveplannermodel.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 6f03fb073..75650ac3d 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -986,32 +986,29 @@ struct divedatapoint * DivePlannerPointsModel::cloneDiveplan(struct diveplan *pl
int DivePlannerPointsModel::analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit)
{
+ int minsum = 0;
+ int midsum = 0;
+ int maxsum = 0;
int leftsum = 0;
int rightsum = 0;
- while (mid->depth > min->depth)
- ++mid;
- while (max->depth > mid->depth)
- ++max;
- while (mid->depth) {
- int left = mid->time - min->time;
- leftsum += left;
- int right = max->time - mid->time;
- rightsum += right;
-#ifdef SHOWSTOPVARIATIONS
- if (min->time + mid->time + max->time)
- printf("%dm: %dmin + %ds/%s +- %ds/%s\n", mid->depth / 1000,
- (mid->time + 1)/60,
- (left + right) / 2, unit,
- (right - left) / 2, unit);
-#else
- (void) unit;
-#endif
+ while (min->depth) {
+ minsum += min->time;
++min;
+ }
+ while (mid->depth) {
+ midsum += mid->time;
++mid;
+ }
+ while (max->depth) {
+ maxsum += max->time;
++max;
}
-#ifdef SHOWSTOPVARIATIONS
+
+ leftsum = midsum - minsum;
+ rightsum = maxsum - midsum;
+
+#ifdef DEBUG_STOPVAR
printf("Total + %d:%02d/%s +- %d s/%s\n\n", FRACTION((leftsum + rightsum) / 2, 60), unit,
(rightsum - leftsum) / 2, unit);
#endif
@@ -1093,7 +1090,7 @@ void DivePlannerPointsModel::computeVariations(struct diveplan *original_plan, s
FRACTION(analyzeVariations(shorter, original, longer, "min"), 60));
emit variationsComputed(QString(buf));
-#ifdef SHOWSTOPVARIATIONS
+#ifdef DEBUG_STOPVAR
printf("\n\n");
#endif
}