30
30
31
31
QgsSimpleLineSymbolLayerV2::QgsSimpleLineSymbolLayerV2 ( QColor color, double width, Qt::PenStyle penStyle )
32
32
: mPenStyle( penStyle ), mPenJoinStyle( DEFAULT_SIMPLELINE_JOINSTYLE ), mPenCapStyle( DEFAULT_SIMPLELINE_CAPSTYLE ), mOffset( 0 ), mOffsetUnit( QgsSymbolV2::MM ),
33
- mUseCustomDashPattern( false ), mCustomDashPatternUnit( QgsSymbolV2::MM )
33
+ mUseCustomDashPattern( false ), mCustomDashPatternUnit( QgsSymbolV2::MM ), mDrawInsidePolygon( false )
34
34
{
35
35
mColor = color;
36
36
mWidth = width;
@@ -94,6 +94,11 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::create( const QgsStringMap& props
94
94
l->setCustomDashPatternUnit ( QgsSymbolLayerV2Utils::decodeOutputUnit ( props[" customdash_unit" ] ) );
95
95
}
96
96
97
+ if ( props.contains ( " draw_inside_polygon" ) )
98
+ {
99
+ l->setDrawInsidePolygon ( props[" draw_inside_polygon" ].toInt () );
100
+ }
101
+
97
102
// data defined properties
98
103
if ( props.contains ( " color_expression" ) )
99
104
l->setDataDefinedProperty ( " color" , props[" color_expression" ] );
@@ -191,6 +196,15 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
191
196
return ;
192
197
}
193
198
199
+ if ( mDrawInsidePolygon )
200
+ {
201
+ // only drawing the line on the interior of the polygon, so set clip path for painter
202
+ p->save ();
203
+ QPainterPath clipPath;
204
+ clipPath.addPolygon ( points );
205
+ p->setClipPath ( clipPath, Qt::IntersectClip );
206
+ }
207
+
194
208
if ( offset == 0 )
195
209
{
196
210
p->drawPolyline ( points );
@@ -200,6 +214,12 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
200
214
double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mOffsetUnit );
201
215
p->drawPolyline ( ::offsetLine ( points, scaledOffset ) );
202
216
}
217
+
218
+ if ( mDrawInsidePolygon )
219
+ {
220
+ // restore painter to reset clip path
221
+ p->restore ();
222
+ }
203
223
}
204
224
205
225
QgsStringMap QgsSimpleLineSymbolLayerV2::properties () const
@@ -216,6 +236,7 @@ QgsStringMap QgsSimpleLineSymbolLayerV2::properties() const
216
236
map[" use_custom_dash" ] = ( mUseCustomDashPattern ? " 1" : " 0" );
217
237
map[" customdash" ] = QgsSymbolLayerV2Utils::encodeRealVector ( mCustomDashVector );
218
238
map[" customdash_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mCustomDashPatternUnit );
239
+ map[" draw_inside_polygon" ] = ( mDrawInsidePolygon ? " 1" : " 0" );
219
240
saveDataDefinedProperties ( map );
220
241
return map;
221
242
}
@@ -231,6 +252,7 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::clone() const
231
252
l->setPenCapStyle ( mPenCapStyle );
232
253
l->setUseCustomDashPattern ( mUseCustomDashPattern );
233
254
l->setCustomDashVector ( mCustomDashVector );
255
+ l->setDrawInsidePolygon ( mDrawInsidePolygon );
234
256
copyDataDefinedProperties ( l );
235
257
return l;
236
258
}
@@ -387,7 +409,15 @@ void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderCon
387
409
388
410
double QgsSimpleLineSymbolLayerV2::estimateMaxBleed () const
389
411
{
390
- return ( mWidth / 2.0 ) + mOffset ;
412
+ if ( mDrawInsidePolygon )
413
+ {
414
+ // set to clip line to the interior of polygon, so we expect no bleed
415
+ return 0 ;
416
+ }
417
+ else
418
+ {
419
+ return ( mWidth / 2.0 ) + mOffset ;
420
+ }
391
421
}
392
422
393
423
QVector<qreal> QgsSimpleLineSymbolLayerV2::dxfCustomDashPattern ( QgsSymbolV2::OutputUnit& unit ) const
0 commit comments