QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 
123  protected:
124  QBrush mBrush;
125  QBrush mSelBrush;
126  Qt::BrushStyle mBrushStyle;
127  QColor mBorderColor;
128  Qt::PenStyle mBorderStyle;
129  double mBorderWidth;
132  Qt::PenJoinStyle mPenJoinStyle;
133  QPen mPen;
134  QPen mSelPen;
135 
136  QPointF mOffset;
139 
140  private:
141  //helper functions for data defined symbology
142  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QBrush& brush, QPen& pen, QPen& selPen );
143 };
144 
146 
148 {
149  public:
150 
152  {
154  ColorRamp
155  };
156 
158  {
161  Conical
162  };
163 
165  {
167  Viewport
168  };
169 
171  {
174  Repeat
175  };
176 
178  QColor color2 = Qt::white,
179  GradientColorType gradientColorType = SimpleTwoColor,
180  GradientType gradientType = Linear,
181  GradientCoordinateMode coordinateMode = Feature,
182  GradientSpread gradientSpread = Pad
183  );
184 
185  virtual ~QgsGradientFillSymbolLayerV2();
186 
187  // static stuff
188 
189  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
190 
191  // implemented from base classes
192 
193  QString layerType() const;
194 
195  void startRender( QgsSymbolV2RenderContext& context );
196 
197  void stopRender( QgsSymbolV2RenderContext& context );
198 
199  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
200 
201  QgsStringMap properties() const;
202 
203  QgsSymbolLayerV2* clone() const;
204 
205  double estimateMaxBleed() const;
206 
208  GradientType gradientType() const { return mGradientType; }
209  void setGradientType( GradientType gradientType ) { mGradientType = gradientType; }
210 
212  GradientColorType gradientColorType() const { return mGradientColorType; }
213  void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
214 
216  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
217  void setColorRamp( QgsVectorColorRampV2* ramp );
218 
220  QColor color2() const { return mColor2; }
221  void setColor2( QColor color2 ) { mColor2 = color2; }
222 
224  GradientCoordinateMode coordinateMode() const { return mCoordinateMode; }
225  void setCoordinateMode( GradientCoordinateMode coordinateMode ) { mCoordinateMode = coordinateMode; }
226 
228  GradientSpread gradientSpread() const { return mGradientSpread; }
229  void setGradientSpread( GradientSpread gradientSpread ) { mGradientSpread = gradientSpread; }
230 
232  void setReferencePoint1( QPointF referencePoint ) { mReferencePoint1 = referencePoint; }
233  QPointF referencePoint1() const { return mReferencePoint1; }
234 
236  void setReferencePoint1IsCentroid( bool isCentroid ) { mReferencePoint1IsCentroid = isCentroid; }
237  bool referencePoint1IsCentroid() const { return mReferencePoint1IsCentroid; }
238 
240  void setReferencePoint2( QPointF referencePoint ) { mReferencePoint2 = referencePoint; }
241  QPointF referencePoint2() const { return mReferencePoint2; }
242 
244  void setReferencePoint2IsCentroid( bool isCentroid ) { mReferencePoint2IsCentroid = isCentroid; }
245  bool referencePoint2IsCentroid() const { return mReferencePoint2IsCentroid; }
246 
248  void setAngle( double angle ) { mAngle = angle; }
249  double angle() const { return mAngle; }
250 
252  void setOffset( QPointF offset ) { mOffset = offset; }
253  QPointF offset() const { return mOffset; }
254 
256  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
257  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
258 
259  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
260  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
261 
264 
265  void setMapUnitScale( const QgsMapUnitScale &scale );
267 
268  protected:
269  QBrush mBrush;
270  QBrush mSelBrush;
271 
273  QColor mColor2;
278 
283  double mAngle;
284 
285  QPointF mOffset;
288 
289  private:
290 
291  //helper functions for data defined symbology
292  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, const QPolygonF& points );
293 
295  void applyGradient( const QgsSymbolV2RenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
296  const GradientColorType &gradientColorType, QgsVectorColorRampV2 *gradientRamp, const GradientType &gradientType,
297  const GradientCoordinateMode &coordinateMode, const GradientSpread &gradientSpread,
298  const QPointF &referencePoint1, const QPointF &referencePoint2, const double angle );
299 
301  QPointF rotateReferencePoint( const QPointF & refPoint, double angle );
302 };
303 
305 {
306  public:
307 
309  {
311  ColorRamp
312  };
313 
314  QgsShapeburstFillSymbolLayerV2( QColor color = DEFAULT_SIMPLEFILL_COLOR, QColor color2 = Qt::white,
315  ShapeburstColorType colorType = SimpleTwoColor,
316  int blurRadius = 0, bool useWholeShape = true, double maxDistance = 5 );
317 
319 
320  // static stuff
321 
322  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
323 
324  // implemented from base classes
325 
326  QString layerType() const;
327 
328  void startRender( QgsSymbolV2RenderContext& context );
329 
330  void stopRender( QgsSymbolV2RenderContext& context );
331 
332  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
333 
334  QgsStringMap properties() const;
335 
336  QgsSymbolLayerV2* clone() const;
337 
338  double estimateMaxBleed() const;
339 
345  void setBlurRadius( int blurRadius ) { mBlurRadius = blurRadius; }
351  int blurRadius() const { return mBlurRadius; }
352 
360  void setUseWholeShape( double useWholeShape ) { mUseWholeShape = useWholeShape; }
367  double useWholeShape() const { return mUseWholeShape; }
368 
376  void setMaxDistance( double maxDistance ) { mMaxDistance = maxDistance; }
384  double maxDistance() const { return mMaxDistance; }
385 
392  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
399  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
400 
401  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
402  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
403 
413  void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
423  ShapeburstColorType colorType() const { return mColorType; }
424 
431  void setColorRamp( QgsVectorColorRampV2* ramp );
438  QgsVectorColorRampV2* colorRamp() { return mGradientRamp; }
439 
446  void setColor2( QColor color2 ) { mColor2 = color2; }
453  QColor color2() const { return mColor2; }
454 
461  void setIgnoreRings( double ignoreRings ) { mIgnoreRings = ignoreRings; }
467  double ignoreRings() const { return mIgnoreRings; }
468 
475  void setOffset( QPointF offset ) { mOffset = offset; }
482  QPointF offset() const { return mOffset; }
483 
490  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
497  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
498 
499  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
500  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
501 
504 
505  void setMapUnitScale( const QgsMapUnitScale &scale );
507 
508  protected:
509  QBrush mBrush;
510  QBrush mSelBrush;
511 
513 
515  double mMaxDistance;
518 
520  QColor mColor2;
523 
525 
526  QPointF mOffset;
529 
530  private:
531 
532  //helper functions for data defined symbology
533  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int& blurRadius, bool& useWholeShape,
534  double& maxDistance , bool &ignoreRings );
535 
536  /* distance transform of a 1d function using squared distance */
537  void distanceTransform1d( double *f, int n, int *v, double *z, double *d );
538  /* distance transform of 2d function using squared distance */
539  void distanceTransform2d( double * im, int width, int height );
540  /* distance transform of a binary QImage */
541  double * distanceTransform( QImage * im );
542 
543  /* fills a QImage with values from an array of doubles containing squared distance transform values */
544  void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRampV2* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
545 };
546 
549 {
550  public:
552  virtual ~QgsImageFillSymbolLayer();
553  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
554 
555  virtual QgsSymbolV2* subSymbol() { return mOutline; }
556  virtual bool setSubSymbol( QgsSymbolV2* symbol );
557 
558  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
559  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
560 
561  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
562  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
563 
566 
567  void setMapUnitScale( const QgsMapUnitScale& scale );
569 
570  virtual double estimateMaxBleed() const;
571 
572  virtual double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const;
573  virtual QColor dxfColor( const QgsSymbolV2RenderContext& context ) const;
574  virtual Qt::PenStyle dxfPenStyle() const;
575 
576  protected:
577  QBrush mBrush;
578  double mNextAngle; // mAngle / data defined angle
579 
584 
587 
588  virtual void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context ) { Q_UNUSED( context ); }
589 };
590 
594 {
595  public:
596  QgsSVGFillSymbolLayer( const QString& svgFilePath = "", double width = 20, double rotation = 0.0 );
597  QgsSVGFillSymbolLayer( const QByteArray& svgData, double width = 20, double rotation = 0.0 );
599 
600  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
601  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
602 
603  // implemented from base classes
604 
605  QString layerType() const;
606 
607  void startRender( QgsSymbolV2RenderContext& context );
608  void stopRender( QgsSymbolV2RenderContext& context );
609 
610  QgsStringMap properties() const;
611 
612  QgsSymbolLayerV2* clone() const;
613 
614  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
615 
616  //getters and setters
617  void setSvgFilePath( const QString& svgPath );
618  QString svgFilePath() const { return mSvgFilePath; }
619  void setPatternWidth( double width ) { mPatternWidth = width;}
620  double patternWidth() const { return mPatternWidth; }
621 
622  void setSvgFillColor( const QColor& c ) { mSvgFillColor = c; }
623  QColor svgFillColor() const { return mSvgFillColor; }
624  void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; }
625  QColor svgOutlineColor() const { return mSvgOutlineColor; }
626  void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; }
627  double svgOutlineWidth() const { return mSvgOutlineWidth; }
628 
629  void setPatternWidthUnit( QgsSymbolV2::OutputUnit unit ) { mPatternWidthUnit = unit; }
630  QgsSymbolV2::OutputUnit patternWidthUnit() const { return mPatternWidthUnit; }
631 
632  void setPatternWidthMapUnitScale( const QgsMapUnitScale& scale ) { mPatternWidthMapUnitScale = scale; }
633  const QgsMapUnitScale& patternWidthMapUnitScale() const { return mPatternWidthMapUnitScale; }
634 
635  void setSvgOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSvgOutlineWidthUnit = unit; }
636  QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const { return mSvgOutlineWidthUnit; }
637 
638  void setSvgOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSvgOutlineWidthMapUnitScale = scale; }
639  const QgsMapUnitScale& svgOutlineWidthMapUnitScale() const { return mSvgOutlineWidthMapUnitScale; }
640 
643 
644  void setMapUnitScale( const QgsMapUnitScale &scale );
646 
647  protected:
652 
654  QByteArray mSvgData;
656  QString mSvgFilePath;
658  QRectF mSvgViewBox;
661  QImage* mSvgPattern;
662 
663  //param(fill), param(outline), param(outline-width) are going
664  //to be replaced in memory
670 
671  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );
672 
673  private:
675  void storeViewBox();
676  void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath
677 
679  void applyPattern( QBrush& brush, const QString& svgFilePath, double patternWidth, QgsSymbolV2::OutputUnit patternWidthUnit, const QColor& svgFillColor, const QColor& svgOutlineColor,
680  double svgOutlineWidth, QgsSymbolV2::OutputUnit svgOutlineWidthUnit, const QgsSymbolV2RenderContext& context, const QgsMapUnitScale& patternWidthMapUnitScale , const QgsMapUnitScale &svgOutlineWidthMapUnitScale );
681 };
682 
684 {
685  public:
688 
689  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
690  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
691 
692  QString layerType() const;
693 
694  void startRender( QgsSymbolV2RenderContext& context );
695 
696  void stopRender( QgsSymbolV2RenderContext& context );
697 
698  QgsStringMap properties() const;
699 
700  QgsSymbolLayerV2* clone() const;
701 
702  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
703 
704  double estimateMaxBleed() const;
705 
706  QString ogrFeatureStyleWidth( double widthScaleFactor ) const;
707 
708  //getters and setters
709  void setLineAngle( double a ) { mLineAngle = a; }
710  double lineAngle() const { return mLineAngle; }
711  void setDistance( double d ) { mDistance = d; }
712  double distance() const { return mDistance; }
713  void setLineWidth( double w );
714  double lineWidth() const { return mLineWidth; }
715  void setColor( const QColor& c );
716  QColor color() const { return mColor; }
717  void setOffset( double offset ) { mOffset = offset; }
718  double offset() const { return mOffset; }
719 
720  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
721  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
722 
723  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
724  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
725 
726  void setLineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mLineWidthUnit = unit; }
727  QgsSymbolV2::OutputUnit lineWidthUnit() const { return mLineWidthUnit; }
728 
729  void setLineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mLineWidthMapUnitScale = scale; }
730  const QgsMapUnitScale& lineWidthMapUnitScale() const { return mLineWidthMapUnitScale; }
731 
732  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
733  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
734 
735  void setOffsetMapUnitScale( const QgsMapUnitScale& scale ) { mOffsetMapUnitScale = scale; }
736  const QgsMapUnitScale& offsetMapUnitScale() const { return mOffsetMapUnitScale; }
737 
740 
741  void setMapUnitScale( const QgsMapUnitScale& scale );
743 
744  bool setSubSymbol( QgsSymbolV2* symbol );
746 
747  protected:
749  double mDistance;
753  double mLineWidth;
756  QColor mColor;
758  double mLineAngle;
760  double mOffset;
763 
764  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );
765 
766  private:
768  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double lineAngle, double distance, double lineWidth, const QColor& color );
769 
772 };
773 
775 {
776  public:
779 
780  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
781  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
782 
783  QString layerType() const;
784 
785  void startRender( QgsSymbolV2RenderContext& context );
786 
787  void stopRender( QgsSymbolV2RenderContext& context );
788 
789  QgsStringMap properties() const;
790 
791  QgsSymbolLayerV2* clone() const;
792 
793  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
794 
795  double estimateMaxBleed() const;
796 
797  //getters and setters
798  double distanceX() const { return mDistanceX; }
799  void setDistanceX( double d ) { mDistanceX = d; }
800 
801  double distanceY() const { return mDistanceY; }
802  void setDistanceY( double d ) { mDistanceY = d; }
803 
804  double displacementX() const { return mDisplacementX; }
805  void setDisplacementX( double d ) { mDisplacementX = d; }
806 
807  double displacementY() const { return mDisplacementY; }
808  void setDisplacementY( double d ) { mDisplacementY = d; }
809 
810  bool setSubSymbol( QgsSymbolV2* symbol );
811  virtual QgsSymbolV2* subSymbol() { return mMarkerSymbol; }
812 
813  void setDistanceXUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceXUnit = unit; }
814  QgsSymbolV2::OutputUnit distanceXUnit() const { return mDistanceXUnit; }
815 
816  void setDistanceXMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceXMapUnitScale = scale; }
817  const QgsMapUnitScale& distanceXMapUnitScale() const { return mDistanceXMapUnitScale; }
818 
819  void setDistanceYUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceYUnit = unit; }
820  QgsSymbolV2::OutputUnit distanceYUnit() const { return mDistanceYUnit; }
821 
822  void setDistanceYMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceYMapUnitScale = scale; }
823  const QgsMapUnitScale& distanceYMapUnitScale() const { return mDistanceYMapUnitScale; }
824 
825  void setDisplacementXUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementXUnit = unit; }
826  QgsSymbolV2::OutputUnit displacementXUnit() const { return mDisplacementXUnit; }
827 
828  void setDisplacementXMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementXMapUnitScale = scale; }
829  const QgsMapUnitScale& displacementXMapUnitScale() const { return mDisplacementXMapUnitScale; }
830 
831  void setDisplacementYUnit( QgsSymbolV2::OutputUnit unit ) { mDisplacementYUnit = unit; }
832  QgsSymbolV2::OutputUnit displacementYUnit() const { return mDisplacementYUnit; }
833 
834  void setDisplacementYMapUnitScale( const QgsMapUnitScale& scale ) { mDisplacementYMapUnitScale = scale; }
835  const QgsMapUnitScale& displacementYMapUnitScale() const { return mDisplacementYMapUnitScale; }
836 
839 
840  void setMapUnitScale( const QgsMapUnitScale &scale );
842 
843  virtual QSet<QString> usedAttributes() const;
844 
845  protected:
847  double mDistanceX;
850  double mDistanceY;
859 
860  void applyDataDefinedSettings( const QgsSymbolV2RenderContext& context );
861 
862  private:
863  void applyPattern( const QgsSymbolV2RenderContext& context, QBrush& brush, double distanceX, double distanceY,
864  double displacementX, double displacementY );
865 };
866 
868 {
869  public:
872 
873  // static stuff
874 
875  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
876  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
877 
878  // implemented from base classes
879 
880  QString layerType() const;
881 
882  void startRender( QgsSymbolV2RenderContext& context );
883 
884  void stopRender( QgsSymbolV2RenderContext& context );
885 
886  void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
887 
888  QgsStringMap properties() const;
889 
890  QgsSymbolLayerV2* clone() const;
891 
892  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
893 
894  void setColor( const QColor& color );
895 
897  bool setSubSymbol( QgsSymbolV2* symbol );
898 
901 
902  void setMapUnitScale( const QgsMapUnitScale &scale );
904 
905  virtual QSet<QString> usedAttributes() const;
906 
907  void setPointOnSurface( bool pointOnSurface ) { mPointOnSurface = pointOnSurface; }
908  bool pointOnSurface() const { return mPointOnSurface; }
909 
910  protected:
913 };
914 
915 #endif
916 
917 
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)
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)
virtual Qt::PenStyle dxfPenStyle() const
double ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
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 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 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 mDisplacementXUnit
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
double useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
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:416
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...
QgsSymbolV2::OutputUnit mDisplacementYUnit
virtual void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
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
double mOffset
Offset perpendicular to line direction.
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.
const QgsMapUnitScale & offsetMapUnitScale() const
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
QPointF offset() const
Returns the offset for the shapeburst fill.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & distanceXMapUnitScale() const
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)
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.
double widthScaleFactor
Definition: qgssvgcache.cpp:79
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
QgsSymbolV2::OutputUnit mDistanceXUnit
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & distanceYMapUnitScale() const
QgsSymbolV2::OutputUnit displacementYUnit() const
QgsSymbolV2::OutputUnit mBorderWidthUnit
Qt::PenJoinStyle penJoinStyle() const
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
void setUseWholeShape(double useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
QgsSymbolV2::OutputUnit mDistanceUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QColor outlineColor() const
Get outline color.
QgsLineSymbolV2 * mFillLineSymbol
Fill line.
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit displacementXUnit() const
void setGradientSpread(GradientSpread gradientSpread)
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 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.
void setIgnoreRings(double ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
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 mPatternWidth
Width of the pattern (in output units)
#define DEFAULT_SIMPLEFILL_COLOR
void setBorderStyle(Qt::PenStyle borderStyle)