From ff2dd6cdece568816b0e6315240f95c1c5a1f78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 5 Dec 2022 08:52:27 +0100 Subject: [PATCH] Code cleanup --- src/map/ENC/rastertile.cpp | 12 +++++++++--- src/map/ENC/rastertile.h | 1 + src/map/ENC/style.cpp | 13 +++++++------ src/map/ENC/style.h | 6 +++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/map/ENC/rastertile.cpp b/src/map/ENC/rastertile.cpp index c5e9d1cb..79f04b2c 100644 --- a/src/map/ENC/rastertile.cpp +++ b/src/map/ENC/rastertile.cpp @@ -202,12 +202,10 @@ void RasterTile::drawTextItems(QPainter *painter, textItems.at(i)->paint(painter); } -void RasterTile::processPoints(QList &textItems) +void RasterTile::processPolygons(QList &textItems) { const Style &s = style(); - std::sort(_points.begin(), _points.end(), pointLess); - for (int i = 0; i < _polygons.size(); i++) { const MapData::Poly *poly = _polygons.at(i); uint type = poly->type()>>16; @@ -227,6 +225,13 @@ void RasterTile::processPoints(QList &textItems) else delete item; } +} + +void RasterTile::processPoints(QList &textItems) +{ + const Style &s = style(); + + std::sort(_points.begin(), _points.end(), pointLess); for (int i = 0; i < _points.size(); i++) { const MapData::Point *point = _points.at(i); @@ -283,6 +288,7 @@ void RasterTile::render() _pixmap.setDevicePixelRatio(_ratio); _pixmap.fill(Qt::transparent); + processPolygons(textItems); processPoints(textItems); processLines(textItems); diff --git a/src/map/ENC/rastertile.h b/src/map/ENC/rastertile.h index 8186ab51..9a90da26 100644 --- a/src/map/ENC/rastertile.h +++ b/src/map/ENC/rastertile.h @@ -35,6 +35,7 @@ private: QPolygonF arrow(const Coordinates &c, qreal angle) const; void processPoints(QList &textItems); void processLines(QList &textItems); + void processPolygons(QList &textItems); void drawBitmapPath(QPainter *painter, const QImage &img, const Polygon &polygon); void drawArrows(QPainter *painter); diff --git a/src/map/ENC/style.cpp b/src/map/ENC/style.cpp index a8dbe949..15ea58a6 100644 --- a/src/map/ENC/style.cpp +++ b/src/map/ENC/style.cpp @@ -14,7 +14,7 @@ static QImage railroad() return img; } -void Style::defaultPolygonStyle() +void Style::polygonStyle() { _polygons[TYPE(M_COVR)] = Polygon(QBrush("#ffffff")); _polygons[TYPE(LNDARE)] = Polygon(QBrush("#e8e064")); @@ -117,7 +117,7 @@ void Style::defaultPolygonStyle() << SUBTYPE(I_RESARE, 17) << TYPE(CBLARE) << TYPE(PIPARE) << TYPE(PRCARE); } -void Style::defaultLineStyle() +void Style::lineStyle() { _lines[TYPE(BUISGL)] = Line(QPen(QColor("#966118"), 1.5)); _lines[TYPE(DEPCNT)] = Line(QPen(QColor("#659aef"), 1, Qt::SolidLine)); @@ -130,6 +130,7 @@ void Style::defaultLineStyle() _lines[TYPE(CBLSUB)] = Line(QImage(":/marine/cable.png")); _lines[TYPE(CBLSUB)].setTextFontSize(Small); _lines[TYPE(PIPSOL)] = Line(QImage(":/marine/pipeline.png")); + _lines[TYPE(PIPSOL)].setTextFontSize(Small); _lines[TYPE(NAVLNE)] = Line(QPen(QColor("#eb49eb"), 1, Qt::DashLine)); _lines[TYPE(COALNE)] = Line(QPen(QColor("#000000"), 1, Qt::SolidLine)); _lines[TYPE(SLCONS)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine)); @@ -165,7 +166,7 @@ void Style::defaultLineStyle() _lines[TYPE(CANALS)] = Line(QPen(QColor("#9fc4e1"), 2)); } -void Style::defaultPointStyle() +void Style::pointStyle() { _points[SUBTYPE(BUAARE, 1)].setTextFontSize(Large); _points[SUBTYPE(BUAARE, 5)].setTextFontSize(Large); @@ -259,9 +260,9 @@ void Style::defaultPointStyle() Style::Style() { - defaultPolygonStyle(); - defaultLineStyle(); - defaultPointStyle(); + polygonStyle(); + lineStyle(); + pointStyle(); } const Style::Line &Style::line(uint type) const diff --git a/src/map/ENC/style.h b/src/map/ENC/style.h index 8169c5cf..1eb5d995 100644 --- a/src/map/ENC/style.h +++ b/src/map/ENC/style.h @@ -98,9 +98,9 @@ public: {return (type & 0xFFFF0000) == TYPE(I_DISMAR);} private: - void defaultPolygonStyle(); - void defaultLineStyle(); - void defaultPointStyle(); + void polygonStyle(); + void lineStyle(); + void pointStyle(); QMap _lines; QMap _polygons;