Skip to content
Permalink
Browse files
Use symbolsForFeature in point displacement renderer
  • Loading branch information
mhugent committed Mar 2, 2012
1 parent 0b198ba commit eaed6703c9d12e265d8f4c47175cc1801eb51175
Showing with 20 additions and 2 deletions.
  1. +18 −2 src/core/symbology-ng/qgspointdisplacementrenderer.cpp
  2. +2 −0 src/core/symbology-ng/qgspointdisplacementrenderer.h
@@ -105,14 +105,14 @@ bool QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRender
{
labelAttributeList << QString();
}
symbolList << dynamic_cast<QgsMarkerSymbolV2*>( mRenderer->symbolForFeature( attIt.value() ) );
symbolList << dynamic_cast<QgsMarkerSymbolV2*>( firstSymbolForFeature( mRenderer, attIt.value() ) );
}
}
}
}
else //only one feature
{
symbolList << dynamic_cast<QgsMarkerSymbolV2*>( mRenderer->symbolForFeature( feature ) );
symbolList << dynamic_cast<QgsMarkerSymbolV2*>( firstSymbolForFeature( mRenderer, feature ) );
if ( mDrawLabels )
{
labelAttributeList << getLabel( feature );
@@ -574,3 +574,19 @@ void QgsPointDisplacementRenderer::drawLabels( const QPointF& centerPoint, QgsSy
p->restore();
}
}

QgsSymbolV2* QgsPointDisplacementRenderer::firstSymbolForFeature( QgsFeatureRendererV2* r, QgsFeature& f )
{
if ( !r )
{
return 0;
}

QgsSymbolV2List symbolList = r->symbolsForFeature( f );
if ( symbolList.size() < 1 )
{
return 0;
}

return symbolList.at( 0 );
}
@@ -145,6 +145,8 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsFeatureRendererV2
void drawCircle( double radiusPainterUnits, QgsSymbolV2RenderContext& context, const QPointF& centerPoint, int nSymbols );
void drawSymbols( QgsFeature& f, QgsRenderContext& context, const QList<QgsMarkerSymbolV2*>& symbolList, const QList<QPointF>& symbolPositions, bool selected = false );
void drawLabels( const QPointF& centerPoint, QgsSymbolV2RenderContext& context, const QList<QPointF>& labelShifts, const QStringList& labelList );
/**Returns first symbol for feature or 0 if none*/
QgsSymbolV2* firstSymbolForFeature( QgsFeatureRendererV2* r, QgsFeature& f );
};

#endif // QGSPOINTDISPLACEMENTRENDERER_H

0 comments on commit eaed670

Please sign in to comment.