QGIS API Documentation  3.23.0-Master (eb871beae0)
qgssymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayer.h
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 #ifndef QGSSYMBOLLAYER_H
16 #define QGSSYMBOLLAYER_H
17 
18 #define DEG2RAD(x) ((x)*M_PI/180)
19 #define DEFAULT_SCALE_METHOD Qgis::ScaleMethod::ScaleDiameter
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
23 #include "qgsfields.h"
24 #include "qgspropertycollection.h"
25 #include "qgssymbolrendercontext.h"
26 
27 #include <QColor>
28 #include <QMap>
29 #include <QPointF>
30 #include <QSet>
31 #include <QDomDocument>
32 #include <QDomElement>
33 #include <QPainterPath>
34 
35 class QPainter;
36 class QSize;
37 class QPolygonF;
38 
39 class QgsDxfExport;
40 class QgsExpression;
41 class QgsRenderContext;
42 class QgsPaintEffect;
44 
45 #ifndef SIP_RUN
46 typedef QMap<QString, QString> QgsStringMap;
47 #endif
48 
53 class CORE_EXPORT QgsSymbolLayer
54 {
55 #ifdef SIP_RUN
56 #include <qgslinesymbollayer.h>
57 #endif
58 
59 
60 #ifdef SIP_RUN
62  switch ( sipCpp->type() )
63  {
65  if ( sipCpp->layerType() == "EllipseMarker" )
66  sipType = sipType_QgsEllipseSymbolLayer;
67  else if ( sipCpp->layerType() == "FontMarker" )
68  sipType = sipType_QgsFontMarkerSymbolLayer;
69  else if ( sipCpp->layerType() == "SimpleMarker" )
70  sipType = sipType_QgsSimpleMarkerSymbolLayer;
71  else if ( sipCpp->layerType() == "FilledMarker" )
72  sipType = sipType_QgsFilledMarkerSymbolLayer;
73  else if ( sipCpp->layerType() == "SvgMarker" )
74  sipType = sipType_QgsSvgMarkerSymbolLayer;
75  else if ( sipCpp->layerType() == "RasterMarker" )
76  sipType = sipType_QgsRasterMarkerSymbolLayer;
77  else if ( sipCpp->layerType() == "VectorField" )
78  sipType = sipType_QgsVectorFieldSymbolLayer;
79  else if ( sipCpp->layerType() == "MaskMarker" )
80  sipType = sipType_QgsMaskMarkerSymbolLayer;
81  else
82  sipType = sipType_QgsMarkerSymbolLayer;
83  break;
84 
86  if ( sipCpp->layerType() == "MarkerLine" )
87  sipType = sipType_QgsMarkerLineSymbolLayer;
88  else if ( sipCpp->layerType() == "SimpleLine" )
89  sipType = sipType_QgsSimpleLineSymbolLayer;
90  else if ( sipCpp->layerType() == "HashLine" )
91  sipType = sipType_QgsHashedLineSymbolLayer;
92  else if ( sipCpp->layerType() == "ArrowLine" )
93  sipType = sipType_QgsArrowSymbolLayer;
94  else if ( sipCpp->layerType() == "InterpolatedLine" )
95  sipType = sipType_QgsInterpolatedLineSymbolLayer;
96  else if ( sipCpp->layerType() == "RasterLine" )
97  sipType = sipType_QgsRasterLineSymbolLayer;
98  else if ( sipCpp->layerType() == "Lineburst" )
99  sipType = sipType_QgsLineburstSymbolLayer;
100  else
101  sipType = sipType_QgsLineSymbolLayer;
102  break;
103 
105  if ( sipCpp->layerType() == "SimpleFill" )
106  sipType = sipType_QgsSimpleFillSymbolLayer;
107  else if ( sipCpp->layerType() == "LinePatternFill" )
108  sipType = sipType_QgsLinePatternFillSymbolLayer;
109  else if ( sipCpp->layerType() == "PointPatternFill" )
110  sipType = sipType_QgsPointPatternFillSymbolLayer;
111  else if ( sipCpp->layerType() == "SVGFill" )
112  sipType = sipType_QgsSVGFillSymbolLayer;
113  else if ( sipCpp->layerType() == "RasterFill" )
114  sipType = sipType_QgsRasterFillSymbolLayer;
115  else if ( sipCpp->layerType() == "CentroidFill" )
116  sipType = sipType_QgsCentroidFillSymbolLayer;
117  else if ( sipCpp->layerType() == "GradientFill" )
118  sipType = sipType_QgsGradientFillSymbolLayer;
119  else if ( sipCpp->layerType() == "ShapeburstFill" )
120  sipType = sipType_QgsShapeburstFillSymbolLayer;
121  else if ( sipCpp->layerType() == "RandomMarkerFill" )
122  sipType = sipType_QgsRandomMarkerFillSymbolLayer;
123  else
124  sipType = sipType_QgsFillSymbolLayer;
125  break;
126 
128  sipType = sipType_QgsGeometryGeneratorSymbolLayer;
129  break;
130  }
131  SIP_END
132 #endif
133  public:
134 
139  enum Property
140  {
141  PropertySize = 0,
211  };
212 
217  static const QgsPropertiesDefinition &propertyDefinitions();
218 
219  virtual ~QgsSymbolLayer();
220 
222  QgsSymbolLayer( const QgsSymbolLayer &other ) = delete;
223 
225  QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;
226 
232  virtual Qgis::SymbolLayerFlags flags() const;
233 
239  bool enabled() const { return mEnabled; }
240 
248  void setEnabled( bool enabled ) { mEnabled = enabled; }
249 
253  virtual QColor color() const { return mColor; }
254 
258  virtual void setColor( const QColor &color ) { mColor = color; }
259 
264  virtual void setStrokeColor( const QColor &color ) { Q_UNUSED( color ) }
265 
270  virtual QColor strokeColor() const { return QColor(); }
271 
276  virtual void setFillColor( const QColor &color ) { Q_UNUSED( color ) }
277 
282  virtual QColor fillColor() const { return QColor(); }
283 
288  virtual QString layerType() const = 0;
289 
302  virtual void startRender( QgsSymbolRenderContext &context ) = 0;
303 
315  virtual void stopRender( QgsSymbolRenderContext &context ) = 0;
316 
335  virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
336 
355  virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
356 
360  virtual QgsSymbolLayer *clone() const = 0 SIP_FACTORY;
361 
363  virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
364  { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
365 
366  virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor ); return QString(); }
367 
373  virtual QVariantMap properties() const = 0;
374 
375  virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) = 0;
376 
380  virtual QgsSymbol *subSymbol();
381 
383  virtual bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER );
384 
385  Qgis::SymbolType type() const { return mType; }
386 
388  virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
389 
398  virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
399 
407  void setLocked( bool locked ) { mLocked = locked; }
408 
414  bool isLocked() const { return mLocked; }
415 
423  virtual double estimateMaxBleed( const QgsRenderContext &context ) const { Q_UNUSED( context ) return 0; }
424 
433  virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit ) { Q_UNUSED( unit ) }
434 
444 
450  virtual bool usesMapUnits() const;
451 
452  virtual void setMapUnitScale( const QgsMapUnitScale &scale ) { Q_UNUSED( scale ) }
453  virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); }
454 
461  void setRenderingPass( int renderingPass );
462 
469  int renderingPass() const;
470 
475  virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
476 
484  virtual void setDataDefinedProperty( Property key, const QgsProperty &property );
485 
487  virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
488 
490  virtual double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
491 
493  virtual double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
494 
496  virtual QColor dxfColor( QgsSymbolRenderContext &context ) const;
497 
499  virtual double dxfAngle( QgsSymbolRenderContext &context ) const;
500 
502  virtual QVector<qreal> dxfCustomDashPattern( QgsUnitTypes::RenderUnit &unit ) const;
503 
505  virtual Qt::PenStyle dxfPenStyle() const;
506 
508  virtual QColor dxfBrushColor( QgsSymbolRenderContext &context ) const;
509 
511  virtual Qt::BrushStyle dxfBrushStyle() const;
512 
519  QgsPaintEffect *paintEffect() const;
520 
527  void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
528 
535  virtual void prepareExpressions( const QgsSymbolRenderContext &context );
536 
543  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
544 
550  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
551 
558  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
559 
565  virtual bool hasDataDefinedProperties() const;
566 
572  virtual QList<QgsSymbolLayerReference> masks() const;
573 
574  protected:
575 
581  QgsSymbolLayer( Qgis::SymbolType type, bool locked = false );
582 
584 
586  bool mEnabled = true;
587 
588  bool mLocked = false;
589  QColor mColor;
590  int mRenderingPass = 0;
591 
593 
594  std::unique_ptr< QgsPaintEffect > mPaintEffect;
596 
597  // Configuration of selected symbology implementation
599  static const bool SELECTION_IS_OPAQUE = true;
601  static const bool SELECT_FILL_BORDER = false;
603  static const bool SELECT_FILL_STYLE = false;
604 
609  void restoreOldDataDefinedProperties( const QVariantMap &stringMap );
610 
615  void copyDataDefinedProperties( QgsSymbolLayer *destLayer ) const;
616 
622  void copyPaintEffect( QgsSymbolLayer *destLayer ) const;
623 
624  private:
625  static void initPropertyDefinitions();
626 
628  static QgsPropertiesDefinition sPropertyDefinitions;
629 
630 #ifdef SIP_RUN
631  QgsSymbolLayer( const QgsSymbolLayer &other );
632 #endif
633 
634 };
635 
637 
643 class CORE_EXPORT QgsMarkerSymbolLayer : public QgsSymbolLayer
644 {
645  public:
646 
649  {
653  };
654 
657  {
658  Top,
661  };
662 
664  QgsMarkerSymbolLayer( const QgsMarkerSymbolLayer &other ) = delete;
665 
668 
669  void startRender( QgsSymbolRenderContext &context ) override;
670 
671  void stopRender( QgsSymbolRenderContext &context ) override;
672 
679  virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
680 
681  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
682 
689  void setAngle( double angle ) { mAngle = angle; }
690 
695  double angle() const { return mAngle; }
696 
706  void setLineAngle( double lineAngle ) { mLineAngle = lineAngle; }
707 
715  virtual void setSize( double size ) { mSize = size; }
716 
723  double size() const { return mSize; }
724 
732  void setSizeUnit( QgsUnitTypes::RenderUnit unit ) { mSizeUnit = unit; }
733 
740  QgsUnitTypes::RenderUnit sizeUnit() const { return mSizeUnit; }
741 
749  void setSizeMapUnitScale( const QgsMapUnitScale &scale ) { mSizeMapUnitScale = scale; }
750 
757  const QgsMapUnitScale &sizeMapUnitScale() const { return mSizeMapUnitScale; }
758 
764  void setScaleMethod( Qgis::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
765 
770  Qgis::ScaleMethod scaleMethod() const { return mScaleMethod; }
771 
780  void setOffset( QPointF offset ) { mOffset = offset; }
781 
789  QPointF offset() const { return mOffset; }
790 
798  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
799 
806  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
807 
815  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
816 
823  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
824 
832  void setHorizontalAnchorPoint( HorizontalAnchorPoint h ) { mHorizontalAnchorPoint = h; }
833 
840  HorizontalAnchorPoint horizontalAnchorPoint() const { return mHorizontalAnchorPoint; }
841 
849  void setVerticalAnchorPoint( VerticalAnchorPoint v ) { mVerticalAnchorPoint = v; }
850 
857  VerticalAnchorPoint verticalAnchorPoint() const { return mVerticalAnchorPoint; }
858 
859  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
860 
867  virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
868  { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "QgsMarkerSymbolLayer %1 not implemented yet" ).arg( layerType() ) ) ); }
869 
870  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
871  QgsUnitTypes::RenderUnit outputUnit() const override;
872  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
873  QgsMapUnitScale mapUnitScale() const override;
874 
881  virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) = 0;
882 
883  protected:
884 
889  QgsMarkerSymbolLayer( bool locked = false );
890 
898  void markerOffset( QgsSymbolRenderContext &context, double &offsetX, double &offsetY ) const;
899 
910  void markerOffset( QgsSymbolRenderContext &context, double width, double height, double &offsetX, double &offsetY ) const SIP_PYNAME( markerOffsetWithWidthAndHeight );
911 
913  void markerOffset( QgsSymbolRenderContext &context, double width, double height,
915  double &offsetX, double &offsetY,
916  const QgsMapUnitScale &widthMapUnitScale, const QgsMapUnitScale &heightMapUnitScale ) const SIP_PYNAME( markerOffset2 );
917 
924  static QPointF _rotatedOffset( QPointF offset, double angle );
925 
927  double mAngle = 0;
929  double mLineAngle = 0;
931  double mSize = 2.0;
937  QPointF mOffset;
945  HorizontalAnchorPoint mHorizontalAnchorPoint = HCenter;
947  VerticalAnchorPoint mVerticalAnchorPoint = VCenter;
948 
949  private:
950  static QgsMarkerSymbolLayer::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString &str );
951  static QgsMarkerSymbolLayer::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString &str );
952 
953 #ifdef SIP_RUN
955 #endif
956 };
957 
962 class CORE_EXPORT QgsLineSymbolLayer : public QgsSymbolLayer
963 {
964  public:
965 
968  {
972  };
973 
975  QgsLineSymbolLayer( const QgsLineSymbolLayer &other ) = delete;
976 
979 
980  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
981  QgsUnitTypes::RenderUnit outputUnit() const override;
982  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
983  QgsMapUnitScale mapUnitScale() const override;
984  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
985  double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
986 
991  virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) = 0;
992 
1001  virtual void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1002 
1016  virtual void setWidth( double width ) { mWidth = width; }
1017 
1027  virtual double width() const { return mWidth; }
1028 
1039  virtual double width( const QgsRenderContext &context ) const;
1040 
1050  double offset() const { return mOffset; }
1051 
1061  void setOffset( double offset ) { mOffset = offset; }
1062 
1069  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
1070 
1077  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
1078 
1085  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
1086 
1093  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
1094 
1095  // TODO QGIS 4.0 - setWidthUnit(), widthUnit(), setWidthUnitScale(), widthUnitScale()
1096  // only apply to simple line symbol layers and do not belong here.
1097 
1103  void setWidthUnit( QgsUnitTypes::RenderUnit unit ) { mWidthUnit = unit; }
1104 
1109  QgsUnitTypes::RenderUnit widthUnit() const { return mWidthUnit; }
1110 
1111  void setWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWidthMapUnitScale = scale; }
1112  const QgsMapUnitScale &widthMapUnitScale() const { return mWidthMapUnitScale; }
1113 
1124  RenderRingFilter ringFilter() const;
1125 
1136  void setRingFilter( QgsLineSymbolLayer::RenderRingFilter filter );
1137 
1138  protected:
1139  QgsLineSymbolLayer( bool locked = false );
1140 
1141  double mWidth = 0;
1144  double mOffset = 0;
1147 
1148  RenderRingFilter mRingFilter = AllRings;
1149 
1150  private:
1151 #ifdef SIP_RUN
1152  QgsLineSymbolLayer( const QgsLineSymbolLayer &other );
1153 #endif
1154 };
1155 
1160 class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
1161 {
1162  public:
1163 
1165  QgsFillSymbolLayer( const QgsFillSymbolLayer &other ) = delete;
1166 
1169 
1175  virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) = 0;
1176 
1177  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1178 
1179  void setAngle( double angle ) { mAngle = angle; }
1180  double angle() const { return mAngle; }
1181 
1182  protected:
1183  QgsFillSymbolLayer( bool locked = false );
1185  void _renderPolygon( QPainter *p, const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1186 
1187  double mAngle = 0.0;
1188 
1189  private:
1190 #ifdef SIP_RUN
1191  QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
1192 #endif
1193 };
1194 
1195 class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
1196 
1197 #endif
1198 
1199 
ScaleMethod
Scale methods.
Definition: qgis.h:197
@ ScaleDiameter
Calculate scale by the diameter.
SymbolType
Symbol types.
Definition: qgis.h:183
@ Marker
Marker symbol.
@ Line
Line symbol.
@ Fill
Fill symbol.
@ Hybrid
Hybrid symbol.
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:65
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Container of fields for a vector layer.
Definition: qgsfields.h:45
virtual void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context)=0
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
double angle() const
QgsFillSymbolLayer & operator=(const QgsFillSymbolLayer &other)=delete
QgsFillSymbolLayer cannot be copied.
void setAngle(double angle)
QgsFillSymbolLayer(const QgsFillSymbolLayer &other)=delete
QgsFillSymbolLayer cannot be copied.
RenderRingFilter
Options for filtering rings when the line symbol layer is being used to render a polygon's rings.
@ ExteriorRingOnly
Render the exterior ring only.
@ InteriorRingsOnly
Render the interior rings only.
@ AllRings
Render both exterior and interior rings.
QgsMapUnitScale mWidthMapUnitScale
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line's offset.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the line's offset.
QgsLineSymbolLayer(const QgsLineSymbolLayer &other)=delete
QgsLineSymbolLayer cannot be copied.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
void setWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line's width.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's offset.
void setOffset(double offset)
Sets the line's offset.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Renders the line symbol layer along the line joining points, using the given render context.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line's width.
virtual double width() const
Returns the estimated width for the line symbol layer.
QgsMapUnitScale mOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the line's offset.
double offset() const
Returns the line's offset.
const QgsMapUnitScale & widthMapUnitScale() const
QgsLineSymbolLayer & operator=(const QgsLineSymbolLayer &other)=delete
QgsLineSymbolLayer cannot be copied.
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.
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
HorizontalAnchorPoint
Symbol horizontal anchor points.
@ Right
Align to right side of symbol.
@ HCenter
Align to horizontal center of symbol.
@ Left
Align to left side of symbol.
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.
QgsMarkerSymbolLayer & operator=(const QgsMarkerSymbolLayer &other)=delete
QgsMarkerSymbolLayer cannot be copied.
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 setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QPointF mOffset
Marker offset.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
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.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
double size() const
Returns the symbol size.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
QgsMarkerSymbolLayer(const QgsMarkerSymbolLayer &other)=delete
QgsMarkerSymbolLayer cannot be copied.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
VerticalAnchorPoint
Symbol vertical anchor points.
@ VCenter
Align to vertical center of symbol.
@ Bottom
Align to bottom of symbol.
@ Top
Align to top of symbol.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Writes the symbol layer definition as a SLD XML element.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
Base class for visual effects which can be applied to QPicture drawings.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
A store for object properties.
Definition: qgsproperty.h:231
Contains information about the context of a rendering operation.
Type used to refer to a specific symbol layer in a symbol of a layer.
Property
Data definable properties.
@ PropertyGradientReference1X
Gradient reference point 1 x.
@ PropertyShapeburstIgnoreRings
Shapeburst ignore rings.
@ PropertyGradientReference2X
Gradient reference point 2 x.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
@ PropertyPlacement
Line marker placement.
@ PropertyHorizontalAnchor
Horizontal anchor point.
@ PropertyPreserveAspectRatio
Preserve aspect ratio between width and height.
@ PropertyDistanceX
Horizontal distance between points.
@ PropertyFile
Filename, eg for svg files.
@ PropertyGradientType
Gradient fill type.
@ PropertyCapStyle
Line cap style.
@ PropertyLineEndWidthValue
End line width for interpolated line renderer (since QGIS 3.22)
@ PropertyLineEndColorValue
End line color for interpolated line renderer (since QGIS 3.22)
@ PropertyAngle
Symbol angle.
@ PropertyLineClipping
Line clipping mode (since QGIS 3.24)
@ PropertyDistanceY
Vertical distance between points.
@ PropertyDisplacementX
Horizontal displacement.
@ PropertyVerticalAnchor
Vertical anchor point.
@ PropertyGradientSpread
Gradient spread mode.
@ PropertyOffsetY
Vertical offset.
@ PropertyGradientReference1Y
Gradient reference point 1 y.
@ PropertyLineDistance
Distance between lines, or length of lines for hash line symbols.
@ PropertyOffsetAlongLine
Offset along line.
@ PropertyLineStartColorValue
Start line color for interpolated line renderer (since QGIS 3.22)
@ PropertyArrowStartWidth
Arrow tail start width.
@ PropertyBlurRadius
Shapeburst blur radius.
@ PropertyGradientReference2Y
Gradient reference point 2 y.
@ PropertyMarkerClipping
Marker clipping mode (since QGIS 3.24)
@ PropertyDensityArea
Density area.
@ PropertyArrowHeadLength
Arrow head length.
@ PropertyGradientReference1IsCentroid
Gradient reference point 1 is centroid.
@ PropertyCustomDash
Custom dash pattern.
@ PropertyShapeburstUseWholeShape
Shapeburst use whole shape.
@ PropertyArrowHeadThickness
Arrow head thickness.
@ PropertyOffsetX
Horizontal offset.
@ PropertyJoinStyle
Line join style.
@ PropertyLineStartWidthValue
Start line width for interpolated line renderer (since QGIS 3.22)
@ PropertyTrimEnd
Trim distance from end of line (since QGIS 3.20)
@ PropertyOpacity
Opacity.
@ PropertySecondaryColor
Secondary color (eg for gradient fills)
@ PropertyCharacter
Character, eg for font marker symbol layers.
@ PropertyCoordinateMode
Gradient coordinate mode.
@ PropertyRandomOffsetY
Random offset Y (since QGIS 3.24)
@ PropertyLineAngle
Line angle, or angle of hash lines for hash line symbols.
@ PropertyShapeburstMaxDistance
Shapeburst fill from edge distance.
@ PropertyTrimStart
Trim distance from start of line (since QGIS 3.20)
@ PropertyOffset
Symbol offset.
@ PropertyStrokeWidth
Stroke width.
@ PropertyDashPatternOffset
Dash pattern offset,.
@ PropertyFillColor
Fill color.
@ PropertyArrowHeadType
Arrow head type.
@ PropertyFontStyle
Font style.
@ PropertyHeight
Symbol height.
@ PropertyClipPoints
Whether markers should be clipped to polygon boundaries.
@ PropertyFontFamily
Font family.
@ PropertyPointCount
Point count.
@ PropertyRandomSeed
Random number seed.
@ PropertyLayerEnabled
Whether symbol layer is enabled.
@ PropertyName
Name, eg shape name for simple markers.
@ PropertyAverageAngleLength
Length to average symbol angles over.
@ PropertyInterval
Line marker interval.
@ PropertyRandomOffsetX
Random offset X (since QGIS 3.24)
@ PropertyFillStyle
Fill style (eg solid, dots)
@ PropertyArrowType
Arrow type.
@ PropertyDisplacementY
Vertical displacement.
@ PropertyStrokeColor
Stroke color.
@ PropertyGradientReference2IsCentroid
Gradient reference point 2 is centroid.
@ PropertyArrowWidth
Arrow tail width.
@ PropertyWidth
Symbol width.
virtual void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
QgsFields mFields
virtual void setFillColor(const QColor &color)
Set fill color.
Qgis::SymbolType type() const
QgsSymbolLayer & operator=(const QgsSymbolLayer &other)=delete
QgsSymbolLayer cannot be copied.
bool isLocked() const
Returns true if the symbol layer colors are locked and the layer will ignore any symbol-level color c...
virtual QgsMapUnitScale mapUnitScale() const
virtual QColor color() const
The fill color.
Qgis::SymbolType mType
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Saves the symbol layer as SLD.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
QgsSymbolLayer(const QgsSymbolLayer &other)=delete
QgsSymbolLayer cannot be copied.
void setEnabled(bool enabled)
Sets whether symbol layer is enabled and should be drawn.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QColor fillColor() const
Gets fill color.
std::unique_ptr< QgsPaintEffect > mPaintEffect
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
virtual QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
virtual void setStrokeColor(const QColor &color)
Set stroke color.
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
void setLocked(bool locked)
Sets whether the layer's colors are locked.
virtual QColor strokeColor() const
Gets stroke color.
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
virtual ~QgsSymbolLayer()
virtual void setColor(const QColor &color)
The fill color.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the symbol layer's property collection, used for data defined overrides.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
virtual void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size)=0
QgsPropertyCollection mDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:175
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
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
#define str(x)
Definition: qgis.cpp:37
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:194
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
QMap< QString, QString > QgsStringMap