mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Some more code cleanup
This commit is contained in:
parent
e48729fc84
commit
d106f47771
@ -203,7 +203,7 @@ qreal Atlas::zoomFit(const QSize &size, const RectC &br)
|
||||
{
|
||||
_zoom = 0;
|
||||
|
||||
if (br.isNull()) {
|
||||
if (!br.isValid()) {
|
||||
_zoom = _zooms.size() - 1;
|
||||
return _zoom;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ QRectF EmptyMap::bounds() const
|
||||
|
||||
qreal EmptyMap::zoomFit(const QSize &size, const RectC &br)
|
||||
{
|
||||
if (br.isNull())
|
||||
if (!br.isValid())
|
||||
_scale = SCALE_MAX;
|
||||
else {
|
||||
QRectF tbr(Mercator().ll2xy(br.topLeft()),
|
||||
|
@ -168,7 +168,7 @@ QRectF OnlineMap::bounds() const
|
||||
|
||||
qreal OnlineMap::zoomFit(const QSize &size, const RectC &br)
|
||||
{
|
||||
if (br.isNull())
|
||||
if (!br.isValid())
|
||||
_zoom = ZOOM_MAX;
|
||||
else {
|
||||
QRectF tbr(Mercator().ll2xy(br.topLeft()),
|
||||
|
@ -173,22 +173,15 @@ QList<PathItem *> PathView::loadData(const Data &data)
|
||||
|
||||
void PathView::updateWaypointsBoundingRect(const Coordinates &wp)
|
||||
{
|
||||
if (_wr.isNull()) {
|
||||
if (_wp.isNull())
|
||||
_wp = wp;
|
||||
else {
|
||||
_wr = RectC(_wp, wp).normalized();
|
||||
_wp = Coordinates();
|
||||
}
|
||||
} else
|
||||
if (_wr.isNull())
|
||||
_wr = RectC(wp, wp);
|
||||
else
|
||||
_wr.unite(wp);
|
||||
}
|
||||
|
||||
qreal PathView::mapScale() const
|
||||
{
|
||||
RectC br = _tr | _rr | _wr;
|
||||
if (!br.isNull() && !_wp.isNull())
|
||||
br.unite(_wp);
|
||||
|
||||
return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br);
|
||||
}
|
||||
@ -196,13 +189,8 @@ qreal PathView::mapScale() const
|
||||
QPointF PathView::contentCenter() const
|
||||
{
|
||||
RectC br = _tr | _rr | _wr;
|
||||
if (!br.isNull() && !_wp.isNull())
|
||||
br.unite(_wp);
|
||||
|
||||
if (br.isNull())
|
||||
return _map->ll2xy(_wp);
|
||||
else
|
||||
return _map->ll2xy(br.center());
|
||||
return _map->ll2xy(br.center());
|
||||
}
|
||||
|
||||
void PathView::updatePOIVisibility()
|
||||
@ -530,8 +518,9 @@ void PathView::clear()
|
||||
_scene->clear();
|
||||
_palette.reset();
|
||||
|
||||
_tr = RectC(); _rr = RectC(); _wr = RectC();
|
||||
_wp = Coordinates();
|
||||
_tr = RectC();
|
||||
_rr = RectC();
|
||||
_wr = RectC();
|
||||
|
||||
resetDigitalZoom();
|
||||
resetCachedContent();
|
||||
|
@ -99,7 +99,6 @@ private:
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
|
||||
RectC _tr, _rr, _wr;
|
||||
Coordinates _wp;
|
||||
qreal _res;
|
||||
|
||||
Map *_map;
|
||||
|
@ -1,28 +1,5 @@
|
||||
#include "rectc.h"
|
||||
|
||||
RectC RectC::normalized() const
|
||||
{
|
||||
RectC r;
|
||||
|
||||
if (_br.lon() < _tl.lon()) {
|
||||
r._tl.setLon(_br.lon());
|
||||
r._br.setLon(_tl.lon());
|
||||
} else {
|
||||
r._tl.setLon(_tl.lon());
|
||||
r._br.setLon(_br.lon());
|
||||
}
|
||||
|
||||
if (_br.lat() < _tl.lat()) {
|
||||
r._tl.setLat(_br.lat());
|
||||
r._br.setLat(_tl.lat());
|
||||
} else {
|
||||
r._tl.setLat(_tl.lat());
|
||||
r._br.setLat(_br.lat());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
RectC RectC::operator|(const RectC &r) const
|
||||
{
|
||||
if (isNull())
|
||||
|
@ -13,7 +13,9 @@ public:
|
||||
: _tl(topLeft), _br(bottomRight) {}
|
||||
|
||||
bool isNull() const
|
||||
{return _tl.isNull() || _br.isNull() || _tl == _br;}
|
||||
{return _tl.isNull() && _br.isNull();}
|
||||
bool isValid() const
|
||||
{return !(_tl.isNull() || _br.isNull() || _tl == _br);}
|
||||
|
||||
Coordinates topLeft() const {return _tl;}
|
||||
Coordinates bottomRight() const {return _br;}
|
||||
@ -26,8 +28,6 @@ public:
|
||||
|
||||
QSizeF size() const {return QSizeF(width(), height());}
|
||||
|
||||
RectC normalized() const;
|
||||
|
||||
RectC operator|(const RectC &r) const;
|
||||
RectC &operator|=(const RectC &r) {*this = *this | r; return *this;}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user