Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#9254: QgsSimpleMarkerSymbolLayerV2 use OutlineStyle
  • Loading branch information
ahuarte47 committed Jan 2, 2014
1 parent 0625c79 commit 8a1d769
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Expand Up @@ -35,7 +35,7 @@
//////

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

if ( props.contains( "outline_style" ) )
{
m->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( props["outline_style"] ) );
}
if ( props.contains( "outline_width" ) )
{
m->setOutlineWidth( props["outline_width"].toDouble() );
Expand Down Expand Up @@ -154,6 +158,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex

mBrush = QBrush( brushColor );
mPen = QPen( penColor );
mPen.setStyle( mOutlineStyle );
mPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) );

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

bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation || dataDefinedProperty( "angle" );
Expand Down Expand Up @@ -567,6 +573,7 @@ QgsStringMap QgsSimpleMarkerSymbolLayerV2::properties() const
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod );
map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle );
map["outline_width"] = QString::number( mOutlineWidth );
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint );
Expand All @@ -583,6 +590,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::clone() const
m->setOffset( mOffset );
m->setSizeUnit( mSizeUnit );
m->setOffsetUnit( mOffsetUnit );
m->setOutlineStyle( mOutlineStyle );
m->setOutlineWidth( mOutlineWidth );
m->setOutlineWidthUnit( mOutlineWidthUnit );
m->setHorizontalAnchorPoint( mHorizontalAnchorPoint );
Expand Down
4 changes: 4 additions & 0 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.h
Expand Up @@ -70,6 +70,9 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
QColor borderColor() const { return mBorderColor; }
void setBorderColor( QColor color ) { mBorderColor = color; }

Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }

double outlineWidth() const { return mOutlineWidth; }
void setOutlineWidth( double w ) { mOutlineWidth = w; }

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

QColor mBorderColor;
Qt::PenStyle mOutlineStyle;
double mOutlineWidth;
QgsSymbolV2::OutputUnit mOutlineWidthUnit;
QPen mPen;
Expand Down
10 changes: 10 additions & 0 deletions src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Expand Up @@ -301,6 +301,7 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer
btnChangeColorFill->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
spinSize->setValue( mLayer->size() );
spinAngle->setValue( mLayer->angle() );
mOutlineStyleComboBox->setPenStyle( mLayer->outlineStyle() );
mOutlineWidthSpinBox->setValue( mLayer->outlineWidth() );

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

void QgsSimpleMarkerSymbolLayerV2Widget::on_mOutlineStyleComboBox_currentIndexChanged( int index )
{
if ( mLayer )
{
mLayer->setOutlineStyle( mOutlineStyleComboBox->penStyle() );
emit changed();
}
}

void QgsSimpleMarkerSymbolLayerV2Widget::on_mOutlineWidthSpinBox_valueChanged( double d )
{
if ( mLayer )
Expand Down
1 change: 1 addition & 0 deletions src/gui/symbology-ng/qgssymbollayerv2widget.h
Expand Up @@ -109,6 +109,7 @@ class GUI_EXPORT QgsSimpleMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
void on_mOffsetUnitComboBox_currentIndexChanged( int index );
void on_mOutlineWidthUnitComboBox_currentIndexChanged( int index );
void on_mDataDefinedPropertiesButton_clicked();
void on_mOutlineStyleComboBox_currentIndexChanged( int index );
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
Expand Down
28 changes: 19 additions & 9 deletions src/ui/symbollayer/widget_simplemarker.ui
Expand Up @@ -141,13 +141,23 @@
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mOutlineStyleLabel">
<property name="text">
<string>Outline style</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsPenStyleComboBox" name="mOutlineStyleComboBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mOutlineWidthLabel">
<property name="text">
<string>Outline width</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QDoubleSpinBox" name="mOutlineWidthSpinBox">
Expand Down Expand Up @@ -175,14 +185,14 @@
</item>
</layout>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Angle</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="spinAngle">
<property name="suffix">
<string> °</string>
Expand All @@ -198,14 +208,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Offset X,Y</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDoubleSpinBox" name="spinOffsetX">
Expand Down Expand Up @@ -255,14 +265,14 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="mAnchorPointLabel">
<property name="text">
<string>Anchor point</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="mHorizontalAnchorComboBox">
Expand Down Expand Up @@ -304,7 +314,7 @@
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QPushButton" name="mDataDefinedPropertiesButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
Expand All @@ -317,7 +327,7 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QListWidget" name="lstNames">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
Expand Down

0 comments on commit 8a1d769

Please sign in to comment.