1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-12 18:05:10 +02:00

Compare commits

..

7 Commits
4.5 ... 4.6

Author SHA1 Message Date
1a66ed0a36 Use the proper layer when displaying a single waypoint on an atlas. 2017-05-01 22:49:01 +02:00
273a127069 Version++ 2017-05-01 13:04:15 +02:00
1c0a0fd0b3 Fixed broken print/PDF export
(wrong map scale/waypoints size)
2017-05-01 12:59:56 +02:00
713e331b2a Some more OZFx extensions 2017-04-30 18:27:12 +02:00
96f406aad7 Removed Thunderforest map (requires API key)
Added USGS maps (topo & imagery)
2017-04-30 13:21:32 +02:00
0aedec66c4 Fixed atlas ll2xy() caching 2017-04-30 00:19:53 +02:00
b500031713 Atlas ll2xy() optimization 2017-04-29 23:15:44 +02:00
20 changed files with 137 additions and 83 deletions

View File

@ -1,5 +1,5 @@
TARGET = GPXSee TARGET = GPXSee
VERSION = 4.5 VERSION = 4.6
QT += core \ QT += core \
gui \ gui \
network network

View File

@ -5,7 +5,7 @@
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "4.5" !define VERSION "4.6"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}.exe" OutFile "GPXSee-${VERSION}.exe"

View File

@ -5,7 +5,7 @@
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "4.5" !define VERSION "4.6"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}_x64.exe" OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -1,3 +1,4 @@
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png
Thunderforest http://tile.thunderforest.com/outdoors/$z/$x/$y.png
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png
USGS Topo https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png
USGS Imagery https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y

View File

