QGIS API Documentation
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  double dxfAngle( QgsSymbolV2RenderContext& context ) const override;
122 
123  Qt::PenStyle dxfPenStyle() const override;
124  QColor dxfBrushColor( QgsSymbolV2RenderContext &context ) const override;
125  Qt::BrushStyle dxfBrushStyle() const override;
126 
127  protected:
130  Qt::BrushStyle mBrushStyle;
132  Qt::PenStyle mBorderStyle;
133  double mBorderWidth;
136  Qt::PenJoinStyle mPenJoinStyle;
139 
143 
144  private:
145  //helper functions for data defined symbology
146  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QBrush& brush, QPen& pen, QPen& selPen );
147 };
148 
150 
152 {
153  public:
154 
156  {
158  ColorRamp
159  };
160 
162  {
165  Conical
166  };
167 
169  {
171  Viewport
172  };
173 
175  {
178  Repeat
179  };
180 
182  const QColor& color2 = Qt::white,
183  GradientColorType gradientColorType = SimpleTwoColor,
184  GradientType gradientType = Linear,
185  GradientCoordinateMode coordinateMode = Feature,
186  GradientSpread gradientSpread = Pad
187  );
188 
189  virtual ~QgsGradientFillSymbolLayerV2();
190 
191  // static stuff
192 
193  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
194 
195  // implemented from base classes
196 
197  QString layerType() const override;
198 
199  void startRender( QgsSymbolV2RenderContext& context ) override;
200 
201  void stopRender( QgsSymbolV2RenderContext& context ) override;
202 
203  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
204 
205  QgsStringMap properties() const override;
206 
207  QgsGradientFillSymbolLayerV2* clone() const override;
208 
209  double estimateMaxBleed() const override;
210 
212  GradientType gradientType() const { return mGradientType; }
213  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
214 
216  GradientColorType gradientColorType() const { return mGradientColorType; }
217  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
218 
220  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
221  void setColorRamp( QgsVectorColorRampV2* ramp );
222 
224  QColor color2() const { return mColor2; }
225  void setColor2( const QColor& color2 ) { mColor2 = color2; }
226 
228  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
229  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
230 
232  GradientSpread gradientSpread() const { return mGradientSpread; }
233  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
234 
236  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
237  QPointF referencePoint1() const { return mReferencePoint1; }
238 
240  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
241  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
242 
244  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
245  QPointF referencePoint2() const { return mReferencePoint2; }
246 
248  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
249  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
250 
252  void setOffset( QPointF offset ) { mOffset = offset; }
253  QPointF offset() const { return mOffset; }
254 
256  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
257  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
258 
259  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
260  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
261 
262  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
263  QgsSymbolV2::OutputUnit outputUnit() const override;
264 
265  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
266  QgsMapUnitScale mapUnitScale() const override;
267 
268  protected:
271 
278 
283 
287 
288  private:
289 
290  //helper functions for data defined symbology
291  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, const QPolygonF& points );
292 
294  void applyGradient( const QgsSymbolV2RenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
295  GradientColorType gradientColorType, QgsVectorColorRampV2 *gradientRamp, GradientType gradientType,
296  GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
297  QPointF referencePoint1, QPointF referencePoint2, const double angle );
298 
300  QPointF rotateReferencePoint( QPointF refPoint, double angle );
301 };
302 
304 {
305  public:
306 
308  {
310  ColorRamp
311  };
312 
313  QgsShapeburstFillSymbolLayerV2( const QColor& color = DEFAULT_SIMPLEFILL_COLOR, const QColor& color2 = Qt::white,
314  ShapeburstColorType colorType = SimpleTwoColor,
315  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
316 
318 
319  // static stuff
320 
321  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
322 
323  // implemented from base classes
324 
325  QString layerType() const override;
326 
327  void startRender( QgsSymbolV2RenderContext& context ) override;
328 
329  void stopRender( QgsSymbolV2RenderContext& context ) override;
330 
331  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
332 
333  QgsStringMap properties() const override;
334 
335  QgsShapeburstFillSymbolLayerV2* clone() const override;
336 
337  double estimateMaxBleed() const override;
338 
344  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
350  int blurRadius() const { return mBlurRadius; }
351 
359  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
366  bool useWholeShape() const { return mUseWholeShape; }
367 
375  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
383  double maxDistance() const { return mMaxDistance; }
384 
391  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
398  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
399 
400  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
401  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
402 
412  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
422  ShapeburstColorType colorType() const { return mColorType; }
423 
430  void setColorRamp( QgsVectorColorRampV2* ramp );
437  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
438 
445  void setColor2( const QColor& color2 ) { mColor2 = color2; }
452  QColor color2() const { return mColor2; }
453 
460  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
466  bool ignoreRings() const { return mIgnoreRings; }
467 
474  void setOffset( QPointF offset ) { mOffset = offset; }
481  QPointF offset() const { return mOffset; }
482 
489  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
496  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
497 
498  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
499  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
500 
501  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
502  QgsSymbolV2::OutputUnit outputUnit() const override;
503 
504  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
505  QgsMapUnitScale mapUnitScale() const override;
506 
507  protected:
510 
512 
514  double mMaxDistance;
517 
522 
524 
528 
529  private:
530 
531  //helper functions for data defined symbology
532  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int& blurRadius, bool& useWholeShape,
533  double& maxDistance, bool &ignoreRings );
534 
535  /* distance transform of a 1d function using squared distance */
536  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
537  /* distance transform of 2d function using squared distance */
538  void distanceTransform2d( double * im, int width, int height );
539  /* distance transform of a binary QImage */
540  double * distanceTransform( QImage * im );
541 
542  /* fills a QImage with values from an array of doubles containing squared distance transform values */
543  void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRampV2* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
544 };
545 
548 {
549  public:
550 
552  virtual ~QgsImageFillSymbolLayer();
553  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
554 
555  virtual QgsSymbolV2* subSymbol() override { return mOutline; }
556  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
557 
558  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
559  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
560 
561  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
562  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
563 
564  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
565  QgsSymbolV2::OutputUnit outputUnit() const override;
566 
567  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
568  QgsMapUnitScale mapUnitScale() const override;
569 
570  virtual double estimateMaxBleed() const override;
571 
572  double dxfWidth( const QgsDxfExport& e, QgsSymbolV2RenderContext& context ) const override;
573  QColor dxfColor( QgsSymbolV2RenderContext& context ) const override;
574 
575  Qt::PenStyle dxfPenStyle() const override;
576 
577  QSet<QString> usedAttributes() const override;
578 
579  protected:
581  double mNextAngle; // mAngle / data defined angle
582 
587 
590 
591  virtual void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) { Q_UNUSED( context ); }
592 };
593 
600 {
601  public:
602 
604  {
606  Viewport
607  };
608 
609  QgsRasterFillSymbolLayer( const QString& imageFilePath = QString() );
611 
612  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
613 
614  // implemented from base classes
615  QString layerType() const override;
616  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
617  void startRender( QgsSymbolV2RenderContext& context ) override;
618  void stopRender( QgsSymbolV2RenderContext& context ) override;
619  QgsStringMap properties() const override;
620  QgsRasterFillSymbolLayer* clone() const override;
621  virtual double estimateMaxBleed() const override;
622 
623  //override QgsImageFillSymbolLayer's support for sub symbols
624  virtual QgsSymbolV2* subSymbol() override { return nullptr; }
625  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
626 
631  void setImageFilePath( const QString& imagePath );
636  QString imageFilePath() const { return mImageFilePath; }
637 
643  void setCoordinateMode( const FillCoordinateMode mode );
649  FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
650 
655  void setAlpha( const double alpha );
660  double alpha() const { return mAlpha; }
661 
668  void setOffset( QPointF offset ) { mOffset = offset; }
675  QPointF offset() const { return mOffset; }
676 
683  void setOffsetUnit( const QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
690  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
691 
698  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
705  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
706 
714  void setWidth( const double width ) { mWidth = width; }
722  double width() const { return mWidth; }
723 
730  void setWidthUnit( const QgsSymbolV2::OutputUnit unit ) { mWidthUnit = unit; }
737  QgsSymbolV2::OutputUnit widthUnit() const { return mWidthUnit; }
738 
745  void setWidthMapUnitScale( const QgsMapUnitScale& scale ) { mWidthMapUnitScale = scale; }
752  const QgsMapUnitScale& widthMapUnitScale() const { return mWidthMapUnitScale; }
753 
754  protected:
755 
759  double mAlpha;
760 
764 
765  double mWidth;
768 
769  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
770 
771  private:
772 
774  void applyPattern( QBrush& brush, const QString& imageFilePath, const double width, const double alpha,
775  const QgsSymbolV2RenderContext& context );
776 };
777 
781 {
782  public:
783  QgsSVGFillSymbolLayer( const QString& svgFilePath = "", double width = 20, double rotation = 0.0 );
784  QgsSVGFillSymbolLayer( const QByteArray& svgData, double width = 20, double rotation = 0.0 );
786 
787  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
788  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
789 
790  // implemented from base classes
791 
792  QString layerType() const override;
793 
794  void startRender( QgsSymbolV2RenderContext& context ) override;
795  void stopRender( QgsSymbolV2RenderContext& context ) override;
796 
797  QgsStringMap properties() const override;
798 
799  QgsSVGFillSymbolLayer* clone() const override;
800 
801  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
802 
803  //getters and setters
804  void setSvgFilePath( const QString& svgPath );
805  QString svgFilePath() const { return mSvgFilePath; }
806  void setPatternWidth( double width ) { mPatternWidth = width;}
807  double patternWidth() const { return mPatternWidth; }
808 
809  void setSvgFillColor( const QColor& c ) { setColor( c ); }
810  QColor svgFillColor() const { return color(); }
811 
812  void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; }
813  QColor svgOutlineColor() const { return mSvgOutlineColor; }
814  void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; }
815  double svgOutlineWidth() const { return mSvgOutlineWidth; }
816 
817  void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit ) { mPatternWidthUnit = unit; }
818  QgsSymbolV2::OutputUnit patternWidthUnit() const { return mPatternWidthUnit; }
819 
820  void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale ) { mPatternWidthMapUnitScale = scale; }
821  const QgsMapUnitScale& patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
822 
823  void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSvgOutlineWidthUnit = unit; }
824  QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const { return mSvgOutlineWidthUnit; }
825 
826  void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSvgOutlineWidthMapUnitScale = scale; }
827  const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const { return mSvgOutlineWidthMapUnitScale; }
828 
829  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
830  QgsSymbolV2::OutputUnit outputUnit() const override;
831 
832  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
833  QgsMapUnitScale mapUnitScale() const override;
834 
835  protected:
840 
849 
850  //param(fill), param(outline), param(outline-width) are going
851  //to be replaced in memory
856 
857  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
858 
859  private:
861  void storeViewBox();
862  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath
863 
865  void applyPattern( QBrush& brush, const QString& svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor& svgFillColor, const QColor& svgOutlineColor,
866  double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext& context, const QgsMapUnitScale& patternWidthMapUnitScale, const QgsMapUnitScale &svgOutlineWidthMapUnitScale );
867 };
868 
870 {
871  public:
874 
875  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
876  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
877 
878  QString layerType() const override;
879 
880  void startRender( QgsSymbolV2RenderContext& context ) override;
881 
882  void stopRender( QgsSymbolV2RenderContext& context ) override;
883 
884  QgsStringMap properties() const override;
885 
886  QgsLinePatternFillSymbolLayer* clone() const override;
887 
888  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
889 
890  double estimateMaxBleed() const override;
891 
892  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
893 
894  //getters and setters
895  void setLineAngle( double a ) { mLineAngle = a; }
896  double lineAngle() const { return mLineAngle; }
897  void setDistance( double d ) { mDistance = d; }
898  double distance() const { return mDistance; }
899  void setLineWidth( double w );
900  double lineWidth() const { return mLineWidth; }
901  void setColor( const QColor& c ) override;
902  QColor color() const override { return mColor; }
903  void setOffset( double offset ) { mOffset = offset; }
904  double offset() const { return mOffset; }
905 
906  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
907  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
908 
909  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
910  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
911 
912  void setLineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mLineWidthUnit = unit; }
913  QgsSymbolV2::OutputUnit lineWidthUnit() const { return mLineWidthUnit; }
914 
915  void setLineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mLineWidthMapUnitScale = scale; }
916  const QgsMapUnitScale& lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
917 
918  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
919  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
920 
921  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
922  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
923 
924  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
925  QgsSymbolV2::OutputUnit outputUnit() const override;
926 
927  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
928  QgsMapUnitScale mapUnitScale() const override;
929 
930  bool setSubSymbol( QgsSymbolV2* symbol ) override;
931  QgsSymbolV2* subSymbol() override;
932 
933  QSet<QString> usedAttributes() const override;
934 
935  protected:
937  double mDistance;
941  double mLineWidth;
946  double mLineAngle;
948  double mOffset;
951 
952  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
953 
954  private:
956  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
957 
959  QgsLineSymbolV2* mFillLineSymbol;
960 };
961 
963 {
964  public:
967 
968  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
969  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
970 
971  QString layerType() const override;
972 
973  void startRender( QgsSymbolV2RenderContext& context ) override;
974 
975  void stopRender( QgsSymbolV2RenderContext& context ) override;
976 
977  QgsStringMap properties() const override;
978 
979  QgsPointPatternFillSymbolLayer* clone() const override;
980 
981  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
982 
983  double estimateMaxBleed() const override;
984 
985  //getters and setters
986  double distanceX() const { return mDistanceX; }
987  void setDistanceX( double d ) { mDistanceX = d; }
988 
989  double distanceY() const { return mDistanceY; }
990  void setDistanceY( double d ) { mDistanceY = d; }
991 
992  double displacementX() const { return mDisplacementX; }
993  void setDisplacementX( double d ) { mDisplacementX = d; }
994 
995  double displacementY() const { return mDisplacementY; }
996  void setDisplacementY( double d ) { mDisplacementY = d; }
997 
998  bool setSubSymbol( QgsSymbolV2* symbol ) override;
999  virtual QgsSymbolV2* subSymbol() override { return mMarkerSymbol; }
1000 
1001  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
1002  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
1003 
1004  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
1005  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1006 
1007  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
1008  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
1009 
1010  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
1011  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1012 
1013  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
1014  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
1015 
1016  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
1017  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1018 
1019  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
1020  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
1021 
1022  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
1023  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1024 
1025  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1026  QgsSymbolV2::OutputUnit outputUnit() const override;
1027 
1028  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1029  QgsMapUnitScale mapUnitScale() const override;
1030 
1031  virtual QSet<QString> usedAttributes() const override;
1032 
1033  protected:
1035  double mDistanceX;
1038  double mDistanceY;
1047 
1048  void applyDataDefinedSettings( QgsSymbolV2RenderContext& context ) override;
1049 
1050  private:
1051  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
1052  double displacementX, double displacementY );
1053 };
1054 
1056 {
1057  public:
1060 
1061  // static stuff
1062 
1063  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
1064  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
1065 
1066  // implemented from base classes
1067 
1068  QString layerType() const override;
1069 
1070  void startRender( QgsSymbolV2RenderContext& context ) override;
1071 
1072  void stopRender( QgsSymbolV2RenderContext& context ) override;
1073 
1074  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
1075 
1076  QgsStringMap properties() const override;
1077 
1078  QgsCentroidFillSymbolLayerV2* clone() const override;
1079 
1080  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap& props ) const override;
1081 
1082  void setColor( const QColor& color ) override;
1083 
1084  QgsSymbolV2* subSymbol() override;
1085  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1086 
1087  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1088  QgsSymbolV2::OutputUnit outputUnit() const override;
1089 
1090  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1091  QgsMapUnitScale mapUnitScale() const override;
1092 
1093  virtual QSet<QString> usedAttributes() const override;
1094 
1095  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
1096  bool pointOnSurface() const { return mPointOnSurface; }
1097 
1100  void setPointOnAllParts( bool pointOnAllParts ) { mPointOnAllParts = pointOnAllParts; }
1103  bool pointOnAllParts() const { return mPointOnAllParts; }
1104 
1105  protected:
1109 
1112 };
1113 
1114 #endif
1115 
1116 
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:62
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
QColor color() const override
The fill color.
QgsVectorColorRampV2 * mGradientRamp
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QMap< QString, QString > QgsStringMap
Definition: qgis.h:451
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)