void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields ) { // make sure that the hash table is up to date rebuildHash(); // find out classification attribute index from name mAttrNum = fields.fieldNameIndex( mAttrName ); if ( mAttrNum == -1 ) { mExpression.reset( new QgsExpression( mAttrName ) ); mExpression->prepare( fields ); } QgsCategoryList::iterator it = mCategories.begin(); for ( ; it != mCategories.end(); ++it ) { it->symbol()->startRender( context, &fields ); if ( mRotation.data() || mSizeScale.data() ) { QgsSymbolV2* tempSymbol = it->symbol()->clone(); tempSymbol->setRenderHints(( mRotation.data() ? QgsSymbolV2::DataDefinedRotation : 0 ) | ( mSizeScale.data() ? QgsSymbolV2::DataDefinedSizeScale : 0 ) ); tempSymbol->startRender( context, &fields ); mTempSymbols[ it->value().toString()] = tempSymbol; } } }
void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ) { // make sure that the hash table is up to date rebuildHash(); // find out classification attribute index from name mAttrNum = vlayer ? vlayer->fieldNameIndex( mAttrName ) : -1; mRotationFieldIdx = ( mRotationField.isEmpty() ? -1 : vlayer->fieldNameIndex( mRotationField ) ); mSizeScaleFieldIdx = ( mSizeScaleField.isEmpty() ? -1 : vlayer->fieldNameIndex( mSizeScaleField ) ); QgsCategoryList::iterator it = mCategories.begin(); for ( ; it != mCategories.end(); ++it ) { it->symbol()->startRender( context, vlayer ); if ( mRotationFieldIdx != -1 || mSizeScaleFieldIdx != -1 ) { QgsSymbolV2* tempSymbol = it->symbol()->clone(); tempSymbol->setRenderHints(( mRotationFieldIdx != -1 ? QgsSymbolV2::DataDefinedRotation : 0 ) | ( mSizeScaleFieldIdx != -1 ? QgsSymbolV2::DataDefinedSizeScale : 0 ) ); tempSymbol->startRender( context, vlayer ); mTempSymbols[ it->value().toString()] = tempSymbol; } } }