Navigation Menu

Skip to content

Commit

Permalink
Shortcuts for easier creation of symbology-ng symbols
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15663 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 2, 2011
1 parent 66fc757 commit d12254b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/core/symbology-ng-core.sip
Expand Up @@ -745,6 +745,12 @@ class QgsMarkerSymbolV2 : QgsSymbolV2
%End

public:
/** Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
This is a convenience method for easier creation of marker symbols.
\note added in v1.7
*/
static QgsMarkerSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;

QgsMarkerSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());

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

public:
/** Create a line symbol with one symbol layer: SimpleLine with specified properties.
This is a convenience method for easier creation of line symbols.
\note added in v1.7
*/
static QgsLineSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;

QgsLineSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());

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

public:
/** Create a fill symbol with one symbol layer: SimpleFill with specified properties.
This is a convenience method for easier creation of fill symbols.
\note added in v1.7
*/
static QgsFillSymbolV2* createSimple( const QgsStringMap& properties ) /Factory/;

QgsFillSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());

void setAngle( double angle );
Expand Down
35 changes: 35 additions & 0 deletions src/core/symbology-ng/qgssymbolv2.cpp
Expand Up @@ -306,6 +306,41 @@ QgsSymbolV2RenderContext& QgsSymbolV2RenderContext::operator=( const QgsSymbolV2

///////////////////

QgsMarkerSymbolV2* QgsMarkerSymbolV2::createSimple( const QgsStringMap& properties )
{
QgsSymbolLayerV2* sl = QgsSimpleMarkerSymbolLayerV2::create( properties );
if ( sl == NULL )
return NULL;

QgsSymbolLayerV2List layers;
layers.append( sl );
return new QgsMarkerSymbolV2( layers );
}

QgsLineSymbolV2* QgsLineSymbolV2::createSimple( const QgsStringMap& properties )
{
QgsSymbolLayerV2* sl = QgsSimpleLineSymbolLayerV2::create( properties );
if ( sl == NULL )
return NULL;

QgsSymbolLayerV2List layers;
layers.append( sl );
return new QgsLineSymbolV2( layers );
}

QgsFillSymbolV2* QgsFillSymbolV2::createSimple( const QgsStringMap& properties )
{
QgsSymbolLayerV2* sl = QgsSimpleFillSymbolLayerV2::create( properties );
if ( sl == NULL )
return NULL;

QgsSymbolLayerV2List layers;
layers.append( sl );
return new QgsFillSymbolV2( layers );
}

///////////////////


QgsMarkerSymbolV2::QgsMarkerSymbolV2( QgsSymbolLayerV2List layers )
: QgsSymbolV2( Marker, layers )
Expand Down
20 changes: 20 additions & 0 deletions src/core/symbology-ng/qgssymbolv2.h
Expand Up @@ -4,6 +4,7 @@

#include "qgis.h"
#include <QList>
#include <QMap>

class QColor;
class QImage;
Expand All @@ -16,6 +17,7 @@ class QPolygonF;
class QgsSymbolLayerV2;
class QgsRenderContext;

typedef QMap<QString, QString> QgsStringMap;
typedef QList<QgsSymbolLayerV2*> QgsSymbolLayerV2List;

class CORE_EXPORT QgsSymbolV2
Expand Down Expand Up @@ -168,6 +170,12 @@ class CORE_EXPORT QgsSymbolV2RenderContext
class CORE_EXPORT QgsMarkerSymbolV2 : public QgsSymbolV2
{
public:
/** Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
This is a convenience method for easier creation of marker symbols.
\note added in v1.7
*/
static QgsMarkerSymbolV2* createSimple( const QgsStringMap& properties );

QgsMarkerSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );

void setAngle( double angle );
Expand All @@ -186,6 +194,12 @@ class CORE_EXPORT QgsMarkerSymbolV2 : public QgsSymbolV2
class CORE_EXPORT QgsLineSymbolV2 : public QgsSymbolV2
{
public:
/** Create a line symbol with one symbol layer: SimpleLine with specified properties.
This is a convenience method for easier creation of line symbols.
\note added in v1.7
*/
static QgsLineSymbolV2* createSimple( const QgsStringMap& properties );

QgsLineSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );

void setWidth( double width );
Expand All @@ -201,6 +215,12 @@ class CORE_EXPORT QgsLineSymbolV2 : public QgsSymbolV2
class CORE_EXPORT QgsFillSymbolV2 : public QgsSymbolV2
{
public:
/** Create a fill symbol with one symbol layer: SimpleFill with specified properties.
This is a convenience method for easier creation of fill symbols.
\note added in v1.7
*/
static QgsFillSymbolV2* createSimple( const QgsStringMap& properties );

QgsFillSymbolV2( QgsSymbolLayerV2List layers = QgsSymbolLayerV2List() );
void setAngle( double angle );
void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context, int layer = -1, bool selected = false );
Expand Down

0 comments on commit d12254b

Please sign in to comment.