@ -118,6 +118,7 @@ Atlas::Atlas(const QString &fileName, QObject *parent) : Map(parent)
_valid = false; _valid = false;
_zoom = 0; _zoom = 0;
_name = fi.dir().dirName(); _name = fi.dir().dirName();
_ci = -1; _cz = -1;
if (!isAtlas(tar, fileName)) if (!isAtlas(tar, fileName))
return; return;
@ -201,6 +202,11 @@ qreal Atlas::zoomFit(const QSize &size, const QRectF &br)
{ {
_zoom = 0; _zoom = 0;
if (br.isNull()) {
_zoom = _zooms.size() - 1;
return _zoom;
}
for (int z = 0; z < _zooms.count(); z++) { for (int z = 0; z < _zooms.count(); z++) {
for (int i = _zooms.at(z).first; i <= _zooms.at(z).second; i++) { for (int i = _zooms.at(z).first; i <= _zooms.at(z).second; i++) {
if (!_bounds.at(i).first.contains(_maps.at(i)->ll2pp(br.center()))) if (!_bounds.at(i).first.contains(_maps.at(i)->ll2pp(br.center())))
@ -233,22 +239,33 @@ qreal Atlas::zoomOut()
return _zoom; return _zoom;
} }
QPointF Atlas::ll2xy(const Coordinates &c) const QPointF Atlas::ll2xy(const Coordinates &c)
{ {
int idx = _zooms.at(_zoom).first; QPointF pp;
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) { if (_cz != _zoom) {
if (_bounds.at(i).first.contains(_maps.at(i)->ll2pp(c))) { _ci = -1;
idx = i; _cz = _zoom;
break; }
if (_ci >= 0)
pp = _maps.at(_ci)->ll2pp(c);
if (_ci < 0 || !_bounds.at(_ci).first.contains(pp)) {
_ci = _zooms.at(_zoom).first;
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
pp = _maps.at(i)->ll2pp(c);
if (_bounds.at(i).first.contains(pp)) {
_ci = i;
break;
}
} }
} }
QPointF p = _maps.at(idx)->ll2xy(c); QPointF p = _maps.at(_ci)->pp2xy(pp);
return p + _bounds.at(idx).second.topLeft(); return p + _bounds.at(_ci).second.topLeft();
} }
Coordinates Atlas::xy2ll(const QPointF &p) const Coordinates Atlas::xy2ll(const QPointF &p)
{ {
int idx = _zooms.at(_zoom).first; int idx = _zooms.at(_zoom).first;

View File

@ -24,8 +24,8 @@ public:
qreal zoomIn(); qreal zoomIn();
qreal zoomOut(); qreal zoomOut();
QPointF ll2xy(const Coordinates &c) const; QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p) const; Coordinates xy2ll(const QPointF &p);
void draw(QPainter *painter, const QRectF &rect); void draw(QPainter *painter, const QRectF &rect);
@ -48,6 +48,8 @@ private:
QVector<QPair<int, int> > _zooms; QVector<QPair<int, int> > _zooms;
QVector<QPair<QRectF, QRectF> > _bounds; QVector<QPair<QRectF, QRectF> > _bounds;
int _zoom; int _zoom;
int _ci, _cz;
}; };
#endif // ATLAS_H #endif // ATLAS_H

View File

@ -64,13 +64,13 @@ void EmptyMap::draw(QPainter *painter, const QRectF &rect)
painter->fillRect(rect, Qt::white); painter->fillRect(rect, Qt::white);
} }
QPointF EmptyMap::ll2xy(const Coordinates &c) const QPointF EmptyMap::ll2xy(const Coordinates &c)
{ {
QPointF m = Mercator().ll2xy(c); QPointF m = Mercator().ll2xy(c);
return QPointF(m.x() / _scale, m.y() / -_scale); return QPointF(m.x() / _scale, m.y() / -_scale);
} }
Coordinates EmptyMap::xy2ll(const QPointF &p) const Coordinates EmptyMap::xy2ll(const QPointF &p)
{ {
QPointF m(p.x() * _scale, -p.y() * _scale); QPointF m(p.x() * _scale, -p.y() * _scale);
return Mercator().xy2ll(m); return Mercator().xy2ll(m);

View File

@ -20,8 +20,8 @@ public:
qreal zoomIn(); qreal zoomIn();
qreal zoomOut(); qreal zoomOut();
QPointF ll2xy(const Coordinates &c) const; QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p) const; Coordinates xy2ll(const QPointF &p);
void draw(QPainter *painter, const QRectF &rect); void draw(QPainter *painter, const QRectF &rect);

View File

@ -25,8 +25,8 @@ public:
virtual qreal zoomIn() = 0; virtual qreal zoomIn() = 0;
virtual qreal zoomOut() = 0; virtual qreal zoomOut() = 0;
virtual QPointF ll2xy(const Coordinates &c) const = 0; virtual QPointF ll2xy(const Coordinates &c) = 0;
virtual Coordinates xy2ll(const QPointF &p) const = 0; virtual Coordinates xy2ll(const QPointF &p) = 0;
virtual void draw(QPainter *painter, const QRectF &rect) = 0; virtual void draw(QPainter *painter, const QRectF &rect) = 0;

View File

@ -348,11 +348,12 @@ bool OfflineMap::getImageInfo(const QString &path)
} }
QString suffix = ii.suffix().toLower(); QString suffix = ii.suffix().toLower();
if (suffix == "ozf3" || suffix == "ozf4") { if (suffix == "ozf3" || suffix == "ozfx3" || suffix == "ozf4"
|| suffix == "ozfx4") {
_errorString = QString("%1: Obfuscated image files not supported") _errorString = QString("%1: Obfuscated image files not supported")
.arg(QFileInfo(_imgPath).fileName()); .arg(QFileInfo(_imgPath).fileName());
return false; return false;
} else if (suffix == "ozf2") { } else if (suffix == "ozf2" || suffix == "ozfx2") {
_ozf.load(_imgPath); _ozf.load(_imgPath);
_size = _ozf.size(); _size = _ozf.size();
} else { } else {

View File

@ -31,9 +31,9 @@ public:
qreal zoomIn() {return 1.0;} qreal zoomIn() {return 1.0;}
qreal zoomOut() {return 1.0;} qreal zoomOut() {return 1.0;}
QPointF ll2xy(const Coordinates &c) const QPointF ll2xy(const Coordinates &c)
{return _transform.map(_projection->ll2xy(c));} {return _transform.map(_projection->ll2xy(c));}
Coordinates xy2ll(const QPointF &p) const Coordinates xy2ll(const QPointF &p)
{return _projection->xy2ll(_inverted.map(p));} {return _projection->xy2ll(_inverted.map(p));}
void draw(QPainter *painter, const QRectF &rect); void draw(QPainter *painter, const QRectF &rect);

View File

@ -232,13 +232,13 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect)
} }
} }
QPointF OnlineMap::ll2xy(const Coordinates &c) const QPointF OnlineMap::ll2xy(const Coordinates &c)
{ {
QPointF m = Mercator().ll2xy(c); QPointF m = Mercator().ll2xy(c);
return QPointF(m.x() / _scale, m.y() / -_scale); return QPointF(m.x() / _scale, m.y() / -_scale);
} }
Coordinates OnlineMap::xy2ll(const QPointF &p) const Coordinates OnlineMap::xy2ll(const QPointF &p)
{ {
QPointF m(p.x() * _scale, -p.y() * _scale); QPointF m(p.x() * _scale, -p.y() * _scale);
return Mercator().xy2ll(m); return Mercator().xy2ll(m);

View File

@ -23,8 +23,8 @@ public:
qreal zoomIn(); qreal zoomIn();
qreal zoomOut(); qreal zoomOut();
QPointF ll2xy(const Coordinates &c) const; QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p) const; Coordinates xy2ll(const QPointF &p);
void draw(QPainter *painter, const QRectF &rect); void draw(QPainter *painter, const QRectF &rect);

View File

@ -12,20 +12,21 @@ PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
: QGraphicsObject(parent) : QGraphicsObject(parent)
{ {
Q_ASSERT(path.count() >= 2); Q_ASSERT(path.count() >= 2);
_path = path; _path = path;
_map = map; _map = map;
_digitalZoom = 0;
updatePainterPath(map);
updateShape();
_width = 3; _width = 3;
QBrush brush(Qt::SolidPattern); QBrush brush(Qt::SolidPattern);
_pen = QPen(brush, _width); _pen = QPen(brush, _width);
updatePainterPath(map);
updateShape();
_marker = new MarkerItem(this); _marker = new MarkerItem(this);
_marker->setPos(position(_path.at(0).distance())); _marker->setPos(position(_path.at(0).distance()));
_marker->setFlag(QGraphicsItem::ItemIgnoresTransformations); _markerDistance = _path.at(0).distance();
_md = _path.at(0).distance();
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
@ -34,7 +35,7 @@ PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
void PathItem::updateShape() void PathItem::updateShape()
{ {
QPainterPathStroker s; QPainterPathStroker s;
s.setWidth((_width + 1) * 1.0/scale()); s.setWidth((_width + 1) * pow(2, -_digitalZoom));
_shape = s.createStroke(_painterPath); _shape = s.createStroke(_painterPath);
} }
@ -71,7 +72,7 @@ void PathItem::setMap(Map *map)
updatePainterPath(map); updatePainterPath(map);
updateShape(); updateShape();
_marker->setPos(position(_md)); _marker->setPos(position(_markerDistance));
} }
void PathItem::setColor(const QColor &color) void PathItem::setColor(const QColor &color)
@ -85,7 +86,7 @@ void PathItem::setWidth(qreal width)
prepareGeometryChange(); prepareGeometryChange();
_width = width; _width = width;
_pen.setWidthF(_width * 1.0/scale()); _pen.setWidthF(_width * pow(2, -_digitalZoom));
updateShape(); updateShape();
} }
@ -96,6 +97,17 @@ void PathItem::setStyle(Qt::PenStyle style)
update(); update();
} }
void PathItem::setDigitalZoom(int zoom)
{
prepareGeometryChange();
_digitalZoom = zoom;
_pen.setWidthF(_width * pow(2, -_digitalZoom));
_marker->setScale(pow(2, -_digitalZoom));
updateShape();
}
QPointF PathItem::position(qreal x) const QPointF PathItem::position(qreal x) const
{ {
int low = 0; int low = 0;
@ -137,7 +149,7 @@ void PathItem::moveMarker(qreal distance)
&& distance <= _path.last().distance()) { && distance <= _path.last().distance()) {
_marker->setVisible(true); _marker->setVisible(true);
_marker->setPos(position(distance)); _marker->setPos(position(distance));
_md = distance; _markerDistance = distance;
} else } else
_marker->setVisible(false); _marker->setVisible(false);
} }
@ -146,7 +158,7 @@ void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
_pen.setWidthF((_width + 1) * 1.0/scale()); _pen.setWidthF((_width + 1) * pow(2, -_digitalZoom));
setZValue(zValue() + 1.0); setZValue(zValue() + 1.0);
update(); update();
@ -157,7 +169,7 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
_pen.setWidthF(_width * 1.0/scale()); _pen.setWidthF(_width * pow(2, -_digitalZoom));
setZValue(zValue() - 1.0); setZValue(zValue() - 1.0);
update(); update();

