QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  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;
52 
53  void startRender( QgsSymbolV2RenderContext& context );
54 
55  void stopRender( QgsSymbolV2RenderContext& context );
56 
57  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
58 
59  QgsStringMap properties() const;
60 
61  QgsSymbolLayerV2* clone() const;
62 
63  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
64 
65  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const;
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( QColor borderColor ) { mBorderColor = borderColor; }
72 
75  QColor outlineColor() const { return borderColor(); }
78  void setOutlineColor( const QColor& color ) { setBorderColor( color ); }
79 
82  QColor fillColor() const { return color(); }
85  void setFillColor( const QColor& color ) { 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 
113 
114  void setMapUnitScale( const QgsMapUnitScale &scale );
116 
117  double estimateMaxBleed() const;
118 
119  double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const;
120  QColor dxfColor( const QgsSymbolV2RenderContext& context ) const;
121  Qt::PenStyle dxfPenStyle() const;
122  QColor dxfBrushColor( const QgsSymbolV2RenderContext& context ) const;
123  Qt::BrushStyle dxfBrushStyle() const;
124 
125  protected:
126  QBrush mBrush;
127  QBrush mSelBrush;
128  Qt::BrushStyle mBrushStyle;
129  QColor mBorderColor;
130  Qt::PenStyle mBorderStyle;
131  double mBorderWidth;
134  Qt::PenJoinStyle mPenJoinStyle;
135  QPen mPen;
136  QPen mSelPen;
137 
138  QPointF mOffset;
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  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;
196 
197  void startRender( QgsSymbolV2RenderContext& context );
198 
199  void stopRender( QgsSymbolV2RenderContext& context );
200 
201  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
202 
203  QgsStringMap properties() const;
204 
205  QgsSymbolLayerV2* clone() const;
206 
207  double estimateMaxBleed() const;
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( 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 setAngle( double angle ) { mAngle = angle; }
251  double angle() const { return mAngle; }
252 
254  void setOffset( QPointF offset ) { mOffset = offset; }
255  QPointF offset() const { return mOffset; }
256 
258  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
259  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
260 
261  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
262  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
263 
266 
267  void setMapUnitScale( const QgsMapUnitScale &scale );
269 
270  protected:
271  QBrush mBrush;
272  QBrush mSelBrush;
273 
275  QColor mColor2;
280 
285  double mAngle;
286 
287  QPointF mOffset;
290 
291  private:
292 
293  //helper functions for data defined symbology
294  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, const QPolygonF& points );
295 
297  void applyGradient( const QgsSymbolV2RenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
298  const GradientColorType &gradientColorType, QgsVectorColorRampV2 *gradientRamp, const GradientType &gradientType,
299  const GradientCoordinateMode &coordinateMode, const GradientSpread &gradientSpread,
300  const QPointF &referencePoint1, const QPointF &referencePoint2, const double angle );
301 
303  QPointF rotateReferencePoint( const QPointF & refPoint, double angle );
304 };
305 
307 {
308  public:
309 
311  {
313  ColorRamp
314  };
315 
316  QgsShapeburstFillSymbolLayerV2( QColor color = DEFAULT_SIMPLEFILL_COLOR, QColor color2 = Qt::white,
317  ShapeburstColorType colorType = SimpleTwoColor,
318  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
319 
321 
322  // static stuff
323 
324  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
325 
326  // implemented from base classes
327 
328  QString layerType() const;
329 
330  void startRender( QgsSymbolV2RenderContext& context );
331 
332  void stopRender( QgsSymbolV2RenderContext& context );
333 
334  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
335 
336  QgsStringMap properties() const;
337 
338  QgsSymbolLayerV2* clone() const;
339 
340  double estimateMaxBleed() const;
341 
347  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
353  int blurRadius() const { return mBlurRadius; }
354 
362  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
369  bool useWholeShape() const { return mUseWholeShape; }
370 
378  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
386  double maxDistance() const { return mMaxDistance; }
387 
394  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
401  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
402 
403  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
404  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
405 
415  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
425  ShapeburstColorType colorType() const { return mColorType; }
426 
433  void setColorRamp( QgsVectorColorRampV2* ramp );
440  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
441 
448  void setColor2( QColor color2 ) { mColor2 = color2; }
455  QColor color2() const { return mColor2; }
456 
463  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
469  bool ignoreRings() const { return mIgnoreRings; }
470 
477  void setOffset( QPointF offset ) { mOffset = offset; }
484  QPointF offset() const { return mOffset; }
485 
492  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
499  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
500 
501  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
502  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
503 
506 
507  void setMapUnitScale( const QgsMapUnitScale &scale );
509 
510  protected:
511  QBrush mBrush;
512  QBrush mSelBrush;
513 
515 
517  double mMaxDistance;
520 
522  QColor mColor2;
525 
527 
528  QPointF mOffset;
531 
532  private:
533 
534  //helper functions for data defined symbology
535  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int& blurRadius, bool& useWholeShape,
536  double& maxDistance, bool &ignoreRings );
537 
538  /* distance transform of a 1d function using squared distance */
539  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
540  /* distance transform of 2d function using squared distance */
541  void distanceTransform2d( double * im, int width, int height );
542  /* distance transform of a binary QImage */
543  double * distanceTransform( QImage * im );
544 
545  /* fills a QImage with values from an array of doubles containing squared distance transform values */
546  void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRampV2* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
547 };
548 
551 {
552  public:
553 
555  virtual ~QgsImageFillSymbolLayer();
556  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
557 
558  virtual QgsSymbolV2* subSymbol() { return mOutline; }
559  virtual bool setSubSymbol( QgsSymbolV2* symbol );
560 
561  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
562  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
563 
564  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
565  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
566 
569 
570  void setMapUnitScale( const QgsMapUnitScale& scale );
572 
573  virtual double estimateMaxBleed() const;
574 
575  virtual double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const;
576  virtual QColor dxfColor( const QgsSymbolV2RenderContext& context ) const;
577  virtual Qt::PenStyle dxfPenStyle() const;
578 
579  protected:
580  QBrush mBrush;
581  double mNextAngle; // mAngle / data defined angle
582 
587 
590 
591  virtual void applyDataDefinedSettings( const 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;
616  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
617  void startRender( QgsSymbolV2RenderContext& context );
618  void stopRender( QgsSymbolV2RenderContext& context );
619  QgsStringMap properties() const;
620  QgsSymbolLayerV2* clone() const;
621  virtual double estimateMaxBleed() const;
622 
623  //override QgsImageFillSymbolLayer's support for sub symbols
624  virtual QgsSymbolV2* subSymbol() { return 0; }
625  virtual bool setSubSymbol( QgsSymbolV2* symbol );
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( const 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 
757  QString mImageFilePath;
759  double mAlpha;
760 
761  QPointF mOffset;
764 
765  double mWidth;
768 
769  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );
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;
793 
794  void startRender( QgsSymbolV2RenderContext& context );
795  void stopRender( QgsSymbolV2RenderContext& context );
796 
797  QgsStringMap properties() const;
798 
799  QgsSymbolLayerV2* clone() const;
800 
801  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
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 ) { mSvgFillColor = c; }
810  QColor svgFillColor() const { return mSvgFillColor; }
811  void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; }
812  QColor svgOutlineColor() const { return mSvgOutlineColor; }
813  void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; }
814  double svgOutlineWidth() const { return mSvgOutlineWidth; }
815 
816  void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit ) { mPatternWidthUnit = unit; }
817  QgsSymbolV2::OutputUnit patternWidthUnit() const { return mPatternWidthUnit; }
818 
819  void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale ) { mPatternWidthMapUnitScale = scale; }
820  const QgsMapUnitScale& patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
821 
822  void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSvgOutlineWidthUnit = unit; }
823  QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const { return mSvgOutlineWidthUnit; }
824 
825  void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSvgOutlineWidthMapUnitScale = scale; }
826  const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const { return mSvgOutlineWidthMapUnitScale; }
827 
830 
831  void setMapUnitScale( const QgsMapUnitScale &scale );
833 
834  protected:
839 
841  QByteArray mSvgData;
843  QString mSvgFilePath;
845  QRectF mSvgViewBox;
847  QImage* mSvgPattern;
848 
849  //param(fill), param(outline), param(outline-width) are going
850  //to be replaced in memory
856 
857  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );
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;
879 
880  void startRender( QgsSymbolV2RenderContext& context );
881 
882  void stopRender( QgsSymbolV2RenderContext& context );
883 
884  QgsStringMap properties() const;
885 
886  QgsSymbolLayerV2* clone() const;
887 
888  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
889 
890  double estimateMaxBleed() const;
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 );
902  QColor color() const { 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 
926 
927  void setMapUnitScale( const QgsMapUnitScale& scale );
929 
930  bool setSubSymbol( QgsSymbolV2* symbol );
932 
933  protected:
935  double mDistance;
939  double mLineWidth;
942  QColor mColor;
944  double mLineAngle;
946  double mOffset;
949 
950  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );
951 
952  private:
954  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
955 
957  QgsLineSymbolV2* mFillLineSymbol;
958 };
959 
961 {
962  public:
965 
966  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
967  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
968 
969  QString layerType() const;
970 
971  void startRender( QgsSymbolV2RenderContext& context );
972 
973  void stopRender( QgsSymbolV2RenderContext& context );
974 
975  QgsStringMap properties() const;
976 
977  QgsSymbolLayerV2* clone() const;
978 
979  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
980 
981  double estimateMaxBleed() const;
982 
983  //getters and setters
984  double distanceX() const { return mDistanceX; }
985  void setDistanceX( double d ) { mDistanceX = d; }
986 
987  double distanceY() const { return mDistanceY; }
988  void setDistanceY( double d ) { mDistanceY = d; }
989 
990  double displacementX() const { return mDisplacementX; }
991  void setDisplacementX( double d ) { mDisplacementX = d; }
992 
993  double displacementY() const { return mDisplacementY; }
994  void setDisplacementY( double d ) { mDisplacementY = d; }
995 
996  bool setSubSymbol( QgsSymbolV2* symbol );
997  virtual QgsSymbolV2* subSymbol() { return mMarkerSymbol; }
998 
999  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
1000  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
1001 
1002  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
1003  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1004 
1005  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
1006  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
1007 
1008  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
1009  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1010 
1011  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
1012  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
1013 
1014  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
1015  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1016 
1017  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
1018  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
1019 
1020  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
1021  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1022 
1025 
1026  void setMapUnitScale( const QgsMapUnitScale &scale );
1027  QgsMapUnitScale mapUnitScale() const;
1028 
1029  virtual QSet<QString> usedAttributes() const;
1030 
1031  protected:
1033  double mDistanceX;
1036  double mDistanceY;
1045 
1046  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );
1047 
1048  private:
1049  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
1050  double displacementX, double displacementY );
1051 };
1052 
1054 {
1055  public:
1058 
1059  // static stuff
1060 
1061  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
1062  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
1063 
1064  // implemented from base classes
1065 
1066  QString layerType() const;
1067 
1068  void startRender( QgsSymbolV2RenderContext& context );
1069 
1070  void stopRender( QgsSymbolV2RenderContext& context );
1071 
1072  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
1073 
1074  QgsStringMap properties() const;
1075 
1076  QgsSymbolLayerV2* clone() const;
1077 
1078  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
1079 
1080  void setColor( const QColor& color );
1081 
1083  bool setSubSymbol( QgsSymbolV2* symbol );
1084 
1087 
1088  void setMapUnitScale( const QgsMapUnitScale &scale );
1089  QgsMapUnitScale mapUnitScale() const;
1090 
1091  virtual QSet<QString> usedAttributes() const;
1092 
1093  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
1094  bool pointOnSurface() const { return mPointOnSurface; }
1095 
1096  protected:
1099 };
1100 
1101 #endif
1102 
1103 
virtual QSet< QString > usedAttributes() const
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's boundary...
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon'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
void setAngle(double angle)
Rotation angle for gradient fill.
const QgsMapUnitScale & displacementXMapUnitScale() const
virtual void setOutputUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit mOffsetUnit
virtual Qt::PenStyle dxfPenStyle() const
FillCoordinateMode mCoordinateMode
void setMapUnitScale(const QgsMapUnitScale &scale)
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
virtual QgsSymbolLayerV2 * clone() const =0
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
QgsSymbolV2::OutputUnit mLineWidthUnit
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
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)
virtual QgsSymbolV2 * subSymbol()
QString svgFilePath() const
virtual void applyDataDefinedSettings(const QgsSymbolV2RenderContext &context)
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...
virtual QgsSymbolV2 * subSymbol()
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
void setColor2(QColor color2)
Sets the color for the endpoint of the shapeburst fill.
QgsSymbolV2::OutputUnit outputUnit() const
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.
void setBorderColor(QColor borderColor)
QColor fillColor() const
Get fill color.
const QgsMapUnitScale & outlineWidthMapUnitScale() const
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
double mLineAngle
Vector line angle in degrees (0 = horizontal, counterclockwise)
const QgsMapUnitScale & borderWidthMapUnitScale() const
QgsVectorColorRampV2 * mGradientRamp
QMap< QString, QString > QgsStringMap
Definition: qgis.h:412
void setFillColor(const QColor &color)
Set fill color.
void setPatternWidth(double width)
QgsSymbolV2::OutputUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setSvgOutlineColor(const QColor &c)
virtual void startRender(QgsSymbolV2RenderContext &context)=0
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
virtual QgsSymbolV2 * subSymbol()
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's boundary...
QString mImageFilePath
Path to the image file.
QgsSymbolV2::OutputUnit mDisplacementYUnit
virtual void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
A class for filling symbols with a repeated raster image.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
QByteArray mSvgData
SVG data.
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'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.
const QgsMapUnitScale & offsetMapUnitScale() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image'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 QgsStringMap properties() const =0
QgsSymbolV2::OutputUnit borderWidthUnit() const
virtual QColor color() const
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
void setDisplacementXUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit mOffsetUnit
void setBorderWidthUnit(QgsSymbolV2::OutputUnit unit)
virtual QColor dxfBrushColor(const QgsSymbolV2RenderContext &context) const
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit mOffsetUnit
QString mSvgFilePath
Path to the svg file (or empty if constructed directly from data)
const QgsMapUnitScale & displacementYMapUnitScale() const
QgsSymbolV2::OutputUnit mOffsetUnit
virtual QColor dxfColor(const QgsSymbolV2RenderContext &context) const
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.
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
void setOffset(QPointF offset)
Offset for gradient fill.
virtual QString layerType() const =0
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's offset.
double widthScaleFactor
Definition: qgssvgcache.cpp:79
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill'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.
QgsMapUnitScale mBorderWidthMapUnitScale
QPointF offset() const
Returns the offset for the fill.
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
void setOffset(const QPointF &offset)
Sets the offset for the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
QgsSymbolV2::OutputUnit mDistanceUnit
virtual QgsMapUnitScale mapUnitScale() const
QgsMapUnitScale mapUnitScale() const
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
void setOutlineColor(const QColor &color)
Set outline color.
virtual void setColor(const QColor &color)
GradientType gradientType() const
Type of gradient, eg linear or radial.
QgsSymbolV2::OutputUnit outlineWidthUnit() const
QgsSymbolV2::OutputUnit mDistanceUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QColor outlineColor() const
Get outline color.
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
QgsSymbolV2::OutputUnit widthUnit() const
Returns the units for the image's width.
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
void setWidthUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the image'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)
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)
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
double angle() const
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
Qt::BrushStyle brushStyle() const
void setOffsetUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the fill's offset.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
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'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)