1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Fixed graph bounds issue

This commit is contained in:
Martin Tůma 2016-11-18 18:02:40 +01:00
parent 80bc9f1f01
commit 23f5a317d0
3 changed files with 8 additions and 6 deletions

View File

@ -120,9 +120,9 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
if (pos >= _graph.first().t() && pos <= _graph.last().t())
emit sliderPositionChanged(distanceAtTime(pos));
else
emit sliderPositionChanged(_graph.last().s() + 1);
emit sliderPositionChanged(NAN);
} else
emit sliderPositionChanged(_graph.last().s() + 1);
emit sliderPositionChanged(NAN);
} else
emit sliderPositionChanged(pos);
}

View File

@ -400,6 +400,8 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos)
return;
_sliderPos = (pos.x() / _slider->area().width()) * bounds().width();
_sliderPos = qMax(_sliderPos, bounds().left());
_sliderPos = qMin(_sliderPos, bounds().right());
updateSliderPosition();
emit sliderPositionChanged(_sliderPos);

View File

@ -1,3 +1,4 @@
#include <cmath>
#include <QApplication>
#include <QCursor>
#include <QPainter>
@ -108,12 +109,11 @@ QPointF PathItem::position(qreal x) const
void PathItem::moveMarker(qreal distance)
{
if (distance > _distance.last())
_marker->setVisible(false);
else {
if (distance >= _distance.first() && distance <= _distance.last()) {
_marker->setVisible(true);
_marker->setPos(position(distance));
}
} else
_marker->setVisible(false);
}
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)