29 #include <QDomDocument> 30 #include <QDomElement> 34 , mPreprocessingEnabled( false )
54 mSubRenderer.
reset( const_cast<QgsFeatureRendererV2*>( subRenderer )->
clone() );
58 mSubRenderer.
reset(
nullptr );
64 return mSubRenderer.
data();
75 mSubRenderer->startRender( context, fields );
77 mFeaturesCategories.
clear();
78 mSymbolCategories.
clear();
79 mFeatureDecorations.
clear();
95 e.
adjust( -e.width()*5, -e.height()*5, e.width()*5, e.height()*5 );
97 exteriorRing << mtp.toMapCoordinates( e.topLeft() );
98 exteriorRing << mtp.toMapCoordinates( e.topRight() );
99 exteriorRing << mtp.toMapCoordinates( e.bottomRight() );
100 exteriorRing << mtp.toMapCoordinates( e.bottomLeft() );
101 exteriorRing << mtp.toMapCoordinates( e.topLeft() );
117 mContext.
setExtent(
QgsRectangle( mtp.toMapCoordinates( v.topLeft() ), mtp.toMapCoordinates( v.bottomRight() ) ) );
121 mExtentPolygon.
clear();
122 mExtentPolygon.
append( exteriorRing );
135 if ( selected || drawVertexMarker )
137 mFeatureDecorations.
append( FeatureDecoration( feature, selected, drawVertexMarker, layer ) );
157 QgsSymbolV2List syms( mSubRenderer->symbolsForFeature( feature, context ) );
161 catId.
append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
166 QgsSymbolV2* sym = mSubRenderer->symbolForFeature( feature, context );
169 catId.
append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
178 if ( ! mSymbolCategories.
contains( catId ) )
180 CombinedFeature cFeat;
182 cFeat.feature = feature;
183 mSymbolCategories.
insert( catId, mSymbolCategories.
count() );
184 mFeaturesCategories.
append( cFeat );
188 CombinedFeature& cFeat = mFeaturesCategories[ mSymbolCategories[catId] ];
198 geom->transform( *xform );
201 if ( mPreprocessingEnabled )
204 if ( ! geom->isGeosValid() )
206 geom.
reset( geom->buffer( 0, 0 ) );
214 cFeat.geometries.append( geom.
take() );
230 Q_FOREACH (
const CombinedFeature& cit, mFeaturesCategories )
233 if ( mPreprocessingEnabled )
239 QgsGeometry *
final = rect->difference( const_cast<QgsGeometry*>( unioned.
data() ) );
255 finalMulti.
append( mExtentPolygon );
270 for (
int i = 0; i < multi.
size(); i++ )
276 if ( exterior.
count() < 4 || exterior[0] != exterior[exterior.
count() - 1] )
278 finalMulti[0].
append( exterior );
281 for (
int j = 1; j < multi[i].
size(); j++ )
284 new_poly.
append( multi[i][j] );
285 finalMulti.
append( new_poly );
294 mSubRenderer->renderFeature( feat, mContext );
297 Q_FOREACH (
const CombinedFeature& cit, mFeaturesCategories )
309 if ( mFeaturesCategories.
isEmpty() )
314 mSubRenderer->renderFeature( feat, mContext );
318 Q_FOREACH ( FeatureDecoration deco, mFeatureDecorations )
320 mSubRenderer->renderFeature( deco.feature, mContext, deco.layer, deco.selected, deco.drawMarkers );
323 mSubRenderer->stopRender( mContext );
330 return "INVERTED: NULL";
332 return "INVERTED [" + mSubRenderer->dump() +
']';
338 if ( mSubRenderer.
isNull() )
356 if ( !embeddedRendererElem.
isNull() )
369 rendererElem.
setAttribute(
"type",
"invertedPolygonRenderer" );
375 QDomElement embeddedRendererElem = mSubRenderer->save( doc );
399 return mSubRenderer->symbolForFeature( feature, context );
406 return mSubRenderer->originalSymbolForFeature( feat, context );
415 return mSubRenderer->symbolsForFeature( feature, context );
422 return mSubRenderer->originalSymbolsForFeature( feat, context );
431 return mSubRenderer->symbols( context );
440 return mSubRenderer->capabilities();
449 return mSubRenderer->usedAttributes();
458 return mSubRenderer->legendSymbologyItems( iconSize );
467 return mSubRenderer->legendSymbolItems( scaleDenominator, rule );
476 return mSubRenderer->willRenderFeature( feat, context );
481 if ( renderer->
type() ==
"invertedPolygonRenderer" )
486 if ( renderer->
type() ==
"singleSymbol" ||
487 renderer->
type() ==
"categorizedSymbol" ||
488 renderer->
type() ==
"graduatedSymbol" ||
489 renderer->
type() ==
"RuleRenderer" )
virtual ~QgsInvertedPolygonRenderer()
#define RENDERER_TAG_NAME
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
A rectangle specified with double values.
bool contains(const Key &key) const
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) override
Renders a given feature.
QgsFeatureRequest::OrderBy orderBy() const
Get the order in which features shall be processed by this renderer.
QList< QgsSymbolV2 * > QgsSymbolV2List
QDomNode appendChild(const QDomNode &newChild)
void append(const T &value)
QString attribute(const QString &name, const QString &defValue) const
virtual bool willRenderFeature(QgsFeature &feat, QgsRenderContext &context) override
Proxy that will call this method on the embedded renderer.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
static QgsInvertedPolygonRenderer * convertFromRenderer(const QgsFeatureRendererV2 *renderer)
Creates a QgsInvertedPolygonRenderer by a conversion from an existing renderer.
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
virtual QgsInvertedPolygonRenderer * clone() const override
Used to clone this feature renderer.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual QString dump() const override
const QgsCoordinateTransform * coordinateTransform() const
void setExtent(const QgsRectangle &extent)
QgsPaintEffect * mPaintEffect
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
void setEmbeddedRenderer(const QgsFeatureRendererV2 *subRenderer)
Sets the embedded renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields) override
Needs to be called when a new render cycle is started.
Perform transforms between map coordinates and device coordinates.
virtual QgsFeatureRendererV2 * clone() const =0
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
void append(const T &value)
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
virtual QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat, QgsRenderContext &context) override
Proxy that will call this method on the embedded renderer.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="") override
Proxy that will call this method on the embedded renderer.
void setAttribute(const QString &name, const QString &value)
void setPreprocessingEnabled(bool enabled)
bool preprocessingEnabled() const
int toInt(bool *ok, int base) const
virtual QgsSymbolV2 * originalSymbolForFeature(QgsFeature &feat, QgsRenderContext &context) override
Proxy that will call this method on the embedded renderer.
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
QList< QPair< QString, QPixmap > > QgsLegendSymbologyList
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature, QgsRenderContext &context) override
Proxy that will call this method on the embedded renderer.
virtual QList< QString > usedAttributes() override
Proxy that will call this method on the embedded renderer.
QByteArray & append(char ch)
virtual QDomElement save(QDomDocument &doc) override
Creates an XML representation of the renderer.
QgsExpressionContext & expressionContext()
Gets the expression context.
void copyRendererData(QgsFeatureRendererV2 *destRenderer) const
Clones generic renderer data to another renderer.
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize) override
Proxy that will call this method on the embedded renderer.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
Contains information about the context of a rendering operation.
const QgsFeatureRendererV2 * embeddedRenderer() const
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
QgsFeatureRequest::OrderBy mOrderBy
QDomElement firstChildElement(const QString &tagName) const
int count(const T &value) const
void adjust(int dx1, int dy1, int dx2, int dy2)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
virtual int capabilities() override
Proxy that will call this method on the embedded renderer.
const QgsMapToPixel & mapToPixel() const
static QgsGeometry * unaryUnion(const QList< QgsGeometry * > &geometryList)
Compute the unary union on a list of geometries.
iterator insert(const Key &key, const T &value)
QgsInvertedPolygonRenderer(const QgsFeatureRendererV2 *embeddedRenderer=nullptr)
Constructor.
static QgsGeometry * fromMultiPolygon(const QgsMultiPolygon &multipoly)
Creates a new geometry from a QgsMultiPolygon.
static QgsGeometry * fromPolygon(const QgsPolygon &polygon)
Creates a new geometry from a QgsPolygon.
virtual void stopRender(QgsRenderContext &context) override
The actual rendering will take place here.
static QgsFeatureRendererV2 * create(QDomElement &element)
Creates a renderer out of an XML, for loading.
QDomElement createElement(const QString &tagName)
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat, QgsRenderContext &context) override
Proxy that will call this method on the embedded renderer.
QList< QPair< QString, QgsSymbolV2 * > > QgsLegendSymbolList
int count(const Key &key) const