1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-04-20 12:19:11 +02:00

Compare commits

..

No commits in common. "db6e891c30e3fe4d96e6a10400d1e7a273c7731c" and "3804e8ca7c8f9e2f1e356b0a1f4d7c782063fb43" have entirely different histories.

5 changed files with 40 additions and 96 deletions

View File

@ -3,7 +3,6 @@
#define CATACH 8 #define CATACH 8
#define CATBUA 10 #define CATBUA 10
#define CATCOV 18
#define CATDIS 21 #define CATDIS 21
#define CATHAF 30 #define CATHAF 30
#define CATLMK 35 #define CATLMK 35

View File

@ -425,8 +425,6 @@ MapData::Poly::Poly(uint type, const Polygon &path, const Attributes &attr,
subtype = CATMFA; subtype = CATMFA;
else if (type == I_BERTHS) else if (type == I_BERTHS)
subtype = I_CATBRT; subtype = I_CATBRT;
else if (type == M_COVR)
subtype = CATCOV;
switch (type) { switch (type) {
case DEPARE: case DEPARE:

View File

@ -169,13 +169,8 @@ void RasterTile::drawPolygons(QPainter *painter,
} else { } else {
if (style.brush() != Qt::NoBrush) { if (style.brush() != Qt::NoBrush) {
painter->setPen(Qt::NoPen); painter->setPen(Qt::NoPen);
QPainterPath path(painterPath(poly.path()));
if (poly.type() == TYPE(DRGARE)) {
painter->setBrush(Qt::white);
painter->drawPath(path);
}
painter->setBrush(style.brush()); painter->setBrush(style.brush());
painter->drawPath(path); painter->drawPath(painterPath(poly.path()));
} }
if (style.pen() != Qt::NoPen) { if (style.pen() != Qt::NoPen) {
painter->setPen(style.pen()); painter->setPen(style.pen());
@ -262,15 +257,17 @@ void RasterTile::drawSectorLights(QPainter *painter,
} }
} }
void RasterTile::processPoints(const QList<Data::Point> &points, void RasterTile::processPoints(QList<Data::Point> &points,
QList<TextItem*> &textItems, QList<TextItem*> &lights, QList<TextItem*> &textItems, QList<TextItem*> &lights,
QList<SectorLight> &sectorLights, bool overZoom) const QList<SectorLight> &sectorLights, bool overZoom)
{ {
LightMap lightsMap; LightMap lightsMap;
SignalSet signalsSet; SignalSet signalsSet;
QSet<Coordinates> slMap; QSet<Coordinates> slMap;
int i; int i;
std::sort(points.begin(), points.end());
/* Lights & Signals */ /* Lights & Signals */
for (i = 0; i < points.size(); i++) { for (i = 0; i < points.size(); i++) {
const Data::Point &point = points.at(i); const Data::Point &point = points.at(i);
@ -331,7 +328,7 @@ void RasterTile::processPoints(const QList<Data::Point> &points,
} }
void RasterTile::processLines(const QList<Data::Line> &lines, void RasterTile::processLines(const QList<Data::Line> &lines,
QList<TextItem*> &textItems) const QList<TextItem*> &textItems)
{ {
for (int i = 0; i < lines.size(); i++) { for (int i = 0; i < lines.size(); i++) {
const Data::Line &line = lines.at(i); const Data::Line &line = lines.at(i);
@ -354,45 +351,19 @@ void RasterTile::processLines(const QList<Data::Line> &lines,
} }
} }
void RasterTile::drawLevels(QPainter *painter, const QList<Level> &levels) void RasterTile::render()
{ {
for (int i = levels.size() - 1; i >= 0; i--) { QImage img(_rect.width() * _ratio, _rect.height() * _ratio,
QList<TextItem*> textItems, lights; QImage::Format_ARGB32_Premultiplied);
QList<SectorLight> sectorLights;
const Level &l = levels.at(i);
processPoints(l.points, textItems, lights, sectorLights, l.overZoom); img.setDevicePixelRatio(_ratio);
processLines(l.lines, textItems); img.fill(Qt::transparent);
drawPolygons(painter, l.polygons); QPainter painter(&img);
drawLines(painter, l.lines); painter.setRenderHint(QPainter::SmoothPixmapTransform);
drawArrows(painter, l.points); painter.setRenderHint(QPainter::Antialiasing);
painter.translate(-_rect.x(), -_rect.y());
drawTextItems(painter, lights);
drawSectorLights(painter, sectorLights);
drawTextItems(painter, textItems);
qDeleteAll(textItems);
qDeleteAll(lights);
}
}
QPainterPath RasterTile::shape(const QList<Data::Poly> &polygons) const
{
QPainterPath shp;
for (int i = 0; i < polygons.size(); i++) {
const Data::Poly &p = polygons.at(i);
if (p.type() == SUBTYPE(M_COVR, 1))
shp.addPath(painterPath(p.path()));
}
return shp;
}
QList<RasterTile::Level> RasterTile::fetchLevels()
{
QList<RasterTile::Level> list;
QPoint ttl(_rect.topLeft()); QPoint ttl(_rect.topLeft());
QRectF polyRect(ttl, QPointF(ttl.x() + _rect.width(), ttl.y() QRectF polyRect(ttl, QPointF(ttl.x() + _rect.width(), ttl.y()
+ _rect.height())); + _rect.height()));
@ -407,41 +378,31 @@ QList<RasterTile::Level> RasterTile::fetchLevels()
RectC pointRectC(pointRectD.toRectC(_proj, 20)); RectC pointRectC(pointRectD.toRectC(_proj, 20));
for (int i = 0; i < _data.size(); i++) { for (int i = 0; i < _data.size(); i++) {
Level level; QList<Data::Line> lines;
QList<Data::Poly> polygons;
QList<Data::Point> points;
QList<TextItem*> textItems, lights;
QList<SectorLight> sectorLights;
_data.at(i)->polys(polyRectC, &level.polygons, &level.lines); _data.at(i)->polys(polyRectC, &polygons, &lines);
_data.at(i)->points(pointRectC, &level.points); _data.at(i)->points(pointRectC, &points);
level.overZoom = i > 0;
std::sort(level.points.begin(), level.points.end()); processPoints(points, textItems, lights, sectorLights,
_data.size() > 1 && i == 0);
processLines(lines, textItems);
if (!level.isNull()) drawPolygons(&painter, polygons);
list.append(level); drawLines(&painter, lines);
drawArrows(&painter, points);
if (_data.size() > 0 && shape(level.polygons).contains(_rect)) drawTextItems(&painter, lights);
break; drawSectorLights(&painter, sectorLights);
drawTextItems(&painter, textItems);
qDeleteAll(textItems);
qDeleteAll(lights);
} }
return list;
}
void RasterTile::render()
{
QList<Level> levels(fetchLevels());
QImage img(_rect.width() * _ratio, _rect.height() * _ratio,
QImage::Format_ARGB32_Premultiplied);
img.setDevicePixelRatio(_ratio);
img.fill(Qt::transparent);
QPainter painter(&img);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.setRenderHint(QPainter::Antialiasing);
painter.translate(-_rect.x(), -_rect.y());
drawLevels(&painter, levels);
//painter.setPen(Qt::red); //painter.setPen(Qt::red);
//painter.setBrush(Qt::NoBrush); //painter.setBrush(Qt::NoBrush);
//painter.setRenderHint(QPainter::Antialiasing, false); //painter.setRenderHint(QPainter::Antialiasing, false);

View File

@ -51,16 +51,6 @@ private:
double end; double end;
}; };
struct Level {
QList<Data::Line> lines;
QList<Data::Poly> polygons;
QList<Data::Point> points;
bool overZoom;
bool isNull() const
{return lines.isEmpty() && polygons.isEmpty() && points.isEmpty();}
};
typedef QMap<Coordinates, Style::Color> LightMap; typedef QMap<Coordinates, Style::Color> LightMap;
typedef QSet<Coordinates> SignalSet; typedef QSet<Coordinates> SignalSet;
@ -71,20 +61,16 @@ private:
QVector<QPolygonF> polylineM(const QVector<Coordinates> &path) const; QVector<QPolygonF> polylineM(const QVector<Coordinates> &path) const;
QPolygonF tsslptArrow(const QPointF &p, qreal angle) const; QPolygonF tsslptArrow(const QPointF &p, qreal angle) const;
QPointF centroid(const QVector<Coordinates> &polygon) const; QPointF centroid(const QVector<Coordinates> &polygon) const;
void processPoints(const QList<Data::Point> &points, void processPoints(QList<Data::Point> &points,
QList<TextItem*> &textItems, QList<TextItem *> &lights, QList<TextItem*> &textItems, QList<TextItem *> &lights,
QList<SectorLight> &sectorLights, bool overZoom) const; QList<SectorLight> &sectorLights, bool overZoom);
void processLines(const QList<Data::Line> &lines, void processLines(const QList<Data::Line> &lines, QList<TextItem*> &textItems);
QList<TextItem*> &textItems) const;
void drawArrows(QPainter *painter, const QList<Data::Point> &points) const; void drawArrows(QPainter *painter, const QList<Data::Point> &points) const;
void drawPolygons(QPainter *painter, const QList<Data::Poly> &polygons) const; void drawPolygons(QPainter *painter, const QList<Data::Poly> &polygons) const;
void drawLines(QPainter *painter, const QList<Data::Line> &lines) const; void drawLines(QPainter *painter, const QList<Data::Line> &lines) const;
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const; void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const; void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const;
bool showLabel(const QImage *img, int type) const; bool showLabel(const QImage *img, int type) const;
void drawLevels(QPainter *painter, const QList<Level> &levels);
QList<Level> fetchLevels();
QPainterPath shape(const QList<Data::Poly> &polygons) const;
Projection _proj; Projection _proj;
Transform _transform; Transform _transform;

View File

@ -350,9 +350,9 @@ QList<Data*> ENCAtlas::levels() const
QList<Data*> list; QList<Data*> list;
QMap<IntendedUsage, ENC::AtlasData*>::const_iterator it = _data.find(_usage); QMap<IntendedUsage, ENC::AtlasData*>::const_iterator it = _data.find(_usage);
do {
list.append(it.value()); list.append(it.value());
} while (it-- != _data.cbegin()); if (it != _data.cbegin())
list.prepend((--it).value());
return list; return list;
} }