QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsfillsymbollayerv2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfillsymbollayerv2.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 QGSFILLSYMBOLLAYERV2_H
17 #define QGSFILLSYMBOLLAYERV2_H
18 
19 #include "qgssymbollayerv2.h"
20 
21 #define DEFAULT_SIMPLEFILL_COLOR QColor(0,0,255)
22 #define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern
23 #define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor(0,0,0)
24 #define DEFAULT_SIMPLEFILL_BORDERSTYLE Qt::SolidLine
25 #define DEFAULT_SIMPLEFILL_BORDERWIDTH DEFAULT_LINE_WIDTH
26 #define DEFAULT_SIMPLEFILL_JOINSTYLE Qt::BevelJoin
27 
28 #define INF 1E20
29 
30 #include <QPen>
31 #include <QBrush>
32 
37 {
38  public:
40  Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
41  const QColor& borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
42  Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
43  double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH,
44  Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEFILL_JOINSTYLE
45  );
46 
47  // static stuff
48 
49  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
50  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
51 
52  // implemented from base classes
53 
54  QString layerType() const override;
55 
56  void startRender( QgsSymbolV2RenderContext& context ) override;
57 
58  void stopRender( QgsSymbolV2RenderContext& context ) override;
59 
60  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
61 
62  QgsStringMap properties() const override;
63 
64  QgsSimpleFillSymbolLayerV2* clone() const override;
65 
67  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
68 
69  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
70 
71  Qt::BrushStyle brushStyle() const { return mBrushStyle; }
72  void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; }
73 
74  QColor borderColor() const { return mBorderColor; }
75  void setBorderColor( const QColor& borderColor ) { mBorderColor = borderColor; }
76 
79  QColor outlineColor() const override { return borderColor(); }
82  void setOutlineColor( const QColor& color ) override { setBorderColor( color ); }
83 
86  QColor fillColor() const override { return color(); }
89  void setFillColor( const QColor& color ) override { setColor( color ); }
90 
91  Qt::PenStyle borderStyle() const { return mBorderStyle; }
92  void setBorderStyle( Qt::PenStyle borderStyle ) { mBorderStyle = borderStyle; }
93 
94  double borderWidth() const { return mBorderWidth; }
95  void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; }
96 
97  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
98  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
99 
100  void setOffset( QPointF offset ) { mOffset = offset; }
101  QPointF offset() { return mOffset; }
102 
103  void setBorderWidthUnit( QgsSymbolV2::OutputUnit unit ) { mBorderWidthUnit = unit; }
104  QgsSymbolV2::OutputUnit borderWidthUnit() const { return mBorderWidthUnit; }
105 
106  void setBorderWidthMapUnitScale( const QgsMapUnitScale& scale ) { mBorderWidthMapUnitScale = scale; }
107  const QgsMapUnitScale& borderWidthMapUnitScale() const { return mBorderWidthMapUnitScale; }
108 
109  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
110  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
111 
112  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
113  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
114 
115  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
116  QgsSymbolV2::OutputUnit outputUnit() const override;
117 
118  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
119  QgsMapUnitScale mapUnitScale() const override;
120 
121  double estimateMaxBleed() const override;
122 
123  double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
124  QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
125  double dxfAngle( QgsSymbolV2RenderContext& context ) const override;
126 
127  Qt::PenStyle dxfPenStyle() const override;
128  QColor dxfBrushColor( QgsSymbolV2RenderContext &context ) const override;
129  Qt::BrushStyle dxfBrushStyle() const override;
130 
131  protected:
134  Qt::BrushStyle mBrushStyle;
136  Qt::PenStyle mBorderStyle;
137  double mBorderWidth;
140  Qt::PenJoinStyle mPenJoinStyle;
143 
147 
148  private:
149  //helper functions for data defined symbology
150  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QBrush& brush, QPen& pen, QPen& selPen );
151 };
152 
154 
159 {
160  public:
161 
163  {
165  ColorRamp
166  };
167 
169  {
172  Conical
173  };
174 
176  {
178  Viewport
179  };
180 
182  {
185  Repeat
186  };
187 
189  const QColor& color2 = Qt::white,
190  GradientColorType gradientColorType = SimpleTwoColor,
191  GradientType gradientType = Linear,
192  GradientCoordinateMode coordinateMode = Feature,
193  GradientSpread gradientSpread = Pad
194  );
195 
196  virtual ~QgsGradientFillSymbolLayerV2();
197 
198  // static stuff
199 
200  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
201 
202  // implemented from base classes
203 
204  QString layerType() const override;
205 
206  void startRender( QgsSymbolV2RenderContext& context ) override;
207 
208  void stopRender( QgsSymbolV2RenderContext& context ) override;
209 
210  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
211 
212  QgsStringMap properties() const override;
213 
214  QgsGradientFillSymbolLayerV2* clone() const override;
215 
216  double estimateMaxBleed() const override;
217 
219  GradientType gradientType() const { return mGradientType; }
220  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
221 
223  GradientColorType gradientColorType() const { return mGradientColorType; }
224  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
225 
227  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
228  void setColorRamp( QgsVectorColorRampV2* ramp );
229 
231  QColor color2() const { return mColor2; }
232  void setColor2( const QColor& color2 ) { mColor2 = color2; }
233 
235  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
236  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
237 
239  GradientSpread gradientSpread() const { return mGradientSpread; }
240  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
241 
243  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
244  QPointF referencePoint1() const { return mReferencePoint1; }
245 
247  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
248  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
249 
251  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
252  QPointF referencePoint2() const { return mReferencePoint2; }
253 
255  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
256  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
257 
259  void setOffset( QPointF offset ) { mOffset = offset; }
260  QPointF offset() const { return mOffset; }
261 
263  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
264  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
265 
266  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
267  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
268 
269  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
270  QgsSymbolV2::OutputUnit outputUnit() const override;
271 
272  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
273  QgsMapUnitScale mapUnitScale() const override;
274 
275  protected:
278 
285 
290 
294 
295  private:
296 
297  //helper functions for data defined symbology
298  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, const QPolygonF& points );
299 
301  void applyGradient( const QgsSymbolV2RenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
302  GradientColorType gradientColorType, QgsVectorColorRampV2 *gradientRamp, GradientType gradientType,
303  GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
304  QPointF referencePoint1, QPointF referencePoint2, const double angle );
305 
307  QPointF rotateReferencePoint( QPointF refPoint, double angle );
308 };
309 
314 {
315  public:
316 
318  {
320  ColorRamp
321  };
322 
323  QgsShapeburstFillSymbolLayerV2( const QColor& color = DEFAULT_SIMPLEFILL_COLOR, const QColor& color2 = Qt::white,
324  ShapeburstColorType colorType = SimpleTwoColor,
325  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
326 
328 
329  // static stuff
330 
331  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
332 
333  // implemented from base classes
334 
335  QString layerType() const override;
336 
337  void startRender( QgsSymbolV2RenderContext& context ) override;
338 
339  void stopRender( QgsSymbolV2RenderContext& context ) override;
340 
341  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
342 
343  QgsStringMap properties() const override;
344 
345  QgsShapeburstFillSymbolLayerV2* clone() const override;
346 
347  double estimateMaxBleed() const override;
348 
354  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
360  int blurRadius() const { return mBlurRadius; }
361 
369  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
376  bool useWholeShape() const { return mUseWholeShape; }
377 
385  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
393  double maxDistance() const { return mMaxDistance; }
394 
401  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
408  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
409 
410  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
411  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
412 
422  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
432  ShapeburstColorType colorType() const { return mColorType; }
433 
440  void setColorRamp( QgsVectorColorRampV2* ramp );
447  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
448 
455  void setColor2( const QColor& color2 ) { mColor2 = color2; }
462  QColor color2() const { return mColor2; }
463 
470  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
476  bool ignoreRings() const { return mIgnoreRings; }
477 
484  void setOffset( QPointF offset ) { mOffset = offset; }
491  QPointF offset() const { return mOffset; }
492 
499  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
506  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
507 
508  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
509  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
510 
511  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
512  QgsSymbolV2::OutputUnit outputUnit() const override;
513 
514  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
515  QgsMapUnitScale mapUnitScale() const override;
516 
517  protected:
520 
522 
524  double mMaxDistance;
527 
532 
534 
538 
539  private:
540 
541  //helper functions for data defined symbology
542  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int& blurRadius, bool& useWholeShape,
543  double& maxDistance, bool &ignoreRings );
544 
545  /* distance transform of a 1d function using squared distance */
546  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
547  /* distance transform of 2d function using squared distance */
548  void distanceTransform2d( double * im, int width, int height );
549  /* distance transform of a binary QImage */
550  double * distanceTransform( QImage * im );
551 
552  /* fills a QImage with values from an array of doubles containing squared distance transform values */
553  void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRampV2* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
554 };
555 
559 {
560  public:
561 
563  virtual ~QgsImageFillSymbolLayer();
564  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
565 
566  virtual QgsSymbolV2* subSymbol() override { return mOutline; }
567  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
568 
569  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
570  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
571 
572  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
573  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
574 
575  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
576  QgsSymbolV2::OutputUnit outputUnit() const override;
577 
578  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
579  QgsMapUnitScale mapUnitScale() const override;
580 
581  virtual double estimateMaxBleed() const override;
582 
583  double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
584  QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
585 
586  Qt::PenStyle dxfPenStyle() const override;
587 
588  QSet<QString> usedAttributes() const override;
589 
590  protected:
592  double mNextAngle; // mAngle / data defined angle
593 
598 
601 
602  virtual void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) { Q_UNUSED( context ); }
603 };
604 
611 {
612  public:
613 
615  {
617  Viewport
618  };
619 
620  QgsRasterFillSymbolLayer( const QString& imageFilePath = QString() );
622 
623  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
624 
625  // implemented from base classes
626  QString layerType() const override;
627  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
628  void startRender( QgsSymbolV2RenderContext& context ) override;
629  void stopRender( QgsSymbolV2RenderContext& context ) override;
630  QgsStringMap properties() const override;
631  QgsRasterFillSymbolLayer* clone() const override;
632  virtual double estimateMaxBleed() const override;
633 
634  //override QgsImageFillSymbolLayer's support for sub symbols
635  virtual QgsSymbolV2* subSymbol() override { return nullptr; }
636  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
637 
642  void setImageFilePath( const QString& imagePath );
647  QString imageFilePath() const { return mImageFilePath; }
648 
654  void setCoordinateMode( const FillCoordinateMode mode );
660  FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
661 
666  void setAlpha( const double alpha );
671  double alpha() const { return mAlpha; }
672 
679  void setOffset( QPointF offset ) { mOffset = offset; }
686  QPointF offset() const { return mOffset; }
687 
694  void setOffsetUnit( const QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
701  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
702 
709  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
716  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
717 
725  void setWidth( const double width ) { mWidth = width; }
733  double width() const { return mWidth; }
734 
741  void setWidthUnit( const QgsSymbolV2::OutputUnit unit ) { mWidthUnit = unit; }
748  QgsSymbolV2::OutputUnit widthUnit() const { return mWidthUnit; }
749 
756  void setWidthMapUnitScale( const QgsMapUnitScale& scale ) { mWidthMapUnitScale = scale; }
763  const QgsMapUnitScale& widthMapUnitScale() const { return mWidthMapUnitScale; }
764 
765  protected:
766 
770  double mAlpha;
771 
775 
776  double mWidth;
779 
780  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
781 
782  private:
783 
785  void applyPattern( QBrush& brush, const QString& imageFilePath, const double width, const double alpha,
786  const QgsSymbolV2RenderContext& context );
787 };
788 
793 {
794  public:
795  QgsSVGFillSymbolLayer( const QString& svgFilePath = "", double width = 20, double rotation = 0.0 );
796  QgsSVGFillSymbolLayer( const QByteArray& svgData, double width = 20, double rotation = 0.0 );
798 
799  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
800  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
801 
802  // implemented from base classes
803 
804  QString layerType() const override;
805 
806  void startRender( QgsSymbolV2RenderContext& context ) override;
807  void stopRender( QgsSymbolV2RenderContext& context ) override;
808 
809  QgsStringMap properties() const override;
810 
811  QgsSVGFillSymbolLayer* clone() const override;
812 
814  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
815 
816  //getters and setters
817  void setSvgFilePath( const QString& svgPath );
818  QString svgFilePath() const { return mSvgFilePath; }
819  void setPatternWidth( double width ) { mPatternWidth = width;}
820  double patternWidth() const { return mPatternWidth; }
821 
822  void setSvgFillColor( const QColor& c ) { setColor( c ); }
823  QColor svgFillColor() const { return color(); }
824 
825  void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; }
826  QColor svgOutlineColor() const { return mSvgOutlineColor; }
827  void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; }
828  double svgOutlineWidth() const { return mSvgOutlineWidth; }
829 
830  void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit ) { mPatternWidthUnit = unit; }
831  QgsSymbolV2::OutputUnit patternWidthUnit() const { return mPatternWidthUnit; }
832 
833  void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale ) { mPatternWidthMapUnitScale = scale; }
834  const QgsMapUnitScale& patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
835 
836  void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSvgOutlineWidthUnit = unit; }
837  QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const { return mSvgOutlineWidthUnit; }
838 
839  void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSvgOutlineWidthMapUnitScale = scale; }
840  const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const { return mSvgOutlineWidthMapUnitScale; }
841 
842  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
843  QgsSymbolV2::OutputUnit outputUnit() const override;
844 
845  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
846  QgsMapUnitScale mapUnitScale() const override;
847 
848  protected:
853 
862 
863  //param(fill), param(outline), param(outline-width) are going
864  //to be replaced in memory
869 
870  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
871 
872  private:
874  void storeViewBox();
875  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath
876 
878  void applyPattern( QBrush& brush, const QString& svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor& svgFillColor, const QColor& svgOutlineColor,
879  double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext& context, const QgsMapUnitScale& patternWidthMapUnitScale, const QgsMapUnitScale &svgOutlineWidthMapUnitScale );
880 };
881 
886 {
887  public:
890 
891  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
892  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
893 
894  QString layerType() const override;
895 
896  void startRender( QgsSymbolV2RenderContext& context ) override;
897 
898  void stopRender( QgsSymbolV2RenderContext& context ) override;
899 
900  QgsStringMap properties() const override;
901 
902  QgsLinePatternFillSymbolLayer* clone() const override;
903 
905  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
906 
907  double estimateMaxBleed() const override;
908 
909  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
910 
911  //getters and setters
912  void setLineAngle( double a ) { mLineAngle = a; }
913  double lineAngle() const { return mLineAngle; }
914  void setDistance( double d ) { mDistance = d; }
915  double distance() const { return mDistance; }
916  void setLineWidth( double w );
917  double lineWidth() const { return mLineWidth; }
918  void setColor( const QColor& c ) override;
919  QColor color() const override;
920  void setOffset( double offset ) { mOffset = offset; }
921  double offset() const { return mOffset; }
922 
923  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
924  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
925 
926  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
927  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
928 
929  void setLineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mLineWidthUnit = unit; }
930  QgsSymbolV2::OutputUnit lineWidthUnit() const { return mLineWidthUnit; }
931 
932  void setLineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mLineWidthMapUnitScale = scale; }
933  const QgsMapUnitScale& lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
934 
935  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
936  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
937 
938  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
939  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
940 
941  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
942  QgsSymbolV2::OutputUnit outputUnit() const override;
943 
944  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
945  QgsMapUnitScale mapUnitScale() const override;
946 
947  bool setSubSymbol( QgsSymbolV2* symbol ) override;
948  QgsSymbolV2* subSymbol() override;
949 
950  QSet<QString> usedAttributes() const override;
951 
952  protected:
954  double mDistance;
958  double mLineWidth;
963  double mLineAngle;
965  double mOffset;
968 
969  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
970 
971  private:
973  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
974 
976  QgsLineSymbolV2* mFillLineSymbol;
977 };
978 
983 {
984  public:
987 
988  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
989  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
990 
991  QString layerType() const override;
992 
993  void startRender( QgsSymbolV2RenderContext& context ) override;
994 
995  void stopRender( QgsSymbolV2RenderContext& context ) override;
996 
997  QgsStringMap properties() const override;
998 
999  QgsPointPatternFillSymbolLayer* clone() const override;
1000 
1002  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
1003 
1004  double estimateMaxBleed() const override;
1005 
1006  //getters and setters
1007  double distanceX() const { return mDistanceX; }
1008  void setDistanceX( double d ) { mDistanceX = d; }
1009 
1010  double distanceY() const { return mDistanceY; }
1011  void setDistanceY( double d ) { mDistanceY = d; }
1012 
1013  double displacementX() const { return mDisplacementX; }
1014  void setDisplacementX( double d ) { mDisplacementX = d; }
1015 
1016  double displacementY() const { return mDisplacementY; }
1017  void setDisplacementY( double d ) { mDisplacementY = d; }
1018 
1019  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1020  virtual QgsSymbolV2* subSymbol() override { return mMarkerSymbol; }
1021 
1022  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
1023  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
1024 
1025  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
1026  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1027 
1028  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
1029  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
1030 
1031  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
1032  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1033 
1034  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
1035  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
1036 
1037  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
1038  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1039 
1040  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
1041  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
1042 
1043  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
1044  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1045 
1046  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1047  QgsSymbolV2::OutputUnit outputUnit() const override;
1048 
1049  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1050  QgsMapUnitScale mapUnitScale() const override;
1051 
1052  virtual QSet<QString> usedAttributes() const override;
1053  void setColor( const QColor& c ) override;
1054  virtual QColor color() const override;
1055 
1056  protected:
1058  double mDistanceX;
1061  double mDistanceY;
1070 
1071  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
1072 
1073  private:
1074  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
1075  double displacementX, double displacementY );
1076 };
1077 
1082 {
1083  public:
1086 
1087  // static stuff
1088 
1089  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
1090  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
1091 
1092  // implemented from base classes
1093 
1094  QString layerType() const override;
1095 
1096  void startRender( QgsSymbolV2RenderContext& context ) override;
1097 
1098  void stopRender( QgsSymbolV2RenderContext& context ) override;
1099 
1100  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
1101 
1102  QgsStringMap properties() const override;
1103 
1104  QgsCentroidFillSymbolLayerV2* clone() const override;
1105 
1107  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
1108 
1109  void setColor( const QColor& color ) override;
1110  QColor color() const override;
1111 
1112  QgsSymbolV2* subSymbol() override;
1113  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1114 
1115  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1116  QgsSymbolV2::OutputUnit outputUnit() const override;
1117 
1118  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1119  QgsMapUnitScale mapUnitScale() const override;
1120 
1121  virtual QSet<QString> usedAttributes() const override;
1122 
1123  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
1124  bool pointOnSurface() const { return mPointOnSurface; }
1125 
1128  void setPointOnAllParts( bool pointOnAllParts ) { mPointOnAllParts = pointOnAllParts; }
1131  bool pointOnAllParts() const { return mPointOnAllParts; }
1132 
1133  protected:
1137 
1140 };
1141 
1142 #endif
1143 
1144 
QgsMapUnitScale mSvgOutlineWidthMapUnitScale
void setBorderWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsVectorColorRampV2 * colorRamp()
Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp...
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit offsetUnit() const
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon&#39;s boundary...
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon&#39;s boundary.
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
QgsVectorColorRampV2 * colorRamp()
Returns the color ramp used for the shapeburst fill.
virtual Qt::BrushStyle dxfBrushStyle() const
get brush/fill style
const QgsMapUnitScale & displacementYMapUnitScale() const
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
QgsSymbolV2::OutputUnit mSvgOutlineWidthUnit
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
void setSvgOutlineWidth(double w)
const QgsMapUnitScale & borderWidthMapUnitScale() const
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
virtual void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit mOffsetUnit
FillCoordinateMode mCoordinateMode
virtual QgsSymbolLayerV2 * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolV2::OutputUnit mLineWidthUnit
QSet< QString > usedAttributes() const override
Returns the set of attributes referenced by the layer.
void setCoordinateMode(GradientCoordinateMode coordinateMode)
virtual Qt::PenStyle dxfPenStyle() const
get pen style
const QgsMapUnitScale & lineWidthMapUnitScale() const
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon&#39;s boundary...
const QgsMapUnitScale & displacementXMapUnitScale() const
virtual QColor dxfColor(QgsSymbolV2RenderContext &context) const
get color
void setDistanceYUnit(QgsSymbolV2::OutputUnit unit)
QString imageFilePath() const
The path to the raster image used for the fill.
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
Qt::BrushStyle brushStyle() const
virtual QgsMapUnitScale mapUnitScale() const
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient.
GradientType gradientType() const
Type of gradient, eg linear or radial.
Base class for polygon renderers generating texture images.
QgsMapUnitScale mPatternWidthMapUnitScale
GradientCoordinateMode mCoordinateMode
void setPointOnSurface(bool pointOnSurface)
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
QgsSymbolV2::OutputUnit widthUnit() const
Returns the units for the image&#39;s width.
QPointF offset() const
Returns the offset for the shapeburst fill.
virtual QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const
get brush/fill color
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mOutlineWidthMapUnitScale
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)=0
QgsSymbolV2::OutputUnit mWidthUnit
QgsSymbolV2::OutputUnit mDisplacementXUnit
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
double mDistance
Distance (in mm or map units) between lines.
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features...
double mLineAngle
Vector line angle in degrees (0 = horizontal, counterclockwise)
QgsSymbolV2::OutputUnit borderWidthUnit() const
QgsVectorColorRampV2 * mGradientRamp
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QMap< QString, QString > QgsStringMap
Definition: qgis.h:492
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const
void setPatternWidth(double width)
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the SLD element following the SLD v1.1 specs.
QgsMapUnitScale mapUnitScale() const override
QgsSymbolV2::OutputUnit outputUnit() const override
void setSvgOutlineColor(const QColor &c)
virtual void startRender(QgsSymbolV2RenderContext &context)=0
const QgsMapUnitScale & offsetMapUnitScale() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
virtual QgsSymbolV2::OutputUnit outputUnit() const
void setGradientType(GradientType gradientType)
const QgsMapUnitScale & offsetMapUnitScale() const
QString mImageFilePath
Path to the image file.
QgsSymbolV2::OutputUnit mDisplacementYUnit
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
GradientSpread gradientSpread() const
Gradient spread mode.
QgsSymbolV2::OutputUnit distanceXUnit() const
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
A class for filling symbols with a repeated raster image.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
QByteArray mSvgData
SVG data.
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsLineSymbolV2 * mOutline
Custom outline.
#define DEFAULT_SIMPLEFILL_STYLE
QgsSymbolV2::OutputUnit patternWidthUnit() const
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
double mOffset
Offset perpendicular to line direction.
void setPenJoinStyle(Qt::PenJoinStyle style)
void setBrushStyle(Qt::BrushStyle style)
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
QgsVectorColorRampV2 * mTwoColorGradientRamp
void setLineWidthUnit(QgsSymbolV2::OutputUnit unit)
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
QColor outlineColor() const override
Get outline color.
virtual double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image&#39;s width.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill&#39;s offset.
QgsSymbolV2::OutputUnit distanceYUnit() const
const QgsMapUnitScale & outlineWidthMapUnitScale() const
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
double alpha() const
The opacity for the raster image used in the fill.
QgsSymbolV2::OutputUnit mOffsetUnit
virtual QgsSymbolV2 * subSymbol() override
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context) override
void setOutlineColor(const QColor &color) override
Set outline color.
void setFillColor(const QColor &color) override
Set fill color.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
const QgsMapUnitScale & svgOutlineWidthMapUnitScale() const
void setDisplacementXUnit(QgsSymbolV2::OutputUnit unit)
virtual bool setSubSymbol(QgsSymbolV2 *symbol) override
set layer&#39;s subsymbol. takes ownership of the passed symbol
QgsSymbolV2::OutputUnit mOffsetUnit
virtual QColor color() const
The fill color.
void setBorderWidthUnit(QgsSymbolV2::OutputUnit unit)
double maxDistance() const
Returns the maximum distance from the shape&#39;s boundary which is shaded.
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit mOffsetUnit
void setOffset(QPointF offset)
Sets the offset for the fill.
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
QString mSvgFilePath
Path to the svg file (or empty if constructed directly from data)
const QgsMapUnitScale & distanceMapUnitScale() const
QgsSymbolV2::OutputUnit mOffsetUnit
QgsSymbolV2::OutputUnit mOutlineWidthUnit
double mOutlineWidth
Outline width.
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void setColorType(ShapeburstColorType colorType)
Sets the color mode to use for the shapeburst fill.
void setDistanceXUnit(QgsSymbolV2::OutputUnit unit)
double mLineWidth
Line width (in mm or map units)
QgsVectorColorRampV2 * mGradientRamp
QgsSymbolV2::OutputUnit displacementXUnit() const
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features...
void setOffset(QPointF offset)
Offset for gradient fill.
virtual QString layerType() const =0
Returns a string that represents this layer type.
void setBorderColor(const QColor &borderColor)
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units used for the offset for the shapeburst fill.
QgsSymbolV2::OutputUnit mDistanceYUnit
virtual QgsSymbolV2 * subSymbol()
void setOffset(QPointF offset)
const QgsMapUnitScale & distanceMapUnitScale() const
A class for svg fill patterns.
QgsSymbolV2::OutputUnit lineWidthUnit() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill&#39;s offset.
void setGradientColorType(GradientColorType gradientColorType)
QgsMapUnitScale mBorderWidthMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
QgsSymbolV2::OutputUnit mDistanceXUnit
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & distanceXMapUnitScale() const
const QgsMapUnitScale & patternWidthMapUnitScale() const
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
get line width
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
QgsSymbolV2::OutputUnit mBorderWidthUnit
QgsSymbolV2::OutputUnit offsetUnit() const
const QgsMapUnitScale & distanceYMapUnitScale() const
QgsSymbolV2::OutputUnit mDistanceUnit
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image&#39;s width.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit offsetUnit() const
qint64 QgsFeatureId
Definition: qgsfeature.h:31
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units for the fill&#39;s offset.
virtual void setColor(const QColor &color)
The fill color.
virtual double dxfAngle(QgsSymbolV2RenderContext &context) const
get angle
QgsSymbolV2::OutputUnit mDistanceUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setColor2(const QColor &color2)
const QgsMapUnitScale & offsetMapUnitScale() const
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
void setWidthUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the image&#39;s width.
void setGradientSpread(GradientSpread gradientSpread)
QgsSymbolV2::OutputUnit mPatternWidthUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenStyle borderStyle() const
virtual QgsSymbolV2 * subSymbol() override
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
QgsSymbolV2::OutputUnit displacementYUnit() const
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
QgsSymbolV2::OutputUnit distanceUnit() const
Abstract base class for color ramps.
void setBorderWidth(double borderWidth)
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
#define DEFAULT_SIMPLEFILL_JOINSTYLE
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
set layer&#39;s subsymbol. takes ownership of the passed symbol
double width() const
Returns the width used for scaling the image used in the fill.
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
Qt::PenJoinStyle penJoinStyle() const
QColor fillColor() const override
Get fill color.
void setOffsetUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the fill&#39;s offset.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
virtual void applyDataDefinedSettings(QgsSymbolV2RenderContext &context)
const QgsMapUnitScale & offsetMapUnitScale() const
virtual QgsSymbolV2 * subSymbol() override
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Units for gradient fill offset.
QRectF mSvgViewBox
SVG view box (to keep the aspect ratio.
QImage * mSvgPattern
SVG pattern image.
void setSvgOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
QPointF offset() const
Returns the offset for the fill.
double mPatternWidth
Width of the pattern (in output units)
QgsSymbolV2::OutputUnit outlineWidthUnit() const
#define DEFAULT_SIMPLEFILL_COLOR
void setBorderStyle(Qt::PenStyle borderStyle)