QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
QgsInvertedPolygonRenderer Class Reference

QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted, where the exterior is turned to an interior and where the exterior theoretically spans the entire plane, allowing to mask the surroundings of some features. More...

#include <qgsinvertedpolygonrenderer.h>

Inheritance diagram for QgsInvertedPolygonRenderer:
Inheritance graph
[legend]
Collaboration diagram for QgsInvertedPolygonRenderer:
Collaboration graph
[legend]

Classes

struct  CombinedFeature
 Structure where the reversed geometry is built during renderFeature. More...
 
struct  FeatureDecoration
 Class used to represent features that must be rendered with decorations (selection, vertex markers) More...
 

Public Member Functions

 QgsInvertedPolygonRenderer (const QgsFeatureRendererV2 *embeddedRenderer=0)
 Constructor. More...
 
virtual ~QgsInvertedPolygonRenderer ()
 
virtual QgsFeatureRendererV2clone ()
 Used to clone this feature renderer. More...
 
virtual void startRender (QgsRenderContext &context, const QgsFields &fields)
 
virtual bool renderFeature (QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
 Renders a given feature. More...
 
virtual void stopRender (QgsRenderContext &context)
 The actual rendering will take place here. More...
 
virtual QString dump () const
 
virtual QList< QString > usedAttributes ()
 Proxy that will call this method on the embedded renderer. More...
 
virtual int capabilities ()
 Proxy that will call this method on the embedded renderer. More...
 
virtual QgsSymbolV2List symbols ()
 Proxy that will call this method on the embedded renderer. More...
 
virtual QgsSymbolV2symbolForFeature (QgsFeature &feature)
 Proxy that will call this method on the embedded renderer. More...
 
virtual QgsSymbolV2List symbolsForFeature (QgsFeature &feat)
 Proxy that will call this method on the embedded renderer. More...
 
virtual QgsLegendSymbologyList legendSymbologyItems (QSize iconSize)
 Proxy that will call this method on the embedded renderer. More...
 
virtual QgsLegendSymbolList legendSymbolItems (double scaleDenominator=-1, QString rule="")
 Proxy that will call this method on the embedded renderer. More...
 
virtual bool willRenderFeature (QgsFeature &feat)
 Proxy that will call this method on the embedded renderer. More...
 
virtual QDomElement save (QDomDocument &doc)
 Creates an XML representation of the renderer. More...
 
void setEmbeddedRenderer (const QgsFeatureRendererV2 *subRenderer)
 sets the embedded renderer More...
 
const QgsFeatureRendererV2embeddedRenderer () const
 
bool preprocessingEnabled () const
 
void setPreprocessingEnabled (bool enabled)
 
- Public Member Functions inherited from QgsFeatureRendererV2
QString type () const
 
virtual Q_DECL_DEPRECATED void startRender (QgsRenderContext &context, const QgsVectorLayer *vlayer)
 
virtual ~QgsFeatureRendererV2 ()
 
bool usingSymbolLevels () const
 
void setUsingSymbolLevels (bool usingSymbolLevels)
 
virtual QDomElement writeSld (QDomDocument &doc, const QgsVectorLayer &layer) const
 create the SLD UserStyle element following the SLD v1.1 specs More...
 
virtual void toSld (QDomDocument &doc, QDomElement &element) const
 used from subclasses to create SLD Rule elements following SLD v1.1 specs More...
 
virtual bool legendSymbolItemsCheckable () const
 items of symbology items in legend should be checkable More...
 
virtual bool legendSymbolItemChecked (int index)
 items of symbology items in legend is checked More...
 
virtual void checkLegendSymbolItem (int index, bool state=true)
 item in symbology was checked More...
 
void setVertexMarkerAppearance (int type, int size)
 set type and size of editing vertex markers for subsequent rendering More...
 
virtual QString rotationField () const
 return rotation field name (or empty string if not set or not supported by renderer) More...
 
virtual void setRotationField (QString fieldName)
 sets rotation field of renderer (if supported by the renderer) More...
 

Static Public Member Functions

static QgsFeatureRendererV2create (QDomElement &element)
 Creates a renderer out of an XML, for loading. More...
 
- Static Public Member Functions inherited from QgsFeatureRendererV2
static QgsFeatureRendererV2defaultRenderer (QGis::GeometryType geomType)
 return a new renderer - used by default in vector layers More...
 
static QgsFeatureRendererV2load (QDomElement &symbologyElem)
 create a renderer from XML element More...
 
static QgsFeatureRendererV2loadSld (const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage)
 create a new renderer according to the information contained in the UserStyle element of a SLD style document More...
 

Private Types

typedef QVector< CombinedFeatureFeatureCategoryVector
 

Private Member Functions

 QgsInvertedPolygonRenderer (const QgsInvertedPolygonRenderer &)
 Private copy constructor. More...
 
QgsInvertedPolygonRendereroperator= (const QgsInvertedPolygonRenderer &)
 Private assignment operator. More...
 

Private Attributes

QScopedPointer
< QgsFeatureRendererV2
mSubRenderer
 Embedded renderer. More...
 
FeatureCategoryVector mFeaturesCategories
 where features are stored, based on the index of their symbol category More...
 
QMap< QByteArray, int > mSymbolCategories
 maps a category to an index More...
 
QgsPolygon mExtentPolygon
 the polygon used as exterior ring that covers the current extent More...
 
QgsRenderContext mContext
 the context used for rendering More...
 
QgsFields mFields
 fields of each feature More...
 
QList< FeatureDecorationmFeatureDecorations
 
bool mPreprocessingEnabled
 whether to preprocess (merge) geometries before rendering More...
 

Additional Inherited Members

- Public Types inherited from QgsFeatureRendererV2
enum  Capabilities {
  SymbolLevels = 1, RotationField = 1 << 1, MoreSymbolsPerFeature = 1 << 2, Filter = 1 << 3,
  ScaleDependent = 1 << 4
}
 
- Protected Member Functions inherited from QgsFeatureRendererV2
 QgsFeatureRendererV2 (QString type)
 
void renderFeatureWithSymbol (QgsFeature &feature, QgsSymbolV2 *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
 
void renderVertexMarker (QPointF &pt, QgsRenderContext &context)
 render editing vertex marker at specified point More...
 
void renderVertexMarkerPolyline (QPolygonF &pts, QgsRenderContext &context)
 render editing vertex marker for a polyline More...
 
void renderVertexMarkerPolygon (QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
 render editing vertex marker for a polygon More...
 
void setScaleMethodToSymbol (QgsSymbolV2 *symbol, int scaleMethod)
 
- Static Protected Member Functions inherited from QgsFeatureRendererV2
static const unsigned char * _getPoint (QPointF &pt, QgsRenderContext &context, const unsigned char *wkb)
 
static const unsigned char * _getLineString (QPolygonF &pts, QgsRenderContext &context, const unsigned char *wkb)
 
static const unsigned char * _getPolygon (QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, const unsigned char *wkb)
 
- Protected Attributes inherited from QgsFeatureRendererV2
QString mType
 
bool mUsingSymbolLevels
 
int mCurrentVertexMarkerType
 The current type of editing marker. More...
 
int mCurrentVertexMarkerSize
 The current size of editing marker. More...
 

Detailed Description

QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted, where the exterior is turned to an interior and where the exterior theoretically spans the entire plane, allowing to mask the surroundings of some features.

It is designed on top of another feature renderer, which is called "embedded" Most of the methods are then only proxies to the embedded renderer.

Features are collected to form one "inverted" polygon during renderFeature() and rendered on stopRender().

Note
added in 2.4

Definition at line 40 of file qgsinvertedpolygonrenderer.h.

Member Typedef Documentation

Definition at line 136 of file qgsinvertedpolygonrenderer.h.

Constructor & Destructor Documentation

QgsInvertedPolygonRenderer::QgsInvertedPolygonRenderer ( const QgsFeatureRendererV2 embeddedRenderer = 0)

Constructor.

Parameters
embeddedRendereroptional embeddedRenderer. If null, a default one will be assigned

Definition at line 30 of file qgsinvertedpolygonrenderer.cpp.

References QgsFeatureRendererV2::defaultRenderer(), mSubRenderer, QGis::Polygon, and setEmbeddedRenderer().

Referenced by clone(), and create().

QgsInvertedPolygonRenderer::~QgsInvertedPolygonRenderer ( )
virtual

Definition at line 44 of file qgsinvertedpolygonrenderer.cpp.

QgsInvertedPolygonRenderer::QgsInvertedPolygonRenderer ( const QgsInvertedPolygonRenderer )
private

Private copy constructor.

See also
clone()

Member Function Documentation

int QgsInvertedPolygonRenderer::capabilities ( )
virtual

Proxy that will call this method on the embedded renderer.

Reimplemented from QgsFeatureRendererV2.

Definition at line 398 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

Referenced by renderFeature().

QgsFeatureRendererV2 * QgsInvertedPolygonRenderer::clone ( )
virtual

Used to clone this feature renderer.

Implements QgsFeatureRendererV2.

Definition at line 328 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer, preprocessingEnabled(), QgsInvertedPolygonRenderer(), and setPreprocessingEnabled().

Referenced by setEmbeddedRenderer().

QgsFeatureRendererV2 * QgsInvertedPolygonRenderer::create ( QDomElement &  element)
static
QString QgsInvertedPolygonRenderer::dump ( ) const
virtual
Returns
a textual representation of the renderer

Reimplemented from QgsFeatureRendererV2.

Definition at line 319 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

const QgsFeatureRendererV2 * QgsInvertedPolygonRenderer::embeddedRenderer ( ) const
Returns
the current embedded renderer

Definition at line 60 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

QgsLegendSymbolList QgsInvertedPolygonRenderer::legendSymbolItems ( double  scaleDenominator = -1,
QString  rule = "" 
)
virtual

Proxy that will call this method on the embedded renderer.

Note
not available in python bindings

Reimplemented from QgsFeatureRendererV2.

Definition at line 425 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

QgsLegendSymbologyList QgsInvertedPolygonRenderer::legendSymbologyItems ( QSize  iconSize)
virtual

Proxy that will call this method on the embedded renderer.

Reimplemented from QgsFeatureRendererV2.

Definition at line 416 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

QgsInvertedPolygonRenderer& QgsInvertedPolygonRenderer::operator= ( const QgsInvertedPolygonRenderer )
private

Private assignment operator.

See also
clone()
bool QgsInvertedPolygonRenderer::preprocessingEnabled ( ) const
inline
Returns
true if the geometries are to be preprocessed (merged with an union) before rendering.

Definition at line 112 of file qgsinvertedpolygonrenderer.h.

Referenced by clone(), and save().

bool QgsInvertedPolygonRenderer::renderFeature ( QgsFeature feature,
QgsRenderContext context,
int  layer = -1,
bool  selected = false,
bool  drawVertexMarker = false 
)
virtual

Renders a given feature.

This will here collect features. The actual rendering will be postponed to stopRender()

Parameters
featurethe feature to render
contextthe rendering context
layerthe symbol layer to render, if that makes sense
selectedwhether this feature has been selected (this will add decorations)
drawVertexMarkerwhether this feature has vertex markers (in edit mode usually)
Returns
true if the rendering was ok

Reimplemented from QgsFeatureRendererV2.

Definition at line 123 of file qgsinvertedpolygonrenderer.cpp.

References capabilities(), QgsRenderContext::coordinateTransform(), QgsInvertedPolygonRenderer::CombinedFeature::feature, QgsInvertedPolygonRenderer::CombinedFeature::geometries, QgsFeature::geometry(), mFeatureDecorations, mFeaturesCategories, QgsFeatureRendererV2::MoreSymbolsPerFeature, mPreprocessingEnabled, mSubRenderer, mSymbolCategories, QgsRenderContext::painter(), and QgsCoordinateTransform::transform().

QDomElement QgsInvertedPolygonRenderer::save ( QDomDocument &  doc)
virtual

Creates an XML representation of the renderer.

Used for saving purpose

Parameters
docthe XML document where to create the XML subtree
Returns
the created XML subtree

Reimplemented from QgsFeatureRendererV2.

Definition at line 356 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer, preprocessingEnabled(), and RENDERER_TAG_NAME.

void QgsInvertedPolygonRenderer::setEmbeddedRenderer ( const QgsFeatureRendererV2 subRenderer)

sets the embedded renderer

Parameters
subRendererthe embedded renderer (will be cloned)

Definition at line 48 of file qgsinvertedpolygonrenderer.cpp.

References clone(), and mSubRenderer.

Referenced by create(), and QgsInvertedPolygonRenderer().

void QgsInvertedPolygonRenderer::setPreprocessingEnabled ( bool  enabled)
inline
Parameters
enabledenables or disables the preprocessing. When enabled, geometries will be merged with an union before being rendered. It allows to fix some rendering artefacts (when rendering overlapping polygons for instance). This will involve some CPU-demanding computations and is thus disabled by default.

Definition at line 119 of file qgsinvertedpolygonrenderer.h.

Referenced by clone(), and create().

void QgsInvertedPolygonRenderer::startRender ( QgsRenderContext context,
const QgsFields fields 
)
virtual
void QgsInvertedPolygonRenderer::stopRender ( QgsRenderContext context)
virtual
QgsSymbolV2 * QgsInvertedPolygonRenderer::symbolForFeature ( QgsFeature feature)
virtual

Proxy that will call this method on the embedded renderer.

Implements QgsFeatureRendererV2.

Definition at line 371 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

QgsSymbolV2List QgsInvertedPolygonRenderer::symbols ( )
virtual

Proxy that will call this method on the embedded renderer.

Implements QgsFeatureRendererV2.

Definition at line 389 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

QgsSymbolV2List QgsInvertedPolygonRenderer::symbolsForFeature ( QgsFeature feat)
virtual

Proxy that will call this method on the embedded renderer.

Reimplemented from QgsFeatureRendererV2.

Definition at line 380 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

QList< QString > QgsInvertedPolygonRenderer::usedAttributes ( )
virtual

Proxy that will call this method on the embedded renderer.

Implements QgsFeatureRendererV2.

Definition at line 407 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

bool QgsInvertedPolygonRenderer::willRenderFeature ( QgsFeature feat)
virtual

Proxy that will call this method on the embedded renderer.

Reimplemented from QgsFeatureRendererV2.

Definition at line 434 of file qgsinvertedpolygonrenderer.cpp.

References mSubRenderer.

Member Data Documentation

QgsRenderContext QgsInvertedPolygonRenderer::mContext
private

the context used for rendering

Definition at line 147 of file qgsinvertedpolygonrenderer.h.

Referenced by startRender(), and stopRender().

QgsPolygon QgsInvertedPolygonRenderer::mExtentPolygon
private

the polygon used as exterior ring that covers the current extent

Definition at line 144 of file qgsinvertedpolygonrenderer.h.

Referenced by startRender(), and stopRender().

QList<FeatureDecoration> QgsInvertedPolygonRenderer::mFeatureDecorations
private

Definition at line 164 of file qgsinvertedpolygonrenderer.h.

Referenced by renderFeature(), startRender(), and stopRender().

FeatureCategoryVector QgsInvertedPolygonRenderer::mFeaturesCategories
private

where features are stored, based on the index of their symbol category

See also
mSymbolCategories

Definition at line 138 of file qgsinvertedpolygonrenderer.h.

Referenced by renderFeature(), startRender(), and stopRender().

QgsFields QgsInvertedPolygonRenderer::mFields
private

fields of each feature

Definition at line 150 of file qgsinvertedpolygonrenderer.h.

Referenced by startRender(), and stopRender().

bool QgsInvertedPolygonRenderer::mPreprocessingEnabled
private

whether to preprocess (merge) geometries before rendering

Definition at line 167 of file qgsinvertedpolygonrenderer.h.

Referenced by renderFeature(), and stopRender().

QScopedPointer<QgsFeatureRendererV2> QgsInvertedPolygonRenderer::mSubRenderer
private
QMap<QByteArray, int> QgsInvertedPolygonRenderer::mSymbolCategories
private

maps a category to an index

Definition at line 141 of file qgsinvertedpolygonrenderer.h.

Referenced by renderFeature(), and startRender().


The documentation for this class was generated from the following files: