29 #include <QDomDocument> 30 #include <QDomElement> 34 , mPreprocessingEnabled( false )
54 mSubRenderer.
reset( subRenderer );
58 mSubRenderer.
reset(
nullptr );
64 return mSubRenderer.
data();
72 mSubRenderer->setLegendSymbolItem( key, symbol );
80 return mSubRenderer->legendSymbolItemsCheckable();
88 return mSubRenderer->legendSymbolItemChecked( key );
96 return mSubRenderer->checkLegendSymbolItem( key, state );
107 mSubRenderer->startRender( context, fields );
109 mFeaturesCategories.
clear();
110 mSymbolCategories.
clear();
111 mFeatureDecorations.
clear();
127 e.
adjust( -e.width()*5, -e.height()*5, e.width()*5, e.height()*5 );
129 exteriorRing << mtp.toMapCoordinates( e.topLeft() );
130 exteriorRing << mtp.toMapCoordinates( e.topRight() );
131 exteriorRing << mtp.toMapCoordinates( e.bottomRight() );
132 exteriorRing << mtp.toMapCoordinates( e.bottomLeft() );
133 exteriorRing << mtp.toMapCoordinates( e.topLeft() );
149 mContext.
setExtent(
QgsRectangle( mtp.toMapCoordinates( v.topLeft() ), mtp.toMapCoordinates( v.bottomRight() ) ) );
153 mExtentPolygon.
clear();
154 mExtentPolygon.
append( exteriorRing );
167 if ( selected || drawVertexMarker )
169 mFeatureDecorations.
append( FeatureDecoration( feature, selected, drawVertexMarker, layer ) );
189 QgsSymbolV2List syms( mSubRenderer->symbolsForFeature( feature, context ) );
193 catId.
append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
198 QgsSymbolV2* sym = mSubRenderer->symbolForFeature( feature, context );
201 catId.
append( reinterpret_cast<const char*>( &sym ),
sizeof( sym ) );
210 if ( ! mSymbolCategories.
contains( catId ) )
212 CombinedFeature cFeat;
214 cFeat.feature = feature;
215 mSymbolCategories.
insert( catId, mSymbolCategories.
count() );
216 mFeaturesCategories.
append( cFeat );
220 CombinedFeature& cFeat = mFeaturesCategories[ mSymbolCategories[catId] ];
230 geom->transform( *xform );
233 if ( mPreprocessingEnabled )
236 if ( ! geom->isGeosValid() )
238 geom.
reset( geom->buffer( 0, 0 ) );
246 cFeat.geometries.append( geom.
take() );
262 Q_FOREACH (
const CombinedFeature& cit, mFeaturesCategories )
265 if ( mPreprocessingEnabled )
271 QgsGeometry *
final = rect->difference( const_cast<QgsGeometry*>( unioned.
data() ) );
287 finalMulti.
append( mExtentPolygon );
302 for (
int i = 0; i < multi.
size(); i++ )
308 if ( exterior.
count() < 4 || exterior[0] != exterior[exterior.
count() - 1] )
310 finalMulti[0].
append( exterior );
313 for (
int j = 1; j < multi[i].
size(); j++ )
316 new_poly.
append( multi[i][j] );
317 finalMulti.
append( new_poly );
326 mSubRenderer->renderFeature( feat, mContext );
329 Q_FOREACH (
const CombinedFeature& cit, mFeaturesCategories )
341 if ( mFeaturesCategories.
isEmpty() )
346 mSubRenderer->renderFeature( feat, mContext );
350 Q_FOREACH ( FeatureDecoration deco, mFeatureDecorations )
352 mSubRenderer->renderFeature( deco.feature, mContext, deco.layer, deco.selected, deco.drawMarkers );
355 mSubRenderer->stopRender( mContext );
362 return "INVERTED: NULL";
364 return "INVERTED [" + mSubRenderer->dump() +
']';
370 if ( mSubRenderer.
isNull() )
388 if ( !embeddedRendererElem.
isNull() )
400 rendererElem.
setAttribute(
"type",
"invertedPolygonRenderer" );
406 QDomElement embeddedRendererElem = mSubRenderer->save( doc );
430 return mSubRenderer->symbolForFeature( feature, context );
437 return mSubRenderer->originalSymbolForFeature( feat, context );
446 return mSubRenderer->symbolsForFeature( feature, context );
453 return mSubRenderer->originalSymbolsForFeature( feat, context );
462 return mSubRenderer->symbols( context );
471 return mSubRenderer->capabilities();
480 return mSubRenderer->usedAttributes();
489 return mSubRenderer->legendSymbologyItems( iconSize );
498 return mSubRenderer->legendSymbolItems( scaleDenominator, rule );
507 return mSubRenderer->willRenderFeature( feat, context );
515 return mSubRenderer->legendSymbolItemsV2();
520 if ( renderer->
type() ==
"invertedPolygonRenderer" )
525 if ( renderer->
type() ==
"singleSymbol" ||
526 renderer->
type() ==
"categorizedSymbol" ||
527 renderer->
type() ==
"graduatedSymbol" ||
528 renderer->
type() ==
"RuleRenderer" )
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
virtual ~QgsInvertedPolygonRenderer()
#define RENDERER_TAG_NAME
A rectangle specified with double values.
virtual bool legendSymbolItemChecked(const QString &key) override
items of symbology items in legend is checked
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.
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.
void setEmbeddedRenderer(QgsFeatureRendererV2 *subRenderer) override
Sets an embedded renderer (subrenderer) for this feature renderer.
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.
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual QString dump() const override
void setExtent(const QgsRectangle &extent)
QgsPaintEffect * mPaintEffect
void setCoordinateTransform(const QgsCoordinateTransform *t)
Sets coordinate transformation.
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)
const QgsFeatureRendererV2 * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
virtual void checkLegendSymbolItem(const QString &key, bool state=true) override
item in symbology was checked
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.
bool preprocessingEnabled() const
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)
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.
const QgsCoordinateTransform * coordinateTransform() const
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const override
Return a list of symbology items for the legend.
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
virtual void setLegendSymbolItem(const QString &key, QgsSymbolV2 *symbol) override
Sets the symbol to be used for a legend symbol item.
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.
virtual QgsLegendSymbologyList legendSymbologyItems(QSize iconSize) override
Proxy that will call this method on the embedded renderer.
static QgsGeometry * unaryUnion(const QList< QgsGeometry *> &geometryList)
Compute the unary union on a list of geometries.
QgsFeatureRequest::OrderBy orderBy() const
Get the order in which features shall be processed by this renderer.
void copyRendererData(QgsFeatureRendererV2 *destRenderer) const
Clones generic renderer data to another renderer.
Contains information about the context of a rendering operation.
may use more than one symbol to render a feature: symbolsForFeature() will return them ...
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
const QgsMapToPixel & mapToPixel() const
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
QgsFeatureRequest::OrderBy mOrderBy
QDomElement firstChildElement(const QString &tagName) const
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
int count(const T &value) const
void adjust(int dx1, int dy1, int dx2, int dy2)
virtual int capabilities() override
Proxy that will call this method on the embedded renderer.
virtual bool legendSymbolItemsCheckable() const override
items of symbology items in legend should be checkable
static Type flatType(Type type)
Returns the flat type for a WKB type.
iterator insert(const Key &key, const T &value)
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
QgsInvertedPolygonRenderer(QgsFeatureRendererV2 *embeddedRenderer=nullptr)
Constructor.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.