QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 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  QgsSymbolLayerV2* clone() const override;
62 
63  void toSld( QDomDocument &doc, QDomElement &element, 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( 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, const QgsSymbolV2RenderContext& context ) const override;
120  QColor dxfColor( const QgsSymbolV2RenderContext& context ) const override;
121  Qt::PenStyle dxfPenStyle() const override;
122  QColor dxfBrushColor( const QgsSymbolV2RenderContext& context ) const override;
123  Qt::BrushStyle dxfBrushStyle() const override;
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 override;
196 
197  void startRender( QgsSymbolV2RenderContext& context ) override;
198 
199  void stopRender( QgsSymbolV2RenderContext& context ) override;
200 
201  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
202 
203  QgsStringMap properties() const override;
204 
205  QgsSymbolLayerV2* clone() const override;
206 
207  double estimateMaxBleed() const override;
208 
210  GradientType gradientType() const { return mGradientType; }
211  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
212 
214  GradientColorType gradientColorType() const { return mGradientColorType; }
215  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
216 
218  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
219  void setColorRamp( QgsVectorColorRampV2* ramp );
220 
222  QColor color2() const { return mColor2; }
223  void setColor2( QColor color2 ) { mColor2 = color2; }
224 
226  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
227  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
228 
230  GradientSpread gradientSpread() const { return mGradientSpread; }
231  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
232 
234  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
235  QPointF referencePoint1() const { return mReferencePoint1; }
236 
238  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
239  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
240 
242  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
243  QPointF referencePoint2() const { return mReferencePoint2; }
244 
246  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
247  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
248 
250  void setOffset( QPointF offset ) { mOffset = offset; }
251  QPointF offset() const { return mOffset; }
252 
254  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
255  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
256 
257  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
258  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
259 
260  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
261  QgsSymbolV2::OutputUnit outputUnit() const override;
262 
263  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
264  QgsMapUnitScale mapUnitScale() const override;
265 
266  protected:
267  QBrush mBrush;
268  QBrush mSelBrush;
269 
271  QColor mColor2;
276 
281 
282  QPointF mOffset;
285 
286  private:
287 
288  //helper functions for data defined symbology
289  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, const QPolygonF& points );
290 
292  void applyGradient( const QgsSymbolV2RenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
293  const GradientColorType &gradientColorType, QgsVectorColorRampV2 *gradientRamp, const GradientType &gradientType,
294  const GradientCoordinateMode &coordinateMode, const GradientSpread &gradientSpread,
295  const QPointF &referencePoint1, const QPointF &referencePoint2, const double angle );
296 
298  QPointF rotateReferencePoint( const QPointF & refPoint, double angle );
299 };
300 
302 {
303  public:
304 
306  {
308  ColorRamp
309  };
310 
311  QgsShapeburstFillSymbolLayerV2( QColor color = DEFAULT_SIMPLEFILL_COLOR, QColor color2 = Qt::white,
312  ShapeburstColorType colorType = SimpleTwoColor,
313  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
314 
316 
317  // static stuff
318 
319  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
320 
321  // implemented from base classes
322 
323  QString layerType() const override;
324 
325  void startRender( QgsSymbolV2RenderContext& context ) override;
326 
327  void stopRender( QgsSymbolV2RenderContext& context ) override;
328 
329  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
330 
331  QgsStringMap properties() const override;
332 
333  QgsSymbolLayerV2* clone() const override;
334 
335  double estimateMaxBleed() const override;
336 
342  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
348  int blurRadius() const { return mBlurRadius; }
349 
357  void setUseWholeShape( bool useWholeShape ) { mUseWholeShape = useWholeShape; }
364  bool useWholeShape() const { return mUseWholeShape; }
365 
373  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
381  double maxDistance() const { return mMaxDistance; }
382 
389  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
396  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
397 
398  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
399  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
400 
410  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
420  ShapeburstColorType colorType() const { return mColorType; }
421 
428  void setColorRamp( QgsVectorColorRampV2* ramp );
435  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
436 
443  void setColor2( QColor color2 ) { mColor2 = color2; }
450  QColor color2() const { return mColor2; }
451 
458  void setIgnoreRings( bool ignoreRings ) { mIgnoreRings = ignoreRings; }
464  bool ignoreRings() const { return mIgnoreRings; }
465 
472  void setOffset( QPointF offset ) { mOffset = offset; }
479  QPointF offset() const { return mOffset; }
480 
487  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
494  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
495 
496  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
497  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
498 
499  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
500  QgsSymbolV2::OutputUnit outputUnit() const override;
501 
502  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
503  QgsMapUnitScale mapUnitScale() const override;
504 
505  protected:
506  QBrush mBrush;
507  QBrush mSelBrush;
508 
510 
512  double mMaxDistance;
515 
517  QColor mColor2;
520 
522 
523  QPointF mOffset;
526 
527  private:
528 
529  //helper functions for data defined symbology
530  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int& blurRadius, bool& useWholeShape,
531  double& maxDistance, bool &ignoreRings );
532 
533  /* distance transform of a 1d function using squared distance */
534  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
535  /* distance transform of 2d function using squared distance */
536  void distanceTransform2d( double * im, int width, int height );
537  /* distance transform of a binary QImage */
538  double * distanceTransform( QImage * im );
539 
540  /* fills a QImage with values from an array of doubles containing squared distance transform values */
541  void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRampV2* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
542 };
543 
546 {
547  public:
548 
550  virtual ~QgsImageFillSymbolLayer();
551  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
552 
553  virtual QgsSymbolV2* subSymbol() override { return mOutline; }
554  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
555 
556  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
557  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
558 
559  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
560  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
561 
562  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
563  QgsSymbolV2::OutputUnit outputUnit() const override;
564 
565  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
566  QgsMapUnitScale mapUnitScale() const override;
567 
568  virtual double estimateMaxBleed() const override;
569 
570  virtual double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const override;
571  virtual QColor dxfColor( const QgsSymbolV2RenderContext& context ) const override;
572  virtual Qt::PenStyle dxfPenStyle() const override;
573 
574  protected:
575  QBrush mBrush;
576  double mNextAngle; // mAngle / data defined angle
577 
582 
585 
586  virtual void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) { Q_UNUSED( context ); }
587 };
588 
595 {
596  public:
597 
599  {
601  Viewport
602  };
603 
604  QgsRasterFillSymbolLayer( const QString& imageFilePath = QString() );
606 
607  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
608 
609  // implemented from base classes
610  QString layerType() const override;
611  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
612  void startRender( QgsSymbolV2RenderContext& context ) override;
613  void stopRender( QgsSymbolV2RenderContext& context ) override;
614  QgsStringMap properties() const override;
615  QgsSymbolLayerV2* clone() const override;
616  virtual double estimateMaxBleed() const override;
617 
618  //override QgsImageFillSymbolLayer's support for sub symbols
619  virtual QgsSymbolV2* subSymbol() override { return 0; }
620  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
621 
626  void setImageFilePath( const QString& imagePath );
631  QString imageFilePath() const { return mImageFilePath; }
632 
638  void setCoordinateMode( const FillCoordinateMode mode );
644  FillCoordinateMode coordinateMode() const { return mCoordinateMode; }
645 
650  void setAlpha( const double alpha );
655  double alpha() const { return mAlpha; }
656 
663  void setOffset( const QPointF& offset ) { mOffset = offset; }
670  QPointF offset() const { return mOffset; }
671 
678  void setOffsetUnit( const QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
685  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
686 
693  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
700  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
701 
709  void setWidth( const double width ) { mWidth = width; }
717  double width() const { return mWidth; }
718 
725  void setWidthUnit( const QgsSymbolV2::OutputUnit unit ) { mWidthUnit = unit; }
732  QgsSymbolV2::OutputUnit widthUnit() const { return mWidthUnit; }
733 
740  void setWidthMapUnitScale( const QgsMapUnitScale& scale ) { mWidthMapUnitScale = scale; }
747  const QgsMapUnitScale& widthMapUnitScale() const { return mWidthMapUnitScale; }
748 
749  protected:
750 
752  QString mImageFilePath;
754  double mAlpha;
755 
756  QPointF mOffset;
759 
760  double mWidth;
763 
764  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) override;
765 
766  private:
767 
769  void applyPattern( QBrush& brush, const QString& imageFilePath, const double width, const double alpha,
770  const QgsSymbolV2RenderContext& context );
771 };
772 
776 {
777  public:
778  QgsSVGFillSymbolLayer( const QString& svgFilePath = "", double width = 20, double rotation = 0.0 );
779  QgsSVGFillSymbolLayer( const QByteArray& svgData, double width = 20, double rotation = 0.0 );
781 
782  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
783  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
784 
785  // implemented from base classes
786 
787  QString layerType() const override;
788 
789  void startRender( QgsSymbolV2RenderContext& context ) override;
790  void stopRender( QgsSymbolV2RenderContext& context ) override;
791 
792  QgsStringMap properties() const override;
793 
794  QgsSymbolLayerV2* clone() const override;
795 
796  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const override;
797 
798  //getters and setters
799  void setSvgFilePath( const QString& svgPath );
800  QString svgFilePath() const { return mSvgFilePath; }
801  void setPatternWidth( double width ) { mPatternWidth = width;}
802  double patternWidth() const { return mPatternWidth; }
803 
804  void setSvgFillColor( const QColor& c ) { mSvgFillColor = c; }
805  QColor svgFillColor() const { return mSvgFillColor; }
806  void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; }
807  QColor svgOutlineColor() const { return mSvgOutlineColor; }
808  void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; }
809  double svgOutlineWidth() const { return mSvgOutlineWidth; }
810 
811  void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit ) { mPatternWidthUnit = unit; }
812  QgsSymbolV2::OutputUnit patternWidthUnit() const { return mPatternWidthUnit; }
813 
814  void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale ) { mPatternWidthMapUnitScale = scale; }
815  const QgsMapUnitScale& patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
816 
817  void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSvgOutlineWidthUnit = unit; }
818  QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const { return mSvgOutlineWidthUnit; }
819 
820  void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSvgOutlineWidthMapUnitScale = scale; }
821  const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const { return mSvgOutlineWidthMapUnitScale; }
822 
823  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
824  QgsSymbolV2::OutputUnit outputUnit() const override;
825 
826  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
827  QgsMapUnitScale mapUnitScale() const override;
828 
829  protected:
834 
836  QByteArray mSvgData;
838  QString mSvgFilePath;
840  QRectF mSvgViewBox;
842  QImage* mSvgPattern;
843 
844  //param(fill), param(outline), param(outline-width) are going
845  //to be replaced in memory
851 
852  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) override;
853 
854  private:
856  void storeViewBox();
857  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath
858 
860  void applyPattern( QBrush& brush, const QString& svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor& svgFillColor, const QColor& svgOutlineColor,
861  double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext& context, const QgsMapUnitScale& patternWidthMapUnitScale, const QgsMapUnitScale &svgOutlineWidthMapUnitScale );
862 };
863 
865 {
866  public:
869 
870  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
871  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
872 
873  QString layerType() const override;
874 
875  void startRender( QgsSymbolV2RenderContext& context ) override;
876 
877  void stopRender( QgsSymbolV2RenderContext& context ) override;
878 
879  QgsStringMap properties() const override;
880 
881  QgsSymbolLayerV2* clone() const override;
882 
883  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const override;
884 
885  double estimateMaxBleed() const override;
886 
887  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
888 
889  //getters and setters
890  void setLineAngle( double a ) { mLineAngle = a; }
891  double lineAngle() const { return mLineAngle; }
892  void setDistance( double d ) { mDistance = d; }
893  double distance() const { return mDistance; }
894  void setLineWidth( double w );
895  double lineWidth() const { return mLineWidth; }
896  void setColor( const QColor& c ) override;
897  QColor color() const override { return mColor; }
898  void setOffset( double offset ) { mOffset = offset; }
899  double offset() const { return mOffset; }
900 
901  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
902  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
903 
904  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
905  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
906 
907  void setLineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mLineWidthUnit = unit; }
908  QgsSymbolV2::OutputUnit lineWidthUnit() const { return mLineWidthUnit; }
909 
910  void setLineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mLineWidthMapUnitScale = scale; }
911  const QgsMapUnitScale& lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
912 
913  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
914  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
915 
916  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
917  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
918 
919  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
920  QgsSymbolV2::OutputUnit outputUnit() const override;
921 
922  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
923  QgsMapUnitScale mapUnitScale() const override;
924 
925  bool setSubSymbol( QgsSymbolV2* symbol ) override;
926  QgsSymbolV2* subSymbol() override;
927 
928  QSet<QString> usedAttributes() const override;
929 
930  protected:
932  double mDistance;
936  double mLineWidth;
939  QColor mColor;
941  double mLineAngle;
943  double mOffset;
946 
947  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) override;
948 
949  private:
951  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
952 
954  QgsLineSymbolV2* mFillLineSymbol;
955 };
956 
958 {
959  public:
962 
963  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
964  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
965 
966  QString layerType() const override;
967 
968  void startRender( QgsSymbolV2RenderContext& context ) override;
969 
970  void stopRender( QgsSymbolV2RenderContext& context ) override;
971 
972  QgsStringMap properties() const override;
973 
974  QgsSymbolLayerV2* clone() const override;
975 
976  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const override;
977 
978  double estimateMaxBleed() const override;
979 
980  //getters and setters
981  double distanceX() const { return mDistanceX; }
982  void setDistanceX( double d ) { mDistanceX = d; }
983 
984  double distanceY() const { return mDistanceY; }
985  void setDistanceY( double d ) { mDistanceY = d; }
986 
987  double displacementX() const { return mDisplacementX; }
988  void setDisplacementX( double d ) { mDisplacementX = d; }
989 
990  double displacementY() const { return mDisplacementY; }
991  void setDisplacementY( double d ) { mDisplacementY = d; }
992 
993  bool setSubSymbol( QgsSymbolV2* symbol ) override;
994  virtual QgsSymbolV2* subSymbol() override { return mMarkerSymbol; }
995 
996  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
997  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
998 
999  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
1000  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
1001 
1002  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
1003  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
1004 
1005  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
1006  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1007 
1008  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
1009  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
1010 
1011  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
1012  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1013 
1014  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
1015  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
1016 
1017  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
1018  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1019 
1020  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1021  QgsSymbolV2::OutputUnit outputUnit() const override;
1022 
1023  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1024  QgsMapUnitScale mapUnitScale() const override;
1025 
1026  virtual QSet<QString> usedAttributes() const override;
1027 
1028  protected:
1030  double mDistanceX;
1033  double mDistanceY;
1042 
1043  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) override;
1044 
1045  private:
1046  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
1047  double displacementX, double displacementY );
1048 };
1049 
1051 {
1052  public:
1055 
1056  // static stuff
1057 
1058  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
1059  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
1060 
1061  // implemented from base classes
1062 
1063  QString layerType() const override;
1064 
1065  void startRender( QgsSymbolV2RenderContext& context ) override;
1066 
1067  void stopRender( QgsSymbolV2RenderContext& context ) override;
1068 
1069  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
1070 
1071  QgsStringMap properties() const override;
1072 
1073  QgsSymbolLayerV2* clone() const override;
1074 
1075  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const override;
1076 
1077  void setColor( const QColor& color ) override;
1078 
1079  QgsSymbolV2* subSymbol() override;
1080  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1081 
1082  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1083  QgsSymbolV2::OutputUnit outputUnit() const override;
1084 
1085  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1086  QgsMapUnitScale mapUnitScale() const override;
1087 
1088  virtual QSet<QString> usedAttributes() const override;
1089 
1090  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
1091  bool pointOnSurface() const { return mPointOnSurface; }
1092 
1093  protected:
1096 };
1097 
1098 #endif
1099 
1100