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