1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Render lights merged with the root objects, not as separate objects

This commit is contained in:
Martin Tůma 2023-03-22 00:41:03 +01:00
parent 048198dfe1
commit 416bd3472f
6 changed files with 72 additions and 33 deletions

View File

@ -194,6 +194,7 @@
<file alias="breakers.png">icons/map/marine/breakers.png</file> <file alias="breakers.png">icons/map/marine/breakers.png</file>
<file alias="overfalls.png">icons/map/marine/overfalls.png</file> <file alias="overfalls.png">icons/map/marine/overfalls.png</file>
<file alias="boarding-place.png">icons/map/marine/boarding-place.png</file> <file alias="boarding-place.png">icons/map/marine/boarding-place.png</file>
<file alias="light.png">icons/map/marine/light.png</file>
</qresource> </qresource>
<!-- Mapsforge rendertheme --> <!-- Mapsforge rendertheme -->

BIN
icons/map/marine/light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

View File

@ -38,6 +38,15 @@ inline bool operator==(const Coordinates &c1, const Coordinates &c2)
{return (c1.lat() == c2.lat() && c1.lon() == c2.lon());} {return (c1.lat() == c2.lat() && c1.lon() == c2.lon());}
inline bool operator!=(const Coordinates &c1, const Coordinates &c2) inline bool operator!=(const Coordinates &c1, const Coordinates &c2)
{return !(c1 == c2);} {return !(c1 == c2);}
inline bool operator<(const Coordinates &c1, const Coordinates &c2)
{
if (c1.lon() < c2.lon())
return true;
else if (c1.lon() > c2.lon())
return false;
else
return (c1.lat() < c2.lat());
}
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
QDebug operator<<(QDebug dbg, const Coordinates &c); QDebug operator<<(QDebug dbg, const Coordinates &c);

View File

