QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 ) );
151
152 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged );
153 connect( mMinCalloutLengthSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::minimumLengthChanged );
154
155 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
156 connect( mOffsetFromAnchorSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromAnchorChanged );
157 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
158 connect( mOffsetFromLabelSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromLabelChanged );
159
160 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsSimpleLineCalloutWidget::drawToAllPartsToggled );
161
162 // Anchor point options
163 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast<int>( QgsCallout::PoleOfInaccessibility ) );
164 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast<int>( QgsCallout::PointOnExterior ) );
165 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast<int>( QgsCallout::PointOnSurface ) );
166 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::Centroid ) );
167 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
168
169 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast<int>( QgsCallout::LabelPointOnExterior ) );
170 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::LabelCentroid ) );
171 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast<int>( QgsCallout::LabelTopLeft ) );
172 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast<int>( QgsCallout::LabelTopMiddle ) );
173 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast<int>( QgsCallout::LabelTopRight ) );
174 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast<int>( QgsCallout::LabelMiddleLeft ) );
175 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast<int>( QgsCallout::LabelMiddleRight ) );
176 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast<int>( QgsCallout::LabelBottomLeft ) );
177 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast<int>( QgsCallout::LabelBottomMiddle ) );
178 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast<int>( QgsCallout::LabelBottomRight ) );
179 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
180
181 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
182
183 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
184
185 mPlacementDDGroupBox->setVisible( qobject_cast<QgsVectorLayer *>( vl ) );
186}
187
188void QgsSimpleLineCalloutWidget::setCallout( const QgsCallout *callout )
189{
190 if ( !callout )
191 return;
192
193 mCallout.reset( dynamic_cast<QgsSimpleLineCallout *>( callout->clone() ) );
194 if ( !mCallout )
195 return;
196
197 mMinCalloutWidthUnitWidget->blockSignals( true );
198 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
199 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
200 mMinCalloutWidthUnitWidget->blockSignals( false );
201
202 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
203
204 mOffsetFromAnchorUnitWidget->blockSignals( true );
205 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
206 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
207 mOffsetFromAnchorUnitWidget->blockSignals( false );
208 mOffsetFromLabelUnitWidget->blockSignals( true );
209 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
210 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
211 mOffsetFromLabelUnitWidget->blockSignals( false );
212 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
213 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
214
215 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
216
217 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
218
219 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast<int>( callout->anchorPoint() ) ) );
220 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast<int>( callout->labelAnchorPoint() ) ) );
221
222 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
223
224 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
225 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
226 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
227 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
228 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
229 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
230 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
231
232 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
233 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
234 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
235 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
236}
237
238void QgsSimpleLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
239{
240 const bool isPolygon = type == Qgis::GeometryType::Polygon;
241 mAnchorPointLbl->setEnabled( isPolygon );
242 mAnchorPointLbl->setVisible( isPolygon );
243 mAnchorPointComboBox->setEnabled( isPolygon );
244 mAnchorPointComboBox->setVisible( isPolygon );
245 mAnchorPointDDBtn->setEnabled( isPolygon );
246 mAnchorPointDDBtn->setVisible( isPolygon );
247}
248
249QgsCallout *QgsSimpleLineCalloutWidget::callout()
250{
251 return mCallout.get();
252}
253
254void QgsSimpleLineCalloutWidget::minimumLengthChanged()
255{
256 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
257 emit changed();
258}
259
260void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
261{
262 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
263 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
264 emit changed();
265}
266
267void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
268{
269 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
270 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
271 emit changed();
272}
273
274void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
275{
276 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
277 emit changed();
278}
279
280void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
281{
282 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
283 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
284 emit changed();
285}
286
287void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
288{
289 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
290 emit changed();
291}
292
293void QgsSimpleLineCalloutWidget::lineSymbolChanged()
294{
295 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<QgsLineSymbol>() );
296 emit changed();
297}
298
299void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
300{
301 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
302 emit changed();
303}
304
305void QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
306{
307 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
308 emit changed();
309}
310
311void QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
312{
313 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
314 emit changed();
315}
316
317void QgsSimpleLineCalloutWidget::drawToAllPartsToggled( bool active )
318{
319 mCallout->setDrawCalloutToAllParts( active );
320 emit changed();
321}
322
323
324//
325// QgsManhattanLineCalloutWidget
326//
327
328QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
329 : QgsSimpleLineCalloutWidget( vl, parent )
330{
331}
332
333
334//
335// QgsCurvedLineCalloutWidget
336//
337
338QgsCurvedLineCalloutWidget::QgsCurvedLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
339 : QgsCalloutWidget( parent, vl )
340{
341 setupUi( this );
342
343 // Callout options - to move to custom widgets when multiple callout styles exist
344 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
345 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
346 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
347
348 mCalloutLineStyleButton->setLayer( qobject_cast<QgsVectorLayer *>( vl ) );
352
353 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged );
354 connect( mMinCalloutLengthSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::minimumLengthChanged );
355
356 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
357 connect( mOffsetFromAnchorSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromAnchorChanged );
358 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
359 connect( mOffsetFromLabelSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromLabelChanged );
360
361 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsCurvedLineCalloutWidget::drawToAllPartsToggled );
362
363 mOrientationComboBox->addItem( tr( "Automatic" ), static_cast<int>( QgsCurvedLineCallout::Automatic ) );
364 mOrientationComboBox->addItem( tr( "Clockwise" ), static_cast<int>( QgsCurvedLineCallout::Clockwise ) );
365 mOrientationComboBox->addItem( tr( "Counter Clockwise" ), static_cast<int>( QgsCurvedLineCallout::CounterClockwise ) );
366 connect( mOrientationComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [=]( int index ) {
367 mCallout->setOrientation( static_cast<QgsCurvedLineCallout::Orientation>( mOrientationComboBox->itemData( index ).toInt() ) );
368 emit changed();
369 } );
370
371 // Anchor point options
372 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast<int>( QgsCallout::PoleOfInaccessibility ) );
373 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast<int>( QgsCallout::PointOnExterior ) );
374 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast<int>( QgsCallout::PointOnSurface ) );
375 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::Centroid ) );
376 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
377
378 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast<int>( QgsCallout::LabelPointOnExterior ) );
379 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::LabelCentroid ) );
380 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast<int>( QgsCallout::LabelTopLeft ) );
381 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast<int>( QgsCallout::LabelTopMiddle ) );
382 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast<int>( QgsCallout::LabelTopRight ) );
383 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast<int>( QgsCallout::LabelMiddleLeft ) );
384 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast<int>( QgsCallout::LabelMiddleRight ) );
385 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast<int>( QgsCallout::LabelBottomLeft ) );
386 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast<int>( QgsCallout::LabelBottomMiddle ) );
387 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast<int>( QgsCallout::LabelBottomRight ) );
388 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
389
390 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsCurvedLineCalloutWidget::lineSymbolChanged );
391
392 connect( mCurvatureSlider, &QSlider::valueChanged, this, [=]( int value ) { mCurvatureSpinBox->setValue( value / 10.0 ); } );
393 connect( mCurvatureSpinBox, static_cast<void ( QgsDoubleSpinBox::* )( double )>( &QgsDoubleSpinBox::valueChanged ), this, [=]( double value ) { whileBlocking( mCurvatureSlider )->setValue( value * 10 ); } );
394 connect( mCurvatureSpinBox, static_cast<void ( QgsDoubleSpinBox::* )( double )>( &QgsDoubleSpinBox::valueChanged ), this, [=]( double value ) {
395 mCallout->setCurvature( value / 100.0 );
396 emit changed();
397 } );
398
399 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
400
401 mPlacementDDGroupBox->setVisible( qobject_cast<QgsVectorLayer *>( vl ) );
402}
403
404void QgsCurvedLineCalloutWidget::setCallout( const QgsCallout *callout )
405{
406 if ( !callout )
407 return;
408
409 mCallout.reset( dynamic_cast<QgsCurvedLineCallout *>( callout->clone() ) );
410 if ( !mCallout )
411 return;
412
413 mMinCalloutWidthUnitWidget->blockSignals( true );
414 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
415 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
416 mMinCalloutWidthUnitWidget->blockSignals( false );
417
418 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
419
420 mOffsetFromAnchorUnitWidget->blockSignals( true );
421 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
422 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
423 mOffsetFromAnchorUnitWidget->blockSignals( false );
424 mOffsetFromLabelUnitWidget->blockSignals( true );
425 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
426 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
427 mOffsetFromLabelUnitWidget->blockSignals( false );
428 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
429 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
430
431 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
432
433 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
434
435 whileBlocking( mOrientationComboBox )->setCurrentIndex( mOrientationComboBox->findData( static_cast<int>( mCallout->orientation() ) ) );
436
437 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast<int>( callout->anchorPoint() ) ) );
438 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast<int>( callout->labelAnchorPoint() ) ) );
439
440 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
441
442 whileBlocking( mCurvatureSpinBox )->setValue( mCallout->curvature() * 100.0 );
443 whileBlocking( mCurvatureSlider )->setValue( mCallout->curvature() * 1000.0 );
444
445 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
446 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
447 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
448 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
449 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
450 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
451 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
452 registerDataDefinedButton( mCalloutCurvatureDDBtn, QgsCallout::Property::Curvature );
453 registerDataDefinedButton( mCalloutOrientationDDBtn, QgsCallout::Property::Orientation );
454
455 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
456 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
457 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
458 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
459}
460
461void QgsCurvedLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
462{
463 const bool isPolygon = type == Qgis::GeometryType::Polygon;
464 mAnchorPointLbl->setEnabled( isPolygon );
465 mAnchorPointLbl->setVisible( isPolygon );
466 mAnchorPointComboBox->setEnabled( isPolygon );
467 mAnchorPointComboBox->setVisible( isPolygon );
468 mAnchorPointDDBtn->setEnabled( isPolygon );
469 mAnchorPointDDBtn->setVisible( isPolygon );
470}
471
472QgsCallout *QgsCurvedLineCalloutWidget::callout()
473{
474 return mCallout.get();
475}
476
477void QgsCurvedLineCalloutWidget::minimumLengthChanged()
478{
479 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
480 emit changed();
481}
482
483void QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged()
484{
485 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
486 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
487 emit changed();
488}
489
490void QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
491{
492 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
493 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
494 emit changed();
495}
496
497void QgsCurvedLineCalloutWidget::offsetFromAnchorChanged()
498{
499 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
500 emit changed();
501}
502
503void QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
504{
505 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
506 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
507 emit changed();
508}
509
510void QgsCurvedLineCalloutWidget::offsetFromLabelChanged()
511{
512 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
513 emit changed();
514}
515
516void QgsCurvedLineCalloutWidget::lineSymbolChanged()
517{
518 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<QgsLineSymbol>() );
519 emit changed();
520}
521
522void QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
523{
524 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
525 emit changed();
526}
527
528void QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
529{
530 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
531 emit changed();
532}
533
534void QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
535{
536 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
537 emit changed();
538}
539
540void QgsCurvedLineCalloutWidget::drawToAllPartsToggled( bool active )
541{
542 mCallout->setDrawCalloutToAllParts( active );
543 emit changed();
544}
545
546
547//
548// QgsBalloonCalloutWidget
549//
550
551QgsBalloonCalloutWidget::QgsBalloonCalloutWidget( QgsMapLayer *vl, QWidget *parent )
552 : QgsCalloutWidget( parent, vl )
553{
554 setupUi( this );
555
556 // Callout options - to move to custom widgets when multiple callout styles exist
557 mCalloutFillStyleButton->setSymbolType( Qgis::SymbolType::Fill );
558 mCalloutFillStyleButton->setDialogTitle( tr( "Balloon Symbol" ) );
559 mCalloutFillStyleButton->registerExpressionContextGenerator( this );
560
561 mMarkerSymbolButton->setSymbolType( Qgis::SymbolType::Marker );
562 mMarkerSymbolButton->setDialogTitle( tr( "Marker Symbol" ) );
563 mMarkerSymbolButton->registerExpressionContextGenerator( this );
564 mMarkerSymbolButton->setShowNull( true );
565 mMarkerSymbolButton->setToNull();
566
567 mCalloutFillStyleButton->setLayer( qobject_cast<QgsVectorLayer *>( vl ) );
568 mMarkerSymbolButton->setLayer( qobject_cast<QgsVectorLayer *>( vl ) );
573
574 mSpinBottomMargin->setClearValue( 0 );
575 mSpinTopMargin->setClearValue( 0 );
576 mSpinRightMargin->setClearValue( 0 );
577 mSpinLeftMargin->setClearValue( 0 );
578 mWedgeWidthSpin->setClearValue( 2.64 );
579 mCornerRadiusSpin->setClearValue( 0.0 );
580
581 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged );
582 connect( mOffsetFromAnchorSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsBalloonCalloutWidget::offsetFromAnchorChanged );
583
584 // Anchor point options
585 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast<int>( QgsCallout::PoleOfInaccessibility ) );
586 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast<int>( QgsCallout::PointOnExterior ) );
587 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast<int>( QgsCallout::PointOnSurface ) );
588 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::Centroid ) );
589 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
590
591 connect( mCalloutFillStyleButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::fillSymbolChanged );
592 connect( mMarkerSymbolButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::markerSymbolChanged );
593
594 connect( mSpinBottomMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
595 QgsMargins margins = mCallout->margins();
596 margins.setBottom( value );
597 mCallout->setMargins( margins );
598 emit changed();
599 } );
600 connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
601 QgsMargins margins = mCallout->margins();
602 margins.setTop( value );
603 mCallout->setMargins( margins );
604 emit changed();
605 } );
606 connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
607 QgsMargins margins = mCallout->margins();
608 margins.setLeft( value );
609 mCallout->setMargins( margins );
610 emit changed();
611 } );
612 connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
613 QgsMargins margins = mCallout->margins();
614 margins.setRight( value );
615 mCallout->setMargins( margins );
616 emit changed();
617 } );
618 connect( mMarginUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
619 mCallout->setMarginsUnit( mMarginUnitWidget->unit() );
620 emit changed();
621 } );
622
623 connect( mWedgeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
624 mCallout->setWedgeWidthUnit( mWedgeWidthUnitWidget->unit() );
625 mCallout->setWedgeWidthMapUnitScale( mWedgeWidthUnitWidget->getMapUnitScale() );
626 emit changed();
627 } );
628 connect( mWedgeWidthSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
629 mCallout->setWedgeWidth( value );
630 emit changed();
631 } );
632
633 connect( mCornerRadiusUnitWidget, &QgsUnitSelectionWidget::changed, this, [=] {
634 mCallout->setCornerRadiusUnit( mCornerRadiusUnitWidget->unit() );
635 mCallout->setCornerRadiusMapUnitScale( mCornerRadiusUnitWidget->getMapUnitScale() );
636 emit changed();
637 } );
638 connect( mCornerRadiusSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( double value ) {
639 mCallout->setCornerRadius( value );
640 emit changed();
641 } );
642
643 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
644
645 mPlacementDDGroupBox->setVisible( qobject_cast<QgsVectorLayer *>( vl ) );
646}
647
648void QgsBalloonCalloutWidget::setCallout( const QgsCallout *callout )
649{
650 if ( !callout )
651 return;
652
653 mCallout.reset( dynamic_cast<QgsBalloonCallout *>( callout->clone() ) );
654 if ( !mCallout )
655 return;
656
657 mOffsetFromAnchorUnitWidget->blockSignals( true );
658 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
659 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
660 mOffsetFromAnchorUnitWidget->blockSignals( false );
661 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
662
663 whileBlocking( mSpinBottomMargin )->setValue( mCallout->margins().bottom() );
664 whileBlocking( mSpinTopMargin )->setValue( mCallout->margins().top() );
665 whileBlocking( mSpinLeftMargin )->setValue( mCallout->margins().left() );
666 whileBlocking( mSpinRightMargin )->setValue( mCallout->margins().right() );
667 whileBlocking( mMarginUnitWidget )->setUnit( mCallout->marginsUnit() );
668
669 mWedgeWidthUnitWidget->blockSignals( true );
670 mWedgeWidthUnitWidget->setUnit( mCallout->wedgeWidthUnit() );
671 mWedgeWidthUnitWidget->setMapUnitScale( mCallout->wedgeWidthMapUnitScale() );
672 mWedgeWidthUnitWidget->blockSignals( false );
673 whileBlocking( mWedgeWidthSpin )->setValue( mCallout->wedgeWidth() );
674
675 mCornerRadiusUnitWidget->blockSignals( true );
676 mCornerRadiusUnitWidget->setUnit( mCallout->cornerRadiusUnit() );
677 mCornerRadiusUnitWidget->setMapUnitScale( mCallout->cornerRadiusMapUnitScale() );
678 mCornerRadiusUnitWidget->blockSignals( false );
679 whileBlocking( mCornerRadiusSpin )->setValue( mCallout->cornerRadius() );
680
681 whileBlocking( mCalloutFillStyleButton )->setSymbol( mCallout->fillSymbol()->clone() );
682 if ( QgsMarkerSymbol *marker = mCallout->markerSymbol() )
683 whileBlocking( mMarkerSymbolButton )->setSymbol( marker->clone() );
684 else
685 whileBlocking( mMarkerSymbolButton )->setToNull();
686
687 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast<int>( callout->anchorPoint() ) ) );
688
689 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
690
691 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
692 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
693 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
694
695 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
696 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
697 registerDataDefinedButton( mMarginsDDBtn, QgsCallout::Property::Margins );
698 registerDataDefinedButton( mWedgeWidthDDBtn, QgsCallout::Property::WedgeWidth );
699 registerDataDefinedButton( mCornerRadiusDDBtn, QgsCallout::Property::CornerRadius );
700}
701
702void QgsBalloonCalloutWidget::setGeometryType( Qgis::GeometryType type )
703{
704 const bool isPolygon = type == Qgis::GeometryType::Polygon;
705 mAnchorPointLbl->setEnabled( isPolygon );
706 mAnchorPointLbl->setVisible( isPolygon );
707 mAnchorPointComboBox->setEnabled( isPolygon );
708 mAnchorPointComboBox->setVisible( isPolygon );
709 mAnchorPointDDBtn->setEnabled( isPolygon );
710 mAnchorPointDDBtn->setVisible( isPolygon );
711}
712
713QgsCallout *QgsBalloonCalloutWidget::callout()
714{
715 return mCallout.get();
716}
717
718void QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged()
719{
720 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
721 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
722 emit changed();
723}
724
725void QgsBalloonCalloutWidget::offsetFromAnchorChanged()
726{
727 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
728 emit changed();
729}
730
731void QgsBalloonCalloutWidget::fillSymbolChanged()
732{
733 mCallout->setFillSymbol( mCalloutFillStyleButton->clonedSymbol<QgsFillSymbol>() );
734 emit changed();
735}
736
737void QgsBalloonCalloutWidget::markerSymbolChanged()
738{
739 mCallout->setMarkerSymbol( mMarkerSymbolButton->isNull() ? nullptr : mMarkerSymbolButton->clonedSymbol<QgsMarkerSymbol>() );
740 emit changed();
741}
742
743void QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
744{
745 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
746 emit changed();
747}
748
749void QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
750{
751 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
752 emit changed();
753}
754
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:5970
Single variable definition for use within a QgsExpressionContextScope.