QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Types | 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 More...
 
bool renderFeature (QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
 Reimplemented from QgsFeatureRendererV2. More...
 
QgsSymbolV2symbolForFeature (QgsFeature &feature)
 to be overridden More...
 
void startRender (QgsRenderContext &context, const QgsFields &fields)
 
void stopRender (QgsRenderContext &context)
 
QList< QString > usedAttributes ()
 
QgsSymbolV2List symbols ()
 for symbol levels More...
 
QDomElement save (QDomDocument &doc)
 store renderer info to XML element More...
 
QgsLegendSymbologyList legendSymbologyItems (QSize iconSize)
 return a list of symbology items for the legend More...
 
QgsLegendSymbolList legendSymbolItems (double scaleDenominator=-1, QString rule="")
 
void setLabelAttributeName (const QString &name)
 
QString labelAttributeName () const
 
void setEmbeddedRenderer (QgsFeatureRendererV2 *r)
 Sets embedded renderer (takes ownership) More...
 
QgsFeatureRendererV2embeddedRenderer ()
 
Q_DECL_DEPRECATED void setDisplacementGroups (const QList< QMap< QgsFeatureId, QgsFeature > > &list)
 not available in python bindings More...
 
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) More...
 
void setCenterSymbol (QgsMarkerSymbolV2 *symbol)
 Sets the center symbol (takes ownership) More...
 
void setTolerance (double t)
 
double tolerance () const
 
- Public Member Functions inherited from QgsFeatureRendererV2
QString type () const
 
virtual Q_DECL_DEPRECATED void startRender (QgsRenderContext &context, const QgsVectorLayer *vlayer)
 
virtual ~QgsFeatureRendererV2 ()
 
virtual QString dump () const
 for debugging More...
 
virtual int capabilities ()
 returns bitwise OR-ed capabilities of the renderer More...
 
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...
 
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...
 
virtual bool willRenderFeature (QgsFeature &feat)
 return whether the renderer will render a feature or not. More...
 
virtual QgsSymbolV2List symbolsForFeature (QgsFeature &feat)
 return list of symbols used for rendering the feature. More...
 

Static Public Member Functions

static QgsFeatureRendererV2create (QDomElement &symbologyElem)
 create a renderer from XML element 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 QMap< QgsFeatureId,
QgsFeature
DisplacementGroup
 

Private Member Functions

QgsRectangle searchRect (const QgsPoint &p) const
 Creates a search rectangle with mTolerance. More...
 
void printInfoDisplacementGroups ()
 This is a debugging function to check the entries in the displacement groups. More...
 
QString getLabel (const QgsFeature &f)
 Returns the label for a feature (using mLabelAttributeName as attribute field) More...
 
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 drawGroup (const DisplacementGroup &group, QgsRenderContext &context)
 
void drawCircle (double radiusPainterUnits, QgsSymbolV2RenderContext &context, const QPointF &centerPoint, int nSymbols)
 
void drawSymbols (const 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. More...
 

Private Attributes

QgsFeatureRendererV2mRenderer
 Embedded renderer. More...
 
QString mLabelAttributeName
 Attribute name for labeling. More...
 
int mLabelIndex
 Label attribute index (or -1 if none). More...
 
QgsMarkerSymbolV2mCenterSymbol
 Center symbol for a displacement group. More...
 
double mTolerance
 Tolerance. More...
 
QFont mLabelFont
 Font that is passed to the renderer. More...
 
QColor mLabelColor
 
double mCircleWidth
 Line width for the circle. More...
 
QColor mCircleColor
 Color to draw the circle. More...
 
double mCircleRadiusAddition
 Addition to the default circle radius. More...
 
bool mDrawLabels
 Is set internally from startRender() depending on scale denominator. More...
 
double mMaxLabelScaleDenominator
 Maximum scale denominator for label display. More...
 
QList< DisplacementGroupmDisplacementGroups
 Groups of features that have the same position. More...
 
QMap< QgsFeatureId, int > mGroupIndex
 Mapping from feature ID to its group index. More...
 
QgsSpatialIndexmSpatialIndex
 Spatial index for fast lookup of close points. More...
 
QSet< QgsFeatureIdmSelectedFeatures
 keeps trask which features are selected 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

A renderer that automatically displaces points with the same position.

Definition at line 31 of file qgspointdisplacementrenderer.h.

Member Typedef Documentation

Definition at line 129 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 399 of file qgspointdisplacementrenderer.cpp.

References M_PI.

Referenced by drawGroup().

QgsMarkerSymbolV2* QgsPointDisplacementRenderer::centerSymbol ( )
inline

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

Definition at line 92 of file qgspointdisplacementrenderer.h.

QColor QgsPointDisplacementRenderer::circleColor ( ) const
inline

Definition at line 80 of file qgspointdisplacementrenderer.h.

double QgsPointDisplacementRenderer::circleRadiusAddition ( ) const
inline

Definition at line 86 of file qgspointdisplacementrenderer.h.

double QgsPointDisplacementRenderer::circleWidth ( ) const
inline

Definition at line 77 of file qgspointdisplacementrenderer.h.

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

Definition at line 446 of file qgspointdisplacementrenderer.cpp.

Referenced by drawGroup().

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 504 of file qgspointdisplacementrenderer.cpp.

References QgsFeatureRendererV2::symbolsForFeature().

Referenced by drawGroup().

QString QgsPointDisplacementRenderer::getLabel ( const QgsFeature f)
private

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

Definition at line 380 of file qgspointdisplacementrenderer.cpp.

References QgsFeature::attributes(), and mLabelIndex.

Referenced by drawGroup().

QString QgsPointDisplacementRenderer::labelAttributeName ( ) const
inline

Definition at line 63 of file qgspointdisplacementrenderer.h.

QColor QgsPointDisplacementRenderer::labelColor ( ) const
inline

Definition at line 83 of file qgspointdisplacementrenderer.h.

QFont QgsPointDisplacementRenderer::labelFont ( ) const
inline

Definition at line 74 of file qgspointdisplacementrenderer.h.

Referenced by create().

QgsLegendSymbolList QgsPointDisplacementRenderer::legendSymbolItems ( double  scaleDenominator = -1,
QString  rule = "" 
)
virtual
Note
not available in python bindings

Reimplemented from QgsFeatureRendererV2.

Definition at line 350 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 341 of file qgspointdisplacementrenderer.cpp.

References QgsFeatureRendererV2::legendSymbologyItems(), and mRenderer.

double QgsPointDisplacementRenderer::maxLabelScaleDenominator ( ) const
inline

Definition at line 89 of file qgspointdisplacementrenderer.h.

void QgsPointDisplacementRenderer::printInfoDisplacementGroups ( )
private

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

Definition at line 365 of file qgspointdisplacementrenderer.cpp.

References FID_TO_STRING, mDisplacementGroups, and QgsDebugMsg.

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 360 of file qgspointdisplacementrenderer.cpp.

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

Referenced by renderFeature().

void QgsPointDisplacementRenderer::setCenterSymbol ( QgsMarkerSymbolV2 symbol)

Sets the center symbol (takes ownership)

Definition at line 391 of file qgspointdisplacementrenderer.cpp.

References mCenterSymbol.

Referenced by clone(), and create().

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

Definition at line 79 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setCircleRadiusAddition ( double  d)
inline

Definition at line 85 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setCircleWidth ( double  w)
inline

Definition at line 76 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

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

not available in python bindings

Deprecated:
since 2.4

Definition at line 71 of file qgspointdisplacementrenderer.h.

void QgsPointDisplacementRenderer::setEmbeddedRenderer ( QgsFeatureRendererV2 r)

Sets embedded renderer (takes ownership)

Definition at line 192 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 82 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

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

Definition at line 73 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setMaxLabelScaleDenominator ( double  d)
inline

Definition at line 88 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::setTolerance ( double  t)
inline

Definition at line 96 of file qgspointdisplacementrenderer.h.

Referenced by clone(), and create().

void QgsPointDisplacementRenderer::startRender ( QgsRenderContext context,
const QgsFields fields 
)
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 198 of file qgspointdisplacementrenderer.cpp.

QgsSymbolV2List QgsPointDisplacementRenderer::symbols ( )
virtual

for symbol levels

Implements QgsFeatureRendererV2.

Definition at line 273 of file qgspointdisplacementrenderer.cpp.

References mRenderer, and QgsFeatureRendererV2::symbols().

double QgsPointDisplacementRenderer::tolerance ( ) const
inline

Definition at line 97 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 70 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 121 of file qgspointdisplacementrenderer.h.

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

double QgsPointDisplacementRenderer::mCircleRadiusAddition
private

Addition to the default circle radius.

Definition at line 123 of file qgspointdisplacementrenderer.h.

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

double QgsPointDisplacementRenderer::mCircleWidth
private

Line width for the circle.

Definition at line 119 of file qgspointdisplacementrenderer.h.

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

QList<DisplacementGroup> QgsPointDisplacementRenderer::mDisplacementGroups
private

Groups of features that have the same position.

Definition at line 131 of file qgspointdisplacementrenderer.h.

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

bool QgsPointDisplacementRenderer::mDrawLabels
private

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

Definition at line 125 of file qgspointdisplacementrenderer.h.

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

QMap<QgsFeatureId, int> QgsPointDisplacementRenderer::mGroupIndex
private

Mapping from feature ID to its group index.

Definition at line 133 of file qgspointdisplacementrenderer.h.

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

QString QgsPointDisplacementRenderer::mLabelAttributeName
private

Attribute name for labeling.

Empty string means no labelling will be done

Definition at line 105 of file qgspointdisplacementrenderer.h.

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

QColor QgsPointDisplacementRenderer::mLabelColor
private

Definition at line 117 of file qgspointdisplacementrenderer.h.

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

QFont QgsPointDisplacementRenderer::mLabelFont
private

Font that is passed to the renderer.

Definition at line 116 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 107 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 127 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 102 of file qgspointdisplacementrenderer.h.

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

QSet<QgsFeatureId> QgsPointDisplacementRenderer::mSelectedFeatures
private

keeps trask which features are selected

Definition at line 137 of file qgspointdisplacementrenderer.h.

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

QgsSpatialIndex* QgsPointDisplacementRenderer::mSpatialIndex
private

Spatial index for fast lookup of close points.

Definition at line 135 of file qgspointdisplacementrenderer.h.

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

double QgsPointDisplacementRenderer::mTolerance
private

Tolerance.

Points that are closer together are considered as equal

Definition at line 113 of file qgspointdisplacementrenderer.h.

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


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