QGIS API Documentation  2.8.2-Wien
 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  protected:
930  double mDistance;
934  double mLineWidth;
937  QColor mColor;
939  double mLineAngle;
941  double mOffset;
944 
945  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) override;
946 
947  private:
949  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
950 
952  QgsLineSymbolV2* mFillLineSymbol;
953 };
954 
956 {
957  public:
960 
961  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
962  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
963 
964  QString layerType() const override;
965 
966  void startRender( QgsSymbolV2RenderContext& context ) override;
967 
968  void stopRender( QgsSymbolV2RenderContext& context ) override;
969 
970  QgsStringMap properties() const override;
971 
972  QgsSymbolLayerV2* clone() const override;
973 
974  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const override;
975 
976  double estimateMaxBleed() const override;
977 
978  //getters and setters
979  double distanceX() const { return mDistanceX; }
980  void setDistanceX( double d ) { mDistanceX = d; }
981 
982  double distanceY() const { return mDistanceY; }
983  void setDistanceY( double d ) { mDistanceY = d; }
984 
985  double displacementX() const { return mDisplacementX; }
986  void setDisplacementX( double d ) { mDisplacementX = d; }
987 
988  double displacementY() const { return mDisplacementY; }
989  void setDisplacementY( double d ) { mDisplacementY = d; }
990 
991  bool setSubSymbol( QgsSymbolV2* symbol ) override;
992  virtual QgsSymbolV2* subSymbol() override { return mMarkerSymbol; }
993 
994  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
995  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
996 
997  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
998  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
999 
1000  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
1001  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
1002 
1003  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
1004  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
1005 
1006  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
1007  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
1008 
1009  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
1010  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
1011 
1012  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
1013  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
1014 
1015  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
1016  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
1017 
1018  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1019  QgsSymbolV2::OutputUnit outputUnit() const override;
1020 
1021  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1022  QgsMapUnitScale mapUnitScale() const override;
1023 
1024  virtual QSet<QString> usedAttributes() const override;
1025 
1026  protected:
1028  double mDistanceX;
1031  double mDistanceY;
1040 
1041  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) override;
1042 
1043  private:
1044  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
1045  double displacementX, double displacementY );
1046 };
1047 
1049 {
1050  public:
1053 
1054  // static stuff
1055 
1056  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
1057  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
1058 
1059  // implemented from base classes
1060 
1061  QString layerType() const override;
1062 
1063  void startRender( QgsSymbolV2RenderContext& context ) override;
1064 
1065  void stopRender( QgsSymbolV2RenderContext& context ) override;
1066 
1067  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) override;
1068 
1069  QgsStringMap properties() const override;
1070 
1071  QgsSymbolLayerV2* clone() const override;
1072 
1073  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const override;
1074 
1075  void setColor( const QColor& color ) override;
1076 
1077  QgsSymbolV2* subSymbol() override;
1078  bool setSubSymbol( QgsSymbolV2* symbol ) override;
1079 
1080  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
1081  QgsSymbolV2::OutputUnit outputUnit() const override;
1082 
1083  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1084  QgsMapUnitScale mapUnitScale() const override;
1085 
1086  virtual QSet<QString> usedAttributes() const override;
1087 
1088  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
1089  bool pointOnSurface() const { return mPointOnSurface; }
1090 
1091  protected:
1094 };
1095 
1096 #endif
1097 
1098