mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Fixed (centred) waypoint position markers
Fixed waypoint "radius" computation
This commit is contained in:
parent
201b3f6dae
commit
61c82a0836
@ -46,8 +46,7 @@ bool POI::loadGPXFile(const QString &fileName)
|
||||
|
||||
if (gpx.loadFile(fileName)) {
|
||||
for (int i = 0; i < gpx.waypoints().size(); i++)
|
||||
_data.append(Waypoint(
|
||||
ll2mercator(gpx.waypoints().at(i).coordinates()),
|
||||
_data.append(Waypoint(gpx.waypoints().at(i).coordinates(),
|
||||
gpx.waypoints().at(i).description()));
|
||||
index.end = _data.size() - 1;
|
||||
|
||||
@ -108,7 +107,7 @@ bool POI::loadCSVFile(const QString &fileName)
|
||||
}
|
||||
QByteArray ba = list[2].trimmed();
|
||||
|
||||
_data.append(Waypoint(ll2mercator(QPointF(lon, lat)),
|
||||
_data.append(Waypoint(QPointF(lon, lat),
|
||||
QString::fromUtf8(ba.data(), ba.size())));
|
||||
ln++;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
void Track::track(QVector<QPointF> &track) const
|
||||
{
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
track.append(ll2mercator(_data.at(i).coordinates));
|
||||
track.append(_data.at(i).coordinates);
|
||||
}
|
||||
|
||||
qreal Track::distance() const
|
||||
|
@ -55,9 +55,9 @@ void TrackView::addTrack(const QVector<QPointF> &track)
|
||||
|
||||
_tracks.append(track);
|
||||
|
||||
path.moveTo(track.at(0).x(), -track.at(0).y());
|
||||
path.moveTo(ll2mercator(QPointF(track.at(0).x(), -track.at(0).y())));
|
||||
for (int i = 1; i < track.size(); i++)
|
||||
path.lineTo(track.at(i).x(), -track.at(i).y());
|
||||
path.lineTo(ll2mercator(QPointF(track.at(i).x(), -track.at(i).y())));
|
||||
|
||||
_maxLen = qMax(path.length(), _maxLen);
|
||||
|
||||
@ -167,8 +167,7 @@ void TrackView::rescale(qreal scale)
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it, jt;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
|
||||
it.value()->setPos(QPointF(it.value()->entry().coordinates().x()
|
||||
* 1.0/scale, -it.value()->entry().coordinates().y() * 1.0/scale));
|
||||
it.value()->setPos(it.value()->entry().coordinates() * 1.0/scale);
|
||||
it.value()->show();
|
||||
}
|
||||
|
||||
@ -197,9 +196,11 @@ void TrackView::loadPOI(const POI &poi)
|
||||
if (_pois.contains(p.at(i)))
|
||||
continue;
|
||||
|
||||
WaypointItem *pi = new WaypointItem(p.at(i));
|
||||
pi->setPos(p.at(i).coordinates().x() * 1.0/_scale,
|
||||
-p.at(i).coordinates().y() * 1.0/_scale);
|
||||
WaypointItem *pi = new WaypointItem(
|
||||
Waypoint(ll2mercator(QPointF(p.at(i).coordinates().x(),
|
||||
-p.at(i).coordinates().y())), p.at(i).description()));
|
||||
|
||||
pi->setPos(pi->entry().coordinates() * 1.0/_scale);
|
||||
pi->setZValue(1);
|
||||
_scene->addItem(pi);
|
||||
|
||||
|
@ -20,8 +20,8 @@ void WaypointItem::updateBoundingRect()
|
||||
QFontMetrics fm(font);
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
|
||||
_boundingRect = QRectF(0, 0, ts.width() + POINT_SIZE,
|
||||
ts.height() + fm.descent() + POINT_SIZE);
|
||||
_boundingRect = QRectF(-POINT_SIZE/2, -POINT_SIZE/2, ts.width()
|
||||
+ POINT_SIZE, ts.height() + fm.descent() + POINT_SIZE);
|
||||
}
|
||||
|
||||
void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -36,10 +36,10 @@ void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
QRect ts = fm.tightBoundingRect(_entry.description());
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(POINT_SIZE - qMax(ts.x(), 0), POINT_SIZE + ts.height(),
|
||||
painter->drawText(POINT_SIZE/2 - qMax(ts.x(), 0), POINT_SIZE/2 + ts.height(),
|
||||
_entry.description());
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->drawEllipse(0, 0, POINT_SIZE, POINT_SIZE);
|
||||
painter->drawEllipse(-POINT_SIZE/2, -POINT_SIZE/2, POINT_SIZE, POINT_SIZE);
|
||||
|
||||
/*
|
||||
painter->setPen(Qt::red);
|
||||
|
Loading…
Reference in New Issue
Block a user