QgsSymbolV2* QgsCategorizedSymbolRendererV2::originalSymbolForFeature( QgsFeature& feature, QgsRenderContext &context ) { Q_UNUSED( context ); QgsAttributes attrs = feature.attributes(); QVariant value; if ( mAttrNum == -1 ) { Q_ASSERT( mExpression.data() ); value = mExpression->evaluate( &context.expressionContext() ); } else { value = attrs.value( mAttrNum ); } // find the right symbol for the category QgsSymbolV2 *symbol = symbolForValue( value ); if ( symbol == skipRender() ) return nullptr; if ( !symbol ) { // if no symbol found use default one return symbolForValue( QVariant( "" ) ); } return symbol; }
QgsSymbolV2* QgsCategorizedSymbolRendererV2::originalSymbolForFeature( QgsFeature& feature, QgsRenderContext &context ) { QVariant value = valueForFeature( feature, context ); // find the right symbol for the category QgsSymbolV2 *symbol = symbolForValue( value ); if ( symbol == skipRender() ) return nullptr; if ( !symbol ) { // if no symbol found use default one return symbolForValue( QVariant( "" ) ); } return symbol; }
void QgsCategorizedSymbolRendererV2::rebuildHash() { mSymbolHash.clear(); for ( int i = 0; i < mCategories.size(); ++i ) { const QgsRendererCategoryV2& cat = mCategories.at( i ); mSymbolHash.insert( cat.value().toString(), ( cat.renderState() || mCounting ) ? cat.symbol() : skipRender() ); } }