QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsellipsesymbollayer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsellipsesymbollayer.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  ***************************************************************************/
15 #include "qgsellipsesymbollayer.h"
16 #include "qgsdxfexport.h"
17 #include "qgsexpression.h"
18 #include "qgsfeature.h"
19 #include "qgsrendercontext.h"
20 #include "qgsvectorlayer.h"
21 #include "qgslogger.h"
22 #include "qgsunittypes.h"
23 #include "qgsproperty.h"
24 #include "qgssymbollayerutils.h"
25 
26 #include <QPainter>
27 #include <QSet>
28 #include <QDomDocument>
29 #include <QDomElement>
30 
32  : mSymbolName( QStringLiteral( "circle" ) )
33  , mStrokeColor( QColor( 35, 35, 35 ) )
34 {
35  mColor = Qt::white;
36  mPen.setColor( mStrokeColor );
37  mPen.setStyle( mStrokeStyle );
38  mPen.setJoinStyle( mPenJoinStyle );
39  mPen.setWidth( 1.0 );
40  mBrush.setColor( mColor );
41  mBrush.setStyle( Qt::SolidPattern );
42  mOffset = QPointF( 0, 0 );
43  mAngle = 0;
44 }
45 
47 {
49  if ( properties.contains( QStringLiteral( "symbol_name" ) ) )
50  {
51  layer->setSymbolName( properties[ QStringLiteral( "symbol_name" )] );
52  }
53  if ( properties.contains( QStringLiteral( "size" ) ) )
54  {
55  layer->setSize( properties[QStringLiteral( "size" )].toDouble() );
56  }
57  if ( properties.contains( QStringLiteral( "size_unit" ) ) )
58  {
59  layer->setSizeUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "size_unit" )] ) );
60  }
61  if ( properties.contains( QStringLiteral( "size_map_unit_scale" ) ) )
62  {
63  layer->setSizeMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "size_map_unit_scale" )] ) );
64  }
65  if ( properties.contains( QStringLiteral( "symbol_width" ) ) )
66  {
67  layer->setSymbolWidth( properties[QStringLiteral( "symbol_width" )].toDouble() );
68  }
69  if ( properties.contains( QStringLiteral( "symbol_width_unit" ) ) )
70  {
71  layer->setSymbolWidthUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "symbol_width_unit" )] ) );
72  }
73  if ( properties.contains( QStringLiteral( "symbol_width_map_unit_scale" ) ) )
74  {
75  layer->setSymbolWidthMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "symbol_width_map_unit_scale" )] ) );
76  }
77  if ( properties.contains( QStringLiteral( "symbol_height" ) ) )
78  {
79  layer->setSymbolHeight( properties[QStringLiteral( "symbol_height" )].toDouble() );
80  }
81  if ( properties.contains( QStringLiteral( "symbol_height_unit" ) ) )
82  {
83  layer->setSymbolHeightUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "symbol_height_unit" )] ) );
84  }
85  if ( properties.contains( QStringLiteral( "symbol_height_map_unit_scale" ) ) )
86  {
87  layer->setSymbolHeightMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "symbol_height_map_unit_scale" )] ) );
88  }
89  if ( properties.contains( QStringLiteral( "angle" ) ) )
90  {
91  layer->setAngle( properties[QStringLiteral( "angle" )].toDouble() );
92  }
93  if ( properties.contains( QStringLiteral( "outline_style" ) ) )
94  {
95  layer->setStrokeStyle( QgsSymbolLayerUtils::decodePenStyle( properties[QStringLiteral( "outline_style" )] ) );
96  }
97  else if ( properties.contains( QStringLiteral( "line_style" ) ) )
98  {
99  layer->setStrokeStyle( QgsSymbolLayerUtils::decodePenStyle( properties[QStringLiteral( "line_style" )] ) );
100  }
101  if ( properties.contains( QStringLiteral( "joinstyle" ) ) )
102  {
103  layer->setPenJoinStyle( QgsSymbolLayerUtils::decodePenJoinStyle( properties[QStringLiteral( "joinstyle" )] ) );
104  }
105  if ( properties.contains( QStringLiteral( "outline_width" ) ) )
106  {
107  layer->setStrokeWidth( properties[QStringLiteral( "outline_width" )].toDouble() );
108  }
109  else if ( properties.contains( QStringLiteral( "line_width" ) ) )
110  {
111  layer->setStrokeWidth( properties[QStringLiteral( "line_width" )].toDouble() );
112  }
113  if ( properties.contains( QStringLiteral( "outline_width_unit" ) ) )
114  {
115  layer->setStrokeWidthUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "outline_width_unit" )] ) );
116  }
117  else if ( properties.contains( QStringLiteral( "line_width_unit" ) ) )
118  {
119  layer->setStrokeWidthUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "line_width_unit" )] ) );
120  }
121  if ( properties.contains( QStringLiteral( "outline_width_map_unit_scale" ) ) )
122  {
123  layer->setStrokeWidthMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "outline_width_map_unit_scale" )] ) );
124  }
125  if ( properties.contains( QStringLiteral( "fill_color" ) ) )
126  {
127  //pre 2.5 projects used "fill_color"
128  layer->setFillColor( QgsSymbolLayerUtils::decodeColor( properties[QStringLiteral( "fill_color" )] ) );
129  }
130  else if ( properties.contains( QStringLiteral( "color" ) ) )
131  {
132  layer->setFillColor( QgsSymbolLayerUtils::decodeColor( properties[QStringLiteral( "color" )] ) );
133  }
134  if ( properties.contains( QStringLiteral( "outline_color" ) ) )
135  {
136  layer->setStrokeColor( QgsSymbolLayerUtils::decodeColor( properties[QStringLiteral( "outline_color" )] ) );
137  }
138  else if ( properties.contains( QStringLiteral( "line_color" ) ) )
139  {
140  layer->setStrokeColor( QgsSymbolLayerUtils::decodeColor( properties[QStringLiteral( "line_color" )] ) );
141  }
142  if ( properties.contains( QStringLiteral( "offset" ) ) )
143  {
144  layer->setOffset( QgsSymbolLayerUtils::decodePoint( properties[QStringLiteral( "offset" )] ) );
145  }
146  if ( properties.contains( QStringLiteral( "offset_unit" ) ) )
147  {
148  layer->setOffsetUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "offset_unit" )] ) );
149  }
150  if ( properties.contains( QStringLiteral( "offset_map_unit_scale" ) ) )
151  {
152  layer->setOffsetMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "offset_map_unit_scale" )] ) );
153  }
154  if ( properties.contains( QStringLiteral( "horizontal_anchor_point" ) ) )
155  {
156  layer->setHorizontalAnchorPoint( QgsMarkerSymbolLayer::HorizontalAnchorPoint( properties[ QStringLiteral( "horizontal_anchor_point" )].toInt() ) );
157  }
158  if ( properties.contains( QStringLiteral( "vertical_anchor_point" ) ) )
159  {
160  layer->setVerticalAnchorPoint( QgsMarkerSymbolLayer::VerticalAnchorPoint( properties[ QStringLiteral( "vertical_anchor_point" )].toInt() ) );
161  }
162 
163  //data defined properties
165 
166  return layer;
167 }
168 
170 {
171  double scaledWidth = mSymbolWidth;
172  double scaledHeight = mSymbolHeight;
173 
175  {
176  bool ok;
177  context.setOriginalValueVariable( mStrokeWidth );
179  if ( exprVal.isValid() )
180  {
181  double width = exprVal.toDouble( &ok );
182  if ( ok )
183  {
184  width = context.renderContext().convertToPainterUnits( width, mStrokeWidthUnit, mStrokeWidthMapUnitScale );
185  mPen.setWidthF( width );
186  mSelPen.setWidthF( width );
187  }
188  }
189 
192  if ( exprVal.isValid() )
193  {
194  mPen.setStyle( QgsSymbolLayerUtils::decodePenStyle( exprVal.toString() ) );
195  mSelPen.setStyle( mPen.style() );
196  }
197 
200  if ( exprVal.isValid() )
201  {
202  mPen.setJoinStyle( QgsSymbolLayerUtils::decodePenJoinStyle( exprVal.toString() ) );
203  mSelPen.setJoinStyle( mPen.joinStyle() );
204  }
205 
208 
211 
213  {
214  QString symbolName = mSymbolName;
215  context.setOriginalValueVariable( mSymbolName );
217  if ( exprVal.isValid() )
218  {
219  symbolName = exprVal.toString();
220  }
221  preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() );
222  }
223  }
224 
225  //offset and rotation
226  bool hasDataDefinedRotation = false;
227  QPointF offset;
228  double angle = 0;
229  calculateOffsetAndRotation( context, scaledWidth, scaledHeight, hasDataDefinedRotation, offset, angle );
230 
231  QPainter *p = context.renderContext().painter();
232  if ( !p )
233  {
234  return;
235  }
236 
237  QMatrix transform;
238  transform.translate( point.x() + offset.x(), point.y() + offset.y() );
239  if ( !qgsDoubleNear( angle, 0.0 ) )
240  {
241  transform.rotate( angle );
242  }
243 
244  p->setPen( context.selected() ? mSelPen : mPen );
245  p->setBrush( context.selected() ? mSelBrush : mBrush );
246  p->drawPath( transform.map( mPainterPath ) );
247 }
248 
249 
250 void QgsEllipseSymbolLayer::calculateOffsetAndRotation( QgsSymbolRenderContext &context,
251  double scaledWidth,
252  double scaledHeight,
253  bool &hasDataDefinedRotation,
254  QPointF &offset,
255  double &angle ) const
256 {
257  double offsetX = 0;
258  double offsetY = 0;
259  markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale );
260  offset = QPointF( offsetX, offsetY );
261 
262 //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
263  bool ok = true;
264  angle = mAngle + mLineAngle;
265  bool usingDataDefinedRotation = false;
267  {
268  context.setOriginalValueVariable( angle );
270  usingDataDefinedRotation = ok;
271  }
272 
273  hasDataDefinedRotation = context.renderHints() & QgsSymbol::DynamicRotation || usingDataDefinedRotation;
274  if ( hasDataDefinedRotation )
275  {
276  // For non-point markers, "dataDefinedRotation" means following the
277  // shape (shape-data defined). For them, "field-data defined" does
278  // not work at all. TODO: if "field-data defined" ever gets implemented
279  // we'll need a way to distinguish here between the two, possibly
280  // using another flag in renderHints()
281  const QgsFeature *f = context.feature();
282  if ( f )
283  {
284  const QgsGeometry g = f->geometry();
285  if ( !g.isNull() && g.type() == QgsWkbTypes::PointGeometry )
286  {
287  const QgsMapToPixel &m2p = context.renderContext().mapToPixel();
288  angle += m2p.mapRotation();
289  }
290  }
291  }
292 
293  if ( angle )
295 }
296 
298 {
299  return QStringLiteral( "EllipseMarker" );
300 }
301 
303 {
304  QgsMarkerSymbolLayer::startRender( context ); // get anchor point expressions
305  if ( !context.feature() || !dataDefinedProperties().hasActiveProperties() )
306  {
307  preparePath( mSymbolName, context );
308  }
309  mPen.setColor( mStrokeColor );
310  mPen.setStyle( mStrokeStyle );
311  mPen.setJoinStyle( mPenJoinStyle );
312  mPen.setWidthF( context.renderContext().convertToPainterUnits( mStrokeWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale ) );
313  mBrush.setColor( mColor );
314 
315  QColor selBrushColor = context.renderContext().selectionColor();
316  QColor selPenColor = selBrushColor == mColor ? selBrushColor : mStrokeColor;
317  if ( context.opacity() < 1 && !SELECTION_IS_OPAQUE )
318  {
319  selBrushColor.setAlphaF( context.opacity() );
320  selPenColor.setAlphaF( context.opacity() );
321  }
322  mSelBrush = QBrush( selBrushColor );
323  mSelPen = QPen( selPenColor );
324  mSelPen.setStyle( mStrokeStyle );
325  mSelPen.setWidthF( context.renderContext().convertToPainterUnits( mStrokeWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale ) );
326 }
327 
329 {
330 }
331 
333 {
335  m->setSymbolName( mSymbolName );
336  m->setSymbolWidth( mSymbolWidth );
337  m->setSymbolHeight( mSymbolHeight );
338  m->setStrokeStyle( mStrokeStyle );
339  m->setOffset( mOffset );
342  m->setStrokeStyle( mStrokeStyle );
343  m->setPenJoinStyle( mPenJoinStyle );
344  m->setStrokeWidth( mStrokeWidth );
345  m->setColor( color() );
346  m->setStrokeColor( mStrokeColor );
347  m->setSymbolWidthUnit( mSymbolWidthUnit );
348  m->setSymbolWidthMapUnitScale( mSymbolWidthMapUnitScale );
349  m->setSymbolHeightUnit( mSymbolHeightUnit );
350  m->setSymbolHeightMapUnitScale( mSymbolHeightMapUnitScale );
351  m->setStrokeWidthUnit( mStrokeWidthUnit );
352  m->setStrokeWidthMapUnitScale( mStrokeWidthMapUnitScale );
353  m->setAngle( mAngle );
356 
358  copyPaintEffect( m );
359  return m;
360 }
361 
362 void QgsEllipseSymbolLayer::toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const
363 {
364  QDomElement symbolizerElem = doc.createElement( QStringLiteral( "se:PointSymbolizer" ) );
365  if ( !props.value( QStringLiteral( "uom" ), QString() ).isEmpty() )
366  symbolizerElem.setAttribute( QStringLiteral( "uom" ), props.value( QStringLiteral( "uom" ), QString() ) );
367  element.appendChild( symbolizerElem );
368 
369  // <Geometry>
370  QgsSymbolLayerUtils::createGeometryElement( doc, symbolizerElem, props.value( QStringLiteral( "geom" ), QString() ) );
371 
372  writeSldMarker( doc, symbolizerElem, props );
373 }
374 
375 void QgsEllipseSymbolLayer::writeSldMarker( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const
376 {
377  // <Graphic>
378  QDomElement graphicElem = doc.createElement( QStringLiteral( "se:Graphic" ) );
379  element.appendChild( graphicElem );
380 
381  double strokeWidth = QgsSymbolLayerUtils::rescaleUom( mStrokeWidth, mStrokeWidthUnit, props );
382  double symbolWidth = QgsSymbolLayerUtils::rescaleUom( mSymbolWidth, mSymbolWidthUnit, props );
383  QgsSymbolLayerUtils::wellKnownMarkerToSld( doc, graphicElem, mSymbolName, mColor, mStrokeColor, mStrokeStyle, strokeWidth, symbolWidth );
384 
385  // <Rotation>
387 
388  QString angleFunc = props.value( QStringLiteral( "angle" ), QString() );
389  if ( angleFunc.isEmpty() ) // symbol has no angle set
390  {
391  if ( ddRotation && ddRotation.isActive() )
392  {
393  angleFunc = ddRotation.asExpression();
394  }
395  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
396  angleFunc = QString::number( mAngle );
397  }
398  else if ( ddRotation && ddRotation.isActive() )
399  {
400  // the symbol has an angle and the symbol layer have a rotation
401  // property set
402  angleFunc = QStringLiteral( "%1 + %2" ).arg( angleFunc, ddRotation.asExpression() );
403  }
404  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
405  {
406  // both the symbol and the symbol layer have angle value set
407  bool ok;
408  double angle = angleFunc.toDouble( &ok );
409  if ( !ok )
410  {
411  // its a string (probably a property name or a function)
412  angleFunc = QStringLiteral( "%1 + %2" ).arg( angleFunc ).arg( mAngle );
413  }
414  else if ( !qgsDoubleNear( angle + mAngle, 0.0 ) )
415  {
416  // it's a double value
417  angleFunc = QString::number( angle + mAngle );
418  }
419  }
420  QgsSymbolLayerUtils::createRotationElement( doc, graphicElem, angleFunc );
421 
422  // <Displacement>
425 
426  // store w/h factor in a <VendorOption>
427  double widthHeightFactor = mSymbolWidth / mSymbolHeight;
428  QDomElement factorElem = QgsSymbolLayerUtils::createVendorOptionElement( doc, QStringLiteral( "widthHeightFactor" ), QString::number( widthHeightFactor ) );
429  graphicElem.appendChild( factorElem );
430 }
431 
433 {
434  QgsDebugMsgLevel( QStringLiteral( "Entered." ), 4 );
435 
436  QDomElement graphicElem = element.firstChildElement( QStringLiteral( "Graphic" ) );
437  if ( graphicElem.isNull() )
438  return nullptr;
439 
440  QString name = QStringLiteral( "circle" );
441  QColor fillColor, strokeColor;
442  double strokeWidth, size;
443  double widthHeightFactor = 1.0;
444  Qt::PenStyle strokeStyle;
445 
446  QgsStringMap vendorOptions = QgsSymbolLayerUtils::getVendorOptionList( graphicElem );
447  for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
448  {
449  if ( it.key() == QLatin1String( "widthHeightFactor" ) )
450  {
451  bool ok;
452  double v = it.value().toDouble( &ok );
453  if ( ok && !qgsDoubleNear( v, 0.0 ) && v > 0 )
454  widthHeightFactor = v;
455  }
456  }
457 
459  return nullptr;
460 
461  QString uom = element.attribute( QStringLiteral( "uom" ) );
464 
465  double angle = 0.0;
466  QString angleFunc;
467  if ( QgsSymbolLayerUtils::rotationFromSldElement( graphicElem, angleFunc ) )
468  {
469  bool ok;
470  double d = angleFunc.toDouble( &ok );
471  if ( ok )
472  angle = d;
473  }
474 
476  m->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
477  m->setSymbolName( name );
478  m->setFillColor( fillColor );
482  m->setSymbolWidth( size );
483  m->setSymbolHeight( size / widthHeightFactor );
484  m->setAngle( angle );
485  return m;
486 }
487 
489 {
490  QgsStringMap map;
491  map[QStringLiteral( "symbol_name" )] = mSymbolName;
492  map[QStringLiteral( "symbol_width" )] = QString::number( mSymbolWidth );
493  map[QStringLiteral( "symbol_width_unit" )] = QgsUnitTypes::encodeUnit( mSymbolWidthUnit );
494  map[QStringLiteral( "symbol_width_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mSymbolWidthMapUnitScale );
495  map[QStringLiteral( "symbol_height" )] = QString::number( mSymbolHeight );
496  map[QStringLiteral( "symbol_height_unit" )] = QgsUnitTypes::encodeUnit( mSymbolHeightUnit );
497  map[QStringLiteral( "symbol_height_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mSymbolHeightMapUnitScale );
498  map[QStringLiteral( "angle" )] = QString::number( mAngle );
499  map[QStringLiteral( "outline_style" )] = QgsSymbolLayerUtils::encodePenStyle( mStrokeStyle );
500  map[QStringLiteral( "outline_width" )] = QString::number( mStrokeWidth );
501  map[QStringLiteral( "outline_width_unit" )] = QgsUnitTypes::encodeUnit( mStrokeWidthUnit );
502  map[QStringLiteral( "outline_width_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mStrokeWidthMapUnitScale );
503  map[QStringLiteral( "joinstyle" )] = QgsSymbolLayerUtils::encodePenJoinStyle( mPenJoinStyle );
504  map[QStringLiteral( "color" )] = QgsSymbolLayerUtils::encodeColor( mColor );
505  map[QStringLiteral( "outline_color" )] = QgsSymbolLayerUtils::encodeColor( mStrokeColor );
506  map[QStringLiteral( "offset" )] = QgsSymbolLayerUtils::encodePoint( mOffset );
507  map[QStringLiteral( "offset_unit" )] = QgsUnitTypes::encodeUnit( mOffsetUnit );
508  map[QStringLiteral( "offset_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mOffsetMapUnitScale );
509  map[QStringLiteral( "size" )] = QString::number( mSize );
510  map[QStringLiteral( "size_unit" )] = QgsUnitTypes::encodeUnit( mSizeUnit );
511  map[QStringLiteral( "size_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mSizeMapUnitScale );
512  map[QStringLiteral( "horizontal_anchor_point" )] = QString::number( mHorizontalAnchorPoint );
513  map[QStringLiteral( "vertical_anchor_point" )] = QString::number( mVerticalAnchorPoint );
514  return map;
515 }
516 
517 QSizeF QgsEllipseSymbolLayer::calculateSize( QgsSymbolRenderContext &context, double *scaledWidth, double *scaledHeight )
518 {
519  double width = 0;
520 
521  if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyWidth ) ) //1. priority: data defined setting on symbol layer le
522  {
523  context.setOriginalValueVariable( mSymbolWidth );
525  }
526  else //2. priority: global width setting
527  {
528  width = mSymbolWidth;
529  }
530  if ( scaledWidth )
531  {
532  *scaledWidth = width;
533  }
534  width = context.renderContext().convertToPainterUnits( width, mSymbolWidthUnit, mSymbolHeightMapUnitScale );
535 
536  double height = 0;
537  if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyHeight ) ) //1. priority: data defined setting on symbol layer level
538  {
539  context.setOriginalValueVariable( mSymbolHeight );
541  }
542  else //2. priority: global height setting
543  {
544  height = mSymbolHeight;
545  }
546  if ( scaledHeight )
547  {
548  *scaledHeight = height;
549  }
550  height = context.renderContext().convertToPainterUnits( height, mSymbolHeightUnit, mSymbolHeightMapUnitScale );
551  return QSizeF( width, height );
552 }
553 
554 void QgsEllipseSymbolLayer::preparePath( const QString &symbolName, QgsSymbolRenderContext &context, double *scaledWidth, double *scaledHeight, const QgsFeature * )
555 {
556  mPainterPath = QPainterPath();
557 
558  QSizeF size = calculateSize( context, scaledWidth, scaledHeight );
559 
560  if ( symbolName == QLatin1String( "circle" ) )
561  {
562  mPainterPath.addEllipse( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
563  }
564  else if ( symbolName == QLatin1String( "semi_circle" ) )
565  {
566  mPainterPath.arcTo( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height(), 0, 180 );
567  mPainterPath.lineTo( 0, 0 );
568  }
569  else if ( symbolName == QLatin1String( "rectangle" ) )
570  {
571  mPainterPath.addRect( QRectF( -size.width() / 2.0, -size.height() / 2.0, size.width(), size.height() ) );
572  }
573  else if ( symbolName == QLatin1String( "diamond" ) )
574  {
575  mPainterPath.moveTo( -size.width() / 2.0, 0 );
576  mPainterPath.lineTo( 0, size.height() / 2.0 );
577  mPainterPath.lineTo( size.width() / 2.0, 0 );
578  mPainterPath.lineTo( 0, -size.height() / 2.0 );
579  mPainterPath.lineTo( -size.width() / 2.0, 0 );
580  }
581  else if ( symbolName == QLatin1String( "cross" ) )
582  {
583  mPainterPath.moveTo( 0, -size.height() / 2.0 );
584  mPainterPath.lineTo( 0, size.height() / 2.0 );
585  mPainterPath.moveTo( -size.width() / 2.0, 0 );
586  mPainterPath.lineTo( size.width() / 2.0, 0 );
587  }
588  else if ( symbolName == QLatin1String( "triangle" ) )
589  {
590  mPainterPath.moveTo( 0, -size.height() / 2.0 );
591  mPainterPath.lineTo( -size.width() / 2.0, size.height() / 2.0 );
592  mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
593  mPainterPath.lineTo( 0, -size.height() / 2.0 );
594  }
595  else if ( symbolName == QLatin1String( "left_half_triangle" ) )
596  {
597  mPainterPath.moveTo( 0, size.height() / 2.0 );
598  mPainterPath.lineTo( size.width() / 2.0, size.height() / 2.0 );
599  mPainterPath.lineTo( 0, -size.height() / 2.0 );
600  mPainterPath.lineTo( 0, size.height() / 2.0 );
601  }
602  else if ( symbolName == QLatin1String( "right_half_triangle" ) )
603  {
604  mPainterPath.moveTo( -size.width() / 2.0, size.height() / 2.0 );
605  mPainterPath.lineTo( 0, size.height() / 2.0 );
606  mPainterPath.lineTo( 0, -size.height() / 2.0 );
607  mPainterPath.lineTo( -size.width() / 2.0, size.height() / 2.0 );
608  }
609 }
610 
612 {
613  if ( mSymbolWidth >= mSymbolHeight )
614  {
615  mSymbolHeight = mSymbolHeight * size / mSymbolWidth;
616  mSymbolWidth = size;
617  }
618  else
619  {
620  mSymbolWidth = mSymbolWidth * size / mSymbolHeight;
621  mSymbolHeight = size;
622  }
624 }
625 
627 {
628  mSymbolWidth = w;
629  QgsMarkerSymbolLayer::setSize( mSymbolWidth >= mSymbolHeight ? mSymbolWidth : mSymbolHeight );
630 }
631 
633 {
634  mSymbolHeight = h;
635  QgsMarkerSymbolLayer::setSize( mSymbolWidth >= mSymbolHeight ? mSymbolWidth : mSymbolHeight );
636 }
637 
639 {
641  mSymbolWidthUnit = unit;
642  mSymbolHeightUnit = unit;
643  mStrokeWidthUnit = unit;
644 }
645 
647 {
649  if ( mSymbolWidthUnit != unit || mSymbolHeightUnit != unit || mStrokeWidthUnit != unit )
650  {
652  }
653  return unit;
654 }
655 
657 {
659  mSymbolWidthMapUnitScale = scale;
660  mSymbolHeightMapUnitScale = scale;
661  mStrokeWidthMapUnitScale = scale;
662 }
663 
665 {
666  if ( QgsMarkerSymbolLayer::mapUnitScale() == mSymbolWidthMapUnitScale &&
667  mSymbolWidthMapUnitScale == mSymbolHeightMapUnitScale &&
668  mSymbolHeightMapUnitScale == mStrokeWidthMapUnitScale )
669  {
670  return mSymbolWidthMapUnitScale;
671  }
672  return QgsMapUnitScale();
673 }
674 
675 QRectF QgsEllipseSymbolLayer::bounds( QPointF point, QgsSymbolRenderContext &context )
676 {
677  QSizeF size = calculateSize( context );
678 
679  bool hasDataDefinedRotation = false;
680  QPointF offset;
681  double angle = 0;
682  calculateOffsetAndRotation( context, size.width(), size.height(), hasDataDefinedRotation, offset, angle );
683 
684  QMatrix transform;
685 
686  // move to the desired position
687  transform.translate( point.x() + offset.x(), point.y() + offset.y() );
688 
689  if ( !qgsDoubleNear( angle, 0.0 ) )
690  transform.rotate( angle );
691 
692  double penWidth = mStrokeWidth;
694  {
695  context.setOriginalValueVariable( mStrokeWidth );
697 
698  if ( exprVal.isValid() )
699  {
700  bool ok;
701  double strokeWidth = exprVal.toDouble( &ok );
702  if ( ok )
703  {
704  penWidth = strokeWidth;
705  }
706  }
707  }
708  penWidth = context.renderContext().convertToPainterUnits( penWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale );
709 
711  {
714  if ( exprVal.isValid() && exprVal.toString() == QLatin1String( "no" ) )
715  {
716  penWidth = 0.0;
717  }
718  }
719  else if ( mStrokeStyle == Qt::NoPen )
720  penWidth = 0;
721 
722  //antialiasing, add 1 pixel
723  penWidth += 1;
724 
725  QRectF symbolBounds = transform.mapRect( QRectF( -size.width() / 2.0,
726  -size.height() / 2.0,
727  size.width(),
728  size.height() ) );
729 
730  //extend bounds by pen width / 2.0
731  symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
732  penWidth / 2.0, penWidth / 2.0 );
733 
734  return symbolBounds;
735 }
736 
737 bool QgsEllipseSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift ) const
738 {
739  //width
740  double symbolWidth = mSymbolWidth;
741 
742  if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyWidth ) ) //1. priority: data defined setting on symbol layer le
743  {
744  context.setOriginalValueVariable( mSymbolWidth );
746  }
747  if ( mSymbolWidthUnit == QgsUnitTypes::RenderMillimeters )
748  {
749  symbolWidth *= mmMapUnitScaleFactor;
750  }
751 
752  //height
753  double symbolHeight = mSymbolHeight;
754  if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyHeight ) ) //1. priority: data defined setting on symbol layer level
755  {
756  context.setOriginalValueVariable( mSymbolHeight );
758  }
759  if ( mSymbolHeightUnit == QgsUnitTypes::RenderMillimeters )
760  {
761  symbolHeight *= mmMapUnitScaleFactor;
762  }
763 
764  //stroke width
765  double strokeWidth = mStrokeWidth;
766 
768  {
769  context.setOriginalValueVariable( mStrokeWidth );
771  }
772  if ( mStrokeWidthUnit == QgsUnitTypes::RenderMillimeters )
773  {
775  }
776 
777  //fill color
778  QColor fc = mColor;
780  {
783  }
784 
785  //stroke color
786  QColor oc = mStrokeColor;
788  {
791  }
792 
793  //symbol name
794  QString symbolName = mSymbolName;
796  {
797  context.setOriginalValueVariable( mSymbolName );
799  }
800 
801  //offset
802  double offsetX = 0;
803  double offsetY = 0;
804  markerOffset( context, offsetX, offsetY );
805  QPointF off( offsetX, offsetY );
806 
807  //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
808  double rotation = 0.0;
810  {
811  context.setOriginalValueVariable( mAngle );
813  }
814  else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) )
815  {
816  rotation = mAngle + mLineAngle;
817  }
818  rotation = -rotation; //rotation in Qt is counterclockwise
819  if ( rotation )
820  off = _rotatedOffset( off, rotation );
821 
822  QTransform t;
823  t.translate( shift.x() + offsetX, shift.y() + offsetY );
824 
825  if ( !qgsDoubleNear( rotation, 0.0 ) )
826  t.rotate( rotation );
827 
828  double halfWidth = symbolWidth / 2.0;
829  double halfHeight = symbolHeight / 2.0;
830 
831  if ( symbolName == QLatin1String( "circle" ) )
832  {
833  if ( qgsDoubleNear( halfWidth, halfHeight ) )
834  {
835  QgsPoint pt( t.map( QPointF( 0, 0 ) ) );
836  e.writeFilledCircle( layerName, oc, pt, halfWidth );
837  }
838  else
839  {
840  QgsPointSequence line;
841 
842  double stepsize = 2 * M_PI / 40;
843  for ( int i = 0; i < 39; ++i )
844  {
845  double angle = stepsize * i;
846  double x = halfWidth * std::cos( angle );
847  double y = halfHeight * std::sin( angle );
848  line << QgsPoint( t.map( QPointF( x, y ) ) );
849  }
850  //close ellipse with first point
851  line << line.at( 0 );
852 
853  if ( mBrush.style() != Qt::NoBrush )
854  e.writePolygon( QgsRingSequence() << line, layerName, QStringLiteral( "SOLID" ), fc );
855  if ( mPen.style() != Qt::NoPen )
856  e.writePolyline( line, layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth );
857  }
858  }
859  else if ( symbolName == QLatin1String( "rectangle" ) )
860  {
862  p << QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) )
863  << QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) )
864  << QgsPoint( t.map( QPointF( halfWidth, halfHeight ) ) )
865  << QgsPoint( t.map( QPointF( -halfWidth, halfHeight ) ) );
866  p << p[0];
867 
868  if ( mBrush.style() != Qt::NoBrush )
869  e.writePolygon( QgsRingSequence() << p, layerName, QStringLiteral( "SOLID" ), fc );
870  if ( mPen.style() != Qt::NoPen )
871  e.writePolyline( p, layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth );
872  return true;
873  }
874  else if ( symbolName == QLatin1String( "cross" ) && mPen.style() != Qt::NoPen )
875  {
877  << QgsPoint( t.map( QPointF( -halfWidth, 0 ) ) )
878  << QgsPoint( t.map( QPointF( halfWidth, 0 ) ) ),
879  layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth );
881  << QgsPoint( t.map( QPointF( 0, halfHeight ) ) )
882  << QgsPoint( t.map( QPointF( 0, -halfHeight ) ) ),
883  layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth );
884  return true;
885  }
886  else if ( symbolName == QLatin1String( "triangle" ) )
887  {
889  p << QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) )
890  << QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) )
891  << QgsPoint( t.map( QPointF( 0, halfHeight ) ) );
892  p << p[0];
893  if ( mBrush.style() != Qt::NoBrush )
894  e.writePolygon( QgsRingSequence() << p, layerName, QStringLiteral( "SOLID" ), fc );
895  if ( mPen.style() != Qt::NoPen )
896  e.writePolyline( p, layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth );
897  return true;
898  }
899 
900  return false; //soon...
901 }
902 
903 
QgsEllipseSymbolLayer::setStrokeWidthUnit
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
Definition: qgsellipsesymbollayer.h:127
QgsEllipseSymbolLayer::stopRender
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Definition: qgsellipsesymbollayer.cpp:328
QgsSymbolRenderContext::setOriginalValueVariable
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
Definition: qgssymbol.cpp:1411
QgsProperty::isActive
bool isActive() const
Returns whether the property is currently active.
Definition: qgsproperty.cpp:266
QgsEllipseSymbolLayer::strokeStyle
Qt::PenStyle strokeStyle() const
Definition: qgsellipsesymbollayer.h:62
QgsMarkerSymbolLayer::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
Definition: qgssymbollayer.h:670
QgsEllipseSymbolLayer::strokeWidth
double strokeWidth() const
Definition: qgsellipsesymbollayer.h:78
QgsAbstractPropertyCollection::valueAsDouble
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
Definition: qgspropertycollection.cpp:66
QgsSymbolLayerUtils::encodeColor
static QString encodeColor(const QColor &color)
Definition: qgssymbollayerutils.cpp:52
QgsMarkerSymbolLayer::setHorizontalAnchorPoint
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
Definition: qgssymbollayer.h:770
QgsMarkerSymbolLayer::VerticalAnchorPoint
VerticalAnchorPoint
Symbol vertical anchor points.
Definition: qgssymbollayer.h:595
QgsRenderContext::convertToPainterUnits
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
Definition: qgsrendercontext.cpp:318
QgsSymbolLayer::mColor
QColor mColor
Definition: qgssymbollayer.h:527
QgsRenderContext::mapToPixel
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Definition: qgsrendercontext.h:325
QgsMarkerSymbolLayer::size
double size() const
Returns the symbol size.
Definition: qgssymbollayer.h:661
QgsSymbolLayer::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
Definition: qgssymbollayer.h:486
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsDxfExport
Definition: qgsdxfexport.h:63
QgsMarkerSymbolLayer::mSizeMapUnitScale
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Definition: qgssymbollayer.h:873
QgsRenderContext::expressionContext
QgsExpressionContext & expressionContext()
Gets the expression context.
Definition: qgsrendercontext.h:596
QgsEllipseSymbolLayer::mapUnitScale
QgsMapUnitScale mapUnitScale() const override
Definition: qgsellipsesymbollayer.cpp:664
QgsSymbolLayerUtils::wellKnownMarkerFromSld
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
Definition: qgssymbollayerutils.cpp:2434
QgsMarkerSymbolLayer::mapUnitScale
QgsMapUnitScale mapUnitScale() const override
Definition: qgssymbollayer.cpp:631
QgsSymbolLayerUtils::encodeMapUnitScale
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Definition: qgssymbollayerutils.cpp:558
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
QgsDxfExport::writePolygon
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
Definition: qgsdxfexport.cpp:1163
QgsSymbolLayerUtils::sizeInPixelsFromSldUom
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
Definition: qgssymbollayerutils.cpp:4563
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsSymbolRenderContext::feature
const QgsFeature * feature() const
Returns the current feature being rendered.
Definition: qgssymbol.h:802
QgsEllipseSymbolLayer::strokeColor
QColor strokeColor() const override
Gets stroke color.
Definition: qgsellipsesymbollayer.h:84
qgsexpression.h
QgsEllipseSymbolLayer::setSymbolName
void setSymbolName(const QString &name)
Definition: qgsellipsesymbollayer.h:51
QgsGeometry::isNull
Q_GADGET bool isNull
Definition: qgsgeometry.h:126
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
The fill color.
Definition: qgssymbollayer.h:232
QgsSymbolLayer::color
virtual QColor color() const
The fill color.
Definition: qgssymbollayer.h:227
QgsSymbolLayer::PropertyFillColor
@ PropertyFillColor
Fill color.
Definition: qgssymbollayer.h:135
QgsEllipseSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgsellipsesymbollayer.cpp:638
qgssymbollayerutils.h
QgsMarkerSymbolLayer::setAngle
void setAngle(double angle)
Sets the rotation angle for the marker.
Definition: qgssymbollayer.h:627
QgsEllipseSymbolLayer::setFillColor
void setFillColor(const QColor &c) override
Set fill color.
Definition: qgsellipsesymbollayer.h:80
QgsSymbolRenderContext::opacity
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:764
qgsfeature.h
QgsProperty::asExpression
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
Definition: qgsproperty.cpp:332
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:67
QgsEllipseSymbolLayer::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
Definition: qgsellipsesymbollayer.cpp:656
QgsMarkerSymbolLayer::startRender
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Definition: qgssymbollayer.cpp:447
QgsSymbolLayer::SELECTION_IS_OPAQUE
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
Definition: qgssymbollayer.h:537
qgsunittypes.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsEllipseSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgsellipsesymbollayer.cpp:646
QgsEllipseSymbolLayer::renderPoint
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
Definition: qgsellipsesymbollayer.cpp:169
QgsEllipseSymbolLayer::symbolName
QString symbolName() const
Definition: qgsellipsesymbollayer.h:52
QgsSymbolLayerUtils::encodePenStyle
static QString encodePenStyle(Qt::PenStyle style)
Definition: qgssymbollayerutils.cpp:141
QgsMarkerSymbolLayer::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
Definition: qgssymbollayer.cpp:625
QgsMarkerSymbolLayer::mSizeUnit
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
Definition: qgssymbollayer.h:871
QgsEllipseSymbolLayer::setStrokeColor
void setStrokeColor(const QColor &c) override
Set stroke color.
Definition: qgsellipsesymbollayer.h:83
QgsEllipseSymbolLayer::setSymbolHeightUnit
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
Definition: qgsellipsesymbollayer.h:110
QgsSymbolLayer::PropertyStrokeColor
@ PropertyStrokeColor
Stroke color.
Definition: qgssymbollayer.h:136
QgsEllipseSymbolLayer
A symbol layer for rendering objects with major and minor axis (e.g.
Definition: qgsellipsesymbollayer.h:32
QgsSymbolLayerUtils::decodeColor
static QColor decodeColor(const QString &str)
Definition: qgssymbollayerutils.cpp:57
QgsMarkerSymbolLayer::mVerticalAnchorPoint
VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
Definition: qgssymbollayer.h:885
QgsSymbolLayerUtils::wellKnownMarkerToSld
static void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
Definition: qgssymbollayerutils.cpp:2398
QgsProperty::value
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
Definition: qgsproperty.cpp:519
QgsSymbolLayerUtils::createGeometryElement
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
Definition: qgssymbollayerutils.cpp:2697
QgsPropertyCollection::property
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
Definition: qgspropertycollection.cpp:214
QgsEllipseSymbolLayer::setSymbolWidthMapUnitScale
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:101
QgsEllipseSymbolLayer::setPenJoinStyle
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
Definition: qgsellipsesymbollayer.h:75
QgsMarkerSymbolLayer::mOffsetUnit
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
Definition: qgssymbollayer.h:877
QgsSymbolRenderContext::selected
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
Definition: qgssymbol.h:777
QgsSymbolLayerUtils::createDisplacementElement
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
Definition: qgssymbollayerutils.cpp:2522
QgsMarkerSymbolLayer::mSize
double mSize
Marker size.
Definition: qgssymbollayer.h:869
QgsUnitTypes::decodeRenderUnit
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
Definition: qgsunittypes.cpp:2900
QgsSymbolRenderContext
Definition: qgssymbol.h:695
QgsMarkerSymbolLayer::HorizontalAnchorPoint
HorizontalAnchorPoint
Symbol horizontal anchor points.
Definition: qgssymbollayer.h:587
QgsMarkerSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:610
QgsMarkerSymbolLayer::markerOffset
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
Definition: qgssymbollayer.cpp:477
QgsSymbolLayer
Definition: qgssymbollayer.h:53
QgsUnitTypes::encodeUnit
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
Definition: qgsunittypes.cpp:122
QgsEllipseSymbolLayer::createFromSld
static QgsSymbolLayer * createFromSld(QDomElement &element)
Definition: qgsellipsesymbollayer.cpp:432
QgsEllipseSymbolLayer::setStrokeWidth
void setStrokeWidth(double w)
Definition: qgsellipsesymbollayer.h:77
QgsEllipseSymbolLayer::setSymbolWidthUnit
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
Definition: qgsellipsesymbollayer.h:92
QgsPropertyCollection::hasActiveProperties
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
Definition: qgspropertycollection.cpp:304
qgsDoubleNear
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:315
QgsMapToPixel::mapRotation
double mapRotation() const
Returns current map rotation in degrees (clockwise)
Definition: qgsmaptopixel.cpp:158
QgsSymbolLayerUtils::rescaleUom
static double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap &props)
Rescales the given size based on the uomScale found in the props, if any is found,...
Definition: qgssymbollayerutils.cpp:4428
QgsEllipseSymbolLayer::clone
QgsEllipseSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Definition: qgsellipsesymbollayer.cpp:332
QgsSymbolLayer::copyPaintEffect
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
Definition: qgssymbollayer.cpp:410
QgsSymbolLayerUtils::decodePoint
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
Definition: qgssymbollayerutils.cpp:435
QgsSymbolLayer::PropertyStrokeStyle
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
Definition: qgssymbollayer.h:138
QgsMarkerSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:616
QgsEllipseSymbolLayer::writeSldMarker
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the symbol layer definition as a SLD XML element.
Definition: qgsellipsesymbollayer.cpp:375
qgsrendercontext.h
QgsSymbolLayerUtils::createVendorOptionElement
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
Definition: qgssymbollayerutils.cpp:2889
QgsSymbolLayer::PropertyName
@ PropertyName
Name, eg shape name for simple markers.
Definition: qgssymbollayer.h:134
QgsMarkerSymbolLayer::setOffset
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
Definition: qgssymbollayer.h:718
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:38
QgsSymbolLayer::mDataDefinedProperties
QgsPropertyCollection mDataDefinedProperties
Definition: qgssymbollayer.h:530
QgsSymbolLayer::PropertyStrokeWidth
@ PropertyStrokeWidth
Stroke width.
Definition: qgssymbollayer.h:137
QgsRingSequence
QVector< QgsPointSequence > QgsRingSequence
Definition: qgsabstractgeometry.h:50
QgsEllipseSymbolLayer::fillColor
QColor fillColor() const override
Gets fill color.
Definition: qgsellipsesymbollayer.h:81
QgsMarkerSymbolLayer::setOffsetUnit
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
Definition: qgssymbollayer.h:736
QgsSymbolLayerUtils::encodePoint
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
Definition: qgssymbollayerutils.cpp:430
QgsAbstractPropertyCollection::valueAsString
QString valueAsString(int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a string.
Definition: qgspropertycollection.cpp:42
QgsSymbolRenderContext::renderHints
QgsSymbol::RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
Definition: qgssymbol.h:789
QgsEllipseSymbolLayer::setSymbolHeight
void setSymbolHeight(double h)
Definition: qgsellipsesymbollayer.cpp:632
qgsvectorlayer.h
QgsRenderContext::selectionColor
QColor selectionColor() const
Returns the color to use when rendering selected features.
Definition: qgsrendercontext.h:390
QgsMarkerSymbolLayer::setOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
Definition: qgssymbollayer.h:753
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
QgsMarkerSymbolLayer::mOffset
QPointF mOffset
Marker offset.
Definition: qgssymbollayer.h:875
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsMarkerSymbolLayer::mHorizontalAnchorPoint
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
Definition: qgssymbollayer.h:883
QgsPointSequence
QVector< QgsPoint > QgsPointSequence
Definition: qgsabstractgeometry.h:46
QgsPropertyCollection::value
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection.
Definition: qgspropertycollection.cpp:228
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsEllipseSymbolLayer::toSld
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Definition: qgsellipsesymbollayer.cpp:362
QgsMapToPixel
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:38
QgsDxfExport::writeFilledCircle
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
Definition: qgsdxfexport.cpp:1403
QgsSymbol::DynamicRotation
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
Definition: qgssymbol.h:106
QgsSymbolLayerUtils::getVendorOptionList
static QgsStringMap getVendorOptionList(QDomElement &element)
Definition: qgssymbollayerutils.cpp:2897
QgsMarkerSymbolLayer::mLineAngle
double mLineAngle
Line rotation angle (see setLineAngle() for details)
Definition: qgssymbollayer.h:867
QgsEllipseSymbolLayer::writeDxf
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
Definition: qgsellipsesymbollayer.cpp:737
qgsellipsesymbollayer.h
QgsSymbolLayerUtils::rotationFromSldElement
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
Definition: qgssymbollayerutils.cpp:2491
QgsEllipseSymbolLayer::startRender
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Definition: qgsellipsesymbollayer.cpp:302
QgsSymbolLayer::PropertyAngle
@ PropertyAngle
Symbol angle.
Definition: qgssymbollayer.h:133
QgsEllipseSymbolLayer::symbolWidth
double symbolWidth() const
Definition: qgsellipsesymbollayer.h:57
qgsproperty.h
QgsUnitTypes::RenderUnknownUnit
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:174
QgsSymbolLayer::restoreOldDataDefinedProperties
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
Definition: qgssymbollayer.cpp:281
QgsSymbolLayerUtils::decodePenJoinStyle
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
Definition: qgssymbollayerutils.cpp:188
QgsSymbolLayerUtils::createRotationElement
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
Definition: qgssymbollayerutils.cpp:2481
QgsMarkerSymbolLayer::_rotatedOffset
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
Definition: qgssymbollayer.cpp:571
QgsMarkerSymbolLayer::setSize
virtual void setSize(double size)
Sets the symbol size.
Definition: qgssymbollayer.h:653
QgsMarkerSymbolLayer::offset
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
Definition: qgssymbollayer.h:727
QgsMarkerSymbolLayer::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
Definition: qgssymbollayer.h:687
QgsMarkerSymbolLayer::setVerticalAnchorPoint
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
Definition: qgssymbollayer.h:787
qgsdxfexport.h
QgsEllipseSymbolLayer::properties
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Definition: qgsellipsesymbollayer.cpp:488
QgsEllipseSymbolLayer::create
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Definition: qgsellipsesymbollayer.cpp:46
QgsMarkerSymbolLayer::mAngle
double mAngle
Marker rotation angle, in degrees clockwise from north.
Definition: qgssymbollayer.h:865
QgsSymbolLayerUtils::encodePenJoinStyle
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
Definition: qgssymbollayerutils.cpp:173
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsSymbolRenderContext::renderContext
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Definition: qgssymbol.h:721
QgsEllipseSymbolLayer::QgsEllipseSymbolLayer
QgsEllipseSymbolLayer()
Definition: qgsellipsesymbollayer.cpp:31
QgsSymbolLayer::PropertyHeight
@ PropertyHeight
Symbol height.
Definition: qgssymbollayer.h:142
QgsEllipseSymbolLayer::setStrokeStyle
void setStrokeStyle(Qt::PenStyle strokeStyle)
Definition: qgsellipsesymbollayer.h:63
qgslogger.h
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:179
QgsSymbolLayerUtils::decodePenStyle
static Qt::PenStyle decodePenStyle(const QString &str)
Definition: qgssymbollayerutils.cpp:162
QgsPropertyCollection::isActive
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition: qgspropertycollection.cpp:268
QgsEllipseSymbolLayer::setSize
void setSize(double size) override
Sets the symbol size.
Definition: qgsellipsesymbollayer.cpp:611
QgsEllipseSymbolLayer::setStrokeWidthMapUnitScale
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:135
QgsGeometry::type
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:127
QgsMarkerSymbolLayer::mOffsetMapUnitScale
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
Definition: qgssymbollayer.h:879
MathUtils::angle
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
QgsSymbolLayer::copyDataDefinedProperties
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
Definition: qgssymbollayer.cpp:402
QgsEllipseSymbolLayer::setSymbolHeightMapUnitScale
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:119
QgsSymbolLayerUtils::decodeMapUnitScale
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
Definition: qgssymbollayerutils.cpp:568
QgsMarkerSymbolLayer::angle
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
Definition: qgssymbollayer.h:633
QgsEllipseSymbolLayer::bounds
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
Definition: qgsellipsesymbollayer.cpp:675
QgsEllipseSymbolLayer::layerType
QString layerType() const override
Returns a string that represents this layer type.
Definition: qgsellipsesymbollayer.cpp:297
QgsEllipseSymbolLayer::symbolHeight
double symbolHeight() const
Definition: qgsellipsesymbollayer.h:60
QgsAbstractPropertyCollection::valueAsColor
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color.
Definition: qgspropertycollection.cpp:54
QgsEllipseSymbolLayer::setSymbolWidth
void setSymbolWidth(double w)
Definition: qgsellipsesymbollayer.cpp:626
QgsDxfExport::writePolyline
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
Definition: qgsdxfexport.cpp:937
QgsSymbolLayer::PropertyJoinStyle
@ PropertyJoinStyle
Line join style.
Definition: qgssymbollayer.h:145
QgsSymbolLayer::PropertyWidth
@ PropertyWidth
Symbol width.
Definition: qgssymbollayer.h:141