Skip to content
Permalink
Browse files

[FIXED] #11572 Filter Legend By Map Content doesn't maintain point di…

…splacement legend

The fix from #1673 has to be enhance to have
 something more generic.

This fix add methods to QgsPointDisplacementRenderer:
* capabilities
* symbolForFeature
* originalSymbolForFeature
* symbolsForFeature
* originalSymbolsForFeature
* willRenderFeature
  • Loading branch information
rldhont committed Nov 7, 2014
1 parent cbf1d33 commit 40c5ae4407d45cf85dfcc10f4b9a03f003d6fe2b
@@ -53,12 +53,6 @@ void QgsMapHitTest::run()
void QgsMapHitTest::runHitTestLayer( QgsVectorLayer* vl, SymbolV2Set& usedSymbols, QgsRenderContext& context )
{
QgsFeatureRendererV2* r = vl->rendererV2();

// Point displacement case
QgsPointDisplacementRenderer* pdr = dynamic_cast<QgsPointDisplacementRenderer*>( r );
if ( pdr )
r = pdr->embeddedRenderer();

bool moreSymbolsPerFeature = r->capabilities() & QgsFeatureRendererV2::MoreSymbolsPerFeature;
r->startRender( context, vl->pendingFields() );
QgsFeature f;
@@ -196,12 +196,80 @@ void QgsPointDisplacementRenderer::setEmbeddedRenderer( QgsFeatureRendererV2* r
mRenderer = r;
}

QList<QString> QgsPointDisplacementRenderer::usedAttributes()
{
QList<QString> attributeList;
if ( !mLabelAttributeName.isEmpty() )
{
attributeList.push_back( mLabelAttributeName );
}
if ( mRenderer )
{
attributeList += mRenderer->usedAttributes();
}
return attributeList;
}

int QgsPointDisplacementRenderer::capabilities()
{
if ( !mRenderer )
{
return 0;
}
return mRenderer->capabilities();
}

QgsSymbolV2List QgsPointDisplacementRenderer::symbols()
{
if ( !mRenderer )
{
return QgsSymbolV2List();
}
return mRenderer->symbols();
}

QgsSymbolV2* QgsPointDisplacementRenderer::symbolForFeature( QgsFeature& feature )
{
Q_UNUSED( feature );
return 0; //not used any more
if ( !mRenderer )
{
return 0;
}
return mRenderer->symbolForFeature( feature );
}

QgsSymbolV2* QgsPointDisplacementRenderer::originalSymbolForFeature( QgsFeature& feat )
{
if ( !mRenderer )
return 0;
return mRenderer->originalSymbolForFeature( feat );
}

QgsSymbolV2List QgsPointDisplacementRenderer::symbolsForFeature( QgsFeature& feature )
{
if ( !mRenderer )
{
return QgsSymbolV2List();
}
return mRenderer->symbolsForFeature( feature );
}

QgsSymbolV2List QgsPointDisplacementRenderer::originalSymbolsForFeature( QgsFeature& feat )
{
if ( !mRenderer )
return QgsSymbolV2List();
return mRenderer->originalSymbolsForFeature( feat );
}

bool QgsPointDisplacementRenderer::willRenderFeature( QgsFeature& feat )
{
if ( !mRenderer )
{
return false;
}
return mRenderer->willRenderFeature( feat );
}


void QgsPointDisplacementRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
{
mRenderer->startRender( context, fields );
@@ -257,32 +325,6 @@ void QgsPointDisplacementRenderer::stopRender( QgsRenderContext& context )
}
}

QList<QString> QgsPointDisplacementRenderer::usedAttributes()
{
QList<QString> attributeList;
if ( !mLabelAttributeName.isEmpty() )
{
attributeList.push_back( mLabelAttributeName );
}
if ( mRenderer )
{
attributeList += mRenderer->usedAttributes();
}
return attributeList;
}

QgsSymbolV2List QgsPointDisplacementRenderer::symbols()
{
if ( mRenderer )
{
return mRenderer->symbols();
}
else
{
return QgsSymbolV2List();
}
}

QgsFeatureRendererV2* QgsPointDisplacementRenderer::create( QDomElement& symbologyElem )
{
QgsPointDisplacementRenderer* r = new QgsPointDisplacementRenderer();
@@ -41,15 +41,27 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsFeatureRendererV2
/**Reimplemented from QgsFeatureRendererV2*/
bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );

QgsSymbolV2* symbolForFeature( QgsFeature& feature );
/** Partial proxy that will call this method on the embedded renderer. */
virtual QList<QString> usedAttributes();
/** Proxy that will call this method on the embedded renderer. */
virtual int capabilities();
/** Proxy that will call this method on the embedded renderer. */
virtual QgsSymbolV2List symbols();
/** Proxy that will call this method on the embedded renderer. */
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature );
/** Proxy that will call this method on the embedded renderer. */
virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feat );
/** Proxy that will call this method on the embedded renderer. */
virtual QgsSymbolV2List symbolsForFeature( QgsFeature& feat );
/** Proxy that will call this method on the embedded renderer. */
virtual QgsSymbolV2List originalSymbolsForFeature( QgsFeature& feat );
/** Proxy that will call this method on the embedded renderer. */
virtual bool willRenderFeature( QgsFeature& feat );

void startRender( QgsRenderContext& context, const QgsFields& fields );

void stopRender( QgsRenderContext& context );

QList<QString> usedAttributes();
QgsSymbolV2List symbols();

//! create a renderer from XML element
static QgsFeatureRendererV2* create( QDomElement& symbologyElem );
QDomElement save( QDomDocument& doc );

0 comments on commit 40c5ae4

Please sign in to comment.
You can’t perform that action at this time.