Continous update of planner

Make the planner update its display continuously upon moving points
including deco. This appears fast enough on typical PCs. If this ends up
being to slow on some systems we may have to make it configurable.

[Dirk Hohndel: cleaned up the two patches and turned into one commit]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert Helling 2013-09-19 09:13:53 -05:00 committed by Dirk Hohndel
parent 40462d5008
commit fc3b68bc19
2 changed files with 21 additions and 7 deletions

View file

@ -427,7 +427,7 @@ void DivePlannerGraphics::createDecoStops()
dp = dp->next;
}
if (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum()) {
if (!activeDraggedHandler && (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum())) {
double newMax = fmax(dp->time / 60.0 + 5, minMinutes);
timeLine->setMaximum(newMax);
timeLine->updateTicks();
@ -521,7 +521,7 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
depthString->setBrush( QColor(redDelta, greenDelta, blueDelta));
if (activeDraggedHandler)
moveActiveHandler(mappedPos);
moveActiveHandler(mappedPos, handles.indexOf(activeDraggedHandler));
if (!handles.count())
return;
@ -534,13 +534,27 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent* event)
}
}
void DivePlannerGraphics::moveActiveHandler(const QPointF& pos)
void DivePlannerGraphics::moveActiveHandler(const QPointF& mappedPos, const int pos)
{
double xpos = timeLine->posAtValue(rint(timeLine->valueAt(pos)));
double ypos = depthLine->posAtValue(rint(depthLine->valueAt(pos)));
divedatapoint data = plannerModel->at(pos);
int minutes = rint(timeLine->valueAt(mappedPos));
int meters = rint(depthLine->valueAt(mappedPos));
double xpos = timeLine->posAtValue(minutes);
double ypos = depthLine->posAtValue(meters);
data.depth = rint(depthLine->valueAt(mappedPos)) * 1000;
data.time = rint(timeLine->valueAt(mappedPos)) * 60;
plannerModel->editStop(pos, data);
activeDraggedHandler->setPos(QPointF(xpos, ypos));
qDeleteAll(lines);
lines.clear();
createDecoStops();
}
bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point)
@ -605,8 +619,8 @@ void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event)
activeDraggedHandler->setBrush(QBrush(Qt::white));
activeDraggedHandler->setPos(QPointF(xpos, ypos));
createDecoStops();
activeDraggedHandler = 0;
createDecoStops();
}
}

View file

@ -149,7 +149,7 @@ private slots:
void pointInserted(const QModelIndex&, int start, int end);
void pointsRemoved(const QModelIndex&, int start, int end);
private:
void moveActiveHandler(const QPointF& pos);
void moveActiveHandler(const QPointF& MappedPos, const int pos);
/* This are the lines of the plotted dive. */
QList<QGraphicsLineItem*> lines;