View File

@ -28,8 +28,7 @@ public:
void setColor(const QColor &color); void setColor(const QColor &color);
void setWidth(qreal width); void setWidth(qreal width);
void setStyle(Qt::PenStyle style); void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom);
void showMarker(bool show) {_marker->setVisible(show);}
public slots: public slots:
void moveMarker(qreal distance); void moveMarker(qreal distance);
@ -50,7 +49,8 @@ private:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
Map *_map; Map *_map;
qreal _md; qreal _markerDistance;
int _digitalZoom;
qreal _width; qreal _width;
QPen _pen; QPen _pen;

View File

@ -50,7 +50,6 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
_mapScale = new ScaleItem(); _mapScale = new ScaleItem();
_mapScale->setZValue(2.0); _mapScale->setZValue(2.0);
_mapScale->setFlag(QGraphicsItem::ItemIgnoresTransformations);
_map = map; _map = map;
_poi = poi; _poi = poi;
@ -97,9 +96,10 @@ PathItem *PathView::addTrack(const Track &track)
_tracks.append(ti); _tracks.append(ti);
_tr |= ti->path().boundingRect(); _tr |= ti->path().boundingRect();
ti->setColor(_palette.nextColor()); ti->setColor(_palette.nextColor());
ti->setWidth(_trackWidth * pow(2, -_digitalZoom)); ti->setWidth(_trackWidth);
ti->setStyle(_trackStyle); ti->setStyle(_trackStyle);
ti->setVisible(_showTracks); ti->setVisible(_showTracks);
ti->setDigitalZoom(_digitalZoom);
_scene->addItem(ti); _scene->addItem(ti);
addPOI(_poi->points(ti->path())); addPOI(_poi->points(ti->path()));
@ -118,11 +118,12 @@ PathItem *PathView::addRoute(const Route &route)
_routes.append(ri); _routes.append(ri);
_rr |= ri->path().boundingRect(); _rr |= ri->path().boundingRect();
ri->setColor(_palette.nextColor()); ri->setColor(_palette.nextColor());
ri->setWidth(_routeWidth * pow(2, -_digitalZoom)); ri->setWidth(_routeWidth);
ri->setStyle(_routeStyle); ri->setStyle(_routeStyle);
ri->setVisible(_showRoutes); ri->setVisible(_showRoutes);
ri->showWaypoints(_showRouteWaypoints); ri->showWaypoints(_showRouteWaypoints);
ri->showWaypointLabels(_showWaypointLabels); ri->showWaypointLabels(_showWaypointLabels);
ri->setDigitalZoom(_digitalZoom);
_scene->addItem(ri); _scene->addItem(ri);
addPOI(_poi->points(ri->path())); addPOI(_poi->points(ri->path()));
@ -142,7 +143,7 @@ void PathView::addWaypoints(const QList<Waypoint> &waypoints)
wi->setZValue(1); wi->setZValue(1);
wi->showLabel(_showWaypointLabels); wi->showLabel(_showWaypointLabels);
wi->setVisible(_showWaypoints); wi->setVisible(_showWaypoints);
wi->setFlag(QGraphicsItem::ItemIgnoresTransformations); wi->setDigitalZoom(_digitalZoom);
_scene->addItem(wi); _scene->addItem(wi);
} }
@ -340,7 +341,7 @@ void PathView::addPOI(const QVector<Waypoint> &waypoints)
pi->setZValue(1); pi->setZValue(1);
pi->showLabel(_showPOILabels); pi->showLabel(_showPOILabels);
pi->setVisible(_showPOI); pi->setVisible(_showPOI);
pi->setFlag(QGraphicsItem::ItemIgnoresTransformations); pi->setDigitalZoom(_digitalZoom);
_scene->addItem(pi); _scene->addItem(pi);
_pois.insert(w, pi); _pois.insert(w, pi);
@ -372,23 +373,40 @@ void PathView::redraw()
void PathView::resetDigitalZoom() void PathView::resetDigitalZoom()
{ {
_digitalZoom = 0; QHash<Waypoint, WaypointItem*>::const_iterator it;
_digitalZoom = 0;
resetTransform(); resetTransform();
setTrackWidth(_trackWidth); for (int i = 0; i < _tracks.size(); i++)
setRouteWidth(_routeWidth); _tracks.at(i)->setDigitalZoom(0);
for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->setDigitalZoom(0);
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setDigitalZoom(0);
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setDigitalZoom(0);
_mapScale->setDigitalZoom(0);
} }
void PathView::digitalZoom(int zoom) void PathView::digitalZoom(int zoom)
{ {
QHash<Waypoint, WaypointItem*>::const_iterator it;
_digitalZoom += zoom; _digitalZoom += zoom;
scale(pow(2, zoom), pow(2, zoom)); scale(pow(2, zoom), pow(2, zoom));
setTrackWidth(_trackWidth); for (int i = 0; i < _tracks.size(); i++)
setRouteWidth(_routeWidth); _tracks.at(i)->setDigitalZoom(_digitalZoom);
for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->setDigitalZoom(_digitalZoom);
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setDigitalZoom(_digitalZoom);
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setDigitalZoom(_digitalZoom);
_mapScale->setResolution(_res * pow(2, -_digitalZoom)); _mapScale->setDigitalZoom(_digitalZoom);
} }
void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c) void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
@ -519,9 +537,7 @@ void PathView::clear()
_tr = QRectF(); _rr = QRectF(); _wr = QRectF(); _tr = QRectF(); _rr = QRectF(); _wr = QRectF();
_wp = QPointF(); _wp = QPointF();
_digitalZoom = 0; resetDigitalZoom();
resetTransform();
resetCachedContent(); resetCachedContent();
} }
@ -608,7 +624,7 @@ void PathView::setTrackWidth(int width)
_trackWidth = width; _trackWidth = width;
for (int i = 0; i < _tracks.count(); i++) for (int i = 0; i < _tracks.count(); i++)
_tracks.at(i)->setWidth(width * pow(2, -_digitalZoom)); _tracks.at(i)->setWidth(width);
} }
void PathView::setRouteWidth(int width) void PathView::setRouteWidth(int width)
@ -616,7 +632,7 @@ void PathView::setRouteWidth(int width)
_routeWidth = width; _routeWidth = width;
for (int i = 0; i < _routes.count(); i++) for (int i = 0; i < _routes.count(); i++)
_routes.at(i)->setWidth(width * pow(2, -_digitalZoom)); _routes.at(i)->setWidth(width);
} }
void PathView::setTrackStyle(Qt::PenStyle style) void PathView::setTrackStyle(Qt::PenStyle style)

