diff options
author | Robert C. Helling <helling@atdotde.de> | 2017-09-18 16:10:47 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-09-20 08:54:41 -0700 |
commit | a6f186279fcce9631623b94bfdc00fa3fd071b4c (patch) | |
tree | 22e907959336c94887f210da14f7fc5c54496b6d /qt-models/diveplannermodel.cpp | |
parent | 5e9bdce195c1ec3ca077ce75cf2c0a221d6029de (diff) | |
download | subsurface-a6f186279fcce9631623b94bfdc00fa3fd071b4c.tar.gz |
Add a checkbox to turn off plan variations
... as those come with a performance penalty
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 6ff446a09..e65bb01eb 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -522,6 +522,13 @@ void DivePlannerPointsModel::setDisplayTransitions(bool value) emitDataChanged(); } +void DivePlannerPointsModel::setDisplayVariations(bool value) +{ + auto planner = SettingsObjectWrapper::instance()->planner_settings; + planner->setDisplayVariations(value); + emitDataChanged(); +} + void DivePlannerPointsModel::setDecoMode(int mode) { auto planner = SettingsObjectWrapper::instance()->planner_settings; @@ -934,52 +941,51 @@ void DivePlannerPointsModel::computeVariations() struct diveplan plan_copy; struct divedatapoint *last_segment; - if(!in_planner()) - return; - cache_deco_state(&save); - cloneDiveplan(&plan_copy); - plan(&plan_copy, dive, 1, original, &cache, true, false); - free_dps(&plan_copy); - restore_deco_state(save, false); - - last_segment = cloneDiveplan(&plan_copy); - last_segment->depth.mm += 1000; - last_segment->next->depth.mm += 1000; - plan(&plan_copy, dive, 1, deeper, &cache, true, false); - free_dps(&plan_copy); - restore_deco_state(save, false); - - last_segment = cloneDiveplan(&plan_copy); - last_segment->depth.mm -= 1000; - last_segment->next->depth.mm -= 1000; - plan(&plan_copy, dive, 1, shallower, &cache, true, false); - free_dps(&plan_copy); - restore_deco_state(save, false); - - last_segment = cloneDiveplan(&plan_copy); - last_segment->next->time += 60; - plan(&plan_copy, dive, 1, longer, &cache, true, false); - free_dps(&plan_copy); - restore_deco_state(save, false); - - last_segment = cloneDiveplan(&plan_copy); - last_segment->next->time -= 60; - plan(&plan_copy, dive, 1, shorter, &cache, true, false); - free_dps(&plan_copy); - restore_deco_state(save, false); - + if(in_planner() && prefs.display_variations) { + cache_deco_state(&save); + cloneDiveplan(&plan_copy); + plan(&plan_copy, dive, 1, original, &cache, true, false); + free_dps(&plan_copy); + restore_deco_state(save, false); + + last_segment = cloneDiveplan(&plan_copy); + last_segment->depth.mm += 1000; + last_segment->next->depth.mm += 1000; + plan(&plan_copy, dive, 1, deeper, &cache, true, false); + free_dps(&plan_copy); + restore_deco_state(save, false); + + last_segment = cloneDiveplan(&plan_copy); + last_segment->depth.mm -= 1000; + last_segment->next->depth.mm -= 1000; + plan(&plan_copy, dive, 1, shallower, &cache, true, false); + free_dps(&plan_copy); + restore_deco_state(save, false); + + last_segment = cloneDiveplan(&plan_copy); + last_segment->next->time += 60; + plan(&plan_copy, dive, 1, longer, &cache, true, false); + free_dps(&plan_copy); + restore_deco_state(save, false); + + last_segment = cloneDiveplan(&plan_copy); + last_segment->next->time -= 60; + plan(&plan_copy, dive, 1, shorter, &cache, true, false); + free_dps(&plan_copy); + restore_deco_state(save, false); #ifdef SHOWSTOPVARIATIONS - printf("\n\n"); + printf("\n\n"); #endif - QString notes(displayed_dive.notes); - free(displayed_dive.notes); + 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)); + 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()); + displayed_dive.notes = strdup(notes.replace("VARIATIONS", QString(buf)).toUtf8().data()); + } setRecalc(oldRecalc); } |