30 #include <QGridLayout>
51 expContext << generator->createExpressionContextScope();
85 QLabel *label =
new QLabel( tr(
"The heatmap renderer only applies to point and multipoint layers. \n"
86 "'%1' is not a point layer and cannot be rendered as a heatmap." )
87 .arg( layer->
name() ),
this );
89 setLayout(
new QGridLayout() );
90 layout()->addWidget( label );
96 connect( mRadiusSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged );
97 connect( mMaxSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged );
98 connect( mQualitySlider, &QSlider::valueChanged,
this, &QgsHeatmapRendererWidget::mQualitySlider_valueChanged );
99 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 );
121 if ( mRenderer->colorRamp() )
123 btnColorRamp->blockSignals(
true );
124 btnColorRamp->setColorRamp( mRenderer->colorRamp() );
125 btnColorRamp->blockSignals(
false );
127 mRadiusSpinBox->blockSignals(
true );
128 mRadiusSpinBox->setValue( mRenderer->radius() );
129 mRadiusSpinBox->blockSignals(
false );
130 mRadiusUnitWidget->blockSignals(
true );
131 mRadiusUnitWidget->setUnit( mRenderer->radiusUnit() );
132 mRadiusUnitWidget->setMapUnitScale( mRenderer->radiusMapUnitScale() );
133 mRadiusUnitWidget->blockSignals(
false );
134 mMaxSpinBox->blockSignals(
true );
135 mMaxSpinBox->setValue( mRenderer->maximumValue() );
136 mMaxSpinBox->blockSignals(
false );
137 mQualitySlider->blockSignals(
true );
138 mQualitySlider->setValue( mRenderer->renderQuality() );
139 mQualitySlider->blockSignals(
false );
141 mWeightExpressionWidget->setLayer( layer );
142 mWeightExpressionWidget->setField( mRenderer->weightExpression() );
150 return mRenderer.get();
157 mRadiusUnitWidget->setMapCanvas( lMapCanvas );
160 void QgsHeatmapRendererWidget::applyColorRamp()
171 mRenderer->setColorRamp( ramp );
175 void QgsHeatmapRendererWidget::mRadiusUnitWidget_changed()
182 mRenderer->setRadiusUnit( mRadiusUnitWidget->unit() );
183 mRenderer->setRadiusMapUnitScale( mRadiusUnitWidget->getMapUnitScale() );
187 void QgsHeatmapRendererWidget::mRadiusSpinBox_valueChanged(
double d )
194 mRenderer->setRadius( d );
198 void QgsHeatmapRendererWidget::mMaxSpinBox_valueChanged(
double d )
205 mRenderer->setMaximumValue( d );
209 void QgsHeatmapRendererWidget::mQualitySlider_valueChanged(
int v )
216 mRenderer->setRenderQuality( v );
220 void QgsHeatmapRendererWidget::weightExpressionChanged(
const QString &expression )
222 mRenderer->setWeightExpression( expression );