Skip to content
Permalink
Browse files
Expose outline join style as a parameter for simple fill symbol type
  • Loading branch information
nyalldawson committed Apr 3, 2014
1 parent d01acce commit 6836a7ded7f02e58f4dca3a9cbd284d6022eecc8
@@ -9,8 +9,10 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH );

double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH,
Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEFILL_JOINSTYLE
);

// static stuff

static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
@@ -59,6 +61,9 @@ class QgsSimpleFillSymbolLayerV2 : QgsFillSymbolLayerV2

double borderWidth() const;
void setBorderWidth( double borderWidth );

Qt::PenJoinStyle penJoinStyle() const;
void setPenJoinStyle( Qt::PenJoinStyle style );

void setOffset( QPointF offset );
QPointF offset();
@@ -31,8 +31,14 @@
#include <QDomDocument>
#include <QDomElement>

QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2( QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth )
: mBrushStyle( style ), mBorderColor( borderColor ), mBorderStyle( borderStyle ), mBorderWidth( borderWidth ), mBorderWidthUnit( QgsSymbolV2::MM ),
QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2( QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth,
Qt::PenJoinStyle penJoinStyle ) :
mBrushStyle( style ),
mBorderColor( borderColor ),
mBorderStyle( borderStyle ),
mBorderWidth( borderWidth ),
mBorderWidthUnit( QgsSymbolV2::MM ),
mPenJoinStyle( penJoinStyle ),
mOffsetUnit( QgsSymbolV2::MM )
{
mColor = color;
@@ -84,6 +90,7 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR;
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE;
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH;
Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEFILL_JOINSTYLE;
QPointF offset;

if ( props.contains( "color" ) )
@@ -98,8 +105,10 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props
borderWidth = props["width_border"].toDouble();
if ( props.contains( "offset" ) )
offset = QgsSymbolLayerV2Utils::decodePoint( props["offset"] );
if ( props.contains( "joinstyle" ) )
penJoinStyle = QgsSymbolLayerV2Utils::decodePenJoinStyle( props["joinstyle"] );

QgsSimpleFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( color, style, borderColor, borderStyle, borderWidth );
QgsSimpleFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( color, style, borderColor, borderStyle, borderWidth, penJoinStyle );
sl->setOffset( offset );
if ( props.contains( "border_width_unit" ) )
sl->setBorderWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["border_width_unit"] ) );
@@ -155,6 +164,7 @@ void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context
mSelPen = QPen( selPenColor );
mPen.setStyle( mBorderStyle );
mPen.setWidthF( mBorderWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mBorderWidthUnit ) );
mPen.setJoinStyle( mPenJoinStyle );
prepareExpressions( context.fields(), context.renderContext().rendererScale() );
}

@@ -201,6 +211,7 @@ QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const
map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle( mBorderStyle );
map["width_border"] = QString::number( mBorderWidth );
map["border_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mBorderWidthUnit );
map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle );
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
saveDataDefinedProperties( map );
@@ -209,7 +220,7 @@ QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const

QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::clone() const
{
QgsSimpleFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth );
QgsSimpleFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth, mPenJoinStyle );
sl->setOffset( mOffset );
sl->setOffsetUnit( mOffsetUnit );
sl->setBorderWidthUnit( mBorderWidthUnit );
@@ -243,7 +254,7 @@ void QgsSimpleFillSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
// <Stroke>
QDomElement strokeElem = doc.createElement( "se:Stroke" );
symbolizerElem.appendChild( strokeElem );
QgsSymbolLayerV2Utils::lineToSld( doc, strokeElem, mBorderStyle, mBorderColor, mBorderWidth );
QgsSymbolLayerV2Utils::lineToSld( doc, strokeElem, mBorderStyle, mBorderColor, mBorderWidth, &mPenJoinStyle );
}

// <se:Displacement>
@@ -257,7 +268,7 @@ QString QgsSimpleFillSymbolLayerV2::ogrFeatureStyle( double mmScaleFactor, doubl
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStyleBrush( mColor ) );
symbolStyle.append( ";" );
//pen
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStylePen( mBorderWidth, mmScaleFactor, mapUnitScaleFactor, mBorderColor ) );
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStylePen( mBorderWidth, mmScaleFactor, mapUnitScaleFactor, mBorderColor, mPenJoinStyle ) );
return symbolStyle;
}

@@ -23,6 +23,7 @@
#define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor(0,0,0)
#define DEFAULT_SIMPLEFILL_BORDERSTYLE Qt::SolidLine
#define DEFAULT_SIMPLEFILL_BORDERWIDTH DEFAULT_LINE_WIDTH
#define DEFAULT_SIMPLEFILL_JOINSTYLE Qt::BevelJoin

#define INF 1E20

@@ -36,7 +37,9 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH );
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH,
Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEFILL_JOINSTYLE
);

// static stuff

@@ -87,6 +90,9 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
double borderWidth() const { return mBorderWidth; }
void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; }

Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }

void setOffset( QPointF offset ) { mOffset = offset; }
QPointF offset() { return mOffset; }

@@ -113,6 +119,7 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
Qt::PenStyle mBorderStyle;
double mBorderWidth;
QgsSymbolV2::OutputUnit mBorderWidthUnit;
Qt::PenJoinStyle mPenJoinStyle;
QPen mPen;
QPen mSelPen;

@@ -538,6 +538,7 @@ QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget( const QgsVec
connect( btnChangeBorderColor, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setBorderColor( const QColor& ) ) );
connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
}
@@ -558,6 +559,9 @@ void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
btnChangeBorderColor->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
cboBorderStyle->setPenStyle( mLayer->borderStyle() );
spinBorderWidth->setValue( mLayer->borderWidth() );
cboJoinStyle->blockSignals( true );
cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
cboJoinStyle->blockSignals( false );
spinOffsetX->blockSignals( true );
spinOffsetX->setValue( mLayer->offset().x() );
spinOffsetX->blockSignals( false );
@@ -605,6 +609,7 @@ void QgsSimpleFillSymbolLayerV2Widget::borderWidthChanged()
void QgsSimpleFillSymbolLayerV2Widget::borderStyleChanged()
{
mLayer->setBorderStyle( cboBorderStyle->penStyle() );
mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
emit changed();
}

0 comments on commit 6836a7d

Please sign in to comment.