Skip to content

Commit 8a1d769

Browse files
committed
#9254: QgsSimpleMarkerSymbolLayerV2 use OutlineStyle
1 parent 0625c79 commit 8a1d769

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

src/core/symbology-ng/qgsmarkersymbollayerv2.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
//////
3636

3737
QgsSimpleMarkerSymbolLayerV2::QgsSimpleMarkerSymbolLayerV2( QString name, QColor color, QColor borderColor, double size, double angle, QgsSymbolV2::ScaleMethod scaleMethod )
38-
: mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
38+
: mOutlineStyle( Qt::SolidLine ), mOutlineWidth( 0 ), mOutlineWidthUnit( QgsSymbolV2::MM )
3939
{
4040
mName = name;
4141
mColor = color;
@@ -80,6 +80,10 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop
8080
if ( props.contains( "size_unit" ) )
8181
m->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["size_unit"] ) );
8282

83+
if ( props.contains( "outline_style" ) )
84+
{
85+
m->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( props["outline_style"] ) );
86+
}
8387
if ( props.contains( "outline_width" ) )
8488
{
8589
m->setOutlineWidth( props["outline_width"].toDouble() );
@@ -154,6 +158,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
154158

155159
mBrush = QBrush( brushColor );
156160
mPen = QPen( penColor );
161+
mPen.setStyle( mOutlineStyle );
157162
mPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) );
158163

159164
QColor selBrushColor = context.renderContext().selectionColor();
@@ -165,6 +170,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
165170
}
166171
mSelBrush = QBrush( selBrushColor );
167172
mSelPen = QPen( selPenColor );
173+
mSelPen.setStyle( mOutlineStyle );
168174
mSelPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) );
169175

170176
bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation || dataDefinedProperty( "angle" );
@@ -567,6 +573,7 @@ QgsStringMap QgsSimpleMarkerSymbolLayerV2::properties() const
567573
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
568574
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
569575
map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod );
576+
map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle );
570577
map["outline_width"] = QString::number( mOutlineWidth );
571578
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
572579
map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint );
@@ -583,6 +590,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::clone() const
583590
m->setOffset( mOffset );
584591
m->setSizeUnit( mSizeUnit );
585592
m->setOffsetUnit( mOffsetUnit );
593+
m->setOutlineStyle( mOutlineStyle );
586594
m->setOutlineWidth( mOutlineWidth );
587595
m->setOutlineWidthUnit( mOutlineWidthUnit );
588596
m->setHorizontalAnchorPoint( mHorizontalAnchorPoint );

src/core/symbology-ng/qgsmarkersymbollayerv2.h

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
7070
QColor borderColor() const { return mBorderColor; }
7171
void setBorderColor( QColor color ) { mBorderColor = color; }
7272

73+
Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
74+
void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }
75+
7376
double outlineWidth() const { return mOutlineWidth; }
7477
void setOutlineWidth( double w ) { mOutlineWidth = w; }
7578

@@ -90,6 +93,7 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
9093
bool prepareCache( QgsSymbolV2RenderContext& context );
9194

9295
QColor mBorderColor;
96+
Qt::PenStyle mOutlineStyle;
9397
double mOutlineWidth;
9498
QgsSymbolV2::OutputUnit mOutlineWidthUnit;
9599
QPen mPen;

src/gui/symbology-ng/qgssymbollayerv2widget.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer
301301
btnChangeColorFill->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
302302
spinSize->setValue( mLayer->size() );
303303
spinAngle->setValue( mLayer->angle() );
304+
mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
304305
mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );
305306

306307
// without blocking signals the value gets changed because of slot setOffset()
@@ -371,6 +372,15 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setOffset()
371372
emit changed();
372373
}
373374

