Skip to content

Commit

Permalink
Use tight icon bounding boxes for marine icons
Browse files Browse the repository at this point in the history
  • Loading branch information
tumic0 committed Jun 10, 2024
1 parent 1186cb1 commit 76f10c2
Show file tree
Hide file tree
Showing 25 changed files with 107 additions and 70 deletions.
Binary file modified icons/map/marine/anchorage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/anchoring-prohibited.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/beacon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/buoy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/chimney.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/crane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/flagstaff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/fleeting-area.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/fog-signal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/gauge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/light-major.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/light-platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/monument.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/mooring-buoy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/spar-buoy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/tower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/windmotor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/map/marine/wreck-exposed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions src/map/ENC/rastertile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,18 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
if ((!label || !fnt) && !img)
continue;

TextPointItem *item = new TextPointItem(pos, label, fnt, img, color,
hColor, 0, 2, rotate);
QPoint offset = img ? style.offset() : QPoint(0, 0);

TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
color, hColor, 0, 2, rotate);
if (item->isValid() && !item->collides(textItems)) {
textItems.append(item);
if (lightsSet.contains(point.pos()))
lights.append(new TextPointItem(pos, 0, 0, _style->light(), 0,
0, 0, 0));
lights.append(new TextPointItem(pos + _style->lightOffset(),
0, 0, _style->light(), 0, 0, 0, 0));
if (signalsSet.contains(point.pos()))
lights.append(new TextPointItem(pos, 0, 0, _style->signal(), 0,
0, 0, 0));
lights.append(new TextPointItem(pos + _style->signalOffset(),
0, 0, _style->signal(), 0, 0, 0, 0));
} else
delete item;
}
Expand Down
73 changes: 48 additions & 25 deletions src/map/ENC/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,27 +202,45 @@ void Style::pointStyle(qreal ratio)
_points[SUBTYPE(BUAARE, 6)].setTextFontSize(Small);
_points[TYPE(SOUNDG)].setTextFontSize(Small);
_points[TYPE(SOUNDG)].setHaloColor(QColor());
_points[TYPE(BOYCAR)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYINB)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYISD)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYLAT)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(I_BOYLAT)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYSAW)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BOYSPP)] = Point(QImage(":/marine/buoy.png"), Small);
_points[TYPE(BCNCAR)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(BCNISD)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(BCNLAT)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(I_BCNLAT)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(BCNSAW)] = Point(QImage(":/marine/beacon.png"), Small);
_points[TYPE(BCNSPP)] = Point(QImage(":/marine/beacon.png"), Small);
_points[SUBTYPE(LNDMRK, 3)] = Point(QImage(":/marine/chimney.png"));
_points[SUBTYPE(LNDMRK, 5)] = Point(QImage(":/marine/flagstaff.png"));
_points[SUBTYPE(LNDMRK, 7)] = Point(QImage(":/marine/pylon.png"));
_points[SUBTYPE(LNDMRK, 9)] = Point(QImage(":/marine/monument.png"));
_points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"));
_points[SUBTYPE(LNDMRK, 18)] = Point(QImage(":/marine/windmill.png"));
_points[SUBTYPE(LNDMRK, 19)] = Point(QImage(":/marine/windmotor.png"));
_points[SUBTYPE(LNDMRK, 20)] = Point(QImage(":/marine/church.png"));
_points[TYPE(BOYCAR)] = Point(QImage(":/marine/buoy.png"), Small,
QPoint(6, -6));
_points[TYPE(BOYINB)] = Point(QImage(":/marine/buoy.png"), Small,
QPoint(6, -6));
_points[TYPE(BOYISD)] = Point(QImage(":/marine/buoy.png"), Small,
QPoint(6, -6));
_points[TYPE(BOYLAT)] = Point(QImage(":/marine/buoy.png"), Small,
QPoint(6, -6));
_points[TYPE(I_BOYLAT)] = Point(QImage(":/marine/buoy.png"), Small,
QPoint(6, -6));
_points[TYPE(BOYSAW)] = Point(QImage(":/marine/buoy.png"), Small,
QPoint(6, -6));
_points[TYPE(BOYSPP)] = Point(QImage(":/marine/buoy.png"), Small,
QPoint(6, -6));
_points[TYPE(BCNCAR)] = Point(QImage(":/marine/beacon.png"), Small,
QPoint(0, -8));
_points[TYPE(BCNISD)] = Point(QImage(":/marine/beacon.png"), Small,
QPoint(0, -8));
_points[TYPE(BCNLAT)] = Point(QImage(":/marine/beacon.png"), Small,
QPoint(0, -8));
_points[TYPE(I_BCNLAT)] = Point(QImage(":/marine/beacon.png"), Small,
QPoint(0, -8));
_points[TYPE(BCNSAW)] = Point(QImage(":/marine/beacon.png"), Small,
QPoint(0, -8));
_points[TYPE(BCNSPP)] = Point(QImage(":/marine/beacon.png"), Small,
QPoint(0, -8));
_points[SUBTYPE(LNDMRK, 3)] = Point(QImage(":/marine/chimney.png"),
Small, QPoint(0, -11));
_points[SUBTYPE(LNDMRK, 5)] = Point(QImage(":/marine/flagstaff.png"),
Small, QPoint(2, -11));
_points[SUBTYPE(LNDMRK, 7)] = Point(QImage(":/marine/pylon.png"), Small);
_points[SUBTYPE(LNDMRK, 9)] = Point(QImage(":/marine/monument.png"), Small,
QPoint(0, -7));
_points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"), Small,
QPoint(0, -11));
_points[SUBTYPE(LNDMRK, 18)] = Point(QImage(":/marine/windmill.png"), Small);
_points[SUBTYPE(LNDMRK, 19)] = Point(QImage(":/marine/windmotor.png"),
Small, QPoint(0, -11));
_points[SUBTYPE(LNDMRK, 20)] = Point(QImage(":/marine/church.png"), Small);
_points[TYPE(LNDELV)] = Point(QImage(":/marine/triangulation-point.png"));
_points[TYPE(OBSTRN)] = Point(QImage(":/marine/obstruction.png"), Small);
_points[SUBTYPE(WRECKS, 0)] = Point(QImage(":/marine/wreck.png"), Small);
Expand All @@ -231,7 +249,8 @@ void Style::pointStyle(qreal ratio)
Small);
_points[SUBTYPE(WRECKS, 3)] = Point(QImage(":/marine/wreck.png"), Small);
_points[SUBTYPE(WRECKS, 4)] = Point(QImage(":/marine/wreck.png"), Small);
_points[SUBTYPE(WRECKS, 5)] = Point(QImage(":/marine/wreck-exposed.png"));
_points[SUBTYPE(WRECKS, 5)] = Point(QImage(":/marine/wreck-exposed.png"),
Small, QPoint(0, -4));
_points[SUBTYPE(UWTROC, 1)] = Point(QImage(":/marine/rock-exposed.png"),
Small);
_points[SUBTYPE(UWTROC, 2)] = Point(QImage(":/marine/rock-exposed.png"),
Expand All @@ -256,9 +275,11 @@ void Style::pointStyle(qreal ratio)
_points[SUBTYPE(MORFAC, 3)] = Point(QImage(":/marine/pile.png"), Small);
_points[SUBTYPE(MORFAC, 5)] = Point(QImage(":/marine/pile.png"), Small);
_points[SUBTYPE(MORFAC, 7)] = Point(QImage(":/marine/mooring-buoy.png"),
Small);
_points[TYPE(CRANES)] = Point(QImage(":/marine/crane.png"), Small);
_points[TYPE(I_CRANES)] = Point(QImage(":/marine/crane.png"), Small);
Small, QPoint(0, -5));
_points[TYPE(CRANES)] = Point(QImage(":/marine/crane.png"), Small,
QPoint(0, -5));
_points[TYPE(I_CRANES)] = Point(QImage(":/marine/crane.png"), Small,
QPoint(0, -5));
_points[SUBTYPE(I_DISMAR, 1)] = Point(QImage(":/marine/distance-mark.png"),
Small);
_points[SUBTYPE(I_DISMAR, 1)].setTextColor(QColor(0xff, 0xff, 0xff));
Expand Down Expand Up @@ -352,7 +373,9 @@ void Style::pointStyle(qreal ratio)
Style::Style(qreal ratio)
{
_light = QImage(":/marine/light.png");
_lightOffset = QPoint(11, 11);
_signal = QImage(":/marine/fog-signal.png");
_signalOffset = QPoint(-9, 9);

_large = pixelSizeFont(16);
_normal = pixelSizeFont(12);
Expand Down
10 changes: 8 additions & 2 deletions src/map/ENC/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ class Style
public:
Point() : _textColor(Qt::black), _haloColor(Qt::white),
_textFontSize(Normal) {}
Point(const QImage &img, FontSize fontSize = Normal)
Point(const QImage &img, FontSize fontSize = Normal,
const QPoint &offset = QPoint(0, 0))
: _textColor(Qt::black), _haloColor(Qt::white),
_textFontSize(fontSize), _img(img) {}
_textFontSize(fontSize), _img(img), _offset(offset) {}

void setTextColor(const QColor &color) {_textColor = color;}
void setHaloColor(const QColor &color) {_haloColor = color;}
Expand All @@ -79,11 +80,13 @@ class Style
const QColor &haloColor() const {return _haloColor;}
FontSize textFontSize() const {return _textFontSize;}
const QImage &img() const {return _img;}
const QPoint &offset() const {return _offset;}

private:
QColor _textColor, _haloColor;
FontSize _textFontSize;
QImage _img;
QPoint _offset;
};

