QGIS API Documentation 3.39.0-Master (d85f3c2a281)
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 "qgsvectorlayer.h"
20#include "qgscallout.h"
23#include "qgsauxiliarystorage.h"
24#include "qgslinesymbol.h"
25#include "qgsfillsymbol.h"
26#include "qgsmarkersymbol.h"
27
29{
30 if ( auto *lExpressionContext = mContext.expressionContext() )
31 return *lExpressionContext;
32
36 expContext << symbolScope;
37
38 // additional scopes
39 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
40 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
41 {
42 expContext.appendScope( new QgsExpressionContextScope( scope ) );
43 }
44
45 //TODO - show actual value
46 expContext.setOriginalValueVariable( QVariant() );
47
49
50 return expContext;
51}
52
54{
55 mContext = context;
56 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
57 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
58 {
59 unitWidget->setMapCanvas( mContext.mapCanvas() );
60 }
61 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
62 for ( QgsSymbolButton *symbolWidget : symbolButtonWidgets )
63 {
64 symbolWidget->setMapCanvas( mContext.mapCanvas() );
65 symbolWidget->setMessageBar( mContext.messageBar() );
66 }
67}
68
70{
71 return mContext;
72}
73
75{
76 button->init( static_cast< int >( key ), callout()->dataDefinedProperties(), QgsCallout::propertyDefinitions(), qobject_cast< QgsVectorLayer * >( mLayer ), true );
77 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsCalloutWidget::updateDataDefinedProperty );
78 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsCalloutWidget::createAuxiliaryField );
79
81}
82
83void QgsCalloutWidget::createAuxiliaryField()
84{
85 // try to create an auxiliary layer if not yet created
86 QgsVectorLayer *vectorLayer = qobject_cast< QgsVectorLayer * >( mLayer );
87 if ( !vectorLayer )
88 return;
89
91 {
93 dlg.exec();
94 }
95
96 // return if still not exists
98 return;
99
100 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
101 const QgsCallout::Property key = static_cast< QgsCallout::Property >( button->propertyKey() );
102 const QgsPropertyDefinition def = QgsCallout::propertyDefinitions()[static_cast< int >( key )];
103
104 // create property in auxiliary storage if necessary
105 if ( !vectorLayer->auxiliaryLayer()->exists( def ) )
106 {
108 }
109
110 // update property with join field name from auxiliary storage
111 QgsProperty property = button->toProperty();
112 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
113 property.setActive( true );
114 button->updateFieldLists();
115 button->setToProperty( property );
116
118
119 emit changed();
120}
121
122void QgsCalloutWidget::updateDataDefinedProperty()
123{
124 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
125 const QgsCallout::Property key = static_cast< QgsCallout::Property >( button->propertyKey() );
127 emit changed();
128}
129
131
132//
133// QgsSimpleLineCalloutWidget
134//
135
136QgsSimpleLineCalloutWidget::QgsSimpleLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
137 : QgsCalloutWidget( parent, vl )
138{
139 setupUi( this );
140
141 // Callout options - to move to custom widgets when multiple callout styles exist
142 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
143 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
144 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
145
146 mCalloutLineStyleButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
153
154 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged );
155 connect( mMinCalloutLengthSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::minimumLengthChanged );
156
157 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
158 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromAnchorChanged );
159 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
160 connect( mOffsetFromLabelSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineCalloutWidget::offsetFromLabelChanged );
161
162 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsSimpleLineCalloutWidget::drawToAllPartsToggled );
163
164 // Anchor point options
165 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
166 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
167 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
168 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
169 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
170
171 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast< int >( QgsCallout::LabelPointOnExterior ) );
172 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::LabelCentroid ) );
173 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast< int >( QgsCallout::LabelTopLeft ) );
174 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast< int >( QgsCallout::LabelTopMiddle ) );
175 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast< int >( QgsCallout::LabelTopRight ) );
176 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast< int >( QgsCallout::LabelMiddleLeft ) );
177 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast< int >( QgsCallout::LabelMiddleRight ) );
178 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast< int >( QgsCallout::LabelBottomLeft ) );
179 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast< int >( QgsCallout::LabelBottomMiddle ) );
180 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast< int >( QgsCallout::LabelBottomRight ) );
181 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
182
183 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
184
185 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
186
187 mPlacementDDGroupBox->setVisible( qobject_cast< QgsVectorLayer * >( vl ) );
188}
189
190void QgsSimpleLineCalloutWidget::setCallout( const QgsCallout *callout )
191{
192 if ( !callout )
193 return;
194
195 mCallout.reset( dynamic_cast<QgsSimpleLineCallout *>( callout->clone() ) );
196 if ( !mCallout )
197 return;
198
199 mMinCalloutWidthUnitWidget->blockSignals( true );
200 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
201 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
202 mMinCalloutWidthUnitWidget->blockSignals( false );
203
204 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
205
206 mOffsetFromAnchorUnitWidget->blockSignals( true );
207 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
208 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
209 mOffsetFromAnchorUnitWidget->blockSignals( false );
210 mOffsetFromLabelUnitWidget->blockSignals( true );
211 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
212 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
213 mOffsetFromLabelUnitWidget->blockSignals( false );
214 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
215 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
216
217 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
218
219 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
220
221 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
222 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast< int >( callout->labelAnchorPoint() ) ) );
223
224 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
225
226 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
227 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
228 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
229 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
230 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
231 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
232 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
233
234 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
235 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
236 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
237 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
238}
239
240void QgsSimpleLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
241{
242 const bool isPolygon = type == Qgis::GeometryType::Polygon;
243 mAnchorPointLbl->setEnabled( isPolygon );
244 mAnchorPointLbl->setVisible( isPolygon );
245 mAnchorPointComboBox->setEnabled( isPolygon );
246 mAnchorPointComboBox->setVisible( isPolygon );
247 mAnchorPointDDBtn->setEnabled( isPolygon );
248 mAnchorPointDDBtn->setVisible( isPolygon );
249}
250
251QgsCallout *QgsSimpleLineCalloutWidget::callout()
252{
253 return mCallout.get();
254}
255
256void QgsSimpleLineCalloutWidget::minimumLengthChanged()
257{
258 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
259 emit changed();
260}
261
262void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
263{
264 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
265 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
266 emit changed();
267}
268
269void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
270{
271 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
272 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
273 emit changed();
274}
275
276void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
277{
278 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
279 emit changed();
280}
281
282void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
283{
284 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
285 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
286 emit changed();
287}
288
289void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
290{
291 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
292 emit changed();
293}
294
295void QgsSimpleLineCalloutWidget::lineSymbolChanged()
296{
297 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol< QgsLineSymbol >() );
298 emit changed();
299}
300
301void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
302{
303 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
304 emit changed();
305}
306
307void QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
308{
309 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
310 emit changed();
311}
312
313void QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
314{
315 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
316 emit changed();
317}
318
319void QgsSimpleLineCalloutWidget::drawToAllPartsToggled( bool active )
320{
321 mCallout->setDrawCalloutToAllParts( active );
322 emit changed();
323}
324
325
326//
327// QgsManhattanLineCalloutWidget
328//
329
330QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
331 : QgsSimpleLineCalloutWidget( vl, parent )
332{
333
334}
335
336
337//
338// QgsCurvedLineCalloutWidget
339//
340
341QgsCurvedLineCalloutWidget::QgsCurvedLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
342 : QgsCalloutWidget( parent, vl )
343{
344 setupUi( this );
345
346 // Callout options - to move to custom widgets when multiple callout styles exist
347 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
348 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
349 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
350
351 mCalloutLineStyleButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
358
359 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged );
360 connect( mMinCalloutLengthSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::minimumLengthChanged );
361
362 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
363 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromAnchorChanged );
364 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
365 connect( mOffsetFromLabelSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromLabelChanged );
366
367 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsCurvedLineCalloutWidget::drawToAllPartsToggled );
368
369 mOrientationComboBox->addItem( tr( "Automatic" ), static_cast< int >( QgsCurvedLineCallout::Automatic ) );
370 mOrientationComboBox->addItem( tr( "Clockwise" ), static_cast< int >( QgsCurvedLineCallout::Clockwise ) );
371 mOrientationComboBox->addItem( tr( "Counter Clockwise" ), static_cast< int >( QgsCurvedLineCallout::CounterClockwise ) );
372 connect( mOrientationComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]( int index )
373 {
374 mCallout->setOrientation( static_cast<QgsCurvedLineCallout::Orientation>( mOrientationComboBox->itemData( index ).toInt() ) );
375 emit changed();
376 } );
377
378 // Anchor point options
379 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
380 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
381 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
382 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
383 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
384
385 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast< int >( QgsCallout::LabelPointOnExterior ) );
386 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::LabelCentroid ) );
387 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast< int >( QgsCallout::LabelTopLeft ) );
388 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast< int >( QgsCallout::LabelTopMiddle ) );
389 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast< int >( QgsCallout::LabelTopRight ) );
390 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast< int >( QgsCallout::LabelMiddleLeft ) );
391 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast< int >( QgsCallout::LabelMiddleRight ) );
392 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast< int >( QgsCallout::LabelBottomLeft ) );
393 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast< int >( QgsCallout::LabelBottomMiddle ) );
394 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast< int >( QgsCallout::LabelBottomRight ) );
395 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
396
397 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsCurvedLineCalloutWidget::lineSymbolChanged );
398
399 connect( mCurvatureSlider, &QSlider::valueChanged, this, [ = ]( int value ) { mCurvatureSpinBox->setValue( value / 10.0 ); } );
400 connect( mCurvatureSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value ) { whileBlocking( mCurvatureSlider )->setValue( value * 10 ); } );
401 connect( mCurvatureSpinBox, static_cast < void ( QgsDoubleSpinBox::* )( double ) > ( &QgsDoubleSpinBox::valueChanged ), this, [ = ]( double value )
402 {
403 mCallout->setCurvature( value / 100.0 );
404 emit changed();
405 } );
406
407 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
408
409 mPlacementDDGroupBox->setVisible( qobject_cast< QgsVectorLayer * >( vl ) );
410}
411
412void QgsCurvedLineCalloutWidget::setCallout( const QgsCallout *callout )
413{
414 if ( !callout )
415 return;
416
417 mCallout.reset( dynamic_cast<QgsCurvedLineCallout *>( callout->clone() ) );
418 if ( !mCallout )
419 return;
420
421 mMinCalloutWidthUnitWidget->blockSignals( true );
422 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
423 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
424 mMinCalloutWidthUnitWidget->blockSignals( false );
425
426 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
427
428 mOffsetFromAnchorUnitWidget->blockSignals( true );
429 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
430 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
431 mOffsetFromAnchorUnitWidget->blockSignals( false );
432 mOffsetFromLabelUnitWidget->blockSignals( true );
433 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
434 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
435 mOffsetFromLabelUnitWidget->blockSignals( false );
436 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
437 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
438
439 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
440
441 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
442
443 whileBlocking( mOrientationComboBox )->setCurrentIndex( mOrientationComboBox->findData( static_cast< int >( mCallout->orientation() ) ) );
444
445 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
446 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast< int >( callout->labelAnchorPoint() ) ) );
447
448 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
449
450 whileBlocking( mCurvatureSpinBox )->setValue( mCallout->curvature() * 100.0 );
451 whileBlocking( mCurvatureSlider )->setValue( mCallout->curvature() * 1000.0 );
452
453 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
454 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
455 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
456 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
457 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
458 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
459 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
460 registerDataDefinedButton( mCalloutCurvatureDDBtn, QgsCallout::Property::Curvature );
461 registerDataDefinedButton( mCalloutOrientationDDBtn, QgsCallout::Property::Orientation );
462
463 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
464 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
465 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
466 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
467}
468
469void QgsCurvedLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
470{
471 const bool isPolygon = type == Qgis::GeometryType::Polygon;
472 mAnchorPointLbl->setEnabled( isPolygon );
473 mAnchorPointLbl->setVisible( isPolygon );
474 mAnchorPointComboBox->setEnabled( isPolygon );
475 mAnchorPointComboBox->setVisible( isPolygon );
476 mAnchorPointDDBtn->setEnabled( isPolygon );
477 mAnchorPointDDBtn->setVisible( isPolygon );
478}
479
480QgsCallout *QgsCurvedLineCalloutWidget::callout()
481{
482 return mCallout.get();
483}
484
485void QgsCurvedLineCalloutWidget::minimumLengthChanged()
486{
487 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
488 emit changed();
489}
490
491void QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged()
492{
493 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
494 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
495 emit changed();
496}
497
498void QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
499{
500 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
501 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
502 emit changed();
503}
504
505void QgsCurvedLineCalloutWidget::offsetFromAnchorChanged()
506{
507 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
508 emit changed();
509}
510
511void QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
512{
513 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
514 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
515 emit changed();
516}
517
518void QgsCurvedLineCalloutWidget::offsetFromLabelChanged()
519{
520 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
521 emit changed();
522}
523
524void QgsCurvedLineCalloutWidget::lineSymbolChanged()
525{
526 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol< QgsLineSymbol >() );
527 emit changed();
528}
529
530void QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
531{
532 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
533 emit changed();
534}
535
536void QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
537{
538 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
539 emit changed();
540}
541
542void QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
543{
544 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
545 emit changed();
546}
547
548void QgsCurvedLineCalloutWidget::drawToAllPartsToggled( bool active )
549{
550 mCallout->setDrawCalloutToAllParts( active );
551 emit changed();
552}
553
554
555//
556// QgsBalloonCalloutWidget
557//
558
559QgsBalloonCalloutWidget::QgsBalloonCalloutWidget( QgsMapLayer *vl, QWidget *parent )
560 : QgsCalloutWidget( parent, vl )
561{
562 setupUi( this );
563
564 // Callout options - to move to custom widgets when multiple callout styles exist
565 mCalloutFillStyleButton->setSymbolType( Qgis::SymbolType::Fill );
566 mCalloutFillStyleButton->setDialogTitle( tr( "Balloon Symbol" ) );
567 mCalloutFillStyleButton->registerExpressionContextGenerator( this );
568
569 mMarkerSymbolButton->setSymbolType( Qgis::SymbolType::Marker );
570 mMarkerSymbolButton->setDialogTitle( tr( "Marker Symbol" ) );
571 mMarkerSymbolButton->registerExpressionContextGenerator( this );
572 mMarkerSymbolButton->setShowNull( true );
573 mMarkerSymbolButton->setToNull();
574
575 mCalloutFillStyleButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
576 mMarkerSymbolButton->setLayer( qobject_cast< QgsVectorLayer * >( vl ) );
585
586 mSpinBottomMargin->setClearValue( 0 );
587 mSpinTopMargin->setClearValue( 0 );
588 mSpinRightMargin->setClearValue( 0 );
589 mSpinLeftMargin->setClearValue( 0 );
590 mWedgeWidthSpin->setClearValue( 2.64 );
591 mCornerRadiusSpin->setClearValue( 0.0 );
592
593 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged );
594 connect( mOffsetFromAnchorSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsBalloonCalloutWidget::offsetFromAnchorChanged );
595
596 // Anchor point options
597 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast< int >( QgsCallout::PoleOfInaccessibility ) );
598 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast< int >( QgsCallout::PointOnExterior ) );
599 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast< int >( QgsCallout::PointOnSurface ) );
600 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast< int >( QgsCallout::Centroid ) );
601 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
602
603 connect( mCalloutFillStyleButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::fillSymbolChanged );
604 connect( mMarkerSymbolButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::markerSymbolChanged );
605
606 connect( mSpinBottomMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
607 {
608 QgsMargins margins = mCallout->margins();
609 margins.setBottom( value );
610 mCallout->setMargins( margins );
611 emit changed();
612 } );
613 connect( mSpinTopMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
614 {
615 QgsMargins margins = mCallout->margins();
616 margins.setTop( value );
617 mCallout->setMargins( margins );
618 emit changed();
619 } );
620 connect( mSpinLeftMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
621 {
622 QgsMargins margins = mCallout->margins();
623 margins.setLeft( value );
624 mCallout->setMargins( margins );
625 emit changed();
626 } );
627 connect( mSpinRightMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
628 {
629 QgsMargins margins = mCallout->margins();
630 margins.setRight( value );
631 mCallout->setMargins( margins );
632 emit changed();
633 } );
634 connect( mMarginUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
635 {
636 mCallout->setMarginsUnit( mMarginUnitWidget->unit() );
637 emit changed();
638 } );
639
640 connect( mWedgeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
641 {
642 mCallout->setWedgeWidthUnit( mWedgeWidthUnitWidget->unit() );
643 mCallout->setWedgeWidthMapUnitScale( mWedgeWidthUnitWidget->getMapUnitScale() );
644 emit changed();
645 } );
646 connect( mWedgeWidthSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
647 {
648 mCallout->setWedgeWidth( value );
649 emit changed();
650 } );
651
652 connect( mCornerRadiusUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
653 {
654 mCallout->setCornerRadiusUnit( mCornerRadiusUnitWidget->unit() );
655 mCallout->setCornerRadiusMapUnitScale( mCornerRadiusUnitWidget->getMapUnitScale() );
656 emit changed();
657 } );
658 connect( mCornerRadiusSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
659 {
660 mCallout->setCornerRadius( value );
661 emit changed();
662 } );
663
664 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
665
666 mPlacementDDGroupBox->setVisible( qobject_cast< QgsVectorLayer * >( vl ) );
667}
668
669void QgsBalloonCalloutWidget::setCallout( const QgsCallout *callout )
670{
671 if ( !callout )
672 return;
673
674 mCallout.reset( dynamic_cast<QgsBalloonCallout *>( callout->clone() ) );
675 if ( !mCallout )
676 return;
677
678 mOffsetFromAnchorUnitWidget->blockSignals( true );
679 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
680 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
681 mOffsetFromAnchorUnitWidget->blockSignals( false );
682 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
683
684 whileBlocking( mSpinBottomMargin )->setValue( mCallout->margins().bottom() );
685 whileBlocking( mSpinTopMargin )->setValue( mCallout->margins().top() );
686 whileBlocking( mSpinLeftMargin )->setValue( mCallout->margins().left() );
687 whileBlocking( mSpinRightMargin )->setValue( mCallout->margins().right() );
688 whileBlocking( mMarginUnitWidget )->setUnit( mCallout->marginsUnit() );
689
690 mWedgeWidthUnitWidget->blockSignals( true );
691 mWedgeWidthUnitWidget->setUnit( mCallout->wedgeWidthUnit() );
692 mWedgeWidthUnitWidget->setMapUnitScale( mCallout->wedgeWidthMapUnitScale() );
693 mWedgeWidthUnitWidget->blockSignals( false );
694 whileBlocking( mWedgeWidthSpin )->setValue( mCallout->wedgeWidth() );
695
696 mCornerRadiusUnitWidget->blockSignals( true );
697 mCornerRadiusUnitWidget->setUnit( mCallout->cornerRadiusUnit() );
698 mCornerRadiusUnitWidget->setMapUnitScale( mCallout->cornerRadiusMapUnitScale() );
699 mCornerRadiusUnitWidget->blockSignals( false );
700 whileBlocking( mCornerRadiusSpin )->setValue( mCallout->cornerRadius() );
701
702 whileBlocking( mCalloutFillStyleButton )->setSymbol( mCallout->fillSymbol()->clone() );
703 if ( QgsMarkerSymbol *marker = mCallout->markerSymbol() )
704 whileBlocking( mMarkerSymbolButton )->setSymbol( marker->clone() );
705 else
706 whileBlocking( mMarkerSymbolButton )->setToNull();
707
708 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast< int >( callout->anchorPoint() ) ) );
709
710 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
711
712 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
713 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
714 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
715
716 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
717 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
718 registerDataDefinedButton( mMarginsDDBtn, QgsCallout::Property::Margins );
719 registerDataDefinedButton( mWedgeWidthDDBtn, QgsCallout::Property::WedgeWidth );
720 registerDataDefinedButton( mCornerRadiusDDBtn, QgsCallout::Property::CornerRadius );
721}
722
723void QgsBalloonCalloutWidget::setGeometryType( Qgis::GeometryType type )
724{
725 const bool isPolygon = type == Qgis::GeometryType::Polygon;
726 mAnchorPointLbl->setEnabled( isPolygon );
727 mAnchorPointLbl->setVisible( isPolygon );
728 mAnchorPointComboBox->setEnabled( isPolygon );
729 mAnchorPointComboBox->setVisible( isPolygon );
730 mAnchorPointDDBtn->setEnabled( isPolygon );
731 mAnchorPointDDBtn->setVisible( isPolygon );
732}
733
734QgsCallout *QgsBalloonCalloutWidget::callout()
735{
736 return mCallout.get();
737}
738
739void QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged()
740{
741 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
742 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
743 emit changed();
744}
745
746void QgsBalloonCalloutWidget::offsetFromAnchorChanged()
747{
748 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
749 emit changed();
750}
751
752void QgsBalloonCalloutWidget::fillSymbolChanged()
753{
754 mCallout->setFillSymbol( mCalloutFillStyleButton->clonedSymbol< QgsFillSymbol >() );
755 emit changed();
756}
757
758void QgsBalloonCalloutWidget::markerSymbolChanged()
759{
760 mCallout->setMarkerSymbol( mMarkerSymbolButton->isNull() ? nullptr : mMarkerSymbolButton->clonedSymbol< QgsMarkerSymbol >() );
761 emit changed();
762}
763
764void QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
765{
766 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
767 emit changed();
768}
769
770void QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
771{
772 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
773 emit changed();
774}
775
777
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:5761
Single variable definition for use within a QgsExpressionContextScope.