summaryrefslogtreecommitdiffstats
path: root/qt-models/diveplannermodel.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-08-29 12:26:00 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-08-29 06:49:44 -0700
commitaed5b7d26708d9559effc27ed2d3b3656f5bc738 (patch)
tree9d8517147a7bebd60c93e5b289651def2dd4e7ac /qt-models/diveplannermodel.cpp
parent2832141d2ca00c9ec502f6c4f7ecbb09a2095516 (diff)
downloadsubsurface-aed5b7d26708d9559effc27ed2d3b3656f5bc738.tar.gz
Show variations in Runtime string
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-rw-r--r--qt-models/diveplannermodel.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index c0f5598be..ee43468a7 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -892,7 +892,7 @@ struct divedatapoint * DivePlannerPointsModel::cloneDiveplan(struct diveplan *pl
return last_segment;
}
-void DivePlannerPointsModel::analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit)
+int DivePlannerPointsModel::analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit)
{
int leftsum = 0;
int rightsum = 0;
@@ -906,17 +906,22 @@ void DivePlannerPointsModel::analyzeVariations(struct decostop *min, struct deco
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);
+#endif
++min;
++mid;
++max;
}
- printf("Total + %d:%02d/%s +- %d:%02d/%s\n\n", FRACTION((leftsum + rightsum) / 2, 60), unit,
- FRACTION((rightsum - leftsum) / 2, 60), unit);
+#ifdef SHOWSTOPVARIATIONS
+ printf("Total + %d:%02d/%s +- %d s/%s\n\n", FRACTION((leftsum + rightsum) / 2, 60), unit,
+ (rightsum - leftsum) / 2, unit);
+#endif
+ return (leftsum + rightsum) / 2;
}
void DivePlannerPointsModel::computeVariations()
@@ -961,9 +966,18 @@ void DivePlannerPointsModel::computeVariations()
free_dps(&plan_copy);
restore_deco_state(save, false);
+#ifdef SHOWSTOPVARIATIONS
printf("\n\n");
- analyzeVariations(shallower, original, deeper, "m");
- analyzeVariations(shorter, original, longer, "min");
+#endif
+
+ QString notes(displayed_dive.notes);
+ free(displayed_dive.notes);
+
+ char buf[200];
+ sprintf(buf, "+ %d:%02d /m + %d:%02d /min", FRACTION(analyzeVariations(shallower, original, deeper, "m"),60),
+ FRACTION(analyzeVariations(shorter, original, longer, "min"), 60));
+
+ displayed_dive.notes = strdup(notes.replace("VARIATIONS", QString(buf)).toUtf8().data());
setRecalc(oldRecalc);
}