[QGIS Commit] r11158 - branches/symbology-ng-branch/src/core/symbology-ng

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Jul 23 11:55:14 EDT 2009


Author: wonder
Date: 2009-07-23 11:55:13 -0400 (Thu, 23 Jul 2009)
New Revision: 11158

Modified:
   branches/symbology-ng-branch/src/core/symbology-ng/qgssymbolv2.cpp
Log:
make color of new symbols random


Modified: branches/symbology-ng-branch/src/core/symbology-ng/qgssymbolv2.cpp
===================================================================
--- branches/symbology-ng-branch/src/core/symbology-ng/qgssymbolv2.cpp	2009-07-23 15:31:19 UTC (rev 11157)
+++ branches/symbology-ng-branch/src/core/symbology-ng/qgssymbolv2.cpp	2009-07-23 15:55:13 UTC (rev 11158)
@@ -14,6 +14,8 @@
 #include <QPainter>
 #include <QSize>
 
+#include <cmath>
+
 QgsSymbolV2::QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers)
   : mType(type), mLayers(layers)
 {
@@ -43,13 +45,17 @@
 
 QgsSymbolV2* QgsSymbolV2::defaultSymbol(QGis::GeometryType geomType)
 {
+  QgsSymbolV2* s;
   switch (geomType)
   {
-    case QGis::Point: return new QgsMarkerSymbolV2();
-    case QGis::Line:  return new QgsLineSymbolV2();
-    case QGis::Polygon: return new QgsFillSymbolV2();
+    case QGis::Point: s = new QgsMarkerSymbolV2(); break;
+    case QGis::Line:  s = new QgsLineSymbolV2(); break;
+    case QGis::Polygon: s = new QgsFillSymbolV2(); break;
     default: QgsDebugMsg("unknown layer's geometry type"); return NULL;
   }
+
+  s->setColor( QColor::fromHsv(rand() % 360, 64 + rand() % 192, 128 + rand() % 128) );
+  return s;
 }
 
 



More information about the QGIS-commit mailing list