2
#include "qgsfillsymbollayerv2.h"
3
#include "qgssymbollayerv2utils.h"
5
#include "qgsrendercontext.h"
9
QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2( QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth )
10
: mBrushStyle( style ), mBorderColor( borderColor ), mBorderStyle( borderStyle ), mBorderWidth( borderWidth )
16
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props )
18
QColor color = DEFAULT_SIMPLEFILL_COLOR;
19
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE;
20
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR;
21
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE;
22
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH;
24
if ( props.contains( "color" ) )
25
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
26
if ( props.contains( "style" ) )
27
style = QgsSymbolLayerV2Utils::decodeBrushStyle( props["style"] );
28
if ( props.contains( "color_border" ) )
29
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["color_border"] );
30
if ( props.contains( "style_border" ) )
31
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["style_border"] );
32
if ( props.contains( "width_border" ) )
33
borderWidth = props["width_border"].toDouble();
35
return new QgsSimpleFillSymbolLayerV2( color, style, borderColor, borderStyle, borderWidth );
39
QString QgsSimpleFillSymbolLayerV2::layerType() const
44
void QgsSimpleFillSymbolLayerV2::startRender( QgsRenderContext& context )
46
mBrush = QBrush( mColor, mBrushStyle );
47
mPen = QPen( mBorderColor );
48
mPen.setStyle( mBorderStyle );
49
mPen.setWidthF( mBorderWidth );
52
void QgsSimpleFillSymbolLayerV2::stopRender( QgsRenderContext& context )
56
void QgsSimpleFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context )
58
QPainter* p = context.painter();
59
p->setBrush( mBrush );
64
// simple polygon without holes
65
p->drawPolygon( points );
69
// polygon with holes must be drawn using painter path
71
path.addPolygon( points );
72
QList<QPolygonF>::iterator it;
73
for ( it = rings->begin(); it != rings->end(); ++it )
74
path.addPolygon( *it );
80
QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const
83
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
84
map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle( mBrushStyle );
85
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor );
86
map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle( mBorderStyle );
87
map["width_border"] = QString::number( mBorderWidth );
91
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::clone() const
93
return new QgsSimpleFillSymbolLayerV2( mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth );