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 2018-04-28 16:07:32 +02:00
parent 266a1d037e
commit bcff05c37c
14 changed files with 26 additions and 32 deletions

View File

@ -503,7 +503,6 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
// Enter plot mode
setUpdatesEnabled(false);
_plot = true;
_map->setBlockingMode(true);
// Compute sizes & ratios
orig = viewport()->rect();
@ -562,7 +561,6 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
_mapScale->setPos(origPos);
// Exit plot mode
_map->setBlockingMode(false);
_plot = false;
setUpdatesEnabled(true);
}
@ -763,7 +761,7 @@ void MapView::drawBackground(QPainter *painter, const QRectF &rect)
QRectF ir = rect.intersected(_map->bounds());
if (_opacity < 1.0)
painter->setOpacity(_opacity);
_map->draw(painter, ir);
_map->draw(painter, ir, _plot);
}
}

View File

@ -260,8 +260,10 @@ Coordinates Atlas::xy2ll(const QPointF &p)
return _maps.at(idx)->xy2ll(p2);
}
void Atlas::draw(QPainter *painter, const QRectF &rect)
void Atlas::draw(QPainter *painter, const QRectF &rect, bool block)
{
Q_UNUSED(block);
// All in one map
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
if (_bounds.at(i).second.contains(rect)) {
@ -288,7 +290,7 @@ void Atlas::draw(QPainter *painter, const QRectF &rect, int mapIndex)
map->load();
painter->translate(offset);
map->draw(painter, pr);
map->draw(painter, pr, true);
painter->translate(-offset);
}

View File

@ -25,7 +25,7 @@ public:
QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p);
void draw(QPainter *painter, const QRectF &rect);
void draw(QPainter *painter, const QRectF &rect, bool block);
void unload();

View File

@ -85,8 +85,9 @@ int EmptyMap::zoomOut()
return _zoom;
}
void EmptyMap::draw(QPainter *painter, const QRectF &rect)
void EmptyMap::draw(QPainter *painter, const QRectF &rect, bool block)
{
Q_UNUSED(block);
painter->fillRect(rect, _backgroundColor);
}

View File

@ -25,7 +25,7 @@ public:
Coordinates xy2ll(const QPointF &p)
{return static_cast<const EmptyMap &>(*this).xy2ll(p);}
void draw(QPainter *painter, const QRectF &rect);
void draw(QPainter *painter, const QRectF &rect, bool block);
private:
QPointF ll2xy(const Coordinates &c) const;

View File

@ -31,9 +31,8 @@ public:
virtual QPointF ll2xy(const Coordinates &c) = 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, bool block) = 0;
virtual void setBlockingMode(bool block) {Q_UNUSED(block);}
virtual void clearCache() {}
virtual void load() {}
virtual void unload() {}

View File

