mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Added missing MG maps HiDPI displays support
This commit is contained in:
parent
2df916eb95
commit
8ee21a8080
@ -160,12 +160,13 @@ void RasterTile::render()
|
||||
processPolygons(textItems);
|
||||
processLines(textItems);
|
||||
|
||||
_pixmap.setDevicePixelRatio(_ratio);
|
||||
_pixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter painter(&_pixmap);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.translate(-_xy.x(), -_xy.y());
|
||||
painter.translate(-_rect.x(), -_rect.y());
|
||||
|
||||
drawPolygons(&painter);
|
||||
drawLines(&painter);
|
||||
@ -294,7 +295,6 @@ static void removeDuplicitLabel(QList<TextItem *> &labels, const QString &text,
|
||||
|
||||
void RasterTile::processPolygons(QList<TextItem*> &textItems)
|
||||
{
|
||||
QRectF tileRect(_xy, _pixmap.size());
|
||||
QSet<QString> set;
|
||||
QList<TextItem *> labels;
|
||||
|
||||
@ -314,10 +314,10 @@ void RasterTile::processPolygons(QList<TextItem*> &textItems)
|
||||
0, &style.brush().color(), &haloColor);
|
||||
if (item->isValid() && !item->collides(textItems)
|
||||
&& !item->collides(labels)
|
||||
&& !(exists && tileRect.contains(item->boundingRect()))
|
||||
&& !(exists && _rect.contains(item->boundingRect().toRect()))
|
||||
&& rectNearPolygon(poly.points, item->boundingRect())) {
|
||||
if (exists)
|
||||
removeDuplicitLabel(labels, poly.label.text(), tileRect);
|
||||
removeDuplicitLabel(labels, poly.label.text(), _rect);
|
||||
else
|
||||
set.insert(poly.label.text());
|
||||
labels.append(item);
|
||||
@ -331,17 +331,14 @@ void RasterTile::processPolygons(QList<TextItem*> &textItems)
|
||||
|
||||
void RasterTile::processLines(QList<TextItem*> &textItems)
|
||||
{
|
||||
QRect tileRect(_xy, _pixmap.size());
|
||||
|
||||
std::stable_sort(_lines.begin(), _lines.end());
|
||||
|
||||
if (_zoom >= 22)
|
||||
processStreetNames(tileRect, textItems);
|
||||
processShields(tileRect, textItems);
|
||||
processStreetNames(textItems);
|
||||
processShields(textItems);
|
||||
}
|
||||
|
||||
void RasterTile::processStreetNames(const QRect &tileRect,
|
||||
QList<TextItem*> &textItems)
|
||||
void RasterTile::processStreetNames(QList<TextItem*> &textItems)
|
||||
{
|
||||
for (int i = 0; i < _lines.size(); i++) {
|
||||
MapData::Poly &poly = _lines[i];
|
||||
@ -358,7 +355,7 @@ void RasterTile::processStreetNames(const QRect &tileRect,
|
||||
? &style.textColor() : 0;
|
||||
|
||||
TextPathItem *item = new TextPathItem(poly.points,
|
||||
&poly.label.text(), tileRect, fnt, color);
|
||||
&poly.label.text(), _rect, fnt, color);
|
||||
if (item->isValid() && !item->collides(textItems))
|
||||
textItems.append(item);
|
||||
else
|
||||
@ -366,8 +363,7 @@ void RasterTile::processStreetNames(const QRect &tileRect,
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::processShields(const QRect &tileRect,
|
||||
QList<TextItem*> &textItems)
|
||||
void RasterTile::processShields(QList<TextItem*> &textItems)
|
||||
{
|
||||
for (int type = FIRST_SHIELD; type <= LAST_SHIELD; type++) {
|
||||
if (minShieldZoom(static_cast<Shield::Type>(type)) > _zoom)
|
||||
@ -393,7 +389,7 @@ void RasterTile::processShields(const QRect &tileRect,
|
||||
for (QHash<Shield, QPolygonF>::const_iterator it = shields.constBegin();
|
||||
it != shields.constEnd(); ++it) {
|
||||
const QPolygonF &p = it.value();
|
||||
QRectF rect(p.boundingRect() & tileRect);
|
||||
QRectF rect(p.boundingRect() & _rect);
|
||||
if (AREA(rect) < AREA(QRect(0, 0, _pixmap.width()/4, _pixmap.width()/4)))
|
||||
continue;
|
||||
|
||||
@ -413,7 +409,7 @@ void RasterTile::processShields(const QRect &tileRect,
|
||||
bool valid = false;
|
||||
while (true) {
|
||||
if (!item->collides(textItems)
|
||||
&& tileRect.contains(item->boundingRect().toRect())) {
|
||||
&& _rect.contains(item->boundingRect().toRect())) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ class RasterTile
|
||||
{
|
||||
public:
|
||||
RasterTile(IMGMap *map, const Style *style, int zoom, const QRect &rect,
|
||||
const QString &key, const QList<MapData::Poly> &polygons,
|
||||
qreal ratio, const QString &key, const QList<MapData::Poly> &polygons,
|
||||
const QList<MapData::Poly> &lines, QList<MapData::Point> &points)
|
||||
: _map(map), _style(style), _zoom(zoom), _xy(rect.topLeft()),
|
||||
_key(key), _pixmap(rect.size()), _polygons(polygons), _lines(lines),
|
||||
_points(points) {}
|
||||
: _map(map), _style(style), _zoom(zoom), _rect(rect), _ratio(ratio),
|
||||
_key(key), _pixmap(rect.width() * ratio, rect.height() * ratio),
|
||||
_polygons(polygons), _lines(lines), _points(points) {}
|
||||
|
||||
const QString &key() const {return _key;}
|
||||
const QPoint &xy() const {return _xy;}
|
||||
QPoint xy() const {return _rect.topLeft();}
|
||||
const QPixmap &pixmap() const {return _pixmap;}
|
||||
|
||||
void render();
|
||||
@ -39,13 +39,14 @@ private:
|
||||
void processPolygons(QList<TextItem *> &textItems);
|
||||
void processLines(QList<TextItem*> &textItems);
|
||||
void processPoints(QList<TextItem*> &textItems);
|
||||
void processShields(const QRect &tileRect, QList<TextItem*> &textItems);
|
||||
void processStreetNames(const QRect &tileRect, QList<TextItem*> &textItems);
|
||||
void processShields(QList<TextItem*> &textItems);
|
||||
void processStreetNames(QList<TextItem*> &textItems);
|
||||
|
||||
IMGMap *_map;
|
||||
const Style *_style;
|
||||
int _zoom;
|
||||
QPoint _xy;
|
||||
QRect _rect;
|
||||
qreal _ratio;
|
||||
QString _key;
|
||||
QPixmap _pixmap;
|
||||
QList<MapData::Poly> _polygons;
|
||||
|
@ -41,7 +41,8 @@ static QList<MapData*> overlays(const QString &fileName)
|
||||
}
|
||||
|
||||
IMGMap::IMGMap(const QString &fileName, QObject *parent)
|
||||
: Map(fileName, parent), _projection(PCS::pcs(3857)), _valid(false)
|
||||
: Map(fileName, parent), _projection(PCS::pcs(3857)), _tileRatio(1.0),
|
||||
_valid(false)
|
||||
{
|
||||
if (GMAPData::isGMAP(fileName))
|
||||
_data.append(new GMAPData(fileName));
|
||||
@ -182,8 +183,8 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
_zoom, &points);
|
||||
|
||||
tiles.append(RasterTile(this, _data.at(n)->style(), _zoom,
|
||||
QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), key, polygons,
|
||||
lines, points));
|
||||
QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), _tileRatio, key,
|
||||
polygons, lines, points));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,6 +201,13 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
}
|
||||
}
|
||||
|
||||
void IMGMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||
{
|
||||
Q_UNUSED(mapRatio);
|
||||
|
||||
_tileRatio = deviceRatio;
|
||||
}
|
||||
|
||||
void IMGMap::setOutputProjection(const Projection &projection)
|
||||
{
|
||||
if (projection == _projection)
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||
|
||||
void setOutputProjection(const Projection &projection);
|
||||
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||
|
||||
void load();
|
||||
void unload();
|
||||
@ -53,6 +54,7 @@ private:
|
||||
Transform _transform;
|
||||
QRectF _bounds;
|
||||
RectC _dataBounds;
|
||||
qreal _tileRatio;
|
||||
|
||||
bool _valid;
|
||||
QString _errorString;
|
||||
|
Loading…
Reference in New Issue
Block a user