View File

@ -1,3 +1,4 @@
#include <cmath>
#include <QPainter> #include <QPainter>
#include "config.h" #include "config.h"
#include "misc.h" #include "misc.h"
@ -15,6 +16,7 @@ ScaleItem::ScaleItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{ {
_units = Metric; _units = Metric;
_res = 1.0; _res = 1.0;
_digitalZoom = 0;
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
setCacheMode(QGraphicsItem::DeviceCoordinateCache); setCacheMode(QGraphicsItem::DeviceCoordinateCache);
@ -87,24 +89,26 @@ QString ScaleItem::units() const
void ScaleItem::computeScale() void ScaleItem::computeScale()
{ {
qreal res = _res * pow(2, -_digitalZoom);
if (_units == Imperial) { if (_units == Imperial) {
_length = niceNum((_res * M2FT * SCALE_WIDTH) / SEGMENTS, 1); _length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
if (_length >= MIINFT) { if (_length >= MIINFT) {
_length = niceNum((_res * M2FT * FT2MI * SCALE_WIDTH) / SEGMENTS, 1); _length = niceNum((res * M2FT * FT2MI * SCALE_WIDTH) / SEGMENTS, 1);
_width = (_length / (_res * M2FT * FT2MI)); _width = (_length / (res * M2FT * FT2MI));
_scale = true; _scale = true;
} else { } else {
_width = (_length / (_res * M2FT)); _width = (_length / (res * M2FT));
_scale = false; _scale = false;
} }
} else { } else {
_length = niceNum((_res * SCALE_WIDTH) / SEGMENTS, 1); _length = niceNum((res * SCALE_WIDTH) / SEGMENTS, 1);
if (_length >= KMINM) { if (_length >= KMINM) {
_length *= M2KM; _length *= M2KM;
_width = (_length / (_res * M2KM)); _width = (_length / (res * M2KM));
_scale = true; _scale = true;
} else { } else {
_width = (_length / _res); _width = (_length / res);
_scale = false; _scale = false;
} }
} }
@ -127,3 +131,14 @@ void ScaleItem::setUnits(enum Units units)
updateBoundingRect(); updateBoundingRect();
update(); update();
} }
void ScaleItem::setDigitalZoom(int zoom)
{
prepareGeometryChange();
_digitalZoom = zoom;
computeScale();
updateBoundingRect();
update();
setScale(pow(2, -_digitalZoom));
}

View File

@ -15,6 +15,7 @@ public:
void setResolution(qreal res); void setResolution(qreal res);
void setUnits(enum Units units); void setUnits(enum Units units);
void setDigitalZoom(int zoom);
private: private:
void updateBoundingRect(); void updateBoundingRect();
@ -27,6 +28,8 @@ private:
Units _units; Units _units;
bool _scale; bool _scale;
int _digitalZoom;
QRectF _boundingRect; QRectF _boundingRect;
}; };

