16#include "moc_qgsheatmaprendererwidget.cpp"
41 expContext = lMapCanvas->createExpressionContext();
77 QLabel *label =
new QLabel( tr(
"The heatmap renderer only applies to point and multipoint layers. \n"
78 "'%1' is not a point layer and cannot be rendered as a heatmap." )
79 .arg( layer->
name() ),
82 setLayout(
new QGridLayout() );
83 layout()->addWidget( label );
89 connect( mRadiusSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged );
90 connect( mMaxSpinBox,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged );
91 connect( mQualitySlider, &QSlider::valueChanged,
this, &QgsHeatmapRendererWidget::mQualitySlider_valueChanged );
92 this->layout()->setContentsMargins( 0, 0, 0, 0 );
95 mWeightExpressionWidget->registerExpressionContextGenerator(
this );
96 mWeightExpressionWidget->setAllowEmptyFieldName(
true );
104 mRenderer = std::make_unique<QgsHeatmapRenderer>();
109 btnColorRamp->setShowGradientOnly(
true );
112 connect( mLegendSettingsButton, &QPushButton::clicked,
this, &QgsHeatmapRendererWidget::showLegendSettings );
114 if ( mRenderer->colorRamp() )
116 btnColorRamp->blockSignals(
true );
117 btnColorRamp->setColorRamp( mRenderer->colorRamp() );
118 btnColorRamp->blockSignals(
false );
120 mRadiusSpinBox->blockSignals(
true );
121 mRadiusSpinBox->setValue( mRenderer->radius() );
122 mRadiusSpinBox->blockSignals(
false );
123 mRadiusUnitWidget->blockSignals(
true );
124 mRadiusUnitWidget->setUnit( mRenderer->radiusUnit() );
125 mRadiusUnitWidget->setMapUnitScale( mRenderer->radiusMapUnitScale() );
126 mRadiusUnitWidget->blockSignals(
false );
127 mMaxSpinBox->blockSignals(
true );
128 mMaxSpinBox->setValue( mRenderer->maximumValue() );
129 mMaxSpinBox->blockSignals(
false );
130 mQualitySlider->blockSignals(
true );
131 mQualitySlider->setValue( mRenderer->renderQuality() );
132 mQualitySlider->blockSignals(
false );
134 mWeightExpressionWidget->setLayer( layer );
135 mWeightExpressionWidget->setField( mRenderer->weightExpression() );
146 return mRenderer.get();
153 mRadiusUnitWidget->setMapCanvas( lMapCanvas );
156void QgsHeatmapRendererWidget::applyColorRamp()
167 mRenderer->setColorRamp( ramp );
171void QgsHeatmapRendererWidget::showLegendSettings()
179 legendPanel->
setSettings( mRenderer->legendSettings() );
181 mRenderer->setLegendSettings( legendPanel->
settings() );
189 dialog.setUseContinuousRampCheckBoxVisibility(
false );
190 dialog.setWindowTitle( tr(
"Legend Settings" ) );
193 mRenderer->setLegendSettings( dialog.settings() );
199void QgsHeatmapRendererWidget::mRadiusUnitWidget_changed()
206 mRenderer->setRadiusUnit( mRadiusUnitWidget->unit() );
207 mRenderer->setRadiusMapUnitScale( mRadiusUnitWidget->getMapUnitScale() );
211void QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged(
double d )
218 mRenderer->setRadius( d );
222void QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged(
double d )
229 mRenderer->setMaximumValue( d );
233void QgsHeatmapRendererWidget::mQualitySlider_valueChanged(
int v )
240 mRenderer->setRenderQuality( v );
244void QgsHeatmapRendererWidget::weightExpressionChanged(
const QString &expression )
246 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.
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.
Abstract base class for all 2D vector feature renderers.
@ 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.