diff options
-rw-r--r-- | core/plannernotes.c | 2 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 24 | ||||
-rw-r--r-- | qt-models/diveplannermodel.h | 2 |
3 files changed, 21 insertions, 7 deletions
diff --git a/core/plannernotes.c b/core/plannernotes.c index 83c868186..414236a1e 100644 --- a/core/plannernotes.c +++ b/core/plannernotes.c @@ -101,7 +101,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d get_current_date()); } - len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "Runtime: %dmin<br></div>"), + len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "Runtime: %dmin VARIATIONS<br></div>"), diveplan_duration(diveplan)); if (!plan_verbatim) { 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); } diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h index ff6b98496..7a4ef9885 100644 --- a/qt-models/diveplannermodel.h +++ b/qt-models/diveplannermodel.h @@ -109,7 +109,7 @@ private: struct diveplan diveplan; struct divedatapoint *cloneDiveplan(struct diveplan *plan_copy); void computeVariations(); - void analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit); + int analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit); Mode mode; bool recalc; QVector<divedatapoint> divepoints; |