28 #include <QGridLayout> 78 QLabel *label =
new QLabel( tr(
"The heatmap renderer only applies to point and multipoint layers. \n" 79 "'%1' is not a point layer and cannot be rendered as a heatmap." )
80 .arg( layer->
name() ),
this );
81 layout()->addWidget( label );
87 connect( mRadiusSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged );
88 connect( mMaxSpinBox, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged );
89 connect( mQualitySlider, &QSlider::valueChanged,
this, &QgsHeatmapRendererWidget::mQualitySlider_valueChanged );
90 this->layout()->setContentsMargins( 0, 0, 0, 0 );
94 mWeightExpressionWidget->registerExpressionContextGenerator(
this );
105 btnColorRamp->setShowGradientOnly(
true );
111 btnColorRamp->blockSignals(
true );
112 btnColorRamp->setColorRamp( mRenderer->
colorRamp() );
113 btnColorRamp->blockSignals(
false );
115 mRadiusSpinBox->blockSignals(
true );
116 mRadiusSpinBox->setValue( mRenderer->
radius() );
117 mRadiusSpinBox->blockSignals(
false );
118 mRadiusUnitWidget->blockSignals(
true );
119 mRadiusUnitWidget->setUnit( mRenderer->
radiusUnit() );
121 mRadiusUnitWidget->blockSignals(
false );
122 mMaxSpinBox->blockSignals(
true );
124 mMaxSpinBox->blockSignals(
false );
125 mQualitySlider->blockSignals(
true );
127 mQualitySlider->blockSignals(
false );
129 mWeightExpressionWidget->setLayer( layer );
143 mRadiusUnitWidget->setMapCanvas( context.
mapCanvas() );
146 void QgsHeatmapRendererWidget::applyColorRamp()
161 void QgsHeatmapRendererWidget::mRadiusUnitWidget_changed()
173 void QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged(
double d )
184 void QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged(
double d )
195 void QgsHeatmapRendererWidget::mQualitySlider_valueChanged(
int v )
206 void QgsHeatmapRendererWidget::weightExpressionChanged(
const QString &expression )
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp to use for shading the heatmap.
Abstract base class for color ramps.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
double maximumValue() const
Returns the maximum value used for shading the heatmap.
void setWeightExpression(const QString &expression)
Sets the expression used for weighting points when generating the heatmap.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
The QgsMapSettings class contains configuration for rendering of the map.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
A renderer which draws points as a live heatmap.
const QgsMapUnitScale & radiusMapUnitScale() const
Returns the map unit scale used for the heatmap's radius.
double radius() const
Returns the radius for the heatmap.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void setRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the heatmap's radius.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
points (e.g., for font sizes)
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setRenderQuality(const int quality)
Sets the render quality used for drawing the heatmap.
void setRadiusUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units used for the heatmap's radius.
void setRadius(const double radius)
Sets the radius for the heatmap.
double renderQuality() const
Returns the render quality used for drawing the heatmap.
static QgsExpressionContextScope * atlasScope(QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
QgsExpressionContextScope & expressionContextScope()
Returns a reference to the expression context scope for the map canvas.
QgsUnitTypes::RenderUnit radiusUnit() const
Returns the units used for the heatmap's radius.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
static QgsHeatmapRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
QgsColorRamp * colorRamp() const
Returns the color ramp used for shading the heatmap.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Represents a vector layer which manages a vector based data sets.
QString weightExpression() const
Returns the expression used for weighting points when generating the heatmap.
void setMaximumValue(const double value)
Sets the maximum value used for shading the heatmap.