27 #include <QDomDocument>
28 #include <QDomElement>
32 , mPreprocessingEnabled( false )
52 mSubRenderer.reset( const_cast<QgsFeatureRendererV2*>( subRenderer )->
clone() );
56 mSubRenderer.reset( 0 );
62 return mSubRenderer.data();
73 mSubRenderer->startRender( context, fields );
75 mFeaturesCategories.clear();
76 mSymbolCategories.clear();
77 mFeatureDecorations.clear();
91 QRect e( context.
painter()->viewport() );
93 e.adjust( -e.width()*5, -e.height()*5, e.width()*5, e.height()*5 );
96 exteriorRing << mtp.toMapCoordinates( e.topRight() );
97 exteriorRing << mtp.toMapCoordinates( e.bottomRight() );
98 exteriorRing << mtp.toMapCoordinates( e.bottomLeft() );
99 exteriorRing << mtp.toMapCoordinates( e.topLeft() );
114 QRect v( context.
painter()->viewport() );
115 mContext.
setExtent(
QgsRectangle( mtp.toMapCoordinates( v.topLeft() ), mtp.toMapCoordinates( v.bottomRight() ) ) );
119 mExtentPolygon.clear();
120 mExtentPolygon.append( exteriorRing );
131 if ( selected || drawVertexMarker )
133 mFeatureDecorations.append( FeatureDecoration( feature, selected, drawVertexMarker, layer ) );
157 catId.append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
162 QgsSymbolV2* sym = mSubRenderer->symbolForFeature( feature );
165 catId.append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
169 if ( catId.isEmpty() )
174 if ( ! mSymbolCategories.contains( catId ) )
176 CombinedFeature cFeat;
178 cFeat.feature = feature;
179 mSymbolCategories.insert( catId, mSymbolCategories.count() );
180 mFeaturesCategories.append( cFeat );
184 CombinedFeature& cFeat = mFeaturesCategories[ mSymbolCategories[catId] ];
197 if ( mPreprocessingEnabled )
200 if ( ! geom->isGeosValid() )
202 geom.reset( geom->buffer( 0, 0 ) );
210 cFeat.geometries.append( geom.take() );
226 for ( FeatureCategoryVector::iterator cit = mFeaturesCategories.begin(); cit != mFeaturesCategories.end(); ++cit )
229 if ( mPreprocessingEnabled )
251 finalMulti.append( mExtentPolygon );
266 for (
int i = 0; i < multi.size(); i++ )
272 if ( exterior.count() < 4 || exterior[0] != exterior[exterior.count() - 1] )
274 finalMulti[0].append( exterior );
277 for (
int j = 1; j < multi[i].size(); j++ )
280 new_poly.append( multi[i][j] );
281 finalMulti.append( new_poly );
288 mSubRenderer->renderFeature( feat, mContext );
290 for ( FeatureCategoryVector::iterator cit = mFeaturesCategories.begin(); cit != mFeaturesCategories.end(); ++cit )
302 if ( mFeaturesCategories.isEmpty() )
307 mSubRenderer->renderFeature( feat, mContext );
311 foreach ( FeatureDecoration deco, mFeatureDecorations )
313 mSubRenderer->renderFeature( deco.feature, mContext, deco.layer, deco.selected, deco.drawMarkers );
316 mSubRenderer->stopRender( mContext );
323 return "INVERTED: NULL";
325 return "INVERTED [" + mSubRenderer->dump() +
"]";
331 if ( mSubRenderer.isNull() )
347 QDomElement embeddedRendererElem = element.firstChildElement(
"renderer-v2" );
348 if ( !embeddedRendererElem.isNull() )
359 rendererElem.setAttribute(
"type",
"invertedPolygonRenderer" );
364 QDomElement embeddedRendererElem = mSubRenderer->save( doc );
365 rendererElem.appendChild( embeddedRendererElem );
377 return mSubRenderer->symbolForFeature( feature );
384 return mSubRenderer->originalSymbolForFeature( feat );
393 return mSubRenderer->symbolsForFeature( feature );
400 return mSubRenderer->originalSymbolsForFeature( feat );
409 return mSubRenderer->symbols();
418 return mSubRenderer->capabilities();
425 return QList<QString>();
427 return mSubRenderer->usedAttributes();
436 return mSubRenderer->legendSymbologyItems( iconSize );
445 return mSubRenderer->legendSymbolItems( scaleDenominator, rule );
454 return mSubRenderer->willRenderFeature( feat );
459 if ( renderer->
type() ==
"invertedPolygonRenderer" )
464 if ( renderer->
type() ==
"singleSymbol" ||
465 renderer->
type() ==
"categorizedSymbol" ||
466 renderer->
type() ==
"graduatedSymbol" ||
467 renderer->
type() ==
"RuleRenderer" )