19#include "moc_qgspointclusterrendererwidget.cpp"
47 setupBlankUi( layer->
name() );
51 connect( mRendererComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged );
52 connect( mDistanceSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsPointClusterRendererWidget::mDistanceSpinBox_valueChanged );
54 connect( mRendererSettingsButton, &QPushButton::clicked,
this, &QgsPointClusterRendererWidget::mRendererSettingsButton_clicked );
55 this->layout()->setContentsMargins( 0, 0, 0, 0 );
68 mRenderer = std::make_unique< QgsPointClusterRenderer >();
73 blockAllSignals(
true );
77 QStringList::const_iterator it = rendererList.constBegin();
78 for ( ; it != rendererList.constEnd(); ++it )
80 if ( *it != QLatin1String(
"pointDisplacement" ) && *it != QLatin1String(
"pointCluster" ) && *it != QLatin1String(
"heatmapRenderer" ) )
87 mDistanceSpinBox->setValue( mRenderer->tolerance() );
88 mDistanceUnitWidget->setUnit( mRenderer->toleranceUnit() );
89 mDistanceUnitWidget->setMapUnitScale( mRenderer->toleranceMapUnitScale() );
90 mCenterSymbolToolButton->setSymbol( mRenderer->clusterSymbol()->clone() );
92 blockAllSignals(
false );
95 if ( mRenderer->embeddedRenderer() )
97 const QString rendererName = mRenderer->embeddedRenderer()->type();
98 const int rendererIndex = mRendererComboBox->findData( rendererName );
99 if ( rendererIndex != -1 )
101 mRendererComboBox->setCurrentIndex( rendererIndex );
102 mRendererComboBox_currentIndexChanged( rendererIndex );
106 connect( mCenterSymbolToolButton, &
QgsSymbolButton::changed,
this, &QgsPointClusterRendererWidget::centerSymbolChanged );
107 mCenterSymbolToolButton->setDialogTitle( tr(
"Cluster symbol" ) );
108 mCenterSymbolToolButton->setLayer(
mLayer );
109 mCenterSymbolToolButton->registerExpressionContextGenerator(
this );
116 return mRenderer.get();
122 if ( mDistanceUnitWidget )
124 if ( mCenterSymbolToolButton )
131void QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged(
int index )
133 const QString rendererId = mRendererComboBox->itemData( index ).toString();
138 const std::unique_ptr< QgsFeatureRenderer > oldRenderer( mRenderer->embeddedRenderer()->clone() );
140 mRenderer->setEmbeddedRenderer( tempRenderWidget->
renderer()->
clone() );
141 delete tempRenderWidget;
146void QgsPointClusterRendererWidget::mRendererSettingsButton_clicked()
172void QgsPointClusterRendererWidget::mDistanceSpinBox_valueChanged(
double d )
176 mRenderer->setTolerance( d );
181void QgsPointClusterRendererWidget::mDistanceUnitWidget_changed()
185 mRenderer->setToleranceUnit( mDistanceUnitWidget->unit() );
186 mRenderer->setToleranceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
191void QgsPointClusterRendererWidget::blockAllSignals(
bool block )
193 mRendererComboBox->blockSignals( block );
194 mCenterSymbolToolButton->blockSignals( block );
195 mDistanceSpinBox->blockSignals( block );
196 mDistanceUnitWidget->blockSignals( block );
211 const auto constScopes = scopes;
219void QgsPointClusterRendererWidget::centerSymbolChanged()
221 mRenderer->setClusterSymbol( mCenterSymbolToolButton->clonedSymbol<
QgsMarkerSymbol >() );
225void QgsPointClusterRendererWidget::updateRendererFromWidget()
235void QgsPointClusterRendererWidget::setupBlankUi(
const QString &layerName )
237 QGridLayout *layout =
new QGridLayout(
this );
238 QLabel *label =
new QLabel( tr(
"The point cluster renderer only applies to (single) point layers. \n'%1' is not a (single) point layer and cannot be displayed by the point cluster renderer." ).arg( layerName ),
this );
239 layout->addWidget( label );
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
Abstract base class for all 2D vector feature renderers.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
A marker symbol type, for rendering Point and MultiPoint geometries.
static QgsPointClusterRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
Creates a QgsPointClusterRenderer from an existing renderer.
QStringList renderersList(QgsRendererAbstractMetadata::LayerTypes layerTypes=QgsRendererAbstractMetadata::All) const
Returns a list of available renderers.
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
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.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
void setAdditionalExpressionContextScopes(const QList< QgsExpressionContextScope > &scopes)
Sets a list of additional expression context scopes to show as available within the layer.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE Qgis::WkbType wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Single variable definition for use within a QgsExpressionContextScope.