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