24 #include <QDomDocument>
25 #include <QDomElement>
28 mSymbolHeightUnit(
QgsSymbolV2::MM ), mFillColor( Qt::white ), mOutlineColor( Qt::black ), mOutlineWidth( 0 ), mOutlineWidthUnit(
QgsSymbolV2::MM )
32 mPen.setJoinStyle( Qt::MiterJoin );
34 mBrush.setStyle( Qt::SolidPattern );
47 if ( properties.contains(
"symbol_name" ) )
51 if ( properties.contains(
"symbol_width" ) )
55 if ( properties.contains(
"symbol_width_unit" ) )
59 if ( properties.contains(
"symbol_height" ) )
63 if ( properties.contains(
"symbol_height_unit" ) )
67 if ( properties.contains(
"angle" ) )
69 layer->
setAngle( properties[
"angle"].toDouble() );
71 if ( properties.contains(
"outline_width" ) )
75 if ( properties.contains(
"outline_width_unit" ) )
79 if ( properties.contains(
"fill_color" ) )
83 if ( properties.contains(
"outline_color" ) )
87 if ( properties.contains(
"offset" ) )
91 if ( properties.contains(
"offset_unit" ) )
97 if ( properties.contains(
"width_expression" ) )
101 if ( properties.contains(
"height_expression" ) )
105 if ( properties.contains(
"rotation_expression" ) )
109 if ( properties.contains(
"outline_width_expression" ) )
113 if ( properties.contains(
"fill_color_expression" ) )
117 if ( properties.contains(
"outline_color_expression" ) )
121 if ( properties.contains(
"symbol_name_expression" ) )
125 if ( properties.contains(
"offset_expression" ) )
131 if ( !properties[
"width_field"].isEmpty() )
135 if ( !properties[
"height_field"].isEmpty() )
139 if ( !properties[
"rotation_field"].isEmpty() )
143 if ( !properties[
"outline_width_field"].isEmpty() )
147 if ( !properties[
"fill_color_field"].isEmpty() )
151 if ( !properties[
"outline_color_field"].isEmpty() )
155 if ( !properties[
"symbol_name_field"].isEmpty() )
173 if ( outlineWidthExpression )
175 double width = outlineWidthExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
177 mPen.setWidthF( width );
179 if ( fillColorExpression )
181 QString colorString = fillColorExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
182 mBrush.setColor( QColor( colorString ) );
184 if ( outlineColorExpression )
186 QString colorString = outlineColorExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
187 mPen.setColor( QColor( colorString ) );
189 if ( widthExpression || heightExpression || symbolNameExpression )
192 if ( symbolNameExpression )
194 symbolName = symbolNameExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toString();
203 QPointF off( offsetX, offsetY );
212 double rotation = 0.0;
213 if ( rotationExpression )
215 rotation = rotationExpression->
evaluate( const_cast<QgsFeature*>( context.
feature() ) ).toDouble();
225 transform.translate( point.x() + off.x(), point.y() + off.y() );
228 transform.rotate( rotation );
238 return "EllipseMarker";
264 QDomElement symbolizerElem = doc.createElement(
"se:PointSymbolizer" );
265 if ( !props.value(
"uom",
"" ).isEmpty() )
266 symbolizerElem.setAttribute(
"uom", props.value(
"uom",
"" ) );
267 element.appendChild( symbolizerElem );
278 QDomElement graphicElem = doc.createElement(
"se:Graphic" );
279 element.appendChild( graphicElem );
286 graphicElem.appendChild( factorElem );
290 QString angleFunc = props.value(
"angle",
"" );
291 if ( angleFunc.isEmpty() )
294 if ( rotationExpression )
295 angleFunc = rotationExpression->
dump();
297 angleFunc = QString::number(
mAngle );
299 else if ( rotationExpression )
303 angleFunc = QString(
"%1 + %2" ).arg( angleFunc ).arg( rotationExpression->
dump() );
309 double angle = angleFunc.toDouble( &ok );
313 angleFunc = QString(
"%1 + %2" ).arg( angleFunc ).arg(
mAngle );
318 angleFunc = QString::number( angle +
mAngle );
328 QDomElement graphicElem = element.firstChildElement(
"Graphic" );
329 if ( graphicElem.isNull() )
332 QString name =
"circle";
334 double borderWidth,
size;
335 double widthHeightFactor = 1.0;
338 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
340 if ( it.key() ==
"widthHeightFactor" )
343 double v = it.value().toDouble( &ok );
345 widthHeightFactor = v;
357 double d = angleFunc.toDouble( &ok );
381 map[
"angle"] = QString::number(
mAngle );
407 if ( widthExpression )
409 width = widthExpression->
evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
423 if ( heightExpression )
425 height = heightExpression->
evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
437 if ( symbolName ==
"circle" )
439 mPainterPath.addEllipse( QRectF( -width / 2.0, -height / 2.0, width, height ) );
441 else if ( symbolName ==
"rectangle" )
443 mPainterPath.addRect( QRectF( -width / 2.0, -height / 2.0, width, height ) );
445 else if ( symbolName ==
"cross" )
452 else if ( symbolName ==
"triangle" )