QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 
39 class CORE_EXPORT QgsSimpleFillSymbolLayer : public QgsFillSymbolLayer
40 {
41  public:
43  Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
44  const QColor &strokeColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
45  Qt::PenStyle strokeStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
46  double strokeWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH,
47  Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEFILL_JOINSTYLE
48  );
49 
50  // static stuff
51 
57  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
58  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
59 
60  // implemented from base classes
61 
62  QString layerType() const override;
63 
64  void startRender( QgsSymbolRenderContext &context ) override;
65 
66  void stopRender( QgsSymbolRenderContext &context ) override;
67 
68  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
69 
70  QVariantMap properties() const override;
71 
72  QgsSimpleFillSymbolLayer *clone() const override SIP_FACTORY;
73 
74  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
75 
76  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
77 
78  Qt::BrushStyle brushStyle() const { return mBrushStyle; }
79  void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; }
80 
81  QColor strokeColor() const override { return mStrokeColor; }
82  void setStrokeColor( const QColor &strokeColor ) override { mStrokeColor = strokeColor; }
83 
84  QColor fillColor() const override { return color(); }
85  void setFillColor( const QColor &color ) override { setColor( color ); }
86 
87  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
88  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
89 
90  double strokeWidth() const { return mStrokeWidth; }
91  void setStrokeWidth( double strokeWidth ) { mStrokeWidth = strokeWidth; }
92 
93  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
94  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
95 
104  void setOffset( QPointF offset ) { mOffset = offset; }
105 
114  QPointF offset() { return mOffset; }
115 
121  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
122 
127  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
128 
129  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
130  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
131 
137  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
138 
144  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
145 
151  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
152 
158  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
159 
160  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
161  QgsUnitTypes::RenderUnit outputUnit() const override;
162  bool usesMapUnits() const override;
163 
164  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
165  QgsMapUnitScale mapUnitScale() const override;
166 
167  double estimateMaxBleed( const QgsRenderContext &context ) const override;
168 
169  double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
170  QColor dxfColor( QgsSymbolRenderContext &context ) const override;
171  double dxfAngle( QgsSymbolRenderContext &context ) const override;
172 
173  Qt::PenStyle dxfPenStyle() const override;
174  QColor dxfBrushColor( QgsSymbolRenderContext &context ) const override;
175  Qt::BrushStyle dxfBrushStyle() const override;
176 
177  protected:
178  QBrush mBrush;
179  QBrush mSelBrush;
180  Qt::BrushStyle mBrushStyle;
181  QColor mStrokeColor;
182  Qt::PenStyle mStrokeStyle;
183  double mStrokeWidth;
186  Qt::PenJoinStyle mPenJoinStyle;
187  QPen mPen;
188  QPen mSelPen;
189 
190  QPointF mOffset;
193 
194  private:
195  //helper functions for data defined symbology
196  void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen );
197 };
198 
199 class QgsColorRamp;
200 
206 {
207  public:
208 
210  {
212  ColorRamp
213  };
214 
216  {
219  Conical
220  };
221 
223  {
225  Viewport
226  };
227 
229  {
232  Repeat
233  };
234 
236  const QColor &color2 = Qt::white,
237  GradientColorType gradientColorType = SimpleTwoColor,
238  GradientType gradientType = Linear,
239  GradientCoordinateMode coordinateMode = Feature,
240  GradientSpread gradientSpread = Pad
241  );
242 
243  ~QgsGradientFillSymbolLayer() override;
244 
245  // static stuff
246 
252  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
253 
254  // implemented from base classes
255 
256  QString layerType() const override;
257  void startRender( QgsSymbolRenderContext &context ) override;
258  void stopRender( QgsSymbolRenderContext &context ) override;
259  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
260  QVariantMap properties() const override;
261  QgsGradientFillSymbolLayer *clone() const override SIP_FACTORY;
262  double estimateMaxBleed( const QgsRenderContext &context ) const override;
263  bool canCauseArtifactsBetweenAdjacentTiles() const override;
264 
266  GradientType gradientType() const { return mGradientType; }
267  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
268 
270  GradientColorType gradientColorType() const { return mGradientColorType; }
271  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
272 
279  QgsColorRamp *colorRamp() { return mGradientRamp; }
280 
288  void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
289 
291  QColor color2() const { return mColor2; }
292  void setColor2( const QColor &color2 ) { mColor2 = color2; }
293 
295  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
296  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
297 
299  GradientSpread gradientSpread() const { return mGradientSpread; }
300  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
301 
303  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
304  QPointF referencePoint1() const { return mReferencePoint1; }
305 
307  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
308  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
309 
311  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
312  QPointF referencePoint2() const { return mReferencePoint2; }
313 
315  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
316  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
317 
326  void setOffset( QPointF offset ) { mOffset = offset; }
327 
336  QPointF offset() const { return mOffset; }
337 
343  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
344 
350  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
351 
357  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
358 
364  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
365 
366  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
367  QgsUnitTypes::RenderUnit outputUnit() const override;
368  bool usesMapUnits() const override;
369 
370  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
371  QgsMapUnitScale mapUnitScale() const override;
372 
373  protected:
374  QBrush mBrush;
375  QBrush mSelBrush;
376 
378  QColor mColor2;
379  QgsColorRamp *mGradientRamp = nullptr;
383 
385  bool mReferencePoint1IsCentroid = false;
387  bool mReferencePoint2IsCentroid = false;
388 
389  QPointF mOffset;
392 
393  private:
394 
395  //helper functions for data defined symbology
396  void applyDataDefinedSymbology( QgsSymbolRenderContext &context, const QPolygonF &points );
397 
399  void applyGradient( const QgsSymbolRenderContext &context, QBrush &brush, const QColor &color, const QColor &color2,
400  GradientColorType gradientColorType, QgsColorRamp *gradientRamp, GradientType gradientType,
401  GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
402  QPointF referencePoint1, QPointF referencePoint2, double angle );
403 
405  QPointF rotateReferencePoint( QPointF refPoint, double angle );
406 };
407 
413 {
414  public:
415 
417  {
419  ColorRamp
420  };
421 
422  QgsShapeburstFillSymbolLayer( const QColor &color = DEFAULT_SIMPLEFILL_COLOR, const QColor &color2 = Qt::white,
423  ShapeburstColorType colorType = SimpleTwoColor,
424  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
425 
427 
433 
439 
440  // static stuff
441 
447  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
448 
449  // implemented from base classes
450 
451  QString layerType() const override;
452  void startRender( QgsSymbolRenderContext &context ) override;
453  void stopRender( QgsSymbolRenderContext &context ) override;
454  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
455  QVariantMap properties() const override;
456  QgsShapeburstFillSymbolLayer *clone() const override SIP_FACTORY;
457  double estimateMaxBleed( const QgsRenderContext &context ) const override;
458  bool canCauseArtifactsBetweenAdjacentTiles() const override;
459 
466  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
467 
474  int blurRadius() const { return mBlurRadius; }
475 
484  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
485 
493  bool useWholeShape() const { return mUseWholeShape; }
494 
503  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
504 
513  double maxDistance() const { return mMaxDistance; }
514 
522  void setDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceUnit = unit; }
523 
531  QgsUnitTypes::RenderUnit distanceUnit() const { return mDistanceUnit; }
532 
533  void setDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceMapUnitScale = scale; }
534  const QgsMapUnitScale &distanceMapUnitScale() const { return mDistanceMapUnitScale; }
535 
546  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
547 
558  ShapeburstColorType colorType() const { return mColorType; }
559 
569  void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
570 
578  QgsColorRamp *colorRamp() { return mGradientRamp.get(); }
579 
587  void setColor2( const QColor &color2 ) { mColor2 = color2; }
588 
596  QColor color2() const { return mColor2; }
597 
605  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
606 
613  bool ignoreRings() const { return mIgnoreRings; }
614 
622  void setOffset( QPointF offset ) { mOffset = offset; }
623 
631  QPointF offset() const { return mOffset; }
632 
640  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
641 
649  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
650 
651  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
652  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
653 
654  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
655  QgsUnitTypes::RenderUnit outputUnit() const override;
656  bool usesMapUnits() const override;
657 
658  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
659  QgsMapUnitScale mapUnitScale() const override;
660 
661  private:
662  QBrush mBrush;
663  QBrush mSelBrush;
664 
665  int mBlurRadius = 0;
666 
667  bool mUseWholeShape = true;
668  double mMaxDistance = 5.0;
670  QgsMapUnitScale mDistanceMapUnitScale;
671 
672  ShapeburstColorType mColorType = SimpleTwoColor;
673  QColor mColor2;
674 
675  bool mIgnoreRings = false;
676 
677  QPointF mOffset;
679  QgsMapUnitScale mOffsetMapUnitScale;
680 
681  std::unique_ptr< QgsColorRamp > mGradientRamp;
682 
683  //helper functions for data defined symbology
684  void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QColor &color, QColor &color2, int &blurRadius, bool &useWholeShape,
685  double &maxDistance, bool &ignoreRings );
686 
687  /* distance transform of a 1d function using squared distance */
688  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
689  /* distance transform of 2d function using squared distance */
690  void distanceTransform2d( double *im, int width, int height, QgsRenderContext &context );
691  /* distance transform of a binary QImage */
692  double *distanceTransform( QImage *im, QgsRenderContext &context );
693 
694  /* fills a QImage with values from an array of doubles containing squared distance transform values */
695  void dtArrayToQImage( double *array, QImage *im, QgsColorRamp *ramp, QgsRenderContext &context, bool useWholeShape = true, int maxPixelDistance = 0 );
696 
697 #ifdef SIP_RUN
699 #endif
700 };
701 
707 {
708  public:
709 
711  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
712 
713  QgsSymbol *subSymbol() override { return mStroke.get(); }
714  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
715 
721  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
722 
728  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
729 
736  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
737 
746  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
747 
748  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
749  QgsUnitTypes::RenderUnit outputUnit() const override;
750  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
751  QgsMapUnitScale mapUnitScale() const override;
752  double estimateMaxBleed( const QgsRenderContext &context ) const override;
753  double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
754  QColor dxfColor( QgsSymbolRenderContext &context ) const override;
755  Qt::PenStyle dxfPenStyle() const override;
756  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
757  bool hasDataDefinedProperties() const override;
758 
759  protected:
760  QBrush mBrush;
761  double mNextAngle = 0.0; // mAngle / data defined angle
762 
764  double mStrokeWidth = 0.0;
767 
769  std::unique_ptr< QgsLineSymbol > mStroke;
770 
771  virtual void applyDataDefinedSettings( QgsSymbolRenderContext &context ) { Q_UNUSED( context ) }
772 
778  virtual bool applyBrushTransformFromContext() const;
779 
780  private:
781 #ifdef SIP_RUN
783 #endif
784 };
785 
793 {
794  public:
795 
798  {
801  };
802 
807  QgsRasterFillSymbolLayer( const QString &imageFilePath = QString() );
808 
813  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
814 
820  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
821 
822  // implemented from base classes
823  QString layerType() const override;
824  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
825  void startRender( QgsSymbolRenderContext &context ) override;
826  void stopRender( QgsSymbolRenderContext &context ) override;
827  QVariantMap properties() const override;
828  QgsRasterFillSymbolLayer *clone() const override SIP_FACTORY;
829  double estimateMaxBleed( const QgsRenderContext &context ) const override;
830  bool usesMapUnits() const override;
831 
832  //override QgsImageFillSymbolLayer's support for sub symbols
833  QgsSymbol *subSymbol() override { return nullptr; }
834  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
835 
841  void setImageFilePath( const QString &imagePath );
842 
848  QString imageFilePath() const { return mImageFilePath; }
849 
856  void setCoordinateMode( FillCoordinateMode mode );
857 
864  FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
865 
871  void setOpacity( double opacity );
872 
878  double opacity() const { return mOpacity; }
879 
887  void setOffset( QPointF offset ) { mOffset = offset; }
888 
896  QPointF offset() const { return mOffset; }
897 
905  void setOffsetUnit( const QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
906 
914  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
915 
923  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
924 
932  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
933 
942  void setWidth( const double width ) { mWidth = width; }
943 
952  double width() const { return mWidth; }
953 
961  void setWidthUnit( const QgsUnitTypes::RenderUnit unit ) { mWidthUnit = unit; }
962 
970  QgsUnitTypes::RenderUnit widthUnit() const { return mWidthUnit; }
971 
979  void setWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWidthMapUnitScale = scale; }
980 
988  const QgsMapUnitScale &widthMapUnitScale() const { return mWidthMapUnitScale; }
989 
990  protected:
991 
992  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
993  bool applyBrushTransformFromContext() const override;
994  private:
995 
997  QString mImageFilePath;
998  FillCoordinateMode mCoordinateMode = QgsRasterFillSymbolLayer::Feature;
999  double mOpacity = 1.0;
1000 
1001  QPointF mOffset;
1003  QgsMapUnitScale mOffsetMapUnitScale;
1004 
1005  double mWidth = 0.0;
1007  QgsMapUnitScale mWidthMapUnitScale;
1008 
1010  void applyPattern( QBrush &brush, const QString &imageFilePath, double width, double opacity,
1011  const QgsSymbolRenderContext &context );
1012 };
1013 
1019 {
1020  public:
1021 
1025  QgsSVGFillSymbolLayer( const QString &svgFilePath, double width = 20, double rotation = 0.0 );
1026 
1030  QgsSVGFillSymbolLayer( const QByteArray &svgData, double width = 20, double rotation = 0.0 );
1031 
1036  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1037 
1042  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
1043 
1049  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
1050 
1051  // implemented from base classes
1052 
1053  QString layerType() const override;
1054  void startRender( QgsSymbolRenderContext &context ) override;
1055  void stopRender( QgsSymbolRenderContext &context ) override;
1056  QVariantMap properties() const override;
1057  QgsSVGFillSymbolLayer *clone() const override SIP_FACTORY;
1058  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
1059  bool usesMapUnits() const override;
1060 
1072  void setSvgFilePath( const QString &svgPath );
1073 
1079  QString svgFilePath() const { return mSvgFilePath; }
1080 
1090  void setPatternWidth( double width ) { mPatternWidth = width;}
1091 
1101  double patternWidth() const { return mPatternWidth; }
1102 
1112  void setSvgFillColor( const QColor &c ) { setColor( c ); }
1113 
1122  QColor svgFillColor() const { return color(); }
1123 
1133  void setSvgStrokeColor( const QColor &c ) { mSvgStrokeColor = c; }
1134 
1143  QColor svgStrokeColor() const { return mSvgStrokeColor; }
1144 
1155  void setSvgStrokeWidth( double w ) { mSvgStrokeWidth = w; }
1156 
1167  double svgStrokeWidth() const { return mSvgStrokeWidth; }
1168 
1176  void setPatternWidthUnit( QgsUnitTypes::RenderUnit unit ) { mPatternWidthUnit = unit; }
1177 
1185  QgsUnitTypes::RenderUnit patternWidthUnit() const { return mPatternWidthUnit; }
1186 
1194  void setPatternWidthMapUnitScale( const QgsMapUnitScale &scale ) { mPatternWidthMapUnitScale = scale; }
1195 
1203  const QgsMapUnitScale &patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
1204 
1212  void setSvgStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSvgStrokeWidthUnit = unit; }
1213 
1221  QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const { return mSvgStrokeWidthUnit; }
1222 
1230  void setSvgStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSvgStrokeWidthMapUnitScale = scale; }
1231 
1239  const QgsMapUnitScale &svgStrokeWidthMapUnitScale() const { return mSvgStrokeWidthMapUnitScale; }
1240 
1241  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1242  QgsUnitTypes::RenderUnit outputUnit() const override;
1243 
1244  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1245  QgsMapUnitScale mapUnitScale() const override;
1246 
1251  QMap<QString, QgsProperty> parameters() const { return mParameters; }
1252 
1257  void setParameters( const QMap<QString, QgsProperty> &parameters );
1258 
1259  protected:
1260 
1261  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
1262 
1263  private:
1264 
1266  double mPatternWidth = 20;
1268  QgsMapUnitScale mPatternWidthMapUnitScale;
1269  QMap<QString, QgsProperty> mParameters;
1270 
1272  QByteArray mSvgData;
1274  QString mSvgFilePath;
1276  QRectF mSvgViewBox;
1277 
1278  //param(fill), param(stroke), param(stroke-width) are going
1279  //to be replaced in memory
1280  QColor mSvgStrokeColor = QColor( 35, 35, 35 );
1281  double mSvgStrokeWidth = 0.2;
1283  QgsMapUnitScale mSvgStrokeWidthMapUnitScale;
1284 
1286  void storeViewBox();
1287  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgStrokeColor, mSvgStrokeWidth with default values for mSvgFilePath
1288 
1290  void applyPattern( QBrush &brush, const QString &svgFilePath, double patternWidth, QgsUnitTypes::RenderUnit patternWidthUnit, const QColor &svgFillColor, const QColor &svgStrokeColor,
1291  double svgStrokeWidth, QgsUnitTypes::RenderUnit svgStrokeWidthUnit, const QgsSymbolRenderContext &context, const QgsMapUnitScale &patternWidthMapUnitScale, const QgsMapUnitScale &svgStrokeWidthMapUnitScale,
1292  const QgsStringMap svgParameters );
1293 };
1294 
1301 {
1302  public:
1304  ~QgsLinePatternFillSymbolLayer() override;
1305 
1310  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1311 
1316  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
1317 
1318  QString layerType() const override;
1319  void startRender( QgsSymbolRenderContext &context ) override;
1320  void stopRender( QgsSymbolRenderContext &context ) override;
1321  QVariantMap properties() const override;
1323  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
1324  double estimateMaxBleed( const QgsRenderContext &context ) const override;
1325 
1326  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
1327 
1335  void setLineAngle( double a ) { mLineAngle = a; }
1336 
1344  double lineAngle() const { return mLineAngle; }
1345 
1352  void setDistance( double d ) { mDistance = d; }
1353 
1359  double distance() const { return mDistance; }
1360 
1367  void setLineWidth( double w );
1368 
1375  double lineWidth() const { return mLineWidth; }
1376 
1377  void setColor( const QColor &c ) override;
1378  QColor color() const override;
1379 
1391  void setOffset( double offset ) { mOffset = offset; }
1392 
1404  double offset() const { return mOffset; }
1405 
1412  void setDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceUnit = unit; }
1413 
1420  QgsUnitTypes::RenderUnit distanceUnit() const { return mDistanceUnit; }
1421 
1429  void setDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceMapUnitScale = scale; }
1430 
1438  const QgsMapUnitScale &distanceMapUnitScale() const { return mDistanceMapUnitScale; }
1439 
1445  void setLineWidthUnit( QgsUnitTypes::RenderUnit unit ) { mLineWidthUnit = unit; }
1446 
1452  QgsUnitTypes::RenderUnit lineWidthUnit() const { return mLineWidthUnit; }
1453 
1461  void setLineWidthMapUnitScale( const QgsMapUnitScale &scale ) { mLineWidthMapUnitScale = scale; }
1462 
1470  const QgsMapUnitScale &lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
1471 
1477  void setOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetUnit = unit; }
1478 
1484  QgsUnitTypes::RenderUnit offsetUnit() const { return mOffsetUnit; }
1485 
1493  void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
1494 
1502  const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
1503 
1504  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1505  QgsUnitTypes::RenderUnit outputUnit() const override;
1506  bool usesMapUnits() const override;
1507  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1508  QgsMapUnitScale mapUnitScale() const override;
1509  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1510  QgsSymbol *subSymbol() override;
1511  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1512  bool hasDataDefinedProperties() const override;
1513 
1514  protected:
1515 
1516  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
1517 
1518  private:
1520  double mDistance = 5.0;
1522  QgsMapUnitScale mDistanceMapUnitScale;
1524  double mLineWidth = 0;
1526  QgsMapUnitScale mLineWidthMapUnitScale;
1528  double mLineAngle = 45.0;
1530  double mOffset = 0.0;
1532  QgsMapUnitScale mOffsetMapUnitScale;
1533 
1534 #ifdef SIP_RUN
1536 #endif
1537 
1539  void applyPattern( const QgsSymbolRenderContext &context, QBrush &brush, double lineAngle, double distance );
1540 
1542  QgsLineSymbol *mFillLineSymbol = nullptr;
1543 };
1544 
1550 {
1551  public:
1553  ~QgsPointPatternFillSymbolLayer() override;
1554 
1560  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1561  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
1562 
1563  QString layerType() const override;
1564 
1565  void startRender( QgsSymbolRenderContext &context ) override;
1566  void stopRender( QgsSymbolRenderContext &context ) override;
1567  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
1568 
1569  QVariantMap properties() const override;
1570 
1572 
1573  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
1574 
1575  double estimateMaxBleed( const QgsRenderContext &context ) const override;
1576 
1577  //getters and setters
1578  double distanceX() const { return mDistanceX; }
1579  void setDistanceX( double d ) { mDistanceX = d; }
1580 
1581  double distanceY() const { return mDistanceY; }
1582  void setDistanceY( double d ) { mDistanceY = d; }
1583 
1584  double displacementX() const { return mDisplacementX; }
1585  void setDisplacementX( double d ) { mDisplacementX = d; }
1586 
1587  double displacementY() const { return mDisplacementY; }
1588  void setDisplacementY( double d ) { mDisplacementY = d; }
1589 
1597  void setOffsetX( double offset ) { mOffsetX = offset; }
1598 
1605  double offsetX() const { return mOffsetX; }
1606 
1614  void setOffsetY( double offset ) { mOffsetY = offset; }
1615 
1622  double offsetY() const { return mOffsetY; }
1623 
1624  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1625  QgsSymbol *subSymbol() override { return mMarkerSymbol; }
1626 
1633  void setDistanceXUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceXUnit = unit; }
1634 
1640  QgsUnitTypes::RenderUnit distanceXUnit() const { return mDistanceXUnit; }
1641 
1642  void setDistanceXMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceXMapUnitScale = scale; }
1643  const QgsMapUnitScale &distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1644 
1651  void setDistanceYUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceYUnit = unit; }
1652 
1658  QgsUnitTypes::RenderUnit distanceYUnit() const { return mDistanceYUnit; }
1659 
1660  void setDistanceYMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceYMapUnitScale = scale; }
1661  const QgsMapUnitScale &distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1662 
1669  void setDisplacementXUnit( QgsUnitTypes::RenderUnit unit ) { mDisplacementXUnit = unit; }
1670 
1676  QgsUnitTypes::RenderUnit displacementXUnit() const { return mDisplacementXUnit; }
1677 
1678  void setDisplacementXMapUnitScale( const QgsMapUnitScale &scale ) { mDisplacementXMapUnitScale = scale; }
1679  const QgsMapUnitScale &displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1680 
1687  void setDisplacementYUnit( QgsUnitTypes::RenderUnit unit ) { mDisplacementYUnit = unit; }
1688 
1694  QgsUnitTypes::RenderUnit displacementYUnit() const { return mDisplacementYUnit; }
1695 
1696  void setDisplacementYMapUnitScale( const QgsMapUnitScale &scale ) { mDisplacementYMapUnitScale = scale; }
1697  const QgsMapUnitScale &displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1698 
1706  void setOffsetXUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetXUnit = unit; }
1707 
1714  QgsUnitTypes::RenderUnit offsetXUnit() const { return mOffsetXUnit; }
1715 
1723  void setOffsetXMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetXMapUnitScale = scale; }
1724 
1731  const QgsMapUnitScale &offsetXMapUnitScale() const { return mOffsetXMapUnitScale; }
1732 
1740  void setOffsetYUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetYUnit = unit; }
1741 
1748  QgsUnitTypes::RenderUnit offsetYUnit() const { return mOffsetYUnit; }
1749 
1757  void setOffsetYMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetYMapUnitScale = scale; }
1758 
1765  const QgsMapUnitScale &offsetYMapUnitScale() const { return mOffsetYMapUnitScale; }
1766 
1767  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1768  QgsUnitTypes::RenderUnit outputUnit() const override;
1769  bool usesMapUnits() const override;
1770 
1771  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1772  QgsMapUnitScale mapUnitScale() const override;
1773 
1774  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1775  bool hasDataDefinedProperties() const override;
1776  void setColor( const QColor &c ) override;
1777  QColor color() const override;
1778 
1779  protected:
1780  QgsMarkerSymbol *mMarkerSymbol = nullptr;
1781  double mDistanceX = 15;
1784  double mDistanceY = 15;
1787  double mDisplacementX = 0;
1790  double mDisplacementY = 0;
1793  double mOffsetX = 0;
1796  double mOffsetY = 0;
1799 
1800  void applyDataDefinedSettings( QgsSymbolRenderContext &context ) override;
1801 
1802  private:
1803 #ifdef SIP_RUN
1805 #endif
1806 
1807  void applyPattern( const QgsSymbolRenderContext &context, QBrush &brush, double distanceX, double distanceY,
1808  double displacementX, double displacementY, double offsetX, double offsetY );
1809 
1810  bool mRenderUsingMarkers = false;
1811 };
1812 
1822 {
1823  public:
1824 
1827  {
1830  };
1831 
1838  QgsRandomMarkerFillSymbolLayer( int pointCount = 10, CountMethod method = AbsoluteCount, double densityArea = 250.0, unsigned long seed = 0 );
1839 
1845  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1846 
1847  QString layerType() const override;
1848  void startRender( QgsSymbolRenderContext &context ) override;
1849  void stopRender( QgsSymbolRenderContext &context ) override;
1850  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
1851  QVariantMap properties() const override;
1852  QgsRandomMarkerFillSymbolLayer *clone() const override SIP_FACTORY;
1853  bool canCauseArtifactsBetweenAdjacentTiles() const override;
1854 
1855  void setColor( const QColor &color ) override;
1856  QColor color() const override;
1857 
1858  QgsSymbol *subSymbol() override;
1859  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1860 
1861  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1862  QgsUnitTypes::RenderUnit outputUnit() const override;
1863  bool usesMapUnits() const override;
1864 
1865  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1866  QgsMapUnitScale mapUnitScale() const override;
1867 
1868  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1869  bool hasDataDefinedProperties() const override;
1870 
1876  int pointCount() const;
1877 
1883  void setPointCount( int count );
1884 
1890  unsigned long seed() const;
1891 
1899  void setSeed( unsigned long seed );
1900 
1906  bool clipPoints() const;
1907 
1913  void setClipPoints( bool clipped );
1914 
1920  CountMethod countMethod() const;
1921 
1927  void setCountMethod( CountMethod method );
1928 
1938  double densityArea() const;
1939 
1945  void setDensityArea( double area );
1946 
1952  void setDensityAreaUnit( QgsUnitTypes::RenderUnit unit ) { mDensityAreaUnit = unit; }
1953 
1958  QgsUnitTypes::RenderUnit densityAreaUnit() const { return mDensityAreaUnit; }
1959 
1967  void setDensityAreaUnitScale( const QgsMapUnitScale &scale ) { mDensityAreaUnitScale = scale; }
1968 
1975  const QgsMapUnitScale &densityAreaUnitScale() const { return mDensityAreaUnitScale; }
1976 
1977  void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
1978  void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
1979 
1980  private:
1981 #ifdef SIP_RUN
1983 #endif
1984 
1985  struct Part
1986  {
1987  QPolygonF exterior;
1988  QVector<QPolygonF> rings;
1989  };
1990 
1991  QVector< Part > mCurrentParts;
1992 
1993  void render( QgsRenderContext &context, const QVector< Part > &parts, const QgsFeature &feature, bool selected );
1994 
1995  std::unique_ptr< QgsMarkerSymbol > mMarker;
1996  CountMethod mCountMethod = AbsoluteCount;
1997  int mPointCount = 10;
1998  double mDensityArea = 250.0;
2000  QgsMapUnitScale mDensityAreaUnitScale;
2001  unsigned long mSeed = 0;
2002  bool mClipPoints = false;
2003 
2004  bool mRenderingFeature = false;
2005  double mFeatureSymbolOpacity = 1;
2006 };
2007 
2008 
2014 {
2015  public:
2017 
2018  // static stuff
2019 
2025  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
2026  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
2027 
2028  // implemented from base classes
2029 
2030  QString layerType() const override;
2031  void startRender( QgsSymbolRenderContext &context ) override;
2032  void stopRender( QgsSymbolRenderContext &context ) override;
2033  void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
2034  QVariantMap properties() const override;
2035  QgsCentroidFillSymbolLayer *clone() const override SIP_FACTORY;
2036  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
2037  void setColor( const QColor &color ) override;
2038  QColor color() const override;
2039  QgsSymbol *subSymbol() override;
2040  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
2041  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
2042  QgsUnitTypes::RenderUnit outputUnit() const override;
2043  bool usesMapUnits() const override;
2044  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
2045  QgsMapUnitScale mapUnitScale() const override;
2046  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
2047  bool hasDataDefinedProperties() const override;
2048  bool canCauseArtifactsBetweenAdjacentTiles() const override;
2049 
2050  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
2051  bool pointOnSurface() const { return mPointOnSurface; }
2052 
2058  void setPointOnAllParts( bool pointOnAllParts ) { mPointOnAllParts = pointOnAllParts; }
2059 
2065  bool pointOnAllParts() const { return mPointOnAllParts; }
2066 
2073  bool clipPoints() const { return mClipPoints; }
2074 
2081  void setClipPoints( bool clipPoints ) { mClipPoints = clipPoints; }
2082 
2089  bool clipOnCurrentPartOnly() const { return mClipOnCurrentPartOnly; }
2090 
2097  void setClipOnCurrentPartOnly( bool clipOnCurrentPartOnly ) { mClipOnCurrentPartOnly = clipOnCurrentPartOnly; }
2098 
2099  void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
2100  void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
2101 
2102  protected:
2103 
2104  std::unique_ptr< QgsMarkerSymbol > mMarker;
2105  bool mPointOnSurface = false;
2106  bool mPointOnAllParts = true;
2107  bool mClipPoints = false;
2108  bool mClipOnCurrentPartOnly = false;
2109 
2110  bool mRenderingFeature = false;
2111  double mFeatureSymbolOpacity = 1;
2112 
2113  QgsFeatureId mCurrentFeatureId = -1;
2114  int mBiggestPartIndex = -1;
2115 
2116  private:
2117 #ifdef SIP_RUN
2119 #endif
2120  struct Part
2121  {
2122  QPolygonF exterior;
2123  QVector<QPolygonF> rings;
2124  };
2125 
2126  void render( QgsRenderContext &context, const QVector<Part> &parts, const QgsFeature &feature, bool selected );
2127  QVector<Part> mCurrentParts;
2128 };
2129 
2130 #endif
2131 
2132 
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.
bool clipOnCurrentPartOnly() const
Returns true if point markers should be clipped to the current part boundary only.
void setPointOnSurface(bool pointOnSurface)
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 id, geometry and a list of field/values...
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.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
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: qgssymbol.h:1204
Struct for storing maximum and minimum scales for measurements in map units.
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:1004
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.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
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.
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.
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.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
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.
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.
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.
Qt::BrushStyle brushStyle() const
virtual void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
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 QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
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 bool canCauseArtifactsBetweenAdjacentTiles() const
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
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.
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
Helper functions for various unit types.
Definition: qgsunittypes.h:39
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:170
@ 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
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:759
#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