49 setupBlankUi( layer->
name() );
53 connect( mRendererComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged );
54 connect( mDistanceSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsPointClusterRendererWidget::mDistanceSpinBox_valueChanged );
56 connect( mRendererSettingsButton, &QPushButton::clicked,
this, &QgsPointClusterRendererWidget::mRendererSettingsButton_clicked );
57 this->layout()->setContentsMargins( 0, 0, 0, 0 );
70 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 QString rendererName = mRenderer->embeddedRenderer()->type();
98 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 )
131 void QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged(
int index )
133 QString rendererId = mRendererComboBox->itemData( index ).toString();
138 std::unique_ptr< QgsFeatureRenderer > oldRenderer( mRenderer->embeddedRenderer()->clone() );
140 mRenderer->setEmbeddedRenderer( tempRenderWidget->
renderer()->
clone() );
141 delete tempRenderWidget;
146 void QgsPointClusterRendererWidget::mRendererSettingsButton_clicked()
172 void QgsPointClusterRendererWidget::mDistanceSpinBox_valueChanged(
double d )
176 mRenderer->setTolerance( d );
181 void QgsPointClusterRendererWidget::mDistanceUnitWidget_changed()
185 mRenderer->setToleranceUnit( mDistanceUnitWidget->unit() );
186 mRenderer->setToleranceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
191 void 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;
219 void QgsPointClusterRendererWidget::centerSymbolChanged()
221 mRenderer->setClusterSymbol( mCenterSymbolToolButton->clonedSymbol<
QgsMarkerSymbol >() );
225 void QgsPointClusterRendererWidget::updateRendererFromWidget()
235 void 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 );
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.
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.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
@ RenderPoints
Points (e.g., for font sizes)
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
Single variable definition for use within a QgsExpressionContextScope.