mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Fixed wrong date info on tracks with segments
This commit is contained in:
@ -224,6 +224,12 @@ qreal GraphItem::timeAtDistance(qreal distance) const
|
||||
return l.pointAt((distance - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
|
||||
GraphItem::SegmentTime GraphItem::date(qreal x)
|
||||
{
|
||||
const GraphSegment *seg = segment(x, _type);
|
||||
return seg ? SegmentTime(seg->start(), seg->first().t()) : SegmentTime();
|
||||
}
|
||||
|
||||
void GraphItem::hover(bool hover)
|
||||
{
|
||||
if (hover) {
|
||||
|
@ -12,6 +12,16 @@ class GraphItem : public QObject, public GraphicsItem
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct SegmentTime
|
||||
{
|
||||
SegmentTime() : time(NAN) {}
|
||||
SegmentTime(const QDateTime &date, qreal time)
|
||||
: date(date), time(time) {}
|
||||
|
||||
QDateTime date;
|
||||
qreal time;
|
||||
};
|
||||
|
||||
GraphItem(const Graph &graph, GraphType type, int width,
|
||||
const QColor &color, Qt::PenStyle style, QGraphicsItem *parent = 0);
|
||||
virtual ~GraphItem() {}
|
||||
@ -43,6 +53,7 @@ public:
|
||||
qreal yAtX(qreal x) const;
|
||||
qreal distanceAtTime(qreal time) const;
|
||||
qreal timeAtDistance(qreal distance) const;
|
||||
SegmentTime date(qreal x);
|
||||
|
||||
void redraw();
|
||||
|
||||
|
@ -334,12 +334,18 @@ void PathItem::setMarkerPosition(qreal pos)
|
||||
void PathItem::setMarkerInfo(qreal pos)
|
||||
{
|
||||
if (_markerInfoType == MarkerInfoItem::Date) {
|
||||
qreal time = _graph
|
||||
? (_graph->graphType() == Time) ? pos : _graph->timeAtDistance(pos)
|
||||
: NAN;
|
||||
QDateTime d(date());
|
||||
if (!std::isnan(time) && d.isValid())
|
||||
_markerInfo->setDate(d.addSecs(time).toTimeZone(_timeZone));
|
||||
QDateTime date;
|
||||
|
||||
if (_graph) {
|
||||
qreal time = (_graph->graphType() == Time)
|
||||
? pos : _graph->timeAtDistance(pos);
|
||||
GraphItem::SegmentTime st(_graph->date(pos));
|
||||
if (st.date.isValid() && !std::isnan(time))
|
||||
date = st.date.addSecs(time - st.time);
|
||||
}
|
||||
|
||||
if (date.isValid())
|
||||
_markerInfo->setDate(date.toTimeZone(_timeZone));
|
||||
else
|
||||
_markerInfo->setDate(QDateTime());
|
||||
} else if (_markerInfoType == MarkerInfoItem::Position)
|
||||
|
Reference in New Issue
Block a user