From 297177ad41449d052dddbf1b7e5b93a4c29c62e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sat, 13 Jul 2019 14:42:44 +0200 Subject: [PATCH] Cosmetics --- src/map/IMG/label.h | 3 +++ src/map/imgmap.cpp | 49 +++++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/map/IMG/label.h b/src/map/IMG/label.h index 51f0bc98..b20a7ca1 100644 --- a/src/map/IMG/label.h +++ b/src/map/IMG/label.h @@ -4,6 +4,9 @@ #include #include +#define FIRST_SHIELD Label::Shield::USInterstate +#define LAST_SHIELD Label::Shield::Oval + class Label { public: class Shield diff --git a/src/map/imgmap.cpp b/src/map/imgmap.cpp index 09c077c5..c7e3d4ec 100644 --- a/src/map/imgmap.cpp +++ b/src/map/imgmap.cpp @@ -18,7 +18,6 @@ #define TILE_SIZE 256 #define TEXT_EXTENT 256 -#define LINE_TEXT_MIN_ZOOM 22 #define AREA(rect) \ (rect.size().width() * rect.size().height()) @@ -181,7 +180,7 @@ static int minShieldZoom(Label::Shield::Type type) case Label::Shield::Oval: return 20; default: - return INT_MAX; + return 0; } } @@ -357,46 +356,44 @@ void IMGMap::processLines(QList &lines, const QRect &tileRect, } } - processStreetNames(lines, tileRect, textItems); + if (_zoom >= 22) + processStreetNames(lines, tileRect, textItems); processShields(lines, tileRect, textItems); } void IMGMap::processStreetNames(QList &lines, const QRect &tileRect, QList &textItems) { - if (_zoom >= LINE_TEXT_MIN_ZOOM) { - for (int i = 0; i < lines.size(); i++) { - IMG::Poly &poly = lines[i]; - const Style::Line &style = _img.style()->line(poly.type); + for (int i = 0; i < lines.size(); i++) { + IMG::Poly &poly = lines[i]; + const Style::Line &style = _img.style()->line(poly.type); - if (style.img().isNull() && style.foreground() == Qt::NoPen) - continue; - if (poly.label.text().isEmpty() - || style.textFontSize() == Style::None) - continue; + if (style.img().isNull() && style.foreground() == Qt::NoPen) + continue; + if (poly.label.text().isEmpty() + || style.textFontSize() == Style::None) + continue; - if (Style::isContourLine(poly.type)) - poly.label.setText(convertUnits(poly.label.text())); + if (Style::isContourLine(poly.type)) + poly.label.setText(convertUnits(poly.label.text())); - const QFont *fnt = font(style.textFontSize(), Style::Small); - const QColor *color = style.textColor().isValid() - ? &style.textColor() : 0; + const QFont *fnt = font(style.textFontSize(), Style::Small); + const QColor *color = style.textColor().isValid() + ? &style.textColor() : 0; - TextPathItem *item = new TextPathItem(poly.points, - &poly.label.text(), tileRect, fnt, color); - if (item->isValid() && !item->collides(textItems)) - textItems.append(item); - else - delete item; - } + TextPathItem *item = new TextPathItem(poly.points, + &poly.label.text(), tileRect, fnt, color); + if (item->isValid() && !item->collides(textItems)) + textItems.append(item); + else + delete item; } } void IMGMap::processShields(QList &lines, const QRect &tileRect, QList &textItems) { - for (int type = Label::Shield::USInterstate; type <= Label::Shield::Oval; - type++) { + for (int type = FIRST_SHIELD; type <= LAST_SHIELD; type++) { if (minShieldZoom(static_cast(type)) > _zoom) continue;