mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-26 12:10:49 +01:00
Fixed broken zoom 0 on HiDPI displays
This commit is contained in:
parent
de63009edd
commit
6768647070
@ -98,15 +98,17 @@ qreal OnlineMap::tileSize() const
|
|||||||
void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||||
{
|
{
|
||||||
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
|
QRectF b(bounds());
|
||||||
|
|
||||||
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
||||||
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
|
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
|
||||||
QPointF tl(floor(rect.left() / tileSize())
|
QPointF tl(floor(rect.left() / tileSize())
|
||||||
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
|
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
|
||||||
|
|
||||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
QSizeF s(qMin(rect.right() - tl.x(), b.width()),
|
||||||
int width = _zoom ? qCeil(s.width() / tileSize()) : 1;
|
qMin(rect.bottom() - tl.y(), b.height()));
|
||||||
int height = _zoom ? qCeil(s.height() / tileSize()) : 1;
|
int width = ceil(s.width() / tileSize());
|
||||||
|
int height = ceil(s.height() / tileSize());
|
||||||
|
|
||||||
QVector<FetchTile> tiles;
|
QVector<FetchTile> tiles;
|
||||||
tiles.reserve(width * height);
|
tiles.reserve(width * height);
|
||||||
@ -122,10 +124,9 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
FetchTile &t = tiles[i];
|
FetchTile &t = tiles[i];
|
||||||
QPointF tp = _zoom ? QPointF(tl.x() + (t.xy().x() - tile.x())
|
QPointF tp(qMax(tl.x(), b.left()) + (t.xy().x() - tile.x()) * tileSize(),
|
||||||
* tileSize(), tl.y() + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
|
qMax(tl.y(), b.top()) + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
|
||||||
t.xy().y()) - tile.y()) * tileSize())
|
t.xy().y()) - tile.y()) * tileSize());
|
||||||
: QPointF(-_tileSize/2, -_tileSize/2);
|
|
||||||
|
|
||||||
if (!t.pixmap().isNull()) {
|
if (!t.pixmap().isNull()) {
|
||||||
t.pixmap().setDevicePixelRatio(imageRatio());
|
t.pixmap().setDevicePixelRatio(imageRatio());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user