QGIS API Documentation  2.13.0-Master
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 
34 {
35  public:
37  Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE,
38  const QColor& borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
39  Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
40  double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH,
41  Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEFILL_JOINSTYLE
42  );
43 
44  // static stuff
45 
46  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
47  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
48 
49  // implemented from base classes
50 
51  QString layerType() const override;
52 
53  void startRender( QgsSymbolV2RenderContext& context ) override;
54 
55  void stopRender( QgsSymbolV2RenderContext& context ) override;
56 
57  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
58 
59  QgsStringMap properties() const override;
60 
61  QgsSimpleFillSymbolLayerV2* clone() const override;
62 
63  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
64 
65  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
66 
67  Qt::BrushStyle brushStyle() const { return mBrushStyle; }
68  void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; }
69 
70  QColor borderColor() const { return mBorderColor; }
71  void setBorderColor( const QColor& borderColor ) { mBorderColor = borderColor; }
72 
75  QColor outlineColor() const override { return borderColor(); }
78  void setOutlineColor( const QColor& color ) override { setBorderColor( color ); }
79 
82  QColor fillColor() const override { return color(); }
85  void setFillColor( const QColor& color ) override { setColor( color ); }
86 
87  Qt::PenStyle borderStyle() const { return mBorderStyle; }
88  void setBorderStyle( Qt::PenStyle borderStyle ) { mBorderStyle = borderStyle; }
89 
90  double borderWidth() const { return mBorderWidth; }
91  void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; }
92 
93  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
94  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
95 
96  void setOffset( QPointF offset ) { mOffset = offset; }
97  QPointF offset() { return mOffset; }
98 
99  void setBorderWidthUnit( QgsSymbolV2::OutputUnit unit ) { mBorderWidthUnit = unit; }
100  QgsSymbolV2::OutputUnit borderWidthUnit() const { return mBorderWidthUnit; }
101 
102  void setBorderWidthMapUnitScale( const QgsMapUnitScale& scale ) { mBorderWidthMapUnitScale = scale; }
103  const QgsMapUnitScale& borderWidthMapUnitScale() const { return mBorderWidthMapUnitScale; }
104 
105  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
106  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
107 
108  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
109  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
110 
111  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
112  QgsSymbolV2::OutputUnit outputUnit() const override;
113 
114  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
115  QgsMapUnitScale mapUnitScale() const override;
116 
117  double estimateMaxBleed() const override;
118 
119  double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
120  QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
121  Qt::PenStyle dxfPenStyle() const override;
122  QColor dxfBrushColor( QgsSymbolV2RenderContext &context ) const override;
123  Qt::BrushStyle dxfBrushStyle() const override;
124 
125  protected:
128  Qt::BrushStyle mBrushStyle;
130  Qt::PenStyle mBorderStyle;
131  double mBorderWidth;
134  Qt::PenJoinStyle mPenJoinStyle;
137 
141 
142  private:
143  //helper functions for data defined symbology
144  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QBrush& brush, QPen& pen, QPen& selPen );
145 };
146 
148 
150 {
151  public:
152 
154  {
156  ColorRamp
157  };
158 
160  {
163  Conical
164  };
165 
167  {
169  Viewport
170  };
171 
173  {
176  Repeat
177  };
178 
180  const QColor& color2 = Qt::white,
181  GradientColorType gradientColorType = SimpleTwoColor,
182  GradientType gradientType = Linear,
183  GradientCoordinateMode coordinateMode = Feature,
184  GradientSpread gradientSpread = Pad
185  );
186 
187  virtual ~QgsGradientFillSymbolLayerV2();
188 
189  // static stuff
190 
191  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
192 
193  // implemented from base classes
194 
195  QString layerType() const override;
196 
197  void startRender( QgsSymbolV2RenderContext& context ) override;
198 
199  void stopRender( QgsSymbolV2RenderContext& context ) override;
200 
201  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
202 
203  QgsStringMap properties() const override;
204 
205  QgsGradientFillSymbolLayerV2* clone() const override;
206 
207  double estimateMaxBleed() const override;
208 
210  GradientType gradientType() const { return mGradientType; }
211  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
212 
214  GradientColorType gradientColorType() const { return mGradientColorType; }
215  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
216 
218  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
219  void setColorRamp( QgsVectorColorRampV2* ramp );
220 
222  QColor color2() const { return mColor2; }
223  void setColor2( const QColor& color2 ) { mColor2 = color2; }
224 
226  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
227  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
228 
230  GradientSpread gradientSpread() const { return mGradientSpread; }
231  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
232 
234  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
235  QPointF referencePoint1() const { return mReferencePoint1; }
236 
238  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
239  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
240 
242  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
243  QPointF referencePoint2() const { return mReferencePoint2; }
244 
246  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
247  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
248 
250  void setOffset( QPointF offset ) { mOffset = offset; }
251  QPointF offset() const { return mOffset; }
252 
254  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
255  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
256 
257  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
258  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
259 
260  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
261  QgsSymbolV2::OutputUnit outputUnit() const override;
262 
263  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
264  QgsMapUnitScale mapUnitScale() const override;
265 
266  protected:
269 
276 
281 
285 
286  private:
287 
288  //helper functions for data defined symbology
289  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, const QPolygonF& points );
290 
292  void applyGradient( const QgsSymbolV2RenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
293  GradientColorType gradientColorType, QgsVectorColorRampV2 *gradientRamp, GradientType gradientType,
294  GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
295  QPointF referencePoint1, QPointF referencePoint2, const double angle );
296 
298  QPointF rotateReferencePoint( QPointF refPoint, double angle );
299 };
300 
302 {
303  public:
304 
306  {
308  ColorRamp
309  };
310 
311  QgsShapeburstFillSymbolLayerV2( const QColor& color = DEFAULT_SIMPLEFILL_COLOR, const QColor& color2 = Qt::white,
312  ShapeburstColorType colorType = SimpleTwoColor,
313  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
314 
316 
317  // static stuff
318 
319  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
320 
321  // implemented from base classes
322 
323  QString layerType() const override;
324 
325  void startRender( QgsSymbolV2RenderContext& context ) override;
326 
327  void stopRender( QgsSymbolV2RenderContext& context ) override;
328 
329  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
330 
331  QgsStringMap properties() const override;
332 
333  QgsShapeburstFillSymbolLayerV2* clone() const override;
334 
335  double estimateMaxBleed() const override;
336 
342  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
348  int blurRadius() const { return mBlurRadius; }
349 
357  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
364  bool useWholeShape() const { return mUseWholeShape; }
365 
373  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
381  double maxDistance() const { return mMaxDistance; }
382 
389  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
396  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
397 
398  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
399  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
400 
410  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
420  ShapeburstColorType colorType() const { return mColorType; }
421 
428  void setColorRamp( QgsVectorColorRampV2* ramp );
435  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
436 
443  void setColor2( const QColor& color2 ) { mColor2 = color2; }
450  QColor color2() const { return mColor2; }
451 
458  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
464  bool ignoreRings() const { return mIgnoreRings; }
465 
472  void setOffset( QPointF offset ) { mOffset = offset; }
479  QPointF offset() const { return mOffset; }
480 
487  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
494  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
495 
496  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
497  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
498 
499  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
500  QgsSymbolV2::OutputUnit outputUnit() const override;
501 
502  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
503  QgsMapUnitScale mapUnitScale() const override;
504 
505  protected:
508 
510 
512  double mMaxDistance;
515 
520 
522 
526 
527  private:
528 
529  //helper functions for data defined symbology
530  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int& blurRadius, bool& useWholeShape,
531  double& maxDistance, bool &ignoreRings );
532 
533  /* distance transform of a 1d function using squared distance */
534  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
535  /* distance transform of 2d function using squared distance */
536  void distanceTransform2d( double * im, int width, int height );
537  /* distance transform of a binary QImage */
538  double * distanceTransform( QImage * im );
539 
540  /* fills a QImage with values from an array of doubles containing squared distance transform values */
541  void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRampV2* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
542 };
543 
546 {
547  public:
548 
550  virtual ~QgsImageFillSymbolLayer();
551  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
552 
553  virtual QgsSymbolV2* subSymbol() override { return mOutline; }
554  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
555 
556  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
557  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
558 
559  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
560  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
561 
562  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
563  QgsSymbolV2::OutputUnit outputUnit() const override;
564 
565  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
566  QgsMapUnitScale mapUnitScale() const override;
567 
568  virtual double estimateMaxBleed() const override;
569 
570  virtual double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
571  virtual QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
572  virtual Qt::PenStyle dxfPenStyle() const override;
573 
574  QSet<QString> usedAttributes() const override;
575 
576  protected:
578  double mNextAngle; // mAngle / data defined angle
579 
584 
587 
588  virtual void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) { Q_UNUSED( context ); }
589 };
590 
597 {
598  public:
599 
601  {
603  Viewport
604  };
605 
606  QgsRasterFillSymbolLayer( const QString& imageFilePath = QString() );
608 
609  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
610 
611  // implemented from base classes
612  QString layerType() const override;
613  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
614  void startRender( QgsSymbolV2RenderContext& context ) override;
615  void stopRender( QgsSymbolV2RenderContext& context ) override;
616  QgsStringMap properties() const override;
617  QgsRasterFillSymbolLayer* clone() const override;
618  virtual double estimateMaxBleed() const override;
619 
620  //override QgsImageFillSymbolLayer's support for sub symbols
621  virtual QgsSymbolV2* subSymbol() override { return nullptr; }
622  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
623 
628  void setImageFilePath( const QString& imagePath );
633  QString imageFilePath() const { return mImageFilePath; }
634 
640  void setCoordinateMode( const FillCoordinateMode mode );
646  FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
647 
652  void setAlpha( const double alpha );
657  double alpha() const { return mAlpha; }
658 
665  void setOffset( QPointF offset ) { mOffset = offset; }
672  QPointF offset() const { return mOffset; }
673 
680  void setOffsetUnit( const QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
687  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
688 
695  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
702  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
703 
711  void setWidth( const double width ) { mWidth = width; }
719  double width() const { return mWidth; }
720 
727  void setWidthUnit( const QgsSymbolV2::OutputUnit unit ) { mWidthUnit = unit; }
734  QgsSymbolV2::OutputUnit widthUnit() const { return mWidthUnit; }
735 
742  void setWidthMapUnitScale( const QgsMapUnitScale& scale ) { mWidthMapUnitScale = scale; }
749  const QgsMapUnitScale& widthMapUnitScale() const { return mWidthMapUnitScale; }
750 
751  protected:
752 
756  double mAlpha;
757 
761 
762  double mWidth;
765 
766  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
767 
768  private:
769 
771  void applyPattern( QBrush& brush, const QString& imageFilePath, const double width, const double alpha,
772  const QgsSymbolV2RenderContext& context );
773 };
774 
778 {
779  public:
780  QgsSVGFillSymbolLayer( const QString& svgFilePath = "", double width = 20, double rotation = 0.0 );
781  QgsSVGFillSymbolLayer( const QByteArray& svgData, double width = 20, double rotation = 0.0 );
783 
784  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
785  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
786 
787  // implemented from base classes
788 
789  QString layerType() const override;
790 
791  void startRender( QgsSymbolV2RenderContext& context ) override;
792  void stopRender( QgsSymbolV2RenderContext& context ) override;
793 
794  QgsStringMap properties() const override;
795 
796  QgsSVGFillSymbolLayer* clone() const override;
797 
798  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
799 
800  //getters and setters
801  void setSvgFilePath( const QString& svgPath );
802  QString svgFilePath() const { return mSvgFilePath; }
803  void setPatternWidth( double width ) { mPatternWidth = width;}
804  double patternWidth() const { return mPatternWidth; }
805 
806  void setSvgFillColor( const QColor& c ) { setColor( c ); }
807  QColor svgFillColor() const { return color(); }
808 
809  void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; }
810  QColor svgOutlineColor() const { return mSvgOutlineColor; }
811  void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; }
812  double svgOutlineWidth() const { return mSvgOutlineWidth; }
813 
814  void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit ) { mPatternWidthUnit = unit; }
815  QgsSymbolV2::OutputUnit patternWidthUnit() const { return mPatternWidthUnit; }
816 
817  void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale ) { mPatternWidthMapUnitScale = scale; }
818  const QgsMapUnitScale& patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
819 
820  void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSvgOutlineWidthUnit = unit; }
821  QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const { return mSvgOutlineWidthUnit; }
822 
823  void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSvgOutlineWidthMapUnitScale = scale; }
824  const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const { return mSvgOutlineWidthMapUnitScale; }
825 
826  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
827  QgsSymbolV2::OutputUnit outputUnit() const override;
828 
829  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
830  QgsMapUnitScale mapUnitScale() const override;
831 
832  protected:
837 
846 
847  //param(fill), param(outline), param(outline-width) are going
848  //to be replaced in memory
853 
854  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
855 
856  private:
858  void storeViewBox();
859  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath
860 
862  void applyPattern( QBrush& brush, const QString& svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor& svgFillColor, const QColor& svgOutlineColor,
863  double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext& context, const QgsMapUnitScale& patternWidthMapUnitScale, const QgsMapUnitScale &svgOutlineWidthMapUnitScale );
864 };
865 
867 {
868  public:
871 
872  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
873  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
874 
875  QString layerType() const override;
876 
877  void startRender( QgsSymbolV2RenderContext& context ) override;
878 
879  void stopRender( QgsSymbolV2RenderContext& context ) override;
880 
881  QgsStringMap properties() const override;
882 
883  QgsLinePatternFillSymbolLayer* clone() const override;
884 
885  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
886 
887  double estimateMaxBleed() const override;
888 
889  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
890 
891  //getters and setters
892  void setLineAngle( double a ) { mLineAngle = a; }
893  double lineAngle() const { return mLineAngle; }
894  void setDistance( double d ) { mDistance = d; }
895  double distance() const { return mDistance; }
896  void setLineWidth( double w );
897  double lineWidth() const { return mLineWidth; }
898  void setColor( const QColor& c ) override;
899  QColor color() const override { return mColor; }
900  void setOffset( double offset ) { mOffset = offset; }
901  double offset() const { return mOffset; }
902 
903  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
904  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
905 
906  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
907  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
908 
909  void setLineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mLineWidthUnit = unit; }
910  QgsSymbolV2::OutputUnit lineWidthUnit() const { return mLineWidthUnit; }
911 
912  void setLineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mLineWidthMapUnitScale = scale; }
913  const QgsMapUnitScale& lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
914 
915  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
916  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
917 
918  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
919  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
920 
921  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
922  QgsSymbolV2::OutputUnit outputUnit() const override;
923 
924  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
925  QgsMapUnitScale mapUnitScale() const override;
926 
927  bool setSubSymbol( QgsSymbolV2* symbol ) override;
928  QgsSymbolV2* subSymbol() override;
929 
930  QSet<QString> usedAttributes() const override;
931 
932  protected:
934  double mDistance;
938  double mLineWidth;
943  double mLineAngle;
945  double mOffset;
948 
949  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
950 
951  private:
953  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
954 
956  QgsLineSymbolV2* mFillLineSymbol;
957 };
958 
960 {
961  public:
964 
965  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
966  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
967 
968  QString layerType() const override;
969 
970  void startRender( QgsSymbolV2RenderContext& context ) override;
971 
972  void stopRender( QgsSymbolV2RenderContext& context ) override;
973 
974  QgsStringMap properties() const override;
975 
976  QgsPointPatternFillSymbolLayer* clone() const override;
977 
978  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
979 
980  double estimateMaxBleed() const override;
981 
982  //getters and setters
983  double distanceX() const { return mDistanceX; }
984  void setDistanceX( double d ) { mDistanceX = d; }
985 
986  double distanceY() const { return mDistanceY; }
987  void setDistanceY( double d ) { mDistanceY = d; }
988 
989  double displacementX() const { return mDisplacementX; }
990  void setDisplacementX( double d ) { mDisplacementX = d; }
991 
992  double displacementY() const { return mDisplacementY; }
993  void setDisplacementY( double d ) { mDisplacementY = d; }
994 
995  bool setSubSymbol( QgsSymbolV2* symbol ) override;
996  virtual QgsSymbolV2* subSymbol() override { return mMarkerSymbol; }
997 
998  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
999  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
1000 
1001  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
1002  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1003 
1004  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
1005  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
1006 
1007  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
1008  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1009 
1010  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
1011  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
1012 
1013  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
1014  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1015 
1016  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
1017  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
1018 
1019  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
1020  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1021 
1022  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1023  QgsSymbolV2::OutputUnit outputUnit() const override;
1024 
1025  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1026  QgsMapUnitScale mapUnitScale() const override;
1027 
1028  virtual QSet<QString> usedAttributes() const override;
1029 
1030  protected:
1032  double mDistanceX;
1035  double mDistanceY;
1044 
1045  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
1046 
1047  private:
1048  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
1049  double displacementX, double displacementY );
1050 };
1051 
1053 {
1054  public:
1057 
1058  // static stuff
1059 
1060  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
1061  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
1062 
1063  // implemented from base classes
1064 
1065  QString layerType() const override;
1066 
1067  void startRender( QgsSymbolV2RenderContext& context ) override;
1068 
1069  void stopRender( QgsSymbolV2RenderContext& context ) override;
1070 
1071  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
1072 
1073  QgsStringMap properties() const override;
1074 
1075  QgsCentroidFillSymbolLayerV2* clone() const override;
1076 
1077  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
1078 
1079  void setColor( const QColor& color ) override;
1080 
1081  QgsSymbolV2* subSymbol() override;
1082  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1083 
1084  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1085  QgsSymbolV2::OutputUnit outputUnit() const override;
1086 
1087  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1088  QgsMapUnitScale mapUnitScale() const override;
1089 
1090  virtual QSet<QString> usedAttributes() const override;
1091 
1092  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
1093  bool pointOnSurface() const { return mPointOnSurface; }
1094 
1095  protected:
1098 };
1099 
1100 #endif
1101 
1102 
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
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)
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
QgsSymbolV2::OutputUnit patternWidthUnit() 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.
const QgsMapUnitScale & patternWidthMapUnitScale() const
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
QgsVectorColorRampV2 * colorRamp()
Returns the color ramp used for the shapeburst fill.
QgsSymbolV2::OutputUnit distanceYUnit() const
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)
virtual QgsSymbolV2::OutputUnit outputUnit() const
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:59
const QgsMapUnitScale & displacementXMapUnitScale() const
virtual void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit mOffsetUnit
virtual Qt::PenStyle dxfPenStyle() const
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)
const QgsMapUnitScale & lineWidthMapUnitScale() const
QgsSymbolV2::OutputUnit distanceXUnit() const
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit offsetUnit() const
void setDistanceYUnit(QgsSymbolV2::OutputUnit unit)
QString svgFilePath() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
double svgOutlineWidth() const
Base class for polygon renderers generating texture images.
QgsMapUnitScale mPatternWidthMapUnitScale
GradientCoordinateMode mCoordinateMode
void setPointOnSurface(bool pointOnSurface)
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image&#39;s width.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mOutlineWidthMapUnitScale
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient.
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)=0
QgsSymbolV2::OutputUnit mWidthUnit
QgsSymbolV2::OutputUnit mDisplacementXUnit
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
double mDistance
Distance (in mm or map units) between lines.
const QgsMapUnitScale & outlineWidthMapUnitScale() const
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
double mLineAngle
Vector line angle in degrees (0 = horizontal, counterclockwise)
const QgsMapUnitScale & borderWidthMapUnitScale() const
QColor color() const override
The fill color.
QgsVectorColorRampV2 * mGradientRamp
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QMap< QString, QString > QgsStringMap
Definition: qgis.h:384
void setPatternWidth(double width)
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
QgsMapUnitScale mapUnitScale() const override
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
QgsSymbolV2::OutputUnit outputUnit() const override
void setSvgOutlineColor(const QColor &c)
virtual void startRender(QgsSymbolV2RenderContext &context)=0
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
void setGradientType(GradientType gradientType)
QgsSymbolV2::OutputUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon&#39;s boundary...
QString mImageFilePath
Path to the image file.
QgsSymbolV2::OutputUnit mDisplacementYUnit
#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.
Qt::PenStyle borderStyle() const
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsLineSymbolV2 * mOutline
Custom outline.
#define DEFAULT_SIMPLEFILL_STYLE
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
double mOffset
Offset perpendicular to line direction.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill&#39;s offset.
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.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
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...
const QgsMapUnitScale & offsetMapUnitScale() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image&#39;s width.
QPointF offset() const
Returns the offset for the shapeburst fill.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & distanceXMapUnitScale() const
QString imageFilePath() const
The path to the raster image used for the fill.
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit mOffsetUnit
QgsSymbolV2::OutputUnit distanceUnit() const
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
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.
QgsSymbolV2::OutputUnit borderWidthUnit() const
virtual QColor color() const
The fill color.
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
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
void setBorderWidthUnit(QgsSymbolV2::OutputUnit unit)
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 & displacementYMapUnitScale() 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
QColor svgOutlineColor() const
GradientSpread gradientSpread() const
Gradient spread mode.
const QgsMapUnitScale & distanceMapUnitScale() const
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
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 & offsetMapUnitScale() const
QgsSymbolV2::OutputUnit lineWidthUnit() const
A class for svg fill patterns.
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units for the fill&#39;s offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill&#39;s offset.
virtual Qt::BrushStyle dxfBrushStyle() const
const QgsMapUnitScale & distanceMapUnitScale() const
void setGradientColorType(GradientColorType gradientColorType)
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
virtual QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const
QgsMapUnitScale mBorderWidthMapUnitScale
QPointF offset() const
Returns the offset for the fill.
Struct for storing maximum and minimum scales for measurements in map units.
QgsSymbolV2::OutputUnit mDistanceXUnit
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & distanceYMapUnitScale() const
QgsSymbolV2::OutputUnit displacementYUnit() const
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
QgsSymbolV2::OutputUnit mBorderWidthUnit
Qt::PenJoinStyle penJoinStyle() const
virtual QColor dxfColor(QgsSymbolV2RenderContext &context) const
const QgsMapUnitScale & offsetMapUnitScale() const
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
QgsSymbolV2::OutputUnit mDistanceUnit
virtual QgsMapUnitScale mapUnitScale() const
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
virtual void setColor(const QColor &color)
The fill color.
GradientType gradientType() const
Type of gradient, eg linear or radial.
QgsSymbolV2::OutputUnit outlineWidthUnit() const
QgsSymbolV2::OutputUnit mDistanceUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setColor2(const QColor &color2)
QgsSymbolV2::OutputUnit widthUnit() const
Returns the units for the image&#39;s width.
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
void setWidthUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the image&#39;s width.
QgsSymbolV2::OutputUnit displacementXUnit() const
void setGradientSpread(GradientSpread gradientSpread)
double width() const
Returns the width used for scaling the image used in the fill.
QgsSymbolV2::OutputUnit mPatternWidthUnit
QgsSymbolV2::OutputUnit offsetUnit() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
virtual QgsSymbolV2 * subSymbol() override
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
const QgsMapUnitScale & offsetMapUnitScale() const
void setBorderWidth(double borderWidth)
const QgsMapUnitScale & svgOutlineWidthMapUnitScale() const
#define DEFAULT_SIMPLEFILL_JOINSTYLE
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
set layer&#39;s subsymbol. takes ownership of the passed symbol
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
Qt::BrushStyle brushStyle() 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 void applyDataDefinedSettings(QgsSymbolV2RenderContext &context)
virtual QgsSymbolV2 * subSymbol() override
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Units for gradient fill offset.
QgsSymbolV2::OutputUnit offsetUnit() const
QRectF mSvgViewBox
SVG view box (to keep the aspect ratio.
QImage * mSvgPattern
SVG pattern image.
double maxDistance() const
Returns the maximum distance from the shape&#39;s boundary which is shaded.
void setSvgOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
double alpha() const
The opacity for the raster image used in the fill.
double mPatternWidth
Width of the pattern (in output units)
#define DEFAULT_SIMPLEFILL_COLOR
void setBorderStyle(Qt::PenStyle borderStyle)