From 93fc1907482796e4454b981f1acb4627b550960e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 19 May 2025 09:18:32 +0200 Subject: [PATCH] Recommended routes style --- src/map/IMG/rastertile.cpp | 4 +++- src/map/IMG/rgnfile.cpp | 21 +++++++++++++++++++-- src/map/IMG/rgnfile.h | 4 +++- src/map/IMG/style.cpp | 1 + src/map/IMG/style.h | 2 ++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index 55b04082..5432c976 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -193,7 +193,9 @@ static quint32 lineType(quint32 type, quint32 flags) return type | (flags & 0xFF000000) | 1<<20; else return type | (flags & 0xFF000000); - } else if (flags & MapData::Poly::Direction) + } else if (Style::isRecommendedRoute(type)) + return (flags & MapData::Poly::Dashed) ? type | 1<<20 : type; + else if (flags & MapData::Poly::Direction) return type | 1<<20; else return type; diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index 76b58ac7..fa48bb11 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -244,7 +244,7 @@ bool RGNFile::readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl, return true; } -bool RGNFile::readLineInfo(Handle &hdl, quint8 flags, quint32 size, +bool RGNFile::readLineStyle(Handle &hdl, quint8 flags, quint32 size, MapData::Poly *line) const { line->flags |= (flags & 0xf)<<24; @@ -270,6 +270,21 @@ bool RGNFile::readLineInfo(Handle &hdl, quint8 flags, quint32 size, } } +bool RGNFile::readRecommendedRoute(Handle &hdl, quint8 flags, quint32 size, + MapData::Poly *line) const +{ + Q_UNUSED(flags); + quint32 val; + + if (!(size >= 1 && readUInt8(hdl, val))) + return false; + + if (val & 2) + line->flags |= MapData::Poly::Dashed; + + return true; +} + bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType, void *object, LBLFile *lbl, Handle &lblHdl) const { @@ -320,7 +335,9 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType, point->flags |= (flags & 0xf)<<20; if (line && Style::isStyledLine(line->type)) - readLineInfo(hdl, flags, rs, line); + readLineStyle(hdl, flags, rs, line); + if (line && Style::isRecommendedRoute(line->type)) + readRecommendedRoute(hdl, flags, rs, line); return seek(hdl, off + rs); } diff --git a/src/map/IMG/rgnfile.h b/src/map/IMG/rgnfile.h index b6b6b576..5016e098 100644 --- a/src/map/IMG/rgnfile.h +++ b/src/map/IMG/rgnfile.h @@ -69,7 +69,9 @@ private: MapData::Point *point) const; bool readLightInfo(Handle &hdl, quint8 flags, quint32 size, MapData::Point *point) const; - bool readLineInfo(Handle &hdl, quint8 flags, quint32 size, + bool readLineStyle(Handle &hdl, quint8 flags, quint32 size, + MapData::Poly *line) const; + bool readRecommendedRoute(Handle &hdl, quint8 flags, quint32 size, MapData::Poly *line) const; bool readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl, quint8 flags, quint32 size, MapData::Point *point) const; diff --git a/src/map/IMG/style.cpp b/src/map/IMG/style.cpp index 8d01ce84..5b92f5b6 100644 --- a/src/map/IMG/style.cpp +++ b/src/map/IMG/style.cpp @@ -490,6 +490,7 @@ void Style::defaultLineStyle(qreal ratio) _lines[0x10106] = Line(QImage(":/marine/cable-line.png")); _lines[0x10107] = Line(QPen(QColor(0xa5, 0x81, 0x40), 3, Qt::SolidLine)); _lines[0x10108] = Line(QPen(QColor(0, 0, 0), 1, Qt::SolidLine)); + _lines[0x110108] = Line(QPen(QColor(0, 0, 0), 1, Qt::DashLine)); _lines[0x10301] = Line(QPen(QColor(0x0e, 0x10, 0x87), 1, Qt::SolidLine)); _lines[0x10307] = Line(QPen(QColor(0x05, 0x62, 0x0e), 1, Qt::SolidLine)); diff --git a/src/map/IMG/style.h b/src/map/IMG/style.h index 5f4955fc..93ed37bb 100644 --- a/src/map/IMG/style.h +++ b/src/map/IMG/style.h @@ -162,6 +162,8 @@ public: {return type >= 0x10400 && type < 0x10700;} static bool isCartographicLine(quint32 type) {return type == 0x10601;} + static bool isRecommendedRoute(quint32 type) + {return type == 0x10108;} static bool hasColorset(quint32 type) {return (isBuoy(type) && !(type == 0x1020d || type >= 0x10216));}