From 1946c3cc6f0cf14d71e3ba67f9a5330ad37bea94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 8 Nov 2022 00:38:45 +0100 Subject: [PATCH] Image polygon lines --- src/map/ENC/attributes.h | 2 ++ src/map/ENC/mapdata.cpp | 7 ++++++- src/map/ENC/rastertile.cpp | 12 +++++++++--- src/map/ENC/style.cpp | 11 ++++++----- src/map/ENC/style.h | 5 +++++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/map/ENC/attributes.h b/src/map/ENC/attributes.h index 6f388bc5..e5a3e1b6 100644 --- a/src/map/ENC/attributes.h +++ b/src/map/ENC/attributes.h @@ -1,6 +1,7 @@ #ifndef ENC_ATTRIBUTES_H #define ENC_ATTRIBUTES_H +#define CATACH 8 #define CATHAF 30 #define CATLMK 35 #define CATMOR 40 @@ -9,6 +10,7 @@ #define DRVAL1 87 #define ELEVAT 90 #define OBJNAM 116 +#define RESTRN 131 #define VALDCO 174 #endif // ENC_ATTRIBUTES_H diff --git a/src/map/ENC/mapdata.cpp b/src/map/ENC/mapdata.cpp index 858126de..5dbacd54 100644 --- a/src/map/ENC/mapdata.cpp +++ b/src/map/ENC/mapdata.cpp @@ -419,8 +419,13 @@ MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL) if (OBJL == DEPARE && key == DRVAL1) subtype = depthLevel(av.at(1).toString()); - else if (OBJL == RESARE && key == CATREA) + else if ((OBJL == RESARE && key == CATREA) + || (OBJL == ACHARE && key == CATACH)) subtype = av.at(1).toString().toUInt(); + else if (OBJL == RESARE && key == RESTRN) { + if (av.at(1).toString().toUInt() == 1) + subtype = 2; + } } return Attr(subtype, label); diff --git a/src/map/ENC/rastertile.cpp b/src/map/ENC/rastertile.cpp index fc04d942..df8ae219 100644 --- a/src/map/ENC/rastertile.cpp +++ b/src/map/ENC/rastertile.cpp @@ -88,9 +88,15 @@ void RasterTile::drawPolygons(QPainter *painter) continue; const Style::Polygon &style = s.polygon(ECDIS(poly->type())); - painter->setPen(style.pen()); - painter->setBrush(style.brush()); - painter->drawPath(painterPath(poly->path())); + if (!style.img().isNull()) { + for (int i = 0; i < poly->path().size(); i++) + BitmapLine::draw(painter, polyline(poly->path().at(i)), + style.img()); + } else { + painter->setPen(style.pen()); + painter->setBrush(style.brush()); + painter->drawPath(painterPath(poly->path())); + } } } } diff --git a/src/map/ENC/style.cpp b/src/map/ENC/style.cpp index 6910fa6f..d9d0ae67 100644 --- a/src/map/ENC/style.cpp +++ b/src/map/ENC/style.cpp @@ -38,8 +38,6 @@ void Style::defaultPolygonStyle() _polygons[TYPE(PONTON)] = Polygon(QBrush("#333333")); _polygons[TYPE(SLCONS)] = Polygon(Qt::NoBrush, QPen(QColor("#333333"), 1.5, Qt::DashLine)); - _polygons[TYPE(ACHARE)] = Polygon(Qt::NoBrush, QPen(QColor("#e728e7"), 1, - Qt::DashDotLine)); _polygons[TYPE(LAKARE)] = Polygon(QBrush("#9fc4e1"), QPen(QColor("#000000"), 1)); _polygons[TYPE(CANALS)] = Polygon(QBrush("#9fc4e1"), @@ -48,12 +46,15 @@ void Style::defaultPolygonStyle() _polygons[TYPE(DYKCON)] = Polygon(QBrush(QColor("#9fc4e1"), Qt::Dense4Pattern), QPen(QColor("#000000"), 1)); _polygons[TYPE(AIRARE)] = Polygon(QBrush("#333333")); - _polygons[SUBTYPE(RESARE, 9)] = Polygon(QBrush(QColor("#ff0000"), - Qt::BDiagPattern), QPen(QColor("#ff0000"), 1)); _polygons[TYPE(TSEZNE)] = Polygon(QBrush("#80fcb4fc")); _polygons[TYPE(DRGARE)] = Polygon(QBrush(QColor("#a0a0ff"), Qt::Dense4Pattern)); _polygons[TYPE(UNSARE)] = Polygon(QBrush("#999999")); + _polygons[SUBTYPE(RESARE, 9)] = Polygon(QBrush(QColor("#ff0000"), + Qt::BDiagPattern)); + + _polygons[SUBTYPE(RESARE, 2)] = Polygon(QImage(":/marine/noanchor-line.png")); + _polygons[SUBTYPE(ACHARE, 1)] = Polygon(QImage(":/marine/anchor-line.png")); _drawOrder << TYPE(M_COVR) << TYPE(LNDARE) << SUBTYPE(DEPARE, 0) @@ -63,7 +64,7 @@ void Style::defaultPolygonStyle() << TYPE(RIVERS) << TYPE(DRGARE) << TYPE(FAIRWY) << TYPE(BUAARE) << TYPE(BUISGL) << TYPE(AIRARE) << TYPE(BRIDGE) << TYPE(SLCONS) << TYPE(PONTON) << TYPE(DMPGRD) << TYPE(TSEZNE) << TYPE(OBSTRN) - << TYPE(ACHARE) << SUBTYPE(RESARE, 9) << TYPE(154); + << SUBTYPE(ACHARE, 1) << SUBTYPE(RESARE, 9) << SUBTYPE(RESARE, 2); } void Style::defaultLineStyle() diff --git a/src/map/ENC/style.h b/src/map/ENC/style.h index 41538d8f..87337a43 100644 --- a/src/map/ENC/style.h +++ b/src/map/ENC/style.h @@ -29,13 +29,18 @@ public: { _pen = (pen == Qt::NoPen) ? QPen(_brush, 0) : pen; } + Polygon(const QImage &img) + : _brush(Qt::NoBrush), _pen(Qt::NoPen), _img(img.convertToFormat( + QImage::Format_ARGB32_Premultiplied)) {} const QPen &pen() const {return _pen;} const QBrush &brush() const {return _brush;} + const QImage &img() const {return _img;} private: QBrush _brush; QPen _pen; + QImage _img; }; class Line {