mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Code cleanup
This commit is contained in:
parent
56d1ac7ff2
commit
90b780a444
@ -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()
|
||||
|
@ -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);
|
||||
|
@ -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())
|
||||
@ -55,6 +59,7 @@ void RectC::unite(const Coordinates &c)
|
||||
if (c.lat() < _tl.lat())
|
||||
_tl.setLat(c.lat());
|
||||
}
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const RectC &rect)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user