QGIS API Documentation
2.2.0-Valmiera
|
A renderer that automatically displaces points with the same position. More...
#include <qgspointdisplacementrenderer.h>
Public Member Functions | |
QgsPointDisplacementRenderer (const QString &labelAttributeName="") | |
~QgsPointDisplacementRenderer () | |
QgsFeatureRendererV2 * | clone () |
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. | |
QgsSymbolV2 * | symbolForFeature (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 (double scaleDenominator=-1, QString rule="") |
void | setLabelAttributeName (const QString &name) |
QString | labelAttributeName () const |
void | setEmbeddedRenderer (QgsFeatureRendererV2 *r) |
Sets embedded renderer (takes ownership) | |
QgsFeatureRendererV2 * | embeddedRenderer () |
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 |
QgsMarkerSymbolV2 * | centerSymbol () |
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 QgsFeatureRendererV2 * | create (QDomElement &symbologyElem) |
create a renderer from XML element | |
Static Public Member Functions inherited from QgsFeatureRendererV2 | |
static QgsFeatureRendererV2 * | defaultRenderer (QGis::GeometryType geomType) |
return a new renderer - used by default in vector layers | |
static QgsFeatureRendererV2 * | load (QDomElement &symbologyElem) |
create a renderer from XML element | |
static QgsFeatureRendererV2 * | loadSld (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 ¢erPoint, int nPosition, double radius, double symbolDiagonal, QList< QPointF > &symbolPositions, QList< QPointF > &labelShifts) const |
void | drawCircle (double radiusPainterUnits, QgsSymbolV2RenderContext &context, const QPointF ¢erPoint, int nSymbols) |
void | drawSymbols (QgsFeature &f, QgsRenderContext &context, const QList< QgsMarkerSymbolV2 * > &symbolList, const QList< QPointF > &symbolPositions, bool selected=false) |
void | drawLabels (const QPointF ¢erPoint, QgsSymbolV2RenderContext &context, const QList< QPointF > &labelShifts, const QStringList &labelList) |
QgsSymbolV2 * | firstSymbolForFeature (QgsFeatureRendererV2 *r, QgsFeature &f) |
Returns first symbol for feature or 0 if none. |
Private Attributes | |
QgsFeatureRendererV2 * | mRenderer |
Embedded renderer. | |
QString | mLabelAttributeName |
Attribute name for labeling. | |
int | mLabelIndex |
Label attribute index (or -1 if none). | |
QgsMarkerSymbolV2 * | mCenterSymbol |
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< QgsFeatureId > | mDisplacementIds |
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. |
A renderer that automatically displaces points with the same position.
Definition at line 31 of file qgspointdisplacementrenderer.h.
QgsPointDisplacementRenderer::QgsPointDisplacementRenderer | ( | const QString & | labelAttributeName = "" | ) |
Definition at line 31 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::defaultRenderer(), mCenterSymbol, mDrawLabels, mRenderer, and QGis::Point.
QgsPointDisplacementRenderer::~QgsPointDisplacementRenderer | ( | ) |
Definition at line 46 of file qgspointdisplacementrenderer.cpp.
References mCenterSymbol, and mRenderer.
|
private |
Definition at line 492 of file qgspointdisplacementrenderer.cpp.
References M_PI.
Referenced by renderFeature().
|
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.
|
inline |
Definition at line 79 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 85 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 76 of file qgspointdisplacementrenderer.h.
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 52 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::clone(), QgsMarkerSymbolV2::clone(), mCenterSymbol, mCircleColor, mCircleRadiusAddition, mCircleWidth, mDisplacementGroups, mLabelAttributeName, mLabelColor, mLabelFont, mMaxLabelScaleDenominator, mRenderer, mTolerance, QgsPointDisplacementRenderer(), setCenterSymbol(), setCircleColor(), setCircleRadiusAddition(), setCircleWidth(), setDisplacementGroups(), setEmbeddedRenderer(), setLabelColor(), setLabelFont(), setMaxLabelScaleDenominator(), and setTolerance().
|
static |
create a renderer from XML element
Definition at line 270 of file qgspointdisplacementrenderer.cpp.
References QgsSymbolLayerV2Utils::decodeColor(), labelFont(), QgsFeatureRendererV2::load(), QgsSymbolLayerV2Utils::loadSymbol(), QgsPointDisplacementRenderer(), setCenterSymbol(), setCircleColor(), setCircleRadiusAddition(), setCircleWidth(), setEmbeddedRenderer(), setLabelAttributeName(), setLabelColor(), setLabelFont(), setMaxLabelScaleDenominator(), and setTolerance().
Referenced by QgsRendererV2Registry::QgsRendererV2Registry().
|
private |
Create the displacement groups efficiently using a spatial index.
Definition at line 344 of file qgspointdisplacementrenderer.cpp.
References QgsGeometry::asPoint(), QgsVectorLayer::fieldNameIndex(), QgsFeature::geometry(), QgsVectorLayer::getFeatures(), QgsFeature::id(), QgsSpatialIndex::insertFeature(), QgsSpatialIndex::intersects(), mDisplacementGroups, mDisplacementIds, QgsFeatureIterator::nextFeature(), searchRect(), usedAttributes(), QGis::WKBPoint, QGis::WKBPoint25D, and QgsVectorLayer::wkbType().
Referenced by startRender().
|
private |
Definition at line 524 of file qgspointdisplacementrenderer.cpp.
References mCircleColor, mCircleWidth, QgsSymbolV2RenderContext::outputLineWidth(), QgsRenderContext::painter(), and QgsSymbolV2RenderContext::renderContext().
Referenced by renderFeature().
|
private |
Definition at line 552 of file qgspointdisplacementrenderer.cpp.
References mLabelColor, mLabelFont, QgsSymbolV2RenderContext::outputLineWidth(), QgsRenderContext::painter(), QgsRenderContext::rasterScaleFactor(), and QgsSymbolV2RenderContext::renderContext().
Referenced by renderFeature().
|
private |
Definition at line 539 of file qgspointdisplacementrenderer.cpp.
Referenced by renderFeature().
|
inline |
Definition at line 67 of file qgspointdisplacementrenderer.h.
|
private |
Returns first symbol for feature or 0 if none.
Definition at line 597 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::symbolsForFeature().
Referenced by renderFeature().
|
private |
Returns the label for a feature (using mLabelAttributeName as attribute field)
Definition at line 473 of file qgspointdisplacementrenderer.cpp.
References QgsFeature::attributes(), and mLabelIndex.
Referenced by renderFeature().
|
inline |
Definition at line 63 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 82 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 73 of file qgspointdisplacementrenderer.h.
Referenced by create().
|
virtual |
Reimplemented from QgsFeatureRendererV2.
Definition at line 335 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::legendSymbolItems(), and mRenderer.
|
virtual |
return a list of symbology items for the legend
Reimplemented from QgsFeatureRendererV2.
Definition at line 326 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::legendSymbologyItems(), and mRenderer.
|
inline |
Definition at line 88 of file qgspointdisplacementrenderer.h.
|
private |
This is a debugging function to check the entries in the displacement groups.
Definition at line 436 of file qgspointdisplacementrenderer.cpp.
References FID_TO_STRING, mDisplacementGroups, mDisplacementIds, and QgsDebugMsg.
Referenced by startRender().
|
virtual |
Reimplemented from QgsFeatureRendererV2.
Reimplemented from QgsFeatureRendererV2.
Definition at line 77 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::_getPoint(), QgsGeometry::asWkb(), calculateSymbolAndLabelPositions(), drawCircle(), drawLabels(), drawSymbols(), firstSymbolForFeature(), QgsFeature::geometry(), getLabel(), QgsFeature::id(), QgsSymbolLayerV2Utils::lineWidthScaleFactor(), M_PI, mCenterSymbol, mCircleRadiusAddition, mDisplacementGroups, mDisplacementIds, mDrawLabels, QgsSymbolV2::MM, mRenderer, QgsSymbolV2RenderContext::outputLineWidth(), QgsRenderContext::painter(), QgsMarkerSymbolV2::renderPoint(), QGis::WKBPoint, QGis::WKBPoint25D, and QgsGeometry::wkbType().
|
private |
|
virtual |
store renderer info to XML element
Reimplemented from QgsFeatureRendererV2.
Definition at line 300 of file qgspointdisplacementrenderer.cpp.
References QgsSymbolLayerV2Utils::encodeColor(), mCenterSymbol, mCircleColor, mCircleRadiusAddition, mCircleWidth, mLabelAttributeName, mLabelColor, mLabelFont, mMaxLabelScaleDenominator, mRenderer, mTolerance, RENDERER_TAG_NAME, QgsFeatureRendererV2::save(), and QgsSymbolLayerV2Utils::saveSymbol().
|
private |
Creates a search rectangle with mTolerance.
Definition at line 431 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 484 of file qgspointdisplacementrenderer.cpp.
References mCenterSymbol.
|
inline |
Definition at line 78 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 84 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 75 of file qgspointdisplacementrenderer.h.
void QgsPointDisplacementRenderer::setDisplacementGroups | ( | const QList< QMap< QgsFeatureId, QgsFeature > > & | list | ) |
not available in python bindings
Definition at line 457 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.
|
inline |
Definition at line 62 of file qgspointdisplacementrenderer.h.
Referenced by create().
|
inline |
Definition at line 81 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 72 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 87 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 95 of file qgspointdisplacementrenderer.h.
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 202 of file qgspointdisplacementrenderer.cpp.
References createDisplacementGroups(), QgsRenderContext::extent(), QgsVectorLayer::fieldNameIndex(), mCenterSymbol, mDrawLabels, mLabelAttributeName, mLabelIndex, mMaxLabelScaleDenominator, mRenderer, printInfoDisplacementGroups(), QgsRenderContext::rendererScale(), QgsFeatureRendererV2::startRender(), and QgsSymbolV2::startRender().
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 234 of file qgspointdisplacementrenderer.cpp.
References mCenterSymbol, mRenderer, QgsDebugMsg, QgsFeatureRendererV2::stopRender(), and QgsSymbolV2::stopRender().
|
virtual |
to be overridden
feature | feature |
Implements QgsFeatureRendererV2.
Definition at line 196 of file qgspointdisplacementrenderer.cpp.
|
virtual |
for symbol levels
Implements QgsFeatureRendererV2.
Definition at line 258 of file qgspointdisplacementrenderer.cpp.
References mRenderer, and QgsFeatureRendererV2::symbols().
|
inline |
Definition at line 96 of file qgspointdisplacementrenderer.h.
|
virtual |
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Reimplemented from QgsFeatureRendererV2.
Definition at line 71 of file qgspointdisplacementrenderer.cpp.
References mRenderer, and QgsFeatureRendererV2::toSld().
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 244 of file qgspointdisplacementrenderer.cpp.
References mLabelAttributeName, mRenderer, and QgsFeatureRendererV2::usedAttributes().
Referenced by createDisplacementGroups().
|
private |
Center symbol for a displacement group.
Definition at line 109 of file qgspointdisplacementrenderer.h.
Referenced by clone(), QgsPointDisplacementRenderer(), renderFeature(), save(), setCenterSymbol(), startRender(), stopRender(), and ~QgsPointDisplacementRenderer().
|
private |
Color to draw the circle.
Definition at line 120 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawCircle(), and save().
|
private |
Addition to the default circle radius.
Definition at line 122 of file qgspointdisplacementrenderer.h.
Referenced by clone(), renderFeature(), and save().
|
private |
Line width for the circle.
Definition at line 118 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawCircle(), and save().
|
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().
|
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().
|
private |
Is set internally from startRender() depending on scale denominator.
Definition at line 124 of file qgspointdisplacementrenderer.h.
Referenced by QgsPointDisplacementRenderer(), renderFeature(), and startRender().
|
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().
|
private |
Definition at line 116 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawLabels(), and save().
|
private |
Font that is passed to the renderer.
Definition at line 115 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawLabels(), and save().
|
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().
|
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().
|
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().
|
private |
Tolerance.
Points that are closer together are considered as equal
Definition at line 112 of file qgspointdisplacementrenderer.h.
Referenced by clone(), save(), and searchRect().