diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-25 16:03:03 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-04-02 13:53:23 -0700 |
commit | 891839d254b8383abea7933ec45aa896d43100c7 (patch) | |
tree | 7655dc9ce69cd51079ef4fd15d6d55e65a8d745a /profile-widget | |
parent | 91136b2c510f4a63d451678deadc2f5c131136aa (diff) | |
download | subsurface-891839d254b8383abea7933ec45aa896d43100c7.tar.gz |
planner: move same-time check to DivePlannerPointsModel
There must not be two dive planner points at the same time
stamp, as this violates the laws of physics (and internal
assumptions).
The corresponding test was done in the profile code at
two different places with floating point arithmetics.
This is a bad idea, because
1) code duplication
2) danger of rounding issues
Instead, do this in one central point in the planner model
and use integer arithmetics. Simply add a few seconds until
a unique timestamp is obtained.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 38bbfdd00..12be6e4a8 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1873,19 +1873,6 @@ void ProfileWidget2::keyLeftAction() if (dp.time / 60 <= 0) continue; - // don't overlap positions. - // maybe this is a good place for a 'goto'? - double xpos = timeAxis->posAtValue((dp.time - 60) / 60); - bool nextStep = false; - for (const auto &h: handles) { - if (IS_FP_SAME(h->pos().x(), xpos)) { - nextStep = true; - break; - } - } - if (nextStep) - continue; - dp.time -= 60; plannerModel->editStop(row, dp); } @@ -1907,19 +1894,6 @@ void ProfileWidget2::keyRightAction() if (dp.time / 60.0 >= timeAxis->maximum()) continue; - // don't overlap positions. - // maybe this is a good place for a 'goto'? - double xpos = timeAxis->posAtValue((dp.time + 60) / 60); - bool nextStep = false; - for (const auto &h: handles) { - if (IS_FP_SAME(h->pos().x(), xpos)) { - nextStep = true; - break; - } - } - if (nextStep) - continue; - dp.time += 60; plannerModel->editStop(row, dp); } |