Skip to content
Permalink
Browse files
feature renderers: don't display not rendered class in catch-all clas…
…s and fix class counting (followup d4b8c40 and 4867b7f)

Funded-By: norBIT
  • Loading branch information
jef-n committed Jul 7, 2014
1 parent 0954ec3 commit 136cd5cd37a898548074056b55ad94987109fb96
@@ -169,7 +169,7 @@ void QgsCategorizedSymbolRendererV2::rebuildHash()
for ( int i = 0; i < mCategories.count(); ++i )
{
QgsRendererCategoryV2& cat = mCategories[i];
mSymbolHash.insert( cat.value().toString(), cat.renderState() ? cat.symbol() : 0 );
mSymbolHash.insert( cat.value().toString(), ( cat.renderState() || mCounting ) ? cat.symbol() : &sSkipRender );
}
}

@@ -208,7 +208,10 @@ QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& featu
}

// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( value );
QgsSymbolV2 *symbol = symbolForValue( value );
if ( symbol == &sSkipRender )
return 0;

if ( !symbol )
{
// if no symbol found use default one
@@ -376,6 +379,8 @@ void QgsCategorizedSymbolRendererV2::sortByLabel( Qt::SortOrder order )

void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
{
mCounting = context.rendererScale() == 0.0;

// make sure that the hash table is up to date
rebuildHash();

@@ -401,7 +406,6 @@ void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, con
mTempSymbols[ it->value().toString()] = tempSymbol;
}
}

}

void QgsCategorizedSymbolRendererV2::stopRender( QgsRenderContext& context )
@@ -752,7 +756,7 @@ bool QgsCategorizedSymbolRendererV2::legendSymbolItemsCheckable() const

bool QgsCategorizedSymbolRendererV2::legendSymbolItemChecked( int index )
{
if( index >= 0 && index < mCategories.size() )
if ( index >= 0 && index < mCategories.size() )
return mCategories[ index ].renderState();
else
return true;
@@ -762,3 +766,5 @@ void QgsCategorizedSymbolRendererV2::checkLegendSymbolItem( int index, bool stat
{
updateCategoryRenderState( index, state );
}

QgsMarkerSymbolV2 QgsCategorizedSymbolRendererV2::sSkipRender;
@@ -193,13 +193,16 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2

//! hashtable for faster access to symbols
QHash<QString, QgsSymbolV2*> mSymbolHash;
bool mCounting;

//! temporary symbols, used for data-defined rotation and scaling
QHash<QString, QgsSymbolV2*> mTempSymbols;

void rebuildHash();

QgsSymbolV2* symbolForValue( QVariant value );

static QgsMarkerSymbolV2 sSkipRender;
};


@@ -177,7 +177,7 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForValue( double value )
{
if ( it->lowerValue() <= value && it->upperValue() >= value )
{
if ( it->renderState() )
if ( it->renderState() || mCounting )
return it->symbol();
else
return NULL;
@@ -237,6 +237,8 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature

void QgsGraduatedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
{
mCounting = context.rendererScale() == 0.0;

// find out classification attribute index from name
mAttrNum = fields.fieldNameIndex( mAttrName );

@@ -211,6 +211,7 @@ class CORE_EXPORT QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2
QScopedPointer<QgsExpression> mExpression;
//! attribute index (derived from attribute name in startRender)
int mAttrNum;
bool mCounting;

//! temporary symbols, used for data-defined rotation and scaling
QHash<QgsSymbolV2*, QgsSymbolV2*> mTempSymbols;

0 comments on commit 136cd5c

Please sign in to comment.