@@ -15,6 +15,10 @@ typedef QList<QgsSymbolLayer *> QgsSymbolLayerList;
15
15
16
16
class QgsSymbol
17
17
{
18
+ %Docstring
19
+
20
+ Abstract base class for all rendered symbols.
21
+ %End
18
22
19
23
%TypeHeaderCode
20
24
#include "qgssymbol.h"
@@ -56,15 +60,20 @@ class QgsSymbol
56
60
57
61
static QgsSymbol *defaultSymbol( QgsWkbTypes::GeometryType geomType ) /Factory/;
58
62
%Docstring
59
- Returns new default symbol for specified geometry type
63
+ Returns a new default symbol for the specified geometry type.
64
+
65
+ The caller takes ownership of the returned object.
60
66
%End
61
67
62
68
SymbolType type() const;
69
+ %Docstring
70
+ Returns the symbol's type.
71
+ %End
63
72
64
73
65
74
QgsSymbolLayerList symbolLayers();
66
75
%Docstring
67
- Returns list of symbol layers contained in the symbol.
76
+ Returns the list of symbol layers contained in the symbol.
68
77
69
78
:return: symbol layers list
70
79
@@ -77,7 +86,7 @@ Returns list of symbol layers contained in the symbol.
77
86
78
87
QgsSymbolLayer *symbolLayer( int layer );
79
88
%Docstring
80
- Returns a specific symbol layers contained in the symbol.
89
+ Returns a specific symbol layer contained in the symbol.
81
90
82
91
:param layer: layer number
83
92
@@ -92,7 +101,7 @@ Returns a specific symbol layers contained in the symbol.
92
101
93
102
int symbolLayerCount() const;
94
103
%Docstring
95
- Returns total number of symbol layers contained in the symbol.
104
+ Returns the total number of symbol layers contained in the symbol.
96
105
97
106
:return: count of symbol layers
98
107
@@ -105,8 +114,8 @@ Returns total number of symbol layers contained in the symbol.
105
114
106
115
bool insertSymbolLayer( int index, QgsSymbolLayer *layer /Transfer/ );
107
116
%Docstring
108
- Insert symbol layer to specified index
109
- Ownership will be transferred.
117
+ Inserts a symbol `` layer`` to specified `` index``.
118
+ Ownership of ``layer`` is transferred to the symbol .
110
119
111
120
:param index: The index at which the layer should be added
112
121
:param layer: The symbol layer to add
@@ -116,23 +125,22 @@ Ownership will be transferred.
116
125
117
126
bool appendSymbolLayer( QgsSymbolLayer *layer /Transfer/ );
118
127
%Docstring
119
- Append symbol layer at the end of the list
120
- Ownership will be transferred.
128
+ Appends a symbol `` layer`` at the end of the current symbol layer list.
129
+ Ownership of ``layer`` is transferred to the symbol .
121
130
122
- :param layer: The layer to add
123
-
124
- :return: True if the layer is added, False if the layer is bad
131
+ :return: true if the layer was successfully added, false if the layer is not compatible with the
132
+ symbol's type().
125
133
%End
126
134
127
135
bool deleteSymbolLayer( int index );
128
136
%Docstring
129
- delete symbol layer at specified index
137
+ Removes and deletes the symbol layer at the specified `` index``.
130
138
%End
131
139
132
140
QgsSymbolLayer *takeSymbolLayer( int index ) /TransferBack/;
133
141
%Docstring
134
- Remove symbol layer from the list and return pointer to it.
135
- Ownership is handed to the caller.
142
+ Removes a symbol layer from the list and returns a pointer to it.
143
+ Ownership of the layer is handed to the caller.
136
144
137
145
:param index: The index of the layer to remove
138
146
@@ -141,7 +149,11 @@ Ownership is handed to the caller.
141
149
142
150
bool changeSymbolLayer( int index, QgsSymbolLayer *layer /Transfer/ );
143
151
%Docstring
144
- delete layer at specified index and set a new one
152
+ Deletes the current layer at the specified ``index`` and replaces it with ``layer``.
153
+ Ownership of ``layer`` is transferred to the symbol.
154
+
155
+ Returns false if ``layer`` is not compatible with the symbol's type(), or
156
+ true if the layer was successfully replaced.
145
157
%End
146
158
147
159
void startRender( QgsRenderContext &context, const QgsFields &fields = QgsFields() );
@@ -168,24 +180,63 @@ Ends the rendering process. This should be called after rendering all desired fe
168
180
%End
169
181
170
182
void setColor( const QColor &color );
183
+ %Docstring
184
+ Sets the ``color`` for the symbol.
185
+
186
+ Calling this method sets the color for each individual symbol layer contained
187
+ within the symbol to ``color``.
188
+
189
+ Locked symbol layers are skipped and are left unchanged.
190
+
191
+ .. seealso:: :py:func:`color`
192
+ %End
193
+
171
194
QColor color() const;
195
+ %Docstring
196
+ Returns the symbol's color.
197
+
198
+ For multi-layer symbols, this method returns the color of the first unlocked symbol
199
+ layer.
200
+
201
+ .. seealso:: :py:func:`setColor`
202
+ %End
172
203
173
204
void drawPreviewIcon( QPainter *painter, QSize size, QgsRenderContext *customContext = 0 );
174
205
%Docstring
175
- Draw icon of the symbol that occupyies area given by size using the painter.
176
- Optionally custom context may be given in order to get rendering of symbols that use map units right.
206
+ Draws an icon of the symbol that occupies an area given by ``size`` using the specified ``painter``.
207
+
208
+ Optionally a custom render context may be given in order to ensure that the preview icon exactly
209
+ matches the settings from that context.
177
210
178
211
.. versionadded:: 2.6
212
+
213
+ .. seealso:: :py:func:`exportImage`
214
+
215
+ .. seealso:: :py:func:`asImage`
179
216
%End
180
217
181
218
void exportImage( const QString &path, const QString &format, QSize size );
182
219
%Docstring
183
- export symbol as image format. PNG and SVG supported
220
+ Export the symbol as an image format, to the specified ``path`` and with the given ``size``.
221
+
222
+ If ``format`` is "SVG" then an SVG file will be created, otherwise a raster image of the
223
+ specified format will be created.
224
+
225
+ .. seealso:: :py:func:`asImage`
226
+
227
+ .. seealso:: :py:func:`drawPreviewIcon`
184
228
%End
185
229
186
230
QImage asImage( QSize size, QgsRenderContext *customContext = 0 );
187
231
%Docstring
188
- Generate symbol as image
232
+ Returns an image of the symbol at the specified ``size``.
233
+
234
+ Optionally a custom render context may be given in order to ensure that the preview icon exactly
235
+ matches the settings from that context.
236
+
237
+ .. seealso:: :py:func:`exportImage`
238
+
239
+ .. seealso:: :py:func:`drawPreviewIcon`
189
240
%End
190
241
191
242
QImage bigSymbolPreviewImage( QgsExpressionContext *expressionContext = 0 );
@@ -194,18 +245,28 @@ Returns a large (roughly 100x100 pixel) preview image for the symbol.
194
245
195
246
:param expressionContext: optional expression context, for evaluation of
196
247
data defined symbol properties
248
+
249
+ .. seealso:: :py:func:`asImage`
250
+
251
+ .. seealso:: :py:func:`drawPreviewIcon`
197
252
%End
198
253
199
254
QString dump() const;
255
+ %Docstring
256
+ Returns a string dump of the symbol's properties.
257
+ %End
200
258
201
259
virtual QgsSymbol *clone() const = 0 /Factory/;
202
260
%Docstring
203
- Gets a deep copy of this symbol.
204
- Needs to be reimplemented by subclasses.
261
+ Returns a deep copy of this symbol.
262
+
205
263
Ownership is transferred to the caller.
206
264
%End
207
265
208
266
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
267
+ %Docstring
268
+ Converts the symbol to a SLD representation.
269
+ %End
209
270
210
271
QgsUnitTypes::RenderUnit outputUnit() const;
211
272
%Docstring
@@ -232,7 +293,25 @@ may use it to specify the units for the line width.
232
293
%End
233
294
234
295
QgsMapUnitScale mapUnitScale() const;
296
+ %Docstring
297
+ Returns the map unit scale for the symbol.
298
+
299
+ If the symbol consists of multiple layers, the map unit scale is only
300
+ returned if all layers have the same scale settings. If the settings differ,
301
+ a default constructed map unit scale is returned.
302
+
303
+ .. seealso:: :py:func:`setMapUnitScale`
304
+ %End
305
+
235
306
void setMapUnitScale( const QgsMapUnitScale &scale );
307
+ %Docstring
308
+ Sets the map unit ``scale`` for the symbol.
309
+
310
+ Calling this method sets the scale for all symbol layers contained within the
311
+ symbol.
312
+
313
+ .. seealso:: :py:func:`mapUnitScale`
314
+ %End
236
315
237
316
qreal opacity() const;
238
317
%Docstring
0 commit comments