QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsellipsesymbollayerv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsellipsesymbollayerv2.cpp
3  ---------------------
4  begin : June 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
16 #include "qgsdxfexport.h"
17 #include "qgsexpression.h"
18 #include "qgsfeature.h"
19 #include "qgsrendercontext.h"
20 #include "qgsvectorlayer.h"
21 #include "qgsdatadefined.h"
22 #include "qgslogger.h"
23 #include "qgsunittypes.h"
24 
25 #include <QPainter>
26 #include <QSet>
27 #include <QDomDocument>
28 #include <QDomElement>
29 
32  , mSymbolName( "circle" )
33  , mSymbolWidth( 4 )
34  , mSymbolWidthUnit( QgsSymbolV2::MM )
35  , mSymbolHeight( 3 )
36  , mSymbolHeightUnit( QgsSymbolV2::MM )
37  , mOutlineColor( Qt::black )
38  , mOutlineStyle( Qt::SolidLine )
39  , mPenJoinStyle( DEFAULT_ELLIPSE_JOINSTYLE )
40  , mOutlineWidth( 0 )
41  , mOutlineWidthUnit( QgsSymbolV2::MM )
42 {
43  mColor = Qt::white;
44  mPen.setColor( mOutlineColor );
45  mPen.setStyle( mOutlineStyle );
46  mPen.setJoinStyle( mPenJoinStyle );
47  mPen.setWidth( 1.0 );
48  mBrush.setColor( mColor );
49  mBrush.setStyle( Qt::SolidPattern );
50  mOffset = QPointF( 0, 0 );
51  mAngle = 0;
52 }
53 
55 {
56 }
57 
59 {
61  if ( properties.contains( "symbol_name" ) )
62  {
63  layer->setSymbolName( properties[ "symbol_name" ] );
64  }
65  if ( properties.contains( "symbol_width" ) )
66  {
67  layer->setSymbolWidth( properties["symbol_width"].toDouble() );
68  }
69  if ( properties.contains( "symbol_width_unit" ) )
70  {
71  layer->setSymbolWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_width_unit"] ) );
72  }
73  if ( properties.contains( "symbol_width_map_unit_scale" ) )
74  {
75  layer->setSymbolWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["symbol_width_map_unit_scale"] ) );
76  }
77  if ( properties.contains( "symbol_height" ) )
78  {
79  layer->setSymbolHeight( properties["symbol_height"].toDouble() );
80  }
81  if ( properties.contains( "symbol_height_unit" ) )
82  {
83  layer->setSymbolHeightUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["symbol_height_unit"] ) );
84  }
85  if ( properties.contains( "symbol_height_map_unit_scale" ) )
86  {
87  layer->setSymbolHeightMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["symbol_height_map_unit_scale"] ) );
88  }
89  if ( properties.contains( "angle" ) )
90  {
91  layer->setAngle( properties["angle"].toDouble() );
92  }
93  if ( properties.contains( "outline_style" ) )
94  {
95  layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["outline_style"] ) );
96  }
97  else if ( properties.contains( "line_style" ) )
98  {
99  layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["line_style"] ) );
100  }
101  if ( properties.contains( "joinstyle" ) )
102  {
103  layer->setPenJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( properties["joinstyle"] ) );
104  }
105  if ( properties.contains( "outline_width" ) )
106  {
107  layer->setOutlineWidth( properties["outline_width"].toDouble() );
108  }
109  else if ( properties.contains( "line_width" ) )
110  {
111  layer->setOutlineWidth( properties["line_width"].toDouble() );
112  }
113  if ( properties.contains( "outline_width_unit" ) )
114  {
115  layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) );
116  }
117  else if ( properties.contains( "line_width_unit" ) )
118  {
119  layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["line_width_unit"] ) );
120  }
121  if ( properties.contains( "outline_width_map_unit_scale" ) )
122  {
123  layer->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["outline_width_map_unit_scale"] ) );
124  }
125  if ( properties.contains( "fill_color" ) )
126  {
127  //pre 2.5 projects used "fill_color"
128  layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["fill_color"] ) );
129  }
130  else if ( properties.contains( "color" ) )
131  {
132  layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["color"] ) );
133  }
134  if ( properties.contains( "outline_color" ) )
135  {
136  layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) );
137  }
138  else if ( properties.contains( "line_color" ) )
139  {
140  layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["line_color"] ) );
141  }
142  if ( properties.contains( "size" ) )
143  {
144  layer->setSize( properties["size"].toDouble() );
145  }
146  if ( properties.contains( "size_unit" ) )
147  {
148  layer->setSizeUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["size_unit"] ) );
149  }
150  if ( properties.contains( "size_map_unit_scale" ) )
151  {
152  layer->setSizeMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["size_map_unit_scale"] ) );
153  }
154  if ( properties.contains( "offset" ) )
155  {
156  layer->setOffset( QgsSymbolLayerV2Utils::decodePoint( properties["offset"] ) );
157  }
158  if ( properties.contains( "offset_unit" ) )
159  {
160  layer->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["offset_unit"] ) );
161  }
162  if ( properties.contains( "offset_map_unit_scale" ) )
163  {
164  layer->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["offset_map_unit_scale"] ) );
165  }
166  if ( properties.contains( "horizontal_anchor_point" ) )
167  {
168  layer->setHorizontalAnchorPoint( QgsMarkerSymbolLayerV2::HorizontalAnchorPoint( properties[ "horizontal_anchor_point" ].toInt() ) );
169  }
170  if ( properties.contains( "vertical_anchor_point" ) )
171  {
172  layer->setVerticalAnchorPoint( QgsMarkerSymbolLayerV2::VerticalAnchorPoint( properties[ "vertical_anchor_point" ].toInt() ) );
173  }
174 
175  //data defined properties
176  layer->restoreDataDefinedProperties( properties );
177 
178  //compatibility with old project file format
179  if ( !properties["width_field"].isEmpty() )
180  {
181  layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH, new QgsDataDefined( properties["width_field"] ) );
182  }
183  if ( !properties["height_field"].isEmpty() )
184  {
185  layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT, new QgsDataDefined( properties["height_field"] ) );
186  }
187  if ( !properties["rotation_field"].isEmpty() )
188  {
189  layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, new QgsDataDefined( properties["rotation_field"] ) );
190  }
191  if ( !properties["outline_width_field"].isEmpty() )
192  {
193  layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, new QgsDataDefined( properties[ "outline_width_field" ] ) );
194  }
195  if ( !properties["fill_color_field"].isEmpty() )
196  {
197  layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, new QgsDataDefined( properties["fill_color_field"] ) );
198  }
199  if ( !properties["outline_color_field"].isEmpty() )
200  {
201  layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, new QgsDataDefined( properties["outline_color_field"] ) );
202  }
203  if ( !properties["symbol_name_field"].isEmpty() )
204  {
205  layer->setDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, new QgsDataDefined( properties["symbol_name_field"] ) );
206  }
207 
208  return layer;
209 }
210 
212 {
213  bool ok;
215  {
216  context.setOriginalValueVariable( mOutlineWidth );
217  double width = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble();
218  width = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), width, mOutlineWidthUnit, mOutlineWidthMapUnitScale );
219  mPen.setWidthF( width );
220  }
222  {
225  if ( ok )
226  {
227  Qt::PenStyle style = QgsSymbolLayerV2Utils::decodePenStyle( styleString );
228  mPen.setStyle( style );
229  }
230  }
232  {
235  if ( ok )
236  {
238  }
239  }
241  {
244  if ( ok )
245  {
247  if ( context.alpha() < 1.0 )
248  {
249  fillColor.setAlphaF( fillColor.alphaF() * context.alpha() );
250  }
251  mBrush.setColor( fillColor );
252  }
253  }
255  {
258  if ( ok )
259  {
261  if ( context.alpha() < 1.0 )
262  {
263  outlineColor.setAlphaF( outlineColor.alphaF() * context.alpha() );
264  }
265  mPen.setColor( outlineColor );
266  }
267  }
268  double scaledWidth = mSymbolWidth;
269  double scaledHeight = mSymbolHeight;
271  {
272  QString symbolName = mSymbolName;
274  {
275  context.setOriginalValueVariable( mSymbolName );
276  symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, context, mSymbolName ).toString();
277  }
278  preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() );
279  }
280 
281  //offset and rotation
282  bool hasDataDefinedRotation = false;
283  QPointF offset;
284  double angle = 0;
285  calculateOffsetAndRotation( context, scaledWidth, scaledHeight, hasDataDefinedRotation, offset, angle );
286 
287  QPainter* p = context.renderContext().painter();
288  if ( !p )
289  {
290  return;
291  }
292 
293  QMatrix transform;
294  transform.translate( point.x() + offset.x(), point.y() + offset.y() );
295  if ( !qgsDoubleNear( angle, 0.0 ) )
296  {
297  transform.rotate( angle );
298  }
299 
300  p->setPen( mPen );
301  p->setBrush( mBrush );
302  p->drawPath( transform.map( mPainterPath ) );
303 }
304 
305 
306 void QgsEllipseSymbolLayerV2::calculateOffsetAndRotation( QgsSymbolV2RenderContext& context,
307  double scaledWidth,
308  double scaledHeight,
309  bool& hasDataDefinedRotation,
310  QPointF& offset,
311  double& angle ) const
312 {
313  double offsetX = 0;
314  double offsetY = 0;
315  markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale );
316  offset = QPointF( offsetX, offsetY );
317 
318 //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
319  bool ok = true;
320  angle = mAngle + mLineAngle;
321  bool usingDataDefinedRotation = false;
323  {
324  context.setOriginalValueVariable( angle );
326  usingDataDefinedRotation = ok;
327  }
328 
329  hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation || usingDataDefinedRotation;
330  if ( hasDataDefinedRotation )
331  {
332  // For non-point markers, "dataDefinedRotation" means following the
333  // shape (shape-data defined). For them, "field-data defined" does
334  // not work at all. TODO: if "field-data defined" ever gets implemented
335  // we'll need a way to distinguish here between the two, possibly
336  // using another flag in renderHints()
337  const QgsFeature* f = context.feature();
338  if ( f )
339  {
340  const QgsGeometry *g = f->constGeometry();
341  if ( g && g->type() == QGis::Point )
342  {
343  const QgsMapToPixel& m2p = context.renderContext().mapToPixel();
344  angle += m2p.mapRotation();
345  }
346  }
347  }
348 
349  if ( angle )
350  offset = _rotatedOffset( offset, angle );
351 }
352 
354 {
355  return "EllipseMarker";
356 }
357 
359 {
360  QgsMarkerSymbolLayerV2::startRender( context ); // get anchor point expressions
361  if ( !context.feature() || !hasDataDefinedProperties() )
362  {
363  preparePath( mSymbolName, context );
364  }
365 
366  QColor outlineColor = mOutlineColor;
368 
369  if ( context.alpha() < 1.0 )
370  {
371  outlineColor.setAlphaF( mOutlineColor.alphaF() * context.alpha() );
372  fillColor.setAlphaF( mColor.alphaF() * context.alpha() );
373  }
374 
375  mPen.setColor( outlineColor );
376  mPen.setStyle( mOutlineStyle );
377  mPen.setJoinStyle( mPenJoinStyle );
378  mPen.setWidthF( QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), mOutlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale ) );
379  mBrush.setColor( fillColor );
380  prepareExpressions( context );
381 }
382 
384 {
385 }
386 
388 {
390  m->setSymbolName( mSymbolName );
391  m->setSymbolWidth( mSymbolWidth );
392  m->setSymbolHeight( mSymbolHeight );
393  m->setOutlineStyle( mOutlineStyle );
394  m->setOffset( mOffset );
397  m->setOutlineStyle( mOutlineStyle );
398  m->setPenJoinStyle( mPenJoinStyle );
399  m->setOutlineWidth( mOutlineWidth );
400  m->setColor( color() );
401  m->setOutlineColor( mOutlineColor );
402  m->setSymbolWidthUnit( mSymbolWidthUnit );
403  m->setSymbolWidthMapUnitScale( mSymbolWidthMapUnitScale );
404  m->setSymbolHeightUnit( mSymbolHeightUnit );
405  m->setSymbolHeightMapUnitScale( mSymbolHeightMapUnitScale );
406  m->setOutlineWidthUnit( mOutlineWidthUnit );
407  m->setOutlineWidthMapUnitScale( mOutlineWidthMapUnitScale );
408  m->setAngle( mAngle );
411 
413  copyPaintEffect( m );
414  return m;
415 }
416 
417 void QgsEllipseSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const
418 {
419  QDomElement symbolizerElem = doc.createElement( "se:PointSymbolizer" );
420  if ( !props.value( "uom", "" ).isEmpty() )
421  symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
422  element.appendChild( symbolizerElem );
423 
424  // <Geometry>
425  QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );
426 
427  writeSldMarker( doc, symbolizerElem, props );
428 }
429 
431 {
432  // <Graphic>
433  QDomElement graphicElem = doc.createElement( "se:Graphic" );
434  element.appendChild( graphicElem );
435 
436  double outlineWidth = QgsSymbolLayerV2Utils::rescaleUom( mOutlineWidth, mOutlineWidthUnit, props );
437  double symbolWidth = QgsSymbolLayerV2Utils::rescaleUom( mSymbolWidth, mSymbolWidthUnit, props );
438  QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, mSymbolName, mColor, mOutlineColor, mOutlineStyle, outlineWidth, symbolWidth );
439 
440  // <Rotation>
442 
443  QString angleFunc = props.value( "angle", "" );
444  if ( angleFunc.isEmpty() ) // symbol has no angle set
445  {
446  if ( ddRotation && ddRotation->isActive() )
447  {
448  angleFunc = ddRotation->useExpression() ? ddRotation->expressionString() : ddRotation->field();
449  }
450  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
451  angleFunc = QString::number( mAngle );
452  }
453  else if ( ddRotation && ddRotation->isActive() )
454  {
455  // the symbol has an angle and the symbol layer have a rotation
456  // property set
457  angleFunc = QString( "%1 + %2" ).arg( angleFunc, ddRotation->useExpression() ? ddRotation->expressionString() : ddRotation->field() );
458  }
459  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
460  {
461  // both the symbol and the symbol layer have angle value set
462  bool ok;
463  double angle = angleFunc.toDouble( &ok );
464  if ( !ok )
465  {
466  // its a string (probably a property name or a function)
467  angleFunc = QString( "%1 + %2" ).arg( angleFunc ).arg( mAngle );
468  }
469  else if ( !qgsDoubleNear( angle + mAngle, 0.0 ) )
470  {
471  // it's a double value
472  angleFunc = QString::number( angle + mAngle );
473  }
474  }
475  QgsSymbolLayerV2Utils::createRotationElement( doc, graphicElem, angleFunc );
476  QgsSymbolLayerV2Utils::createRotationElement( doc, graphicElem, angleFunc );
477 
478  // <Displacement>
480  QgsSymbolLayerV2Utils::createDisplacementElement( doc, graphicElem, offset );
481 
482  // store w/h factor in a <VendorOption>
483  double widthHeightFactor = mSymbolWidth / mSymbolHeight;
484  QDomElement factorElem = QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "widthHeightFactor", QString::number( widthHeightFactor ) );
485  graphicElem.appendChild( factorElem );
486 }
487 
489 {
490  QgsDebugMsg( "Entered." );
491 
492  QDomElement graphicElem = element.firstChildElement( "Graphic" );
493  if ( graphicElem.isNull() )
494  return nullptr;
495 
496  QString name = "circle";
497  QColor fillColor, borderColor;
498  double borderWidth, size;
499  double widthHeightFactor = 1.0;
500  Qt::PenStyle borderStyle;
501 
502  QgsStringMap vendorOptions = QgsSymbolLayerV2Utils::getVendorOptionList( graphicElem );
503  for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
504  {
505  if ( it.key() == "widthHeightFactor" )
506  {
507  bool ok;
508  double v = it.value().toDouble( &ok );
509  if ( ok && !qgsDoubleNear( v, 0.0 ) && v > 0 )
510  widthHeightFactor = v;
511  }
512  }
513 
514  if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
515  return nullptr;
516 
517  const QString uom = element.attribute( QString( "uom" ), "" );
519  borderWidth = QgsSymbolLayerV2Utils::sizeInPixelsFromSldUom( uom, borderWidth );
520 
521  double angle = 0.0;
522  QString angleFunc;
523  if ( QgsSymbolLayerV2Utils::rotationFromSldElement( graphicElem, angleFunc ) )
524  {
525  bool ok;
526  double d = angleFunc.toDouble( &ok );
527  if ( ok )
528  angle = d;
529  }
530 
533  m->setSymbolName( name );
534  m->setFillColor( fillColor );
535  m->setOutlineColor( borderColor );
536  m->setOutlineStyle( borderStyle );
537  m->setOutlineWidth( borderWidth );
538  m->setSymbolWidth( size );
539  m->setSymbolHeight( size / widthHeightFactor );
540  m->setAngle( angle );
541  return m;
542 }
543 
545 {
546  QgsStringMap map;
547  map["symbol_name"] = mSymbolName;
548  map["symbol_width"] = QString::number( mSymbolWidth );
549  map["symbol_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolWidthUnit );
550  map["symbol_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSymbolWidthMapUnitScale );
551  map["symbol_height"] = QString::number( mSymbolHeight );
552  map["symbol_height_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSymbolHeightUnit );
553  map["symbol_height_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSymbolHeightMapUnitScale );
554  map["angle"] = QString::number( mAngle );
555  map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle );
556  map["outline_width"] = QString::number( mOutlineWidth );
557  map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
558  map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale );
559  map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle );
560  map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
561  map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor );
562  map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
564  map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale );
565  map["size"] = QString::number( mSize );
567  map["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale );
568  map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint );
569  map["vertical_anchor_point"] = QString::number( mVerticalAnchorPoint );
571  return map;
572 }
573 
574 QSizeF QgsEllipseSymbolLayerV2::calculateSize( QgsSymbolV2RenderContext& context, double* scaledWidth, double* scaledHeight )
575 {
576  double width = 0;
577 
578  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH ) ) //1. priority: data defined setting on symbol layer le
579  {
580  context.setOriginalValueVariable( mSymbolWidth );
581  width = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH, context, mSymbolWidth ).toDouble();
582  }
583  else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
584  {
585  width = mSize;
586  }
587  else //3. priority: global width setting
588  {
589  width = mSymbolWidth;
590  }
591  if ( scaledWidth )
592  {
593  *scaledWidth = width;
594  }
595  width = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), width, mSymbolWidthUnit, mSymbolHeightMapUnitScale );
596 
597  double height = 0;
598  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT ) ) //1. priority: data defined setting on symbol layer level
599  {
600  context.setOriginalValueVariable( mSymbolHeight );
601  height = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT, context, mSymbolHeight ).toDouble();
602  }
603  else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
604  {
605  height = mSize;
606  }
607  else //3. priority: global height setting
608  {
609  height = mSymbolHeight;
610  }
611  if ( scaledHeight )
612  {
613  *scaledHeight = height;
614  }
615  height = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), height, mSymbolHeightUnit, mSymbolHeightMapUnitScale );
616  return QSizeF( width, height );
617 }
618 
619 void QgsEllipseSymbolLayerV2::preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, double* scaledWidth, double* scaledHeight, const QgsFeature* )
620 {
621  mPainterPath = QPainterPath();
622 
623  QSizeF size = calculateSize( context, scaledWidth, scaledHeight );
624 
625  if ( symbolName == "circle" )
626  {
627  mPainterPath.addEllipse( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
628  }
629  else if ( symbolName == "semi_circle" )
630  {
631  mPainterPath.arcTo( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height(), 0, 180 );
632  mPainterPath.lineTo( 0, 0 );
633  }
634  else if ( symbolName == "rectangle" )
635  {
636  mPainterPath.addRect( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
637  }
638  else if ( symbolName == "diamond" )
639  {
640  mPainterPath.moveTo( -size.width() / 2.0, 0 );
641  mPainterPath.lineTo( 0, size.height() / 2.0 );
642  mPainterPath.lineTo( size.width() / 2.0, 0 );
643  mPainterPath.lineTo( 0, -size.height() / 2.0 );
644  mPainterPath.lineTo( -size.width() / 2.0, 0 );
645  }
646  else if ( symbolName == "cross" )
647  {
648  mPainterPath.moveTo( 0, -size.height() / 2.0 );
649  mPainterPath.lineTo( 0, size.height() / 2.0 );
650  mPainterPath.moveTo( -size.width() / 2.0, 0 );
651  mPainterPath.lineTo( size.width() / 2.0, 0 );
652  }
653  else if ( symbolName == "triangle" )
654  {
655  mPainterPath.moveTo( 0, -size.height() / 2.0 );
656  mPainterPath.lineTo( -size.width() / 2.0, size.height() / 2.0 );
657  mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
658  mPainterPath.lineTo( 0, -size.height() / 2.0 );
659  }
660  else if ( symbolName == "left_half_triangle" )
661  {
662  mPainterPath.moveTo( 0, size.height() / 2.0 );
663  mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
664  mPainterPath.lineTo( 0, -size.height() / 2.0 );
665  mPainterPath.lineTo( 0, size.height() / 2.0 );
666  }
667  else if ( symbolName == "right_half_triangle" )
668  {
669  mPainterPath.moveTo( -size.width() / 2.0, size.height() / 2.0 );
670  mPainterPath.lineTo( 0, size.height() / 2.0 );
671  mPainterPath.lineTo( 0, -size.height() / 2.0 );
672  mPainterPath.lineTo( -size.width() / 2.0, size.height() / 2.0 );
673  }
674 }
675 
677 {
679  mSymbolWidthUnit = unit;
680  mSymbolHeightUnit = unit;
681  mOutlineWidthUnit = unit;
682 }
683 
685 {
687  if ( mSymbolWidthUnit != unit || mSymbolHeightUnit != unit || mOutlineWidthUnit != unit )
688  {
689  return QgsSymbolV2::Mixed;
690  }
691  return unit;
692 }
693 
695 {
697  mSymbolWidthMapUnitScale = scale;
698  mSymbolHeightMapUnitScale = scale;
699  mOutlineWidthMapUnitScale = scale;
700 }
701 
703 {
704  if ( QgsMarkerSymbolLayerV2::mapUnitScale() == mSymbolWidthMapUnitScale &&
705  mSymbolWidthMapUnitScale == mSymbolHeightMapUnitScale &&
706  mSymbolHeightMapUnitScale == mOutlineWidthMapUnitScale )
707  {
708  return mSymbolWidthMapUnitScale;
709  }
710  return QgsMapUnitScale();
711 }
712 
714 {
715  QSizeF size = calculateSize( context );
716 
717  bool hasDataDefinedRotation = false;
718  QPointF offset;
719  double angle = 0;
720  calculateOffsetAndRotation( context, size.width(), size.height(), hasDataDefinedRotation, offset, angle );
721 
722  double pixelSize = 1.0 / context.renderContext().rasterScaleFactor();
723 
724  QMatrix transform;
725 
726  // move to the desired position
727  transform.translate( point.x() + offset.x(), point.y() + offset.y() );
728 
729  if ( !qgsDoubleNear( angle, 0.0 ) )
730  transform.rotate( angle );
731 
732  double penWidth = 0.0;
733  bool ok = true;
735  {
736  context.setOriginalValueVariable( mOutlineWidth );
738  if ( ok )
739  {
740  penWidth = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), outlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale );
741  }
742  }
744  {
747  if ( ok && outlineStyle == "no" )
748  {
749  penWidth = 0.0;
750  }
751  }
752 
753  //antialiasing
754  penWidth += pixelSize;
755 
756  QRectF symbolBounds = transform.mapRect( QRectF( -size.width() / 2.0,
757  -size.height() / 2.0,
758  size.width(),
759  size.height() ) );
760 
761  //extend bounds by pen width / 2.0
762  symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
763  penWidth / 2.0, penWidth / 2.0 );
764 
765  return symbolBounds;
766 }
767 
768 bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext &context, QPointF shift ) const
769 {
770  //width
771  double symbolWidth = mSymbolWidth;
772 
773  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH ) ) //1. priority: data defined setting on symbol layer le
774  {
775  context.setOriginalValueVariable( mSymbolWidth );
776  symbolWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH, context, mSymbolWidth ).toDouble();
777  }
778  else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
779  {
780  symbolWidth = mSize;
781  }
782  if ( mSymbolWidthUnit == QgsSymbolV2::MM )
783  {
784  symbolWidth *= mmMapUnitScaleFactor;
785  }
786 
787  //height
788  double symbolHeight = mSymbolHeight;
789  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT ) ) //1. priority: data defined setting on symbol layer level
790  {
791  context.setOriginalValueVariable( mSymbolHeight );
792  symbolHeight = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT, context, mSymbolHeight ).toDouble();
793  }
794  else if ( context.renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
795  {
796  symbolHeight = mSize;
797  }
798  if ( mSymbolHeightUnit == QgsSymbolV2::MM )
799  {
800  symbolHeight *= mmMapUnitScaleFactor;
801  }
802 
803  //outline width
804  double outlineWidth = mOutlineWidth;
805 
807  {
808  context.setOriginalValueVariable( mOutlineWidth );
809  outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble();
810  }
811  if ( mOutlineWidthUnit == QgsSymbolV2::MM )
812  {
813  outlineWidth *= outlineWidth;
814  }
815 
816  //fill color
817  bool ok;
818  QColor fc = mColor;
820  {
823  if ( ok )
824  fc = QgsSymbolLayerV2Utils::decodeColor( colorString );
825  }
826 
827  //outline color
828  QColor oc = mOutlineColor;
830  {
833  if ( ok )
834  oc = QgsSymbolLayerV2Utils::decodeColor( colorString );
835  }
836 
837  //symbol name
838  QString symbolName = mSymbolName;
840  {
841  context.setOriginalValueVariable( mSymbolName );
842  symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, context, mSymbolName ).toString();
843  }
844 
845  //offset
846  double offsetX = 0;
847  double offsetY = 0;
848  markerOffset( context, offsetX, offsetY );
849  QPointF off( offsetX, offsetY );
850 
851  //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
852  double rotation = 0.0;
854  {
855  context.setOriginalValueVariable( mAngle );
857  }
858  else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) )
859  {
860  rotation = mAngle + mLineAngle;
861  }
862  rotation = -rotation; //rotation in Qt is counterclockwise
863  if ( rotation )
864  off = _rotatedOffset( off, rotation );
865 
866  QTransform t;
867  t.translate( shift.x() + offsetX, shift.y() + offsetY );
868 
869  if ( !qgsDoubleNear( rotation, 0.0 ) )
870  t.rotate( rotation );
871 
872  double halfWidth = symbolWidth / 2.0;
873  double halfHeight = symbolHeight / 2.0;
874 
875  if ( symbolName == "circle" )
876  {
877  if ( qgsDoubleNear( halfWidth, halfHeight ) )
878  {
879  QgsPointV2 pt( t.map( QPointF( 0, 0 ) ) );
880  e.writeFilledCircle( layerName, oc, pt, halfWidth );
881  }
882  else
883  {
884  QgsPointSequenceV2 line;
885 
886  double stepsize = 2 * M_PI / 40;
887  for ( int i = 0; i < 39; ++i )
888  {
889  double angle = stepsize * i;
890  double x = halfWidth * cos( angle );
891  double y = halfHeight * sin( angle );
892  line << QgsPointV2( t.map( QPointF( x, y ) ) );
893  }
894  //close ellipse with first point
895  line << line.at( 0 );
896 
897  if ( mBrush.style() != Qt::NoBrush )
898  e.writePolygon( QgsRingSequenceV2() << line, layerName, "SOLID", fc );
899  if ( mPen.style() != Qt::NoPen )
900  e.writePolyline( line, layerName, "CONTINUOUS", oc, outlineWidth );
901  }
902  }
903  else if ( symbolName == "rectangle" )
904  {
906  p << QgsPointV2( t.map( QPointF( -halfWidth, -halfHeight ) ) )
907  << QgsPointV2( t.map( QPointF( halfWidth, -halfHeight ) ) )
908  << QgsPointV2( t.map( QPointF( halfWidth, halfHeight ) ) )
909  << QgsPointV2( t.map( QPointF( -halfWidth, halfHeight ) ) );
910  p << p[0];
911 
912  if ( mBrush.style() != Qt::NoBrush )
913  e.writePolygon( QgsRingSequenceV2() << p, layerName, "SOLID", fc );
914  if ( mPen.style() != Qt::NoPen )
915  e.writePolyline( p, layerName, "CONTINUOUS", oc, outlineWidth );
916  return true;
917  }
918  else if ( symbolName == "cross" && mPen.style() != Qt::NoPen )
919  {
921  << QgsPointV2( t.map( QPointF( -halfWidth, 0 ) ) )
922  << QgsPointV2( t.map( QPointF( halfWidth, 0 ) ) ),
923  layerName, "CONTINUOUS", oc, outlineWidth );
925  << QgsPointV2( t.map( QPointF( 0, halfHeight ) ) )
926  << QgsPointV2( t.map( QPointF( 0, -halfHeight ) ) ),
927  layerName, "CONTINUOUS", oc, outlineWidth );
928  return true;
929  }
930  else if ( symbolName == "triangle" )
931  {
933  p << QgsPointV2( t.map( QPointF( -halfWidth, -halfHeight ) ) )
934  << QgsPointV2( t.map( QPointF( halfWidth, -halfHeight ) ) )
935  << QgsPointV2( t.map( QPointF( 0, halfHeight ) ) );
936  p << p[0];
937  if ( mBrush.style() != Qt::NoBrush )
938  e.writePolygon( QgsRingSequenceV2() << p, layerName, "SOLID", fc );
939  if ( mPen.style() != Qt::NoPen )
940  e.writePolyline( p, layerName, "CONTINUOUS", oc, outlineWidth );
941  return true;
942  }
943 
944  return false; //soon...
945 }
946 
947 
void addEllipse(const QRectF &boundingRectangle)
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
static const QString EXPR_OUTLINE_COLOR
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
void markerOffset(QgsSymbolV2RenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
Qt::PenStyle style() const
void setSymbolWidthUnit(QgsSymbolV2::OutputUnit unit)
QColor fillColor() const override
Get fill color.
QgsSymbolV2::OutputUnit outputUnit() const override
void setStyle(Qt::PenStyle style)
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
QPointF offset() const
Returns the marker&#39;s offset, which is the horizontal and vertical displacement which the rendered mar...
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
Renders a marker at the specified point.
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
A container class for data source field mapping or expression.
bool contains(const Key &key) const
static Q_DECL_DEPRECATED bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &borderColor, double &borderWidth, double &size)
void startRender(QgsSymbolV2RenderContext &context) override
qreal alphaF() const
QDomNode appendChild(const QDomNode &newChild)
static double rescaleUom(double size, QgsSymbolV2::OutputUnit unit, const QgsStringMap &props)
Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified.
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
Qt::BrushStyle style() const
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
QString attribute(const QString &name, const QString &defValue) const
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
double size() const
Returns the symbol size.
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
QPoint map(const QPoint &point) const
static QString encodeColor(const QColor &color)
static const QString EXPR_WIDTH
static QgsStringMap getVendorOptionList(QDomElement &element)
The output shall be in pixels.
Definition: qgssymbolv2.h:70
const T & at(int i) const
void setOffset(QPointF offset)
Sets the marker&#39;s offset, which is the horizontal and vertical displacement which the rendered marker...
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
virtual bool hasDataDefinedProperties() const
Checks whether the layer has any associated data defined properties.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QgsEllipseSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
void setJoinStyle(Qt::PenJoinStyle style)
void moveTo(const QPointF &point)
static QPointF decodePoint(const QString &str)
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
Definition: qgsfeature.cpp:82
const QgsFeature * feature() const
Current feature being rendered - may be null.
Definition: qgssymbolv2.h:388
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
QRectF bounds(QPointF point, QgsSymbolV2RenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QgsSymbolV2::OutputUnit outputUnit() const override
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
QColor outlineColor() const override
Get outline color.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol&#39;s offset.
virtual QgsDataDefined * getDataDefinedProperty(const QString &property) const
Returns the data defined property corresponding to the specified property key.
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
double toDouble(bool *ok) const
void setStyle(Qt::BrushStyle style)
A symbol layer for rendering objects with major and minor axis (e.g.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Definition: qgis.h:353
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual Q_DECL_DEPRECATED QVariant evaluateDataDefinedProperty(const QString &property, const QgsFeature *feature, const QVariant &defaultVal=QVariant(), bool *ok=nullptr) const
Evaluates the matching data defined property and returns the calculated value.
double mapRotation() const
Return current map rotation in degrees.
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units for the symbol&#39;s offset.
bool useExpression() const
Returns if the field or the expression part is active.
void setMapUnitScale(const QgsMapUnitScale &scale) override
static const QString EXPR_JOIN_STYLE
static QgsSymbolV2::OutputUnit decodeOutputUnit(const QString &str)
static QString encodePenStyle(Qt::PenStyle style)
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
Mixed units in symbol layers.
Definition: qgssymbolv2.h:69
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
QTransform & translate(qreal dx, qreal dy)
The output shall be in millimeters.
Definition: qgssymbolv2.h:67
QString number(int n, int base)
static const QString EXPR_FILL_COLOR
qreal x() const
qreal y() const
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
static QString encodePoint(QPointF point)
static double convertToPainterUnits(const QgsRenderContext &c, double size, QgsSymbolV2::OutputUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale())
Converts a size from the specied units to painter units.
void setPen(const QColor &color)
void lineTo(const QPointF &endPoint)
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
Definition: qgssymbolv2.h:376
void setAttribute(const QString &name, const QString &value)
QMatrix & translate(qreal dx, qreal dy)
QString expressionString() const
Returns the expression string of this QgsDataDefined.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:34
bool isEmpty() const
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
void addRect(const QRectF &rectangle)
#define M_PI
void setSizeUnit(QgsSymbolV2::OutputUnit unit)
Sets the units for the symbol&#39;s size.
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
void setWidthF(qreal width)
void setBrush(const QBrush &brush)
Q_DECL_DEPRECATED void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
Qt::PenStyle outlineStyle() const
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
iterator end()
void setOutlineStyle(Qt::PenStyle outlineStyle)
void setColor(const QColor &color)
void setSymbolName(const QString &name)
virtual Q_DECL_DEPRECATED void prepareExpressions(const QgsFields *fields, double scale=-1.0)
Prepares all data defined property expressions for evaluation.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
virtual QColor color() const
The fill color.
double mAngle
Marker rotation angle, in degrees clockwise from north.
iterator begin()
static Qt::PenStyle decodePenStyle(const QString &str)
double mLineAngle
Line rotation angle (see setLineAngle() for details)
static const QString EXPR_OUTLINE_STYLE
Q_DECL_DEPRECATED void writePolyline(const QgsPolyline &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void copyDataDefinedProperties(QgsSymbolLayerV2 *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves all data defined properties to a string map.
QRect mapRect(const QRect &rectangle) const
QString field() const
Get the field which this QgsDataDefined represents.
bool isNull() const
void startRender(QgsSymbolV2RenderContext &context) override
static const QString EXPR_OUTLINE_WIDTH
QTransform & rotate(qreal angle, Qt::Axis axis)
void copyPaintEffect(QgsSymbolLayerV2 *destLayer) const
Copies paint effect of this layer to another symbol layer.
QMatrix & rotate(qreal degrees)
VerticalAnchorPoint
Symbol vertical anchor points.
QPainter * painter()
const QgsMapToPixel & mapToPixel() const
void drawPath(const QPainterPath &path)
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void setWidth(int width)
Struct for storing maximum and minimum scales for measurements in map units.
QgsMapUnitScale mapUnitScale() const override
virtual bool hasDataDefinedProperty(const QString &property) const
Checks whether the layer has a matching data defined property and if that property is currently activ...
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsRenderContext & renderContext()
Definition: qgssymbolv2.h:359
QDomElement firstChildElement(const QString &tagName) const
void setOutlineColor(const QColor &c) override
Set outline color.
Q_DECL_DEPRECATED void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
static const QString EXPR_ROTATION
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
QgsSymbolV2::OutputUnit mOffsetUnit
Offset units.
void setAlphaF(qreal alpha)
virtual void setColor(const QColor &color)
The fill color.
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
double toDouble(bool *ok) const
static QColor decodeColor(const QString &str)
Abstract base class for marker symbol layers.
VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
void stopRender(QgsSymbolV2RenderContext &context) override
QgsSymbolV2::OutputUnit mSizeUnit
Marker size unit.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
HorizontalAnchorPoint
Symbol horizontal anchor points.
void setPenJoinStyle(Qt::PenJoinStyle style)
Set outline join style.
void restoreDataDefinedProperties(const QgsStringMap &stringMap)
Restores all data defined properties from string map.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QString layerType() const override
Returns a string that represents this layer type.
double rasterScaleFactor() const
double mSize
Marker size.
QDomElement createElement(const QString &tagName)
static const QString EXPR_SYMBOL_NAME
qreal height() const
QgsMapUnitScale mapUnitScale() const override
void setSize(double size)
Sets the symbol size.
void map(int x, int y, int *tx, int *ty) const
void setAngle(double angle)
Sets the rotation angle for the marker.
void arcTo(const QRectF &rectangle, qreal startAngle, qreal sweepLength)
void setColor(const QColor &color)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QString toString() const
QPointF mOffset
Marker offset.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol&#39;s size.
void setFillColor(const QColor &c) override
Set fill color.
void setSymbolHeightUnit(QgsSymbolV2::OutputUnit unit)
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
bool isActive() const
qreal width() const
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
#define DEFAULT_ELLIPSE_JOINSTYLE
QList< QgsPointV2 > QgsPointSequenceV2
static const QString EXPR_HEIGHT
const T value(const Key &key) const
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &borderColor=QColor(), double borderWidth=-1, double size=-1)
virtual Q_DECL_DEPRECATED void setDataDefinedProperty(const QString &property, const QString &expressionString)
Sets a data defined expression for a property.