Skip to content

Commit e63fedf

Browse files
committed
Improve/extend QgsSymbol docs
1 parent bd84db5 commit e63fedf

File tree

2 files changed

+204
-41
lines changed

2 files changed

+204
-41
lines changed

python/core/auto_generated/symbology/qgssymbol.sip.in

+100-21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ typedef QList<QgsSymbolLayer *> QgsSymbolLayerList;
1515

1616
class QgsSymbol
1717
{
18+
%Docstring
19+
20+
Abstract base class for all rendered symbols.
21+
%End
1822

1923
%TypeHeaderCode
2024
#include "qgssymbol.h"
@@ -56,15 +60,20 @@ class QgsSymbol
5660

5761
static QgsSymbol *defaultSymbol( QgsWkbTypes::GeometryType geomType ) /Factory/;
5862
%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.
6066
%End
6167

6268
SymbolType type() const;
69+
%Docstring
70+
Returns the symbol's type.
71+
%End
6372

6473

6574
QgsSymbolLayerList symbolLayers();
6675
%Docstring
67-
Returns list of symbol layers contained in the symbol.
76+
Returns the list of symbol layers contained in the symbol.
6877

6978
:return: symbol layers list
7079

@@ -77,7 +86,7 @@ Returns list of symbol layers contained in the symbol.
7786

7887
QgsSymbolLayer *symbolLayer( int layer );
7988
%Docstring
80-
Returns a specific symbol layers contained in the symbol.
89+
Returns a specific symbol layer contained in the symbol.
8190

8291
:param layer: layer number
8392

@@ -92,7 +101,7 @@ Returns a specific symbol layers contained in the symbol.
92101

93102
int symbolLayerCount() const;
94103
%Docstring
95-
Returns total number of symbol layers contained in the symbol.
104+
Returns the total number of symbol layers contained in the symbol.
96105

97106
:return: count of symbol layers
98107

@@ -105,8 +114,8 @@ Returns total number of symbol layers contained in the symbol.
105114

106115
bool insertSymbolLayer( int index, QgsSymbolLayer *layer /Transfer/ );
107116
%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.
110119

111120
:param index: The index at which the layer should be added
112121
:param layer: The symbol layer to add
@@ -116,23 +125,22 @@ Ownership will be transferred.
116125

117126
bool appendSymbolLayer( QgsSymbolLayer *layer /Transfer/ );
118127
%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.
121130

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().
125133
%End
126134

127135
bool deleteSymbolLayer( int index );
128136
%Docstring
129-
delete symbol layer at specified index
137+
Removes and deletes the symbol layer at the specified ``index``.
130138
%End
131139

132140
QgsSymbolLayer *takeSymbolLayer( int index ) /TransferBack/;
133141
%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.
136144

137145
:param index: The index of the layer to remove
138146

@@ -141,7 +149,11 @@ Ownership is handed to the caller.
141149

142150
bool changeSymbolLayer( int index, QgsSymbolLayer *layer /Transfer/ );
143151
%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.
145157
%End
146158

147159
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
168180
%End
169181

170182
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+
171194
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
172203

173204
void drawPreviewIcon( QPainter *painter, QSize size, QgsRenderContext *customContext = 0 );
174205
%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.
177210

178211
.. versionadded:: 2.6
212+
213+
.. seealso:: :py:func:`exportImage`
214+
215+
.. seealso:: :py:func:`asImage`
179216
%End
180217

181218
void exportImage( const QString &path, const QString &format, QSize size );
182219
%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`
184228
%End
185229

186230
QImage asImage( QSize size, QgsRenderContext *customContext = 0 );
187231
%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`
189240
%End
190241

191242
QImage bigSymbolPreviewImage( QgsExpressionContext *expressionContext = 0 );
@@ -194,18 +245,28 @@ Returns a large (roughly 100x100 pixel) preview image for the symbol.
194245

195246
:param expressionContext: optional expression context, for evaluation of
196247
data defined symbol properties
248+
249+
.. seealso:: :py:func:`asImage`
250+
251+
.. seealso:: :py:func:`drawPreviewIcon`
197252
%End
198253

199254
QString dump() const;
255+
%Docstring
256+
Returns a string dump of the symbol's properties.
257+
%End
200258

201259
virtual QgsSymbol *clone() const = 0 /Factory/;
202260
%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+
205263
Ownership is transferred to the caller.
206264
%End
207265

208266
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
267+
%Docstring
268+
Converts the symbol to a SLD representation.
269+
%End
209270

210271
QgsUnitTypes::RenderUnit outputUnit() const;
211272
%Docstring
@@ -232,7 +293,25 @@ may use it to specify the units for the line width.
232293
%End
233294

234295
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+
235306
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
236315

237316
qreal opacity() const;
238317
%Docstring

0 commit comments

Comments
 (0)