QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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 "qgsvectorlayer.h"
20#include "qgscallout.h"
23#include "qgsauxiliarystorage.h"
24#include "qgslinesymbol.h"
25#include "qgsfillsymbol.h"
26
28{
29 if ( auto *lExpressionContext = mContext.expressionContext() )
30 return *lExpressionContext;
31
35 expContext << symbolScope;
36
37 // additional scopes
38 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
39 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
40 {
41 expContext.appendScope( new QgsExpressionContextScope( scope ) );
42 }
43
44 //TODO - show actual value
45 expContext.setOriginalValueVariable( QVariant() );
46
48
49 return expContext;
50}
51
53{
54 mContext = context;
55 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
56 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
57 {
58 unitWidget->setMapCanvas( mContext.mapCanvas() );
59 }
60 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
61 for ( QgsSymbolButton *symbolWidget : symbolButtonWidgets )
62 {
63 symbolWidget->setMapCanvas( mContext.mapCanvas() );
64 symbolWidget->setMessageBar( mContext.messageBar() );
65 }
66}
67
69{
70 return mContext;
71}
72
74{
75 button->init( static_cast< int >( key ), callout()->dataDefinedProperties(), QgsCallout::propertyDefinitions(), mVectorLayer, true );
76 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsCalloutWidget::updateDataDefinedProperty );
77 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsCalloutWidget::createAuxiliaryField );
78
80}
81
82void QgsCalloutWidget::createAuxiliaryField()
83{
84 // try to create an auxiliary layer if not yet created
85 if ( !mVectorLayer->auxiliaryLayer() )
86 {
87 QgsNewAuxiliaryLayerDialog dlg( mVectorLayer, this );
88 dlg.exec();
89 }
90
91 // return if still not exists
92 if ( !mVectorLayer->auxiliaryLayer() )
93 return;
94
95 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
96 const QgsCallout::Property key = static_cast< QgsCallout::Property >( button->propertyKey() );
97 const QgsPropertyDefinition def = QgsCallout::propertyDefinitions()[static_cast< int >( key )];
98
99 // create property in auxiliary storage if necessary
100 if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
101 {
102 mVectorLayer->auxiliaryLayer()->addAuxiliaryField( def );
103 }
104
105 // update property with join field name from auxiliary storage
106 QgsProperty property = button->toProperty();
107 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
108 property.setActive( true );
109 button->updateFieldLists();
110 button->setToProperty( property );
111
113
114 emit changed();
115}
116
117void QgsCalloutWidget::updateDataDefinedProperty()
118{
119 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
120 const QgsCallout::Property key = static_cast< QgsCallout::Property >( button->propertyKey() );
122 emit changed();
123}
124
126
127//
128// QgsSimpleLineCalloutWidget
129//
130
131QgsSimpleLineCalloutWidget::QgsSimpleLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent )
132 : QgsCalloutWidget( parent, vl )
133{
134 setupUi( this );
135
136 // Callout options - to move to custom widgets when multiple callout styles exist
137 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
138 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
139 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
140
141 mCalloutLineStyleButton->setLayer( vl );
148
149 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged );
150 connect( mMinCalloutLengthSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::minimumLengthChanged );
151
152 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
153 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromAnchorChanged );
154 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
155 connect( mOffsetFromLabelSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromLabelChanged );
156
157 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsSimpleLineCalloutWidget::drawToAllPartsToggled );
158
159 // Anchor point options
160 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
161 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
162 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
163 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
164 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
165
166 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast< int >( QgsCallout::LabelPointOnExterior ) );
167 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::LabelCentroid ) );
168 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast< int >( QgsCallout::LabelTopLeft ) );
169 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast< int >( QgsCallout::LabelTopMiddle ) );
170 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast< int >( QgsCallout::LabelTopRight ) );
171 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast< int >( QgsCallout::LabelMiddleLeft ) );
172 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast< int >( QgsCallout::LabelMiddleRight ) );
173 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast< int >( QgsCallout::LabelBottomLeft ) );
174 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast< int >( QgsCallout::LabelBottomMiddle ) );
175 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast< int >( QgsCallout::LabelBottomRight ) );
176 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
177
178 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
179
180 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
181}
182
183void QgsSimpleLineCalloutWidget::setCallout( QgsCallout *callout )
184{
185 if ( !callout )
186 return;
187
188 mCallout.reset( dynamic_cast<QgsSimpleLineCallout *>( callout->clone() ) );
189 if ( !mCallout )
190 return;
191
192 mMinCalloutWidthUnitWidget->blockSignals( true );
193 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
194 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
195 mMinCalloutWidthUnitWidget->blockSignals( false );
196
197 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
198
199 mOffsetFromAnchorUnitWidget->blockSignals( true );
200 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
201 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
202 mOffsetFromAnchorUnitWidget->blockSignals( false );
203 mOffsetFromLabelUnitWidget->blockSignals( true );
204 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
205 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
206 mOffsetFromLabelUnitWidget->blockSignals( false );
207 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
208 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
209
210 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
211
212 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
213
214 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
215 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast< int >( callout->labelAnchorPoint() ) ) );
216
217 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
218
219 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
220 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
221 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
222 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
223 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
224 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
225 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
226
227 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
228 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
229 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
230 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
231}
232
233void QgsSimpleLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
234{
235 const bool isPolygon = type == Qgis::GeometryType::Polygon;
236 mAnchorPointLbl->setEnabled( isPolygon );
237 mAnchorPointLbl->setVisible( isPolygon );
238 mAnchorPointComboBox->setEnabled( isPolygon );
239 mAnchorPointComboBox->setVisible( isPolygon );
240 mAnchorPointDDBtn->setEnabled( isPolygon );
241 mAnchorPointDDBtn->setVisible( isPolygon );
242}
243
244QgsCallout *QgsSimpleLineCalloutWidget::callout()
245{
246 return mCallout.get();
247}
248
249void QgsSimpleLineCalloutWidget::minimumLengthChanged()
250{
251 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
252 emit changed();
253}
254
255void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
256{
257 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
258 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
259 emit changed();
260}
261
262void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
263{
264 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
265 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
266 emit changed();
267}
268
269void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
270{
271 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
272 emit changed();
273}
274
275void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
276{
277 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
278 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
279 emit changed();
280}
281
282void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
283{
284 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
285 emit changed();
286}
287
288void QgsSimpleLineCalloutWidget::lineSymbolChanged()
289{
290 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol< QgsLineSymbol >() );
291 emit changed();
292}
293
294void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
295{
296 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
297 emit changed();
298}
299
300void QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
301{
302 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
303 emit changed();
304}
305
306void QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
307{
308 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
309 emit changed();
310}
311
312void QgsSimpleLineCalloutWidget::drawToAllPartsToggled( bool active )
313{
314 mCallout->setDrawCalloutToAllParts( active );
315 emit changed();
316}
317
318
319//
320// QgsManhattanLineCalloutWidget
321//
322
323QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent )
324 : QgsSimpleLineCalloutWidget( vl, parent )
325{
326
327}
328
329
330//
331// QgsCurvedLineCalloutWidget
332//
333
334QgsCurvedLineCalloutWidget::QgsCurvedLineCalloutWidget( QgsVectorLayer *vl, QWidget *parent )
335 : QgsCalloutWidget( parent, vl )
336{
337 setupUi( this );
338
339 // Callout options - to move to custom widgets when multiple callout styles exist
340 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
341 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
342 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
343
344 mCalloutLineStyleButton->setLayer( vl );
351
352 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged );
353 connect( mMinCalloutLengthSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::minimumLengthChanged );
354
355 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
356 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromAnchorChanged );
357 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
358 connect( mOffsetFromLabelSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromLabelChanged );
359
360 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsCurvedLineCalloutWidget::drawToAllPartsToggled );
361
362 mOrientationComboBox->addItem( tr( "Automatic" ), static_cast< int >( QgsCurvedLineCallout::Automatic ) );
363 mOrientationComboBox->addItem( tr( "Clockwise" ), static_cast< int >( QgsCurvedLineCallout::Clockwise ) );
364 mOrientationComboBox->addItem( tr( "Counter Clockwise" ), static_cast< int >( QgsCurvedLineCallout::CounterClockwise ) );
365 connect( mOrientationComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]( int index )
366 {
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 {
396 mCallout->setCurvature( value / 100.0 );
397 emit changed();
398 } );
399
400 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
401}
402
403void QgsCurvedLineCalloutWidget::setCallout( QgsCallout *callout )
404{
405 if ( !callout )
406 return;
407
408 mCallout.reset( dynamic_cast<QgsCurvedLineCallout *>( callout->clone() ) );
409 if ( !mCallout )
410 return;
411
412 mMinCalloutWidthUnitWidget->blockSignals( true );
413 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
414 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
415 mMinCalloutWidthUnitWidget->blockSignals( false );
416
417 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
418
419 mOffsetFromAnchorUnitWidget->blockSignals( true );
420 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
421 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
422 mOffsetFromAnchorUnitWidget->blockSignals( false );
423 mOffsetFromLabelUnitWidget->blockSignals( true );
424 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
425 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
426 mOffsetFromLabelUnitWidget->blockSignals( false );
427 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
428 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
429
430 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
431
432 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
433
434 whileBlocking( mOrientationComboBox )->setCurrentIndex( mOrientationComboBox->findData( static_cast< int >( mCallout->orientation() ) ) );
435
436 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
437 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast< int >( callout->labelAnchorPoint() ) ) );
438
439 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
440
441 whileBlocking( mCurvatureSpinBox )->setValue( mCallout->curvature() * 100.0 );
442 whileBlocking( mCurvatureSlider )->setValue( mCallout->curvature() * 1000.0 );
443
444 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
445 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
446 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
447 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
448 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
449 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
450 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
451 registerDataDefinedButton( mCalloutCurvatureDDBtn, QgsCallout::Property::Curvature );
452 registerDataDefinedButton( mCalloutOrientationDDBtn, QgsCallout::Property::Orientation );
453
454 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
455 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
456 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
457 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
458}
459
460void QgsCurvedLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
461{
462 const bool isPolygon = type == Qgis::GeometryType::Polygon;
463 mAnchorPointLbl->setEnabled( isPolygon );
464 mAnchorPointLbl->setVisible( isPolygon );
465 mAnchorPointComboBox->setEnabled( isPolygon );
466 mAnchorPointComboBox->setVisible( isPolygon );
467 mAnchorPointDDBtn->setEnabled( isPolygon );
468 mAnchorPointDDBtn->setVisible( isPolygon );
469}
470
471QgsCallout *QgsCurvedLineCalloutWidget::callout()
472{
473 return mCallout.get();
474}
475
476void QgsCurvedLineCalloutWidget::minimumLengthChanged()
477{
478 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
479 emit changed();
480}
481
482void QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged()
483{
484 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
485 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
486 emit changed();
487}
488
489void QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
490{
491 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
492 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
493 emit changed();
494}
495
496void QgsCurvedLineCalloutWidget::offsetFromAnchorChanged()
497{
498 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
499 emit changed();
500}
501
502void QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
503{
504 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
505 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
506 emit changed();
507}
508
509void QgsCurvedLineCalloutWidget::offsetFromLabelChanged()
510{
511 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
512 emit changed();
513}
514
515void QgsCurvedLineCalloutWidget::lineSymbolChanged()
516{
517 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol< QgsLineSymbol >() );
518 emit changed();
519}
520
521void QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
522{
523 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
524 emit changed();
525}
526
527void QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
528{
529 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
530 emit changed();
531}
532
533void QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
534{
535 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
536 emit changed();
537}
538
539void QgsCurvedLineCalloutWidget::drawToAllPartsToggled( bool active )
540{
541 mCallout->setDrawCalloutToAllParts( active );
542 emit changed();
543}
544
545
546//
547// QgsBalloonCalloutWidget
548//
549
550QgsBalloonCalloutWidget::QgsBalloonCalloutWidget( QgsVectorLayer *vl, QWidget *parent )
551 : QgsCalloutWidget( parent, vl )
552{
553 setupUi( this );
554
555 // Callout options - to move to custom widgets when multiple callout styles exist
556 mCalloutFillStyleButton->setSymbolType( Qgis::SymbolType::Fill );
557 mCalloutFillStyleButton->setDialogTitle( tr( "Balloon Symbol" ) );
558 mCalloutFillStyleButton->registerExpressionContextGenerator( this );
559
560 mCalloutFillStyleButton->setLayer( vl );
569
570 mSpinBottomMargin->setClearValue( 0 );
571 mSpinTopMargin->setClearValue( 0 );
572 mSpinRightMargin->setClearValue( 0 );
573 mSpinLeftMargin->setClearValue( 0 );
574 mWedgeWidthSpin->setClearValue( 2.64 );
575 mCornerRadiusSpin->setClearValue( 0.0 );
576
577 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged );
578 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsBalloonCalloutWidget::offsetFromAnchorChanged );
579
580 // Anchor point options
581 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
582 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
583 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
584 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
585 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
586
587 connect( mCalloutFillStyleButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::fillSymbolChanged );
588
589 connect( mSpinBottomMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
590 {
591 QgsMargins margins = mCallout->margins();
592 margins.setBottom( value );
593 mCallout->setMargins( margins );
594 emit changed();
595 } );
596 connect( mSpinTopMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
597 {
598 QgsMargins margins = mCallout->margins();
599 margins.setTop( value );
600 mCallout->setMargins( margins );
601 emit changed();
602 } );
603 connect( mSpinLeftMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
604 {
605 QgsMargins margins = mCallout->margins();
606 margins.setLeft( value );
607 mCallout->setMargins( margins );
608 emit changed();
609 } );
610 connect( mSpinRightMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
611 {
612 QgsMargins margins = mCallout->margins();
613 margins.setRight( value );
614 mCallout->setMargins( margins );
615 emit changed();
616 } );
617 connect( mMarginUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
618 {
619 mCallout->setMarginsUnit( mMarginUnitWidget->unit() );
620 emit changed();
621 } );
622
623 connect( mWedgeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
624 {
625 mCallout->setWedgeWidthUnit( mWedgeWidthUnitWidget->unit() );
626 mCallout->setWedgeWidthMapUnitScale( mWedgeWidthUnitWidget->getMapUnitScale() );
627 emit changed();
628 } );
629 connect( mWedgeWidthSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
630 {
631 mCallout->setWedgeWidth( value );
632 emit changed();
633 } );
634
635 connect( mCornerRadiusUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
636 {
637 mCallout->setCornerRadiusUnit( mCornerRadiusUnitWidget->unit() );
638 mCallout->setCornerRadiusMapUnitScale( mCornerRadiusUnitWidget->getMapUnitScale() );
639 emit changed();
640 } );
641 connect( mCornerRadiusSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
642 {
643 mCallout->setCornerRadius( value );
644 emit changed();
645 } );
646
647 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
648}
649
650void QgsBalloonCalloutWidget::setCallout( QgsCallout *callout )
651{
652 if ( !callout )
653 return;
654
655 mCallout.reset( dynamic_cast<QgsBalloonCallout *>( callout->clone() ) );
656 if ( !mCallout )
657 return;
658
659 mOffsetFromAnchorUnitWidget->blockSignals( true );
660 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
661 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
662 mOffsetFromAnchorUnitWidget->blockSignals( false );
663 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
664
665 whileBlocking( mSpinBottomMargin )->setValue( mCallout->margins().bottom() );
666 whileBlocking( mSpinTopMargin )->setValue( mCallout->margins().top() );
667 whileBlocking( mSpinLeftMargin )->setValue( mCallout->margins().left() );
668 whileBlocking( mSpinRightMargin )->setValue( mCallout->margins().right() );
669 whileBlocking( mMarginUnitWidget )->setUnit( mCallout->marginsUnit() );
670
671 mWedgeWidthUnitWidget->blockSignals( true );
672 mWedgeWidthUnitWidget->setUnit( mCallout->wedgeWidthUnit() );
673 mWedgeWidthUnitWidget->setMapUnitScale( mCallout->wedgeWidthMapUnitScale() );
674 mWedgeWidthUnitWidget->blockSignals( false );
675 whileBlocking( mWedgeWidthSpin )->setValue( mCallout->wedgeWidth() );
676
677 mCornerRadiusUnitWidget->blockSignals( true );
678 mCornerRadiusUnitWidget->setUnit( mCallout->cornerRadiusUnit() );
679 mCornerRadiusUnitWidget->setMapUnitScale( mCallout->cornerRadiusMapUnitScale() );
680 mCornerRadiusUnitWidget->blockSignals( false );
681 whileBlocking( mCornerRadiusSpin )->setValue( mCallout->cornerRadius() );
682
683 whileBlocking( mCalloutFillStyleButton )->setSymbol( mCallout->fillSymbol()->clone() );
684
685 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
686
687 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
688
689 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
690 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
691 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
692
693 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
694 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
695 registerDataDefinedButton( mMarginsDDBtn, QgsCallout::Property::Margins );
696 registerDataDefinedButton( mWedgeWidthDDBtn, QgsCallout::Property::WedgeWidth );
697 registerDataDefinedButton( mCornerRadiusDDBtn, QgsCallout::Property::CornerRadius );
698}
699
700void QgsBalloonCalloutWidget::setGeometryType( Qgis::GeometryType type )
701{
702 const bool isPolygon = type == Qgis::GeometryType::Polygon;
703 mAnchorPointLbl->setEnabled( isPolygon );
704 mAnchorPointLbl->setVisible( isPolygon );
705 mAnchorPointComboBox->setEnabled( isPolygon );
706 mAnchorPointComboBox->setVisible( isPolygon );
707 mAnchorPointDDBtn->setEnabled( isPolygon );
708 mAnchorPointDDBtn->setVisible( isPolygon );
709}
710
711QgsCallout *QgsBalloonCalloutWidget::callout()
712{
713 return mCallout.get();
714}
715
716void QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged()
717{
718 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
719 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
720 emit changed();
721}
722
723void QgsBalloonCalloutWidget::offsetFromAnchorChanged()
724{
725 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
726 emit changed();
727}
728
729void QgsBalloonCalloutWidget::fillSymbolChanged()
730{
731 mCallout->setFillSymbol( mCalloutFillStyleButton->clonedSymbol< QgsFillSymbol >() );
732 emit changed();
733}
734
735void QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
736{
737 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
738 emit changed();
739}
740
741void QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
742{
743 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
744 emit changed();
745}
746
748
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:255
@ Polygon
Polygons.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MapUnits
Map units.
@ MetersInMapUnits
Meters value as Map units.
@ 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:893
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 ...
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
virtual QgsCallout * callout()=0
Returns the callout defined by the current settings in the widget.
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsCallout::Property key)
Registers a data defined override button.
Abstract base class for callout renderers.
Definition: qgscallout.h:53
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:333
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in callouts.
Definition: qgscallout.cpp:193
AnchorPoint anchorPoint() const
Returns the feature's anchor point position.
Definition: qgscallout.h:363
LabelAnchorPoint labelAnchorPoint() const
Returns the label's anchor point position.
Definition: qgscallout.h:396
AnchorPoint
Feature's anchor point position.
Definition: qgscallout.h:114
@ PointOnExterior
A point on the surface's outline closest to the label is used as anchor for polygon geometries.
Definition: qgscallout.h:116
@ Centroid
The surface's centroid is used as anchor for polygon geometries.
Definition: qgscallout.h:118
@ PointOnSurface
A point guaranteed to be on the surface is used as anchor for polygon geometries.
Definition: qgscallout.h:117
@ PoleOfInaccessibility
The surface's pole of inaccessibility used as anchor for polygon geometries.
Definition: qgscallout.h:115
LabelAnchorPoint
Label's anchor point position.
Definition: qgscallout.h:126
@ LabelPointOnExterior
The point on the label's boundary closest to the feature.
Definition: qgscallout.h:127
@ LabelBottomLeft
Bottom left corner of the label's boundary.
Definition: qgscallout.h:134
@ LabelBottomMiddle
Bottom middle of the label's boundary.
Definition: qgscallout.h:135
@ LabelMiddleLeft
Middle left of the label's boundary.
Definition: qgscallout.h:132
@ LabelBottomRight
Bottom right corner of the label's boundary.
Definition: qgscallout.h:136
@ LabelMiddleRight
Middle right of the label's boundary.
Definition: qgscallout.h:133
@ LabelTopMiddle
Top middle of the label's boundary.
Definition: qgscallout.h:130
@ LabelTopLeft
Top left corner of the label's boundary.
Definition: qgscallout.h:129
@ LabelCentroid
The labe's centroid.
Definition: qgscallout.h:128
@ LabelTopRight
Top right corner of the label's boundary.
Definition: qgscallout.h:131
Property
Data definable properties.
Definition: qgscallout.h:85
@ MinimumCalloutLength
Minimum length of callouts.
@ LabelAnchorPointPosition
Label's anchor point position.
@ CornerRadius
Balloon callout corner radius (since QGIS 3.20)
@ OffsetFromAnchor
Distance to offset lines from anchor points.
@ OffsetFromLabel
Distance to offset lines from label area.
@ DestinationX
X-coordinate of callout destination (feature anchor) (since QGIS 3.20)
@ DestinationY
Y-coordinate of callout destination (feature anchor) (since QGIS 3.20)
@ WedgeWidth
Balloon callout wedge width (since QGIS 3.20)
@ AnchorPointPosition
Feature's anchor point position.
@ OriginX
X-coordinate of callout origin (label anchor) (since QGIS 3.20)
@ OriginY
Y-coordinate of callout origin (label anchor) (since QGIS 3.20)
@ Curvature
Curvature of curved line callouts (since QGIS 3.20)
@ BlendMode
Callout blend mode (since QGIS 3.20)
@ Orientation
Orientation of curved line callouts (since QGIS 3.20)
@ Margins
Margin from text (since QGIS 3.20)
@ DrawCalloutToAllParts
Whether callout lines should be drawn to all feature parts.
Draws curved lines as callouts.
Definition: qgscallout.h:793
Orientation
Curve orientation.
Definition: qgscallout.h:800
@ Clockwise
Curve lines in a clockwise direction.
Definition: qgscallout.h:802
@ CounterClockwise
Curve lines in a counter-clockwise direction.
Definition: qgscallout.h:803
@ Automatic
Automatically choose most cartographically pleasing orientation based on label and callout arrangemen...
Definition: qgscallout.h:801
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.
Definition: qgsfillsymbol.h:30
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
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 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.
Definition: qgsproperty.h:228
void setField(const QString &field)
Sets the field name the property references.
A simple direct line callout style.
Definition: qgscallout.h:513
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,...
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:81
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:5111
Single variable definition for use within a QgsExpressionContextScope.