28 return *lExpressionContext;
33 expContext << symbolScope;
53 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
56 unitWidget->setMapCanvas( mContext.
mapCanvas() );
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 )
102 def = dlg.propertyDefinition();
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 );
180 connect( mLabelAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
182 connect( mCalloutLineStyleButton, &
QgsSymbolButton::changed,
this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
185 void QgsSimpleLineCalloutWidget::setCallout(
QgsCallout *callout )
194 mMinCalloutWidthUnitWidget->blockSignals(
true );
195 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
196 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
197 mMinCalloutWidthUnitWidget->blockSignals(
false );
199 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
201 mOffsetFromAnchorUnitWidget->blockSignals(
true );
202 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
203 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
204 mOffsetFromAnchorUnitWidget->blockSignals(
false );
205 mOffsetFromLabelUnitWidget->blockSignals(
true );
206 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
207 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
208 mOffsetFromLabelUnitWidget->blockSignals(
false );
209 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
210 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
212 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
214 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
216 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData(
static_cast< int >( callout->
anchorPoint() ) ) );
217 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData(
static_cast< int >( callout->
labelAnchorPoint() ) ) );
230 mAnchorPointLbl->setEnabled( isPolygon );
231 mAnchorPointLbl->setVisible( isPolygon );
232 mAnchorPointComboBox->setEnabled( isPolygon );
233 mAnchorPointComboBox->setVisible( isPolygon );
234 mAnchorPointDDBtn->setEnabled( isPolygon );
235 mAnchorPointDDBtn->setVisible( isPolygon );
238 QgsCallout *QgsSimpleLineCalloutWidget::callout()
240 return mCallout.get();
243 void QgsSimpleLineCalloutWidget::minimumLengthChanged()
245 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
249 void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
251 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
252 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
256 void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
258 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
259 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
263 void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
265 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
269 void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
271 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
272 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
276 void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
278 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
282 void QgsSimpleLineCalloutWidget::lineSymbolChanged()
284 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<
QgsLineSymbol >() );
288 void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged(
int index )
290 mCallout->setAnchorPoint(
static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
294 void QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged(
int index )
300 void QgsSimpleLineCalloutWidget::drawToAllPartsToggled(
bool active )
302 mCallout->setDrawCalloutToAllParts( active );
311 QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
312 : QgsSimpleLineCalloutWidget( vl, parent )
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
Abstract base class for callout renderers.
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in callouts.
AnchorPoint anchorPoint() const
Returns the feature's anchor point position.
LabelAnchorPoint labelAnchorPoint() const
Returns the label's anchor point position.
AnchorPoint
Feature's anchor point position.
@ PointOnExterior
A point on the surface's outline closest to the label is used as anchor for polygon geometries.
@ Centroid
The surface's centroid is used as anchor for polygon geometries.
@ PointOnSurface
A point guaranteed to be on the surface is used as anchor for polygon geometries.
@ PoleOfInaccessibility
The surface's pole of inaccessibility used as anchor for polygon geometries.
virtual QgsCallout * clone() const =0
Duplicates a callout by creating a deep copy of the callout.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the callout's property collection, used for data defined overrides.
LabelAnchorPoint
Label's anchor point position.
@ LabelPointOnExterior
The point on the label's boundary closest to the feature.
@ LabelBottomLeft
Bottom left corner of the label's boundary.
@ LabelBottomMiddle
Bottom middle of the label's boundary.
@ LabelMiddleLeft
Middle left of the label's boundary.
@ LabelBottomRight
Bottom right corner of the label's boundary.
@ LabelMiddleRight
Middle right of the label's boundary.
@ LabelTopMiddle
Top middle of the label's boundary.
@ LabelTopLeft
Top left corner of the label's boundary.
@ LabelCentroid
The labe's centroid.
@ LabelTopRight
Top right corner of the label's boundary.
Property
Data definable properties.
@ AnchorPointPosition
Feature's anchor point position.
@ LabelAnchorPointPosition
Label's anchor point position.
@ DrawCalloutToAllParts
Whether callout lines should be drawn to all feature parts.
@ OffsetFromAnchor
Distance to offset lines from anchor points.
@ OffsetFromLabel
Distance to offset lines from label area.
@ MinimumCalloutLength
Minimum length of callouts.
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.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
A line symbol type, for rendering LineString and MultiLineString geometries.
A dialog to create a new auxiliary field.
A dialog to create a new auxiliary layer.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
Definition for a property.
A store for object properties.
void setField(const QString &field)
Sets the field name the property references.
A simple direct line callout style.
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.
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.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Single variable definition for use within a QgsExpressionContextScope.