Skip to content

Commit 123a60e

Browse files
committedDec 10, 2015
[sip, doxygen] Geometry modifier bindings
and lots of doxymentation
1 parent 17f9d55 commit 123a60e

13 files changed

+151
-134
lines changed
 

‎python/core/core.sip

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,7 @@
290290
%Include symbology-ng/qgslinesymbollayerv2.sip
291291
%Include symbology-ng/qgsmarkersymbollayerv2.sip
292292
%Include symbology-ng/qgssymbollayerv2registry.sip
293-
%Include symbology-ng/qgspolygongeneratorsymbollayerv2.sip
294-
%Include symbology-ng/qgslinegeneratorsymbollayerv2.sip
295-
%Include symbology-ng/qgspointgeneratorsymbollayerv2.sip
293+
%Include symbology-ng/qgsgeometrygeneratorsymbollayerv2.sip
296294

297295
%Include symbology-ng/qgssymbologyv2conversion.sip
298296

‎python/core/symbology-ng/qgslinegeneratorsymbollayerv2.sip renamed to ‎python/core/symbology-ng/qgsgeometrygeneratorsymbollayerv2.sip

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgslinegeneratorsymbollayerv2.sip
2+
qgsgeometrygeneratorsymbollayerv2.sip
33
---------------------
44
begin : November 2015
55
copyright : (C) 2015 by Matthias Kuhn
@@ -12,18 +12,26 @@
1212
* (at your option) any later version. *
1313
* *
1414
***************************************************************************/
15-
class QgsLineGeneratorSymbolLayerV2 : QgsLineSymbolLayerV2
15+
class QgsGeometryGeneratorSymbolLayerV2 : QgsSymbolLayerV2
1616
{
1717
%TypeHeaderCode
18-
#include "qgslinegeneratorsymbollayerv2.h"
18+
#include "qgsgeometrygeneratorsymbollayerv2.h"
1919
%End
2020
public:
2121
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
2222

23-
QgsLineGeneratorSymbolLayerV2( QgsLineSymbolV2* symbol, const QgsStringMap& properties = QgsStringMap() );
24-
2523
QString layerType() const;
2624

25+
/**
26+
* Set the type of symbol which should be created.
27+
* Should match with the return type of the expression.
28+
*
29+
* @param symbolType The symbol type which shall be used below this symbol.
30+
*/
31+
void setSymbolType( QgsSymbolV2::SymbolType symbolType );
32+
33+
QgsSymbolV2::SymbolType symbolType() const;
34+
2735
void startRender( QgsSymbolV2RenderContext& context );
2836

2937
void stopRender( QgsSymbolV2RenderContext& context );
@@ -36,6 +44,9 @@ class QgsLineGeneratorSymbolLayerV2 : QgsLineSymbolLayerV2
3644

3745
void setGeometryExpression( const QString& exp );
3846

47+
/**
48+
* Get the expression to generate this geometry.
49+
*/
3950
QString geometryExpression() const;
4051

4152
virtual QgsSymbolV2* subSymbol();
@@ -49,8 +60,8 @@ class QgsLineGeneratorSymbolLayerV2 : QgsLineSymbolLayerV2
4960
//! care about the geometry of its parents.
5061
bool isCompatibleWithSymbol( QgsSymbolV2* symbol );
5162

52-
virtual void renderPolyline( const QPolygonF& point, QgsSymbolV2RenderContext& context );
63+
virtual void render( QgsSymbolV2RenderContext& context );
5364

5465
private:
55-
QgsLineGeneratorSymbolLayerV2( const QgsLineGeneratorSymbolLayerV2& copy );
66+
QgsGeometryGeneratorSymbolLayerV2( const QgsGeometryGeneratorSymbolLayerV2& copy );
5667
};

‎python/core/symbology-ng/qgspointgeneratorsymbollayerv2.sip

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎python/core/symbology-ng/qgspolygongeneratorsymbollayerv2.sip

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎python/core/symbology-ng/qgssymbollayerv2.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class QgsSymbolLayerV2
5858
sipType = sipType_QgsFillSymbolLayerV2;
5959
break;
6060

61-
default:
62-
sipType = 0;
61+
case QgsSymbolV2::Hybrid:
62+
sipType = sipType_QgsGeometryGeneratorSymbolLayerV2;
6363
break;
6464
}
6565
%End

‎python/core/symbology-ng/qgssymbolv2.sip

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ class QgsSymbolV2
160160
*/
161161
bool clipFeaturesToExtent() const;
162162

163+
/**
164+
* Return a list of attributes required to render this feature.
165+
* This should include any attributes required by the symbology including
166+
* the ones required by expressions.
167+
*/
163168
QSet<QString> usedAttributes() const;
164169

