[QGIS Commit] r11060 - branches/symbology-ng-branch/python/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jul 13 15:52:04 EDT 2009


Author: wonder
Date: 2009-07-13 15:52:03 -0400 (Mon, 13 Jul 2009)
New Revision: 11060

Modified:
   branches/symbology-ng-branch/python/core/conversions.sip
   branches/symbology-ng-branch/python/core/qgsvectorlayer.sip
   branches/symbology-ng-branch/python/core/symbology-ng-core.sip
Log:
Added python bindings for symbol levels.


Modified: branches/symbology-ng-branch/python/core/conversions.sip
===================================================================
--- branches/symbology-ng-branch/python/core/conversions.sip	2009-07-13 18:50:52 UTC (rev 11059)
+++ branches/symbology-ng-branch/python/core/conversions.sip	2009-07-13 19:52:03 UTC (rev 11060)
@@ -3,6 +3,7 @@
 which are not wrapped by PyQt:
 - QVector< QVector<TYPE> >
 - QVector< QVector< QVector<TYPE> > >
+- QList< QList<TYPE> >
 - QSet<int>
 - QSet<TYPE>
 - QMap<int, QMap<int, TYPE> >
@@ -173,6 +174,85 @@
 };
 
 
+
+template <TYPE>
+%MappedType QList< QList<TYPE> >
+{
+%TypeHeaderCode
+#include <QList>
+%End
+
+%ConvertFromTypeCode
+  // Create the list.
+  PyObject *l;
+
+  if ((l = PyList_New(sipCpp->size())) == NULL)
+    return NULL;
+
+  const sipMappedType* qlist_type = sipFindMappedType("QList<TYPE>");
+
+  // Set the list elements.
+  for (int i = 0; i < sipCpp->size(); ++i)
+  {
+    QList<TYPE>* t = new QList<TYPE>(sipCpp->at(i));
+    PyObject *tobj;
+
+    if ((tobj = sipConvertFromMappedType(t, qlist_type, sipTransferObj)) == NULL)
+    {
+      Py_DECREF(l);
+      delete t;
+      return NULL;
+    }
+    PyList_SET_ITEM(l, i, tobj);
+  }
+
+  return l;
+%End
+
+%ConvertToTypeCode
+  const sipMappedType* qlist_type = sipFindMappedType("QList<TYPE>");
+
+  // Check the type if that is all that is required.
+  if (sipIsErr == NULL)
+  {
+    if (!PyList_Check(sipPy))
+      return 0;
+
+    for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
+      if (!sipCanConvertToMappedType(PyList_GET_ITEM(sipPy, i), qlist_type, SIP_NOT_NONE))
+        return 0;
+
+    return 1;
+  }
+
+
+  QList< QList<TYPE> > *ql = new QList< QList<TYPE> >;
+
+  for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
+  {
+    int state;
+    //TYPE *t = reinterpret_cast<TYPE *>(sipConvertToInstance(PyList_GET_ITEM(sipPy, i), sipClass_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
+    QList<TYPE> * t = reinterpret_cast< QList<TYPE> * >(sipConvertToMappedType(PyList_GET_ITEM(sipPy, i), qlist_type, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
+
+    if (*sipIsErr)
+    {
+      sipReleaseInstance(t, sipClass_TYPE, state);
+      delete ql;
+      return 0;
+    }
+    ql->append(*t);
+    sipReleaseInstance(t, sipClass_TYPE, state);
+  }
+
+  *sipCppPtr = ql;
+  return sipGetState(sipTransferObj);
+%End
+
+};
+
+
+
+
 %MappedType QSet<int>
 {
 %TypeHeaderCode

Modified: branches/symbology-ng-branch/python/core/qgsvectorlayer.sip
===================================================================
--- branches/symbology-ng-branch/python/core/qgsvectorlayer.sip	2009-07-13 18:50:52 UTC (rev 11059)
+++ branches/symbology-ng-branch/python/core/qgsvectorlayer.sip	2009-07-13 19:52:03 UTC (rev 11060)
@@ -106,6 +106,9 @@
   /** set whether to use renderer V2 for drawing. Added in QGIS 1.2 */
   void setUsingRendererV2(bool usingRendererV2);
     
+  void drawRendererV2( QgsRenderContext& rendererContext, bool labeling );
+  void drawRendererV2Levels( QgsRenderContext& rendererContext, bool labeling );
+
   /** Returns point, line or polygon */
   QGis::GeometryType geometryType() const;
 

Modified: branches/symbology-ng-branch/python/core/symbology-ng-core.sip
===================================================================
--- branches/symbology-ng-branch/python/core/symbology-ng-core.sip	2009-07-13 18:50:52 UTC (rev 11059)
+++ branches/symbology-ng-branch/python/core/symbology-ng-core.sip	2009-07-13 19:52:03 UTC (rev 11060)
@@ -1,6 +1,28 @@
 
 ///////////////
 
+
+class QgsSymbolV2LevelItem
+{
+%TypeHeaderCode
+#include <qgsrendererv2.h>
+%End
+
+public:
+  QgsSymbolV2LevelItem( QgsSymbolV2* symbol, int layer );
+  QgsSymbolV2* symbol();
+  int layer();
+};
+
+// every level has list of items: symbol + symbol layer num
+typedef QList< QgsSymbolV2LevelItem > QgsSymbolV2Level;
+
+// this is a list of levels
+typedef QList< QgsSymbolV2Level > QgsSymbolV2LevelOrder;
+
+///////////////
+
+
 class QgsFeatureRendererV2
 {
 %TypeHeaderCode
@@ -32,8 +54,11 @@
 	virtual QString dump();
 
 	
-	void renderFeature(QgsFeature& feature, QgsRenderContext& context);
-	
+  void renderFeature(QgsFeature& feature, QgsRenderContext& context, int layer = -1);
+
+  QgsSymbolV2LevelOrder& symbolLevels();
+  void setSymbolLevels(const QgsSymbolV2LevelOrder& levelOrder);
+
 protected:
   QgsFeatureRendererV2(RendererType type);
 
@@ -191,7 +216,7 @@
 %End
 
 public:
-	virtual void renderPoint(const QPointF& point, QgsRenderContext& context) = 0;
+  virtual void renderPoint(const QPointF& point, QgsRenderContext& context) = 0;
 	
 	void drawPreviewIcon(QPainter* painter, QSize size);
 
@@ -213,7 +238,7 @@
 %End
 
 public:
-	virtual void renderPolyline(const QPolygonF& points, QgsRenderContext& context) = 0;
+  virtual void renderPolyline(const QPolygonF& points, QgsRenderContext& context) = 0;
 	
   void setWidth(int width);
   int width() const;
@@ -232,7 +257,7 @@
 %End
 
 public:
-	virtual void renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context) = 0;
+  virtual void renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context) = 0;
 	
 	void drawPreviewIcon(QPainter* painter, QSize size);
   
@@ -334,7 +359,7 @@
 	void setSize(double size);
 	double size();
 	
-	void renderPoint(const QPointF& point, QgsRenderContext& context);
+  void renderPoint(const QPointF& point, QgsRenderContext& context, int layer = -1);
 
   virtual QgsSymbolV2* clone() const /Factory/;
 };
@@ -353,7 +378,7 @@
 	void setWidth(int width);
 	int width();
 	
-	void renderPolyline(const QPolygonF& points, QgsRenderContext& context);
+  void renderPolyline(const QPolygonF& points, QgsRenderContext& context, int layer = -1);
 	
   virtual QgsSymbolV2* clone() const /Factory/;
 };
@@ -369,7 +394,7 @@
 public:
 	QgsFillSymbolV2(QgsSymbolLayerV2List layers /Transfer/ = QgsSymbolLayerV2List());
 	
-	void renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context);
+  void renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context, int layer = -1);
 
   virtual QgsSymbolV2* clone() const /Factory/;
 };



More information about the QGIS-commit mailing list