View File

@ -3,7 +3,6 @@
#include "config.h" #include "config.h"
#include "format.h" #include "format.h"
#include "tooltip.h" #include "tooltip.h"
#include "map.h"
#include "waypointitem.h" #include "waypointitem.h"
@ -46,11 +45,6 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
} }
void WaypointItem::setMap(Map *map)
{
setPos(map->ll2xy(_waypoint.coordinates()));
}
void WaypointItem::updateShape() void WaypointItem::updateShape()
{ {
QPainterPath p; QPainterPath p;
@ -106,14 +100,6 @@ void WaypointItem::paint(QPainter *painter,
*/ */
} }
/*
void WaypointItem::setScale(qreal scale)
{
QPointF p = _map->ll2xy(_waypoint.coordinates());
setPos(QPointF(p.x(), -p.y()) * scale);
}
*/
void WaypointItem::setUnits(enum Units units) void WaypointItem::setUnits(enum Units units)
{ {
setToolTip(toolTip(units)); setToolTip(toolTip(units));

View File

@ -1,11 +1,11 @@
#ifndef WAYPOINTITEM_H #ifndef WAYPOINTITEM_H
#define WAYPOINTITEM_H #define WAYPOINTITEM_H
#include <cmath>
#include <QGraphicsItem> #include <QGraphicsItem>
#include "waypoint.h" #include "waypoint.h"
#include "units.h" #include "units.h"
#include "map.h"
class Map;
class WaypointItem : public QGraphicsItem class WaypointItem : public QGraphicsItem
{ {
@ -14,9 +14,10 @@ public:
const Waypoint &waypoint() const {return _waypoint;} const Waypoint &waypoint() const {return _waypoint;}
void setMap(Map *map); void setMap(Map *map) {setPos(map->ll2xy(_waypoint.coordinates()));}
void setUnits(Units units); void setUnits(Units units);
void showLabel(bool show); void showLabel(bool show);
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
QPainterPath shape() const {return _shape;} QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();} QRectF boundingRect() const {return _shape.boundingRect();}