Skip to content
Permalink
Browse files

Ported single and graduated symbol renderer to use usedAttributes() f…

…unctions of symbol
  • Loading branch information
mhugent committed Jun 9, 2011
1 parent 066a0ea commit b76da25f08e9549a89f08b8a9defa37d939940f7
@@ -218,13 +218,29 @@ void QgsGraduatedSymbolRendererV2::stopRender( QgsRenderContext& context )

QList<QString> QgsGraduatedSymbolRendererV2::usedAttributes()
{
QList<QString> lst;
lst.append( mAttrName );
if ( !mRotationField.isEmpty() )
lst.append( mRotationField );
if ( !mSizeScaleField.isEmpty() )
lst.append( mSizeScaleField );
return lst;
QSet<QString> attributes;

QgsSymbolV2* symbol = 0;
QgsRangeList::const_iterator range_it = mRanges.constBegin();
for(; range_it != mRanges.constEnd(); ++range_it )
{
symbol = range_it->symbol();
if ( symbol )
{
attributes.unite( symbol->usedAttributes() );
}
}

if ( !mRotationField.isEmpty() )
{
attributes.insert( mRotationField );
}
if ( !mSizeScaleField.isEmpty() )
{
attributes.insert( mSizeScaleField );
}

return attributes.toList();
}

bool QgsGraduatedSymbolRendererV2::updateRangeSymbol( int rangeIndex, QgsSymbolV2* symbol )
@@ -122,12 +122,20 @@ void QgsSingleSymbolRendererV2::stopRender( QgsRenderContext& context )

QList<QString> QgsSingleSymbolRendererV2::usedAttributes()
{
QList<QString> lst;
QSet<QString> attributes;
if( mSymbol )
{
attributes.unite( mSymbol->usedAttributes() );
}
if ( !mRotationField.isEmpty() )
lst.append( mRotationField );
{
attributes.insert( mRotationField );
}
if ( !mSizeScaleField.isEmpty() )
lst.append( mSizeScaleField );
return lst;
{
attributes.insert( mSizeScaleField );
}
return attributes.toList();
}

QgsSymbolV2* QgsSingleSymbolRendererV2::symbol() const
@@ -1,10 +1,12 @@
#ifndef QGSSYMBOLLAYERV2_H
#define QGSSYMBOLLAYERV2_H

#include <QMap>


#include <QColor>
#include <QMap>
#include <QPointF>
#include <QSet>

#include "qgssymbolv2.h"

@@ -52,6 +54,9 @@ class CORE_EXPORT QgsSymbolLayerV2
void setRenderingPass( int renderingPass ) { mRenderingPass = renderingPass; }
int renderingPass() const { return mRenderingPass; }

// symbol layers normally only use additional attributes to provide data defined settings
virtual QSet<QString> usedAttributes() const { return QSet<QString>(); }

protected:
QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false )
: mType( type ), mLocked( locked ), mRenderingPass( 0 ) {}
@@ -265,6 +265,20 @@ QgsSymbolLayerV2List QgsSymbolV2::cloneLayers() const
return lst;
}

QSet<QString> QgsSymbolV2::usedAttributes() const
{
QSet<QString> attributes;
QgsSymbolLayerV2List::const_iterator sIt = mLayers.constBegin();
for(; sIt != mLayers.constEnd(); ++sIt )
{
if( *sIt )
{
attributes.unite( (*sIt)->usedAttributes() );
}
}
return attributes;
}

////////////////////

QgsSymbolV2RenderContext::QgsSymbolV2RenderContext( QgsRenderContext& c, QgsSymbolV2::OutputUnit u, qreal alpha, bool selected, int renderHints, const QgsFeature* f )
@@ -99,6 +99,8 @@ class CORE_EXPORT QgsSymbolV2
//! @note added in 1.5
int renderHints() { return mRenderHints; }

QSet<QString> usedAttributes() const;

protected:
QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers ); // can't be instantiated

0 comments on commit b76da25

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