35 , mRenderer( nullptr )
36 , mEmbeddedRendererWidget( nullptr )
48 setupBlankUi( layer->
name() );
64 blockAllSignals(
true );
74 mLabelFieldComboBox->addItem( f.
name() );
76 mLabelFieldComboBox->addItem(
tr(
"None" ) );
79 if ( !currentLabelAttribute.
isEmpty() )
81 mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( currentLabelAttribute ) );
85 mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText(
tr(
"None" ) ) );
92 for ( ; it != rendererList.
constEnd(); ++it )
94 if ( *it !=
"pointDisplacement" )
101 mCircleColorButton->setColorDialogTitle(
tr(
"Select color" ) );
102 mCircleColorButton->setContext(
"symbology" );
103 mCircleColorButton->setAllowAlpha(
true );
104 mCircleColorButton->setShowNoColor(
true );
105 mCircleColorButton->setNoColorString(
tr(
"No outline" ) );
106 mLabelColorButton->setContext(
"symbology" );
107 mLabelColorButton->setColorDialogTitle(
tr(
"Select color" ) );
108 mLabelColorButton->setAllowAlpha(
true );
110 mCircleWidthSpinBox->setValue( mRenderer->
circleWidth() );
111 mCircleColorButton->setColor( mRenderer->
circleColor() );
112 mLabelColorButton->setColor( mRenderer->
labelColor() );
113 mCircleModificationSpinBox->setClearValue( 0.0 );
115 mDistanceSpinBox->setValue( mRenderer->
tolerance() );
119 mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( mRenderer->
placement() ) );
123 mMaxScaleDenominatorEdit->setValidator(
new QDoubleValidator( mMaxScaleDenominatorEdit ) );
126 mScaleDependentLabelsCheckBox->setCheckState( Qt::Checked );
130 mScaleDependentLabelsCheckBox->setCheckState( Qt::Unchecked );
131 mMaxScaleDenominatorEdit->setEnabled(
false );
135 blockAllSignals(
false );
141 int rendererIndex = mRendererComboBox->findData( rendererName );
142 if ( rendererIndex != -1 )
144 mRendererComboBox->setCurrentIndex( rendererIndex );
145 on_mRendererComboBox_currentIndexChanged( rendererIndex );
155 delete mEmbeddedRendererWidget;
160 if ( mRenderer && mEmbeddedRendererWidget )
163 if ( embeddedRenderer )
174 if ( mDistanceUnitWidget )
175 mDistanceUnitWidget->setMapCanvas( canvas );
176 if ( mEmbeddedRendererWidget )
180 void QgsPointDisplacementRendererWidget::on_mLabelFieldComboBox_currentIndexChanged(
const QString& text )
184 if ( text ==
tr(
"None" ) )
196 void QgsPointDisplacementRendererWidget::on_mRendererComboBox_currentIndexChanged(
int index )
198 QString rendererId = mRendererComboBox->itemData( index ).toString();
202 delete mEmbeddedRendererWidget;
209 void QgsPointDisplacementRendererWidget::on_mPlacementComboBox_currentIndexChanged(
int index )
218 void QgsPointDisplacementRendererWidget::on_mRendererSettingsButton_clicked()
220 if ( mEmbeddedRendererWidget )
232 buttonBox->
addButton( QDialogButtonBox::Ok );
234 layout->
addWidget( mEmbeddedRendererWidget, 0, 0 );
237 mEmbeddedRendererWidget->
setParent(
nullptr );
243 void QgsPointDisplacementRendererWidget::on_mLabelFontButton_clicked()
259 void QgsPointDisplacementRendererWidget::on_mCircleWidthSpinBox_valueChanged(
double d )
268 void QgsPointDisplacementRendererWidget::on_mCircleColorButton_colorChanged(
const QColor& newColor )
279 void QgsPointDisplacementRendererWidget::on_mLabelColorButton_colorChanged(
const QColor& newColor )
290 void QgsPointDisplacementRendererWidget::on_mCircleModificationSpinBox_valueChanged(
double d )
301 void QgsPointDisplacementRendererWidget::on_mDistanceSpinBox_valueChanged(
double d )
310 void QgsPointDisplacementRendererWidget::on_mDistanceUnitWidget_changed()
320 void QgsPointDisplacementRendererWidget::on_mScaleDependentLabelsCheckBox_stateChanged(
int state )
322 if ( state == Qt::Unchecked )
324 mMaxScaleDenominatorEdit->setText(
"-1" );
325 mMaxScaleDenominatorEdit->setEnabled(
false );
329 mMaxScaleDenominatorEdit->setEnabled(
true );
333 void QgsPointDisplacementRendererWidget::on_mMaxScaleDenominatorEdit_textChanged(
const QString & text )
341 double scaleDenominator = text.
toDouble( &ok );
349 void QgsPointDisplacementRendererWidget::blockAllSignals(
bool block )
351 mLabelFieldComboBox->blockSignals( block );
352 mLabelFontButton->blockSignals( block );
353 mCircleWidthSpinBox->blockSignals( block );
354 mCircleColorButton->blockSignals( block );
355 mRendererComboBox->blockSignals( block );
356 mLabelColorButton->blockSignals( block );
357 mCircleModificationSpinBox->blockSignals( block );
358 mScaleDependentLabelsCheckBox->blockSignals( block );
359 mMaxScaleDenominatorEdit->blockSignals( block );
360 mCenterSymbolPushButton->blockSignals( block );
361 mDistanceSpinBox->blockSignals( block );
362 mDistanceUnitWidget->blockSignals( block );
363 mPlacementComboBox->blockSignals( block );
366 void QgsPointDisplacementRendererWidget::on_mCenterSymbolPushButton_clicked()
375 if ( dlg.
exec() == QDialog::Rejected )
385 void QgsPointDisplacementRendererWidget::updateCenterIcon()
393 mCenterSymbolPushButton->setIcon( icon );
396 void QgsPointDisplacementRendererWidget::setupBlankUi(
const QString& layerName )
398 QLabel* label =
new QLabel(
tr(
"The point displacement renderer only applies to (single) point layers. \n'%1' is not a point layer and cannot be displayed by the point displacement renderer" ).arg( layerName ),
this );
QColor labelColor() const
static QgsRendererV2Registry * instance()
Returns a pointer to the QgsRendererV2Registry singleton.
Placement
Placement methods for dispersing points.
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
void setContentsMargins(int left, int top, int right, int bottom)
const QgsMapUnitScale & toleranceMapUnitScale() const
Returns the map unit scale object for the distance tolerance.
QgsSymbolV2::OutputUnit toleranceUnit() const
Returns the units for the tolerance distance.
void setLabelAttributeName(const QString &name)
QFont getFont(bool &ok, const QFont &initial, const QString &title)
Show font selection dialog.
void setLabelFont(const QFont &f)
void setCenterSymbol(QgsMarkerSymbolV2 *symbol)
Sets the center symbol (takes ownership)
The output shall be in pixels.
void setMaxLabelScaleDenominator(double d)
double circleRadiusAddition() const
static QgsPointDisplacementRenderer * convertFromRenderer(const QgsFeatureRendererV2 *renderer)
creates a QgsPointDisplacementRenderer from an existing renderer.
double tolerance() const
Returns the tolerance distance for grouping points.
double toDouble(bool *ok) const
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
QgsRendererV2AbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
void setToleranceUnit(QgsSymbolV2::OutputUnit unit)
Sets the units for the tolerance distance.
QgsFields fields() const
Returns the list of fields of this layer.
virtual QgsFeatureRendererV2 * clone() const =0
The output shall be in millimeters.
QString number(int n, int base)
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
static QgsStyleV2 * defaultStyle()
return default application-wide style
The output shall be in map unitx.
void setLabelColor(const QColor &c)
QColor circleColor() const
void setPlacement(Placement placement)
Sets the placement method used for dispersing the points.
QString labelAttributeName() const
Encapsulate a field in an attribute table or data source.
void setCircleRadiusAddition(double d)
double maxLabelScaleDenominator() const
A renderer that automatically displaces points with the same position.
void setEmbeddedRenderer(QgsFeatureRendererV2 *r) override
Sets an embedded renderer (subrenderer) for this feature renderer.
void setCircleWidth(double w)
void setCircleColor(const QColor &c)
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
QString name
Read property of QString layerName.
void setToleranceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the distance tolerance.
QStringList renderersList(QgsRendererV2AbstractMetadata::LayerTypes layerTypes=QgsRendererV2AbstractMetadata::All) const
Returns a list of available renderers.
Placement placement() const
Returns the placement method used for dispersing the points.
const_iterator constEnd() const
const_iterator constBegin() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsMarkerSymbolV2 * centerSymbol()
Returns the symbol for the center of a displacement group (but not ownership of the symbol) ...
Represents a vector layer which manages a vector based data sets.
const QgsFeatureRendererV2 * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
virtual QgsMarkerSymbolV2 * clone() const override
void setTolerance(double t)
Sets the tolerance distance for grouping points.
double circleWidth() const