mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
91136b2c51
commit
891839d254
2 changed files with 12 additions and 26 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue