QgsHeatmapRenderer class
A renderer which draws points as a live heatmap.
Contents
Public static functions
- static auto create(QDomElement& element, const QgsReadWriteContext& context) -> QgsFeatureRenderer*
- Creates a new heatmap renderer instance from XML.
Constructors, destructors, conversion operators
- QgsHeatmapRenderer(const QgsHeatmapRenderer&) deleted
- Direct copies are forbidden. Use clone() instead.
Public functions
- auto clone() const -> QgsHeatmapRenderer* override
- Create a deep copy of this renderer.
- auto colorRamp() const -> QgsColorRamp*
- Returns the color ramp used for shading the heatmap.
- auto dump() const -> QString override
- Returns debug information about this renderer.
- auto maximumValue() const -> double
- Returns the maximum value used for shading the heatmap.
- void modifyRequestExtent(QgsRectangle& extent, QgsRenderContext& context) override
- Allows for a renderer to modify the extent of a feature request prior to rendering.
- auto operator=(const QgsHeatmapRenderer&) -> QgsHeatmapRenderer& deleted
- Direct copies are forbidden. Use clone() instead.
- auto radius() const -> double
- Returns the radius for the heatmap.
- auto radiusMapUnitScale() const -> const QgsMapUnitScale&
- Returns the map unit scale used for the heatmap's radius.
-
auto radiusUnit() const -> QgsUnitTypes::
RenderUnit - Returns the units used for the heatmap's radius.
- auto renderFeature(const QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false) -> bool override
- Render a feature using this renderer in the given context.
- auto renderQuality() const -> double
- Returns the render quality used for drawing the heatmap.
- auto save(QDomDocument& doc, const QgsReadWriteContext& context) -> QDomElement override
- store renderer info to XML element
- void setColorRamp(QgsColorRamp* ramp)
- Sets the color ramp to use for shading the heatmap.
- void setMaximumValue(const double value)
- Sets the maximum value used for shading the heatmap.
- void setRadius(const double radius)
- Sets the radius for the heatmap.
- void setRadiusMapUnitScale(const QgsMapUnitScale& scale)
- Sets the map unit scale used for the heatmap's radius.
-
void setRadiusUnit(const QgsUnitTypes::
RenderUnit unit) - Sets the units used for the heatmap's radius.
- void setRenderQuality(const int quality)
- Sets the render quality used for drawing the heatmap.
- void setWeightExpression(const QString& expression)
- Sets the expression used for weighting points when generating the heatmap.
- void startRender(QgsRenderContext& context, const QgsFields& fields) override
- Must be called when a new render cycle is started.
- void stopRender(QgsRenderContext& context) override
- Must be called when a render cycle has finished, to allow the renderer to clean up.
- auto symbolForFeature(const QgsFeature& feature, QgsRenderContext& context) const -> QgsSymbol* override
- auto symbols(QgsRenderContext& context) const -> QgsSymbolList override
- auto usedAttributes(const QgsRenderContext& context) const -> QSet<QString> override
- Returns a list of attributes required by this renderer.
- auto weightExpression() const -> QString
- Returns the expression used for weighting points when generating the heatmap.
Function documentation
QgsHeatmapRenderer* QgsHeatmapRenderer:: clone() const override
Create a deep copy of this renderer.
| Returns | A copy of this renderer |
|---|
Should be implemented by all subclasses and generate a proper subclass.
QgsColorRamp* QgsHeatmapRenderer:: colorRamp() const
Returns the color ramp used for shading the heatmap.
| Returns | color ramp for heatmap |
|---|
double QgsHeatmapRenderer:: maximumValue() const
Returns the maximum value used for shading the heatmap.
| Returns | maximum value for heatmap shading. If 0, then maximum value will be automatically calculated. |
|---|
void QgsHeatmapRenderer:: modifyRequestExtent(QgsRectangle& extent,
QgsRenderContext& context) override
Allows for a renderer to modify the extent of a feature request prior to rendering.
| Parameters | |
|---|---|
| extent | reference to request's filter extent. Modify extent to change the extent of feature request |
| context | render context |
double QgsHeatmapRenderer:: radius() const
Returns the radius for the heatmap.
| Returns | heatmap radius |
|---|
const QgsMapUnitScale& QgsHeatmapRenderer:: radiusMapUnitScale() const
Returns the map unit scale used for the heatmap's radius.
| Returns | map unit scale for heatmap's radius |
|---|
QgsUnitTypes:: RenderUnit QgsHeatmapRenderer:: radiusUnit() const
Returns the units used for the heatmap's radius.
| Returns | units for heatmap radius |
|---|
bool QgsHeatmapRenderer:: renderFeature(const QgsFeature& feature,
QgsRenderContext& context,
int layer = -1,
bool selected = false,
bool drawVertexMarker = false) override
Render a feature using this renderer in the given context.
Must be called between startRender() and stopRender() calls. Default implementation renders a symbol as determined by symbolForFeature() call. Returns true if the feature has been returned (this is used for example to determine whether the feature may be labelled).
If layer is not -1, the renderer should draw only a particula layer from symbols (in order to support symbol level rendering).
double QgsHeatmapRenderer:: renderQuality() const
Returns the render quality used for drawing the heatmap.
| Returns | render quality. A value of 1 indicates maximum quality, and increasing the value will result in faster drawing but lower quality rendering. |
|---|
void QgsHeatmapRenderer:: setColorRamp(QgsColorRamp* ramp)
Sets the color ramp to use for shading the heatmap.
| Parameters | |
|---|---|
| ramp | color ramp for heatmap. Ownership of ramp is transferred to the renderer. |
void QgsHeatmapRenderer:: setMaximumValue(const double value)
Sets the maximum value used for shading the heatmap.
| Parameters | |
|---|---|
| value | maximum value for heatmap shading. Set to 0 for automatic calculation of maximum value. |
void QgsHeatmapRenderer:: setRadius(const double radius)
Sets the radius for the heatmap.
| Parameters | |
|---|---|
| radius | heatmap radius |
void QgsHeatmapRenderer:: setRadiusMapUnitScale(const QgsMapUnitScale& scale)
Sets the map unit scale used for the heatmap's radius.
| Parameters | |
|---|---|
| scale | map unit scale for heatmap's radius |
void QgsHeatmapRenderer:: setRadiusUnit(const QgsUnitTypes:: RenderUnit unit)
Sets the units used for the heatmap's radius.
| Parameters | |
|---|---|
| unit | units for heatmap radius |
void QgsHeatmapRenderer:: setRenderQuality(const int quality)
Sets the render quality used for drawing the heatmap.
| Parameters | |
|---|---|
| quality | render quality. A value of 1 indicates maximum quality, and increasing the value will result in faster drawing but lower quality rendering. |
void QgsHeatmapRenderer:: setWeightExpression(const QString& expression)
Sets the expression used for weighting points when generating the heatmap.
| Parameters | |
|---|---|
| expression | point weight expression. If set to empty, all points are equally weighted. |
void QgsHeatmapRenderer:: startRender(QgsRenderContext& context,
const QgsFields& fields) override
Must be called when a new render cycle is started.
| Parameters | |
|---|---|
| context | Additional information passed to the renderer about the job which will be rendered |
| fields | The fields available for rendering |
A call to startRender() must always be followed by a corresponding call to stopRender() after all features have been rendered.
void QgsHeatmapRenderer:: stopRender(QgsRenderContext& context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
Calls to stopRender() must always be preceded by a call to startRender().
QgsSymbol* QgsHeatmapRenderer:: symbolForFeature(const QgsFeature& feature,
QgsRenderContext& context) const override
QgsSymbolList QgsHeatmapRenderer:: symbols(QgsRenderContext& context) const override
QSet<QString> QgsHeatmapRenderer:: usedAttributes(const QgsRenderContext& context) const override
Returns a list of attributes required by this renderer.
| Returns | A set of attributes |
|---|
Attributes not listed in here may not have been requested from the provider at rendering time.
QString QgsHeatmapRenderer:: weightExpression() const
Returns the expression used for weighting points when generating the heatmap.
| Returns | point weight expression. If empty, all points are equally weighted. |
|---|