Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgssymbollayerv2.h
Go to the documentation of this file.
1 #ifndef QGSSYMBOLLAYERV2_H
2 #define QGSSYMBOLLAYERV2_H
3 
4 #include <QMap>
5 
6 #include <QColor>
7 #include <QPointF>
8 
9 #include "qgssymbolv2.h"
10 
11 #include "qgssymbollayerv2utils.h" // QgsStringMap
12 
13 class QPainter;
14 class QSize;
15 class QPolygonF;
16 
17 class QgsRenderContext;
18 class QgsSymbolV2;
19 
20 
21 class CORE_EXPORT QgsSymbolLayerV2
22 {
23  public:
24 
25  // not necessarily supported by all symbol layers...
26  virtual void setColor( const QColor& color ) { mColor = color; }
27  virtual QColor color() const { return mColor; }
28 
29  virtual ~QgsSymbolLayerV2() {}
30 
31  virtual QString layerType() const = 0;
32 
33  virtual void startRender( QgsSymbolV2RenderContext& context ) = 0;
34  virtual void stopRender( QgsSymbolV2RenderContext& context ) = 0;
35 
36  virtual QgsSymbolLayerV2* clone() const = 0;
37 
38  virtual QgsStringMap properties() const = 0;
39 
40  virtual void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) = 0;
41 
42  virtual QgsSymbolV2* subSymbol() { return NULL; }
43  // set layer's subsymbol. takes ownership of the passed symbol
44  virtual bool setSubSymbol( QgsSymbolV2* symbol ) { delete symbol; return false; }
45 
46  QgsSymbolV2::SymbolType type() const { return mType; }
47 
48  void setLocked( bool locked ) { mLocked = locked; }
49  bool isLocked() const { return mLocked; }
50 
51  // used only with rending with symbol levels is turned on (0 = first pass, 1 = second, ...)
52  void setRenderingPass( int renderingPass ) { mRenderingPass = renderingPass; }
53  int renderingPass() const { return mRenderingPass; }
54 
55  protected:
56  QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false )
57  : mType( type ), mLocked( locked ), mRenderingPass( 0 ) {}
58 
60  bool mLocked;
61  QColor mColor;
63 
64  // Configuration of selected symbology implementation
65  static const bool selectionIsOpaque = true; // Selection ignores symbol alpha
66  static const bool selectFillBorder = false; // Fill symbol layer also selects border symbology
67  static const bool selectFillStyle = false; // Fill symbol uses symbol layer style..
68 
69 };
70 
72 
73 class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
74 {
75  public:
76  virtual void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) = 0;
77 
78  void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
79 
80  void setAngle( double angle ) { mAngle = angle; }
81  double angle() const { return mAngle; }
82 
83  void setSize( double size ) { mSize = size; }
84  double size() const { return mSize; }
85 
86  void setOffset( QPointF offset ) { mOffset = offset; }
87  QPointF offset() { return mOffset; }
88 
89  protected:
90  QgsMarkerSymbolLayerV2( bool locked = false );
91 
92  double mAngle;
93  double mSize;
94  QPointF mOffset;
95 };
96 
97 class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
98 {
99  public:
100  virtual void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) = 0;
101 
103  virtual void renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
104 
105  virtual void setWidth( double width ) { mWidth = width; }
106  virtual double width() const { return mWidth; }
107 
108  void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
109 
110  protected:
111  QgsLineSymbolLayerV2( bool locked = false );
112 
113  double mWidth;
114 };
115 
116 class CORE_EXPORT QgsFillSymbolLayerV2 : public QgsSymbolLayerV2
117 {
118  public:
119  virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) = 0;
120 
121  void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
122 
123  void setAngle( double angle ) { mAngle = angle; }
124  double angle() const { return mAngle; }
125 
126  protected:
127  QgsFillSymbolLayerV2( bool locked = false );
129  void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings );
130 
131  double mAngle;
132 };
133 
134 class QgsSymbolLayerV2Widget;
135 
136 #endif