mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Reload the ENC style on device pixel ratio changes
This commit is contained in:
parent
c4b1671fec
commit
ba2fd6d2e2
@ -1,6 +1,9 @@
|
|||||||
#ifndef ENC_OBJECTS_H
|
#ifndef ENC_OBJECTS_H
|
||||||
#define ENC_OBJECTS_H
|
#define ENC_OBJECTS_H
|
||||||
|
|
||||||
|
#define TYPE(t) ((t)<<16)
|
||||||
|
#define SUBTYPE(t, s) (((t)<<16)|(s))
|
||||||
|
|
||||||
#define AIRARE 2
|
#define AIRARE 2
|
||||||
#define ACHBRT 3
|
#define ACHBRT 3
|
||||||
#define ACHARE 4
|
#define ACHARE 4
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
#include "common/linec.h"
|
#include "common/linec.h"
|
||||||
#include "map/bitmapline.h"
|
#include "map/bitmapline.h"
|
||||||
#include "map/textpathitem.h"
|
#include "map/textpathitem.h"
|
||||||
|
#include "map/textpointitem.h"
|
||||||
#include "map/rectd.h"
|
#include "map/rectd.h"
|
||||||
|
#include "objects.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
#include "rastertile.h"
|
#include "rastertile.h"
|
||||||
|
|
||||||
@ -18,12 +20,6 @@ static const float C1 = 0.866025f; /* sqrt(3)/2 */
|
|||||||
static const QColor tsslptPen = QColor(0xeb, 0x49, 0xeb);
|
static const QColor tsslptPen = QColor(0xeb, 0x49, 0xeb);
|
||||||
static const QColor tsslptBrush = QColor(0xeb, 0x49, 0xeb, 0x80);
|
static const QColor tsslptBrush = QColor(0xeb, 0x49, 0xeb, 0x80);
|
||||||
|
|
||||||
static const Style *style(qreal ratio)
|
|
||||||
{
|
|
||||||
static ENC::Style s(ratio);
|
|
||||||
return &s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double area(const QVector<Coordinates> &polygon)
|
static double area(const QVector<Coordinates> &polygon)
|
||||||
{
|
{
|
||||||
double area = 0;
|
double area = 0;
|
||||||
@ -406,21 +402,19 @@ void RasterTile::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
||||||
const MapData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
const Style *style, const MapData *data, int zoom, const Range &zoomRange,
|
||||||
qreal ratio) :
|
const QRect &rect, qreal ratio) :
|
||||||
_proj(proj), _transform(transform), _map(data), _atlas(0), _zoom(zoom),
|
_proj(proj), _transform(transform), _style(style), _map(data), _atlas(0),
|
||||||
_zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
||||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
||||||
{
|
{
|
||||||
_style = style(ratio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile::RasterTile(const Projection &proj, const Transform &transform,
|
||||||
AtlasData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
const Style *style, AtlasData *data, int zoom, const Range &zoomRange,
|
||||||
qreal ratio) :
|
const QRect &rect, qreal ratio) :
|
||||||
_proj(proj), _transform(transform), _map(0), _atlas(data), _zoom(zoom),
|
_proj(proj), _transform(transform), _style(style), _map(0), _atlas(data),
|
||||||
_zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio),
|
||||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false)
|
||||||
{
|
{
|
||||||
_style = style(ratio);
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
#include "map/projection.h"
|
#include "map/projection.h"
|
||||||
#include "map/transform.h"
|
#include "map/transform.h"
|
||||||
#include "map/textpointitem.h"
|
|
||||||
#include "mapdata.h"
|
#include "mapdata.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
#include "atlasdata.h"
|
#include "atlasdata.h"
|
||||||
@ -18,11 +17,11 @@ class RasterTile
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile(const Projection &proj, const Transform &transform,
|
||||||
const MapData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
const Style *style, const MapData *data, int zoom, const Range &zoomRange,
|
||||||
qreal ratio);
|
const QRect &rect, qreal ratio);
|
||||||
RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile(const Projection &proj, const Transform &transform,
|
||||||
AtlasData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
const Style *style, AtlasData *data, int zoom, const Range &zoomRange,
|
||||||
qreal ratio);
|
const QRect &rect, qreal ratio);
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
QPoint xy() const {return _rect.topLeft();}
|
QPoint xy() const {return _rect.topLeft();}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
#include "objects.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
|
|
||||||
using namespace ENC;
|
using namespace ENC;
|
||||||
|
@ -5,13 +5,9 @@
|
|||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include "objects.h"
|
|
||||||
|
|
||||||
namespace ENC {
|
namespace ENC {
|
||||||
|
|
||||||
#define TYPE(t) ((t)<<16)
|
|
||||||
#define SUBTYPE(t, s) (((t)<<16)|(s))
|
|
||||||
|
|
||||||
class Style
|
class Style
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -121,8 +121,8 @@ void ENCAtlas::addMap(const QDir &dir, const QByteArray &file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ENCAtlas::ENCAtlas(const QString &fileName, QObject *parent)
|
ENCAtlas::ENCAtlas(const QString &fileName, QObject *parent)
|
||||||
: Map(fileName, parent), _projection(PCS::pcs(3857)),
|
: Map(fileName, parent), _projection(PCS::pcs(3857)), _tileRatio(1.0),
|
||||||
_tileRatio(1.0), _zoom(0), _valid(false)
|
_style(0), _zoom(0), _valid(false)
|
||||||
{
|
{
|
||||||
QDir dir(QFileInfo(fileName).absoluteDir());
|
QDir dir(QFileInfo(fileName).absoluteDir());
|
||||||
ISO8211 ddf(fileName);
|
ISO8211 ddf(fileName);
|
||||||
@ -160,6 +160,7 @@ ENCAtlas::ENCAtlas(const QString &fileName, QObject *parent)
|
|||||||
ENCAtlas::~ENCAtlas()
|
ENCAtlas::~ENCAtlas()
|
||||||
{
|
{
|
||||||
qDeleteAll(_data);
|
qDeleteAll(_data);
|
||||||
|
delete _style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ENCAtlas::load(const Projection &in, const Projection &out,
|
void ENCAtlas::load(const Projection &in, const Projection &out,
|
||||||
@ -171,6 +172,9 @@ void ENCAtlas::load(const Projection &in, const Projection &out,
|
|||||||
_tileRatio = deviceRatio;
|
_tileRatio = deviceRatio;
|
||||||
_projection = out;
|
_projection = out;
|
||||||
|
|
||||||
|
Q_ASSERT(!_style);
|
||||||
|
_style = new Style(deviceRatio);
|
||||||
|
|
||||||
QPixmapCache::clear();
|
QPixmapCache::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +183,9 @@ void ENCAtlas::unload()
|
|||||||
cancelJobs(true);
|
cancelJobs(true);
|
||||||
|
|
||||||
_cache.clear();
|
_cache.clear();
|
||||||
|
|
||||||
|
delete _style;
|
||||||
|
_style = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ENCAtlas::zoomFit(const QSize &size, const RectC &rect)
|
int ENCAtlas::zoomFit(const QSize &size, const RectC &rect)
|
||||||
@ -356,7 +363,7 @@ void ENCAtlas::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
||||||
painter->drawPixmap(ttl, pm);
|
painter->drawPixmap(ttl, pm);
|
||||||
else
|
else
|
||||||
tiles.append(RasterTile(_projection, _transform,
|
tiles.append(RasterTile(_projection, _transform, _style,
|
||||||
_data.value(_usage), _zoom, zooms(_usage),
|
_data.value(_usage), _zoom, zooms(_usage),
|
||||||
QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), _tileRatio));
|
QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), _tileRatio));
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#ifndef ENCATLAS_H
|
#ifndef ENCATLAS_H
|
||||||
#define ENCATLAS_H
|
#define ENCATLAS_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QMutex>
|
||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "projection.h"
|
#include "projection.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
#include "ENC/iso8211.h"
|
#include "ENC/iso8211.h"
|
||||||
#include "ENC/atlasdata.h"
|
#include "ENC/atlasdata.h"
|
||||||
|
#include "ENC/style.h"
|
||||||
|
|
||||||
class ENCJob;
|
class ENCJob;
|
||||||
class QDir;
|
class QDir;
|
||||||
@ -84,6 +87,7 @@ private:
|
|||||||
Transform _transform;
|
Transform _transform;
|
||||||
qreal _tileRatio;
|
qreal _tileRatio;
|
||||||
QMap<IntendedUsage, ENC::AtlasData*> _data;
|
QMap<IntendedUsage, ENC::AtlasData*> _data;
|
||||||
|
ENC::Style *_style;
|
||||||
ENC::MapCache _cache;
|
ENC::MapCache _cache;
|
||||||
QMutex _lock;
|
QMutex _lock;
|
||||||
IntendedUsage _usage;
|
IntendedUsage _usage;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
#include "common/wgs84.h"
|
#include "common/wgs84.h"
|
||||||
|
#include "ENC/mapdata.h"
|
||||||
|
#include "ENC/style.h"
|
||||||
#include "rectd.h"
|
#include "rectd.h"
|
||||||
#include "pcs.h"
|
#include "pcs.h"
|
||||||
#include "encjob.h"
|
#include "encjob.h"
|
||||||
@ -118,7 +120,7 @@ bool ENCMap::processRecord(const ISO8211::Record &record,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ENCMap::ENCMap(const QString &fileName, QObject *parent)
|
ENCMap::ENCMap(const QString &fileName, QObject *parent)
|
||||||
: Map(fileName, parent), _data(0), _projection(PCS::pcs(3857)),
|
: Map(fileName, parent), _data(0), _style(0), _projection(PCS::pcs(3857)),
|
||||||
_tileRatio(1.0), _valid(false)
|
_tileRatio(1.0), _valid(false)
|
||||||
{
|
{
|
||||||
QVector<ISO8211::Record> gv;
|
QVector<ISO8211::Record> gv;
|
||||||
@ -161,6 +163,12 @@ ENCMap::ENCMap(const QString &fileName, QObject *parent)
|
|||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ENCMap::~ENCMap()
|
||||||
|
{
|
||||||
|
delete _data;
|
||||||
|
delete _style;
|
||||||
|
}
|
||||||
|
|
||||||
void ENCMap::load(const Projection &in, const Projection &out,
|
void ENCMap::load(const Projection &in, const Projection &out,
|
||||||
qreal deviceRatio, bool hidpi)
|
qreal deviceRatio, bool hidpi)
|
||||||
{
|
{
|
||||||
@ -171,6 +179,9 @@ void ENCMap::load(const Projection &in, const Projection &out,
|
|||||||
_projection = out;
|
_projection = out;
|
||||||
Q_ASSERT(!_data);
|
Q_ASSERT(!_data);
|
||||||
_data = new MapData(path());
|
_data = new MapData(path());
|
||||||
|
Q_ASSERT(!_style);
|
||||||
|
_style = new Style(deviceRatio);
|
||||||
|
|
||||||
QPixmapCache::clear();
|
QPixmapCache::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,6 +191,8 @@ void ENCMap::unload()
|
|||||||
|
|
||||||
delete _data;
|
delete _data;
|
||||||
_data = 0;
|
_data = 0;
|
||||||
|
delete _style;
|
||||||
|
_style = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ENCMap::zoomFit(const QSize &size, const RectC &rect)
|
int ENCMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
@ -323,8 +336,9 @@ void ENCMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
||||||
painter->drawPixmap(ttl, pm);
|
painter->drawPixmap(ttl, pm);
|
||||||
else
|
else
|
||||||
tiles.append(RasterTile(_projection, _transform, _data, _zoom,
|
tiles.append(RasterTile(_projection, _transform, _style, _data,
|
||||||
_zooms, QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), _tileRatio));
|
_zoom, _zooms, QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)),
|
||||||
|
_tileRatio));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "projection.h"
|
#include "projection.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
#include "ENC/mapdata.h"
|
|
||||||
#include "ENC/iso8211.h"
|
#include "ENC/iso8211.h"
|
||||||
|
#include "ENC/mapdata.h"
|
||||||
|
#include "ENC/style.h"
|
||||||
|
|
||||||
class ENCJob;
|
class ENCJob;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ class ENCMap : public Map
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ENCMap(const QString &fileName, QObject *parent = 0);
|
ENCMap(const QString &fileName, QObject *parent = 0);
|
||||||
~ENCMap() {delete _data;}
|
~ENCMap();
|
||||||
|
|
||||||
QString name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ private:
|
|||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
ENC::MapData *_data;
|
ENC::MapData *_data;
|
||||||
|
ENC::Style *_style;
|
||||||
Projection _projection;
|
Projection _projection;
|
||||||
Transform _transform;
|
Transform _transform;
|
||||||
qreal _tileRatio;
|
qreal _tileRatio;
|
||||||
|
Loading…
Reference in New Issue
Block a user