QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 QgsSymbol::ScaleDiameter
20 
21 #include "qgis_core.h"
22 // #include "qgis.h"
23 #include <QColor>
24 #include <QMap>
25 #include <QPointF>
26 #include <QSet>
27 #include <QDomDocument>
28 #include <QDomElement>
29 #include <QPainterPath>
30 
31 #include "qgssymbol.h"
32 #include "qgsfields.h"
33 #include "qgspropertycollection.h"
34 #include "qgspainteffect.h"
35 
36 class QPainter;
37 class QSize;
38 class QPolygonF;
39 
40 class QgsDxfExport;
41 class QgsExpression;
42 class QgsRenderContext;
43 
44 #ifndef SIP_RUN
45 typedef QMap<QString, QString> QgsStringMap;
46 #endif
47 
52 class CORE_EXPORT QgsSymbolLayer
53 {
54 #ifdef SIP_RUN
55 #include <qgslinesymbollayer.h>
56 #endif
57 
58 
59 #ifdef SIP_RUN
61  switch ( sipCpp->type() )
62  {
63  case QgsSymbol::Marker:
64  if ( sipCpp->layerType() == "EllipseMarker" )
65  sipType = sipType_QgsEllipseSymbolLayer;
66  else if ( sipCpp->layerType() == "FontMarker" )
67  sipType = sipType_QgsFontMarkerSymbolLayer;
68  else if ( sipCpp->layerType() == "SimpleMarker" )
69  sipType = sipType_QgsSimpleMarkerSymbolLayer;
70  else if ( sipCpp->layerType() == "FilledMarker" )
71  sipType = sipType_QgsFilledMarkerSymbolLayer;
72  else if ( sipCpp->layerType() == "SvgMarker" )
73  sipType = sipType_QgsSvgMarkerSymbolLayer;
74  else if ( sipCpp->layerType() == "RasterMarker" )
75  sipType = sipType_QgsRasterMarkerSymbolLayer;
76  else if ( sipCpp->layerType() == "VectorField" )
77  sipType = sipType_QgsVectorFieldSymbolLayer;
78  else if ( sipCpp->layerType() == "MaskMarker" )
79  sipType = sipType_QgsMaskMarkerSymbolLayer;
80  else
81  sipType = sipType_QgsMarkerSymbolLayer;
82  break;
83 
84  case QgsSymbol::Line:
85  if ( sipCpp->layerType() == "MarkerLine" )
86  sipType = sipType_QgsMarkerLineSymbolLayer;
87  else if ( sipCpp->layerType() == "SimpleLine" )
88  sipType = sipType_QgsSimpleLineSymbolLayer;
89  else if ( sipCpp->layerType() == "ArrowLine" )
90  sipType = sipType_QgsArrowSymbolLayer;
91  else
92  sipType = sipType_QgsLineSymbolLayer;
93  break;
94 
95  case QgsSymbol::Fill:
96  if ( sipCpp->layerType() == "SimpleFill" )
97  sipType = sipType_QgsSimpleFillSymbolLayer;
98  else if ( sipCpp->layerType() == "LinePatternFill" )
99  sipType = sipType_QgsLinePatternFillSymbolLayer;
100  else if ( sipCpp->layerType() == "PointPatternFill" )
101  sipType = sipType_QgsPointPatternFillSymbolLayer;
102  else if ( sipCpp->layerType() == "SVGFill" )
103  sipType = sipType_QgsSVGFillSymbolLayer;
104  else if ( sipCpp->layerType() == "RasterFill" )
105  sipType = sipType_QgsRasterFillSymbolLayer;
106  else if ( sipCpp->layerType() == "CentroidFill" )
107  sipType = sipType_QgsCentroidFillSymbolLayer;
108  else if ( sipCpp->layerType() == "GradientFill" )
109  sipType = sipType_QgsGradientFillSymbolLayer;
110  else if ( sipCpp->layerType() == "ShapeburstFill" )
111  sipType = sipType_QgsShapeburstFillSymbolLayer;
112  else if ( sipCpp->layerType() == "RandomMarkerFill" )
113  sipType = sipType_QgsRandomMarkerFillSymbolLayer;
114  else
115  sipType = sipType_QgsFillSymbolLayer;
116  break;
117 
118  case QgsSymbol::Hybrid:
119  sipType = sipType_QgsGeometryGeneratorSymbolLayer;
120  break;
121  }
122  SIP_END
123 #endif
124  public:
125 
130  enum Property
131  {
132  PropertySize = 0,
192  };
193 
198  static const QgsPropertiesDefinition &propertyDefinitions();
199 
200  virtual ~QgsSymbolLayer();
201 
203  QgsSymbolLayer( const QgsSymbolLayer &other ) = delete;
204 
206  QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;
207 
213  bool enabled() const { return mEnabled; }
214 
222  void setEnabled( bool enabled ) { mEnabled = enabled; }
223 
227  virtual QColor color() const { return mColor; }
228 
232  virtual void setColor( const QColor &color ) { mColor = color; }
233 
238  virtual void setStrokeColor( const QColor &color ) { Q_UNUSED( color ) }
239 
244  virtual QColor strokeColor() const { return QColor(); }
245 
250  virtual void setFillColor( const QColor &color ) { Q_UNUSED( color ) }
251 
256  virtual QColor fillColor() const { return QColor(); }
257 
262  virtual QString layerType() const = 0;
263 
276  virtual void startRender( QgsSymbolRenderContext &context ) = 0;
277 
289  virtual void stopRender( QgsSymbolRenderContext &context ) = 0;
290 
309  virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
310 
329  virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
330 
334  virtual QgsSymbolLayer *clone() const = 0 SIP_FACTORY;
335 
337  virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
338  { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
339 
340  virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor ); return QString(); }
341 
347  virtual QVariantMap properties() const = 0;
348 
349  virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) = 0;
350 
354  virtual QgsSymbol *subSymbol() { return nullptr; }
355 
357  virtual bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) { delete symbol; return false; }
358 
359  QgsSymbol::SymbolType type() const { return mType; }
360 
362  virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
363 
372  virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
373 
374  void setLocked( bool locked ) { mLocked = locked; }
375  bool isLocked() const { return mLocked; }
376 
384  virtual double estimateMaxBleed( const QgsRenderContext &context ) const { Q_UNUSED( context ) return 0; }
385 
394  virtual void setOutputUnit( QgsUnitTypes::RenderUnit unit ) { Q_UNUSED( unit ) }
395 
405 
411  virtual bool usesMapUnits() const;
412 
413  virtual void setMapUnitScale( const QgsMapUnitScale &scale ) { Q_UNUSED( scale ) }
414  virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); }
415 
422  void setRenderingPass( int renderingPass );
423 
430  int renderingPass() const;
431 
436  virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
437 
445  virtual void setDataDefinedProperty( Property key, const QgsProperty &property );
446 
448  virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
449 
451  virtual double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
452 
454  virtual double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
455 
457  virtual QColor dxfColor( QgsSymbolRenderContext &context ) const;
458 
460  virtual double dxfAngle( QgsSymbolRenderContext &context ) const;
461 
463  virtual QVector<qreal> dxfCustomDashPattern( QgsUnitTypes::RenderUnit &unit ) const;
464 
466  virtual Qt::PenStyle dxfPenStyle() const;
467 
469  virtual QColor dxfBrushColor( QgsSymbolRenderContext &context ) const;
470 
472  virtual Qt::BrushStyle dxfBrushStyle() const;
473 
480  QgsPaintEffect *paintEffect() const;
481 
488  void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
489 
496  virtual void prepareExpressions( const QgsSymbolRenderContext &context );
497 
504  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
505 
511  const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
512 
519  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
520 
526  virtual bool hasDataDefinedProperties() const;
527 
533  virtual QgsSymbolLayerReferenceList masks() const;
534 
535  protected:
536 
537  QgsSymbolLayer( QgsSymbol::SymbolType type, bool locked = false );
538 
540 
542  bool mEnabled = true;
543 
544  bool mLocked = false;
545  QColor mColor;
546  int mRenderingPass = 0;
547 
549 
550  std::unique_ptr< QgsPaintEffect > mPaintEffect;
552 
553  // Configuration of selected symbology implementation
555  static const bool SELECTION_IS_OPAQUE = true;
557  static const bool SELECT_FILL_BORDER = false;
559  static const bool SELECT_FILL_STYLE = false;
560 
565  void restoreOldDataDefinedProperties( const QVariantMap &stringMap );
566 
571  void copyDataDefinedProperties( QgsSymbolLayer *destLayer ) const;
572 
578  void copyPaintEffect( QgsSymbolLayer *destLayer ) const;
579 
580  private:
581  static void initPropertyDefinitions();
582 
584  static QgsPropertiesDefinition sPropertyDefinitions;
585 
586 #ifdef SIP_RUN
587  QgsSymbolLayer( const QgsSymbolLayer &other );
588 #endif
589 
590 };
591 
593 
599 class CORE_EXPORT QgsMarkerSymbolLayer : public QgsSymbolLayer
600 {
601  public:
602 
605  {
609  };
610 
613  {
614  Top,
617  };
618 
620  QgsMarkerSymbolLayer( const QgsMarkerSymbolLayer &other ) = delete;
621 
624 
625  void startRender( QgsSymbolRenderContext &context ) override;
626 
627  void stopRender( QgsSymbolRenderContext &context ) override;
628 
635  virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
636 
637  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
638 
645  void setAngle( double angle ) { mAngle = angle; }
646 
651  double angle() const { return mAngle; }
652 
662  void setLineAngle( double lineAngle ) { mLineAngle = lineAngle; }
663 
671  virtual void setSize( double size ) { mSize = size; }
672 
679  double size() const { return mSize; }
680 
688  void setSizeUnit( QgsUnitTypes::RenderUnit unit ) { mSizeUnit = unit; }
689 
696  QgsUnitTypes::RenderUnit sizeUnit() const { return mSizeUnit; }
697 
705  void setSizeMapUnitScale( const QgsMapUnitScale &scale ) { mSizeMapUnitScale = scale; }
706 
713  const QgsMapUnitScale &sizeMapUnitScale() const { return mSizeMapUnitScale; }
714 
720  void setScaleMethod( QgsSymbol::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
721 
726  QgsSymbol::ScaleMethod scaleMethod() const { return mScaleMethod; }
727 
736  void setOffset( QPointF offset ) { mOffset = offset; }
737 
745  QPointF offset() const { return mOffset; }
746 
754  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
755 
762  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
763 
771  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
772 
779  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
780 
788  void setHorizontalAnchorPoint( HorizontalAnchorPoint h ) { mHorizontalAnchorPoint = h; }
789 
796  HorizontalAnchorPoint horizontalAnchorPoint() const { return mHorizontalAnchorPoint; }
797 
805  void setVerticalAnchorPoint( VerticalAnchorPoint v ) { mVerticalAnchorPoint = v; }
806 
813  VerticalAnchorPoint verticalAnchorPoint() const { return mVerticalAnchorPoint; }
814 
815  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
816 
823  virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
824  { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "QgsMarkerSymbolLayer %1 not implemented yet" ).arg( layerType() ) ) ); }
825 
826  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
827  QgsUnitTypes::RenderUnit outputUnit() const override;
828  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
829  QgsMapUnitScale mapUnitScale() const override;
830 
837  virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) = 0;
838 
839  protected:
840 
845  QgsMarkerSymbolLayer( bool locked = false );
846 
854  void markerOffset( QgsSymbolRenderContext &context, double &offsetX, double &offsetY ) const;
855 
866  void markerOffset( QgsSymbolRenderContext &context, double width, double height, double &offsetX, double &offsetY ) const SIP_PYNAME( markerOffsetWithWidthAndHeight );
867 
869  void markerOffset( QgsSymbolRenderContext &context, double width, double height,
871  double &offsetX, double &offsetY,
872  const QgsMapUnitScale &widthMapUnitScale, const QgsMapUnitScale &heightMapUnitScale ) const SIP_PYNAME( markerOffset2 );
873 
880  static QPointF _rotatedOffset( QPointF offset, double angle );
881 
883  double mAngle = 0;
885  double mLineAngle = 0;
887  double mSize = 2.0;
893  QPointF mOffset;
901  HorizontalAnchorPoint mHorizontalAnchorPoint = HCenter;
903  VerticalAnchorPoint mVerticalAnchorPoint = VCenter;
904 
905  private:
906  static QgsMarkerSymbolLayer::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString &str );
907  static QgsMarkerSymbolLayer::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString &str );
908 
909 #ifdef SIP_RUN
911 #endif
912 };
913 
918 class CORE_EXPORT QgsLineSymbolLayer : public QgsSymbolLayer
919 {
920  public:
921 
924  {
928  };
929 
931  QgsLineSymbolLayer( const QgsLineSymbolLayer &other ) = delete;
932 
935 
936  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
937  QgsUnitTypes::RenderUnit outputUnit() const override;
938  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
939  QgsMapUnitScale mapUnitScale() const override;
940  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
941  double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
942 
947  virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) = 0;
948 
957  virtual void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
958 
972  virtual void setWidth( double width ) { mWidth = width; }
973 
983  virtual double width() const { return mWidth; }
984 
995  virtual double width( const QgsRenderContext &context ) const;
996 
1006  double offset() const { return mOffset; }
1007 
1017  void setOffset( double offset ) { mOffset = offset; }
1018 
1025  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
1026 
1033  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
1034 
1041  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
1042 
1049  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
1050 
1051  // TODO QGIS 4.0 - setWidthUnit(), widthUnit(), setWidthUnitScale(), widthUnitScale()
1052  // only apply to simple line symbol layers and do not belong here.
1053 
1059  void setWidthUnit( QgsUnitTypes::RenderUnit unit ) { mWidthUnit = unit; }
1060 
1065  QgsUnitTypes::RenderUnit widthUnit() const { return mWidthUnit; }
1066 
1067  void setWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWidthMapUnitScale = scale; }
1068  const QgsMapUnitScale &widthMapUnitScale() const { return mWidthMapUnitScale; }
1069 
1080  RenderRingFilter ringFilter() const;
1081 
1092  void setRingFilter( QgsLineSymbolLayer::RenderRingFilter filter );
1093 
1094  protected:
1095  QgsLineSymbolLayer( bool locked = false );
1096 
1097  double mWidth = 0;
1100  double mOffset = 0;
1103 
1104  RenderRingFilter mRingFilter = AllRings;
1105 
1106  private:
1107 #ifdef SIP_RUN
1108  QgsLineSymbolLayer( const QgsLineSymbolLayer &other );
1109 #endif
1110 };
1111 
1116 class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
1117 {
1118  public:
1119 
1121  QgsFillSymbolLayer( const QgsFillSymbolLayer &other ) = delete;
1122 
1125 
1131  virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) = 0;
1132 
1133  void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1134 
1135  void setAngle( double angle ) { mAngle = angle; }
1136  double angle() const { return mAngle; }
1137 
1138  protected:
1139  QgsFillSymbolLayer( bool locked = false );
1141  void _renderPolygon( QPainter *p, const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1142 
1143  double mAngle = 0.0;
1144 
1145  private:
1146 #ifdef SIP_RUN
1147  QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
1148 #endif
1149 };
1150 
1151 class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
1152 
1153 #endif
1154 
1155 
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:64
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
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.
QgsSymbol::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's 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.
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.
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.
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
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:232
Contains information about the context of a rendering operation.
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.
@ PropertyAngle
Symbol angle.
@ 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.
@ PropertyArrowStartWidth
Arrow tail start width.
@ PropertyBlurRadius
Shapeburst blur radius.
@ PropertyGradientReference2Y
Gradient reference point 2 y.
@ 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.
@ PropertyOpacity
Opacity.
@ PropertySecondaryColor
Secondary color (eg for gradient fills)
@ PropertyCharacter
Character, eg for font marker symbol layers.
@ PropertyCoordinateMode
Gradient coordinate mode.
@ PropertyLineAngle
Line angle, or angle of hash lines for hash line symbols.
@ PropertyShapeburstMaxDistance
Shapeburst fill from edge distance.
@ 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.
@ 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.
QgsSymbolLayer & operator=(const QgsSymbolLayer &other)=delete
QgsSymbolLayer cannot be copied.
bool isLocked() const
virtual QgsMapUnitScale mapUnitScale() const
virtual QColor color() const
The fill color.
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
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
QgsSymbol::SymbolType type() const
void setLocked(bool 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
QgsSymbol::SymbolType mType
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:65
ScaleMethod
Scale method.
Definition: qgssymbol.h:98
@ ScaleDiameter
Calculate scale by the diameter.
Definition: qgssymbol.h:100
SymbolType
Type of the symbol.
Definition: qgssymbol.h:87
@ Line
Line symbol.
Definition: qgssymbol.h:89
@ Hybrid
Hybrid symbol.
Definition: qgssymbol.h:91
@ Fill
Fill symbol.
Definition: qgssymbol.h:90
@ Marker
Marker symbol.
Definition: qgssymbol.h:88
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:174
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
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 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
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList