Skip to content
Permalink
Browse files

[FEATURE] add outline join style to ellipse markers

  • Loading branch information
nirvn authored and nyalldawson committed Apr 4, 2016
1 parent 54d093e commit 541463718d2863ca92336e40a4f74eb62da6a0e5
@@ -35,6 +35,13 @@ class QgsEllipseSymbolLayerV2 : QgsMarkerSymbolLayerV2
Qt::PenStyle outlineStyle() const;
void setOutlineStyle( Qt::PenStyle outlineStyle );

/** Get outline join style.
* @note added in 2.16 */
Qt::PenJoinStyle penJoinStyle() const;
/** Set outline join style.
* @note added in 2.16 */
void setPenJoinStyle( Qt::PenJoinStyle style );

void setOutlineWidth( double w );
double outlineWidth() const;

@@ -36,18 +36,18 @@ QgsEllipseSymbolLayerV2::QgsEllipseSymbolLayerV2()
, mSymbolHeightUnit( QgsSymbolV2::MM )
, mOutlineColor( Qt::black )
, mOutlineStyle( Qt::SolidLine )
, mPenJoinStyle( DEFAULT_ELLIPSE_JOINSTYLE )
, mOutlineWidth( 0 )
, mOutlineWidthUnit( QgsSymbolV2::MM )
{
mColor = Qt::white;
mPen.setColor( mOutlineColor );
mPen.setStyle( mOutlineStyle );
mPen.setJoinStyle( mPenJoinStyle );
mPen.setWidth( 1.0 );
mPen.setJoinStyle( Qt::MiterJoin );
mBrush.setColor( mColor );
mBrush.setStyle( Qt::SolidPattern );
mOffset = QPointF( 0, 0 );

mAngle = 0;
}

@@ -98,6 +98,10 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
{
layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["line_style"] ) );
}
if ( properties.contains( "joinstyle" ) )
{
layer->setPenJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( properties["joinstyle"] ) );
}
if ( properties.contains( "outline_width" ) )
{
layer->setOutlineWidth( properties["outline_width"].toDouble() );
@@ -224,6 +228,15 @@ void QgsEllipseSymbolLayerV2::renderPoint( QPointF point, QgsSymbolV2RenderConte
mPen.setStyle( style );
}
}
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_JOIN_STYLE ) )
{
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle ) );
QString style = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_JOIN_STYLE, context, QVariant(), &ok ).toString();
if ( ok )
{
mPen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( style ) );
}
}
if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR ) )
{
context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
@@ -337,6 +350,7 @@ void QgsEllipseSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
}
mPen.setColor( mOutlineColor );
mPen.setStyle( mOutlineStyle );
mPen.setJoinStyle( mPenJoinStyle );
mPen.setWidthF( QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), mOutlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale ) );
mBrush.setColor( mColor );
prepareExpressions( context );
@@ -481,6 +495,7 @@ QgsStringMap QgsEllipseSymbolLayerV2::properties() const
map["outline_width"] = QString::number( mOutlineWidth );
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale );
map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle );
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor );
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
@@ -15,6 +15,8 @@
#ifndef QGSELLIPSESYMBOLLAYERV2_H
#define QGSELLIPSESYMBOLLAYERV2_H

#define DEFAULT_ELLIPSE_JOINSTYLE Qt::MiterJoin

#include "qgsmarkersymbollayerv2.h"
#include <QPainterPath>

@@ -54,6 +56,13 @@ class CORE_EXPORT QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }

/** Get outline join style.
* @note added in 2.16 */
Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
/** Set outline join style.
* @note added in 2.16 */
void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }

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

@@ -99,6 +108,7 @@ class CORE_EXPORT QgsEllipseSymbolLayerV2: public QgsMarkerSymbolLayerV2
QgsMapUnitScale mSymbolHeightMapUnitScale;
QColor mOutlineColor;
Qt::PenStyle mOutlineStyle;
Qt::PenJoinStyle mPenJoinStyle;
double mOutlineWidth;
QgsSymbolV2::OutputUnit mOutlineWidthUnit;
QgsMapUnitScale mOutlineWidthMapUnitScale;
@@ -67,6 +67,7 @@ QgsEllipseSymbolLayerV2Widget::QgsEllipseSymbolLayerV2Widget( const QgsVectorLay

connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penJoinStyleChanged() ) );
}

void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
@@ -106,6 +107,7 @@ void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
spinOffsetY->setValue( offsetPt.y() );
mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
blockComboSignals( false );

registerDataDefinedButton( mSymbolWidthDDBtn, "width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
@@ -115,6 +117,7 @@ void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
registerDataDefinedButton( mFillColorDDBtn, "fill_color", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
registerDataDefinedButton( mBorderColorDDBtn, "outline_color", QgsDataDefinedButton::String, QgsDataDefinedButton::colorAlphaDesc() );
registerDataDefinedButton( mOutlineStyleDDBtn, "outline_style", QgsDataDefinedButton::String, QgsDataDefinedButton::lineStyleDesc() );
registerDataDefinedButton( mJoinStyleDDBtn, "join_style", QgsDataDefinedButton::String, QgsDataDefinedButton::penJoinStyleDesc() );
registerDataDefinedButton( mShapeDDBtn, "symbol_name", QgsDataDefinedButton::String, QgsDataDefinedButton::markerStyleDesc() );
registerDataDefinedButton( mOffsetDDBtn, "offset", QgsDataDefinedButton::String, QgsDataDefinedButton::doubleXYDesc() );
registerDataDefinedButton( mHorizontalAnchorDDBtn, "horizontal_anchor_point", QgsDataDefinedButton::String, QgsDataDefinedButton::horizontalAnchorDesc() );
@@ -249,6 +252,12 @@ void QgsEllipseSymbolLayerV2Widget::on_mOffsetUnitWidget_changed()
}
}

