48 setupBlankUi( layer->
name() );
52 connect( mLabelFieldComboBox,
static_cast<void ( QComboBox::* )(
const QString & )
>( &QComboBox::currentIndexChanged ),
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( mScaleDependentLabelsCheckBox, &QCheckBox::stateChanged,
this, &QgsPointDisplacementRendererWidget::mScaleDependentLabelsCheckBox_stateChanged );
62 connect( mRendererSettingsButton, &QPushButton::clicked,
this, &QgsPointDisplacementRendererWidget::mRendererSettingsButton_clicked );
63 this->layout()->setContentsMargins( 0, 0, 0, 0 );
79 blockAllSignals(
true );
89 for (
const QgsField &f : layerFields )
91 mLabelFieldComboBox->addItem( f.name() );
93 mLabelFieldComboBox->addItem( tr(
"None" ) );
96 if ( !currentLabelAttribute.isEmpty() )
98 mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( currentLabelAttribute ) );
102 mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( tr(
"None" ) ) );
108 QStringList::const_iterator it = rendererList.constBegin();
109 for ( ; it != rendererList.constEnd(); ++it )
111 if ( *it != QLatin1String(
"pointDisplacement" ) && *it != QLatin1String(
"pointCluster" ) && *it != QLatin1String(
"heatmapRenderer" ) )
118 mCircleColorButton->setColorDialogTitle( tr(
"Select Color" ) );
119 mCircleColorButton->setContext( QStringLiteral(
"symbology" ) );
120 mCircleColorButton->setAllowOpacity(
true );
121 mCircleColorButton->setShowNoColor(
true );
122 mCircleColorButton->setNoColorString( tr(
"Transparent Stroke" ) );
123 mLabelColorButton->setContext( QStringLiteral(
"symbology" ) );
124 mLabelColorButton->setColorDialogTitle( tr(
"Select Color" ) );
125 mLabelColorButton->setAllowOpacity(
true );
127 mCircleWidthSpinBox->setValue( mRenderer->
circleWidth() );
128 mCircleColorButton->setColor( mRenderer->
circleColor() );
129 mLabelColorButton->setColor( mRenderer->
labelColor() );
130 mLabelFontButton->setCurrentFont( mRenderer->
labelFont() );
131 mCircleModificationSpinBox->setClearValue( 0.0 );
133 mDistanceSpinBox->setValue( mRenderer->
tolerance() );
138 mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( mRenderer->
placement() ) );
141 mMinLabelScaleWidget->setScale( std::max( mRenderer->
minimumLabelScale(), 0.0 ) );
144 mScaleDependentLabelsCheckBox->setCheckState( Qt::Checked );
148 mScaleDependentLabelsCheckBox->setCheckState( Qt::Unchecked );
149 mMinLabelScaleWidget->setEnabled(
false );
153 blockAllSignals(
false );
159 int rendererIndex = mRendererComboBox->findData( rendererName );
160 if ( rendererIndex != -1 )
162 mRendererComboBox->setCurrentIndex( rendererIndex );
163 mRendererComboBox_currentIndexChanged( rendererIndex );
168 connect( mLabelFontButton, &
QgsFontButton::changed,
this, &QgsPointDisplacementRendererWidget::labelFontChanged );
169 connect( mCenterSymbolToolButton, &
QgsSymbolButton::changed,
this, &QgsPointDisplacementRendererWidget::centerSymbolChanged );
170 mCenterSymbolToolButton->setDialogTitle( tr(
"Center symbol" ) );
171 mCenterSymbolToolButton->setLayer(
mLayer );
172 mCenterSymbolToolButton->registerExpressionContextGenerator(
this );
188 if ( mDistanceUnitWidget )
189 mDistanceUnitWidget->setMapCanvas( context.
mapCanvas() );
190 if ( mMinLabelScaleWidget )
192 mMinLabelScaleWidget->setMapCanvas( context.
mapCanvas() );
193 mMinLabelScaleWidget->setShowCurrentScaleButton(
true );
195 if ( mCenterSymbolToolButton )
197 mCenterSymbolToolButton->setMapCanvas( context.
mapCanvas() );
198 mCenterSymbolToolButton->setMessageBar( context.
messageBar() );
221 void QgsPointDisplacementRendererWidget::mLabelFieldComboBox_currentIndexChanged(
const QString &text )
225 if ( text == tr(
"None" ) )
237 void QgsPointDisplacementRendererWidget::mRendererComboBox_currentIndexChanged(
int index )
239 QString rendererId = mRendererComboBox->itemData( index ).toString();
246 delete tempRenderWidget;
251 void QgsPointDisplacementRendererWidget::mPlacementComboBox_currentIndexChanged(
int index )
260 void QgsPointDisplacementRendererWidget::mRendererSettingsButton_clicked()
286 void QgsPointDisplacementRendererWidget::labelFontChanged()
293 mRenderer->
setLabelFont( mLabelFontButton->currentFont() );
297 void QgsPointDisplacementRendererWidget::mCircleWidthSpinBox_valueChanged(
double d )
306 void QgsPointDisplacementRendererWidget::mCircleColorButton_colorChanged(
const QColor &newColor )
317 void QgsPointDisplacementRendererWidget::mLabelColorButton_colorChanged(
const QColor &newColor )
328 void QgsPointDisplacementRendererWidget::mCircleModificationSpinBox_valueChanged(
double d )
339 void QgsPointDisplacementRendererWidget::mDistanceSpinBox_valueChanged(
double d )
348 void QgsPointDisplacementRendererWidget::mDistanceUnitWidget_changed()
358 void QgsPointDisplacementRendererWidget::mScaleDependentLabelsCheckBox_stateChanged(
int state )
360 if ( state == Qt::Unchecked )
362 mMinLabelScaleWidget->setScale( 0 );
363 mMinLabelScaleWidget->setEnabled(
false );
367 mMinLabelScaleWidget->setEnabled(
true );
371 void QgsPointDisplacementRendererWidget::minLabelScaleChanged(
double scale )
382 void QgsPointDisplacementRendererWidget::blockAllSignals(
bool block )
384 mLabelFieldComboBox->blockSignals( block );
385 mLabelFontButton->blockSignals( block );
386 mCircleWidthSpinBox->blockSignals( block );
387 mCircleColorButton->blockSignals( block );
388 mRendererComboBox->blockSignals( block );
389 mLabelColorButton->blockSignals( block );
390 mCircleModificationSpinBox->blockSignals( block );
391 mScaleDependentLabelsCheckBox->blockSignals( block );
392 mMinLabelScaleWidget->blockSignals( block );
393 mCenterSymbolToolButton->blockSignals( block );
394 mDistanceSpinBox->blockSignals( block );
395 mDistanceUnitWidget->blockSignals( block );
396 mPlacementComboBox->blockSignals( block );
399 void QgsPointDisplacementRendererWidget::centerSymbolChanged()
405 void QgsPointDisplacementRendererWidget::updateRendererFromWidget()
415 void QgsPointDisplacementRendererWidget::setupBlankUi(
const QString &layerName )
417 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 );
418 QVBoxLayout *layout =
new QVBoxLayout(
this );
419 layout->setContentsMargins( 0, 0, 0, 0 );
420 layout->addWidget( label );
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
Meters value as Map units.
Single variable definition for use within a QgsExpressionContextScope.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
Placement
Placement methods for dispersing points.
Place points in a grid around group.
QgsMarkerSymbol * centerSymbol()
Returns the symbol for the center of a displacement group (but not ownership of the symbol)...
double minimumLabelScale() const
Returns the minimum map scale (i.e.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
void setLabelFont(const QFont &font)
Sets the font used for labeling points.
void setTolerance(double distance)
Sets the tolerance distance for grouping points.
void setLabelColor(const QColor &color)
Sets the color to use for for labeling points.
void setToleranceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the distance tolerance.
void setToleranceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the tolerance distance.
double circleRadiusAddition() const
Returns the factor for increasing the ring size of displacement groups.
Container of fields for a vector layer.
QStringList renderersList(QgsRendererAbstractMetadata::LayerTypes layerTypes=QgsRendererAbstractMetadata::All) const
Returns a list of available renderers.
QString labelAttributeName() const
Returns the attribute name used for labeling points, or an empty string if no labeling will be done b...
void setCenterSymbol(QgsMarkerSymbol *symbol)
Sets the center symbol for a displacement group.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
QgsUnitTypes::RenderUnit toleranceUnit() const
Returns the units for the tolerance distance.
A marker symbol type, for rendering Point and MultiPoint geometries.
QFont labelFont() const
Returns the font used for labeling points.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void setCircleColor(const QColor &color)
Sets the color used for drawing the displacement group circle.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
points (e.g., for font sizes)
void setLabelAttributeName(const QString &name)
Sets the attribute name for labeling points.
QColor circleColor() const
Returns the color used for drawing the displacement group circle.
Place points in concentric rings around group.
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
void setPlacement(Placement placement)
Sets the placement method used for dispersing the points.
Encapsulate a field in an attribute table or data source.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setAdditionalExpressionContextScopes(const QList< QgsExpressionContextScope > &scopes)
Sets a list of additional expression context scopes to show as available within the layer...
double tolerance() const
Returns the tolerance distance for grouping points.
const QgsMapUnitScale & toleranceMapUnitScale() const
Returns the map unit scale object for the distance tolerance.
Place points in a single ring around group.
A renderer that automatically displaces points with the same geographic location. ...
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
void setMinimumLabelScale(double scale)
Sets the minimum map scale (i.e.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context.
Placement placement() const
Returns the placement method used for dispersing the points.
void setCircleRadiusAddition(double distance)
Sets a factor for increasing the ring size of displacement groups.
void setEmbeddedRenderer(QgsFeatureRenderer *r) override
Sets an embedded renderer (subrenderer) for this feature renderer.
Represents a vector layer which manages a vector based data sets.
static QgsPointDisplacementRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
Creates a QgsPointDisplacementRenderer from an existing renderer.
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
void setCircleWidth(double width)
Sets the line width for the displacement group circle.
QColor labelColor() const
Returns the color used for for labeling points.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
double circleWidth() const
Returns the line width for the displacement group circle in mm.