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 34c4d331..dc745f84 100644 Binary files a/icons/map/marine/light-major.png and b/icons/map/marine/light-major.png differ diff --git a/icons/map/marine/light-platform.png b/icons/map/marine/light-platform.png deleted file mode 100644 index 30409846..00000000 Binary files a/icons/map/marine/light-platform.png and /dev/null differ diff --git a/src/map/IMG/mapdata.h b/src/map/IMG/mapdata.h index fd49522f..4de46e76 100644 --- a/src/map/IMG/mapdata.h +++ b/src/map/IMG/mapdata.h @@ -45,13 +45,19 @@ public: }; struct Point { - Point() : id(0), classLabel(false) {} + Point() : id(0), flags(0) {} + + enum Flags { + NoFlag = 0, + ClassLabel = 1, + Light = 2 + }; Coordinates coordinates; Label label; - quint32 type; quint64 id; - bool classLabel; + quint32 type; + quint32 flags; bool operator<(const Point &other) const {return id < other.id;} diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index 936fd6b0..e462c6de 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -418,31 +418,36 @@ void RasterTile::processPoints(QList &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; }; }