165170
/** Returns whether the symbol utilises any data defined properties.
@@ -170,10 +175,41 @@ class QgsSymbolV2
170175
void setLayer( const QgsVectorLayer* layer );
171176
const QgsVectorLayer* layer() const;
172177

178+
/**
179+
* Render a feature.
180+
*/
181+
void renderFeature( const QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false, int currentVertexMarkerType = 0, int currentVertexMarkerSize = 0 );
182+
173183
protected:
174184
QgsSymbolV2( SymbolType type, const QgsSymbolLayerV2List& layers /Transfer/ ); // can't be instantiated
175185

186+
/**
187+
* Creates a point in screen coordinates from a wkb string in map
188+
* coordinates
189+
*/
190+
static const unsigned char* _getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb );
191+
/**
192+
* Creates a line string in screen coordinates from a wkb string in map
193+
* coordinates
194+
*/
195+
static const unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
196+
/**
197+
* Creates a polygon in screen coordinates from a wkb string in map
198+
* coordinates
199+
*/
200+
static const unsigned char* _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
201+
176202
QgsSymbolLayerV2List cloneLayers() const /Factory/;
203+
/**
204+
* Renders a context using a particular symbol layer without passing in a
205+
* geometry. This is used as fallback, if the symbol being rendered is not
206+
* compatible with the specified layer. In such a case, this method can be
207+
* called and will call the layer's rendering method anyway but the
208+
* geometry passed to the layer will be empty.
209+
* This is required for layers that generate their own geometry from other
210+
* information in the rendering context.
211+
*/
212+
void renderUsingLayer( QgsSymbolLayerV2* layer, QgsSymbolV2RenderContext& context );
177213

178214
//! check whether a symbol layer type can be used within the symbol
179215
//! (marker-marker, line-line, fill-fill/line)

‎python/gui/symbology-ng/qgssymbollayerv2widget.sip

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,18 @@ class QgsSymbolLayerV2Widget : QWidget
6363
virtual QString dataDefinedPropertyLabel( const QString &entryName ) /Deprecated/;
6464

6565
signals:
66+
/**
67+
* Should be emitted whenever configuration changes happened on this symbol layer configuration.
68+
* If the subsymbol is changed, {@link symbolChanged()} should be emitted instead.
69+
*/
6670
void changed();
71+
/**
72+
* Should be emitted whenever the sub symbol changed on this symbol layer configuration.
73+
* Normally {@link changed()} should be preferred.
74+
*
75+
* @see {@link changed()}
76+
*/
77+
void symbolChanged();
6778

6879
protected slots:
6980
void updateDataDefinedProperty();
@@ -424,3 +435,19 @@ class QgsCentroidFillSymbolLayerV2Widget : QgsSymbolLayerV2Widget
424435
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
425436
virtual QgsSymbolLayerV2* symbolLayer();
426437
};
438+
439+
440+
class QgsGeometryGeneratorSymbolLayerWidget : QgsSymbolLayerV2Widget
441+
{
442+
%TypeHeaderCode
443+
#include <qgssymbollayerv2widget.h>
444+
%End
445+
public:
446+
QgsGeometryGeneratorSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent /TransferThis/ = nullptr );
447+
448+
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) /Factory/;
449+
450+
// from base class
451+
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
452+
virtual QgsSymbolLayerV2* symbolLayer();
453+
};

‎src/core/qgsclipper.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,17 @@ class CORE_EXPORT QgsClipper
6565
static const double MIN_Y;
6666

6767

68-
// A handy way to refer to the four boundaries
68+
//! A handy way to refer to the four boundaries
6969
enum Boundary {XMax, XMin, YMax, YMin};
7070

71-
// Trims the given feature to a rectangular box. Returns the trimmed
72-
// feature in x and y. The shapeOpen parameter determines whether
73-
// the function treats the points as a closed shape (polygon), or as
74-
// an open shape (linestring).
75-
//
76-
// @note not available in python bindings on android
71+
/**
72+
* Trims the given feature to a rectangular box. Returns the trimmed
73+
* feature in x and y. The shapeOpen parameter determines whether
74+
* the function treats the points as a closed shape (polygon), or as
75+
* an open shape (linestring).
76+
*
77+
* @note not available in python bindings on android
78+
*/
7779
static void trimFeature( QVector<double>& x,
7880
QVector<double>& y,
7981
bool shapeOpen );

‎src/core/qgsrelation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ class CORE_EXPORT QgsRelation
251251
bool isValid() const;
252252

253253
protected:
254+
/**
255+
* Updates the validity status of this relation.
256+
* Will be called internally whenever a member is changed.
257+
*/
254258
void updateRelationStatus();
255259

256260
private:

‎src/core/symbology-ng/qgsgeometrygeneratorsymbollayerv2.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ class CORE_EXPORT QgsGeometryGeneratorSymbolLayerV2 : public QgsSymbolLayerV2
5353