Style(qreal ratio);
Expand All @@ -96,6 +99,8 @@ class Style
const QFont *font(Style::FontSize size) const;
const QImage *light() const {return &_light;}
const QImage *signal() const {return &_signal;}
const QPoint &lightOffset() const {return _lightOffset;}
const QPoint &signalOffset() const {return _signalOffset;}

private:
void polygonStyle();
Expand All @@ -110,6 +115,7 @@ class Style
/* Fonts and images must be initialized after QGuiApplication! */
QFont _small, _normal, _large;
QImage _light, _signal;
QPoint _lightOffset, _signalOffset;
};

}
Expand Down
4 changes: 3 additions & 1 deletion src/map/IMG/rastertile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,10 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
if ((!label || !fnt) && !img)
continue;

QPoint offset = img ? style.offset() : QPoint(0, 0);

TextPointItem *item = new TextPointItem(QPoint(point.coordinates.lon(),
point.coordinates.lat()), label, fnt, img, color, hcolor, 0,
point.coordinates.lat()) + offset, label, fnt, img, color, hcolor, 0,
ICON_PADDING);
if (item->isValid() && !item->collides(textItems))
textItems.append(item);
Expand Down
71 changes: 36 additions & 35 deletions src/map/IMG/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,48 +670,49 @@ void Style::defaultPointStyle(qreal ratio)
_points[0x11108] = _points[0x3008];