@ -311,8 +311,10 @@ void OfflineMap::drawImage(QPainter *painter, const QRectF &rect) const
r.width(), r.height());
}
void OfflineMap::draw(QPainter *painter, const QRectF &rect)
void OfflineMap::draw(QPainter *painter, const QRectF &rect, bool block)
{
Q_UNUSED(block);
if (_ozf)
drawOZF(painter, rect);
else if (_tile.isValid())

View File

@ -33,7 +33,7 @@ public:
Coordinates xy2ll(const QPointF &p)
{return static_cast<const OfflineMap &>(*this).xy2ll(p);}
void draw(QPainter *painter, const QRectF &rect);
void draw(QPainter *painter, const QRectF &rect, bool block);
void load();
void unload();

View File

@ -44,7 +44,7 @@ static int scale2zoom(qreal scale)
OnlineMap::OnlineMap(const QString &name, const QString &url,
const Range &zooms, const RectC &bounds, const Authorization &authorization,
QObject *parent) : Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
_block(false), _valid(false)
_valid(false)
{
QString dir(TILES_DIR + "/" + _name);
@ -112,7 +112,7 @@ int OnlineMap::zoomOut()
return _zoom;
}
void OnlineMap::draw(QPainter *painter, const QRectF &rect)
void OnlineMap::draw(QPainter *painter, const QRectF &rect, bool block)
{
qreal scale = zoom2scale(_zoom);
@ -127,7 +127,7 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect)
for (int j = 0; j < ceil(s.height() / TILE_SIZE); j++)
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
if (_block)
if (block)
_tileLoader->loadTilesSync(tiles);
else
_tileLoader->loadTilesAsync(tiles);

View File

@ -30,9 +30,8 @@ public:
Coordinates xy2ll(const QPointF &p)
{return static_cast<const OnlineMap &>(*this).xy2ll(p);}
void draw(QPainter *painter, const QRectF &rect);
void draw(QPainter *painter, const QRectF &rect, bool block);
void setBlockingMode(bool block) {_block = block;}
void clearCache() {_tileLoader->clearCache();}
bool isValid() const {return _valid;}
@ -48,7 +47,6 @@ private:
Range _zooms;
RectC _bounds;
int _zoom;
bool _block;
bool _valid;
QString _errorString;

View File

@ -103,8 +103,7 @@ bool WMSMap::loadWMS()
}
WMSMap::WMSMap(const QString &name, const WMS::Setup &setup, QObject *parent)
: Map(parent), _name(name), _setup(setup), _zoom(0), _block(false),
_valid(false)
: Map(parent), _name(name), _setup(setup), _zoom(0), _valid(false)
{
if (!QDir().mkpath(tilesDir())) {
_errorString = "Error creating tiles dir";
@ -187,7 +186,7 @@ Coordinates WMSMap::xy2ll(const QPointF &p) const
return _projection.xy2ll(_transform.img2proj(p));
}
void WMSMap::draw(QPainter *painter, const QRectF &rect)
void WMSMap::draw(QPainter *painter, const QRectF &rect, bool block)
{
QPoint tl = QPoint((int)floor(rect.left() / (qreal)TILE_SIZE),
(int)floor(rect.top() / (qreal)TILE_SIZE));
@ -209,7 +208,7 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect)
}
}
if (_block)
if (block)
_tileLoader->loadTilesSync(tiles);
else
_tileLoader->loadTilesAsync(tiles);

View File

@ -30,9 +30,8 @@ public:
Coordinates xy2ll(const QPointF &p)
{return static_cast<const WMSMap &>(*this).xy2ll(p);}
void draw(QPainter *painter, const QRectF &rect);
void draw(QPainter *painter, const QRectF &rect, bool block);
void setBlockingMode(bool block) {_block = block;}
void clearCache();
bool isValid() const {return _valid;}
@ -60,7 +59,6 @@ private:
PointD _tl, _br;
QRectF _bounds;
int _zoom;
bool _block;
bool _valid;
QString _errorString;

View File

@ -36,8 +36,7 @@ bool WMTSMap::loadWMTS()
}
WMTSMap::WMTSMap(const QString &name, const WMTS::Setup &setup, QObject *parent)
: Map(parent), _name(name), _setup(setup), _zoom(0), _block(false),
_valid(false)
: Map(parent), _name(name), _setup(setup), _zoom(0), _valid(false)
{
if (!QDir().mkpath(tilesDir())) {
_errorString = "Error creating tiles dir";
@ -158,7 +157,7 @@ int WMTSMap::zoomOut()
return _zoom;
}
void WMTSMap::draw(QPainter *painter, const QRectF &rect)
void WMTSMap::draw(QPainter *painter, const QRectF &rect, bool block)
{
const WMTS::Zoom &z = _zooms.at(_zoom);
QPoint tl = QPoint((int)floor(rect.left() / (qreal)z.tile().width()),
@ -171,7 +170,7 @@ void WMTSMap::draw(QPainter *painter, const QRectF &rect)
for (int j = tl.y(); j < br.y(); j++)
tiles.append(Tile(QPoint(i, j), z.id()));
if (_block)
if (block)
_tileLoader->loadTilesSync(tiles);
else
_tileLoader->loadTilesAsync(tiles);

View File

@ -30,9 +30,8 @@ public:
Coordinates xy2ll(const QPointF &p)
{return static_cast<const WMTSMap &>(*this).xy2ll(p);}
void draw(QPainter *painter, const QRectF &rect);
void draw(QPainter *painter, const QRectF &rect, bool block);
void setBlockingMode(bool block) {_block = block;}
void clearCache();
bool isValid() const {return _valid;}
@ -56,7 +55,6 @@ private:
Transform _transform;
CoordinateSystem _cs;
int _zoom;
bool _block;
bool _valid;
QString _errorString;