QGIS API Documentation  2.17.0-Master (6f7b933)
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 
66  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
67 
68  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
69 
70  Qt::BrushStyle brushStyle() const { return mBrushStyle; }
71  void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; }
72 
73  QColor borderColor() const { return mBorderColor; }
74  void setBorderColor( const QColor& borderColor ) { mBorderColor = borderColor; }
75 
78  QColor outlineColor() const override { return borderColor(); }
81  void setOutlineColor( const QColor& color ) override { setBorderColor( color ); }
82 
85  QColor fillColor() const override { return color(); }
88  void setFillColor( const QColor& color ) override { setColor( color ); }
89 
90  Qt::PenStyle borderStyle() const { return mBorderStyle; }
91  void setBorderStyle( Qt::PenStyle borderStyle ) { mBorderStyle = borderStyle; }
92 
93  double borderWidth() const { return mBorderWidth; }
94  void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; }
95 
96  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
97  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
98 
99  void setOffset( QPointF offset ) { mOffset = offset; }
100  QPointF offset() { return mOffset; }
101 
102  void setBorderWidthUnit( QgsSymbolV2::OutputUnit unit ) { mBorderWidthUnit = unit; }
103  QgsSymbolV2::OutputUnit borderWidthUnit() const { return mBorderWidthUnit; }
104 
105  void setBorderWidthMapUnitScale( const QgsMapUnitScale& scale ) { mBorderWidthMapUnitScale = scale; }
106  const QgsMapUnitScale& borderWidthMapUnitScale() const { return mBorderWidthMapUnitScale; }
107 
108  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
109  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
110 
111  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
112  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
113 
114  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
115  QgsSymbolV2::OutputUnit outputUnit() const override;
116 
117  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
118  QgsMapUnitScale mapUnitScale() const override;
119 
120  double estimateMaxBleed() const override;
121 
122  double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
123  QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
124  double dxfAngle( QgsSymbolV2RenderContext& context ) const override;
125 
126  Qt::PenStyle dxfPenStyle() const override;
127  QColor dxfBrushColor( QgsSymbolV2RenderContext &context ) const override;
128  Qt::BrushStyle dxfBrushStyle() const override;
129 
130  protected:
133  Qt::BrushStyle mBrushStyle;
135  Qt::PenStyle mBorderStyle;
136  double mBorderWidth;
139  Qt::PenJoinStyle mPenJoinStyle;
142 
146 
147  private:
148  //helper functions for data defined symbology
149  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QBrush& brush, QPen& pen, QPen& selPen );
150 };
151 
153 
158 {
159  public:
160 
162  {
164  ColorRamp
165  };
166 
168  {
171  Conical
172  };
173 
175  {
177  Viewport
178  };
179 
181  {
184  Repeat
185  };
186 
188  const QColor& color2 = Qt::white,
189  GradientColorType gradientColorType = SimpleTwoColor,
190  GradientType gradientType = Linear,
191  GradientCoordinateMode coordinateMode = Feature,
192  GradientSpread gradientSpread = Pad
193  );
194 
195  virtual ~QgsGradientFillSymbolLayerV2();
196 
197  // static stuff
198 
199  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
200 
201  // implemented from base classes
202 
203  QString layerType() const override;
204 
205  void startRender( QgsSymbolV2RenderContext& context ) override;
206 
207  void stopRender( QgsSymbolV2RenderContext& context ) override;
208 
209  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
210 
211  QgsStringMap properties() const override;
212 
213  QgsGradientFillSymbolLayerV2* clone() const override;
214 
215  double estimateMaxBleed() const override;
216 
218  GradientType gradientType() const { return mGradientType; }
219  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
220 
222  GradientColorType gradientColorType() const { return mGradientColorType; }
223  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
224 
226  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
227  void setColorRamp( QgsVectorColorRampV2* ramp );
228 
230  QColor color2() const { return mColor2; }
231  void setColor2( const QColor& color2 ) { mColor2 = color2; }
232 
234  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
235  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
236 
238  GradientSpread gradientSpread() const { return mGradientSpread; }
239  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
240 
242  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
243  QPointF referencePoint1() const { return mReferencePoint1; }
244 
246  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
247  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
248 
250  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
251  QPointF referencePoint2() const { return mReferencePoint2; }
252 
254  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
255  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
256 
258  void setOffset( QPointF offset ) { mOffset = offset; }
259  QPointF offset() const { return mOffset; }
260 
262  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
263  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
264 
265  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
266  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
267 
268  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
269  QgsSymbolV2::OutputUnit outputUnit() const override;
270 
271  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
272  QgsMapUnitScale mapUnitScale() const override;
273 
274  protected:
277 
284 
289 
293 
294  private:
295 
296  //helper functions for data defined symbology
297  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, const QPolygonF& points );
298 
300  void applyGradient( const QgsSymbolV2RenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
301  GradientColorType gradientColorType, QgsVectorColorRampV2 *gradientRamp, GradientType gradientType,
302  GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
303  QPointF referencePoint1, QPointF referencePoint2, const double angle );
304 
306  QPointF rotateReferencePoint( QPointF refPoint, double angle );
307 };
308 
313 {
314  public:
315 
317  {
319  ColorRamp
320  };
321 
322  QgsShapeburstFillSymbolLayerV2( const QColor& color = DEFAULT_SIMPLEFILL_COLOR, const QColor& color2 = Qt::white,
323  ShapeburstColorType colorType = SimpleTwoColor,
324  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
325 
327 
328  // static stuff
329 
330  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
331 
332  // implemented from base classes
333 
334  QString layerType() const override;
335 
336  void startRender( QgsSymbolV2RenderContext& context ) override;
337 
338  void stopRender( QgsSymbolV2RenderContext& context ) override;
339 
340  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
341 
342  QgsStringMap properties() const override;
343 
344  QgsShapeburstFillSymbolLayerV2* clone() const override;
345 
346  double estimateMaxBleed() const override;
347 
353  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
359  int blurRadius() const { return mBlurRadius; }
360 
368  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
375  bool useWholeShape() const { return mUseWholeShape; }
376 
384  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
392  double maxDistance() const { return mMaxDistance; }
393 
400  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
407  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
408 
409  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
410  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
411 
421  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
431  ShapeburstColorType colorType() const { return mColorType; }
432 
439  void setColorRamp( QgsVectorColorRampV2* ramp );
446  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
447 
454  void setColor2( const QColor& color2 ) { mColor2 = color2; }
461  QColor color2() const { return mColor2; }
462 
469  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
475  bool ignoreRings() const { return mIgnoreRings; }
476 
483  void setOffset( QPointF offset ) { mOffset = offset; }
490  QPointF offset() const { return mOffset; }
491 
498  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
505  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
506 
507  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
508  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
509 
510  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
511  QgsSymbolV2::OutputUnit outputUnit() const override;
512 
513  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
514  QgsMapUnitScale mapUnitScale() const override;
515 
516  protected:
519 
521 
523  double mMaxDistance;
526 
531 
533 
537 
538  private:
539 
540  //helper functions for data defined symbology
541  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int& blurRadius, bool& useWholeShape,
542  double& maxDistance, bool &ignoreRings );
543 
544  /* distance transform of a 1d function using squared distance */
545  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
546  /* distance transform of 2d function using squared distance */
547  void distanceTransform2d( double * im, int width, int height );
548  /* distance transform of a binary QImage */
549  double * distanceTransform( QImage * im );
550 
551  /* fills a QImage with values from an array of doubles containing squared distance transform values */
552  void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRampV2* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
553 };
554 
558 {
559  public:
560 
562  virtual ~QgsImageFillSymbolLayer();
563  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
564 
565  virtual QgsSymbolV2* subSymbol() override { return mOutline; }
566  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
567 
568  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
569  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
570 
571  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
572  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
573 
574  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
575  QgsSymbolV2::OutputUnit outputUnit() const override;
576 
577  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
578  QgsMapUnitScale mapUnitScale() const override;
579 
580  virtual double estimateMaxBleed() const override;
581 
582  double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
583  QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
584 
585  Qt::PenStyle dxfPenStyle() const override;
586 
587  QSet<QString> usedAttributes() const override;
588 
589  protected:
591  double mNextAngle; // mAngle / data defined angle
592 
597 
600 
601  virtual void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) { Q_UNUSED( context ); }
602 };
603 
610 {
611  public:
612 
614  {
616  Viewport
617  };
618 
619  QgsRasterFillSymbolLayer( const QString& imageFilePath = QString() );
621 
622  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
623 
624  // implemented from base classes
625  QString layerType() const override;
626  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
627  void startRender( QgsSymbolV2RenderContext& context ) override;
628  void stopRender( QgsSymbolV2RenderContext& context ) override;
629  QgsStringMap properties() const override;
630  QgsRasterFillSymbolLayer* clone() const override;
631  virtual double estimateMaxBleed() const override;
632 
633  //override QgsImageFillSymbolLayer's support for sub symbols
634  virtual QgsSymbolV2* subSymbol() override { return nullptr; }
635  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
636 
641  void setImageFilePath( const QString& imagePath );
646  QString imageFilePath() const { return mImageFilePath; }
647 
653  void setCoordinateMode( const FillCoordinateMode mode );
659  FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
660 
665  void setAlpha( const double alpha );
670  double alpha() const { return mAlpha; }
671 
678  void setOffset( QPointF offset ) { mOffset = offset; }
685  QPointF offset() const { return mOffset; }
686 
693  void setOffsetUnit( const QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
700  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
701 
708  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
715  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
716 
724  void setWidth( const double width ) { mWidth = width; }
732  double width() const { return mWidth; }
733 
740  void setWidthUnit( const QgsSymbolV2::OutputUnit unit ) { mWidthUnit = unit; }
747  QgsSymbolV2::OutputUnit widthUnit() const { return mWidthUnit; }
748 
755  void setWidthMapUnitScale( const QgsMapUnitScale& scale ) { mWidthMapUnitScale = scale; }
762  const QgsMapUnitScale& widthMapUnitScale() const { return mWidthMapUnitScale; }
763 
764  protected:
765 
769  double mAlpha;
770 
774 
775  double mWidth;
778 
779  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
780 
781  private:
782 
784  void applyPattern( QBrush& brush, const QString& imageFilePath, const double width, const double alpha,
785  const QgsSymbolV2RenderContext& context );
786 };
787 
792 {
793  public:
794  QgsSVGFillSymbolLayer( const QString& svgFilePath = "", double width = 20, double rotation = 0.0 );
795  QgsSVGFillSymbolLayer( const QByteArray& svgData, double width = 20, double rotation = 0.0 );
797 
798  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
799  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
800 
801  // implemented from base classes
802 
803  QString layerType() const override;
804 
805  void startRender( QgsSymbolV2RenderContext& context ) override;
806  void stopRender( QgsSymbolV2RenderContext& context ) override;
807 
808  QgsStringMap properties() const override;
809 
810  QgsSVGFillSymbolLayer* clone() const override;
811 
812  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
813 
814  //getters and setters
815  void setSvgFilePath( const QString& svgPath );
816  QString svgFilePath() const { return mSvgFilePath; }
817  void setPatternWidth( double width ) { mPatternWidth = width;}
818  double patternWidth() const { return mPatternWidth; }
819 
820  void setSvgFillColor( const QColor& c ) { setColor( c ); }
821  QColor svgFillColor() const { return color(); }
822 
823  void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; }
824  QColor svgOutlineColor() const { return mSvgOutlineColor; }
825  void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; }
826  double svgOutlineWidth() const { return mSvgOutlineWidth; }
827 
828  void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit ) { mPatternWidthUnit = unit; }
829  QgsSymbolV2::OutputUnit patternWidthUnit() const { return mPatternWidthUnit; }
830 
831  void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale ) { mPatternWidthMapUnitScale = scale; }
832  const QgsMapUnitScale& patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
833 
834  void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSvgOutlineWidthUnit = unit; }
835  QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const { return mSvgOutlineWidthUnit; }
836 
837  void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSvgOutlineWidthMapUnitScale = scale; }
838  const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const { return mSvgOutlineWidthMapUnitScale; }
839 
840  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
841  QgsSymbolV2::OutputUnit outputUnit() const override;
842 
843  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
844  QgsMapUnitScale mapUnitScale() const override;
845 
846  protected:
851 
860 
861  //param(fill), param(outline), param(outline-width) are going
862  //to be replaced in memory
867 
868  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
869 
870  private:
872  void storeViewBox();
873  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath
874 
876  void applyPattern( QBrush& brush, const QString& svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor& svgFillColor, const QColor& svgOutlineColor,
877  double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext& context, const QgsMapUnitScale& patternWidthMapUnitScale, const QgsMapUnitScale &svgOutlineWidthMapUnitScale );
878 };
879 
884 {
885  public:
888 
889  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
890  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
891 
892  QString layerType() const override;
893 
894  void startRender( QgsSymbolV2RenderContext& context ) override;
895 
896  void stopRender( QgsSymbolV2RenderContext& context ) override;
897 
898  QgsStringMap properties() const override;
899 
900  QgsLinePatternFillSymbolLayer* clone() const override;
901 
902  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
903 
904  double estimateMaxBleed() const override;
905 
906  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
907 
908  //getters and setters
909  void setLineAngle( double a ) { mLineAngle = a; }
910  double lineAngle() const { return mLineAngle; }
911  void setDistance( double d ) { mDistance = d; }
912  double distance() const { return mDistance; }
913  void setLineWidth( double w );
914  double lineWidth() const { return mLineWidth; }
915  void setColor( const QColor& c ) override;
916  QColor color() const override;
917  void setOffset( double offset ) { mOffset = offset; }
918  double offset() const { return mOffset; }
919 
920  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
921  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
922 
923  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
924  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
925 
926  void setLineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mLineWidthUnit = unit; }
927  QgsSymbolV2::OutputUnit lineWidthUnit() const { return mLineWidthUnit; }
928 
929  void setLineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mLineWidthMapUnitScale = scale; }
930  const QgsMapUnitScale& lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
931 
932  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
933  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
934 
935  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
936  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
937 
938  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
939  QgsSymbolV2::OutputUnit outputUnit() const override;
940 
941  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
942  QgsMapUnitScale mapUnitScale() const override;
943 
944  bool setSubSymbol( QgsSymbolV2* symbol ) override;
945  QgsSymbolV2* subSymbol() override;
946 
947  QSet<QString> usedAttributes() const override;
948 
949  protected:
951  double mDistance;
955  double mLineWidth;
960  double mLineAngle;
962  double mOffset;
965 
966  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
967 
968  private:
970  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
971 
973  QgsLineSymbolV2* mFillLineSymbol;
974 };
975 
980 {
981  public:
984 
985  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
986  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
987 
988  QString layerType() const override;
989 
990  void startRender( QgsSymbolV2RenderContext& context ) override;
991 
992  void stopRender( QgsSymbolV2RenderContext& context ) override;
993 
994  QgsStringMap properties() const override;
995 
996  QgsPointPatternFillSymbolLayer* clone() const override;
997 
998  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
999 
1000  double estimateMaxBleed() const override;
1001 
1002  //getters and setters
1003  double distanceX() const { return mDistanceX; }
1004  void setDistanceX( double d ) { mDistanceX = d; }
1005 
1006  double distanceY() const { return mDistanceY; }
1007  void setDistanceY( double d ) { mDistanceY = d; }
1008 
1009  double displacementX() const { return mDisplacementX; }
1010  void setDisplacementX( double d ) { mDisplacementX = d; }
1011 
1012  double displacementY() const { return mDisplacementY; }
1013  void setDisplacementY( double d ) { mDisplacementY = d; }
1014 
1015  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1016  virtual QgsSymbolV2* subSymbol() override { return mMarkerSymbol; }
1017 
1018  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
1019  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
1020 
1021  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
1022  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1023 
1024  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
1025  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
1026 
1027  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
1028  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1029 
1030  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
1031  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
1032 
1033  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
1034  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1035 
1036  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
1037  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
1038 
1039  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
1040  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1041 
1042  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1043  QgsSymbolV2::OutputUnit outputUnit() const override;
1044 
1045  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1046  QgsMapUnitScale mapUnitScale() const override;
1047 
1048  virtual QSet<QString> usedAttributes() const override;
1049  void setColor( const QColor& c ) override;
1050  virtual QColor color() const override;
1051 
1052  protected:
1054  double mDistanceX;
1057  double mDistanceY;
1066 
1067  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
1068 
1069  private:
1070  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
1071  double displacementX, double displacementY );
1072 };
1073 
1078 {
1079  public:
1082 
1083  // static stuff
1084 
1085  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
1086  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
1087 
1088  // implemented from base classes
1089 
1090  QString layerType() const override;
1091 
1092  void startRender( QgsSymbolV2RenderContext& context ) override;
1093 
1094  void stopRender( QgsSymbolV2RenderContext& context ) override;
1095 
1096  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
1097 
1098  QgsStringMap properties() const override;
1099 
1100  QgsCentroidFillSymbolLayerV2* clone() const override;
1101 
1102  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
1103 
1104  void setColor( const QColor& color ) override;
1105  QColor color() const override;
1106 
1107  QgsSymbolV2* subSymbol() override;
1108  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1109 
1110  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1111  QgsSymbolV2::OutputUnit outputUnit() const override;
1112 
1113  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1114  QgsMapUnitScale mapUnitScale() const override;
1115 
1116  virtual QSet<QString> usedAttributes() const override;
1117 
1118  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
1119  bool pointOnSurface() const { return mPointOnSurface; }
1120 
1123  void setPointOnAllParts( bool pointOnAllParts ) { mPointOnAllParts = pointOnAllParts; }
1126  bool pointOnAllParts() const { return mPointOnAllParts; }
1127 
1128  protected:
1132 
1135 };
1136 
1137 #endif
1138 
1139 
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:65
const QgsMapUnitScale & displacementXMapUnitScale() const
virtual void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit mOffsetUnit
virtual Qt::PenStyle dxfPenStyle() const
get pen style
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
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features...
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
get line width
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)
const QgsMapUnitScale & borderWidthMapUnitScale() const
QgsVectorColorRampV2 * mGradientRamp
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QMap< QString, QString > QgsStringMap
Definition: qgis.h:492
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
virtual double dxfAngle(QgsSymbolV2RenderContext &context) const
get angle
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
get brush/fill style
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
get brush/fill color
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
get color
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)
qint64 QgsFeatureId
Definition: qgsfeature.h:31
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].
Abstract base class for color ramps.
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)