@@ -48,8 +48,9 @@ static void _fixQPictureDPI( QPainter* p )
48
48
49
49
// ////
50
50
51
- QgsSimpleMarkerSymbolLayerV2::QgsSimpleMarkerSymbolLayerV2 ( const QString& name, const QColor& color, const QColor& borderColor, double size, double angle, QgsSymbolV2::ScaleMethod scaleMethod )
52
- : mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
51
+ QgsSimpleMarkerSymbolLayerV2::QgsSimpleMarkerSymbolLayerV2 ( const QString& name, const QColor& color, const QColor& borderColor, double size, double angle, QgsSymbolV2::ScaleMethod scaleMethod,
52
+ Qt::PenJoinStyle penJoinStyle )
53
+ : mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM ), mPenJoinStyle( penJoinStyle )
53
54
{
54
55
mName = name;
55
56
mColor = color;
@@ -68,6 +69,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop
68
69
QString name = DEFAULT_SIMPLEMARKER_NAME;
69
70
QColor color = DEFAULT_SIMPLEMARKER_COLOR;
70
71
QColor borderColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR;
72
+ Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEMARKER_JOINSTYLE;
71
73
double size = DEFAULT_SIMPLEMARKER_SIZE;
72
74
double angle = DEFAULT_SIMPLEMARKER_ANGLE;
73
75
QgsSymbolV2::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD;
@@ -89,14 +91,18 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop
89
91
{
90
92
borderColor = QgsSymbolLayerV2Utils::decodeColor ( props[" line_color" ] );
91
93
}
94
+ if ( props.contains ( " joinstyle" ) )
95
+ {
96
+ penJoinStyle = QgsSymbolLayerV2Utils::decodePenJoinStyle ( props[" joinstyle" ] );
97
+ }
92
98
if ( props.contains ( " size" ) )
93
99
size = props[" size" ].toDouble ();
94
100
if ( props.contains ( " angle" ) )
95
101
angle = props[" angle" ].toDouble ();
96
102
if ( props.contains ( " scale_method" ) )
97
103
scaleMethod = QgsSymbolLayerV2Utils::decodeScaleMethod ( props[" scale_method" ] );
98
104
99
- QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2 ( name, color, borderColor, size, angle, scaleMethod );
105
+ QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2 ( name, color, borderColor, size, angle, scaleMethod, penJoinStyle );
100
106
if ( props.contains ( " offset" ) )
101
107
m->setOffset ( QgsSymbolLayerV2Utils::decodePoint ( props[" offset" ] ) );
102
108
if ( props.contains ( " offset_unit" ) )
@@ -168,6 +174,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
168
174
mBrush = QBrush ( brushColor );
169
175
mPen = QPen ( penColor );
170
176
mPen .setStyle ( mOutlineStyle );
177
+ mPen .setJoinStyle ( mPenJoinStyle );
171
178
mPen .setWidthF ( QgsSymbolLayerV2Utils::convertToPainterUnits ( context.renderContext (), mOutlineWidth , mOutlineWidthUnit , mOutlineWidthMapUnitScale ) );
172
179
173
180
QColor selBrushColor = context.renderContext ().selectionColor ();
@@ -190,8 +197,8 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
190
197
// - drawing to screen (not printer)
191
198
mUsingCache = !hasDataDefinedRotation && !hasDataDefinedSize && !context.renderContext ().forceVectorOutput ()
192
199
&& !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_NAME ) && !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_COLOR ) && !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_COLOR_BORDER )
193
- && !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) && !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE ) &&
194
- !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_SIZE );
200
+ && !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) && !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE )
201
+ && ! hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_JOIN_STYLE ) && !hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_SIZE );
195
202
196
203
// use either QPolygonF or QPainterPath for drawing
197
204
// TODO: find out whether drawing directly doesn't bring overhead - if not, use it for all shapes
@@ -259,7 +266,7 @@ bool QgsSimpleMarkerSymbolLayerV2::prepareCache( QgsSymbolV2RenderContext& conte
259
266
double scaledSize = QgsSymbolLayerV2Utils::convertToPainterUnits ( context.renderContext (), mSize , mSizeUnit , mSizeMapUnitScale );
260
267
261
268
// calculate necessary image size for the cache
262
- double pw = (( qgsDoubleNear ( mPen .widthF (), 0.0 ) ? 1 : mPen .widthF () ) + 1 ) / 2 * 2 ; // make even (round up); handle cosmetic pen
269
+ double pw = qRound ((( qgsDoubleNear ( mPen .widthF (), 0.0 ) ? 1 : mPen .widthF () * 4 ) + 1 ) ) / 2 * 2 ; // make even (round up); handle cosmetic pen
263
270
int imageSize = ( static_cast < int >( scaledSize ) + pw ) / 2 * 2 + 1 ; // make image width, height odd; account for pen width
264
271
double center = imageSize / 2.0 ;
265
272
@@ -560,6 +567,16 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( QPointF point, QgsSymbolV2Render
560
567
mSelPen .setStyle ( QgsSymbolLayerV2Utils::decodePenStyle ( outlineStyle ) );
561
568
}
562
569
}
570
+ if ( hasDataDefinedProperty ( QgsSymbolLayerV2::EXPR_JOIN_STYLE ) )
571
+ {
572
+ context.setOriginalValueVariable ( QgsSymbolLayerV2Utils::encodePenJoinStyle ( mPenJoinStyle ) );
573
+ QString style = evaluateDataDefinedProperty ( QgsSymbolLayerV2::EXPR_JOIN_STYLE, context, QVariant (), &ok ).toString ();
574
+ if ( ok )
575
+ {
576
+ mPen .setJoinStyle ( QgsSymbolLayerV2Utils::decodePenJoinStyle ( style ) );
577
+ mSelPen .setJoinStyle ( QgsSymbolLayerV2Utils::decodePenJoinStyle ( style ) );
578
+ }
579
+ }
563
580
564
581
p->setBrush ( context.selected () ? mSelBrush : mBrush );
565
582
p->setPen ( context.selected () ? mSelPen : mPen );
@@ -664,6 +681,7 @@ QgsStringMap QgsSimpleMarkerSymbolLayerV2::properties() const
664
681
map[" outline_width" ] = QString::number ( mOutlineWidth );
665
682
map[" outline_width_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mOutlineWidthUnit );
666
683
map[" outline_width_map_unit_scale" ] = QgsSymbolLayerV2Utils::encodeMapUnitScale ( mOutlineWidthMapUnitScale );
684
+ map[" joinstyle" ] = QgsSymbolLayerV2Utils::encodePenJoinStyle ( mPenJoinStyle );
667
685
map[" horizontal_anchor_point" ] = QString::number ( mHorizontalAnchorPoint );
668
686
map[" vertical_anchor_point" ] = QString::number ( mVerticalAnchorPoint );
669
687
@@ -675,7 +693,7 @@ QgsStringMap QgsSimpleMarkerSymbolLayerV2::properties() const
675
693
676
694
QgsSimpleMarkerSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::clone () const
677
695
{
678
- QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2 ( mName , mColor , mBorderColor , mSize , mAngle , mScaleMethod );
696
+ QgsSimpleMarkerSymbolLayerV2* m = new QgsSimpleMarkerSymbolLayerV2 ( mName , mColor , mBorderColor , mSize , mAngle , mScaleMethod , mPenJoinStyle );
679
697
m->setOffset ( mOffset );
680
698
m->setSizeUnit ( mSizeUnit );
681
699
m->setSizeMapUnitScale ( mSizeMapUnitScale );
0 commit comments