Skip to content

Commit

Permalink
[FIXED] #11572 Filter Legend By Map Content doesn't maintain point di…
Browse files Browse the repository at this point in the history
…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 13, 2014
1 parent cbf1d33 commit 40c5ae4
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 38 deletions.
6 changes: 0 additions & 6 deletions src/core/qgsmaphittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
98 changes: 70 additions & 28 deletions src/core/symbology-ng/qgspointdisplacementrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 16 additions & 4 deletions src/core/symbology-ng/qgspointdisplacementrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 40c5ae4

Please sign in to comment.