// Marine stuff
_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"));
_points[0x10201] = Point(QImage(":/marine/buoy.png"));
_points[0x10202] = Point(QImage(":/marine/buoy.png"));
_points[0x10203] = Point(QImage(":/marine/buoy.png"));
_points[0x10204] = Point(QImage(":/marine/buoy.png"));
_points[0x10205] = Point(QImage(":/marine/buoy.png"));
_points[0x10206] = Point(QImage(":/marine/beacon.png"));
_points[0x10207] = Point(QImage(":/marine/spar-buoy.png"));
_points[0x10209] = Point(QImage(":/marine/buoy.png"));
_points[0x1020a] = Point(QImage(":/marine/buoy.png"));
_points[0x1020b] = Point(QImage(":/marine/buoy.png"));
_points[0x1020d] = Point(QImage(":/marine/light-platform.png"));
_points[0x1020e] = Point(QImage(":/marine/beacon.png"));
_points[0x1020f] = Point(QImage(":/marine/beacon.png"));
_points[0x10210] = Point(QImage(":/marine/beacon.png"));
_points[0x10211] = Point(QImage(":/marine/beacon.png"));
_points[0x10212] = Point(QImage(":/marine/beacon.png"));
_points[0x10213] = Point(QImage(":/marine/beacon.png"));
_points[0x10214] = Point(QImage(":/marine/beacon.png"));
_points[0x10215] = Point(QImage(":/marine/beacon.png"));
_points[0x10216] = Point(QImage(":/marine/mooring-buoy.png"));
_points[0x10305] = Point(QImage(":/marine/chimney.png"));
_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[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));
_points[0x10203] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
_points[0x10204] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
_points[0x10205] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
_points[0x10206] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
_points[0x10207] = Point(QImage(":/marine/spar-buoy.png"), QPoint(2, -9));
_points[0x10209] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
_points[0x1020a] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
_points[0x1020b] = Point(QImage(":/marine/buoy.png"), QPoint(6, -6));
_points[0x1020d] = Point(QImage(":/marine/light-platform.png"),
QPoint(8, -8));
_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));
_points[0x10211] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
_points[0x10212] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
_points[0x10213] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
_points[0x10214] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
_points[0x10215] = Point(QImage(":/marine/beacon.png"), QPoint(0, -8));
_points[0x10216] = Point(QImage(":/marine/mooring-buoy.png"), QPoint(0, -5));
_points[0x10305] = Point(QImage(":/marine/chimney.png"), QPoint(0, -11));
_points[0x10306] = Point(QImage(":/marine/church.png"));
_points[0x10307] = Point(QImage(":/marine/silo.png"));
_points[0x10308] = Point(QImage(":/marine/tower.png"));
_points[0x10308] = Point(QImage(":/marine/tower.png"), QPoint(0, -11));
_points[0x1030a] = Point(QImage(":/marine/triangulation-point.png"));
_points[0x1030b] = Point(QImage(":/marine/radio.png"));
_points[0x10400] = Point(QImage(":/marine/obstruction.png"));
_points[0x10401] = Point(QImage(":/marine/obstruction.png"));
_points[0x10402] = Point(QImage(":/marine/wreck.png"));
_points[0x10403] = Point(QImage(":/marine/wreck-exposed.png"));
_points[0x10403] = Point(QImage(":/marine/wreck-exposed.png"), QPoint(0, -4));
_points[0x10408] = Point(QImage(":/marine/obstruction-covers.png"));
_points[0x1040a] = Point(QImage(":/marine/rock-dangerous.png"));
_points[0x1040c] = Point(QImage(":/marine/rock-exposed.png"));
Expand Down
5 changes: 4 additions & 1 deletion src/map/IMG/style.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ class Style
Point() {}
Point(FontSize fontSize, const QColor &textColor = QColor())
: _text(textColor, fontSize) {}
Point(const QImage &img) : _img(img) {}
Point(const QImage &img, const QPoint &offset = QPoint(0, 0))
: _img(img), _offset(offset) {}

const Font &text() const {return _text;}
const QImage &img() const {return _img;}
const QPoint &offset() const {return _offset;}

private:
friend class Style;
Expand All @@ -98,6 +100,7 @@ class Style

Font _text;
QImage _img;
QPoint _offset;
};


Expand Down

0 comments on commit 76f10c2

Please sign in to comment.