5454
void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) override;
5555

56+
/**
57+
* Set the expression to generate this geometry.
58+
*/
5659
void setGeometryExpression( const QString& exp );
5760

61+
/**
62+
* Get the expression to generate this geometry.
63+
*/
5864
QString geometryExpression() const { return mExpression->expression(); }
5965

6066
virtual QgsSymbolV2* subSymbol() override { return mSymbol; }
@@ -68,6 +74,16 @@ class CORE_EXPORT QgsGeometryGeneratorSymbolLayerV2 : public QgsSymbolLayerV2
6874
//! care about the geometry of its parents.
6975
bool isCompatibleWithSymbol( QgsSymbolV2* symbol ) override;
7076

77+
/**
78+
* Will render this symbol layer using the context.
79+
* In comparison to other symbols there is no geometry passed in, since
80+
* the geometry will be created based on information from the context
81+
* which contains a QgsRenderContext which in turn contains an expression
82+
* context which is available to the evaluated expression.
83+
*
84+
* @param context The rendering context which will be used to render and to
85+
* construct a geometry.
86+
*/
7187
virtual void render( QgsSymbolV2RenderContext& context );
7288

7389
private:

‎src/core/symbology-ng/qgssymbolv2.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ class CORE_EXPORT QgsSymbolV2
217217
*/
218218
bool clipFeaturesToExtent() const { return mClipFeaturesToExtent; }
219219

220+
/**
221+
* Return a list of attributes required to render this feature.
222+
* This should include any attributes required by the symbology including
223+
* the ones required by expressions.
224+
*/
220225
QSet<QString> usedAttributes() const;
221226

222227
/** Returns whether the symbol utilises any data defined properties.
@@ -228,17 +233,45 @@ class CORE_EXPORT QgsSymbolV2
228233
void setLayer( const QgsVectorLayer* layer ) { mLayer = layer; }
229234
const QgsVectorLayer* layer() const { return mLayer; }
230235

236+
/**
237+
* Render a feature.
238+
*/
231239
void renderFeature( const QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false, int currentVertexMarkerType = 0, int currentVertexMarkerSize = 0 );
232240

233241
protected:
234242
QgsSymbolV2( SymbolType type, const QgsSymbolLayerV2List& layers ); // can't be instantiated
235243

244+
/**
245+
* Creates a point in screen coordinates from a wkb string in map
246+
* coordinates
247+
*/
236248
static const unsigned char* _getPoint( QPointF& pt, QgsRenderContext& context, const unsigned char* wkb );
249+
/**
250+
* Creates a line string in screen coordinates from a wkb string in map
251+
* coordinates
252+
*/
237253
static const unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
254+
/**
255+
* Creates a polygon in screen coordinates from a wkb string in map
256+
* coordinates
257+
*/
238258
static const unsigned char* _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
239259

260+
/**
261+
* Retrieve a cloned list of all layers that make up this symbol.
262+
* Ownership is transferred to the caller.
263+
*/
240264
QgsSymbolLayerV2List cloneLayers() const;
241265

266+
/**
267+
* Renders a context using a particular symbol layer without passing in a
268+
* geometry. This is used as fallback, if the symbol being rendered is not
269+
* compatible with the specified layer. In such a case, this method can be
270+
* called and will call the layer's rendering method anyway but the
271+
* geometry passed to the layer will be empty.
272+
* This is required for layers that generate their own geometry from other
273+
* information in the rendering context.
274+
*/
242275
void renderUsingLayer( QgsSymbolLayerV2* layer, QgsSymbolV2RenderContext& context );
243276

244277
//! check whether a symbol layer type can be used within the symbol

‎src/gui/symbology-ng/qgssymbollayerv2widget.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3129,4 +3129,3 @@ void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
31293129

31303130
emit symbolChanged();
31313131
}
3132-

‎src/gui/symbology-ng/qgssymbollayerv2widget.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,15 +667,18 @@ class GUI_EXPORT QgsGeometryGeneratorSymbolLayerWidget : public QgsSymbolLayerV2
667667
Q_OBJECT
668668

669669
public:
670-
QgsGeometryGeneratorSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = NULL );
670+
QgsGeometryGeneratorSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = 0 );
671671

672+
/**
673+
* Will be registered as factory
674+
*/
672675
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsGeometryGeneratorSymbolLayerWidget( vl ); }
673676

674677
// from base class
675678
virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
676679
virtual QgsSymbolLayerV2* symbolLayer() override;
677680

678-
protected:
681+
private:
679682
QgsGeometryGeneratorSymbolLayerV2* mLayer;
680683

681684
private slots:

0 commit comments

Comments
 (0)
Please sign in to comment.