QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
QgsFeatureRendererV2 Class Reference

#include <qgsrendererv2.h>

Inheritance diagram for QgsFeatureRendererV2:
Inheritance graph
[legend]

Public Types

enum  Capabilities {
  SymbolLevels = 1, RotationField = 1 << 1, MoreSymbolsPerFeature = 1 << 2, Filter = 1 << 3,
  ScaleDependent = 1 << 4
}

Public Member Functions

QString type () const
virtual QgsSymbolV2symbolForFeature (QgsFeature &feature)=0
 to be overridden
virtual void startRender (QgsRenderContext &context, const QgsVectorLayer *vlayer)=0
virtual void stopRender (QgsRenderContext &context)=0
virtual QList< QString > usedAttributes ()=0
virtual ~QgsFeatureRendererV2 ()
virtual QgsFeatureRendererV2clone ()=0
virtual bool renderFeature (QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
virtual QString dump () const
 for debugging
virtual int capabilities ()
 returns bitwise OR-ed capabilities of the renderer
virtual QgsSymbolV2List symbols ()=0
 for symbol levels
bool usingSymbolLevels () const
void setUsingSymbolLevels (bool usingSymbolLevels)
virtual QDomElement save (QDomDocument &doc)
 store renderer info to XML element
virtual QDomElement writeSld (QDomDocument &doc, const QgsVectorLayer &layer) const
 create the SLD UserStyle element following the SLD v1.1 specs
virtual void toSld (QDomDocument &doc, QDomElement &element) const
 used from subclasses to create SLD Rule elements following SLD v1.1 specs
virtual QgsLegendSymbologyList legendSymbologyItems (QSize iconSize)
 return a list of symbology items for the legend
virtual QgsLegendSymbolList legendSymbolItems (double scaleDenominator=-1, QString rule="")
 return a list of item text / symbol
void setVertexMarkerAppearance (int type, int size)
 set type and size of editing vertex markers for subsequent rendering
virtual QString rotationField () const
 return rotation field name (or empty string if not set or not supported by renderer)
virtual void setRotationField (QString fieldName)
 sets rotation field of renderer (if supported by the renderer)
virtual bool willRenderFeature (QgsFeature &feat)
 return whether the renderer will render a feature or not.
virtual QgsSymbolV2List symbolsForFeature (QgsFeature &feat)
 return list of symbols used for rendering the feature.

Static Public Member Functions

static QgsFeatureRendererV2defaultRenderer (QGis::GeometryType geomType)
 return a new renderer - used by default in vector layers
static QgsFeatureRendererV2load (QDomElement &symbologyElem)
 create a renderer from XML element
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

Protected Member Functions

 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
void renderVertexMarkerPolyline (QPolygonF &pts, QgsRenderContext &context)
 render editing vertex marker for a polyline
void renderVertexMarkerPolygon (QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
 render editing vertex marker for a polygon
void setScaleMethodToSymbol (QgsSymbolV2 *symbol, int scaleMethod)

Static Protected Member Functions

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

QString mType
bool mUsingSymbolLevels
int mCurrentVertexMarkerType
 The current type of editing marker.
int mCurrentVertexMarkerSize
 The current size of editing marker.

Detailed Description

Definition at line 68 of file qgsrendererv2.h.

Member Enumeration Documentation

Enumerator:
SymbolLevels 
RotationField 
MoreSymbolsPerFeature 
Filter 
ScaleDependent 

Definition at line 99 of file qgsrendererv2.h.

Constructor & Destructor Documentation

virtual QgsFeatureRendererV2::~QgsFeatureRendererV2 ( )
inlinevirtual

Definition at line 90 of file qgsrendererv2.h.

QgsFeatureRendererV2::QgsFeatureRendererV2 ( QString  type)
protected

Definition at line 203 of file qgsrendererv2.cpp.

Member Function Documentation

const unsigned char * QgsFeatureRendererV2::_getLineString ( QPolygonF &  pts,
QgsRenderContext context,
const unsigned char *  wkb 
)
staticprotected
const unsigned char * QgsFeatureRendererV2::_getPoint ( QPointF &  pt,
QgsRenderContext context,
const unsigned char *  wkb 
)
staticprotected
const unsigned char * QgsFeatureRendererV2::_getPolygon ( QPolygonF &  pts,
QList< QPolygonF > &  holes,
QgsRenderContext context,
const unsigned char *  wkb 
)
staticprotected
virtual int QgsFeatureRendererV2::capabilities ( )
inlinevirtual
virtual QgsFeatureRendererV2* QgsFeatureRendererV2::clone ( )
pure virtual
QgsFeatureRendererV2 * QgsFeatureRendererV2::defaultRenderer ( QGis::GeometryType  geomType)
static

return a new renderer - used by default in vector layers

Definition at line 210 of file qgsrendererv2.cpp.

References QgsSymbolV2::defaultSymbol().

Referenced by QgsPointDisplacementRenderer::QgsPointDisplacementRenderer(), QgsVectorLayer::QgsVectorLayer(), and QgsVectorLayer::readSymbology().

QString QgsFeatureRendererV2::dump ( ) const
virtual
QgsLegendSymbolList QgsFeatureRendererV2::legendSymbolItems ( double  scaleDenominator = -1,
QString  rule = "" 
)
virtual
QgsLegendSymbologyList QgsFeatureRendererV2::legendSymbologyItems ( QSize  iconSize)
virtual
QgsFeatureRendererV2 * QgsFeatureRendererV2::load ( QDomElement &  symbologyElem)
static
QgsFeatureRendererV2 * QgsFeatureRendererV2::loadSld ( const QDomNode &  node,
QGis::GeometryType  geomType,
QString &  errorMessage 
)
static

create a new renderer according to the information contained in the UserStyle element of a SLD style document

Parameters
nodethe node in the SLD document whose the UserStyle element is a child
geomTypethe geometry type of the features, used to convert Symbolizer elements
errorMessageit will contain the error message if something went wrong
Returns
the renderer
Note
added in 1.9

Definition at line 400 of file qgsrendererv2.cpp.

References QgsRendererV2AbstractMetadata::createRendererFromSld(), QgsRendererV2Registry::instance(), QgsDebugMsg, and QgsRendererV2Registry::rendererMetadata().

Referenced by QgsVectorLayer::readSld().

bool QgsFeatureRendererV2::renderFeature ( QgsFeature feature,
QgsRenderContext context,
int  layer = -1,
bool  selected = false,
bool  drawVertexMarker = false 
)
virtual
void QgsFeatureRendererV2::renderFeatureWithSymbol ( QgsFeature feature,
QgsSymbolV2 symbol,
QgsRenderContext context,
int  layer,
bool  selected,
bool  drawVertexMarker 
)
protected
void QgsFeatureRendererV2::renderVertexMarker ( QPointF &  pt,
QgsRenderContext context 
)
protected

render editing vertex marker at specified point

Definition at line 524 of file qgsrendererv2.cpp.

References QgsVectorLayer::drawVertexMarker(), mCurrentVertexMarkerSize, mCurrentVertexMarkerType, and QgsRenderContext::painter().

Referenced by renderVertexMarkerPolygon(), and renderVertexMarkerPolyline().

void QgsFeatureRendererV2::renderVertexMarkerPolygon ( QPolygonF &  pts,
QList< QPolygonF > *  rings,
QgsRenderContext context 
)
protected

render editing vertex marker for a polygon

Definition at line 537 of file qgsrendererv2.cpp.

References renderVertexMarker().

Referenced by renderFeatureWithSymbol().

void QgsFeatureRendererV2::renderVertexMarkerPolyline ( QPolygonF &  pts,
QgsRenderContext context 
)
protected

render editing vertex marker for a polyline

Definition at line 531 of file qgsrendererv2.cpp.

References renderVertexMarker().

Referenced by renderFeatureWithSymbol().

virtual QString QgsFeatureRendererV2::rotationField ( ) const
inlinevirtual

return rotation field name (or empty string if not set or not supported by renderer)

Note
added in 1.9

Reimplemented in QgsGraduatedSymbolRendererV2, QgsCategorizedSymbolRendererV2, and QgsSingleSymbolRendererV2.

Definition at line 159 of file qgsrendererv2.h.

QDomElement QgsFeatureRendererV2::save ( QDomDocument &  doc)
virtual
virtual void QgsFeatureRendererV2::setRotationField ( QString  fieldName)
inlinevirtual

sets rotation field of renderer (if supported by the renderer)

Note
added in 1.9

Reimplemented in QgsGraduatedSymbolRendererV2, QgsCategorizedSymbolRendererV2, and QgsSingleSymbolRendererV2.

Definition at line 162 of file qgsrendererv2.h.

void QgsFeatureRendererV2::setScaleMethodToSymbol ( QgsSymbolV2 symbol,
int  scaleMethod 
)
protected
void QgsFeatureRendererV2::setUsingSymbolLevels ( bool  usingSymbolLevels)
inline
void QgsFeatureRendererV2::setVertexMarkerAppearance ( int  type,
int  size 
)

set type and size of editing vertex markers for subsequent rendering

Definition at line 518 of file qgsrendererv2.cpp.

References mCurrentVertexMarkerSize, mCurrentVertexMarkerType, size, and type().

Referenced by QgsVectorLayer::draw(), and QgsVectorLayer::drawRendererV2Levels().

virtual void QgsFeatureRendererV2::startRender ( QgsRenderContext context,
const QgsVectorLayer vlayer 
)
pure virtual
virtual void QgsFeatureRendererV2::stopRender ( QgsRenderContext context)
pure virtual
virtual QgsSymbolV2* QgsFeatureRendererV2::symbolForFeature ( QgsFeature feature)
pure virtual
virtual QgsSymbolV2List QgsFeatureRendererV2::symbols ( )
pure virtual
QgsSymbolV2List QgsFeatureRendererV2::symbolsForFeature ( QgsFeature feat)
virtual

return list of symbols used for rendering the feature.

For renderers that do not support MoreSymbolsPerFeature it is more efficient to use symbolForFeature()

Note
added in 1.9

Reimplemented in QgsRuleBasedRendererV2.

Definition at line 552 of file qgsrendererv2.cpp.

References symbolForFeature().

Referenced by QgsVectorFileWriter::addFeature(), QgsVectorLayer::countSymbolFeatures(), and QgsPointDisplacementRenderer::firstSymbolForFeature().

virtual void QgsFeatureRendererV2::toSld ( QDomDocument &  doc,
QDomElement &  element 
) const
inlinevirtual

used from subclasses to create SLD Rule elements following SLD v1.1 specs

Note
added in 1.9

Reimplemented in QgsRuleBasedRendererV2, QgsCategorizedSymbolRendererV2, QgsGraduatedSymbolRendererV2, QgsSingleSymbolRendererV2, and QgsPointDisplacementRenderer.

Definition at line 143 of file qgsrendererv2.h.

Referenced by QgsPointDisplacementRenderer::toSld(), and writeSld().

QString QgsFeatureRendererV2::type ( ) const
inline
virtual QList<QString> QgsFeatureRendererV2::usedAttributes ( )
pure virtual
bool QgsFeatureRendererV2::usingSymbolLevels ( ) const
inline
virtual bool QgsFeatureRendererV2::willRenderFeature ( QgsFeature feat)
inlinevirtual

return whether the renderer will render a feature or not.

Must be called between startRender() and stopRender() calls. Default implementation uses symbolForFeature().

Note
added in 1.9

Reimplemented in QgsRuleBasedRendererV2.

Definition at line 168 of file qgsrendererv2.h.

Referenced by QgsVectorLayer::drawLabels(), QgsAttributeTableFilterModel::generateListOfVisibleFeatures(), and QgsMapToolIdentify::identifyVectorLayer().

QDomElement QgsFeatureRendererV2::writeSld ( QDomDocument &  doc,
const QgsVectorLayer layer 
) const
virtual

create the SLD UserStyle element following the SLD v1.1 specs

Note
added in 1.9

Definition at line 489 of file qgsrendererv2.cpp.

References QgsMapLayer::name(), and toSld().

Referenced by QgsVectorLayer::writeSld().

Member Data Documentation

int QgsFeatureRendererV2::mCurrentVertexMarkerSize
protected

The current size of editing marker.

Definition at line 206 of file qgsrendererv2.h.

Referenced by renderVertexMarker(), and setVertexMarkerAppearance().

int QgsFeatureRendererV2::mCurrentVertexMarkerType
protected

The current type of editing marker.

Definition at line 204 of file qgsrendererv2.h.

Referenced by renderVertexMarker(), and setVertexMarkerAppearance().

QString QgsFeatureRendererV2::mType
protected

Definition at line 199 of file qgsrendererv2.h.

bool QgsFeatureRendererV2::mUsingSymbolLevels
protected

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