QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsmarkersymbol.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmarkersymbol.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
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 
16 #include "qgsmarkersymbol.h"
17 #include "qgsmarkersymbollayer.h"
19 #include "qgssymbollayerutils.h"
20 #include "qgspainteffect.h"
21 
22 QgsMarkerSymbol *QgsMarkerSymbol::createSimple( const QVariantMap &properties )
23 {
25  if ( !sl )
26  return nullptr;
27 
28  QgsSymbolLayerList layers;
29  layers.append( sl );
30  return new QgsMarkerSymbol( layers );
31 }
32 
34  : QgsSymbol( Qgis::SymbolType::Marker, layers )
35 {
36  if ( mLayers.isEmpty() )
37  mLayers.append( new QgsSimpleMarkerSymbolLayer() );
38 }
39 
40 void QgsMarkerSymbol::setAngle( double symbolAngle ) const
41 {
42  double origAngle = angle();
43  double angleDiff = symbolAngle - origAngle;
44  const auto constMLayers = mLayers;
45  for ( QgsSymbolLayer *layer : constMLayers )
46  {
47  QgsMarkerSymbolLayer *markerLayer = dynamic_cast<QgsMarkerSymbolLayer *>( layer );
48  if ( markerLayer )
49  markerLayer->setAngle( markerLayer->angle() + angleDiff );
50  }
51 }
52 
53 double QgsMarkerSymbol::angle() const
54 {
55  for ( QgsSymbolLayer *layer : std::as_const( mLayers ) )
56  {
58  continue;
59  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
60  return markerLayer->angle();
61  }
62  return 0;
63 }
64 
65 void QgsMarkerSymbol::setLineAngle( double lineAng ) const
66 {
67  const auto constMLayers = mLayers;
68  for ( QgsSymbolLayer *layer : constMLayers )
69  {
71  continue;
72  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( layer );
73  markerLayer->setLineAngle( lineAng );
74  }
75 }
76 
78 {
79  const double symbolRotation = angle();
80 
81 
82  for ( QgsSymbolLayer *layer : std::as_const( mLayers ) )
83  {
85  continue;
86  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
87  if ( !property )
88  {
89  layer->setDataDefinedProperty( QgsSymbolLayer::PropertyAngle, QgsProperty() );
90  }
91  else
92  {
93  if ( qgsDoubleNear( markerLayer->angle(), symbolRotation ) )
94  {
95  layer->setDataDefinedProperty( QgsSymbolLayer::PropertyAngle, property );
96  }
97  else
98  {
99  QgsProperty rotatedDD = QgsSymbolLayerUtils::rotateWholeSymbol( markerLayer->angle() - symbolRotation, property );
100  layer->setDataDefinedProperty( QgsSymbolLayer::PropertyAngle, rotatedDD );
101  }
102  }
103  }
104 }
105 
107 {
108  const double symbolRotation = angle();
109  QgsProperty symbolDD;
110 
111  // find the base of the "en masse" pattern
112  const auto layers = mLayers;
113  for ( QgsSymbolLayer *layer : layers )
114  {
115  if ( layer->type() != Qgis::SymbolType::Marker )
116  continue;
117  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
118  if ( qgsDoubleNear( markerLayer->angle(), symbolRotation ) && markerLayer->dataDefinedProperties().isActive( QgsSymbolLayer::PropertyAngle ) )
119  {
120  symbolDD = markerLayer->dataDefinedProperties().property( QgsSymbolLayer::PropertyAngle );
121  break;
122  }
123  }
124 
125  if ( !symbolDD )
126  return QgsProperty();
127 
128  // check that all layer's angle expressions match the "en masse" pattern
129  for ( QgsSymbolLayer *layer : layers )
130  {
131  if ( layer->type() != Qgis::SymbolType::Marker )
132  continue;
133  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
134 
136 
137  if ( qgsDoubleNear( markerLayer->angle(), symbolRotation ) )
138  {
139  if ( !layerAngleDD || layerAngleDD != symbolDD )
140  return QgsProperty();
141  }
142  else
143  {
144  QgsProperty rotatedDD( QgsSymbolLayerUtils::rotateWholeSymbol( markerLayer->angle() - symbolRotation, symbolDD ) );
145  if ( !layerAngleDD || layerAngleDD != rotatedDD )
146  return QgsProperty();
147  }
148  }
149  return symbolDD;
150 }
151 
152 
153 void QgsMarkerSymbol::setSize( double s ) const
154 {
155  double origSize = size();
156 
157  const auto constMLayers = mLayers;
158  for ( QgsSymbolLayer *layer : constMLayers )
159  {
160  QgsMarkerSymbolLayer *markerLayer = dynamic_cast<QgsMarkerSymbolLayer *>( layer );
161  if ( markerLayer )
162  {
163  if ( qgsDoubleNear( markerLayer->size(), origSize ) )
164  {
165  markerLayer->setSize( s );
166  }
167  else if ( !qgsDoubleNear( origSize, 0.0 ) )
168  {
169  // proportionally scale size
170  markerLayer->setSize( markerLayer->size() * s / origSize );
171  }
172  // also scale offset to maintain relative position
173  if ( !qgsDoubleNear( origSize, 0.0 ) && ( !qgsDoubleNear( markerLayer->offset().x(), 0.0 ) || !qgsDoubleNear( markerLayer->offset().y(), 0.0 ) ) )
174  markerLayer->setOffset( QPointF( markerLayer->offset().x() * s / origSize,
175  markerLayer->offset().y() * s / origSize ) );
176  }
177  else
178  {
179  QgsGeometryGeneratorSymbolLayer *geomGeneratorLayer = dynamic_cast<QgsGeometryGeneratorSymbolLayer *>( layer );
180  if ( geomGeneratorLayer && geomGeneratorLayer->symbolType() == Qgis::SymbolType::Marker )
181  {
182  QgsMarkerSymbol *markerSymbol = qgis::down_cast<QgsMarkerSymbol *>( geomGeneratorLayer->subSymbol() );
183  if ( qgsDoubleNear( markerSymbol->size(), origSize ) )
184  {
185  markerSymbol->setSize( s );
186  }
187  else if ( !qgsDoubleNear( origSize, 0.0 ) )
188  {
189  // proportionally scale the width
190  markerSymbol->setSize( markerSymbol->size() * s / origSize );
191  }
192  }
193  }
194  }
195 }
196 
197 double QgsMarkerSymbol::size() const
198 {
199  // return size of the largest symbol
200  double maxSize = 0;
201  const auto constMLayers = mLayers;
202  for ( QgsSymbolLayer *layer : constMLayers )
203  {
204  const QgsMarkerSymbolLayer *markerLayer = dynamic_cast<QgsMarkerSymbolLayer *>( layer );
205  if ( markerLayer )
206  {
207  const double lsize = markerLayer->size();
208  if ( lsize > maxSize )
209  maxSize = lsize;
210  }
211  else
212  {
213  QgsGeometryGeneratorSymbolLayer *geomGeneratorLayer = dynamic_cast<QgsGeometryGeneratorSymbolLayer *>( layer );
214  if ( geomGeneratorLayer && geomGeneratorLayer->symbolType() == Qgis::SymbolType::Marker )
215  {
216  QgsMarkerSymbol *markerSymbol = qgis::down_cast<QgsMarkerSymbol *>( geomGeneratorLayer->subSymbol() );
217  const double lsize = markerSymbol->size();
218  if ( lsize > maxSize )
219  maxSize = lsize;
220  }
221  }
222  }
223  return maxSize;
224 }
225 
226 double QgsMarkerSymbol::size( const QgsRenderContext &context ) const
227 {
228  // return size of the largest symbol
229  double maxSize = 0;
230  for ( QgsSymbolLayer *layer : mLayers )
231  {
232  if ( layer->type() != Qgis::SymbolType::Marker )
233  continue;
234  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
235  const double layerSize = context.convertToPainterUnits( markerLayer->size(), markerLayer->sizeUnit(), markerLayer->sizeMapUnitScale() );
236  maxSize = std::max( maxSize, layerSize );
237  }
238  return maxSize;
239 }
240 
242 {
243  const auto constMLayers = mLayers;
244  for ( QgsSymbolLayer *layer : constMLayers )
245  {
246  if ( layer->type() != Qgis::SymbolType::Marker )
247  continue;
248 
249  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( layer );
250  markerLayer->setSizeUnit( unit );
251  }
252 }
253 
255 {
256  bool first = true;
258 
259  const auto constMLayers = mLayers;
260  for ( QgsSymbolLayer *layer : constMLayers )
261  {
262  if ( layer->type() != Qgis::SymbolType::Marker )
263  continue;
264  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
265 
266  if ( first )
267  unit = markerLayer->sizeUnit();
268  else
269  {
270  if ( unit != markerLayer->sizeUnit() )
272  }
273 
274  first = false;
275  }
276  return unit;
277 }
278 
280 {
281  const auto constMLayers = mLayers;
282  for ( QgsSymbolLayer *layer : constMLayers )
283  {
284  if ( layer->type() != Qgis::SymbolType::Marker )
285  continue;
286 
287  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( layer );
288  markerLayer->setSizeMapUnitScale( scale );
289  }
290 }
291 
293 {
294  const auto constMLayers = mLayers;
295  for ( QgsSymbolLayer *layer : constMLayers )
296  {
297  if ( layer->type() != Qgis::SymbolType::Marker )
298  continue;
299 
300  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( layer );
301  return markerLayer->sizeMapUnitScale();
302  }
303  return QgsMapUnitScale();
304 }
305 
307 {
308  const double symbolSize = size();
309 
310  const auto constMLayers = mLayers;
311  for ( QgsSymbolLayer *layer : constMLayers )
312  {
313  if ( layer->type() != Qgis::SymbolType::Marker )
314  continue;
315  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( layer );
316 
317  if ( !property )
318  {
321  }
322  else
323  {
324  if ( qgsDoubleNear( symbolSize, 0.0 ) || qgsDoubleNear( markerLayer->size(), symbolSize ) )
325  {
326  markerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertySize, property );
327  }
328  else
329  {
330  markerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertySize, QgsSymbolLayerUtils::scaleWholeSymbol( markerLayer->size() / symbolSize, property ) );
331  }
332 
333  if ( !qgsDoubleNear( markerLayer->offset().x(), 0.0 ) || !qgsDoubleNear( markerLayer->offset().y(), 0.0 ) )
334  {
335  markerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertyOffset, QgsSymbolLayerUtils::scaleWholeSymbol(
336  markerLayer->offset().x() / symbolSize,
337  markerLayer->offset().y() / symbolSize, property ) );
338  }
339  }
340  }
341 }
342 
344 {
345  const double symbolSize = size();
346 
347  QgsProperty symbolDD;
348 
349  // find the base of the "en masse" pattern
350  const auto layers = mLayers;
351  for ( QgsSymbolLayer *layer : layers )
352  {
353  if ( layer->type() != Qgis::SymbolType::Marker )
354  continue;
355  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
356  if ( qgsDoubleNear( markerLayer->size(), symbolSize ) && markerLayer->dataDefinedProperties().isActive( QgsSymbolLayer::PropertySize ) )
357  {
358  symbolDD = markerLayer->dataDefinedProperties().property( QgsSymbolLayer::PropertySize );
359  break;
360  }
361  }
362 
363  if ( !symbolDD )
364  return QgsProperty();
365 
366  // check that all layers size expressions match the "en masse" pattern
367  for ( QgsSymbolLayer *layer : layers )
368  {
369  if ( layer->type() != Qgis::SymbolType::Marker )
370  continue;
371  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
372 
375 
376  if ( qgsDoubleNear( markerLayer->size(), symbolSize ) )
377  {
378  if ( !layerSizeDD || layerSizeDD != symbolDD )
379  return QgsProperty();
380  }
381  else
382  {
383  if ( qgsDoubleNear( symbolSize, 0.0 ) )
384  return QgsProperty();
385 
386  QgsProperty scaledDD( QgsSymbolLayerUtils::scaleWholeSymbol( markerLayer->size() / symbolSize, symbolDD ) );
387  if ( !layerSizeDD || layerSizeDD != scaledDD )
388  return QgsProperty();
389  }
390 
391  QgsProperty scaledOffsetDD( QgsSymbolLayerUtils::scaleWholeSymbol( markerLayer->offset().x() / symbolSize, markerLayer->offset().y() / symbolSize, symbolDD ) );
392  if ( layerOffsetDD && layerOffsetDD != scaledOffsetDD )
393  return QgsProperty();
394  }
395 
396  return symbolDD;
397 }
398 
400 {
401  const auto constMLayers = mLayers;
402  for ( QgsSymbolLayer *layer : constMLayers )
403  {
404  if ( layer->type() != Qgis::SymbolType::Marker )
405  continue;
406  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( layer );
407  markerLayer->setScaleMethod( scaleMethod );
408  }
409 }
410 
412 {
413  const auto constMLayers = mLayers;
414  for ( QgsSymbolLayer *layer : constMLayers )
415  {
416  if ( layer->type() != Qgis::SymbolType::Marker )
417  continue;
418  const QgsMarkerSymbolLayer *markerLayer = static_cast<const QgsMarkerSymbolLayer *>( layer );
419  // return scale method of the first symbol layer
420  return markerLayer->scaleMethod();
421  }
422 
423  return DEFAULT_SCALE_METHOD;
424 }
425 
426 void QgsMarkerSymbol::renderPointUsingLayer( QgsMarkerSymbolLayer *layer, QPointF point, QgsSymbolRenderContext &context )
427 {
428  static QPointF nullPoint( 0, 0 );
429 
430  if ( layer->dataDefinedProperties().hasActiveProperties() && !layer->dataDefinedProperties().valueAsBool( QgsSymbolLayer::PropertyLayerEnabled, context.renderContext().expressionContext(), true ) )
431  return;
432 
433  QgsPaintEffect *effect = layer->paintEffect();
434  if ( effect && effect->enabled() )
435  {
436  QgsEffectPainter p( context.renderContext() );
437  p->translate( point );
438  p.setEffect( effect );
439  layer->renderPoint( nullPoint, context );
440  }
441  else
442  {
443  layer->renderPoint( point, context );
444  }
445 }
446 
447 void QgsMarkerSymbol::renderPoint( QPointF point, const QgsFeature *f, QgsRenderContext &context, int layerIdx, bool selected )
448 {
450  : mOpacity;
451 
452  QgsSymbolRenderContext symbolContext( context, QgsUnitTypes::RenderUnknownUnit, opacity, selected, mRenderHints, f );
453  symbolContext.setGeometryPartCount( symbolRenderContext()->geometryPartCount() );
454  symbolContext.setGeometryPartNum( symbolRenderContext()->geometryPartNum() );
455 
456  if ( layerIdx != -1 )
457  {
458  QgsSymbolLayer *symbolLayer = mLayers.value( layerIdx );
460  {
462  {
463  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( symbolLayer );
464  renderPointUsingLayer( markerLayer, point, symbolContext );
465  }
466  else
467  {
468  QPolygonF points;
469  points.append( point );
470  renderUsingLayer( symbolLayer, symbolContext, QgsWkbTypes::PointGeometry, &points );
471  }
472  }
473  return;
474  }
475 
476 
477  for ( QgsSymbolLayer *symbolLayer : std::as_const( mLayers ) )
478  {
479  if ( context.renderingStopped() )
480  break;
481 
482  if ( !symbolLayer->enabled() || !context.isSymbolLayerEnabled( symbolLayer ) )
483  continue;
484 
486  {
487  QgsMarkerSymbolLayer *markerLayer = static_cast<QgsMarkerSymbolLayer *>( symbolLayer );
488  renderPointUsingLayer( markerLayer, point, symbolContext );
489  }
490  else
491  {
492  QPolygonF points;
493  points.append( point );
494  renderUsingLayer( symbolLayer, symbolContext, QgsWkbTypes::PointGeometry, &points );
495  }
496  }
497 }
498 
499 QRectF QgsMarkerSymbol::bounds( QPointF point, QgsRenderContext &context, const QgsFeature &feature ) const
500 {
501  QgsSymbolRenderContext symbolContext( context, QgsUnitTypes::RenderUnknownUnit, mOpacity, false, mRenderHints, &feature, feature.fields() );
502 
503  QRectF bound;
504  const auto constMLayers = mLayers;
505  for ( QgsSymbolLayer *layer : constMLayers )
506  {
507  if ( layer->type() == Qgis::SymbolType::Marker )
508  {
509  if ( !layer->enabled()
510  || ( layer->dataDefinedProperties().hasActiveProperties() && !layer->dataDefinedProperties().valueAsBool( QgsSymbolLayer::PropertyLayerEnabled, context.expressionContext(), true ) ) )
511  continue;
512 
514  if ( bound.isNull() )
515  bound = symbolLayer->bounds( point, symbolContext );
516  else
517  bound = bound.united( symbolLayer->bounds( point, symbolContext ) );
518  }
519  }
520  return bound;
521 }
522 
524 {
525  QgsMarkerSymbol *cloneSymbol = new QgsMarkerSymbol( cloneLayers() );
526  cloneSymbol->setOpacity( mOpacity );
528  cloneSymbol->setLayer( mLayer );
531  cloneSymbol->setForceRHR( mForceRHR );
533  cloneSymbol->setFlags( mSymbolFlags );
535  return cloneSymbol;
536 }
QgsSymbol::setLayer
Q_DECL_DEPRECATED void setLayer(const QgsVectorLayer *layer)
Definition: qgssymbol.cpp:1196
QgsSymbol::cloneLayers
QgsSymbolLayerList cloneLayers() const
Retrieve a cloned list of all layers that make up this symbol.
Definition: qgssymbol.cpp:1116
QgsSymbolLayer::enabled
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
Definition: qgssymbollayer.h:242
QgsSymbol::mLayer
const Q_DECL_DEPRECATED QgsVectorLayer * mLayer
Definition: qgssymbol.h:805
QgsMarkerSymbolLayer::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
Definition: qgssymbollayer.h:794
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
QgsMarkerSymbol::setDataDefinedAngle
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:77
QgsMarkerSymbolLayer::size
double size() const
Returns the symbol size.
Definition: qgssymbollayer.h:785
QgsSymbolLayer::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
Definition: qgssymbollayer.h:595
QgsProperty
A store for object properties.
Definition: qgsproperty.h:230
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsRenderContext::expressionContext
QgsExpressionContext & expressionContext()
Gets the expression context.
Definition: qgsrendercontext.h:625
QgsEffectPainter
A class to manager painter saving and restoring required for effect drawing.
Definition: qgspainteffect.h:395
QgsMarkerSymbol::size
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
Definition: qgsmarkersymbol.cpp:197
QgsGeometryGeneratorSymbolLayer::subSymbol
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Definition: qgsgeometrygeneratorsymbollayer.h:105
QgsMarkerSymbol::setLineAngle
void setLineAngle(double lineAngle) const
Sets the line angle modification for the symbol's angle.
Definition: qgsmarkersymbol.cpp:65
QgsMarkerSymbol::dataDefinedSize
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:343
QgsSymbol::layer
const Q_DECL_DEPRECATED QgsVectorLayer * layer() const
Definition: qgssymbol.cpp:1203
qgssymbollayerutils.h
QgsMarkerSymbolLayer::setAngle
void setAngle(double angle)
Sets the rotation angle for the marker.
Definition: qgssymbollayer.h:751
QgsSymbolRenderContext::setGeometryPartNum
void setGeometryPartNum(int num)
Sets the part number of current geometry.
Definition: qgssymbolrendercontext.h:192
QgsSymbol::setDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol's property collection, used for data defined overrides.
Definition: qgssymbol.h:637
qgsmarkersymbollayer.h
QgsMarkerSymbol::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale) const
Sets the size map unit scale for the whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:279
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsMarkerSymbolLayer::setScaleMethod
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
Definition: qgssymbollayer.h:826
QgsMarkerSymbolLayer
Abstract base class for marker symbol layers.
Definition: qgssymbollayer.h:705
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:92
qgspainteffect.h
QgsMarkerSymbol::angle
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgsmarkersymbol.cpp:53
QgsSymbol::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
Definition: qgssymbol.h:622
QgsSymbol::symbolLayer
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
Definition: qgssymbol.cpp:725
QgsMarkerSymbol::scaleMethod
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
Definition: qgsmarkersymbol.cpp:411
QgsSymbol::PropertyOpacity
@ PropertyOpacity
Opacity.
Definition: qgssymbol.h:131
QgsMarkerSymbol::setDataDefinedSize
void setDataDefinedSize(const QgsProperty &property) const
Set data defined size for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:306
QgsRenderContext::isSymbolLayerEnabled
bool isSymbolLayerEnabled(const QgsSymbolLayer *layer) const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
Definition: qgsrendercontext.h:166
QgsPropertyCollection::property
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
Definition: qgspropertycollection.cpp:214
QgsMarkerSymbol::clone
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
Definition: qgsmarkersymbol.cpp:523
Qgis::ScaleMethod
ScaleMethod
Scale methods.
Definition: qgis.h:219
QgsMarkerSymbolLayer::sizeUnit
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
Definition: qgssymbollayer.h:802
QgsSymbolRenderContext
Definition: qgssymbolrendercontext.h:35
QgsSymbol::setOpacity
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Definition: qgssymbol.h:502
Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:2820
QgsRenderContext::renderingStopped
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
Definition: qgsrendercontext.h:285
QgsSymbol::setClipFeaturesToExtent
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent.
Definition: qgssymbol.h:541
QgsSimpleMarkerSymbolLayer::create
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsSimpleMarkerSymbolLayer.
Definition: qgsmarkersymbollayer.cpp:851
QgsSymbol::opacity
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:495
QgsMarkerSymbolLayer::scaleMethod
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
Definition: qgssymbollayer.h:832
QgsSymbolLayer::PropertyOffset
@ PropertyOffset
Symbol offset.
Definition: qgssymbollayer.h:151
QgsSymbolLayer
Definition: qgssymbollayer.h:54
QgsSymbol::setAnimationSettings
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets a the symbol animation settings.
Definition: qgssymbol.cpp:668
QgsMarkerSymbol::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit) const
Sets the size units for the whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:241
QgsSymbol::mRenderHints
Qgis::SymbolRenderHints mRenderHints
Definition: qgssymbol.h:791
QgsSymbol::mLayers
QgsSymbolLayerList mLayers
Definition: qgssymbol.h:786
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
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
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:2265
QgsSimpleMarkerSymbolLayer
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
Definition: qgsmarkersymbollayer.h:176
QgsSymbolLayer::PropertySize
@ PropertySize
Symbol size.
Definition: qgssymbollayer.h:144
QgsSymbolRenderContext::setGeometryPartCount
void setGeometryPartCount(int count)
Sets the part count of current geometry.
Definition: qgssymbolrendercontext.h:180
QgsGeometryGeneratorSymbolLayer
Definition: qgsgeometrygeneratorsymbollayer.h:31
QgsMarkerSymbol::setAngle
void setAngle(double symbolAngle) const
Sets the angle for the whole symbol.
Definition: qgsmarkersymbol.cpp:40
QgsSymbol::renderUsingLayer
void renderUsingLayer(QgsSymbolLayer *layer, QgsSymbolRenderContext &context, QgsWkbTypes::GeometryType geometryType=QgsWkbTypes::GeometryType::UnknownGeometry, const QPolygonF *points=nullptr, const QVector< QPolygonF > *rings=nullptr)
Renders a context using a particular symbol layer without passing in a geometry.
Definition: qgssymbol.cpp:1130
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:842
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsGeometryGeneratorSymbolLayer::symbolType
Qgis::SymbolType symbolType() const
Access the symbol type.
Definition: qgsgeometrygeneratorsymbollayer.h:55
QgsMarkerSymbol::setScaleMethod
void setScaleMethod(Qgis::ScaleMethod scaleMethod) const
Sets the method to use for scaling the marker's size.
Definition: qgsmarkersymbol.cpp:399
QgsSymbol::symbolRenderContext
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
Definition: qgssymbol.cpp:1793
QgsSymbol::setForceRHR
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
Definition: qgssymbol.h:563
QgsMarkerSymbolLayer::setLineAngle
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
Definition: qgssymbollayer.h:768
QgsMarkerSymbol::bounds
QRectF bounds(QPointF point, QgsRenderContext &context, const QgsFeature &feature=QgsFeature()) const
Returns the approximate bounding box of the marker symbol, which includes the bounding box of all sym...
Definition: qgsmarkersymbol.cpp:499
QgsSymbolLayer::PropertyLayerEnabled
@ PropertyLayerEnabled
Whether symbol layer is enabled.
Definition: qgssymbollayer.h:188
QgsRenderContext::convertToPainterUnits
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
Definition: qgsrendercontext.cpp:367
QgsSymbol::mOpacity
qreal mOpacity
Symbol opacity (in the range 0 - 1)
Definition: qgssymbol.h:789
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsSymbolLayer::type
Qgis::SymbolType type() const
Definition: qgssymbollayer.h:437
QgsMarkerSymbol::dataDefinedAngle
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:106
QgsSymbolLayerList
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition: qgssymbol.h:27
qgsmarkersymbol.h
DEFAULT_SCALE_METHOD
#define DEFAULT_SCALE_METHOD
Definition: qgssymbollayer.h:19
QgsMarkerSymbol::setSize
void setSize(double size) const
Sets the size for the whole symbol.
Definition: qgsmarkersymbol.cpp:153
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:52
QgsSymbol::setFlags
void setFlags(Qgis::SymbolFlags flags)
Sets flags for the symbol.
Definition: qgssymbol.h:522
QgsSymbolLayer::PropertyAngle
@ PropertyAngle
Symbol angle.
Definition: qgssymbollayer.h:145
QgsUnitTypes::RenderUnknownUnit
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:175
QgsMarkerSymbolLayer::setSize
virtual void setSize(double size)
Sets the symbol size.
Definition: qgssymbollayer.h:777
QgsMarkerSymbolLayer::offset
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
Definition: qgssymbollayer.h:851
QgsMarkerSymbolLayer::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
Definition: qgssymbollayer.h:811
Qgis
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:71
QgsFeature::fields
QgsFields fields
Definition: qgsfeature.h:70
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsSymbolRenderContext::renderContext
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Definition: qgssymbolrendercontext.h:62
QgsMarkerSymbol::sizeUnit
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the size units for the whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:254
qgsgeometrygeneratorsymbollayer.h
QgsPaintEffect::enabled
bool enabled() const
Returns whether the effect is enabled.
Definition: qgspainteffect.h:197
QgsMarkerSymbol::QgsMarkerSymbol
QgsMarkerSymbol(const QgsSymbolLayerList &layers=QgsSymbolLayerList())
Constructor for QgsMarkerSymbol, with the specified list of initial symbol layers.
Definition: qgsmarkersymbol.cpp:33
QgsSymbol::mForceRHR
bool mForceRHR
Definition: qgssymbol.h:801
QgsMarkerSymbol::sizeMapUnitScale
QgsMapUnitScale sizeMapUnitScale() const
Returns the size map unit scale for the whole symbol.
Definition: qgsmarkersymbol.cpp:292
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
QgsSymbol::mAnimationSettings
QgsSymbolAnimationSettings mAnimationSettings
Definition: qgssymbol.h:803
Q_NOWARN_DEPRECATED_PUSH
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:2819
QgsMarkerSymbol::renderPoint
void renderPoint(QPointF point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
Renders the symbol at the specified point, using the given render context.
Definition: qgsmarkersymbol.cpp:447
QgsMarkerSymbol::createSimple
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
Definition: qgsmarkersymbol.cpp:22
QgsSymbol::mSymbolFlags
Qgis::SymbolFlags mSymbolFlags
Symbol flags.
Definition: qgssymbol.h:798
QgsMarkerSymbolLayer::angle
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
Definition: qgssymbollayer.h:757
Qgis::SymbolType::Marker
@ Marker
Marker symbol.
QgsSymbolLayer::setDataDefinedProperty
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
Definition: qgssymbollayer.cpp:126
QgsSymbol::mClipFeaturesToExtent
bool mClipFeaturesToExtent
Definition: qgssymbol.h:800
QgsMarkerSymbolLayer::sizeMapUnitScale
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
Definition: qgssymbollayer.h:819
QgsMapLayer::type
QgsMapLayerType type
Definition: qgsmaplayer.h:80