[QGIS Commit] r15663 - in trunk/qgis: python/core src/core/symbology-ng

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Apr 2 16:37:38 EDT 2011


Author: wonder
Date: 2011-04-02 13:37:38 -0700 (Sat, 02 Apr 2011)
New Revision: 15663

Modified:
   trunk/qgis/python/core/symbology-ng-core.sip
   trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp
   trunk/qgis/src/core/symbology-ng/qgssymbolv2.h
Log:
Shortcuts for easier creation of symbology-ng symbols


Modified: trunk/qgis/python/core/symbology-ng-core.sip
===================================================================
--- trunk/qgis/python/core/symbology-ng-core.sip	2011-04-02 12:26:39 UTC (rev 15662)
+++ trunk/qgis/python/core/symbology-ng-core.sip	2011-04-02 20:37:38 UTC (rev 15663)
@@ -745,6 +745,12 @@
 %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);
@@ -767,6 +773,12 @@
 %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);
@@ -786,6 +798,12 @@
 %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 );

Modified: trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp	2011-04-02 12:26:39 UTC (rev 15662)
+++ trunk/qgis/src/core/symbology-ng/qgssymbolv2.cpp	2011-04-02 20:37:38 UTC (rev 15663)
@@ -306,7 +306,42 @@
 
 ///////////////////
 
+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 )
 {

Modified: trunk/qgis/src/core/symbology-ng/qgssymbolv2.h
===================================================================
--- trunk/qgis/src/core/symbology-ng/qgssymbolv2.h	2011-04-02 12:26:39 UTC (rev 15662)
+++ trunk/qgis/src/core/symbology-ng/qgssymbolv2.h	2011-04-02 20:37:38 UTC (rev 15663)
@@ -4,6 +4,7 @@
 
 #include "qgis.h"
 #include <QList>
+#include <QMap>
 
 class QColor;
 class QImage;
@@ -16,6 +17,7 @@
 class QgsSymbolLayerV2;
 class QgsRenderContext;
 
+typedef QMap<QString, QString> QgsStringMap;
 typedef QList<QgsSymbolLayerV2*> QgsSymbolLayerV2List;
 
 class CORE_EXPORT QgsSymbolV2
@@ -168,6 +170,12 @@
 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 );
@@ -186,6 +194,12 @@
 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 );
@@ -201,6 +215,12 @@
 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 );



More information about the QGIS-commit mailing list