QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
QgsPointDisplacementRenderer Class Reference

A renderer that automatically displaces points with the same position. More...

#include <qgspointdisplacementrenderer.h>

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

Public Member Functions

 QgsPointDisplacementRenderer (const QString &labelAttributeName="")
 ~QgsPointDisplacementRenderer ()
QgsFeatureRendererV2clone ()
virtual void toSld (QDomDocument &doc, QDomElement &element) const
 used from subclasses to create SLD Rule elements following SLD v1.1 specs
bool renderFeature (QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
 Reimplemented from QgsFeatureRendererV2.
QgsSymbolV2symbolForFeature (QgsFeature &feature)
 to be overridden
void startRender (QgsRenderContext &context, const QgsVectorLayer *vlayer)
void stopRender (QgsRenderContext &context)
QList< QString > usedAttributes ()
QgsSymbolV2List symbols ()
 for symbol levels
QDomElement save (QDomDocument &doc)
 store renderer info to XML element
QgsLegendSymbologyList legendSymbologyItems (QSize iconSize)
 return a list of symbology items for the legend
QgsLegendSymbolList legendSymbolItems ()
void setLabelAttributeName (const QString &name)
QString labelAttributeName () const
void setEmbeddedRenderer (QgsFeatureRendererV2 *r)
 Sets embedded renderer (takes ownership)
QgsFeatureRendererV2embeddedRenderer ()
void setDisplacementGroups (const QList< QMap< QgsFeatureId, QgsFeature > > &list)
 not available in python bindings
void setLabelFont (const QFont &f)
QFont labelFont () const
void setCircleWidth (double w)
double circleWidth () const
void setCircleColor (const QColor &c)
QColor circleColor () const
void setLabelColor (const QColor &c)
QColor labelColor () const
void setCircleRadiusAddition (double d)
double circleRadiusAddition () const
void setMaxLabelScaleDenominator (double d)
double maxLabelScaleDenominator () const
QgsMarkerSymbolV2centerSymbol ()
 Returns the symbol for the center of a displacement group (but not ownership of the symbol)
void setCenterSymbol (QgsMarkerSymbolV2 *symbol)
 Sets the center symbol (takes ownership)
void setTolerance (double t)
double tolerance () const
- Public Member Functions inherited from QgsFeatureRendererV2
QString type () const
virtual ~QgsFeatureRendererV2 ()
virtual QString dump () const
 for debugging
virtual int capabilities ()
 returns bitwise OR-ed capabilities of the renderer
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
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 QgsFeatureRendererV2create (QDomElement &symbologyElem)
 create a renderer from XML element
- Static Public Member Functions inherited from QgsFeatureRendererV2
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

Private Member Functions

void createDisplacementGroups (QgsVectorLayer *vlayer, const QgsRectangle &viewExtent)
 Create the displacement groups efficiently using a spatial index.
QgsRectangle searchRect (const QgsPoint &p) const
 Creates a search rectangle with mTolerance.
void printInfoDisplacementGroups ()
 This is a debugging function to check the entries in the displacement groups.
QString getLabel (const QgsFeature &f)
 Returns the label for a feature (using mLabelAttributeName as attribute field)
void renderPoint (const QPointF &point, QgsSymbolV2RenderContext &context, const QList< QgsMarkerSymbolV2 * > &symbols, const QStringList &labels)
void calculateSymbolAndLabelPositions (const QPointF &centerPoint, int nPosition, double radius, double symbolDiagonal, QList< QPointF > &symbolPositions, QList< QPointF > &labelShifts) const
void drawCircle (double radiusPainterUnits, QgsSymbolV2RenderContext &context, const QPointF &centerPoint, int nSymbols)
void drawSymbols (QgsFeature &f, QgsRenderContext &context, const QList< QgsMarkerSymbolV2 * > &symbolList, const QList< QPointF > &symbolPositions, bool selected=false)
void drawLabels (const QPointF &centerPoint, QgsSymbolV2RenderContext &context, const QList< QPointF > &labelShifts, const QStringList &labelList)
QgsSymbolV2firstSymbolForFeature (QgsFeatureRendererV2 *r, QgsFeature &f)
 Returns first symbol for feature or 0 if none.

Private Attributes

QgsFeatureRendererV2mRenderer
 Embedded renderer.
QString mLabelAttributeName
 Attribute name for labeling.
int mLabelIndex
 Label attribute index (or -1 if none).
QgsMarkerSymbolV2mCenterSymbol
 Center symbol for a displacement group.
double mTolerance
 Tolerance.
QFont mLabelFont
 Font that is passed to the renderer.
QColor mLabelColor
double mCircleWidth
 Line width for the circle.
QColor mCircleColor
 Color to draw the circle.
double mCircleRadiusAddition
 Addition to the default circle radius.
bool mDrawLabels
 Is set internally from startRender() depending on scale denominator.
double mMaxLabelScaleDenominator
 Maximum scale denominator for label display.
QList< QMap< QgsFeatureId,
QgsFeature > > 
mDisplacementGroups
 Groups of features that have the same position.
QSet< QgsFeatureIdmDisplacementIds
 Set that contains all the ids the display groups (for quicker lookup)

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
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 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.
int mCurrentVertexMarkerSize
 The current size of editing marker.

Detailed Description

A renderer that automatically displaces points with the same position.

Definition at line 31 of file qgspointdisplacementrenderer.h.

Constructor & Destructor Documentation

QgsPointDisplacementRenderer::QgsPointDisplacementRenderer ( const QString &  labelAttributeName = "")
QgsPointDisplacementRenderer::~QgsPointDisplacementRenderer ( )

Definition at line 46 of file qgspointdisplacementrenderer.cpp.

References mCenterSymbol, and mRenderer.

Member Function Documentation

void QgsPointDisplacementRenderer::calculateSymbolAndLabelPositions ( const QPointF &  centerPoint,
int  nPosition,
double  radius,
double  symbolDiagonal,
QList< QPointF > &  symbolPositions,
QList< QPointF > &  labelShifts 
) const
private

Definition at line 490 of file qgspointdisplacementrenderer.cpp.

References M_PI.

Referenced by renderFeature().

QgsMarkerSymbolV2* QgsPointDisplacementRenderer::centerSymbol ( )
inline

Returns the symbol for the center of a displacement group (but not ownership of the symbol)

Definition at line 91 of file qgspointdisplacementrenderer.h.

QColor QgsPointDisplacementRenderer::circleColor ( ) const
inline

Definition at line 79 of file qgspointdisplacementrenderer.h.

double QgsPointDisplacementRenderer::circleRadiusAddition ( ) const
inline

Definition at line 85 of file qgspointdisplacementrenderer.h.

double QgsPointDisplacementRenderer::circleWidth ( ) const
inline

Definition at line 76 of file qgspointdisplacementrenderer.h.

QgsFeatureRendererV2 * QgsPointDisplacementRenderer::clone ( )
virtual
QgsFeatureRendererV2 * QgsPointDisplacementRenderer::create ( QDomElement &  symbologyElem)
static
void QgsPointDisplacementRenderer::createDisplacementGroups ( QgsVectorLayer vlayer,
const QgsRectangle viewExtent 
)
private
void QgsPointDisplacementRenderer::drawCircle ( double  radiusPainterUnits,
QgsSymbolV2RenderContext context,
const QPointF &  centerPoint,
int  nSymbols 
)
private
void QgsPointDisplacementRenderer::drawLabels ( const QPointF &  centerPoint,
QgsSymbolV2RenderContext context,
const QList< QPointF > &  labelShifts,
const QStringList &  labelList 
)
private
void QgsPointDisplacementRenderer::drawSymbols ( QgsFeature f,
QgsRenderContext context,
const QList< QgsMarkerSymbolV2 * > &  symbolList,
const QList< QPointF > &  symbolPositions,
bool  selected = false 
)
private

Definition at line 537 of file qgspointdisplacementrenderer.cpp.

Referenced by renderFeature().

QgsFeatureRendererV2* QgsPointDisplacementRenderer::embeddedRenderer ( )
inline

Definition at line 67 of file qgspointdisplacementrenderer.h.

QgsSymbolV2 * QgsPointDisplacementRenderer::firstSymbolForFeature ( QgsFeatureRendererV2 r,
QgsFeature f 
)
private

Returns first symbol for feature or 0 if none.

Definition at line 595 of file qgspointdisplacementrenderer.cpp.

References QgsFeatureRendererV2::symbolsForFeature().

Referenced by renderFeature().

QString QgsPointDisplacementRenderer::getLabel ( const QgsFeature f)
private

Returns the label for a feature (using mLabelAttributeName as attribute field)

Definition at line 471 of file qgspointdisplacementrenderer.cpp.

References QgsFeature::attributes(), and mLabelIndex.

Referenced by renderFeature().

QString QgsPointDisplacementRenderer::labelAttributeName ( ) const
inline

Definition at line 63 of file qgspointdisplacementrenderer.h.

QColor QgsPointDisplacementRenderer::labelColor ( ) const
inline

Definition at line 82 of file qgspointdisplacementrenderer.h.

QFont QgsPointDisplacementRenderer::labelFont ( ) const
inline

Definition at line 73 of file qgspointdisplacementrenderer.h.

Referenced by create().

QgsLegendSymbolList QgsPointDisplacementRenderer::legendSymbolItems ( )
virtual
Note
not available in python bindings

Reimplemented from QgsFeatureRendererV2.

Definition at line 333 of file qgspointdisplacementrenderer.cpp.

References QgsFeatureRendererV2::legendSymbolItems(), and mRenderer.

QgsLegendSymbologyList QgsPointDisplacementRenderer::legendSymbologyItems ( QSize  iconSize)
virtual

return a list of symbology items for the legend

Reimplemented from QgsFeatureRendererV2.

Definition at line 324 of file qgspointdisplacementrenderer.cpp.

References QgsFeatureRendererV2::legendSymbologyItems(), and mRenderer.

double QgsPointDisplacementRenderer::maxLabelScaleDenominator ( ) const
inline

Definition at line 88 of file qgspointdisplacementrenderer.h.

void QgsPointDisplacementRenderer::printInfoDisplacementGroups ( )
private

This is a debugging function to check the entries in the displacement groups.

Definition at line 434 of file qgspointdisplacementrenderer.cpp.

References FID_TO_STRING, mDisplacementGroups, mDisplacementIds, and QgsDebugMsg.

Referenced by startRender().

bool QgsPointDisplacementRenderer::renderFeature ( QgsFeature feature,
QgsRenderContext context,
int  layer = -1,
bool  selected = false,
bool  drawVertexMarker = false 
)
virtual
void QgsPointDisplacementRenderer::renderPoint ( const QPointF &  point,
QgsSymbolV2RenderContext context,
const QList< QgsMarkerSymbolV2 * > &  symbols,
const QStringList &  labels 
)
private
QDomElement QgsPointDisplacementRenderer::save ( QDomDocument &  doc)
virtual
QgsRectangle QgsPointDisplacementRenderer::searchRect ( const QgsPoint p) const
private

Creates a search rectangle with mTolerance.

Definition at line 429 of file qgspointdisplacementrenderer.cpp.

References mTolerance, QgsPoint::x(), and QgsPoint::y().

Referenced by createDisplacementGroups().

void QgsPointDisplacementRenderer::setCenterSymbol ( QgsMarkerSymbolV2 symbol)

Sets the center symbol (takes ownership)

Definition at line 482 of file qgspointdisplacementrenderer.cpp.

References mCenterSymbol.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setCircleColor ( const QColor &  c)
inline

Definition at line 78 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setCircleRadiusAddition ( double  d)
inline

Definition at line 84 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setCircleWidth ( double  w)
inline

Definition at line 75 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setDisplacementGroups ( const QList< QMap< QgsFeatureId, QgsFeature > > &  list)

not available in python bindings

Definition at line 455 of file qgspointdisplacementrenderer.cpp.

References mDisplacementGroups, and mDisplacementIds.

Referenced by clone().

void QgsPointDisplacementRenderer::setEmbeddedRenderer ( QgsFeatureRendererV2 r)

Sets embedded renderer (takes ownership)

Definition at line 190 of file qgspointdisplacementrenderer.cpp.

References mRenderer.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setLabelAttributeName ( const QString &  name)
inline

Definition at line 62 of file qgspointdisplacementrenderer.h.

Referenced by create().

void QgsPointDisplacementRenderer::setLabelColor ( const QColor &  c)
inline

Definition at line 81 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setLabelFont ( const QFont &  f)
inline

Definition at line 72 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setMaxLabelScaleDenominator ( double  d)
inline

Definition at line 87 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setTolerance ( double  t)
inline

Definition at line 95 of file qgspointdisplacementrenderer.h.

Referenced by clone().

void QgsPointDisplacementRenderer::startRender ( QgsRenderContext context,
const QgsVectorLayer vlayer 
)
virtual
void QgsPointDisplacementRenderer::stopRender ( QgsRenderContext context)
virtual
QgsSymbolV2 * QgsPointDisplacementRenderer::symbolForFeature ( QgsFeature feature)
virtual

to be overridden

Parameters
featurefeature
Returns
returns pointer to symbol or 0 if symbol was not found

Implements QgsFeatureRendererV2.

Definition at line 196 of file qgspointdisplacementrenderer.cpp.

QgsSymbolV2List QgsPointDisplacementRenderer::symbols ( )
virtual

for symbol levels

Implements QgsFeatureRendererV2.

Definition at line 258 of file qgspointdisplacementrenderer.cpp.

References mRenderer, and QgsFeatureRendererV2::symbols().

double QgsPointDisplacementRenderer::tolerance ( ) const
inline

Definition at line 96 of file qgspointdisplacementrenderer.h.

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

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

Note
added in 1.9

Reimplemented from QgsFeatureRendererV2.

Definition at line 71 of file qgspointdisplacementrenderer.cpp.

References mRenderer, and QgsFeatureRendererV2::toSld().

QList< QString > QgsPointDisplacementRenderer::usedAttributes ( )
virtual

Member Data Documentation

QgsMarkerSymbolV2* QgsPointDisplacementRenderer::mCenterSymbol
private
QColor QgsPointDisplacementRenderer::mCircleColor
private

Color to draw the circle.

Definition at line 120 of file qgspointdisplacementrenderer.h.

Referenced by clone(), drawCircle(), and save().

double QgsPointDisplacementRenderer::mCircleRadiusAddition
private

Addition to the default circle radius.

Definition at line 122 of file qgspointdisplacementrenderer.h.

Referenced by clone(), renderFeature(), and save().

double QgsPointDisplacementRenderer::mCircleWidth
private

Line width for the circle.

Definition at line 118 of file qgspointdisplacementrenderer.h.

Referenced by clone(), drawCircle(), and save().

QList<QMap<QgsFeatureId, QgsFeature> > QgsPointDisplacementRenderer::mDisplacementGroups
private

Groups of features that have the same position.

Definition at line 129 of file qgspointdisplacementrenderer.h.

Referenced by clone(), createDisplacementGroups(), printInfoDisplacementGroups(), renderFeature(), and setDisplacementGroups().

QSet<QgsFeatureId> QgsPointDisplacementRenderer::mDisplacementIds
private

Set that contains all the ids the display groups (for quicker lookup)

Definition at line 131 of file qgspointdisplacementrenderer.h.

Referenced by createDisplacementGroups(), printInfoDisplacementGroups(), renderFeature(), and setDisplacementGroups().

bool QgsPointDisplacementRenderer::mDrawLabels
private

Is set internally from startRender() depending on scale denominator.

Definition at line 124 of file qgspointdisplacementrenderer.h.

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

QString QgsPointDisplacementRenderer::mLabelAttributeName
private

Attribute name for labeling.

Empty string means no labelling will be done

Definition at line 104 of file qgspointdisplacementrenderer.h.

Referenced by clone(), save(), startRender(), and usedAttributes().

QColor QgsPointDisplacementRenderer::mLabelColor
private

Definition at line 116 of file qgspointdisplacementrenderer.h.

Referenced by clone(), drawLabels(), and save().

QFont QgsPointDisplacementRenderer::mLabelFont
private

Font that is passed to the renderer.

Definition at line 115 of file qgspointdisplacementrenderer.h.

Referenced by clone(), drawLabels(), and save().

int QgsPointDisplacementRenderer::mLabelIndex
private

Label attribute index (or -1 if none).

This index is not stored, it is requested in the startRender() method

Definition at line 106 of file qgspointdisplacementrenderer.h.

Referenced by getLabel(), and startRender().

double QgsPointDisplacementRenderer::mMaxLabelScaleDenominator
private

Maximum scale denominator for label display.

Negative number means no scale limitation

Definition at line 126 of file qgspointdisplacementrenderer.h.

Referenced by clone(), save(), and startRender().

QgsFeatureRendererV2* QgsPointDisplacementRenderer::mRenderer
private

Embedded renderer.

Like This, it is possible to use a classification together with point displacement

Definition at line 101 of file qgspointdisplacementrenderer.h.

Referenced by clone(), legendSymbolItems(), legendSymbologyItems(), QgsPointDisplacementRenderer(), renderFeature(), save(), setEmbeddedRenderer(), startRender(), stopRender(), symbols(), toSld(), usedAttributes(), and ~QgsPointDisplacementRenderer().

double QgsPointDisplacementRenderer::mTolerance
private

Tolerance.

Points that are closer together are considered as equal

Definition at line 112 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and searchRect().


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