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