QGIS API Documentation
2.4.0-Chugiak
|
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 More... | |
bool | renderFeature (QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) |
Reimplemented from QgsFeatureRendererV2. More... | |
QgsSymbolV2 * | symbolForFeature (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... | |
QgsFeatureRendererV2 * | embeddedRenderer () |
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 |
QgsMarkerSymbolV2 * | centerSymbol () |
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 QgsFeatureRendererV2 * | create (QDomElement &symbologyElem) |
create a renderer from XML element More... | |
Static Public Member Functions inherited from QgsFeatureRendererV2 | |
static QgsFeatureRendererV2 * | defaultRenderer (QGis::GeometryType geomType) |
return a new renderer - used by default in vector layers More... | |
static QgsFeatureRendererV2 * | load (QDomElement &symbologyElem) |
create a renderer from XML element More... | |
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 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 ¢erPoint, 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 ¢erPoint, int nSymbols) |
void | drawSymbols (const 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. More... | |
Private Attributes | |
QgsFeatureRendererV2 * | mRenderer |
Embedded renderer. More... | |
QString | mLabelAttributeName |
Attribute name for labeling. More... | |
int | mLabelIndex |
Label attribute index (or -1 if none). More... | |
QgsMarkerSymbolV2 * | mCenterSymbol |
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< DisplacementGroup > | mDisplacementGroups |
Groups of features that have the same position. More... | |
QMap< QgsFeatureId, int > | mGroupIndex |
Mapping from feature ID to its group index. More... | |
QgsSpatialIndex * | mSpatialIndex |
Spatial index for fast lookup of close points. More... | |
QSet< QgsFeatureId > | mSelectedFeatures |
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... | |
A renderer that automatically displaces points with the same position.
Definition at line 31 of file qgspointdisplacementrenderer.h.
|
private |
Definition at line 129 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 399 of file qgspointdisplacementrenderer.cpp.
References M_PI.
Referenced by drawGroup().
|
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.
|
inline |
Definition at line 80 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 86 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 77 of file qgspointdisplacementrenderer.h.
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 52 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::clone(), QgsMarkerSymbolV2::clone(), mCenterSymbol, mCircleColor, mCircleRadiusAddition, mCircleWidth, mLabelAttributeName, mLabelColor, mLabelFont, mMaxLabelScaleDenominator, mRenderer, mTolerance, QgsPointDisplacementRenderer(), setCenterSymbol(), setCircleColor(), setCircleRadiusAddition(), setCircleWidth(), setEmbeddedRenderer(), setLabelColor(), setLabelFont(), setMaxLabelScaleDenominator(), and setTolerance().
|
static |
create a renderer from XML element
Definition at line 285 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 |
Definition at line 431 of file qgspointdisplacementrenderer.cpp.
References mCircleColor, mCircleWidth, QgsSymbolV2RenderContext::outputLineWidth(), QgsRenderContext::painter(), and QgsSymbolV2RenderContext::renderContext().
Referenced by drawGroup().
|
private |
Definition at line 124 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, mDrawLabels, QgsSymbolV2::MM, mRenderer, mSelectedFeatures, QgsSymbolV2RenderContext::outputLineWidth(), QgsRenderContext::painter(), and QgsMarkerSymbolV2::renderPoint().
Referenced by stopRender().
|
private |
Definition at line 459 of file qgspointdisplacementrenderer.cpp.
References mLabelColor, mLabelFont, QgsSymbolV2RenderContext::outputLineWidth(), QgsRenderContext::painter(), QgsRenderContext::rasterScaleFactor(), and QgsSymbolV2RenderContext::renderContext().
Referenced by drawGroup().
|
private |
Definition at line 446 of file qgspointdisplacementrenderer.cpp.
Referenced by drawGroup().
|
inline |
Definition at line 67 of file qgspointdisplacementrenderer.h.
|
private |
Returns first symbol for feature or 0 if none.
Definition at line 504 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::symbolsForFeature().
Referenced by drawGroup().
|
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().
|
inline |
Definition at line 63 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 83 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 74 of file qgspointdisplacementrenderer.h.
Referenced by create().
|
virtual |
Reimplemented from QgsFeatureRendererV2.
Definition at line 350 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 341 of file qgspointdisplacementrenderer.cpp.
References QgsFeatureRendererV2::legendSymbologyItems(), and mRenderer.
|
inline |
Definition at line 89 of file qgspointdisplacementrenderer.h.
|
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.
|
virtual |
Reimplemented from QgsFeatureRendererV2.
Reimplemented from QgsFeatureRendererV2.
Definition at line 76 of file qgspointdisplacementrenderer.cpp.
References QgsGeometry::asPoint(), QgsFeature::geometry(), QgsFeature::id(), QgsSpatialIndex::insertFeature(), QgsSpatialIndex::intersects(), mDisplacementGroups, mGroupIndex, mSelectedFeatures, mSpatialIndex, searchRect(), QGis::WKBPoint, QGis::WKBPoint25D, and QgsGeometry::wkbType().
|
private |
|
virtual |
store renderer info to XML element
Reimplemented from QgsFeatureRendererV2.
Definition at line 315 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 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.
|
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.
|
inline |
not available in python bindings
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.
|
inline |
Definition at line 62 of file qgspointdisplacementrenderer.h.
Referenced by create().
|
inline |
Definition at line 82 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 73 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 88 of file qgspointdisplacementrenderer.h.
|
inline |
Definition at line 96 of file qgspointdisplacementrenderer.h.
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 204 of file qgspointdisplacementrenderer.cpp.
References QgsFields::fieldNameIndex(), mCenterSymbol, mDisplacementGroups, mDrawLabels, mGroupIndex, mLabelAttributeName, mLabelIndex, mMaxLabelScaleDenominator, mRenderer, mSelectedFeatures, mSpatialIndex, QgsRenderContext::rendererScale(), QgsFeatureRendererV2::startRender(), and QgsSymbolV2::startRender().
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 237 of file qgspointdisplacementrenderer.cpp.
References drawGroup(), mCenterSymbol, mDisplacementGroups, mGroupIndex, mRenderer, mSelectedFeatures, mSpatialIndex, QgsDebugMsg, QgsFeatureRendererV2::stopRender(), and QgsSymbolV2::stopRender().
|
virtual |
to be overridden
feature | feature |
Implements QgsFeatureRendererV2.
Definition at line 198 of file qgspointdisplacementrenderer.cpp.
|
virtual |
for symbol levels
Implements QgsFeatureRendererV2.
Definition at line 273 of file qgspointdisplacementrenderer.cpp.
References mRenderer, and QgsFeatureRendererV2::symbols().
|
inline |
Definition at line 97 of file qgspointdisplacementrenderer.h.
|
virtual |
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Reimplemented from QgsFeatureRendererV2.
Definition at line 70 of file qgspointdisplacementrenderer.cpp.
References mRenderer, and QgsFeatureRendererV2::toSld().
|
virtual |
Implements QgsFeatureRendererV2.
Definition at line 259 of file qgspointdisplacementrenderer.cpp.
References mLabelAttributeName, mRenderer, and QgsFeatureRendererV2::usedAttributes().
|
private |
Center symbol for a displacement group.
Definition at line 110 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawGroup(), QgsPointDisplacementRenderer(), save(), setCenterSymbol(), startRender(), stopRender(), and ~QgsPointDisplacementRenderer().
|
private |
Color to draw the circle.
Definition at line 121 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawCircle(), and save().
|
private |
Addition to the default circle radius.
Definition at line 123 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawGroup(), and save().
|
private |
Line width for the circle.
Definition at line 119 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawCircle(), and save().
|
private |
Groups of features that have the same position.
Definition at line 131 of file qgspointdisplacementrenderer.h.
Referenced by printInfoDisplacementGroups(), renderFeature(), startRender(), and stopRender().
|
private |
Is set internally from startRender() depending on scale denominator.
Definition at line 125 of file qgspointdisplacementrenderer.h.
Referenced by drawGroup(), QgsPointDisplacementRenderer(), and startRender().
|
private |
Mapping from feature ID to its group index.
Definition at line 133 of file qgspointdisplacementrenderer.h.
Referenced by renderFeature(), startRender(), and stopRender().
|
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().
|
private |
Definition at line 117 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawLabels(), and save().
|
private |
Font that is passed to the renderer.
Definition at line 116 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 107 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 127 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 102 of file qgspointdisplacementrenderer.h.
Referenced by clone(), drawGroup(), legendSymbolItems(), legendSymbologyItems(), QgsPointDisplacementRenderer(), save(), setEmbeddedRenderer(), startRender(), stopRender(), symbols(), toSld(), usedAttributes(), and ~QgsPointDisplacementRenderer().
|
private |
keeps trask which features are selected
Definition at line 137 of file qgspointdisplacementrenderer.h.
Referenced by drawGroup(), renderFeature(), startRender(), and stopRender().
|
private |
Spatial index for fast lookup of close points.
Definition at line 135 of file qgspointdisplacementrenderer.h.
Referenced by renderFeature(), startRender(), and stopRender().
|
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().