1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2017-12-01 20:52:34 +01:00
parent 56d1ac7ff2
commit 90b780a444
3 changed files with 21 additions and 30 deletions

View File

@ -154,7 +154,7 @@ void MapView::addWaypoints(const QList<Waypoint> &waypoints)
WaypointItem *wi = new WaypointItem(w, _map);
_waypoints.append(wi);
updateWaypointsBoundingRect(wi->waypoint().coordinates());
_wr.unite(wi->waypoint().coordinates());
wi->setZValue(1);
wi->setSize(_waypointSize);
wi->setColor(_waypointColor);
@ -193,33 +193,20 @@ QList<PathItem *> MapView::loadData(const Data &data)
return paths;
}
void MapView::updateWaypointsBoundingRect(const Coordinates &wp)
{
if (_wr.isNull())
_wr = RectC(wp, wp);
else
_wr.unite(wp);
}
qreal MapView::mapZoom() const
{
RectC br;
RectC br = _tr | _rr | _wr;
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
br = RectC(_map->xy2ll(sceneRect().topLeft()),
_map->xy2ll(sceneRect().bottomRight()));
else
br = _tr | _rr | _wr;
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), br);
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN),
br.isNull() ? RectC(_map->xy2ll(sceneRect().topLeft()),
_map->xy2ll(sceneRect().bottomRight())) : br);
}
QPointF MapView::contentCenter() const
{
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
return sceneRect().center();
else
return _map->ll2xy((_tr | _rr | _wr).center());
RectC br = _tr | _rr | _wr;
return br.isNull() ? sceneRect().center() : _map->ll2xy(br.center());
}
void MapView::updatePOIVisibility()

View File

@ -85,7 +85,6 @@ private:
void digitalZoom(int zoom);
void resetDigitalZoom();
void updatePOIVisibility();
void updateWaypointsBoundingRect(const Coordinates &wp);
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);

View File

@ -46,6 +46,10 @@ RectC RectC::operator|(const RectC &r) const
void RectC::unite(const Coordinates &c)
{
if (isNull()) {
_tl = c;
_br = c;
} else {
if (c.lon() < _tl.lon())
_tl.setLon(c.lon());
if (c.lon() > _br.lon())
@ -54,6 +58,7 @@ void RectC::unite(const Coordinates &c)
_br.setLat(c.lat());
if (c.lat() < _tl.lat())
_tl.setLat(c.lat());
}
}
QDebug operator<<(QDebug dbg, const RectC &rect)