MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / LineRenderable

Method LineRenderable

src/core/renderables/renderable_implementation.cpp:150–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148// ### LineRenderable ###
149
150LineRenderable::LineRenderable(const LineSymbol* symbol, const VirtualPath& virtual_path, bool closed)
151 : Renderable(symbol->getColor())
152 , line_width(0.001 * symbol->getLineWidth())
153{
154 Q_ASSERT(virtual_path.size() >= 2);
155
156 qreal half_line_width = (color_priority < 0) ? 0 : line_width/2;
157
158 switch (symbol->getCapStyle())
159 {
160 case LineSymbol::FlatCap: cap_style = Qt::FlatCap; break;
161 case LineSymbol::RoundCap: cap_style = Qt::RoundCap; break;
162 case LineSymbol::SquareCap: cap_style = Qt::SquareCap; break;
163 case LineSymbol::PointedCap: cap_style = Qt::FlatCap; break;
164 }
165 switch (symbol->getJoinStyle())
166 {
167 case LineSymbol::BevelJoin: join_style = Qt::BevelJoin; break;
168 case LineSymbol::MiterJoin: join_style = Qt::MiterJoin; break;
169 case LineSymbol::RoundJoin: join_style = Qt::RoundJoin; break;
170 }
171
172 auto& flags = virtual_path.coords.flags;
173 auto& coords = virtual_path.coords;
174
175 bool has_curve = false;
176 bool hole = false;
177 QPainterPath first_subpath;
178
179 auto i = virtual_path.first_index;
180 bool gap = flags[i].isGapPoint(); // Line may start with a gap
181 path.moveTo(coords[i]);
182 extent = QRectF(coords[i].x(), coords[i].y(), 0.0001, 0.0001);
183 extentIncludeCap(i, half_line_width, false, symbol, virtual_path);
184
185 for (++i; i <= virtual_path.last_index; ++i)
186 {
187 if (gap)
188 {
189 if (flags[i].isHolePoint())
190 {
191 gap = false;
192 hole = true;
193 }
194 else if (flags[i].isGapPoint())
195 {
196 gap = false;
197 if (first_subpath.isEmpty() && closed)
198 {
199 first_subpath = path;
200 path = QPainterPath();
201 }
202 path.moveTo(coords[i]);
203 extentIncludeCap(i, half_line_width, false, symbol, virtual_path);
204 }
205 continue;
206 }
207

Callers

nothing calls this directly

Calls 15

rectIncludeFunction · 0.85
getLineWidthMethod · 0.80
getCapStyleMethod · 0.80
getJoinStyleMethod · 0.80
isGapPointMethod · 0.80
xMethod · 0.80
yMethod · 0.80
isHolePointMethod · 0.80
isCurveStartMethod · 0.80
backMethod · 0.80
perpRightMethod · 0.80
setLengthMethod · 0.80

Tested by

no test coverage detected