QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgscalloutwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscalloutwidget.cpp
3 ---------------------
4 begin : July 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgscalloutwidget.h"
17#include "moc_qgscalloutwidget.cpp"
18#include "qgsvectorlayer.h"
21#include "qgscallout.h"
24#include "qgsauxiliarystorage.h"
25#include "qgslinesymbol.h"
26#include "qgsfillsymbol.h"
27#include "qgsmarkersymbol.h"
28
30{
31 if ( auto *lExpressionContext = mContext.expressionContext() )
32 return *lExpressionContext;
33
37 expContext << symbolScope;
38
39 // additional scopes
40 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
41 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
42 {
43 expContext.appendScope( new QgsExpressionContextScope( scope ) );
44 }
45
46 //TODO - show actual value
47 expContext.setOriginalValueVariable( QVariant() );
48
50
51 return expContext;
52}
53
55{
56 mContext = context;
57 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
58 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
59 {
60 unitWidget->setMapCanvas( mContext.mapCanvas() );
61 }
62 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
63 for ( QgsSymbolButton *symbolWidget : symbolButtonWidgets )
64 {
65 symbolWidget->setMapCanvas( mContext.mapCanvas() );
66 symbolWidget->setMessageBar( mContext.messageBar() );
67 }
68}
69
71{
72 return mContext;
73}
74
76{
77 button->init( static_cast< int >( key ), callout()->dataDefinedProperties(), QgsCallout::propertyDefinitions(), qobject_cast< QgsVectorLayer * >( mLayer ), true );
78 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsCalloutWidget::updateDataDefinedProperty );
79 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsCalloutWidget::createAuxiliaryField );
80
82}
83
84void QgsCalloutWidget::createAuxiliaryField()
85{
86 // try to create an auxiliary layer if not yet created
87 QgsVectorLayer *vectorLayer = qobject_cast< QgsVectorLayer * >( mLayer );
88 if ( !vectorLayer )
89 return;
90
92 {
94 dlg.exec();
95 }
96
97 // return if still not exists
99 return;
100
101 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
102 const QgsCallout::Property key = static_cast< QgsCallout::Property >( button->propertyKey() );
103 const QgsPropertyDefinition def = QgsCallout::propertyDefinitions()[static_cast< int >( key )];
104
105 // create property in auxiliary storage if necessary
106 if ( !vectorLayer->auxiliaryLayer()->exists( def ) )
107 {
109 }
110
111 // update property with join field name from auxiliary storage
112 QgsProperty property = button->toProperty();
113 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
114 property.setActive( true );
115 button->updateFieldLists();
116 button->setToProperty( property );
117
119
120 emit changed();
121}
122
123void QgsCalloutWidget::updateDataDefinedProperty()
124{
125 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
126 const QgsCallout::Property key = static_cast< QgsCallout::Property >( button->propertyKey() );
128 emit changed();
129}
130
132
133//
134// QgsSimpleLineCalloutWidget
135//
136
137QgsSimpleLineCalloutWidget::QgsSimpleLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
138 : QgsCalloutWidget( parent, vl )
139{
140 setupUi( this );
141
142 // Callout options - to move to custom widgets when multiple callout styles exist
143 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
144 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
145 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
146
147 mCalloutLineStyleButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
154
155 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged );
156 connect( mMinCalloutLengthSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::minimumLengthChanged );
157
158 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
159 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromAnchorChanged );
160 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
161 connect( mOffsetFromLabelSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromLabelChanged );
162
163 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsSimpleLineCalloutWidget::drawToAllPartsToggled );
164
165 // Anchor point options
166 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
167 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
168 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
169 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
170 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
171
172 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast< int >( QgsCallout::LabelPointOnExterior ) );
173 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::LabelCentroid ) );
174 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast< int >( QgsCallout::LabelTopLeft ) );
175 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast< int >( QgsCallout::LabelTopMiddle ) );
176 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast< int >( QgsCallout::LabelTopRight ) );
177 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast< int >( QgsCallout::LabelMiddleLeft ) );
178 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast< int >( QgsCallout::LabelMiddleRight ) );
179 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast< int >( QgsCallout::LabelBottomLeft ) );
180 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast< int >( QgsCallout::LabelBottomMiddle ) );
181 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast< int >( QgsCallout::LabelBottomRight ) );
182 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
183
184 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
185
186 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
187
188 mPlacementDDGroupBox->setVisible( qobject_cast< QgsVectorLayer * >( vl ) );
189}
190
191void QgsSimpleLineCalloutWidget::setCallout( const QgsCallout *callout )
192{
193 if ( !callout )
194 return;
195
196 mCallout.reset( dynamic_cast<QgsSimpleLineCallout *>( callout->clone() ) );
197 if ( !mCallout )
198 return;
199
200 mMinCalloutWidthUnitWidget->blockSignals( true );
201 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
202 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
203 mMinCalloutWidthUnitWidget->blockSignals( false );
204
205 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
206
207 mOffsetFromAnchorUnitWidget->blockSignals( true );
208 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
209 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
210 mOffsetFromAnchorUnitWidget->blockSignals( false );
211 mOffsetFromLabelUnitWidget->blockSignals( true );
212 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
213 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
214 mOffsetFromLabelUnitWidget->blockSignals( false );
215 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
216 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
217
218 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
219
220 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
221
222 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
223 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast< int >( callout->labelAnchorPoint() ) ) );
224
225 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
226
227 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
228 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
229 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
230 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
231 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
232 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
233 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
234
235 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
236 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
237 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
238 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
239}
240
241void QgsSimpleLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
242{
243 const bool isPolygon = type == Qgis::GeometryType::Polygon;
244 mAnchorPointLbl->setEnabled( isPolygon );
245 mAnchorPointLbl->setVisible( isPolygon );
246 mAnchorPointComboBox->setEnabled( isPolygon );
247 mAnchorPointComboBox->setVisible( isPolygon );
248 mAnchorPointDDBtn->setEnabled( isPolygon );
249 mAnchorPointDDBtn->setVisible( isPolygon );
250}
251
252QgsCallout *QgsSimpleLineCalloutWidget::callout()
253{
254 return mCallout.get();
255}
256
257void QgsSimpleLineCalloutWidget::minimumLengthChanged()
258{
259 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
260 emit changed();
261}
262
263void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
264{
265 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
266 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
267 emit changed();
268}
269
270void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
271{
272 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
273 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
274 emit changed();
275}
276
277void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
278{
279 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
280 emit changed();
281}
282
283void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
284{
285 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
286 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
287 emit changed();
288}
289
290void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
291{
292 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
293 emit changed();
294}
295
296void QgsSimpleLineCalloutWidget::lineSymbolChanged()
297{
298 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol< QgsLineSymbol >() );
299 emit changed();
300}
301
302void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
303{
304 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
305 emit changed();
306}
307
308void QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
309{
310 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
311 emit changed();
312}
313
314void QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
315{
316 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
317 emit changed();
318}
319
320void QgsSimpleLineCalloutWidget::drawToAllPartsToggled( bool active )
321{
322 mCallout->setDrawCalloutToAllParts( active );
323 emit changed();
324}
325
326
327//
328// QgsManhattanLineCalloutWidget
329//
330
331QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
332 : QgsSimpleLineCalloutWidget( vl, parent )
333{
334
335}
336
337
338//
339// QgsCurvedLineCalloutWidget
340//
341
342QgsCurvedLineCalloutWidget::QgsCurvedLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
343 : QgsCalloutWidget( parent, vl )
344{
345 setupUi( this );
346
347 // Callout options - to move to custom widgets when multiple callout styles exist
348 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
349 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
350 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
351
352 mCalloutLineStyleButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
359
360 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged );
361 connect( mMinCalloutLengthSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::minimumLengthChanged );
362
363 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
364 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromAnchorChanged );
365 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
366 connect( mOffsetFromLabelSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromLabelChanged );
367
368 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsCurvedLineCalloutWidget::drawToAllPartsToggled );
369
370 mOrientationComboBox->addItem( tr( "Automatic" ), static_cast< int >( QgsCurvedLineCallout::Automatic ) );
371 mOrientationComboBox->addItem( tr( "Clockwise" ), static_cast< int >( QgsCurvedLineCallout::Clockwise ) );
372 mOrientationComboBox->addItem( tr( "Counter Clockwise" ), static_cast< int >( QgsCurvedLineCallout::CounterClockwise ) );
373 connect( mOrientationComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]( int index )
374 {
375 mCallout->setOrientation( static_cast<QgsCurvedLineCallout::Orientation>( mOrientationComboBox->itemData( index ).toInt() ) );
376 emit changed();
377 } );
378
379 // Anchor point options
380 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
381 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
382 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
383 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
384 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
385
386 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast< int >( QgsCallout::LabelPointOnExterior ) );
387 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::LabelCentroid ) );
388 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast< int >( QgsCallout::LabelTopLeft ) );
389 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast< int >( QgsCallout::LabelTopMiddle ) );
390 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast< int >( QgsCallout::LabelTopRight ) );
391 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast< int >( QgsCallout::LabelMiddleLeft ) );
392 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast< int >( QgsCallout::LabelMiddleRight ) );
393 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast< int >( QgsCallout::LabelBottomLeft ) );
394 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast< int >( QgsCallout::LabelBottomMiddle ) );
395 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast< int >( QgsCallout::LabelBottomRight ) );
396 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
397
398 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsCurvedLineCalloutWidget::lineSymbolChanged );
399
400 connect( mCurvatureSlider, &QSlider::valueChanged, this, [ = ]( int value ) { mCurvatureSpinBox->setValue( value / 10.0 ); } );
401 connect( mCurvatureSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) { whileBlocking( mCurvatureSlider )->setValue( value * 10 ); } );
402 connect( mCurvatureSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value )
403 {
404 mCallout->setCurvature( value / 100.0 );
405 emit changed();
406 } );
407
408 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
409
410 mPlacementDDGroupBox->setVisible( qobject_cast< QgsVectorLayer * >( vl ) );
411}
412
413void QgsCurvedLineCalloutWidget::setCallout( const QgsCallout *callout )
414{
415 if ( !callout )
416 return;
417
418 mCallout.reset( dynamic_cast<QgsCurvedLineCallout *>( callout->clone() ) );
419 if ( !mCallout )
420 return;
421
422 mMinCalloutWidthUnitWidget->blockSignals( true );
423 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
424 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
425 mMinCalloutWidthUnitWidget->blockSignals( false );
426
427 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
428
429 mOffsetFromAnchorUnitWidget->blockSignals( true );
430 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
431 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
432 mOffsetFromAnchorUnitWidget->blockSignals( false );
433 mOffsetFromLabelUnitWidget->blockSignals( true );
434 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
435 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
436 mOffsetFromLabelUnitWidget->blockSignals( false );
437 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
438 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
439
440 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
441
442 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
443
444 whileBlocking( mOrientationComboBox )->setCurrentIndex( mOrientationComboBox->findData( static_cast< int >( mCallout->orientation() ) ) );
445
446 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
447 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast< int >( callout->labelAnchorPoint() ) ) );
448
449 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
450
451 whileBlocking( mCurvatureSpinBox )->setValue( mCallout->curvature() * 100.0 );
452 whileBlocking( mCurvatureSlider )->setValue( mCallout->curvature() * 1000.0 );
453
454 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
455 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
456 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
457 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
458 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
459 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
460 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
461 registerDataDefinedButton( mCalloutCurvatureDDBtn, QgsCallout::Property::Curvature );
462 registerDataDefinedButton( mCalloutOrientationDDBtn, QgsCallout::Property::Orientation );
463
464 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
465 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
466 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
467 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
468}
469
470void QgsCurvedLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
471{
472 const bool isPolygon = type == Qgis::GeometryType::Polygon;
473 mAnchorPointLbl->setEnabled( isPolygon );
474 mAnchorPointLbl->setVisible( isPolygon );
475 mAnchorPointComboBox->setEnabled( isPolygon );
476 mAnchorPointComboBox->setVisible( isPolygon );
477 mAnchorPointDDBtn->setEnabled( isPolygon );
478 mAnchorPointDDBtn->setVisible( isPolygon );
479}
480
481QgsCallout *QgsCurvedLineCalloutWidget::callout()
482{
483 return mCallout.get();
484}
485
486void QgsCurvedLineCalloutWidget::minimumLengthChanged()
487{
488 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
489 emit changed();
490}
491
492void QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged()
493{
494 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
495 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
496 emit changed();
497}
498
499void QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
500{
501 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
502 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
503 emit changed();
504}
505
506void QgsCurvedLineCalloutWidget::offsetFromAnchorChanged()
507{
508 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
509 emit changed();
510}
511
512void QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
513{
514 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
515 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
516 emit changed();
517}
518
519void QgsCurvedLineCalloutWidget::offsetFromLabelChanged()
520{
521 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
522 emit changed();
523}
524
525void QgsCurvedLineCalloutWidget::lineSymbolChanged()
526{
527 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol< QgsLineSymbol >() );
528 emit changed();
529}
530
531void QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
532{
533 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
534 emit changed();
535}
536
537void QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
538{
539 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
540 emit changed();
541}
542
543void QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
544{
545 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
546 emit changed();
547}
548
549void QgsCurvedLineCalloutWidget::drawToAllPartsToggled( bool active )
550{
551 mCallout->setDrawCalloutToAllParts( active );
552 emit changed();
553}
554
555
556//
557// QgsBalloonCalloutWidget
558//
559
560QgsBalloonCalloutWidget::QgsBalloonCalloutWidget( QgsMapLayer *vl, QWidget *parent )
561 : QgsCalloutWidget( parent, vl )
562{
563 setupUi( this );
564
565 // Callout options - to move to custom widgets when multiple callout styles exist
566 mCalloutFillStyleButton->setSymbolType( Qgis::SymbolType::Fill );
567 mCalloutFillStyleButton->setDialogTitle( tr( "Balloon Symbol" ) );
568 mCalloutFillStyleButton->registerExpressionContextGenerator( this );
569
570 mMarkerSymbolButton->setSymbolType( Qgis::SymbolType::Marker );
571 mMarkerSymbolButton->setDialogTitle( tr( "Marker Symbol" ) );
572 mMarkerSymbolButton->registerExpressionContextGenerator( this );
573 mMarkerSymbolButton->setShowNull( true );
574 mMarkerSymbolButton->setToNull();
575
576 mCalloutFillStyleButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
577 mMarkerSymbolButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
586
587 mSpinBottomMargin->setClearValue( 0 );
588 mSpinTopMargin->setClearValue( 0 );
589 mSpinRightMargin->setClearValue( 0 );
590 mSpinLeftMargin->setClearValue( 0 );
591 mWedgeWidthSpin->setClearValue( 2.64 );
592 mCornerRadiusSpin->setClearValue( 0.0 );
593
594 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged );
595 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsBalloonCalloutWidget::offsetFromAnchorChanged );
596
597 // Anchor point options
598 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
599 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
600 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
601 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
602 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
603
604 connect( mCalloutFillStyleButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::fillSymbolChanged );
605 connect( mMarkerSymbolButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::markerSymbolChanged );
606
607 connect( mSpinBottomMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
608 {
609 QgsMargins margins = mCallout->margins();
610 margins.setBottom( value );
611 mCallout->setMargins( margins );
612 emit changed();
613 } );
614 connect( mSpinTopMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
615 {
616 QgsMargins margins = mCallout->margins();
617 margins.setTop( value );
618 mCallout->setMargins( margins );
619 emit changed();
620 } );
621 connect( mSpinLeftMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
622 {
623 QgsMargins margins = mCallout->margins();
624 margins.setLeft( value );
625 mCallout->setMargins( margins );
626 emit changed();
627 } );
628 connect( mSpinRightMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
629 {
630 QgsMargins margins = mCallout->margins();
631 margins.setRight( value );
632 mCallout->setMargins( margins );
633 emit changed();
634 } );
635 connect( mMarginUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
636 {
637 mCallout->setMarginsUnit( mMarginUnitWidget->unit() );
638 emit changed();
639 } );
640
641 connect( mWedgeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
642 {
643 mCallout->setWedgeWidthUnit( mWedgeWidthUnitWidget->unit() );
644 mCallout->setWedgeWidthMapUnitScale( mWedgeWidthUnitWidget->getMapUnitScale() );
645 emit changed();
646 } );
647 connect( mWedgeWidthSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
648 {
649 mCallout->setWedgeWidth( value );
650 emit changed();
651 } );
652
653 connect( mCornerRadiusUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
654 {
655 mCallout->setCornerRadiusUnit( mCornerRadiusUnitWidget->unit() );
656 mCallout->setCornerRadiusMapUnitScale( mCornerRadiusUnitWidget->getMapUnitScale() );
657 emit changed();
658 } );
659 connect( mCornerRadiusSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
660 {
661 mCallout->setCornerRadius( value );
662 emit changed();
663 } );
664
665 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
666
667 mPlacementDDGroupBox->setVisible( qobject_cast< QgsVectorLayer * >( vl ) );
668}
669
670void QgsBalloonCalloutWidget::setCallout( const QgsCallout *callout )
671{
672 if ( !callout )
673 return;
674
675 mCallout.reset( dynamic_cast<QgsBalloonCallout *>( callout->clone() ) );
676 if ( !mCallout )
677 return;
678
679 mOffsetFromAnchorUnitWidget->blockSignals( true );
680 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
681 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
682 mOffsetFromAnchorUnitWidget->blockSignals( false );
683 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
684
685 whileBlocking( mSpinBottomMargin )->setValue( mCallout->margins().bottom() );
686 whileBlocking( mSpinTopMargin )->setValue( mCallout->margins().top() );
687 whileBlocking( mSpinLeftMargin )->setValue( mCallout->margins().left() );
688 whileBlocking( mSpinRightMargin )->setValue( mCallout->margins().right() );
689 whileBlocking( mMarginUnitWidget )->setUnit( mCallout->marginsUnit() );
690
691 mWedgeWidthUnitWidget->blockSignals( true );
692 mWedgeWidthUnitWidget->setUnit( mCallout->wedgeWidthUnit() );
693 mWedgeWidthUnitWidget->setMapUnitScale( mCallout->wedgeWidthMapUnitScale() );
694 mWedgeWidthUnitWidget->blockSignals( false );
695 whileBlocking( mWedgeWidthSpin )->setValue( mCallout->wedgeWidth() );
696
697 mCornerRadiusUnitWidget->blockSignals( true );
698 mCornerRadiusUnitWidget->setUnit( mCallout->cornerRadiusUnit() );
699 mCornerRadiusUnitWidget->setMapUnitScale( mCallout->cornerRadiusMapUnitScale() );
700 mCornerRadiusUnitWidget->blockSignals( false );
701 whileBlocking( mCornerRadiusSpin )->setValue( mCallout->cornerRadius() );
702
703 whileBlocking( mCalloutFillStyleButton )->setSymbol( mCallout->fillSymbol()->clone() );
704 if ( QgsMarkerSymbol *marker = mCallout->markerSymbol() )
705 whileBlocking( mMarkerSymbolButton )->setSymbol( marker->clone() );
706 else
707 whileBlocking( mMarkerSymbolButton )->setToNull();
708
709 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
710
711 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
712
713 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
714 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
715 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
716
717 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
718 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
719 registerDataDefinedButton( mMarginsDDBtn, QgsCallout::Property::Margins );
720 registerDataDefinedButton( mWedgeWidthDDBtn, QgsCallout::Property::WedgeWidth );
721 registerDataDefinedButton( mCornerRadiusDDBtn, QgsCallout::Property::CornerRadius );
722}
723
724void QgsBalloonCalloutWidget::setGeometryType( Qgis::GeometryType type )
725{
726 const bool isPolygon = type == Qgis::GeometryType::Polygon;
727 mAnchorPointLbl->setEnabled( isPolygon );
728 mAnchorPointLbl->setVisible( isPolygon );
729 mAnchorPointComboBox->setEnabled( isPolygon );
730 mAnchorPointComboBox->setVisible( isPolygon );
731 mAnchorPointDDBtn->setEnabled( isPolygon );
732 mAnchorPointDDBtn->setVisible( isPolygon );
733}
734
735QgsCallout *QgsBalloonCalloutWidget::callout()
736{
737 return mCallout.get();
738}
739
740void QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged()
741{
742 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
743 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
744 emit changed();
745}
746
747void QgsBalloonCalloutWidget::offsetFromAnchorChanged()
748{
749 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
750 emit changed();
751}
752
753void QgsBalloonCalloutWidget::fillSymbolChanged()
754{
755 mCallout->setFillSymbol( mCalloutFillStyleButton->clonedSymbol< QgsFillSymbol >() );
756 emit changed();
757}
758
759void QgsBalloonCalloutWidget::markerSymbolChanged()
760{
761 mCallout->setMarkerSymbol( mMarkerSymbolButton->isNull() ? nullptr : mMarkerSymbolButton->clonedSymbol< QgsMarkerSymbol >() );
762 emit changed();
763}
764
765void QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
766{
767 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
768 emit changed();
769}
770
771void QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
772{
773 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
774 emit changed();
775}
776
778
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
@ Polygon
Polygons.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MapUnits
Map units.
@ MetersInMapUnits
Meters value as Map units.
@ Marker
Marker symbol.
@ Line
Line symbol.
@ Fill
Fill symbol.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
A cartoon talking bubble callout style.
Definition qgscallout.h:880
Base class for widgets which allow control over the properties of callouts.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
virtual QgsCallout * callout()=0
Returns the callout defined by the current settings in the widget.
const QgsMapLayer * layer() const
Returns the vector layer associated with the widget.
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
Q_DECL_DEPRECATED const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsCallout::Property key)
Registers a data defined override button.
Abstract base class for callout renderers.
Definition qgscallout.h:54
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.
Definition qgscallout.h:334
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.
Definition qgscallout.h:364
LabelAnchorPoint labelAnchorPoint() const
Returns the label's anchor point position.
Definition qgscallout.h:397
AnchorPoint
Feature's anchor point position.
Definition qgscallout.h:115
@ PointOnExterior
A point on the surface's outline closest to the label is used as anchor for polygon geometries.
Definition qgscallout.h:117
@ Centroid
The surface's centroid is used as anchor for polygon geometries.
Definition qgscallout.h:119
@ PointOnSurface
A point guaranteed to be on the surface is used as anchor for polygon geometries.
Definition qgscallout.h:118
@ PoleOfInaccessibility
The surface's pole of inaccessibility used as anchor for polygon geometries.
Definition qgscallout.h:116
LabelAnchorPoint
Label's anchor point position.
Definition qgscallout.h:127
@ LabelPointOnExterior
The point on the label's boundary closest to the feature.
Definition qgscallout.h:128
@ LabelBottomLeft
Bottom left corner of the label's boundary.
Definition qgscallout.h:135
@ LabelBottomMiddle
Bottom middle of the label's boundary.
Definition qgscallout.h:136
@ LabelMiddleLeft
Middle left of the label's boundary.
Definition qgscallout.h:133
@ LabelBottomRight
Bottom right corner of the label's boundary.
Definition qgscallout.h:137
@ LabelMiddleRight
Middle right of the label's boundary.
Definition qgscallout.h:134
@ LabelTopMiddle
Top middle of the label's boundary.
Definition qgscallout.h:131
@ LabelTopLeft
Top left corner of the label's boundary.
Definition qgscallout.h:130
@ LabelCentroid
The labe's centroid.
Definition qgscallout.h:129
@ LabelTopRight
Top right corner of the label's boundary.
Definition qgscallout.h:132
Property
Data definable properties.
Definition qgscallout.h:86
@ MinimumCalloutLength
Minimum length of callouts.
@ LabelAnchorPointPosition
Label's anchor point position.
@ CornerRadius
Balloon callout corner radius.
@ OffsetFromAnchor
Distance to offset lines from anchor points.
@ OffsetFromLabel
Distance to offset lines from label area.
@ DestinationX
X-coordinate of callout destination (feature anchor)
@ DestinationY
Y-coordinate of callout destination (feature anchor)
@ WedgeWidth
Balloon callout wedge width.
@ AnchorPointPosition
Feature's anchor point position.
@ OriginX
X-coordinate of callout origin (label anchor)
@ OriginY
Y-coordinate of callout origin (label anchor)
@ Curvature
Curvature of curved line callouts.
@ BlendMode
Callout blend mode.
@ Orientation
Orientation of curved line callouts.
@ Margins
Margin from text.
@ DrawCalloutToAllParts
Whether callout lines should be drawn to all feature parts.
Draws curved lines as callouts.
Definition qgscallout.h:785
Orientation
Curve orientation.
Definition qgscallout.h:792
@ Clockwise
Curve lines in a clockwise direction.
Definition qgscallout.h:794
@ CounterClockwise
Curve lines in a counter-clockwise direction.
Definition qgscallout.h:795
@ Automatic
Automatically choose most cartographically pleasing orientation based on label and callout arrangemen...
Definition qgscallout.h:793
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
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 fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
Base class for all map layer types.
Definition qgsmaplayer.h:76
The QgsMargins class defines the four margins of a rectangle.
Definition qgsmargins.h:37
void setBottom(double bottom)
Sets the bottom margin to bottom.
Definition qgsmargins.h:113
void setLeft(double left)
Sets the left margin to left.
Definition qgsmargins.h:95
void setRight(double right)
Sets the right margin to right.
Definition qgsmargins.h:107
void setTop(double top)
Sets the top margin to top.
Definition qgsmargins.h:101
A marker symbol type, for rendering Point and MultiPoint geometries.
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.
Definition qgsproperty.h:45
A button for controlling property overrides which may apply to a widget.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
void updateFieldLists()
Updates list of fields.
void changed()
Emitted when property definition changes.
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout).
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
int propertyKey() const
Returns the property key linked to the button.
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
A store for object properties.
void setField(const QString &field)
Sets the field name the property references.
A simple direct line callout style.
Definition qgscallout.h:514
A button for creating and modifying QgsSymbol settings.
void changed()
Emitted when the symbol's settings are changed.
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.
A widget displaying a combobox allowing the user to choose between various display units,...
void changed()
Emitted when the selected unit is changed, or the definition of the map unit scale is changed.
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
Represents a vector layer which manages a vector based data sets.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:5821
Single variable definition for use within a QgsExpressionContextScope.