Skip to content

Commit d12254b

Browse files
author
wonder
committedApr 2, 2011
Shortcuts for easier creation of symbology-ng symbols
git-svn-id: http://svn.osgeo.org/qgis/trunk@15663 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 66fc757 commit d12254b

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
 

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,12 @@ class QgsMarkerSymbolV2 : QgsSymbolV2
745745
%End
746746

747747
public:
748+
/** Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
749+
This is a convenience method for easier creation of marker symbols.
750+
\note added in v1.7
751+
*/
752+
static QgsMarkerSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;
753+
748754
QgsMarkerSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());
749755

750756
void setAngle(double angle);
@@ -767,6 +773,12 @@ class QgsLineSymbolV2 : QgsSymbolV2
767773
%End
768774

769775
public:
776+
/** Create a line symbol with one symbol layer: SimpleLine with specified properties.
777+
This is a convenience method for easier creation of line symbols.
778+
\note added in v1.7
779+
*/
780+
static QgsLineSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;
781+
770782
QgsLineSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());
771783

772784
void setWidth(double width);
@@ -786,6 +798,12 @@ class QgsFillSymbolV2 : QgsSymbolV2
786798
%End
787799

788800
public:
801+
/** Create a fill symbol with one symbol layer: SimpleFill with specified properties.
802+
This is a convenience method for easier creation of fill symbols.
803+
\note added in v1.7
804+
*/
805+
static QgsFillSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;
806+
789807
QgsFillSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());
790808

791809
void setAngle( double angle );

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,41 @@ QgsSymbolV2RenderContext& QgsSymbolV2RenderContext::operator=( const QgsSymbolV2
306306

307307
///////////////////
308308

309+
QgsMarkerSymbolV2* QgsMarkerSymbolV2::createSimple( const QgsStringMap& properties )
310+
{
311+
QgsSymbolLayerV2* sl = QgsSimpleMarkerSymbolLayerV2::create( properties );
312+
if ( sl == NULL )
313+
return NULL;
314+
315+
QgsSymbolLayerV2List layers;
316+
layers.append( sl );
317+
return new QgsMarkerSymbolV2( layers );
318+
}
319+
320+
QgsLineSymbolV2* QgsLineSymbolV2::createSimple( const QgsStringMap& properties )
321+
{
322+
QgsSymbolLayerV2* sl = QgsSimpleLineSymbolLayerV2::create( properties );
323+
if ( sl == NULL )
324+
return NULL;
325+
326+
QgsSymbolLayerV2List layers;
327+
layers.append( sl );
328+
return new QgsLineSymbolV2( layers );
329+
}
330+
331+
QgsFillSymbolV2* QgsFillSymbolV2::createSimple( const QgsStringMap& properties )
332+
{
333+
QgsSymbolLayerV2* sl = QgsSimpleFillSymbolLayerV2::create( properties );
334+
if ( sl == NULL )
335+
return NULL;
336+
337+
QgsSymbolLayerV2List layers;
338+
layers.append( sl );
339+
return new QgsFillSymbolV2( layers );
340+
}
341+
342+
///////////////////
343+
309344

310345
QgsMarkerSymbolV2::QgsMarkerSymbolV2( QgsSymbolLayerV2List layers )
311346
: QgsSymbolV2( Marker, layers )

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "qgis.h"
66
#include <QList>
7+
#include <QMap>
78

89
class QColor;
910
class QImage;
@@ -16,6 +17,7 @@ class QPolygonF;
1617
class QgsSymbolLayerV2;
1718
class QgsRenderContext;
1819

20+
typedef QMap<QString, QString> QgsStringMap;
1921
typedef QList<QgsSymbolLayerV2*> QgsSymbolLayerV2List;
2022

2123
class CORE_EXPORT QgsSymbolV2
@@ -168,6 +170,12 @@ class CORE_EXPORT QgsSymbolV2RenderContext
168170
class CORE_EXPORT QgsMarkerSymbolV2 : public QgsSymbolV2
169171
{
170172
public:
173+
/** Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
174+
This is a convenience method for easier creation of marker symbols.
175+
\note added in v1.7
176+
*/
177+
static QgsMarkerSymbolV2* createSimple( const QgsStringMap& properties );
178+
171179
QgsMarkerSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
172180

173181
void setAngle( double angle );
@@ -186,6 +194,12 @@ class CORE_EXPORT QgsMarkerSymbolV2 : public QgsSymbolV2
186194
class CORE_EXPORT QgsLineSymbolV2 : public QgsSymbolV2
187195
{
188196
public:
197+
/** Create a line symbol with one symbol layer: SimpleLine with specified properties.
198+
This is a convenience method for easier creation of line symbols.
199+
\note added in v1.7
200+
*/
201+
static QgsLineSymbolV2* createSimple( const QgsStringMap& properties );
202+
189203
QgsLineSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
190204

191205
void setWidth( double width );
@@ -201,6 +215,12 @@ class CORE_EXPORT QgsLineSymbolV2 : public QgsSymbolV2
201215
class CORE_EXPORT QgsFillSymbolV2 : public QgsSymbolV2
202216
{
203217
public:
218+
/** Create a fill symbol with one symbol layer: SimpleFill with specified properties.
219+
This is a convenience method for easier creation of fill symbols.
220+
\note added in v1.7
221+
*/
222+
static QgsFillSymbolV2* createSimple( const QgsStringMap& properties );
223+
204224
QgsFillSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
205225
void setAngle( double angle );
206226
void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context, int layer = -1, bool selected = false );

0 commit comments

Comments
 (0)
Please sign in to comment.