From d412390c75e30982b11d295df3f0e6d5d590fce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 15 Sep 2024 19:42:53 +0200 Subject: [PATCH] Added basic support for marine lights to IMG maps --- gpxsee.qrc | 1 - icons/map/marine/light-major.png | Bin 4664 -> 226 bytes icons/map/marine/light-platform.png | Bin 4573 -> 0 bytes src/map/IMG/mapdata.h | 12 ++++++++--- src/map/IMG/rastertile.cpp | 29 ++++++++++++++----------- src/map/IMG/rgnfile.cpp | 32 +++++++++++++++++++++++++--- src/map/IMG/rgnfile.h | 1 + src/map/IMG/style.cpp | 28 +++++++++++++----------- src/map/IMG/style.h | 10 +++++++++ 9 files changed, 81 insertions(+), 32 deletions(-) delete mode 100644 icons/map/marine/light-platform.png diff --git a/gpxsee.qrc b/gpxsee.qrc index 5f11af62..71746621 100644 --- a/gpxsee.qrc +++ b/gpxsee.qrc @@ -99,7 +99,6 @@ icons/map/marine/light-major.png - icons/map/marine/light-platform.png icons/map/marine/buoy.png icons/map/marine/beacon.png icons/map/marine/rock-exposed.png diff --git a/icons/map/marine/light-major.png b/icons/map/marine/light-major.png index 34c4d331114a7ade649f3118cfe016abc5beffaf..dc745f84c43defb23d52a864f11560c5cd7f3b14 100644 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^{2+rR+`kF1T^jjL*q_Tfg@2lX{(-kM$ST%ly9JsZ<_5PuW ze{a7PEZm=df3Y;n^==vQ$*yx#4NJFFmkS^BdBasC+_u+HWi7|Qe@fr~G3h-@dv9GR RvjFHC22WQ%mvv4FO#n=2RE_`u literal 4664 zcmeHKdsGuw8V{(*Mky|0rHY!yM|n7z2YHSJgajmNAPTIgwK~a6V3cHHGLXP26_rM7 zIkN4s;sYz#-Ii4zeb_GG`arR4Pb+IhP`6cHZMA^-D5qL0cJB=DZqM1{Iotn8&YkG)5r;JOs}cyrmq%+f2AxJDve_9kolXe^uA-bb)N$t)2e@0_-T2p}z;03dpG#`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HD z00@H+IfNp=CJY`}FwE7A!4-$Y|HVl-uP~y>0K5J%P`p4bgoldZ0B2m;`5iw4d+|GZ z0MKJjo{HZwy2j{wDh8fPc`Uoe=z1y!o=SNvyZ&!<35Ty!lok97a)Qg!i^;3Gi@cX{ z*%B>(gDs_*S?t-xzEF$sGPaCIC~m{cH2(+VcUIM zWepisJ?(KlA67mPoI4alr_swsH)*0D!;MT6~H z-I|ieFUj1KThBerf5)dWvhj&kT7IGAF)`_(s(I441)sc1L^a)P{PO6J4T`T9?tyEX zeV-Nh-YfGn`OZ`}PW(sOHO3^%VLD<+V$15>zzqTU%L+Yrzw=CeZtv-X-CI8WF=kmr z)9t2?&HtgF;}91N&FlX&;4W3H*fr!sQkx><)-uwBQVJ=U5ZeWDHh)WDRn kr&D+Ah^S0C{8L~4mfC%_S$Q2)Czlesn0ReP^oDK!0l}q$)Bpeg diff --git a/icons/map/marine/light-platform.png b/icons/map/marine/light-platform.png deleted file mode 100644 index 30409846500f82b1ee18da9a72a12e5f4d6a746f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4573 zcmeHKeNYrf7GFN))~KA40zZhu0wqFbcV<6^-8mM81!2)eghdFs#56OrFv#vKy92v$ zhazy~ypY6PNU6jVHKLYLLdukvGbIMauOiWudSwz1Q7We#ph9WTGXbw>_`am-imJ3;9muYd3L+wHAssY!FBi=+~XWR5X8AszNhVMF|U;df8v2XV0bipe%wjK)Zb zAAEtD9^MiUC<%HVqcQ?zPY*AN7wl_bn-66{M`(*Ye8j#M%8N(kIw(hs>IgQtho@u? z?03PYgmM7v55va3KC)H|l!eDn{5*luEZD~SB%>(}QOa>luF^t#OsOU@g2XWdSCSeP ziQ#a4k3AC}2}mt*6HWbQ z9{cqV$uAxIv3Gb$dBM%xl`F$`Gd1i2&VMcUt?%9Pu863MkpsGcPmO_Lo4z~IHL&>Z zzIM;cwe>q6#T3t;X>IF$IY%InFU9R*AAafes#l3cgUk4 z?BhR%C;RW+Q=^P*{`J9EmYt2SzqBBBIOMwGoz)>(3u~9mJ``Wo_q6rdEf;t6^mo>6Q6XpIbwc($TUNvCrFdYOnzLRlDA z$PiJ5->8>m!#px@4hB)n)p86?bh9N&S*#R^anKerJz>=-1boxW@_F7)Diki4OYTz1 zIY*uX*XeW$OsP;RQK*4BOKm)Gqc&%#05O7*z&I%fYv)GfP&z17UD1(f*>@2Kyz^zO|>=}pjs`ZLZdODg(Et^XmTe( ztaY$3D?#C8uLLL>LaBfS;9BSirKSl~4Hzv7XdQ;CaUEe%S(J=U2Sg~EB3E$^D}do- ztssw4*ll^@gg`hMmuA$ zTCLXL6H4nDhZAO^fGO5aaYhIW2{!|Y1wx)e0C61dg)}%Az;g~W#}(>j<5hQj+60di z4S0|Mcm{%w*J1Nm9gf13BsSu{0B7Q8)>8Vvw1vZi#6W!*@?_Qt*Dn=^Mov@)Q#A56 z@>M+rg1LqP&+WD8DE!qB3h5Nl+L$_KVQ23C*JbR8RKevp5iYQ5+Md^`BZIJJ|jc{5{6;~ zievvxm|}Fp3ZZ6&N61)UqX+^v!3%#I85_w)0(xNU!Pv+-O13!VOHbn}AQ#`FUz)aOf|Rc@~M`arT@ zNZhrczFaGy{IcEbaqa29{O+&6S=?kl%-k*S%xk$Edn~T1_x(4QxvNUOf8SPCH#b00 zKmXOwUpP1X&C{xb>z)QIn*YLi{Qh8s?rdMO;TFgF*ZklPTC`{PnXFGzQX2m7#pw^8 z)Fy>Dp2FX|G5F8eYJjF}4+;HVz3H`m`}wGp)!W|v(Xh2Ye7)4w9U3r{eyZ)^;*`PW zfW~8&wue;pho#yNwhtx_l)FxRe+Suo-QW&vUq?Rpdr(383VGA|ypl}-Px*lv3e{A< z{Pq1EMQ;YjbSHhwu7h!Ka9v$3#JM`Jo+dapJJ% &points, for (int i = 0; i < points.size(); i++) { const MapData::Point &point = points.at(i); - const Style::Point &style = _data->style()->point(point.type); + const Style *style = _data->style(); + const Style::Point &ps = style->point(point.type); bool poi = Style::isPOI(point.type); const QString *label = point.label.text().isEmpty() ? 0 : &(point.label.text()); - const QImage *img = style.img().isNull() ? 0 : &style.img(); + const QImage *img = ps.img().isNull() ? 0 : &ps.img(); const QFont *fnt = poi - ? poiFont(style.text().size(), _zoom, point.classLabel) - : _data->style()->font(style.text().size()); - const QColor *color = style.text().color().isValid() - ? &style.text().color() : &textColor; + ? poiFont(ps.text().size(), _zoom, point.flags + & MapData::Point::ClassLabel) + : style->font(ps.text().size()); + const QColor *color = ps.text().color().isValid() + ? &ps.text().color() : &textColor; const QColor *hcolor = Style::isDepthPoint(point.type) ? 0 : &haloColor; if ((!label || !fnt) && !img) continue; - QPoint offset = img ? style.offset() : QPoint(0, 0); + QPoint pos(point.coordinates.lon(), point.coordinates.lat()); + QPoint offset = img ? ps.offset() : QPoint(0, 0); - TextPointItem *item = new TextPointItem(QPoint(point.coordinates.lon(), - point.coordinates.lat()) + offset, label, fnt, img, color, hcolor, 0, - ICON_PADDING); - if (item->isValid() && !item->collides(textItems)) + TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img, + color, hcolor, 0, ICON_PADDING); + if (item->isValid() && !item->collides(textItems)) { textItems.append(item); - else + if (point.flags & MapData::Point::Light) + textItems.append(new TextPointItem(pos + style->lightOffset(), + 0, 0, style->light(), 0, 0, 0, 0)); + } else delete item; } } diff --git a/src/map/IMG/rgnfile.cpp b/src/map/IMG/rgnfile.cpp index 0de976ba..88acd51d 100644 --- a/src/map/IMG/rgnfile.cpp +++ b/src/map/IMG/rgnfile.cpp @@ -107,6 +107,27 @@ bool RGNFile::readObstructionInfo(Handle &hdl, quint8 flags, quint32 size, return true; } +bool RGNFile::readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) const +{ + quint16 val; + quint8 lc; + + if ((flags & 0xe0) != 0xe0) + return true; + + if (!readUInt16(hdl, val)) + return false; + + lc = (val >> 10) & 0x0f; + if (!lc) + lc = (val >> 6) & 7; + + if (lc) + point->flags |= MapData::Point::Light; + + return true; +} + bool RGNFile::readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl, quint8 flags, quint32 size, MapData::Point *point) const { @@ -116,7 +137,7 @@ bool RGNFile::readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl, return false; point->label = lbl->label(lblHdl, this, hdl, size); - point->classLabel = true; + point->flags |= MapData::Point::ClassLabel; return true; } @@ -154,12 +175,17 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType, if (poly && Style::isRaster(poly->type)) readRasterInfo(hdl, lbl, rs, poly); + if (point && !Style::isMarinePoint(point->type)) + readLabel(hdl, lbl, lblHdl, flags, rs, point); + if (point && Style::isDepthPoint(point->type)) readDepthInfo(hdl, flags, rs, point); if (point && Style::isObstructionPoint(point->type)) readObstructionInfo(hdl, flags, rs, point); - if (point && !Style::isMarinePoint(point->type)) - readLabel(hdl, lbl, lblHdl, flags, rs, point); + if (point && Style::isBuoy(point->type)) + readBuoyInfo(hdl, flags, point); + if (point && Style::isLight(point->type)) + point->flags |= MapData::Point::Light; return seek(hdl, off + rs); } diff --git a/src/map/IMG/rgnfile.h b/src/map/IMG/rgnfile.h index 528e94a0..7b574e93 100644 --- a/src/map/IMG/rgnfile.h +++ b/src/map/IMG/rgnfile.h @@ -64,6 +64,7 @@ private: MapData::Point *point) const; bool readObstructionInfo(Handle &hdl, quint8 flags, quint32 size, MapData::Point *point) const; + bool readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) 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 82a27d9c..e0ddc97b 100644 --- a/src/map/IMG/style.cpp +++ b/src/map/IMG/style.cpp @@ -675,17 +675,17 @@ void Style::defaultPointStyle(qreal ratio) _points[0x11108] = _points[0x3008]; // Marine stuff - _points[0x10100] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10101] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10102] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10103] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10104] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10105] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10106] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10107] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10108] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x10109] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); - _points[0x1010a] = Point(QImage(":/marine/light-major.png"), QPoint(8, -8)); + _points[0x10100] = Point(QImage(":/marine/light-major.png")); + _points[0x10101] = Point(QImage(":/marine/light-major.png")); + _points[0x10102] = Point(QImage(":/marine/light-major.png")); + _points[0x10103] = Point(QImage(":/marine/light-major.png")); + _points[0x10104] = Point(QImage(":/marine/light-major.png")); + _points[0x10105] = Point(QImage(":/marine/light-major.png")); + _points[0x10106] = Point(QImage(":/marine/light-major.png")); + _points[0x10107] = Point(QImage(":/marine/light-major.png")); + _points[0x10108] = Point(QImage(":/marine/light-major.png")); + _points[0x10109] = Point(QImage(":/marine/light-major.png")); + _points[0x1010a] = Point(QImage(":/marine/light-major.png")); _points[0x10200] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6)); _points[0x10201] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6)); _points[0x10202] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6)); @@ -699,8 +699,7 @@ void Style::defaultPointStyle(qreal ratio) _points[0x1020a] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6)); _points[0x1020b] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6)); _points[0x1020c] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6)); - _points[0x1020d] = Point(QImage(":/marine/light-platform.png"), - QPoint(8, -8)); + _points[0x1020d] = Point(QImage(":/marine/platform.png")); _points[0x1020e] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8)); _points[0x1020f] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8)); _points[0x10210] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8)); @@ -1278,6 +1277,9 @@ Style::Style(qreal ratio, SubFile *typ) _small = pixelSizeFont(12); _extraSmall = pixelSizeFont(10); + _light = QImage(":/marine/light.png"); + _lightOffset = QPoint(11, 11); + defaultLineStyle(ratio); defaultPolygonStyle(); defaultPointStyle(ratio); diff --git a/src/map/IMG/style.h b/src/map/IMG/style.h index eec09345..9bfc47b1 100644 --- a/src/map/IMG/style.h +++ b/src/map/IMG/style.h @@ -113,6 +113,9 @@ public: const QFont *font(Style::FontSize size, Style::FontSize defaultSize = Style::Normal) const; + const QImage *light() const {return &_light;} + const QPoint &lightOffset() const {return _lightOffset;} + static bool isPOI(quint32 type) {return !((type >= TYPE(0x01) && type <= TYPE(0x1f)) || (type >= 0x11400 && type < 0x11500));} @@ -143,6 +146,10 @@ public: {return (type == 0x10301);} static bool isObstructionPoint(quint32 type) {return (type >= 0x10400 && type <= 0x10401);} + static bool isBuoy(quint32 type) + {return (type >= 0x10200 && type < 0x10300);} + static bool isLight(quint32 type) + {return (type >= 0x10100 && type < 0x10200);} static bool isMarinePoint(quint32 type) {return type >= 0x10100 && type < 0x10a00;} static bool isMarina(quint32 type) @@ -193,6 +200,9 @@ private: /* Fonts and images must be initialized after QGuiApplication! */ QFont _large, _normal, _small, _extraSmall; + + QImage _light; + QPoint _lightOffset; }; }