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 >();
75 blockAllSignals(
true );
79 QStringList::const_iterator it = rendererList.constBegin();
80 for ( ; it != rendererList.constEnd(); ++it )
82 if ( *it != QLatin1String(
"pointDisplacement" ) && *it != QLatin1String(
"pointCluster" ) && *it != QLatin1String(
"heatmapRenderer" ) )
89 mDistanceSpinBox->setValue( mRenderer->tolerance() );
90 mDistanceUnitWidget->setUnit( mRenderer->toleranceUnit() );
91 mDistanceUnitWidget->setMapUnitScale( mRenderer->toleranceMapUnitScale() );
92 mCenterSymbolToolButton->setSymbol( mRenderer->clusterSymbol()->clone() );
94 blockAllSignals(
false );
97 if ( mRenderer->embeddedRenderer() )
99 const QString rendererName = mRenderer->embeddedRenderer()->type();
100 const int rendererIndex = mRendererComboBox->findData( rendererName );
101 if ( rendererIndex != -1 )
103 mRendererComboBox->setCurrentIndex( rendererIndex );
104 mRendererComboBox_currentIndexChanged( rendererIndex );
108 connect( mCenterSymbolToolButton, &
QgsSymbolButton::changed,
this, &QgsPointClusterRendererWidget::centerSymbolChanged );
109 mCenterSymbolToolButton->setDialogTitle( tr(
"Cluster symbol" ) );
110 mCenterSymbolToolButton->setLayer(
mLayer );
111 mCenterSymbolToolButton->registerExpressionContextGenerator(
this );
118 return mRenderer.get();
124 if ( mDistanceUnitWidget )
126 if ( mCenterSymbolToolButton )
133 void QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged(
int index )
135 const QString rendererId = mRendererComboBox->itemData( index ).toString();
140 const std::unique_ptr< QgsFeatureRenderer > oldRenderer( mRenderer->embeddedRenderer()->clone() );
142 mRenderer->setEmbeddedRenderer( tempRenderWidget->
renderer()->
clone() );
143 delete tempRenderWidget;
148 void QgsPointClusterRendererWidget::mRendererSettingsButton_clicked()
174 void QgsPointClusterRendererWidget::mDistanceSpinBox_valueChanged(
double d )
178 mRenderer->setTolerance( d );
183 void QgsPointClusterRendererWidget::mDistanceUnitWidget_changed()
187 mRenderer->setToleranceUnit( mDistanceUnitWidget->unit() );
188 mRenderer->setToleranceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
193 void QgsPointClusterRendererWidget::blockAllSignals(
bool block )
195 mRendererComboBox->blockSignals( block );
196 mCenterSymbolToolButton->blockSignals( block );
197 mDistanceSpinBox->blockSignals( block );
198 mDistanceUnitWidget->blockSignals( block );
213 const auto constScopes = scopes;
221 void QgsPointClusterRendererWidget::centerSymbolChanged()
223 mRenderer->setClusterSymbol( mCenterSymbolToolButton->clonedSymbol<
QgsMarkerSymbol >() );
227 void QgsPointClusterRendererWidget::updateRendererFromWidget()
237 void QgsPointClusterRendererWidget::setupBlankUi(
const QString &layerName )
239 QGridLayout *layout =
new QGridLayout(
this );
240 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 );
241 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.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another 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.
@ RenderMetersInMapUnits
Meters value as Map 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.