QGIS API Documentation  master-59fd5e0
QgsPointDisplacementRenderer Class Reference

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

#include <qgspointdisplacementrenderer.h>

+ Inheritance diagram for QgsPointDisplacementRenderer:
+ Collaboration diagram for QgsPointDisplacementRenderer:

List of all members.

Public Member Functions

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

Static Public Member Functions

static QgsFeatureRendererV2create (QDomElement &symbologyElem)
 create a renderer from XML element

Private Member Functions

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

Private Attributes

QgsMarkerSymbolV2mCenterSymbol
 Center symbol for a displacement group.
QColor mCircleColor
 Color to draw the circle.
double mCircleRadiusAddition
 Addition to the default circle radius.
double mCircleWidth
 Line width for the circle.
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)
bool mDrawLabels
 Is set internally from startRender() depending on scale denominator.
QString mLabelAttributeName
 Attribute name for labeling.
QColor mLabelColor
QFont mLabelFont
 Font that is passed to the renderer.
int mLabelIndex
 Label attribute index (or -1 if none).
double mMaxLabelScaleDenominator
 Maximum scale denominator for label display.
QgsFeatureRendererV2mRenderer
 Embedded renderer.
double mTolerance
 Tolerance.

Detailed Description

A renderer that automatically displaces points with the same position.

Definition at line 31 of file qgspointdisplacementrenderer.h.


Constructor & Destructor Documentation


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().

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

Definition at line 91 of file qgspointdisplacementrenderer.h.

Referenced by QgsPointDisplacementRendererWidget::on_mCenterSymbolPushButton_clicked(), and QgsPointDisplacementRendererWidget::updateCenterIcon().

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().

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().

Note:
not available in python bindings

Reimplemented from QgsFeatureRendererV2.

Definition at line 333 of file qgspointdisplacementrenderer.cpp.

References QgsFeatureRendererV2::legendSymbolItems(), and mRenderer.

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.

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().

void QgsPointDisplacementRenderer::renderPoint ( const QPointF &  point,
QgsSymbolV2RenderContext context,
const QList< QgsMarkerSymbolV2 * > &  symbols,
const QStringList &  labels 
) [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().

not available in python bindings

Definition at line 455 of file qgspointdisplacementrenderer.cpp.

References mDisplacementGroups, and mDisplacementIds.

Referenced by clone().

Sets embedded renderer (takes ownership)

Definition at line 190 of file qgspointdisplacementrenderer.cpp.

References mRenderer.

Referenced by clone(), create(), and QgsPointDisplacementRendererWidget::renderer().

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.

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().


Member Data Documentation

Color to draw the circle.

Definition at line 120 of file qgspointdisplacementrenderer.h.

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

Addition to the default circle radius.

Definition at line 122 of file qgspointdisplacementrenderer.h.

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

Line width for the circle.

Definition at line 118 of file qgspointdisplacementrenderer.h.

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

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().

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

Definition at line 124 of file qgspointdisplacementrenderer.h.

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

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().

Definition at line 116 of file qgspointdisplacementrenderer.h.

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

Font that is passed to the renderer.

Definition at line 115 of file qgspointdisplacementrenderer.h.

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

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().

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().

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines