QGIS API Documentation  3.21.0-Master (af9a72eda6)
qgsfillsymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfillsymbollayer.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 
16 #ifndef QGSFILLSYMBOLLAYER_H
17 #define QGSFILLSYMBOLLAYER_H
18 
19 #include "qgis_core.h"
20 #include "qgis.h"
21 #include "qgssymbollayer.h"
22 
23 #define DEFAULT_SIMPLEFILL_COLOR QColor(0,0,255)
24 #define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern
25 #define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor( 35, 35, 35 )
26 #define DEFAULT_SIMPLEFILL_BORDERSTYLE Qt::SolidLine
27 #define DEFAULT_SIMPLEFILL_BORDERWIDTH DEFAULT_LINE_WIDTH
28 #define DEFAULT_SIMPLEFILL_JOINSTYLE Qt::BevelJoin
29 
30 #define INF 1E20
31 
32 #include <QPen>
33 #include <QBrush>
34 
35 class QgsMarkerSymbol;
36 class QgsLineSymbol;
37 class QgsPathResolver;
38 
43 class CORE_EXPORT QgsSimpleFillSymbolLayer : public QgsFillSymbolLayer
44 {
45  public:
47  Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
48  const QColor &strokeColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
49  Qt::PenStyle strokeStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
50  double strokeWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH,
51  Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEFILL_JOINSTYLE
52  );
53 
55 
56  // static stuff
57 
63  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
64  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
65 
66  // implemented from base classes
67 
68  QString layerType() const override;
69 
70  void startRender( QgsSymbolRenderContext &context ) override;
71 
72  void stopRender( QgsSymbolRenderContext &context ) override;
73 
74  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
75 
76  QVariantMap properties() const override;
77 
78  QgsSimpleFillSymbolLayer *clone() const override SIP_FACTORY;
79 
80  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
81 
82  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
83 
84  Qt::BrushStyle brushStyle() const { return mBrushStyle; }
85  void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; }
86 
87  QColor strokeColor() const override { return mStrokeColor; }
88  void setStrokeColor( const QColor &strokeColor ) override { mStrokeColor = strokeColor; }
89 
90  QColor fillColor() const override { return color(); }
91  void setFillColor( const QColor &color ) override { setColor( color ); }
92 
93  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
94  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
95 
96  double strokeWidth() const { return mStrokeWidth; }
97  void setStrokeWidth( double strokeWidth ) { mStrokeWidth = strokeWidth; }
98 
99  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
100  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
101 
110  void setOffset( QPointF offset ) { mOffset = offset; }
111 
120  QPointF offset() { return mOffset; }
121 
127  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
128 
133  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
134 
135  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
136  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
137 
143  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
144 
150  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
151 
157  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
158 
164  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
165 
166  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
167  QgsUnitTypes::RenderUnit outputUnit() const override;
168  bool usesMapUnits() const override;
169 
170  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
171  QgsMapUnitScale mapUnitScale() const override;
172 
173  double estimateMaxBleed( const QgsRenderContext &context ) const override;
174 
175  double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
176  QColor dxfColor( QgsSymbolRenderContext &context ) const override;
177  double dxfAngle( QgsSymbolRenderContext &context ) const override;
178 
179  Qt::PenStyle dxfPenStyle() const override;
180  QColor dxfBrushColor( QgsSymbolRenderContext &context ) const override;
181  Qt::BrushStyle dxfBrushStyle() const override;
182 
183  protected:
184  QBrush mBrush;
185  QBrush mSelBrush;
186  Qt::BrushStyle mBrushStyle;
187  QColor mStrokeColor;
188  Qt::PenStyle mStrokeStyle;
189  double mStrokeWidth;
192  Qt::PenJoinStyle mPenJoinStyle;
193  QPen mPen;
194  QPen mSelPen;
195 
196  QPointF mOffset;
199 
200  private:
201  //helper functions for data defined symbology
202  void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen );
203 };
204 
205 class QgsColorRamp;
206 
212 {
213  public:
214 
216  {
218  ColorRamp
219  };
220 
222  {
225  Conical
226  };
227 
229  {
231  Viewport
232  };
233 
235  {
238  Repeat
239  };
240 
242  const QColor &color2 = Qt::white,
243  GradientColorType gradientColorType = SimpleTwoColor,
244  GradientType gradientType = Linear,
245  GradientCoordinateMode coordinateMode = Feature,
246  GradientSpread gradientSpread = Pad
247  );
248 
249  ~QgsGradientFillSymbolLayer() override;
250 
251  // static stuff
252 
258  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
259 
260  // implemented from base classes
261 
262  QString layerType() const override;
263  void startRender( QgsSymbolRenderContext &context ) override;
264  void stopRender( QgsSymbolRenderContext &context ) override;
265  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
266  QVariantMap properties() const override;
267  QgsGradientFillSymbolLayer *clone() const override SIP_FACTORY;
268  double estimateMaxBleed( const QgsRenderContext &context ) const override;
269  bool canCauseArtifactsBetweenAdjacentTiles() const override;
270 
272  GradientType gradientType() const { return mGradientType; }
273  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
274 
276  GradientColorType gradientColorType() const { return mGradientColorType; }
277  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
278 
285  QgsColorRamp *colorRamp() { return mGradientRamp; }
286 
294  void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
295 
297  QColor color2() const { return mColor2; }
298  void setColor2( const QColor &color2 ) { mColor2 = color2; }
299 
301  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
302  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
303 
305  GradientSpread gradientSpread() const { return mGradientSpread; }
306  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
307 
309  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
310  QPointF referencePoint1() const { return mReferencePoint1; }
311 
313  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
314  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
315 
317  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
318  QPointF referencePoint2() const { return mReferencePoint2; }
319 
321  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
322  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
323 
332  void setOffset( QPointF offset ) { mOffset = offset; }
333 
342  QPointF offset() const { return mOffset; }
343 
349  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
350 
356  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
357 
363  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
364 
370  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
371 
372  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
373  QgsUnitTypes::RenderUnit outputUnit() const override;
374  bool usesMapUnits() const override;
375 
376  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
377  QgsMapUnitScale mapUnitScale() const override;
378 
379  protected:
380  QBrush mBrush;
381  QBrush mSelBrush;
382 
384  QColor mColor2;
385  QgsColorRamp *mGradientRamp = nullptr;
389 
391  bool mReferencePoint1IsCentroid = false;
393  bool mReferencePoint2IsCentroid = false;
394 
395  QPointF mOffset;
398 
399  private:
400 
401  //helper functions for data defined symbology
402  void applyDataDefinedSymbology( QgsSymbolRenderContext &context, const QPolygonF &points );
403 
405  void applyGradient( const QgsSymbolRenderContext &context, QBrush &brush, const QColor &color, const QColor &color2,
406  GradientColorType gradientColorType, QgsColorRamp *gradientRamp, GradientType gradientType,
407  GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
408  QPointF referencePoint1, QPointF referencePoint2, double angle );
409 
411  QPointF rotateReferencePoint( QPointF refPoint, double angle );
412 };
413 
419 {
420  public:
421 
423  {
425  ColorRamp
426  };
427 
428  QgsShapeburstFillSymbolLayer( const QColor &color = DEFAULT_SIMPLEFILL_COLOR, const QColor &color2 = Qt::white,
429  ShapeburstColorType colorType = SimpleTwoColor,
430  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
431 
433 
439 
445 
446  // static stuff
447 
453  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
454 
455  // implemented from base classes
456 
457  QString layerType() const override;
458  void startRender( QgsSymbolRenderContext &context ) override;
459  void stopRender( QgsSymbolRenderContext &context ) override;
460  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
461  QVariantMap properties() const override;
462  QgsShapeburstFillSymbolLayer *clone() const override SIP_FACTORY;
463  double estimateMaxBleed( const QgsRenderContext &context ) const override;
464  bool canCauseArtifactsBetweenAdjacentTiles() const override;
465 
472  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
473 
480  int blurRadius() const { return mBlurRadius; }
481 
490  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
491 
499  bool useWholeShape() const { return mUseWholeShape; }
500 
509  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
510 
519  double maxDistance() const { return mMaxDistance; }
520 
528  void setDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceUnit = unit; }
529 
537  QgsUnitTypes::RenderUnit distanceUnit() const { return mDistanceUnit; }
538 
539  void setDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceMapUnitScale = scale; }
540  const QgsMapUnitScale &distanceMapUnitScale() const { return mDistanceMapUnitScale; }
541 
552  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
553 
564  ShapeburstColorType colorType() const { return mColorType; }
565 
575  void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
576 
584  QgsColorRamp *colorRamp() { return mGradientRamp.get(); }
585 
593  void setColor2( const QColor &color2 ) { mColor2 = color2; }
594 
602  QColor color2() const { return mColor2; }
603 
611  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
612 
619  bool ignoreRings() const { return mIgnoreRings; }
620 
628  void setOffset( QPointF offset ) { mOffset = offset; }
629 
637  QPointF offset() const { return mOffset; }
638 
646  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
647 
655  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
656 
657  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
658  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
659 
660  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
661  QgsUnitTypes::RenderUnit outputUnit() const override;
662  bool usesMapUnits() const override;
663 
664  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
665  QgsMapUnitScale mapUnitScale() const override;
666 
667  private:
668  QBrush mBrush;
669  QBrush mSelBrush;
670 
671  int mBlurRadius = 0;
672 
673  bool mUseWholeShape = true;
674  double mMaxDistance = 5.0;
676  QgsMapUnitScale mDistanceMapUnitScale;
677 
678  ShapeburstColorType mColorType = SimpleTwoColor;
679  QColor mColor2;
680 
681  bool mIgnoreRings = false;
682 
683  QPointF mOffset;
685  QgsMapUnitScale mOffsetMapUnitScale;
686 
687  std::unique_ptr< QgsColorRamp > mGradientRamp;
688 
689  //helper functions for data defined symbology
690  void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QColor &color, QColor &color2, int &blurRadius, bool &useWholeShape,
691  double &maxDistance, bool &ignoreRings );
692 
693  /* distance transform of a 1d function using squared distance */
694  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
695  /* distance transform of 2d function using squared distance */
696  void distanceTransform2d( double *im, int width, int height, QgsRenderContext &context );
697  /* distance transform of a binary QImage */
698  double *distanceTransform( QImage *im, QgsRenderContext &context );
699 
700  /* fills a QImage with values from an array of doubles containing squared distance transform values */
701  void dtArrayToQImage( double *array, QImage *im, QgsColorRamp *ramp, QgsRenderContext &context, bool useWholeShape = true, int maxPixelDistance = 0 );
702 
703 #ifdef SIP_RUN
705 #endif
706 };
707 
713 {
714  public:
715 
718 
719  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
720 
721  QgsSymbol *subSymbol() override;
722  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
723 
729  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
730 
736  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
737 
744  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
745 
754  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
755 
756  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
757  QgsUnitTypes::RenderUnit outputUnit() const override;
758  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
759  QgsMapUnitScale mapUnitScale() const override;
760  double estimateMaxBleed( const QgsRenderContext &context ) const override;
761  double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
762  QColor dxfColor( QgsSymbolRenderContext &context ) const override;
763  Qt::PenStyle dxfPenStyle() const override;
764  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
765  bool hasDataDefinedProperties() const override;
766 
767  protected:
768  QBrush mBrush;
769  double mNextAngle = 0.0; // mAngle / data defined angle
770 
772  double mStrokeWidth = 0.0;
775 
777  std::unique_ptr< QgsLineSymbol > mStroke;
778 
779  virtual void applyDataDefinedSettings( QgsSymbolRenderContext &context ) { Q_UNUSED( context ) }
780 
786  virtual bool applyBrushTransformFromContext() const;
787 
788  private:
789 #ifdef SIP_RUN
791 #endif
792 };
793 
801 {
802  public:
803 
806  {
809  };
810 
815  QgsRasterFillSymbolLayer( const QString &imageFilePath = QString() );
816 
818 
823  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
824 
830  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
831 
832  // implemented from base classes
833  QString layerType() const override;
834  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
835  void startRender( QgsSymbolRenderContext &context ) override;
836  void stopRender( QgsSymbolRenderContext &context ) override;
837  QVariantMap properties() const override;
838  QgsRasterFillSymbolLayer *clone() const override SIP_FACTORY;
839  double estimateMaxBleed( const QgsRenderContext &context ) const override;
840  bool usesMapUnits() const override;
841 
842  //override QgsImageFillSymbolLayer's support for sub symbols
843  QgsSymbol *subSymbol() override { return nullptr; }
844  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
845 
851  void setImageFilePath( const QString &imagePath );
852 
858  QString imageFilePath() const { return mImageFilePath; }
859 
866  void setCoordinateMode( FillCoordinateMode mode );
867 
874  FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
875 
881  void setOpacity( double opacity );
882 
888  double opacity() const { return mOpacity; }
889 
897  void setOffset( QPointF offset ) { mOffset = offset; }
898 
906  QPointF offset() const { return mOffset; }
907 
915  void setOffsetUnit( const QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
916 
924  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
925 
933  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
934 
942  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
943 
952  void setWidth( const double width ) { mWidth = width; }
953 
962  double width() const { return mWidth; }
963 
971  void setWidthUnit( const QgsUnitTypes::RenderUnit unit ) { mWidthUnit = unit; }
972 
980  QgsUnitTypes::RenderUnit widthUnit() const { return mWidthUnit; }
981 
989  void setWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWidthMapUnitScale = scale; }
990 
998  const QgsMapUnitScale &widthMapUnitScale() const { return mWidthMapUnitScale; }
999 
1000  protected:
1001 
1002  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
1003  bool applyBrushTransformFromContext() const override;
1004  private:
1005 
1007  QString mImageFilePath;
1008  FillCoordinateMode mCoordinateMode = QgsRasterFillSymbolLayer::Feature;
1009  double mOpacity = 1.0;
1010 
1011  QPointF mOffset;
1013  QgsMapUnitScale mOffsetMapUnitScale;
1014 
1015  double mWidth = 0.0;
1017  QgsMapUnitScale mWidthMapUnitScale;
1018 
1020  void applyPattern( QBrush &brush, const QString &imageFilePath, double width, double opacity,
1021  const QgsSymbolRenderContext &context );
1022 };
1023 
1029 {
1030  public:
1031 
1035  QgsSVGFillSymbolLayer( const QString &svgFilePath, double width = 20, double rotation = 0.0 );
1036 
1040  QgsSVGFillSymbolLayer( const QByteArray &svgData, double width = 20, double rotation = 0.0 );
1041 
1043 
1048  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1049 
1054  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
1055 
1061  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
1062 
1063  // implemented from base classes
1064 
1065  QString layerType() const override;
1066  void startRender( QgsSymbolRenderContext &context ) override;
1067  void stopRender( QgsSymbolRenderContext &context ) override;
1068  QVariantMap properties() const override;
1069  QgsSVGFillSymbolLayer *clone() const override SIP_FACTORY;
1070  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
1071  bool usesMapUnits() const override;
1072 
1084  void setSvgFilePath( const QString &svgPath );
1085 
1091  QString svgFilePath() const { return mSvgFilePath; }
1092 
1102  void setPatternWidth( double width ) { mPatternWidth = width;}
1103 
1113  double patternWidth() const { return mPatternWidth; }
1114 
1124  void setSvgFillColor( const QColor &c ) { setColor( c ); }
1125 
1134  QColor svgFillColor() const { return color(); }
1135 
1145  void setSvgStrokeColor( const QColor &c ) { mSvgStrokeColor = c; }
1146 
1155  QColor svgStrokeColor() const { return mSvgStrokeColor; }
1156 
1167  void setSvgStrokeWidth( double w ) { mSvgStrokeWidth = w; }
1168 
1179  double svgStrokeWidth() const { return mSvgStrokeWidth; }
1180 
1188  void setPatternWidthUnit( QgsUnitTypes::RenderUnit unit ) { mPatternWidthUnit = unit; }
1189 
1197  QgsUnitTypes::RenderUnit patternWidthUnit() const { return mPatternWidthUnit; }
1198 
1206  void setPatternWidthMapUnitScale( const QgsMapUnitScale &scale ) { mPatternWidthMapUnitScale = scale; }
1207 
1215  const QgsMapUnitScale &patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
1216 
1224  void setSvgStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSvgStrokeWidthUnit = unit; }
1225 
1233  QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const { return mSvgStrokeWidthUnit; }
1234 
1242  void setSvgStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSvgStrokeWidthMapUnitScale = scale; }
1243 
1251  const QgsMapUnitScale &svgStrokeWidthMapUnitScale() const { return mSvgStrokeWidthMapUnitScale; }
1252 
1253  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1254  QgsUnitTypes::RenderUnit outputUnit() const override;
1255 
1256  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1257  QgsMapUnitScale mapUnitScale() const override;
1258 
1263  QMap<QString, QgsProperty> parameters() const { return mParameters; }
1264 
1269  void setParameters( const QMap<QString, QgsProperty> &parameters );
1270 
1271  protected:
1272 
1273  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
1274 
1275  private:
1276 
1278  double mPatternWidth = 20;
1280  QgsMapUnitScale mPatternWidthMapUnitScale;
1281  QMap<QString, QgsProperty> mParameters;
1282 
1284  QByteArray mSvgData;
1286  QString mSvgFilePath;
1288  QRectF mSvgViewBox;
1289 
1290  //param(fill), param(stroke), param(stroke-width) are going
1291  //to be replaced in memory
1292  QColor mSvgStrokeColor = QColor( 35, 35, 35 );
1293  double mSvgStrokeWidth = 0.2;
1295  QgsMapUnitScale mSvgStrokeWidthMapUnitScale;
1296 
1298  void storeViewBox();
1299  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgStrokeColor, mSvgStrokeWidth with default values for mSvgFilePath
1300 
1302  void applyPattern( QBrush &brush, const QString &svgFilePath, double patternWidth, QgsUnitTypes::RenderUnit patternWidthUnit, const QColor &svgFillColor, const QColor &svgStrokeColor,
1303  double svgStrokeWidth, QgsUnitTypes::RenderUnit svgStrokeWidthUnit, const QgsSymbolRenderContext &context, const QgsMapUnitScale &patternWidthMapUnitScale, const QgsMapUnitScale &svgStrokeWidthMapUnitScale,
1304  const QgsStringMap svgParameters );
1305 };
1306 
1313 {
1314  public:
1316  ~QgsLinePatternFillSymbolLayer() override;
1317 
1322  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1323 
1328  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
1329 
1330  QString layerType() const override;
1331  void startRender( QgsSymbolRenderContext &context ) override;
1332  void stopRender( QgsSymbolRenderContext &context ) override;
1333  QVariantMap properties() const override;
1335  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
1336  double estimateMaxBleed( const QgsRenderContext &context ) const override;
1337 
1338  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
1339 
1347  void setLineAngle( double a ) { mLineAngle = a; }
1348 
1356  double lineAngle() const { return mLineAngle; }
1357 
1364  void setDistance( double d ) { mDistance = d; }
1365 
1371  double distance() const { return mDistance; }
1372 
1379  void setLineWidth( double w );
1380 
1387  double lineWidth() const { return mLineWidth; }
1388 
1389  void setColor( const QColor &c ) override;
1390  QColor color() const override;
1391 
1403  void setOffset( double offset ) { mOffset = offset; }
1404 
1416  double offset() const { return mOffset; }
1417 
1424  void setDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceUnit = unit; }
1425 
1432  QgsUnitTypes::RenderUnit distanceUnit() const { return mDistanceUnit; }
1433 
1441  void setDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceMapUnitScale = scale; }
1442 
1450  const QgsMapUnitScale &distanceMapUnitScale() const { return mDistanceMapUnitScale; }
1451 
1457  void setLineWidthUnit( QgsUnitTypes::RenderUnit unit ) { mLineWidthUnit = unit; }
1458 
1464  QgsUnitTypes::RenderUnit lineWidthUnit() const { return mLineWidthUnit; }
1465 
1473  void setLineWidthMapUnitScale( const QgsMapUnitScale &scale ) { mLineWidthMapUnitScale = scale; }
1474 
1482  const QgsMapUnitScale &lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
1483 
1489  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
1490 
1496  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
1497 
1505  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
1506 
1514  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
1515 
1516  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1517  QgsUnitTypes::RenderUnit outputUnit() const override;
1518  bool usesMapUnits() const override;
1519  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1520  QgsMapUnitScale mapUnitScale() const override;
1521  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1522  QgsSymbol *subSymbol() override;
1523  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1524  bool hasDataDefinedProperties() const override;
1525 
1526  protected:
1527 
1528  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
1529 
1530  private:
1532  double mDistance = 5.0;
1534  QgsMapUnitScale mDistanceMapUnitScale;
1536  double mLineWidth = 0;
1538  QgsMapUnitScale mLineWidthMapUnitScale;
1540  double mLineAngle = 45.0;
1542  double mOffset = 0.0;
1544  QgsMapUnitScale mOffsetMapUnitScale;
1545 
1546 #ifdef SIP_RUN
1548 #endif
1549 
1551  void applyPattern( const QgsSymbolRenderContext &context, QBrush &brush, double lineAngle, double distance );
1552 
1554  QgsLineSymbol *mFillLineSymbol = nullptr;
1555 };
1556 
1562 {
1563  public:
1565  ~QgsPointPatternFillSymbolLayer() override;
1566 
1572  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1573  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
1574 
1575  QString layerType() const override;
1576 
1577  void startRender( QgsSymbolRenderContext &context ) override;
1578  void stopRender( QgsSymbolRenderContext &context ) override;
1579  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
1580 
1581  QVariantMap properties() const override;
1582 
1584 
1585  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
1586 
1587  double estimateMaxBleed( const QgsRenderContext &context ) const override;
1588 
1589  //getters and setters
1590  double distanceX() const { return mDistanceX; }
1591  void setDistanceX( double d ) { mDistanceX = d; }
1592 
1593  double distanceY() const { return mDistanceY; }
1594  void setDistanceY( double d ) { mDistanceY = d; }
1595 
1596  double displacementX() const { return mDisplacementX; }
1597  void setDisplacementX( double d ) { mDisplacementX = d; }
1598 
1599  double displacementY() const { return mDisplacementY; }
1600  void setDisplacementY( double d ) { mDisplacementY = d; }
1601 
1609  void setOffsetX( double offset ) { mOffsetX = offset; }
1610 
1617  double offsetX() const { return mOffsetX; }
1618 
1626  void setOffsetY( double offset ) { mOffsetY = offset; }
1627 
1634  double offsetY() const { return mOffsetY; }
1635 
1636  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1637  QgsSymbol *subSymbol() override;
1638 
1645  void setDistanceXUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceXUnit = unit; }
1646 
1652  QgsUnitTypes::RenderUnit distanceXUnit() const { return mDistanceXUnit; }
1653 
1654  void setDistanceXMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceXMapUnitScale = scale; }
1655  const QgsMapUnitScale &distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1656 
1663  void setDistanceYUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceYUnit = unit; }
1664 
1670  QgsUnitTypes::RenderUnit distanceYUnit() const { return mDistanceYUnit; }
1671 
1672  void setDistanceYMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceYMapUnitScale = scale; }
1673  const QgsMapUnitScale &distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1674 
1681  void setDisplacementXUnit( QgsUnitTypes::RenderUnit unit ) { mDisplacementXUnit = unit; }
1682 
1688  QgsUnitTypes::RenderUnit displacementXUnit() const { return mDisplacementXUnit; }
1689 
1690  void setDisplacementXMapUnitScale( const QgsMapUnitScale &scale ) { mDisplacementXMapUnitScale = scale; }
1691  const QgsMapUnitScale &displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1692 
1699  void setDisplacementYUnit( QgsUnitTypes::RenderUnit unit ) { mDisplacementYUnit = unit; }
1700 
1706  QgsUnitTypes::RenderUnit displacementYUnit() const { return mDisplacementYUnit; }
1707 
1708  void setDisplacementYMapUnitScale( const QgsMapUnitScale &scale ) { mDisplacementYMapUnitScale = scale; }
1709  const QgsMapUnitScale &displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1710 
1718  void setOffsetXUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetXUnit = unit; }
1719 
1726  QgsUnitTypes::RenderUnit offsetXUnit() const { return mOffsetXUnit; }
1727 
1735  void setOffsetXMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetXMapUnitScale = scale; }
1736 
1743  const QgsMapUnitScale &offsetXMapUnitScale() const { return mOffsetXMapUnitScale; }
1744 
1752  void setOffsetYUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetYUnit = unit; }
1753 
1760  QgsUnitTypes::RenderUnit offsetYUnit() const { return mOffsetYUnit; }
1761 
1769  void setOffsetYMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetYMapUnitScale = scale; }
1770 
1777  const QgsMapUnitScale &offsetYMapUnitScale() const { return mOffsetYMapUnitScale; }
1778 
1779  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1780  QgsUnitTypes::RenderUnit outputUnit() const override;
1781  bool usesMapUnits() const override;
1782 
1783  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1784  QgsMapUnitScale mapUnitScale() const override;
1785 
1786  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1787  bool hasDataDefinedProperties() const override;
1788  void setColor( const QColor &c ) override;
1789  QColor color() const override;
1790 
1791  protected:
1792  QgsMarkerSymbol *mMarkerSymbol = nullptr;
1793  double mDistanceX = 15;
1796  double mDistanceY = 15;
1799  double mDisplacementX = 0;
1802  double mDisplacementY = 0;
1805  double mOffsetX = 0;
1808  double mOffsetY = 0;
1811 
1812  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
1813 
1814  private:
1815 #ifdef SIP_RUN
1817 #endif
1818 
1819  void applyPattern( const QgsSymbolRenderContext &context, QBrush &brush, double distanceX, double distanceY,
1820  double displacementX, double displacementY, double offsetX, double offsetY );
1821 
1822  bool mRenderUsingMarkers = false;
1823 };
1824 
1834 {
1835  public:
1836 
1839  {
1842  };
1843 
1850  QgsRandomMarkerFillSymbolLayer( int pointCount = 10, CountMethod method = AbsoluteCount, double densityArea = 250.0, unsigned long seed = 0 );
1851 
1853 
1859  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1860 
1861  QString layerType() const override;
1862  void startRender( QgsSymbolRenderContext &context ) override;
1863  void stopRender( QgsSymbolRenderContext &context ) override;
1864  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
1865  QVariantMap properties() const override;
1866  QgsRandomMarkerFillSymbolLayer *clone() const override SIP_FACTORY;
1867  bool canCauseArtifactsBetweenAdjacentTiles() const override;
1868 
1869  void setColor( const QColor &color ) override;
1870  QColor color() const override;
1871 
1872  QgsSymbol *subSymbol() override;
1873  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1874 
1875  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1876  QgsUnitTypes::RenderUnit outputUnit() const override;
1877  bool usesMapUnits() const override;
1878 
1879  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1880  QgsMapUnitScale mapUnitScale() const override;
1881 
1882  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1883  bool hasDataDefinedProperties() const override;
1884 
1890  int pointCount() const;
1891 
1897  void setPointCount( int count );
1898 
1904  unsigned long seed() const;
1905 
1913  void setSeed( unsigned long seed );
1914 
1920  bool clipPoints() const;
1921 
1927  void setClipPoints( bool clipped );
1928 
1934  CountMethod countMethod() const;
1935 
1941  void setCountMethod( CountMethod method );
1942 
1952  double densityArea() const;
1953 
1959  void setDensityArea( double area );
1960 
1966  void setDensityAreaUnit( QgsUnitTypes::RenderUnit unit ) { mDensityAreaUnit = unit; }
1967 
1972  QgsUnitTypes::RenderUnit densityAreaUnit() const { return mDensityAreaUnit; }
1973 
1981  void setDensityAreaUnitScale( const QgsMapUnitScale &scale ) { mDensityAreaUnitScale = scale; }
1982 
1989  const QgsMapUnitScale &densityAreaUnitScale() const { return mDensityAreaUnitScale; }
1990 
1991  void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
1992  void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
1993 
1994  private:
1995 #ifdef SIP_RUN
1997 #endif
1998 
1999  struct Part
2000  {
2001  QPolygonF exterior;
2002  QVector<QPolygonF> rings;
2003  };
2004 
2005  QVector< Part > mCurrentParts;
2006 
2007  void render( QgsRenderContext &context, const QVector< Part > &parts, const QgsFeature &feature, bool selected );
2008 
2009  std::unique_ptr< QgsMarkerSymbol > mMarker;
2010  CountMethod mCountMethod = AbsoluteCount;
2011  int mPointCount = 10;
2012  double mDensityArea = 250.0;
2014  QgsMapUnitScale mDensityAreaUnitScale;
2015  unsigned long mSeed = 0;
2016  bool mClipPoints = false;
2017 
2018  bool mRenderingFeature = false;
2019  double mFeatureSymbolOpacity = 1;
2020 };
2021 
2022 
2028 {
2029  public:
2032 
2033  // static stuff
2034 
2040  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
2041  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
2042 
2043  // implemented from base classes
2044 
2045  QString layerType() const override;
2046  void startRender( QgsSymbolRenderContext &context ) override;
2047  void stopRender( QgsSymbolRenderContext &context ) override;
2048  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
2049  QVariantMap properties() const override;
2050  QgsCentroidFillSymbolLayer *clone() const override SIP_FACTORY;
2051  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
2052  void setColor( const QColor &color ) override;
2053  QColor color() const override;
2054  QgsSymbol *subSymbol() override;
2055  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
2056  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
2057  QgsUnitTypes::RenderUnit outputUnit() const override;
2058  bool usesMapUnits() const override;
2059  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
2060  QgsMapUnitScale mapUnitScale() const override;
2061  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
2062  bool hasDataDefinedProperties() const override;
2063  bool canCauseArtifactsBetweenAdjacentTiles() const override;
2064 
2065  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
2066  bool pointOnSurface() const { return mPointOnSurface; }
2067 
2073  void setPointOnAllParts( bool pointOnAllParts ) { mPointOnAllParts = pointOnAllParts; }
2074 
2080  bool pointOnAllParts() const { return mPointOnAllParts; }
2081 
2088  bool clipPoints() const { return mClipPoints; }
2089 
2096  void setClipPoints( bool clipPoints ) { mClipPoints = clipPoints; }
2097 
2104  bool clipOnCurrentPartOnly() const { return mClipOnCurrentPartOnly; }
2105 
2112  void setClipOnCurrentPartOnly( bool clipOnCurrentPartOnly ) { mClipOnCurrentPartOnly = clipOnCurrentPartOnly; }
2113 
2114  void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
2115  void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
2116 
2117  protected:
2118 
2119  std::unique_ptr< QgsMarkerSymbol > mMarker;
2120  bool mPointOnSurface = false;
2121  bool mPointOnAllParts = true;
2122  bool mClipPoints = false;
2123  bool mClipOnCurrentPartOnly = false;
2124 
2125  bool mRenderingFeature = false;
2126  double mFeatureSymbolOpacity = 1;
2127 
2128  QgsFeatureId mCurrentFeatureId = -1;
2129  int mBiggestPartIndex = -1;
2130 
2131  private:
2132 #ifdef SIP_RUN
2134 #endif
2135  struct Part
2136  {
2137  QPolygonF exterior;
2138  QVector<QPolygonF> rings;
2139  };
2140 
2141  void render( QgsRenderContext &context, const QVector<Part> &parts, const QgsFeature &feature, bool selected );
2142  QVector<Part> mCurrentParts;
2143 };
2144 
2145 #endif
2146 
2147 
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features.
void setClipOnCurrentPartOnly(bool clipOnCurrentPartOnly)
Sets whether point markers should be clipped to the current part boundary only.
void setClipPoints(bool clipPoints)
Sets whether point markers should be clipped to the polygon boundary.
std::unique_ptr< QgsMarkerSymbol > mMarker
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features.
bool clipPoints() const
Returns true if point markers should be clipped to the polygon boundary.
~QgsCentroidFillSymbolLayer() override
bool clipOnCurrentPartOnly() const
Returns true if point markers should be clipped to the current part boundary only.
Abstract base class for color ramps.
Definition: qgscolorramp.h:32
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:64
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
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,...
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient fill.
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
void setGradientType(GradientType gradientType)
void setCoordinateMode(GradientCoordinateMode coordinateMode)
GradientColorType mGradientColorType
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the fill's offset.
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
void setGradientColorType(GradientColorType gradientColorType)
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
void setGradientSpread(GradientSpread gradientSpread)
GradientCoordinateMode mCoordinateMode
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
void setOffset(QPointF offset)
Sets an offset by which polygons will be translated during rendering.
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
QPointF offset() const
Returns the offset by which polygons will be translated during rendering.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
void setColor2(const QColor &color2)
Base class for polygon renderers generating texture images.
std::unique_ptr< QgsLineSymbol > mStroke
Custom stroke.
QgsMapUnitScale mStrokeWidthMapUnitScale
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
virtual void applyDataDefinedSettings(QgsSymbolRenderContext &context)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units fo the symbol's stroke width.
~QgsImageFillSymbolLayer() override
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
A symbol fill consisting of repeated parallel lines.
void setLineWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's width.
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line width.
double lineWidth() const
Returns the width of the line subsymbol used to render the parallel lines in the fill.
const QgsMapUnitScale & lineWidthMapUnitScale() const
Returns the map unit scale for the pattern's line width.
QgsUnitTypes::RenderUnit lineWidthUnit() const
Returns the units for the line's width.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the pattern's line offset.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line distance.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line pattern's offset.
void setDistance(double d)
Sets the distance between lines in the fill pattern.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the distance between lines in the fill pattern.
void setLineAngle(double a)
Sets the angle for the parallel lines used to fill the symbol.
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line pattern's offset.
double distance() const
Returns the distance between lines in the fill pattern.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the units for the distance between lines in the fill pattern.
void setOffset(double offset)
Sets the offset distance for lines within the fill, which is the distance to offset the parallel line...
const QgsMapUnitScale & distanceMapUnitScale() const
Returns the map unit scale for the pattern's line distance.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line offset.
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
Struct for storing maximum and minimum scales for measurements in map units.
A marker symbol type, for rendering Point and MultiPoint geometries.
Resolves relative paths into absolute paths and vice versa.
const QgsMapUnitScale & displacementYMapUnitScale() const
void setOffsetYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical offset for rows in the pattern.
void setOffsetX(double offset)
Sets the horizontal offset values for points in the pattern.
QgsUnitTypes::RenderUnit offsetYUnit() const
Returns the units for the vertical offset for rows in the pattern.
const QgsMapUnitScale & offsetYMapUnitScale() const
Returns the unit scale for the vertical offset between rows in the pattern.
QgsUnitTypes::RenderUnit displacementYUnit() const
Returns the units for the vertical displacement between rows in the pattern.
QgsUnitTypes::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
double offsetY() const
Returns the vertical offset values for points in the pattern.
const QgsMapUnitScale & distanceYMapUnitScale() const
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
void setOffsetY(double offset)
Sets the vertical offset values for points in the pattern.
QgsUnitTypes::RenderUnit offsetXUnit() const
Returns the units for the horizontal offset for rows in the pattern.
void setDistanceXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal distance between points in the pattern.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & offsetXMapUnitScale() const
Returns the unit scale for the horizontal offset for rows in the pattern.
void setOffsetYMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the vertical offset for rows in the pattern.
void setDisplacementYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
double offsetX() const
Returns the horizontal offset values for points in the pattern.
void setDisplacementXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal displacement between rows in the pattern.
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit displacementXUnit() const
Returns the units for the horizontal displacement between rows in the pattern.
void setOffsetXMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the horizontal offset for rows in the pattern.
void setOffsetXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal offset between rows in the pattern.
const QgsMapUnitScale & distanceXMapUnitScale() const
QgsUnitTypes::RenderUnit distanceXUnit() const
Returns the units for the horizontal distance between points in the pattern.
void setDistanceYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical distance between points in the pattern.
const QgsMapUnitScale & displacementXMapUnitScale() const
A fill symbol layer which places markers at random locations within polygons.
~QgsRandomMarkerFillSymbolLayer() override
QgsUnitTypes::RenderUnit densityAreaUnit() const
Returns the units for the density area.
void setDensityAreaUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the density area.
const QgsMapUnitScale & densityAreaUnitScale() const
Returns the map scale for the density area.
CountMethod
Methods to define the number of points randomly filling the polygon.
@ AbsoluteCount
The point count is used as an absolute count of markers.
@ DensityBasedCount
The point count is part of a marker density count.
A class for filling symbols with a repeated raster image.
double width() const
Returns the width used for scaling the image used in the fill.
void setWidthUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the image's width.
FillCoordinateMode
Fill coordinate modes, dictates fill tiling behavior.
@ Feature
Tiling is based on feature bounding box.
@ Viewport
Tiling is based on complete map viewport.
void setOffsetUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the fill's offset.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the image's width.
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
double opacity() const
Returns the opacity for the raster image used in the fill.
~QgsRasterFillSymbolLayer() override
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
QString imageFilePath() const
The path to the raster image used for the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
QPointF offset() const
Returns the offset for the fill.
void setOffset(QPointF offset)
Sets the offset for the fill.
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
Contains information about the context of a rendering operation.
A class for filling symbols with a repeated SVG file.
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's stroke.
void setPatternWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the width of the SVG images in the pattern.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
void setSvgFillColor(const QColor &c)
Sets the fill color used for rendering the SVG content.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
void setSvgStrokeWidth(double w)
Sets the stroke width used for rendering the SVG content.
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
void setSvgStrokeColor(const QColor &c)
Sets the stroke color used for rendering the SVG content.
void setSvgStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the stroke width.
void setPatternWidth(double width)
Sets the width to render the SVG content as within the fill (i.e.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
~QgsSVGFillSymbolLayer() override
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's width.
~QgsShapeburstFillSymbolLayer() override
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsColorRamp * colorRamp()
Returns the color ramp used for the shapeburst fill.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
const QgsMapUnitScale & distanceMapUnitScale() const
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
QgsShapeburstFillSymbolLayer & operator=(const QgsShapeburstFillSymbolLayer &other)=delete
QgsShapeburstFillSymbolLayer cannot be copied.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary.
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading.
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon's boundary.
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
const QgsMapUnitScale & offsetMapUnitScale() const
void setColorType(ShapeburstColorType colorType)
Sets the color mode to use for the shapeburst fill.
QPointF offset() const
Returns the offset for the shapeburst fill.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the offset for the shapeburst fill.
QgsShapeburstFillSymbolLayer(const QgsShapeburstFillSymbolLayer &other)=delete
QgsShapeburstFillSymbolLayer cannot be copied.
Qt::PenJoinStyle penJoinStyle() const
QColor strokeColor() const override
Gets stroke color.
void setBrushStyle(Qt::BrushStyle style)
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the width of the fill's stroke.
~QgsSimpleFillSymbolLayer() override
void setPenJoinStyle(Qt::PenJoinStyle style)
QColor fillColor() const override
Gets fill color.
Qt::PenStyle strokeStyle() const
QgsMapUnitScale mOffsetMapUnitScale
void setStrokeWidth(double strokeWidth)
void setStrokeStyle(Qt::PenStyle strokeStyle)
QgsMapUnitScale mStrokeWidthMapUnitScale
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setFillColor(const QColor &color) override
Set fill color.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
QPointF offset()
Returns the offset by which polygons will be translated during rendering.
void setOffset(QPointF offset)
Sets an offset by which polygons will be translated during rendering.
void setStrokeColor(const QColor &strokeColor) override
Set stroke color.
Qt::PenJoinStyle mPenJoinStyle
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the fill's offset.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the fill's stroke.
virtual void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
virtual void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called before the layer will be rendered for a particular feature.
virtual QgsMapUnitScale mapUnitScale() const
virtual QColor color() const
The fill color.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
Gets brush/fill color.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
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.
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 Qt::PenStyle dxfPenStyle() const
Gets pen style.
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
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 QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
virtual void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called after the layer has been rendered for a particular feature.
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
virtual double dxfAngle(QgsSymbolRenderContext &context) const
Gets angle.
virtual QColor strokeColor() const
Gets stroke color.
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
virtual void setColor(const QColor &color)
The fill color.
virtual Qt::BrushStyle dxfBrushStyle() const
Gets brush/fill style.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
Helper functions for various unit types.
Definition: qgsunittypes.h:39
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
@ 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
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QMap< QString, QString > QgsStringMap
Definition: qgis.h:1262
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
#define DEFAULT_SIMPLEFILL_JOINSTYLE
#define DEFAULT_SIMPLEFILL_COLOR
#define DEFAULT_SIMPLEFILL_STYLE
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
#define DEFAULT_SIMPLEFILL_BORDERWIDTH