375+
void QgsSimpleMarkerSymbolLayerV2Widget::on_mOutlineStyleComboBox_currentIndexChanged( int index )
376+
{
377+
if ( mLayer )
378+
{
379+
mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
380+
emit changed();
381+
}
382+
}
383+
374384
void QgsSimpleMarkerSymbolLayerV2Widget::on_mOutlineWidthSpinBox_valueChanged( double d )
375385
{
376386
if ( mLayer )

src/gui/symbology-ng/qgssymbollayerv2widget.h

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class GUI_EXPORT QgsSimpleMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
109109
void on_mOffsetUnitComboBox_currentIndexChanged( int index );
110110
void on_mOutlineWidthUnitComboBox_currentIndexChanged( int index );
111111
void on_mDataDefinedPropertiesButton_clicked();
112+
void on_mOutlineStyleComboBox_currentIndexChanged( int index );
112113
void on_mOutlineWidthSpinBox_valueChanged( double d );
113114
void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
114115
void on_mVerticalAnchorComboBox_currentIndexChanged( int index );

src/ui/symbollayer/widget_simplemarker.ui

+19-9
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,23 @@
141141
</layout>
142142
</item>
143143
<item row="2" column="0">
144+
<widget class="QLabel" name="mOutlineStyleLabel">
145+
<property name="text">
146+
<string>Outline style</string>
147+
</property>
148+
</widget>
149+
</item>
150+
<item row="2" column="1">
151+
<widget class="QgsPenStyleComboBox" name="mOutlineStyleComboBox"/>
152+
</item>
153+
<item row="3" column="0">
144154
<widget class="QLabel" name="mOutlineWidthLabel">
145155
<property name="text">
146156
<string>Outline width</string>
147157
</property>
148158
</widget>
149159
</item>
150-
<item row="2" column="1">
160+
<item row="3" column="1">
151161
<layout class="QHBoxLayout" name="horizontalLayout_4">
152162
<item>
153163
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
@@ -175,14 +185,14 @@
175185
</item>
176186
</layout>
177187
</item>
178-
<item row="3" column="0">
188+
<item row="4" column="0">
179189
<widget class="QLabel" name="label_4">
180190
<property name="text">
181191
<string>Angle</string>
182192
</property>
183193
</widget>
184194
</item>
185-
<item row="3" column="1">
195+
<item row="4" column="1">
186196
<widget class="QDoubleSpinBox" name="spinAngle">
187197
<property name="suffix">
188198
<string> °</string>
@@ -198,14 +208,14 @@
198208
</property>
199209
</widget>
200210
</item>
201-
<item row="4" column="0">
211+
<item row="5" column="0">
202212
<widget class="QLabel" name="label_5">
203213
<property name="text">
204214
<string>Offset X,Y</string>
205215
</property>
206216
</widget>
207217
</item>
208-
<item row="4" column="1">
218+
<item row="5" column="1">
209219
<layout class="QHBoxLayout" name="horizontalLayout">
210220
<item>
211221
<widget class="QDoubleSpinBox" name="spinOffsetX">
@@ -255,14 +265,14 @@
255265
</item>
256266
</layout>
257267
</item>
258-
<item row="5" column="0">
268+
<item row="6" column="0">
259269
<widget class="QLabel" name="mAnchorPointLabel">
260270
<property name="text">
261271
<string>Anchor point</string>
262272
</property>
263273
</widget>
264274
</item>
265-
<item row="5" column="1">
275+
<item row="6" column="1">
266276
<layout class="QHBoxLayout" name="horizontalLayout_5">
267277
<item>
268278
<widget class="QComboBox" name="mHorizontalAnchorComboBox">
@@ -304,7 +314,7 @@
304314
</item>
305315
</layout>
306316
</item>
307-
<item row="6" column="0" colspan="2">
317+
<item row="7" column="0" colspan="2">
308318
<widget class="QPushButton" name="mDataDefinedPropertiesButton">
309319
<property name="sizePolicy">
310320
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -317,7 +327,7 @@
317327
</property>
318328
</widget>
319329
</item>
320-
<item row="7" column="0" colspan="2">
330+
<item row="8" column="0" colspan="2">
321331
<widget class="QListWidget" name="lstNames">
322332
<property name="sizePolicy">
323333
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">

0 commit comments

Comments
 (0)