1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-26 04:00:49 +01:00

Some more style/layout fiddeling

+ code cleanup
This commit is contained in:
Martin Tůma 2020-01-24 19:44:19 +01:00
parent cb01c0b590
commit 09d6de00a6
3 changed files with 145 additions and 175 deletions

View File

@ -1,72 +1,69 @@
#include <QImage> #include <QImage>
#include "style.h" #include "style.h"
#define TYPE(t) ((t)<<8)
void Style::defaultPolygonStyle() void Style::defaultPolygonStyle()
{ {
_polygons[TYPE(0x01)] = Style::Polygon(QBrush("#dfd3b5")); _polygons[TYPE(0x01)] = Polygon(QBrush("#dfd3b5"));
_polygons[TYPE(0x02)] = Style::Polygon(QBrush("#dfd3b5")); _polygons[TYPE(0x02)] = Polygon(QBrush("#dfd3b5"));
_polygons[TYPE(0x03)] = Style::Polygon(QBrush("#dfd3b5")); _polygons[TYPE(0x03)] = Polygon(QBrush("#dfd3b5"));
_polygons[TYPE(0x04)] = Style::Polygon(QBrush("#ff4040", Qt::BDiagPattern)); _polygons[TYPE(0x04)] = Polygon(QBrush("#ff4040", Qt::BDiagPattern));
_polygons[TYPE(0x05)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x05)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x06)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x06)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x07)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x07)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x08)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x08)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x09)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x09)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x0a)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x0a)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x0b)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x0b)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x0c)] = Style::Polygon(QBrush("#d6d4ce")); _polygons[TYPE(0x0c)] = Polygon(QBrush("#d6d4ce"));
_polygons[TYPE(0x0d)] = Style::Polygon(QBrush("#f8e3be")); _polygons[TYPE(0x0d)] = Polygon(QBrush("#f8e3be"));
_polygons[TYPE(0x0e)] = Style::Polygon(QBrush("#ffffff")); _polygons[TYPE(0x0e)] = Polygon(QBrush("#ffffff"));
_polygons[TYPE(0x0f)] = Style::Polygon(QBrush("#e6e2d9")); _polygons[TYPE(0x0f)] = Polygon(QBrush("#e6e2d9"));
_polygons[TYPE(0x10)] = Style::Polygon(QBrush("#e6e2d9")); _polygons[TYPE(0x10)] = Polygon(QBrush("#e6e2d9"));
_polygons[TYPE(0x11)] = Style::Polygon(QBrush("#e6e2d9")); _polygons[TYPE(0x11)] = Polygon(QBrush("#e6e2d9"));
_polygons[TYPE(0x12)] = Style::Polygon(QBrush("#e6e2d9")); _polygons[TYPE(0x12)] = Polygon(QBrush("#e6e2d9"));
_polygons[TYPE(0x13)] = Style::Polygon(QBrush("#dbd0b6"), _polygons[TYPE(0x13)] = Polygon(QBrush("#dbd0b6"),
QPen(QColor("#cdccc4"), 1)); QPen(QColor("#cdccc4"), 1));
_polygons[TYPE(0x14)] = Style::Polygon(QBrush(QColor("#9ac269"), _polygons[TYPE(0x14)] = Polygon(QBrush("#d4ebb8"));
_polygons[TYPE(0x15)] = Polygon(QBrush("#d4ebb8"));
_polygons[TYPE(0x16)] = Polygon(QBrush(QColor("#9ac269"),
Qt::BDiagPattern)); Qt::BDiagPattern));
_polygons[TYPE(0x15)] = Style::Polygon(QBrush(QColor("#9ac269"), _polygons[TYPE(0x17)] = Polygon(QBrush("#d4ebb8"));
Qt::BDiagPattern)); _polygons[TYPE(0x18)] = Polygon(QBrush("#d4ebb8"));
_polygons[TYPE(0x16)] = Style::Polygon(QBrush(QColor("#9ac269"), _polygons[TYPE(0x19)] = Polygon(QBrush("#e3edc6"), QPen("#c9d3a5"));
Qt::BDiagPattern)); _polygons[TYPE(0x1a)] = Polygon(QBrush("#000000", Qt::Dense6Pattern),
_polygons[TYPE(0x17)] = Style::Polygon(QBrush("#d4ebb8"));
_polygons[TYPE(0x18)] = Style::Polygon(QBrush("#d4ebb8"));
_polygons[TYPE(0x19)] = Style::Polygon(QBrush("#e3edc6"), QPen("#c9d3a5"));
_polygons[TYPE(0x1a)] = Style::Polygon(QBrush("#000000", Qt::Dense6Pattern),
QPen(QColor("#cdccc4"), 1)); QPen(QColor("#cdccc4"), 1));
_polygons[TYPE(0x1e)] = Style::Polygon(QBrush(QColor("#9ac269"), _polygons[TYPE(0x1e)] = Polygon(QBrush(QColor("#9ac269"),
Qt::BDiagPattern)); Qt::BDiagPattern));
_polygons[TYPE(0x1f)] = Style::Polygon(QBrush(QColor("#9ac269"), _polygons[TYPE(0x1f)] = Polygon(QBrush(QColor("#9ac269"),
Qt::BDiagPattern)); Qt::BDiagPattern));
_polygons[TYPE(0x28)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x28)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x29)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x29)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x32)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x32)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x3b)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x3b)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x3c)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x3c)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x3d)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x3d)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x3e)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x3e)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x3f)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x3f)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x40)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x40)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x41)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x41)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x42)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x42)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x43)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x43)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x44)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x44)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x45)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x45)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x46)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x46)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x47)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x47)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x48)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x48)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x49)] = Style::Polygon(QBrush("#9fc4e1")); _polygons[TYPE(0x49)] = Polygon(QBrush("#9fc4e1"));
_polygons[TYPE(0x4b)] = Style::Polygon(QBrush("#f1f0e5"), QPen("#f1f0e5")); _polygons[TYPE(0x4b)] = Polygon(QBrush("#f1f0e5"), QPen("#f1f0e5"));
_polygons[TYPE(0x4a)] = Style::Polygon(QBrush("#f1f0e5"), QPen("#f1f0e5")); _polygons[TYPE(0x4a)] = Polygon(QBrush("#f1f0e5"), QPen("#f1f0e5"));
_polygons[TYPE(0x4c)] = Style::Polygon(QBrush("#9fc4e1", Qt::Dense6Pattern)); _polygons[TYPE(0x4c)] = Polygon(QBrush("#9fc4e1", Qt::Dense6Pattern));
_polygons[TYPE(0x4d)] = Style::Polygon(QBrush("#ddf1fd")); _polygons[TYPE(0x4d)] = Polygon(QBrush("#ddf1fd"));
_polygons[TYPE(0x4e)] = Style::Polygon(QBrush("#e3edc1")); _polygons[TYPE(0x4e)] = Polygon(QBrush("#e3edc1"));
_polygons[TYPE(0x4f)] = Style::Polygon(QBrush("#d4ebb8")); _polygons[TYPE(0x4f)] = Polygon(QBrush("#d4ebb8"));
_polygons[TYPE(0x50)] = Style::Polygon(QBrush("#d4ebb8")); _polygons[TYPE(0x50)] = Polygon(QBrush("#d4ebb8"));
_polygons[TYPE(0x51)] = Style::Polygon(QBrush("#9fc4e1", Qt::Dense4Pattern)); _polygons[TYPE(0x51)] = Polygon(QBrush("#9fc4e1", Qt::Dense4Pattern));
_polygons[TYPE(0x52)] = Style::Polygon(QBrush("#d4ebb8")); _polygons[TYPE(0x52)] = Polygon(QBrush("#d4ebb8"));
_drawOrder << TYPE(0x4b) << TYPE(0x4a) << TYPE(0x01) << TYPE(0x02) _drawOrder << TYPE(0x4b) << TYPE(0x4a) << TYPE(0x01) << TYPE(0x02)
<< TYPE(0x03) << TYPE(0x17) << TYPE(0x18) << TYPE(0x19) << TYPE(0x1a) << TYPE(0x03) << TYPE(0x17) << TYPE(0x18) << TYPE(0x19) << TYPE(0x1a)
@ -89,71 +86,69 @@ void Style::defaultLineStyle()
QPen rr(QColor("#717171"), 3, Qt::CustomDashLine); QPen rr(QColor("#717171"), 3, Qt::CustomDashLine);
rr.setDashPattern(pattern); rr.setDashPattern(pattern);
_lines[TYPE(0x01)] = Style::Line(QPen(QColor("#9bd772"), 2, Qt::SolidLine), _lines[TYPE(0x01)] = Line(QPen(QColor("#9bd772"), 2, Qt::SolidLine),
QPen(QColor("#72a35a"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#72a35a"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x02)] = Style::Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine), _lines[TYPE(0x02)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x03)] = Style::Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine), _lines[TYPE(0x03)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x04)] = Style::Line(QPen(QColor("#faef75"), 3, Qt::SolidLine), _lines[TYPE(0x04)] = Line(QPen(QColor("#faef75"), 3, Qt::SolidLine),
QPen(QColor("#dbd27b"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#dbd27b"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x05)] = Style::Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine), _lines[TYPE(0x05)] = Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine),
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x06)] = Style::Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine), _lines[TYPE(0x06)] = Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine),
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x07)] = Style::Line(QPen(QColor("#ffffff"), 2, Qt::SolidLine), _lines[TYPE(0x07)] = Line(QPen(QColor("#ffffff"), 2, Qt::SolidLine),
QPen(QColor("#d5cdc0"), 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#d5cdc0"), 4, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x08)] = Style::Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine), _lines[TYPE(0x08)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x09)] = Style::Line(QPen(QColor("#9bd772"), 2, Qt::SolidLine), _lines[TYPE(0x09)] = Line(QPen(QColor("#9bd772"), 2, Qt::SolidLine),
QPen(QColor("#72a35a"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#72a35a"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x0a)] = Style::Line(QPen(QColor("#aba083"), 1, Qt::DashLine)); _lines[TYPE(0x0a)] = Line(QPen(QColor("#aba083"), 1, Qt::DashLine));
_lines[TYPE(0x0b)] = Style::Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine), _lines[TYPE(0x0b)] = Line(QPen(QColor("#ffcc78"), 2, Qt::SolidLine),
QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#e8a541"), 6, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x0c)] = Style::Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine), _lines[TYPE(0x0c)] = Line(QPen(QColor("#ffffff"), 3, Qt::SolidLine),
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x14)] = Style::Line(rr, QPen(Qt::white, 3, Qt::SolidLine, _lines[TYPE(0x14)] = Line(rr, QPen(Qt::white, 3, Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin)); Qt::RoundCap, Qt::RoundJoin));
_lines[TYPE(0x16)] = Style::Line(QPen(QColor("#aba083"), 1, Qt::DotLine)); _lines[TYPE(0x16)] = Line(QPen(QColor("#aba083"), 1, Qt::DotLine));
_lines[TYPE(0x18)] = Style::Line(QPen(QColor("#9fc4e1"), 2, Qt::SolidLine)); _lines[TYPE(0x18)] = Line(QPen(QColor("#9fc4e1"), 2, Qt::SolidLine));
_lines[TYPE(0x18)].setTextColor(QColor("#9fc4e1")); _lines[TYPE(0x18)].setTextColor(QColor("#9fc4e1"));
//_lines[TYPE(0x1a)] = Style::Line(QPen(QColor("#7697b7"), 1, Qt::DashLine)); //_lines[TYPE(0x1a)] = Line(QPen(QColor("#7697b7"), 1, Qt::DashLine));
_lines[TYPE(0x1b)] = Style::Line(QPen(QColor("#7697b7"), 1, Qt::DashLine)); _lines[TYPE(0x1b)] = Line(QPen(QColor("#7697b7"), 1, Qt::DashLine));
_lines[TYPE(0x1e)] = Style::Line(QPen(QColor("#505145"), 2, Qt::DashDotLine)); _lines[TYPE(0x1e)] = Line(QPen(QColor("#505145"), 2, Qt::DashDotLine));
_lines[TYPE(0x1f)] = Style::Line(QPen(QColor("#9fc4e1"), 3, Qt::SolidLine)); _lines[TYPE(0x1f)] = Line(QPen(QColor("#9fc4e1"), 3, Qt::SolidLine));
_lines[TYPE(0x1f)].setTextColor(QColor("#9fc4e1")); _lines[TYPE(0x1f)].setTextColor(QColor("#9fc4e1"));
_lines[TYPE(0x20)] = Style::Line(QPen(QColor("#cacfc0"), 1, Qt::SolidLine)); _lines[TYPE(0x20)] = Line(QPen(QColor("#cfcfcf"), 1, Qt::SolidLine));
_lines[TYPE(0x20)].setTextColor(QColor("#62695a")); _lines[TYPE(0x20)].setTextFontSize(None);
_lines[TYPE(0x20)].setTextFontSize(Style::Small); _lines[TYPE(0x21)] = Line(QPen(QColor("#bfbfbf"), 1, Qt::SolidLine));
_lines[TYPE(0x21)] = Style::Line(QPen(QColor("#cacfc0"), 1.5, Qt::SolidLine)); _lines[TYPE(0x21)].setTextColor(QColor("#666666"));
_lines[TYPE(0x21)].setTextColor(QColor("#62695a")); _lines[TYPE(0x21)].setTextFontSize(Small);
_lines[TYPE(0x21)].setTextFontSize(Style::Small); _lines[TYPE(0x22)] = Line(QPen(QColor("#afafaf"), 1, Qt::SolidLine));
_lines[TYPE(0x22)] = Style::Line(QPen(QColor("#cacfc0"), 2, Qt::SolidLine)); _lines[TYPE(0x22)].setTextColor(QColor("#666666"));
_lines[TYPE(0x22)].setTextColor(QColor("#62695a")); _lines[TYPE(0x22)].setTextFontSize(Small);
_lines[TYPE(0x22)].setTextFontSize(Style::Small); _lines[TYPE(0x23)] = Line(QPen(QColor("#55aaff"), 1, Qt::SolidLine));
_lines[TYPE(0x23)] = Style::Line(QPen(QColor("#55aaff"), 1, Qt::SolidLine)); _lines[TYPE(0x23)].setTextFontSize(None);
_lines[TYPE(0x23)].setTextColor(QColor("#55aaff")); _lines[TYPE(0x24)] = Line(QPen(QColor("#659aef"), 1, Qt::SolidLine));
_lines[TYPE(0x23)].setTextFontSize(Style::Small); _lines[TYPE(0x24)].setTextColor(QColor("#558adf"));
_lines[TYPE(0x24)] = Style::Line(QPen(QColor("#55aaff"), 1.5, Qt::SolidLine)); _lines[TYPE(0x24)].setTextFontSize(Small);
_lines[TYPE(0x24)].setTextColor(QColor("#55aaff")); _lines[TYPE(0x25)] = Line(QPen(QColor("#558adf"), 1, Qt::SolidLine));
_lines[TYPE(0x24)].setTextFontSize(Style::Small); _lines[TYPE(0x25)].setTextColor(QColor("#558adf"));
_lines[TYPE(0x25)] = Style::Line(QPen(QColor("#55aaff"), 2, Qt::SolidLine)); _lines[TYPE(0x25)].setTextFontSize(Small);
_lines[TYPE(0x25)].setTextColor(QColor("#55aaff")); _lines[TYPE(0x26)] = Line(QPen(QColor("#9fc4e1"), 2, Qt::DotLine));
_lines[TYPE(0x25)].setTextFontSize(Style::Small); _lines[TYPE(0x27)] = Line(QPen(QColor("#ffffff"), 4, Qt::SolidLine),
_lines[TYPE(0x26)] = Style::Line(QPen(QColor("#9fc4e1"), 2, Qt::DotLine));
_lines[TYPE(0x27)] = Style::Line(QPen(QColor("#ffffff"), 4, Qt::SolidLine),
QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); QPen(QColor("#d5cdc0"), 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
//_lines[TYPE(0x28)] = Style::Line(QPen(QColor("#5a5a5a"), 1, Qt::SolidLine)); //_lines[TYPE(0x28)] = Line(QPen(QColor("#5a5a5a"), 1, Qt::SolidLine));
_lines[TYPE(0x29)] = Style::Line(QPen(QColor("#5a5a5a"), 1, Qt::SolidLine)); _lines[TYPE(0x29)] = Line(QPen(QColor("#5a5a5a"), 1, Qt::SolidLine));
_lines[TYPE(0x29)].setTextFontSize(Style::None); _lines[TYPE(0x29)].setTextFontSize(None);
} }
void Style::defaultPointStyle() void Style::defaultPointStyle()
{ {
// Cities // Cities
_points[TYPE(0x01)].setTextFontSize(Style::Large); _points[TYPE(0x01)].setTextFontSize(Large);
_points[TYPE(0x02)].setTextFontSize(Style::Large); _points[TYPE(0x02)].setTextFontSize(Large);
_points[TYPE(0x03)].setTextFontSize(Style::Large); _points[TYPE(0x03)].setTextFontSize(Large);
// POI // POI
_points[0x2a00] = Point(QImage(":/restaurant-11.png")); _points[0x2a00] = Point(QImage(":/restaurant-11.png"));
@ -412,14 +407,14 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2) if (!(readColor(file, hdl, c1) && readColor(file, hdl, c2)
&& readColor(file, hdl, c3) && readColor(file, hdl, c4))) && readColor(file, hdl, c3) && readColor(file, hdl, c4)))
return false; return false;
_polygons[type] = Style::Polygon(QBrush(c1), QPen(c3, 2)); _polygons[type] = Polygon(QBrush(c1), QPen(c3, 2));
break; break;
case 0x06: case 0x06:
case 0x07: case 0x07:
if (!readColor(file, hdl, c1)) if (!readColor(file, hdl, c1))
return false; return false;
_polygons[type] = Style::Polygon(QBrush(c1)); _polygons[type] = Polygon(QBrush(c1));
break; break;
case 0x08: case 0x08:
@ -432,7 +427,7 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_polygons[type] = Style::Polygon(QBrush(img)); _polygons[type] = Polygon(QBrush(img));
break; break;
case 0x09: case 0x09:
@ -446,7 +441,7 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_polygons[type] = Style::Polygon(QBrush(img)); _polygons[type] = Polygon(QBrush(img));
break; break;
case 0x0B: case 0x0B:
@ -462,7 +457,7 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_polygons[type] = Style::Polygon(QBrush(img)); _polygons[type] = Polygon(QBrush(img));
break; break;
case 0x0E: case 0x0E:
@ -475,7 +470,7 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_polygons[type] = Style::Polygon(QBrush(img)); _polygons[type] = Polygon(QBrush(img));
break; break;
case 0x0F: case 0x0F:
@ -488,7 +483,7 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_polygons[type] = Style::Polygon(QBrush(img)); _polygons[type] = Polygon(QBrush(img));
break; break;
default: default:
@ -539,16 +534,16 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_lines[type] = Style::Line(img); _lines[type] = Line(img);
} else { } else {
if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2))) if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2)))
return false; return false;
_lines[type] = (w2 > w1) _lines[type] = (w2 > w1)
? Style::Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap, ? Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin)) Qt::RoundJoin))
: Style::Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap, : Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin)); Qt::RoundJoin));
} }
break; break;
@ -566,16 +561,16 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_lines[type] = Style::Line(img); _lines[type] = Line(img);
} else { } else {
if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2))) if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2)))
return false; return false;
_lines[type] = (w2 > w1) _lines[type] = (w2 > w1)
? Style::Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap, ? Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin)) Qt::RoundJoin))
: Style::Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap, : Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin)); Qt::RoundJoin));
} }
break; break;
@ -593,12 +588,12 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_lines[type] = Style::Line(img); _lines[type] = Line(img);
} else { } else {
if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2))) if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2)))
return false; return false;
_lines[type] = Style::Line(QPen(c1, w1, Qt::SolidLine, _lines[type] = Line(QPen(c1, w1, Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin)); Qt::RoundCap, Qt::RoundJoin));
} }
break; break;
@ -616,16 +611,16 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_lines[type] = Style::Line(img); _lines[type] = Line(img);
} else { } else {
if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2))) if (!(file->readUInt8(hdl, w1) && file->readUInt8(hdl, w2)))
return false; return false;
_lines[type] = (w2 > w1) _lines[type] = (w2 > w1)
? Style::Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap, ? Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin), QPen(c2, w2, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin)) Qt::RoundJoin))
: Style::Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap, : Line(QPen(c1, w1, Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin)); Qt::RoundJoin));
} }
break; break;
@ -642,12 +637,12 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_lines[type] = Style::Line(img); _lines[type] = Line(img);
} else { } else {
if (!file->readUInt8(hdl, w1)) if (!file->readUInt8(hdl, w1))
return false; return false;
_lines[type] = Style::Line(QPen(c1, w1, Qt::SolidLine, _lines[type] = Line(QPen(c1, w1, Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin)); Qt::RoundCap, Qt::RoundJoin));
} }
break; break;
@ -664,12 +659,12 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
if (!readBitmap(file, hdl, img, 1)) if (!readBitmap(file, hdl, img, 1))
return false; return false;
_lines[type] = Style::Line(img); _lines[type] = Line(img);
} else { } else {
if (!file->readUInt8(hdl, w1)) if (!file->readUInt8(hdl, w1))
return false; return false;
_lines[type] = Style::Line(QPen(c1, w1, Qt::SolidLine, _lines[type] = Line(QPen(c1, w1, Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin)); Qt::RoundCap, Qt::RoundJoin));
} }
break; break;
@ -973,43 +968,6 @@ const Style::Point &Style::point(quint32 type) const
return (it == _points.constEnd()) ? null : *it; return (it == _points.constEnd()) ? null : *it;
} }
bool Style::isContourLine(quint32 type)
{
return (type == TYPE(0x20) || type == TYPE(0x21) || type == TYPE(0x22)
|| type == TYPE(0x23) || type == TYPE(0x24) || type == TYPE(0x25)
|| (type & 0xffff00) == TYPE(0x109));
}
bool Style::isWaterArea(quint32 type)
{
return (type >= TYPE(0x3c) && type <= TYPE(0x44));
}
bool Style::isMilitaryArea(quint32 type)
{
return (type == TYPE(0x04));
}
bool Style::isSpot(quint32 type)
{
return (type == TYPE(0x62) || type == TYPE(0x63));
}
bool Style::isSummit(quint32 type)
{
return (type == 0x6616);
}
bool Style::isMajorRoad(quint32 type)
{
return (type <= TYPE(0x04));
}
bool Style::isWaterAreaPOI(quint32 type)
{
return (type == 0x6603);
}
Style::POIClass Style::poiClass(quint32 type) Style::POIClass Style::poiClass(quint32 type)
{ {
if ((type >= 0x2a00 && type < 0x2b00) || type == 0x2c0a || type == 0x2d02) if ((type >= 0x2a00 && type < 0x2b00) || type == 0x2c0a || type == 0x2d02)

View File

@ -6,6 +6,7 @@
#include <QDebug> #include <QDebug>
#include "subfile.h" #include "subfile.h"
#define TYPE(t) ((t)<<8)
class Style class Style
{ {
@ -106,13 +107,22 @@ public:
const Point &point(quint32 type) const; const Point &point(quint32 type) const;
const QList<quint32> &drawOrder() const {return _drawOrder;} const QList<quint32> &drawOrder() const {return _drawOrder;}
static bool isContourLine(quint32 type); static bool isContourLine(quint32 type)
static bool isSpot(quint32 type); {return ((type >= TYPE(0x20) && type <= TYPE(0x25))
static bool isSummit(quint32 type); || (type & 0xffff00) == TYPE(0x109));}
static bool isMajorRoad(quint32 type); static bool isWaterArea(quint32 type)
static bool isWaterArea(quint32 type); {return (type >= TYPE(0x3c) && type <= TYPE(0x44));}
static bool isMilitaryArea(quint32 type); static bool isMilitaryArea(quint32 type)
static bool isWaterAreaPOI(quint32 type); {return (type == TYPE(0x04));}
static bool isNatureReserve(quint32 type)
{return (type == TYPE(0x16));}
static bool isSpot(quint32 type)
{return (type == TYPE(0x62) || type == TYPE(0x63));}
static bool isSummit(quint32 type)
{return (type == 0x6616);}
static bool isMajorRoad(quint32 type)
{return (type <= TYPE(0x04));}
static POIClass poiClass(quint32 type); static POIClass poiClass(quint32 type);
private: private:

View File

@ -44,8 +44,9 @@ public:
QList<TextItem*> textItems; QList<TextItem*> textItems;
QRect tileRect(_xy, QSize(TILE_SIZE, TILE_SIZE)); QRect tileRect(_xy, QSize(TILE_SIZE, TILE_SIZE));
_map->processPolygons(_polygons, textItems);
_map->processPoints(_points, textItems); _map->processPoints(_points, textItems);
_map->processPolygons(_polygons, textItems);
_map->processLines(_lines, tileRect, textItems); _map->processLines(_lines, tileRect, textItems);
_img.fill(Qt::transparent); _img.fill(Qt::transparent);
@ -174,7 +175,7 @@ static int minShieldZoom(Label::Shield::Type type)
switch (type) { switch (type) {
case Label::Shield::USInterstate: case Label::Shield::USInterstate:
case Label::Shield::Hbox: case Label::Shield::Hbox:
return 18; return 17;
case Label::Shield::USShield: case Label::Shield::USShield:
case Label::Shield::Box: case Label::Shield::Box:
return 19; return 19;
@ -391,11 +392,13 @@ void IMGMap::processPolygons(QList<IMG::Poly> &polygons,
if (poly.label.text().isEmpty()) if (poly.label.text().isEmpty())
continue; continue;
if (Style::isWaterArea(poly.type) || Style::isMilitaryArea(poly.type)) { if (_zoom <= 23 && (Style::isWaterArea(poly.type)
|| Style::isMilitaryArea(poly.type)
|| Style::isNatureReserve(poly.type))) {
const Style::Polygon &style = _img.style()->polygon(poly.type); const Style::Polygon &style = _img.style()->polygon(poly.type);
TextPointItem *item = new TextPointItem( TextPointItem *item = new TextPointItem(
centroid(poly.points).toPoint(), &poly.label.text(), centroid(poly.points).toPoint(), &poly.label.text(),
poiFont(), 0, &style.brush().color(), 0); poiFont(), 0, &style.brush().color());
if (item->isValid() && !item->collides(textItems) if (item->isValid() && !item->collides(textItems)
&& rectNearPolygon(poly.points, item->boundingRect())) && rectNearPolygon(poly.points, item->boundingRect()))
textItems.append(item); textItems.append(item);
@ -525,8 +528,7 @@ void IMGMap::processPoints(QList<IMG::Point> &points,
IMG::Point &point = points[i]; IMG::Point &point = points[i];
const Style::Point &style = _img.style()->point(point.type); const Style::Point &style = _img.style()->point(point.type);
if (point.poi && (_zoom < minPOIZoom(Style::poiClass(point.type)) if (point.poi && _zoom < minPOIZoom(Style::poiClass(point.type)))
|| Style::isWaterAreaPOI(point.type)))
continue; continue;
const QString *label = point.label.text().isEmpty() const QString *label = point.label.text().isEmpty()