47 expContext << generator->createExpressionContextScope();
81 QLabel *label =
new QLabel( tr(
"The heatmap renderer only applies to point and multipoint layers. \n"
82 "'%1' is not a point layer and cannot be rendered as a heatmap." )
83 .arg( layer->
name() ),
this );
85 setLayout(
new QGridLayout() );
86 layout()->addWidget( label );
92 connect( mRadiusSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged );
93 connect( mMaxSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged );
94 connect( mQualitySlider, &QSlider::valueChanged,
this, &QgsHeatmapRendererWidget::mQualitySlider_valueChanged );
95 this->layout()->setContentsMargins( 0, 0, 0, 0 );
103 mWeightExpressionWidget->registerExpressionContextGenerator(
this );
104 mWeightExpressionWidget->setAllowEmptyFieldName(
true );
112 mRenderer = std::make_unique< QgsHeatmapRenderer >();
117 btnColorRamp->setShowGradientOnly(
true );
120 connect( mLegendSettingsButton, &QPushButton::clicked,
this, &QgsHeatmapRendererWidget::showLegendSettings );
122 if ( mRenderer->colorRamp() )
124 btnColorRamp->blockSignals(
true );
125 btnColorRamp->setColorRamp( mRenderer->colorRamp() );
126 btnColorRamp->blockSignals(
false );
128 mRadiusSpinBox->blockSignals(
true );
129 mRadiusSpinBox->setValue( mRenderer->radius() );
130 mRadiusSpinBox->blockSignals(
false );
131 mRadiusUnitWidget->blockSignals(
true );
132 mRadiusUnitWidget->setUnit( mRenderer->radiusUnit() );
133 mRadiusUnitWidget->setMapUnitScale( mRenderer->radiusMapUnitScale() );
134 mRadiusUnitWidget->blockSignals(
false );
135 mMaxSpinBox->blockSignals(
true );
136 mMaxSpinBox->setValue( mRenderer->maximumValue() );
137 mMaxSpinBox->blockSignals(
false );
138 mQualitySlider->blockSignals(
true );
139 mQualitySlider->setValue( mRenderer->renderQuality() );
140 mQualitySlider->blockSignals(
false );
142 mWeightExpressionWidget->setLayer( layer );
143 mWeightExpressionWidget->setField( mRenderer->weightExpression() );
154 return mRenderer.get();
161 mRadiusUnitWidget->setMapCanvas( lMapCanvas );
164void QgsHeatmapRendererWidget::applyColorRamp()
175 mRenderer->setColorRamp( ramp );
179void QgsHeatmapRendererWidget::showLegendSettings()
187 legendPanel->
setSettings( mRenderer->legendSettings() );
190 mRenderer->setLegendSettings( legendPanel->
settings() );
198 dialog.setUseContinuousRampCheckBoxVisibility(
false );
199 dialog.setWindowTitle( tr(
"Legend Settings" ) );
202 mRenderer->setLegendSettings( dialog.settings() );
208void QgsHeatmapRendererWidget::mRadiusUnitWidget_changed()
215 mRenderer->setRadiusUnit( mRadiusUnitWidget->unit() );
216 mRenderer->setRadiusMapUnitScale( mRadiusUnitWidget->getMapUnitScale() );
220void QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged(
double d )
227 mRenderer->setRadius( d );
231void QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged(
double d )
238 mRenderer->setMaximumValue( d );
242void QgsHeatmapRendererWidget::mQualitySlider_valueChanged(
int v )
249 mRenderer->setRenderQuality( v );
253void QgsHeatmapRendererWidget::weightExpressionChanged(
const QString &expression )
255 mRenderer->setWeightExpression( expression );
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
A dialog for configuring a QgsColorRampLegendNode (QgsColorRampLegendNodeSettings).
Abstract base class for color ramps.
Abstract interface for generating an expression context scope.
Single scope for storing variables and functions for use within a QgsExpressionContext.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const 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.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
@ HeatmapRadius
Heatmap renderer radius.
@ HeatmapMaximum
Heatmap maximum value.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
static QgsHeatmapRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
The QgsMapSettings class contains configuration for rendering of the map.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.