-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsmarkersymbollayerv2.h
213 lines (148 loc) · 6.74 KB
/
qgsmarkersymbollayerv2.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/***************************************************************************
qgsmarkersymbollayerv2.h
---------------------
begin : November 2009
copyright : (C) 2009 by Martin Dobias
email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMARKERSYMBOLLAYERV2_H
#define QGSMARKERSYMBOLLAYERV2_H
#include "qgssymbollayerv2.h"
#define DEFAULT_SIMPLEMARKER_NAME "circle"
#define DEFAULT_SIMPLEMARKER_COLOR QColor(255,0,0)
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR QColor(0,0,0)
#define DEFAULT_SIMPLEMARKER_SIZE DEFAULT_POINT_SIZE
#define DEFAULT_SIMPLEMARKER_ANGLE 0
#define DEFAULT_SCALE_METHOD QgsSymbolV2::ScaleArea
#include <QPen>
#include <QBrush>
#include <QPicture>
#include <QPolygonF>
#include <QFont>
class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
{
public:
QgsSimpleMarkerSymbolLayerV2( QString name = DEFAULT_SIMPLEMARKER_NAME,
QColor color = DEFAULT_SIMPLEMARKER_COLOR,
QColor borderColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR,
double size = DEFAULT_SIMPLEMARKER_SIZE,
double angle = DEFAULT_SIMPLEMARKER_ANGLE,
QgsSymbolV2::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
// static stuff
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
static QgsSymbolLayerV2* createFromSld( QDomElement &element );
// implemented from base classes
QString layerType() const;
void startRender( QgsSymbolV2RenderContext& context );
void stopRender( QgsSymbolV2RenderContext& context );
void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
QgsSymbolLayerV2* clone() const;
void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
QString ogrFeatureStyle( double widthScaleFactor ) const;
QString name() const { return mName; }
void setName( QString name ) { mName = name; }
QColor borderColor() const { return mBorderColor; }
void setBorderColor( QColor color ) { mBorderColor = color; }
protected:
void drawMarker( QPainter* p, QgsSymbolV2RenderContext& context );
bool prepareShape();
bool preparePath();
void prepareCache( QgsSymbolV2RenderContext& context );
QColor mBorderColor;
QPen mPen;
QBrush mBrush;
QPolygonF mPolygon;
QPainterPath mPath;
QString mName;
QImage mCache;
QPen mSelPen;
QBrush mSelBrush;
QImage mSelCache;
bool mUsingCache;
};
//////////
#define DEFAULT_SVGMARKER_NAME "/symbol/Star1.svg"
#define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
#define DEFAULT_SVGMARKER_ANGLE 0
class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
{
public:
QgsSvgMarkerSymbolLayerV2( QString name = DEFAULT_SVGMARKER_NAME,
double size = DEFAULT_SVGMARKER_SIZE,
double angle = DEFAULT_SVGMARKER_ANGLE );
// static stuff
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
static QgsSymbolLayerV2* createFromSld( QDomElement &element );
// implemented from base classes
QString layerType() const;
void startRender( QgsSymbolV2RenderContext& context );
void stopRender( QgsSymbolV2RenderContext& context );
void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
QgsSymbolLayerV2* clone() const;
void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
QString path() const { return mPath; }
void setPath( QString path );
QColor fillColor() const { return mFillColor; }
void setFillColor( const QColor& c ) { mFillColor = c; }
QColor outlineColor() const { return mOutlineColor; }
void setOutlineColor( const QColor& c ) { mOutlineColor = c; }
double outlineWidth() const { return mOutlineWidth; }
void setOutlineWidth( double w ) { mOutlineWidth = w; }
protected:
QString mPath;
//param(fill), param(outline), param(outline-width) are going
//to be replaced in memory
QColor mFillColor;
QColor mOutlineColor;
double mOutlineWidth;
double mOrigSize;
};
//////////
#define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
#define MM2POINT(x) ( (x) * 72 / 25.4 )
#define DEFAULT_FONTMARKER_FONT "Dingbats"
#define DEFAULT_FONTMARKER_CHR QChar('A')
#define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
#define DEFAULT_FONTMARKER_COLOR QColor(Qt::black)
#define DEFAULT_FONTMARKER_ANGLE 0
class CORE_EXPORT QgsFontMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
{
public:
QgsFontMarkerSymbolLayerV2( QString fontFamily = DEFAULT_FONTMARKER_FONT,
QChar chr = DEFAULT_FONTMARKER_CHR,
double pointSize = DEFAULT_FONTMARKER_SIZE,
QColor color = DEFAULT_FONTMARKER_COLOR,
double angle = DEFAULT_FONTMARKER_ANGLE );
// static stuff
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
static QgsSymbolLayerV2* createFromSld( QDomElement &element );
// implemented from base classes
QString layerType() const;
void startRender( QgsSymbolV2RenderContext& context );
void stopRender( QgsSymbolV2RenderContext& context );
void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
QgsStringMap properties() const;
QgsSymbolLayerV2* clone() const;
void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
// new methods
QString fontFamily() const { return mFontFamily; }
void setFontFamily( QString family ) { mFontFamily = family; }
QChar character() const { return mChr; }
void setCharacter( QChar ch ) { mChr = ch; }
protected:
QString mFontFamily;
QChar mChr;
QPointF mChrOffset;
QFont mFont;
double mOrigSize;
};
#endif