QGIS API Documentation  3.25.0-Master (349eb7cb1e)
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 }
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:72
ScaleMethod
Scale methods.
Definition: qgis.h:219
@ Marker
Marker symbol.
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.
A class to manager painter saving and restoring required for effect drawing.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
QgsFields fields
Definition: qgsfeature.h:66
Qgis::SymbolType symbolType() const
Access the symbol type.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
QgsMapLayerType type
Definition: qgsmaplayer.h:80
Struct for storing maximum and minimum scales for measurements in map units.
Abstract base class for marker symbol layers.
virtual void setSize(double size)
Sets the symbol size.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setAngle(double angle)
Sets the rotation angle for the marker.
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
double size() const
Returns the symbol size.
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
A marker symbol type, for rendering Point and MultiPoint geometries.
void setScaleMethod(Qgis::ScaleMethod scaleMethod) const
Sets the method to use for scaling the marker's size.
void setAngle(double symbolAngle) const
Sets the angle for the whole symbol.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the size units for the whole symbol (including all symbol layers).
void setSize(double size) const
Sets the size for the whole symbol.
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
QgsMarkerSymbol(const QgsSymbolLayerList &layers=QgsSymbolLayerList())
Constructor for QgsMarkerSymbol, with the specified list of initial symbol layers.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
double angle() const
Returns the marker angle for the whole symbol.
QgsMapUnitScale sizeMapUnitScale() const
Returns the size map unit scale for the whole symbol.
void setSizeUnit(QgsUnitTypes::RenderUnit unit) const
Sets the size units for the whole symbol (including all symbol layers).
void setLineAngle(double lineAngle) const
Sets the line angle modification for the symbol's angle.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
void setDataDefinedSize(const QgsProperty &property) const
Set data defined size for whole symbol (including all symbol layers).
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
void setSizeMapUnitScale(const QgsMapUnitScale &scale) const
Sets the size map unit scale for the whole symbol (including all symbol layers).
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
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.
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
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...
Base class for visual effects which can be applied to QPicture drawings.
bool enabled() const
Returns whether the effect is enabled.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
A store for object properties.
Definition: qgsproperty.h:231
Contains information about the context of a rendering operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
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).
bool isSymbolLayerEnabled(const QgsSymbolLayer *layer) const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsSimpleMarkerSymbolLayer.
@ PropertyAngle
Symbol angle.
@ PropertySize
Symbol size.
@ PropertyOffset
Symbol offset.
@ PropertyLayerEnabled
Whether symbol layer is enabled.
Qgis::SymbolType type() const
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
void setGeometryPartCount(int count)
Sets the part count of current geometry.
void setGeometryPartNum(int num)
Sets the part number of current geometry.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:93
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol's property collection, used for data defined overrides.
Definition: qgssymbol.h:637
Qgis::SymbolFlags mSymbolFlags
Symbol flags.
Definition: qgssymbol.h:798
QgsSymbolLayerList cloneLayers() const
Retrieve a cloned list of all layers that make up this symbol.
Definition: qgssymbol.cpp:814
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
Definition: qgssymbol.cpp:1491
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
Definition: qgssymbol.cpp:423
@ PropertyOpacity
Opacity.
Definition: qgssymbol.h:131
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:828
qreal mOpacity
Symbol opacity (in the range 0 - 1)
Definition: qgssymbol.h:789
Q_DECL_DEPRECATED const QgsVectorLayer * mLayer
Definition: qgssymbol.h:805
bool mClipFeaturesToExtent
Definition: qgssymbol.h:800
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:495
void setFlags(Qgis::SymbolFlags flags)
Sets flags for the symbol.
Definition: qgssymbol.h:522
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
Definition: qgssymbol.h:622
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Definition: qgssymbol.h:502
Qgis::SymbolRenderHints mRenderHints
Definition: qgssymbol.h:791
bool mForceRHR
Definition: qgssymbol.h:801
QgsSymbolLayerList mLayers
Definition: qgssymbol.h:786
Q_DECL_DEPRECATED const QgsVectorLayer * layer() const
Definition: qgssymbol.cpp:901
QgsSymbolAnimationSettings mAnimationSettings
Definition: qgssymbol.h:803
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets a the symbol animation settings.
Definition: qgssymbol.cpp:366
Q_DECL_DEPRECATED void setLayer(const QgsVectorLayer *layer)
Definition: qgssymbol.cpp:894
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent.
Definition: qgssymbol.h:541
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
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:175
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:2630
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:2629
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:2075
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition: qgssymbol.h:27
#define DEFAULT_SCALE_METHOD