Skip to content
Permalink
Browse files

Make symbology-ng work with (old) labeling.

git-svn-id: http://svn.osgeo.org/qgis/trunk@12190 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Nov 19, 2009
1 parent 7d636dd commit dc159b3b7075c111724e37e60576bcaefbc96b75
Showing with 23 additions and 3 deletions.
  1. +23 −3 src/core/qgsvectorlayer.cpp
@@ -315,12 +315,26 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext )
{
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 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext )
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 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext )
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

0 comments on commit dc159b3

Please sign in to comment.