Added unsurveyed area render style
[GPXSee.git] / src / map / ENC / style.cpp
blob6910fa6f90203612100018e63ad4f102f20a5822
1 #include <QPainter>
2 #include "style.h"
4 using namespace ENC;
6 static QImage railroad()
8 QImage img(16, 4, QImage::Format_ARGB32_Premultiplied);
9 img.fill(Qt::black);
10 QPainter p(&img);
11 p.setPen(QPen(Qt::white, 2));
12 p.drawLine(9, 2, 15, 2);
14 return img;
17 void Style::defaultPolygonStyle()
19 _polygons[TYPE(M_COVR)] = Polygon(QBrush("#ffffff"));
20 _polygons[TYPE(LNDARE)] = Polygon(QBrush("#e8e064"));
21 _polygons[TYPE(BUAARE)] = Polygon(QBrush("#d98b21"));
22 _polygons[TYPE(BUISGL)] = Polygon(QBrush("#d98b21"),
23 QPen(QColor("#966118"), 1.5));
24 _polygons[TYPE(BRIDGE)] = Polygon(QBrush("#a58140"));
25 _polygons[SUBTYPE(DEPARE, 0)] = Polygon(QBrush("#98c064"));
26 _polygons[SUBTYPE(DEPARE, 1)] = Polygon(QBrush("#a0a0ff"));
27 _polygons[SUBTYPE(DEPARE, 2)] = Polygon(QBrush("#b0b0ff"));
28 _polygons[SUBTYPE(DEPARE, 3)] = Polygon(QBrush("#c0c0ff"));
29 _polygons[SUBTYPE(DEPARE, 4)] = Polygon(QBrush("#c0d0ff"));
30 _polygons[SUBTYPE(DEPARE, 5)] = Polygon(QBrush("#c0e0ff"));
31 _polygons[SUBTYPE(DEPARE, 6)] = Polygon(QBrush("#ffffff"));
32 _polygons[TYPE(DMPGRD)] = Polygon(QBrush(QColor("#a3a3a3"),
33 Qt::Dense3Pattern));
34 _polygons[TYPE(FAIRWY)] = Polygon(Qt::NoBrush, QPen(QColor("#888888"), 1,
35 Qt::DashDotDotLine));
36 _polygons[TYPE(OBSTRN)] = Polygon(Qt::NoBrush, QPen(QColor("#000000"), 1.5,
37 Qt::DotLine));
38 _polygons[TYPE(PONTON)] = Polygon(QBrush("#333333"));
39 _polygons[TYPE(SLCONS)] = Polygon(Qt::NoBrush, QPen(QColor("#333333"), 1.5,
40 Qt::DashLine));
41 _polygons[TYPE(ACHARE)] = Polygon(Qt::NoBrush, QPen(QColor("#e728e7"), 1,
42 Qt::DashDotLine));
43 _polygons[TYPE(LAKARE)] = Polygon(QBrush("#9fc4e1"),
44 QPen(QColor("#000000"), 1));
45 _polygons[TYPE(CANALS)] = Polygon(QBrush("#9fc4e1"),
46 QPen(QColor("#000000"), 1));
47 _polygons[TYPE(RIVERS)] = Polygon(QBrush("#9fc4e1"));
48 _polygons[TYPE(DYKCON)] = Polygon(QBrush(QColor("#9fc4e1"),
49 Qt::Dense4Pattern), QPen(QColor("#000000"), 1));
50 _polygons[TYPE(AIRARE)] = Polygon(QBrush("#333333"));
51 _polygons[SUBTYPE(RESARE, 9)] = Polygon(QBrush(QColor("#ff0000"),
52 Qt::BDiagPattern), QPen(QColor("#ff0000"), 1));
53 _polygons[TYPE(TSEZNE)] = Polygon(QBrush("#80fcb4fc"));
54 _polygons[TYPE(DRGARE)] = Polygon(QBrush(QColor("#a0a0ff"),
55 Qt::Dense4Pattern));
56 _polygons[TYPE(UNSARE)] = Polygon(QBrush("#999999"));
58 _drawOrder
59 << TYPE(M_COVR) << TYPE(LNDARE) << SUBTYPE(DEPARE, 0)
60 << SUBTYPE(DEPARE, 1) << SUBTYPE(DEPARE, 2) << SUBTYPE(DEPARE, 3)
61 << TYPE(UNSARE) << SUBTYPE(DEPARE, 4) << SUBTYPE(DEPARE, 5)
62 << SUBTYPE(DEPARE, 6) << TYPE(LAKARE) << TYPE(CANALS) << TYPE(DYKCON)
63 << TYPE(RIVERS) << TYPE(DRGARE) << TYPE(FAIRWY) << TYPE(BUAARE)
64 << TYPE(BUISGL) << TYPE(AIRARE) << TYPE(BRIDGE) << TYPE(SLCONS)
65 << TYPE(PONTON) << TYPE(DMPGRD) << TYPE(TSEZNE) << TYPE(OBSTRN)
66 << TYPE(ACHARE) << SUBTYPE(RESARE, 9) << TYPE(154);
69 void Style::defaultLineStyle()
71 _lines[TYPE(DEPCNT)] = Line(QPen(QColor("#659aef"), 1, Qt::SolidLine));
72 _lines[TYPE(DEPCNT)].setTextColor(QColor("#558adf"));
73 _lines[TYPE(DEPCNT)].setTextFontSize(Small);
74 _lines[TYPE(CBLOHD)] = Line(QImage(":/marine/cable-line.png"));
75 _lines[TYPE(BRIDGE)] = Line(QPen(QColor("#a58140"), 3, Qt::SolidLine));
76 _lines[TYPE(CBLSUB)] = Line(QImage(":/marine/cable.png"));
77 _lines[TYPE(CBLSUB)].setTextFontSize(Small);
78 _lines[TYPE(PIPSOL)] = Line(QImage(":/marine/pipeline.png"));
79 _lines[TYPE(NAVLNE)] = Line(QPen(QColor("#eb49eb"), 1, Qt::DashLine));
80 _lines[TYPE(COALNE)] = Line(QPen(QColor("#000000"), 1, Qt::SolidLine));
81 _lines[TYPE(SLCONS)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
82 _lines[TYPE(PONTON)] = Line(QPen(QColor("#333333"), 1, Qt::SolidLine));
83 _lines[TYPE(DYKCON)] = Line(QPen(QColor("#333333"), 2, Qt::SolidLine));
84 _lines[TYPE(RIVERS)] = Line(QPen(QColor("#000000"), 1, Qt::SolidLine));
85 _lines[TYPE(TSSBND)] = Line(QPen(QColor("#eb49eb"), 2, Qt::DashLine));
86 _lines[TYPE(LNDELV)] = Line(QPen(QColor("#999440"), 1, Qt::SolidLine));
87 _lines[TYPE(LNDELV)].setTextColor(QColor("#797420"));
88 _lines[TYPE(LNDELV)].setTextFontSize(Small);
89 _lines[TYPE(SLOTOP)] = Line(QPen(QColor("#797420"), 1, Qt::SolidLine));
90 _lines[TYPE(OBSTRN)] = Line(QPen(QColor("#000000"), 1.5, Qt::DotLine));
91 _lines[TYPE(FERYRT)] = Line(QImage(":/marine/ferry-line.png"));
92 _lines[TYPE(RAILWY)] = Line(railroad());
93 _lines[TYPE(ROADWY)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
94 _lines[TYPE(GATCON)] = Line(QPen(QColor("#000000"), 2, Qt::SolidLine));
97 void Style::defaultPointStyle()
99 _points[TYPE(BUAARE)].setTextFontSize(Large);
100 _points[TYPE(SOUNDG)].setTextFontSize(Small);
101 _points[TYPE(LIGHTS)] = Point(QImage(":/marine/light-major.png"), Small);
102 _points[TYPE(BOYCAR)] = Point(QImage(":/marine/buoy.png"), Small);
103 _points[TYPE(BOYINB)] = Point(QImage(":/marine/buoy.png"), Small);
104 _points[TYPE(BOYISD)] = Point(QImage(":/marine/buoy.png"), Small);
105 _points[TYPE(BOYLAT)] = Point(QImage(":/marine/buoy.png"), Small);
106 _points[TYPE(BOYSAW)] = Point(QImage(":/marine/buoy.png"), Small);
107 _points[TYPE(BOYSPP)] = Point(QImage(":/marine/buoy.png"), Small);
108 _points[TYPE(BCNISD)] = Point(QImage(":/marine/beacon.png"), Small);
109 _points[TYPE(BCNLAT)] = Point(QImage(":/marine/beacon.png"), Small);
110 _points[TYPE(BCNSAW)] = Point(QImage(":/marine/beacon.png"), Small);
111 _points[TYPE(BCNSPP)] = Point(QImage(":/marine/beacon.png"), Small);
112 _points[SUBTYPE(LNDMRK, 3)] = Point(QImage(":/marine/chimney.png"));
113 _points[SUBTYPE(LNDMRK, 20)] = Point(QImage(":/marine/church.png"));
114 _points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"));
115 _points[TYPE(LNDELV)] = Point(QImage(":/marine/triangulation-point.png"));
116 _points[TYPE(OBSTRN)] = Point(QImage(":/marine/obstruction.png"), Small);
117 _points[TYPE(WRECKS)] = Point(QImage(":/marine/wreck.png"), Small);
118 _points[SUBTYPE(WRECKS, 1)] = Point(QImage(":/marine/wreck.png"), Small);
119 _points[SUBTYPE(WRECKS, 2)] = Point(QImage(":/marine/wreck-dangerous.png"),
120 Small);
121 _points[SUBTYPE(WRECKS, 3)] = Point(QImage(":/marine/wreck.png"), Small);
122 _points[SUBTYPE(WRECKS, 4)] = Point(QImage(":/marine/wreck.png"), Small);
123 _points[SUBTYPE(WRECKS, 5)] = Point(QImage(":/marine/wreck-exposed.png"));
124 _points[TYPE(UWTROC)] = Point(QImage(":/marine/rock-dangerous.png"), Small);
125 _points[SUBTYPE(HRBFAC, 5)] = Point(QImage(":/marine/yacht-harbor.png"));
126 _points[TYPE(ACHBRT)] = Point(QImage(":/marine/anchorage.png"));
127 _points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png"));
128 _points[TYPE(PILPNT)] = Point(QImage(":/marine/pile.png"), Small);
129 _points[SUBTYPE(MORFAC, 1)] = Point(QImage(":/marine/pile.png"), Small);
130 _points[SUBTYPE(MORFAC, 5)] = Point(QImage(":/marine/pile.png"), Small);
131 _points[SUBTYPE(MORFAC, 7)] = Point(QImage(":/marine/mooring-buoy.png"),
132 Small);
135 Style::Style()
137 defaultPolygonStyle();
138 defaultLineStyle();
139 defaultPointStyle();
142 const Style::Line &Style::line(quint32 type) const
144 static Line null;
146 QMap<uint, Line>::const_iterator it = _lines.find(type);
147 return (it == _lines.constEnd()) ? null : *it;
150 const Style::Polygon &Style::polygon(quint32 type) const
152 static Polygon null;
154 QMap<uint, Polygon>::const_iterator it = _polygons.find(type);
155 return (it == _polygons.constEnd()) ? null : *it;
158 const Style::Point &Style::point(quint32 type) const
160 static Point null;
162 QMap<uint, Point>::const_iterator it = _points.find(type);
163 return (it == _points.constEnd()) ? null : *it;