46 setupBlankUi( layer->
name() );
50 connect( mRendererComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged );
51 connect( mDistanceSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsPointClusterRendererWidget::mDistanceSpinBox_valueChanged );
53 connect( mRendererSettingsButton, &QPushButton::clicked,
this, &QgsPointClusterRendererWidget::mRendererSettingsButton_clicked );
54 this->layout()->setContentsMargins( 0, 0, 0, 0 );
67 mRenderer = std::make_unique< QgsPointClusterRenderer >();
72 blockAllSignals(
true );
76 QStringList::const_iterator it = rendererList.constBegin();
77 for ( ; it != rendererList.constEnd(); ++it )
79 if ( *it != QLatin1String(
"pointDisplacement" ) && *it != QLatin1String(
"pointCluster" ) && *it != QLatin1String(
"heatmapRenderer" ) )
86 mDistanceSpinBox->setValue( mRenderer->tolerance() );
87 mDistanceUnitWidget->setUnit( mRenderer->toleranceUnit() );
88 mDistanceUnitWidget->setMapUnitScale( mRenderer->toleranceMapUnitScale() );
89 mCenterSymbolToolButton->setSymbol( mRenderer->clusterSymbol()->clone() );
91 blockAllSignals(
false );
94 if ( mRenderer->embeddedRenderer() )
96 const QString rendererName = mRenderer->embeddedRenderer()->type();
97 const int rendererIndex = mRendererComboBox->findData( rendererName );
98 if ( rendererIndex != -1 )
100 mRendererComboBox->setCurrentIndex( rendererIndex );
101 mRendererComboBox_currentIndexChanged( rendererIndex );
105 connect( mCenterSymbolToolButton, &
QgsSymbolButton::changed,
this, &QgsPointClusterRendererWidget::centerSymbolChanged );
106 mCenterSymbolToolButton->setDialogTitle( tr(
"Cluster symbol" ) );
107 mCenterSymbolToolButton->setLayer(
mLayer );
108 mCenterSymbolToolButton->registerExpressionContextGenerator(
this );
115 return mRenderer.get();
121 if ( mDistanceUnitWidget )
123 if ( mCenterSymbolToolButton )
130void QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged(
int index )
132 const QString rendererId = mRendererComboBox->itemData( index ).toString();
137 const std::unique_ptr< QgsFeatureRenderer > oldRenderer( mRenderer->embeddedRenderer()->clone() );
139 mRenderer->setEmbeddedRenderer( tempRenderWidget->
renderer()->
clone() );
140 delete tempRenderWidget;
145void QgsPointClusterRendererWidget::mRendererSettingsButton_clicked()
171void QgsPointClusterRendererWidget::mDistanceSpinBox_valueChanged(
double d )
175 mRenderer->setTolerance( d );
180void QgsPointClusterRendererWidget::mDistanceUnitWidget_changed()
184 mRenderer->setToleranceUnit( mDistanceUnitWidget->unit() );
185 mRenderer->setToleranceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
190void QgsPointClusterRendererWidget::blockAllSignals(
bool block )
192 mRendererComboBox->blockSignals( block );
193 mCenterSymbolToolButton->blockSignals( block );
194 mDistanceSpinBox->blockSignals( block );
195 mDistanceUnitWidget->blockSignals( block );
210 const auto constScopes = scopes;
218void QgsPointClusterRendererWidget::centerSymbolChanged()
220 mRenderer->setClusterSymbol( mCenterSymbolToolButton->clonedSymbol<
QgsMarkerSymbol >() );
224void QgsPointClusterRendererWidget::updateRendererFromWidget()
234void QgsPointClusterRendererWidget::setupBlankUi(
const QString &layerName )
236 QGridLayout *layout =
new QGridLayout(
this );
237 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 );
238 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.