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
266a1d037e
commit
bcff05c37c
@ -503,7 +503,6 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
|
|||||||
// Enter plot mode
|
// Enter plot mode
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
_plot = true;
|
_plot = true;
|
||||||
_map->setBlockingMode(true);
|
|
||||||
|
|
||||||
// Compute sizes & ratios
|
// Compute sizes & ratios
|
||||||
orig = viewport()->rect();
|
orig = viewport()->rect();
|
||||||
@ -562,7 +561,6 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
|
|||||||
_mapScale->setPos(origPos);
|
_mapScale->setPos(origPos);
|
||||||
|
|
||||||
// Exit plot mode
|
// Exit plot mode
|
||||||
_map->setBlockingMode(false);
|
|
||||||
_plot = false;
|
_plot = false;
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
@ -763,7 +761,7 @@ void MapView::drawBackground(QPainter *painter, const QRectF &rect)
|
|||||||
QRectF ir = rect.intersected(_map->bounds());
|
QRectF ir = rect.intersected(_map->bounds());
|
||||||
if (_opacity < 1.0)
|
if (_opacity < 1.0)
|
||||||
painter->setOpacity(_opacity);
|
painter->setOpacity(_opacity);
|
||||||
_map->draw(painter, ir);
|
_map->draw(painter, ir, _plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,8 +260,10 @@ Coordinates Atlas::xy2ll(const QPointF &p)
|
|||||||
return _maps.at(idx)->xy2ll(p2);
|
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
|
// All in one map
|
||||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
if (_bounds.at(i).second.contains(rect)) {
|
if (_bounds.at(i).second.contains(rect)) {
|
||||||
@ -288,7 +290,7 @@ void Atlas::draw(QPainter *painter, const QRectF &rect, int mapIndex)
|
|||||||
map->load();
|
map->load();
|
||||||
|
|
||||||
painter->translate(offset);
|
painter->translate(offset);
|
||||||
map->draw(painter, pr);
|
map->draw(painter, pr, true);
|
||||||
painter->translate(-offset);
|
painter->translate(-offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
QPointF ll2xy(const Coordinates &c);
|
QPointF ll2xy(const Coordinates &c);
|
||||||
Coordinates xy2ll(const QPointF &p);
|
Coordinates xy2ll(const QPointF &p);
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect);
|
void draw(QPainter *painter, const QRectF &rect, bool block);
|
||||||
|
|
||||||
void unload();
|
void unload();
|
||||||
|
|
||||||
|
@ -85,8 +85,9 @@ int EmptyMap::zoomOut()
|
|||||||
return _zoom;
|
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);
|
painter->fillRect(rect, _backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
Coordinates xy2ll(const QPointF &p)
|
Coordinates xy2ll(const QPointF &p)
|
||||||
{return static_cast<const EmptyMap &>(*this).xy2ll(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:
|
private:
|
||||||
QPointF ll2xy(const Coordinates &c) const;
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
@ -31,9 +31,8 @@ public:
|
|||||||
virtual QPointF ll2xy(const Coordinates &c) = 0;
|
virtual QPointF ll2xy(const Coordinates &c) = 0;
|
||||||
virtual Coordinates xy2ll(const QPointF &p) = 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 clearCache() {}
|
||||||
virtual void load() {}
|
virtual void load() {}
|
||||||
virtual void unload() {}
|
virtual void unload() {}
|
||||||
|
@ -311,8 +311,10 @@ void OfflineMap::drawImage(QPainter *painter, const QRectF &rect) const
|
|||||||
r.width(), r.height());
|
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)
|
if (_ozf)
|
||||||
drawOZF(painter, rect);
|
drawOZF(painter, rect);
|
||||||
else if (_tile.isValid())
|
else if (_tile.isValid())
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
Coordinates xy2ll(const QPointF &p)
|
Coordinates xy2ll(const QPointF &p)
|
||||||
{return static_cast<const OfflineMap &>(*this).xy2ll(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 load();
|
||||||
void unload();
|
void unload();
|
||||||
|
@ -44,7 +44,7 @@ static int scale2zoom(qreal scale)
|
|||||||
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
||||||
const Range &zooms, const RectC &bounds, const Authorization &authorization,
|
const Range &zooms, const RectC &bounds, const Authorization &authorization,
|
||||||
QObject *parent) : Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
|
QObject *parent) : Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
|
||||||
_block(false), _valid(false)
|
_valid(false)
|
||||||
{
|
{
|
||||||
QString dir(TILES_DIR + "/" + _name);
|
QString dir(TILES_DIR + "/" + _name);
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ int OnlineMap::zoomOut()
|
|||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnlineMap::draw(QPainter *painter, const QRectF &rect)
|
void OnlineMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
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++)
|
for (int j = 0; j < ceil(s.height() / TILE_SIZE); j++)
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
||||||
|
|
||||||
if (_block)
|
if (block)
|
||||||
_tileLoader->loadTilesSync(tiles);
|
_tileLoader->loadTilesSync(tiles);
|
||||||
else
|
else
|
||||||
_tileLoader->loadTilesAsync(tiles);
|
_tileLoader->loadTilesAsync(tiles);
|
||||||
|
@ -30,9 +30,8 @@ public:
|
|||||||
Coordinates xy2ll(const QPointF &p)
|
Coordinates xy2ll(const QPointF &p)
|
||||||
{return static_cast<const OnlineMap &>(*this).xy2ll(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();}
|
void clearCache() {_tileLoader->clearCache();}
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
@ -48,7 +47,6 @@ private:
|
|||||||
Range _zooms;
|
Range _zooms;
|
||||||
RectC _bounds;
|
RectC _bounds;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
bool _block;
|
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -103,8 +103,7 @@ bool WMSMap::loadWMS()
|
|||||||
}
|
}
|
||||||
|
|
||||||
WMSMap::WMSMap(const QString &name, const WMS::Setup &setup, QObject *parent)
|
WMSMap::WMSMap(const QString &name, const WMS::Setup &setup, QObject *parent)
|
||||||
: Map(parent), _name(name), _setup(setup), _zoom(0), _block(false),
|
: Map(parent), _name(name), _setup(setup), _zoom(0), _valid(false)
|
||||||
_valid(false)
|
|
||||||
{
|
{
|
||||||
if (!QDir().mkpath(tilesDir())) {
|
if (!QDir().mkpath(tilesDir())) {
|
||||||
_errorString = "Error creating tiles dir";
|
_errorString = "Error creating tiles dir";
|
||||||
@ -187,7 +186,7 @@ Coordinates WMSMap::xy2ll(const QPointF &p) const
|
|||||||
return _projection.xy2ll(_transform.img2proj(p));
|
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),
|
QPoint tl = QPoint((int)floor(rect.left() / (qreal)TILE_SIZE),
|
||||||
(int)floor(rect.top() / (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);
|
_tileLoader->loadTilesSync(tiles);
|
||||||
else
|
else
|
||||||
_tileLoader->loadTilesAsync(tiles);
|
_tileLoader->loadTilesAsync(tiles);
|
||||||
|
@ -30,9 +30,8 @@ public:
|
|||||||
Coordinates xy2ll(const QPointF &p)
|
Coordinates xy2ll(const QPointF &p)
|
||||||
{return static_cast<const WMSMap &>(*this).xy2ll(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();
|
void clearCache();
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
@ -60,7 +59,6 @@ private:
|
|||||||
PointD _tl, _br;
|
PointD _tl, _br;
|
||||||
QRectF _bounds;
|
QRectF _bounds;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
bool _block;
|
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -36,8 +36,7 @@ bool WMTSMap::loadWMTS()
|
|||||||
}
|
}
|
||||||
|
|
||||||
WMTSMap::WMTSMap(const QString &name, const WMTS::Setup &setup, QObject *parent)
|
WMTSMap::WMTSMap(const QString &name, const WMTS::Setup &setup, QObject *parent)
|
||||||
: Map(parent), _name(name), _setup(setup), _zoom(0), _block(false),
|
: Map(parent), _name(name), _setup(setup), _zoom(0), _valid(false)
|
||||||
_valid(false)
|
|
||||||
{
|
{
|
||||||
if (!QDir().mkpath(tilesDir())) {
|
if (!QDir().mkpath(tilesDir())) {
|
||||||
_errorString = "Error creating tiles dir";
|
_errorString = "Error creating tiles dir";
|
||||||
@ -158,7 +157,7 @@ int WMTSMap::zoomOut()
|
|||||||
return _zoom;
|
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);
|
const WMTS::Zoom &z = _zooms.at(_zoom);
|
||||||
QPoint tl = QPoint((int)floor(rect.left() / (qreal)z.tile().width()),
|
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++)
|
for (int j = tl.y(); j < br.y(); j++)
|
||||||
tiles.append(Tile(QPoint(i, j), z.id()));
|
tiles.append(Tile(QPoint(i, j), z.id()));
|
||||||
|
|
||||||
if (_block)
|
if (block)
|
||||||
_tileLoader->loadTilesSync(tiles);
|
_tileLoader->loadTilesSync(tiles);
|
||||||
else
|
else
|
||||||
_tileLoader->loadTilesAsync(tiles);
|
_tileLoader->loadTilesAsync(tiles);
|
||||||
|
@ -30,9 +30,8 @@ public:
|
|||||||
Coordinates xy2ll(const QPointF &p)
|
Coordinates xy2ll(const QPointF &p)
|
||||||
{return static_cast<const WMTSMap &>(*this).xy2ll(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();
|
void clearCache();
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
@ -56,7 +55,6 @@ private:
|
|||||||
Transform _transform;
|
Transform _transform;
|
||||||
CoordinateSystem _cs;
|
CoordinateSystem _cs;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
bool _block;
|
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
Loading…
Reference in New Issue
Block a user