void QgsEllipseSymbolLayerV2Widget::penJoinStyleChanged()
{
mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
emit changed();
}

void QgsEllipseSymbolLayerV2Widget::blockComboSignals( bool block )
{
mSymbolWidthUnitWidget->blockSignals( block );
@@ -260,6 +269,7 @@ void QgsEllipseSymbolLayerV2Widget::blockComboSignals( bool block )
mOutlineWidthUnitWidget->blockSignals( block );
mSymbolHeightUnitWidget->blockSignals( block );
mOffsetUnitWidget->blockSignals( block );
cboJoinStyle->blockSignals( block );
}

void QgsEllipseSymbolLayerV2Widget::on_mHorizontalAnchorComboBox_currentIndexChanged( int index )
@@ -56,6 +56,8 @@ class GUI_EXPORT QgsEllipseSymbolLayerV2Widget: public QgsSymbolLayerV2Widget, p
void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
void on_mVerticalAnchorComboBox_currentIndexChanged( int index );

void penJoinStyleChanged();

void setOffset();
};

@@ -26,7 +26,17 @@
</property>
</widget>
</item>
<item row="7" column="1">
<item row="2" column="0">
<widget class="QLabel" name="mSymbolHeightLabel">
<property name="text">
<string>Symbol height</string>
</property>
<property name="buddy">
<cstring>mHeightSpinBox</cstring>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QComboBox" name="mHorizontalAnchorComboBox">
@@ -82,7 +92,7 @@
</item>
</layout>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="mAnchorPointLabel">
<property name="text">
<string>Anchor point</string>
@@ -92,7 +102,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Offset X,Y</string>
@@ -203,7 +213,7 @@
</item>
</layout>
</item>
<item row="5" column="1">
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QgsDoubleSpinBox" name="mHeightSpinBox">
@@ -246,7 +256,7 @@
</item>
</layout>
</item>
<item row="3" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QgsDoubleSpinBox" name="mOutlineWidthSpinBox">
@@ -289,7 +299,7 @@
</item>
</layout>
</item>
<item row="6" column="1">
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QgsDoubleSpinBox" name="spinOffsetX">
@@ -354,24 +364,14 @@
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="mSymbolHeightLabel">
<property name="text">
<string>Symbol height</string>
</property>
<property name="buddy">
<cstring>mHeightSpinBox</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Colors</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QLabel" name="mOutlineWidthLabel">
<property name="text">
<string>Outline width</string>
@@ -381,7 +381,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QLabel" name="mRotationLabel">
<property name="text">
<string>Rotation</string>
@@ -391,7 +391,7 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QgsDoubleSpinBox" name="mRotationSpinBox">
@@ -461,7 +461,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="mOutlineStyleLabel">
<property name="text">
<string>Outline style</string>
@@ -471,7 +471,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QgsPenStyleComboBox" name="mOutlineStyleComboBox"/>
@@ -485,6 +485,30 @@
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Join style</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QgsPenJoinStyleComboBox" name="cboJoinStyle"/>
</item>
<item>
<widget class="QgsDataDefinedButton" name="mJoinStyleDDBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
@@ -569,6 +593,11 @@
<header>qgsunitselectionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsPenJoinStyleComboBox</class>
<extends>QComboBox</extends>
<header>qgspenstylecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsPenStyleComboBox</class>
<extends>QComboBox</extends>
@@ -582,14 +611,16 @@
<tabstop>mBorderColorDDBtn</tabstop>
<tabstop>mWidthSpinBox</tabstop>
<tabstop>mSymbolWidthDDBtn</tabstop>
<tabstop>mHeightSpinBox</tabstop>
<tabstop>mSymbolHeightDDBtn</tabstop>
<tabstop>mOutlineStyleComboBox</tabstop>
<tabstop>mOutlineStyleDDBtn</tabstop>
<tabstop>cboJoinStyle</tabstop>
<tabstop>mJoinStyleDDBtn</tabstop>
<tabstop>mOutlineWidthSpinBox</tabstop>
<tabstop>mOutlineWidthDDBtn</tabstop>
<tabstop>mRotationSpinBox</tabstop>
<tabstop>mRotationDDBtn</tabstop>
<tabstop>mHeightSpinBox</tabstop>
<tabstop>mSymbolHeightDDBtn</tabstop>
<tabstop>spinOffsetX</tabstop>
<tabstop>spinOffsetY</tabstop>
<tabstop>mOffsetDDBtn</tabstop>

0 comments on commit 5414637

Please sign in to comment.
You can’t perform that action at this time.