[QGIS Commit] r12190 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Nov 19 07:28:33 EST 2009


Author: wonder
Date: 2009-11-19 07:28:31 -0500 (Thu, 19 Nov 2009)
New Revision: 12190

Modified:
   trunk/qgis/src/core/qgsvectorlayer.cpp
Log:
Make symbology-ng work with (old) labeling.


Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2009-11-19 11:42:47 UTC (rev 12189)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2009-11-19 12:28:31 UTC (rev 12190)
@@ -315,12 +315,26 @@
 {
   QgsDebugMsg( "Starting draw of labels" );
 
-  if ( mRenderer && mLabelOn &&
+  if ( ( mRenderer || mRendererV2 ) && mLabelOn &&
        ( !label()->scaleBasedVisibility() ||
          ( label()->minScale() <= rendererContext.rendererScale() &&
            rendererContext.rendererScale() <= label()->maxScale() ) ) )
   {
-    QgsAttributeList attributes = mRenderer->classificationAttributes();
+    QgsAttributeList attributes;
+    if ( mRenderer )
+    {
+      attributes = mRenderer->classificationAttributes();
+    }
+    else if ( mRendererV2 )
+    {
+      foreach( QString attrName, mRendererV2->usedAttributes() )
+      {
+        int attrNum = QgsFeatureRendererV2::fieldNameIndex( pendingFields(), attrName );
+        attributes.append( attrNum );
+      }
+      // make sure the renderer is ready for classification ("symbolForFeature")
+      mRendererV2->startRender( rendererContext, pendingFields() );
+    }
 
     // Add fields required for labels
     mLabel->addRequiredFields( attributes );
@@ -338,7 +352,8 @@
       QgsFeature fet;
       while ( nextFeature( fet ) )
       {
-        if ( mRenderer->willRenderFeature( &fet ) )
+        if ( ( mRenderer && mRenderer->willRenderFeature( &fet ) )
+          || ( mRendererV2 && mRendererV2->symbolForFeature( fet ) != NULL ) )
         {
           bool sel = mSelectedFeatureIds.contains( fet.id() );
           mLabel->renderLabel( rendererContext, fet, sel, 0 );
@@ -352,6 +367,11 @@
       QgsLogger::critical( "Error projecting label locations, caught in " + QString( __FILE__ ) + ", line " + QString( __LINE__ ) );
     }
 
+    if ( mRendererV2 )
+    {
+      mRendererV2->stopRender( rendererContext );
+    }
+
 #ifdef QGISDEBUG
     QgsLogger::debug( "Total features processed", featureCount, 1, __FILE__, __FUNCTION__, __LINE__ );
 #endif



More information about the QGIS-commit mailing list