From 1bd2f3fe3e780f642b1c0b9c11dca793e19c40ab Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Sat, 2 Dec 2017 08:45:41 +0100 Subject: 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 --- qt-models/diveplannermodel.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'qt-models') 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 } -- cgit v1.2.3-70-g09d2