48 setupBlankUi( layer->
name() );
52 connect( mLabelFieldComboBox, &QComboBox::currentTextChanged,
this, &QgsPointDisplacementRendererWidget::mLabelFieldComboBox_currentIndexChanged );
53 connect( mRendererComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointDisplacementRendererWidget::mRendererComboBox_currentIndexChanged );
54 connect( mPlacementComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointDisplacementRendererWidget::mPlacementComboBox_currentIndexChanged );
55 connect( mCircleWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsPointDisplacementRendererWidget::mCircleWidthSpinBox_valueChanged );
56 connect( mCircleColorButton, &
QgsColorButton::colorChanged,
this, &QgsPointDisplacementRendererWidget::mCircleColorButton_colorChanged );
57 connect( mDistanceSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsPointDisplacementRendererWidget::mDistanceSpinBox_valueChanged );
60 connect( mCircleModificationSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsPointDisplacementRendererWidget::mCircleModificationSpinBox_valueChanged );
61 connect( mLabelDistanceFactorSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsPointDisplacementRendererWidget::mLabelDistanceFactorSpinBox_valueChanged );
62 connect( mScaleDependentLabelsCheckBox, &QCheckBox::stateChanged,
this, &QgsPointDisplacementRendererWidget::mScaleDependentLabelsCheckBox_stateChanged );
63 connect( mRendererSettingsButton, &QPushButton::clicked,
this, &QgsPointDisplacementRendererWidget::mRendererSettingsButton_clicked );
64 this->layout()->setContentsMargins( 0, 0, 0, 0 );
80 blockAllSignals(
true );
90 for (
const QgsField &f : layerFields )
92 mLabelFieldComboBox->addItem( f.name() );
94 mLabelFieldComboBox->addItem( tr(
"None" ) );
97 if ( !currentLabelAttribute.isEmpty() )
99 mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( currentLabelAttribute ) );
103 mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( tr(
"None" ) ) );
109 QStringList::const_iterator it = rendererList.constBegin();
110 for ( ; it != rendererList.constEnd(); ++it )
112 if ( *it != QLatin1String(
"pointDisplacement" ) && *it != QLatin1String(
"pointCluster" ) && *it != QLatin1String(
"heatmapRenderer" ) )
119 mCircleColorButton->setColorDialogTitle( tr(
"Select Color" ) );
120 mCircleColorButton->setContext( QStringLiteral(
"symbology" ) );
121 mCircleColorButton->setAllowOpacity(
true );
122 mCircleColorButton->setShowNoColor(
true );
123 mCircleColorButton->setNoColorString( tr(
"Transparent Stroke" ) );
124 mLabelColorButton->setContext( QStringLiteral(
"symbology" ) );
125 mLabelColorButton->setColorDialogTitle( tr(
"Select Color" ) );
126 mLabelColorButton->setAllowOpacity(
true );
128 mCircleWidthSpinBox->setValue( mRenderer->
circleWidth() );
129 mCircleColorButton->setColor( mRenderer->
circleColor() );
130 mLabelColorButton->setColor( mRenderer->
labelColor() );
131 mLabelFontButton->setCurrentFont( mRenderer->
labelFont() );
132 mCircleModificationSpinBox->setClearValue( 0.0 );
134 mLabelDistanceFactorSpinBox->setClearValue( 0.5 );
136 mDistanceSpinBox->setValue( mRenderer->
tolerance() );
141 mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( mRenderer->
placement() ) );
144 mMinLabelScaleWidget->setScale( std::max( mRenderer->
minimumLabelScale(), 0.0 ) );
147 mScaleDependentLabelsCheckBox->setCheckState( Qt::Checked );
151 mScaleDependentLabelsCheckBox->setCheckState( Qt::Unchecked );
152 mMinLabelScaleWidget->setEnabled(
false );
156 blockAllSignals(
false );
162 int rendererIndex = mRendererComboBox->findData( rendererName );
163 if ( rendererIndex != -1 )
165 mRendererComboBox->setCurrentIndex( rendererIndex );
166 mRendererComboBox_currentIndexChanged( rendererIndex );
171 connect( mLabelFontButton, &
QgsFontButton::changed,
this, &QgsPointDisplacementRendererWidget::labelFontChanged );
172 connect( mCenterSymbolToolButton, &
QgsSymbolButton::changed,
this, &QgsPointDisplacementRendererWidget::centerSymbolChanged );
173 mCenterSymbolToolButton->setDialogTitle( tr(
"Center symbol" ) );
174 mCenterSymbolToolButton->setLayer(
mLayer );
175 mCenterSymbolToolButton->registerExpressionContextGenerator(
this );
191 if ( mDistanceUnitWidget )
193 if ( mMinLabelScaleWidget )
196 mMinLabelScaleWidget->setShowCurrentScaleButton(
true );
198 if ( mCenterSymbolToolButton )
217 const auto constScopes = scopes;
225 void QgsPointDisplacementRendererWidget::mLabelFieldComboBox_currentIndexChanged(
const QString &text )
229 if ( text == tr(
"None" ) )
241 void QgsPointDisplacementRendererWidget::mRendererComboBox_currentIndexChanged(
int index )
243 QString rendererId = mRendererComboBox->itemData( index ).toString();
251 delete tempRenderWidget;
256 void QgsPointDisplacementRendererWidget::mPlacementComboBox_currentIndexChanged(
int index )
265 void QgsPointDisplacementRendererWidget::mRendererSettingsButton_clicked()
291 void QgsPointDisplacementRendererWidget::labelFontChanged()
298 mRenderer->
setLabelFont( mLabelFontButton->currentFont() );
302 void QgsPointDisplacementRendererWidget::mCircleWidthSpinBox_valueChanged(
double d )
311 void QgsPointDisplacementRendererWidget::mCircleColorButton_colorChanged(
const QColor &newColor )
322 void QgsPointDisplacementRendererWidget::mLabelColorButton_colorChanged(
const QColor &newColor )
333 void QgsPointDisplacementRendererWidget::mCircleModificationSpinBox_valueChanged(
double d )
344 void QgsPointDisplacementRendererWidget::mLabelDistanceFactorSpinBox_valueChanged(
double d )
355 void QgsPointDisplacementRendererWidget::mDistanceSpinBox_valueChanged(
double d )
364 void QgsPointDisplacementRendererWidget::mDistanceUnitWidget_changed()
374 void QgsPointDisplacementRendererWidget::mScaleDependentLabelsCheckBox_stateChanged(
int state )
376 if ( state == Qt::Unchecked )
378 mMinLabelScaleWidget->setScale( 0 );
379 mMinLabelScaleWidget->setEnabled(
false );
383 mMinLabelScaleWidget->setEnabled(
true );
387 void QgsPointDisplacementRendererWidget::minLabelScaleChanged(
double scale )
398 void QgsPointDisplacementRendererWidget::blockAllSignals(
bool block )
400 mLabelFieldComboBox->blockSignals( block );
401 mLabelFontButton->blockSignals( block );
402 mCircleWidthSpinBox->blockSignals( block );
403 mCircleColorButton->blockSignals( block );
404 mRendererComboBox->blockSignals( block );
405 mLabelColorButton->blockSignals( block );
406 mCircleModificationSpinBox->blockSignals( block );
407 mLabelDistanceFactorSpinBox->blockSignals( block );
408 mScaleDependentLabelsCheckBox->blockSignals( block );
409 mMinLabelScaleWidget->blockSignals( block );
410 mCenterSymbolToolButton->blockSignals( block );
411 mDistanceSpinBox->blockSignals( block );
412 mDistanceUnitWidget->blockSignals( block );
413 mPlacementComboBox->blockSignals( block );
416 void QgsPointDisplacementRendererWidget::centerSymbolChanged()
422 void QgsPointDisplacementRendererWidget::updateRendererFromWidget()
432 void QgsPointDisplacementRendererWidget::setupBlankUi(
const QString &layerName )
434 QLabel *label =
new QLabel( tr(
"The point displacement renderer only applies to (single) point layers. \n'%1' is not a (single) point layer and cannot be displayed by the point displacement renderer." ).arg( layerName ),
this );
435 QVBoxLayout *layout =
new QVBoxLayout(
this );
436 layout->setContentsMargins( 0, 0, 0, 0 );
437 layout->addWidget( label );