mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Process all the ll2xy operations in parallel
This commit is contained in:
parent
3635a7dfdc
commit
baf574b68b
@ -1,5 +1,6 @@
|
|||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include "map/imgmap.h"
|
||||||
#include "textpathitem.h"
|
#include "textpathitem.h"
|
||||||
#include "textpointitem.h"
|
#include "textpointitem.h"
|
||||||
#include "bitmapline.h"
|
#include "bitmapline.h"
|
||||||
@ -166,6 +167,10 @@ void RasterTile::render()
|
|||||||
{
|
{
|
||||||
QList<TextItem*> textItems;
|
QList<TextItem*> textItems;
|
||||||
|
|
||||||
|
ll2xy(_polygons);
|
||||||
|
ll2xy(_lines);
|
||||||
|
ll2xy(_points);
|
||||||
|
|
||||||
processPoints(textItems);
|
processPoints(textItems);
|
||||||
processPolygons(textItems);
|
processPolygons(textItems);
|
||||||
processLines(textItems);
|
processLines(textItems);
|
||||||
@ -186,6 +191,25 @@ void RasterTile::render()
|
|||||||
qDeleteAll(textItems);
|
qDeleteAll(textItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RasterTile::ll2xy(QList<MapData::Poly> &polys)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < polys.size(); i++) {
|
||||||
|
MapData::Poly &poly = polys[i];
|
||||||
|
for (int j = 0; j < poly.points.size(); j++) {
|
||||||
|
QPointF &p = poly.points[j];
|
||||||
|
p = _map->ll2xy(Coordinates(p.x(), p.y()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RasterTile::ll2xy(QList<MapData::Point> &points)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < points.size(); i++) {
|
||||||
|
QPointF p(_map->ll2xy(points.at(i).coordinates));
|
||||||
|
points[i].coordinates = Coordinates(p.x(), p.y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RasterTile::drawPolygons(QPainter *painter)
|
void RasterTile::drawPolygons(QPainter *painter)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < _style->drawOrder().size(); n++) {
|
for (int n = 0; n < _style->drawOrder().size(); n++) {
|
||||||
|
@ -7,14 +7,15 @@
|
|||||||
class QPainter;
|
class QPainter;
|
||||||
class TextItem;
|
class TextItem;
|
||||||
class Style;
|
class Style;
|
||||||
|
class IMGMap;
|
||||||
|
|
||||||
class RasterTile
|
class RasterTile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RasterTile(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,
|
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)
|
||||||
: _style(style), _zoom(zoom), _xy(rect.topLeft()),
|
: _map(map), _style(style), _zoom(zoom), _xy(rect.topLeft()),
|
||||||
_key(key), _img(rect.size(), QImage::Format_ARGB32_Premultiplied),
|
_key(key), _img(rect.size(), QImage::Format_ARGB32_Premultiplied),
|
||||||
_polygons(polygons), _lines(lines), _points(points) {}
|
_polygons(polygons), _lines(lines), _points(points) {}
|
||||||
|
|
||||||
@ -25,6 +26,9 @@ public:
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void ll2xy(QList<MapData::Poly> &polys);
|
||||||
|
void ll2xy(QList<MapData::Point> &points);
|
||||||
|
|
||||||
void drawPolygons(QPainter *painter);
|
void drawPolygons(QPainter *painter);
|
||||||
void drawLines(QPainter *painter);
|
void drawLines(QPainter *painter);
|
||||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);
|
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);
|
||||||
@ -35,6 +39,7 @@ private:
|
|||||||
void processShields(const QRect &tileRect, QList<TextItem*> &textItems);
|
void processShields(const QRect &tileRect, QList<TextItem*> &textItems);
|
||||||
void processStreetNames(const QRect &tileRect, QList<TextItem*> &textItems);
|
void processStreetNames(const QRect &tileRect, QList<TextItem*> &textItems);
|
||||||
|
|
||||||
|
IMGMap *_map;
|
||||||
const Style *_style;
|
const Style *_style;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
QPoint _xy;
|
QPoint _xy;
|
||||||
|
@ -141,35 +141,6 @@ void IMGMap::updateTransform()
|
|||||||
_bounds.adjust(0.5, 0, -0.5, 0);
|
_bounds.adjust(0.5, 0, -0.5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF IMGMap::ll2xy(const Coordinates &c)
|
|
||||||
{
|
|
||||||
return _transform.proj2img(_projection.ll2xy(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
Coordinates IMGMap::xy2ll(const QPointF &p)
|
|
||||||
{
|
|
||||||
return _projection.xy2ll(_transform.img2proj(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
void IMGMap::ll2xy(QList<MapData::Poly> &polys)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < polys.size(); i++) {
|
|
||||||
MapData::Poly &poly = polys[i];
|
|
||||||
for (int j = 0; j < poly.points.size(); j++) {
|
|
||||||
QPointF &p = poly.points[j];
|
|
||||||
p = ll2xy(Coordinates(p.x(), p.y()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IMGMap::ll2xy(QList<MapData::Point> &points)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < points.size(); i++) {
|
|
||||||
QPointF p(ll2xy(points.at(i).coordinates));
|
|
||||||
points[i].coordinates = Coordinates(p.x(), p.y());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||||
{
|
{
|
||||||
Q_UNUSED(flags);
|
Q_UNUSED(flags);
|
||||||
@ -202,7 +173,6 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
_transform.img2proj(polyRect.bottomRight()));
|
_transform.img2proj(polyRect.bottomRight()));
|
||||||
_data.at(n)->polys(polyRectD.toRectC(_projection, 4), _zoom,
|
_data.at(n)->polys(polyRectD.toRectC(_projection, 4), _zoom,
|
||||||
&polygons, &lines);
|
&polygons, &lines);
|
||||||
ll2xy(polygons); ll2xy(lines);
|
|
||||||
|
|
||||||
QRectF pointRect(QPointF(ttl.x() - TEXT_EXTENT,
|
QRectF pointRect(QPointF(ttl.x() - TEXT_EXTENT,
|
||||||
ttl.y() - TEXT_EXTENT), QPointF(ttl.x() + TILE_SIZE
|
ttl.y() - TEXT_EXTENT), QPointF(ttl.x() + TILE_SIZE
|
||||||
@ -212,9 +182,8 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
_transform.img2proj(pointRect.bottomRight()));
|
_transform.img2proj(pointRect.bottomRight()));
|
||||||
_data.at(n)->points(pointRectD.toRectC(_projection, 4),
|
_data.at(n)->points(pointRectD.toRectC(_projection, 4),
|
||||||
_zoom, &points);
|
_zoom, &points);
|
||||||
ll2xy(points);
|
|
||||||
|
|
||||||
tiles.append(RasterTile(_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)), key, polygons,
|
||||||
lines, points));
|
lines, points));
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,16 @@ public:
|
|||||||
|
|
||||||
QRectF bounds() {return _bounds;}
|
QRectF bounds() {return _bounds;}
|
||||||
|
|
||||||
virtual int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
virtual void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
virtual int zoomFit(const QSize &, const RectC &);
|
int zoomFit(const QSize &, const RectC &);
|
||||||
virtual int zoomIn();
|
int zoomIn();
|
||||||
virtual int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c);
|
QPointF ll2xy(const Coordinates &c)
|
||||||
Coordinates xy2ll(const QPointF &p);
|
{return _transform.proj2img(_projection.ll2xy(c));}
|
||||||
|
Coordinates xy2ll(const QPointF &p)
|
||||||
|
{return _projection.xy2ll(_transform.img2proj(p));}
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||||
|
|
||||||
@ -39,8 +41,6 @@ public:
|
|||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ll2xy(QList<MapData::Poly> &polys);
|
|
||||||
void ll2xy(QList<MapData::Point> &points);
|
|
||||||
Transform transform(int zoom) const;
|
Transform transform(int zoom) const;
|
||||||
void updateTransform();
|
void updateTransform();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user