@ -19,32 +19,33 @@ static QMap<uint,uint> orderMapInit()
{ {
QMap<uint,uint> map; QMap<uint,uint> map;
map.insert(TYPE(CGUSTA), 0); map.insert(TYPE(LIGHTS), 0);
map.insert(SUBTYPE(BUAARE, 1), 1);
map.insert(SUBTYPE(BUAARE, 5), 2); map.insert(TYPE(CGUSTA), 1);
map.insert(SUBTYPE(BUAARE, 4), 3); map.insert(SUBTYPE(BUAARE, 1), 2);
map.insert(SUBTYPE(BUAARE, 3), 4); map.insert(SUBTYPE(BUAARE, 5), 3);
map.insert(SUBTYPE(BUAARE, 2), 5); map.insert(SUBTYPE(BUAARE, 4), 4);
map.insert(SUBTYPE(BUAARE, 6), 6); map.insert(SUBTYPE(BUAARE, 3), 5);
map.insert(SUBTYPE(BUAARE, 0), 7); map.insert(SUBTYPE(BUAARE, 2), 6);
map.insert(TYPE(RDOSTA), 8); map.insert(SUBTYPE(BUAARE, 6), 7);
map.insert(TYPE(RADSTA), 9); map.insert(SUBTYPE(BUAARE, 0), 8);
map.insert(TYPE(RTPBCN), 10); map.insert(TYPE(RDOSTA), 9);
map.insert(TYPE(BCNISD), 11); map.insert(TYPE(RADSTA), 10);
map.insert(TYPE(BCNLAT), 12); map.insert(TYPE(RTPBCN), 11);
map.insert(TYPE(I_BCNLAT), 12); map.insert(TYPE(BCNISD), 12);
map.insert(TYPE(BCNSAW), 13); map.insert(TYPE(BCNLAT), 13);
map.insert(TYPE(BCNSPP), 14); map.insert(TYPE(I_BCNLAT), 13);
map.insert(TYPE(BOYCAR), 15); map.insert(TYPE(BCNSAW), 14);
map.insert(TYPE(BOYINB), 16); map.insert(TYPE(BCNSPP), 15);
map.insert(TYPE(BOYISD), 17); map.insert(TYPE(BOYCAR), 16);
map.insert(TYPE(BOYLAT), 18); map.insert(TYPE(BOYINB), 17);
map.insert(TYPE(I_BOYLAT), 18); map.insert(TYPE(BOYISD), 18);
map.insert(TYPE(BOYSAW), 19); map.insert(TYPE(BOYLAT), 19);
map.insert(TYPE(BOYSPP), 20); map.insert(TYPE(I_BOYLAT), 19);
map.insert(TYPE(MORFAC), 21); map.insert(TYPE(BOYSAW), 20);
map.insert(TYPE(OFSPLF), 22); map.insert(TYPE(BOYSPP), 21);
map.insert(TYPE(LIGHTS), 23); map.insert(TYPE(MORFAC), 22);
map.insert(TYPE(OFSPLF), 23);
map.insert(TYPE(OBSTRN), 24); map.insert(TYPE(OBSTRN), 24);
map.insert(TYPE(WRECKS), 25); map.insert(TYPE(WRECKS), 25);
map.insert(TYPE(UWTROC), 26); map.insert(TYPE(UWTROC), 26);

View File

@ -13,6 +13,8 @@ using namespace ENC;
#define TSSLPT_SIZE 0.005 /* ll */ #define TSSLPT_SIZE 0.005 /* ll */
#define RDOCAL_SIZE 12 /* px */ #define RDOCAL_SIZE 12 /* px */
typedef QMap<Coordinates, const MapData::Point*> PointMap;
const float C1 = 0.866025f; /* sqrt(3)/2 */ const float C1 = 0.866025f; /* sqrt(3)/2 */
static const QColor haloColor(Qt::white); static const QColor haloColor(Qt::white);
@ -49,6 +51,12 @@ static QFont *font(Style::FontSize size)
} }
} }
static const QImage *light()
{
static QImage img(":/marine/light.png");
return &img;
}
static const Style& style() static const Style& style()
{ {
static Style s; static Style s;
@ -266,13 +274,25 @@ void RasterTile::processPolygons(QList<TextItem*> &textItems)
} }
void RasterTile::processPoints(QList<TextItem*> &textItems, void RasterTile::processPoints(QList<TextItem*> &textItems,
QList<QImage*> &images) QList<TextItem*> &lights, QList<QImage*> &images)
{ {
const Style &s = style(); const Style &s = style();
PointMap lightsMap;
int i;
std::sort(_points.begin(), _points.end(), pointLess); std::sort(_points.begin(), _points.end(), pointLess);
for (int i = 0; i < _points.size(); i++) { /* Lights */
for (i = 0; i < _points.size(); i++) {
const MapData::Point *point = _points.at(i);
if (point->type()>>16 == LIGHTS)
lightsMap.insert(point->pos(), point);
else
break;
}
/* Everything else */
for ( ; i < _points.size(); i++) {
const MapData::Point *point = _points.at(i); const MapData::Point *point = _points.at(i);
const Style::Point &style = s.point(point->type()); const Style::Point &style = s.point(point->type());
@ -288,12 +308,17 @@ void RasterTile::processPoints(QList<TextItem*> &textItems,
if ((!label || !fnt) && !img) if ((!label || !fnt) && !img)
continue; continue;
TextPointItem *item = new TextPointItem(ll2xy(point->pos()).toPoint(), QPoint pos(ll2xy(point->pos()).toPoint());
label, fnt, img, color, hColor, 0, ICON_PADDING); TextPointItem *item = new TextPointItem(pos, label, fnt, img, color,
hColor, 0, ICON_PADDING);
if (item->isValid() && !item->collides(textItems)) { if (item->isValid() && !item->collides(textItems)) {
textItems.append(item); textItems.append(item);
if (rimg) if (rimg)
images.append(rimg); images.append(rimg);
const PointMap::const_iterator it = lightsMap.find(point->pos());
if (it != lightsMap.constEnd())
lights.append(new TextPointItem(pos, 0, 0, light(), 0, 0, 0,
ICON_PADDING));
} else { } else {
delete item; delete item;
delete rimg; delete rimg;
@ -328,14 +353,14 @@ void RasterTile::processLines(QList<TextItem*> &textItems)
void RasterTile::render() void RasterTile::render()
{ {
QList<TextItem*> textItems; QList<TextItem*> textItems, lights;
QList<QImage*> images; QList<QImage*> images;
_pixmap.setDevicePixelRatio(_ratio); _pixmap.setDevicePixelRatio(_ratio);
_pixmap.fill(Qt::transparent); _pixmap.fill(Qt::transparent);
processPolygons(textItems); processPolygons(textItems);
processPoints(textItems, images); processPoints(textItems, lights, images);
processLines(textItems); processLines(textItems);
QPainter painter(&_pixmap); QPainter painter(&_pixmap);
@ -347,9 +372,11 @@ void RasterTile::render()
drawLines(&painter); drawLines(&painter);
drawArrows(&painter); drawArrows(&painter);
drawTextItems(&painter, lights);
drawTextItems(&painter, textItems); drawTextItems(&painter, textItems);
qDeleteAll(textItems); qDeleteAll(textItems);
qDeleteAll(lights);
qDeleteAll(images); qDeleteAll(images);
//painter.setPen(Qt::red); //painter.setPen(Qt::red);

View File

@ -33,7 +33,8 @@ private:
QPainterPath painterPath(const Polygon &polygon) const; QPainterPath painterPath(const Polygon &polygon) const;
QPolygonF polyline(const QVector<Coordinates> &path) const; QPolygonF polyline(const QVector<Coordinates> &path) const;
QPolygonF tsslptArrow(const Coordinates &c, qreal angle) const; QPolygonF tsslptArrow(const Coordinates &c, qreal angle) const;
void processPoints(QList<TextItem*> &textItems, QList<QImage*> &images); void processPoints(QList<TextItem*> &textItems, QList<TextItem *> &lights,
QList<QImage*> &images);
void processLines(QList<TextItem*> &textItems); void processLines(QList<TextItem*> &textItems);
void processPolygons(QList<TextItem*> &textItems); void processPolygons(QList<TextItem*> &textItems);
void drawBitmapPath(QPainter *painter, const QImage &img, void drawBitmapPath(QPainter *painter, const QImage &img,