33 expContext << symbolScope;
43 expContext.setOriginalValueVariable( QVariant() );
53 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
54 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
58 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
61 symbolWidget->setMapCanvas( mContext.
mapCanvas() );
62 symbolWidget->setMessageBar( mContext.
messageBar() );
80 void QgsCalloutWidget::createAuxiliaryField()
101 if ( dlg.exec() == QDialog::Accepted )
112 property.setActive(
true );
121 void QgsCalloutWidget::updateDataDefinedProperty()
135 QgsSimpleLineCalloutWidget::QgsSimpleLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
142 mCalloutLineStyleButton->setDialogTitle( tr(
"Callout Symbol" ) );
143 mCalloutLineStyleButton->registerExpressionContextGenerator(
this );
145 mCalloutLineStyleButton->setLayer( vl );
154 connect( mMinCalloutLengthSpin, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::minimumLengthChanged );
157 connect( mOffsetFromAnchorSpin, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::offsetFromAnchorChanged );
159 connect( mOffsetFromLabelSpin, static_cast <
void ( QDoubleSpinBox::* )(
double ) > ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::offsetFromLabelChanged );
161 connect( mDrawToAllPartsCheck, &QCheckBox::toggled,
this, &QgsSimpleLineCalloutWidget::drawToAllPartsToggled );
168 connect( mAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
170 connect( mCalloutLineStyleButton, &
QgsSymbolButton::changed,
this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
178 mCallout.reset( dynamic_cast<QgsSimpleLineCallout *>( callout->
clone() ) );
182 mMinCalloutWidthUnitWidget->blockSignals(
true );
183 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
184 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
185 mMinCalloutWidthUnitWidget->blockSignals(
false );
187 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
189 mOffsetFromAnchorUnitWidget->blockSignals(
true );
190 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
191 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
192 mOffsetFromAnchorUnitWidget->blockSignals(
false );
193 mOffsetFromLabelUnitWidget->blockSignals(
true );
194 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
195 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
196 mOffsetFromLabelUnitWidget->blockSignals(
false );
197 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
198 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
200 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
202 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
204 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->
anchorPoint() ) ) );
216 mAnchorPointLbl->setEnabled( isPolygon );
217 mAnchorPointLbl->setVisible( isPolygon );
218 mAnchorPointComboBox->setEnabled( isPolygon );
219 mAnchorPointComboBox->setVisible( isPolygon );
220 mAnchorPointDDBtn->setEnabled( isPolygon );
221 mAnchorPointDDBtn->setVisible( isPolygon );
224 QgsCallout *QgsSimpleLineCalloutWidget::callout()
226 return mCallout.get();
229 void QgsSimpleLineCalloutWidget::minimumLengthChanged()
231 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
235 void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
237 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
238 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
242 void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
244 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
245 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
249 void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
251 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
255 void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
257 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
258 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
262 void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
264 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
268 void QgsSimpleLineCalloutWidget::lineSymbolChanged()
270 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<
QgsLineSymbol >() );
274 void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged(
int index )
276 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
280 void QgsSimpleLineCalloutWidget::drawToAllPartsToggled(
bool active )
282 mCallout->setDrawCalloutToAllParts( active );
291 QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
292 : QgsSimpleLineCalloutWidget( vl, parent )
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
Meters value as Map units.
Single variable definition for use within a QgsExpressionContextScope.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
Abstract base class for callout renderers.
Minimum length of callouts.
Distance to offset lines from anchor points.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
Property
Data definable properties.
virtual QgsCallout * clone() const =0
Duplicates a callout by creating a deep copy of the callout.
The surface's centroid is used as anchor for polygon geometries.
Feature's anchor point position.
The surface's pole of inaccessibility used as anchor for polygon geometries.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
A line symbol type, for rendering LineString and MultiLineString geometries.
A dialog to create a new auxiliary layer.
void setField(const QString &field)
Sets the field name the property references.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in callouts.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
Single scope for storing variables and functions for use within a QgsExpressionContext.
A store for object properties.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
Distance to offset lines from label area.
Definition for a property.
A point on the surface's outline closest to the label is used as anchor for polygon geometries...
Whether callout lines should be drawn to all feature parts.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the callout's property collection, used for data defined overrides.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Points (e.g., for font sizes)
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
AnchorPoint anchorPoint() const
Returns the feature's anchor point position.
Represents a vector layer which manages a vector based data sets.
A point guaranteed to be on the surface is used as anchor for polygon geometries. ...
QgsPropertyDefinition propertyDefinition() const
Returns the underlying property definition.
A dialog to create a new auxiliary field.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...