QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
18#include "qgsauxiliarystorage.h"
19#include "qgscallout.h"
21#include "qgsfillsymbol.h"
22#include "qgslinesymbol.h"
23#include "qgsmarkersymbol.h"
27#include "qgsvectorlayer.h"
28
29#include "moc_qgscalloutwidget.cpp"
30
32{
33 if ( auto *lExpressionContext = mContext.expressionContext() )
34 return *lExpressionContext;
35
36 QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( layer() ) );
39 expContext << symbolScope;
40
41 // additional scopes
42 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
43 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
44 {
45 expContext.appendScope( new QgsExpressionContextScope( scope ) );
46 }
47
48 //TODO - show actual value
49 expContext.setOriginalValueVariable( QVariant() );
50
52
53 return expContext;
54}
55
57{
58 mContext = context;
59 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
60 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
61 {
62 unitWidget->setMapCanvas( mContext.mapCanvas() );
63 }
64 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
65 for ( QgsSymbolButton *symbolWidget : symbolButtonWidgets )
66 {
67 symbolWidget->setMapCanvas( mContext.mapCanvas() );
68 symbolWidget->setMessageBar( mContext.messageBar() );
69 }
70}
71
73{
74 return mContext;
75}
76
78{
79 button->init( static_cast<int>( key ), callout()->dataDefinedProperties(), QgsCallout::propertyDefinitions(), qobject_cast<QgsVectorLayer *>( mLayer ), true );
80 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsCalloutWidget::updateDataDefinedProperty );
81 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsCalloutWidget::createAuxiliaryField );
82
84}
85
86void QgsCalloutWidget::createAuxiliaryField()
87{
88 // try to create an auxiliary layer if not yet created
89 QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( mLayer );
90 if ( !vectorLayer )
91 return;
92
94 {
96 dlg.exec();
97 }
98
99 // return if still not exists
100 if ( !vectorLayer->auxiliaryLayer() )
101 return;
102
103 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
104 const QgsCallout::Property key = static_cast<QgsCallout::Property>( button->propertyKey() );
105 const QgsPropertyDefinition def = QgsCallout::propertyDefinitions()[static_cast<int>( key )];
106
107 // create property in auxiliary storage if necessary
108 if ( !vectorLayer->auxiliaryLayer()->exists( def ) )
109 {
110 vectorLayer->auxiliaryLayer()->addAuxiliaryField( def );
111 }
112
113 // update property with join field name from auxiliary storage
114 QgsProperty property = button->toProperty();
115 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
116 property.setActive( true );
117 button->updateFieldLists();
118 button->setToProperty( property );
119
121
122 emit changed();
123}
124
125void QgsCalloutWidget::updateDataDefinedProperty()
126{
127 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
128 const QgsCallout::Property key = static_cast<QgsCallout::Property>( button->propertyKey() );
130 emit changed();
131}
132
134
135//
136// QgsSimpleLineCalloutWidget
137//
138
139QgsSimpleLineCalloutWidget::QgsSimpleLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
140 : QgsCalloutWidget( parent, vl )
141{
142 setupUi( this );
143
144 // Callout options - to move to custom widgets when multiple callout styles exist
145 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
146 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
147 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
148
149 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// QgsCurvedLineCalloutWidget
338//
339
340QgsCurvedLineCalloutWidget::QgsCurvedLineCalloutWidget( QgsMapLayer *vl, QWidget *parent )
341 : QgsCalloutWidget( parent, vl )
342{
343 setupUi( this );
344
345 // Callout options - to move to custom widgets when multiple callout styles exist
346 mCalloutLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
347 mCalloutLineStyleButton->setDialogTitle( tr( "Callout Symbol" ) );
348 mCalloutLineStyleButton->registerExpressionContextGenerator( this );
349
350 mCalloutLineStyleButton->setLayer( qobject_cast<QgsVectorLayer *>( vl ) );
354
355 connect( mMinCalloutWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged );
356 connect( mMinCalloutLengthSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::minimumLengthChanged );
357
358 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged );
359 connect( mOffsetFromAnchorSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromAnchorChanged );
360 connect( mOffsetFromLabelUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged );
361 connect( mOffsetFromLabelSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsCurvedLineCalloutWidget::offsetFromLabelChanged );
362
363 connect( mDrawToAllPartsCheck, &QCheckBox::toggled, this, &QgsCurvedLineCalloutWidget::drawToAllPartsToggled );
364
365 mOrientationComboBox->addItem( tr( "Automatic" ), static_cast<int>( QgsCurvedLineCallout::Automatic ) );
366 mOrientationComboBox->addItem( tr( "Clockwise" ), static_cast<int>( QgsCurvedLineCallout::Clockwise ) );
367 mOrientationComboBox->addItem( tr( "Counter Clockwise" ), static_cast<int>( QgsCurvedLineCallout::CounterClockwise ) );
368 connect( mOrientationComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [this]( int index ) {
369 mCallout->setOrientation( static_cast<QgsCurvedLineCallout::Orientation>( mOrientationComboBox->itemData( index ).toInt() ) );
370 emit changed();
371 } );
372
373 // Anchor point options
374 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast<int>( QgsCallout::PoleOfInaccessibility ) );
375 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast<int>( QgsCallout::PointOnExterior ) );
376 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast<int>( QgsCallout::PointOnSurface ) );
377 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::Centroid ) );
378 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
379
380 mLabelAnchorPointComboBox->addItem( tr( "Closest Point" ), static_cast<int>( QgsCallout::LabelPointOnExterior ) );
381 mLabelAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::LabelCentroid ) );
382 mLabelAnchorPointComboBox->addItem( tr( "Top Left" ), static_cast<int>( QgsCallout::LabelTopLeft ) );
383 mLabelAnchorPointComboBox->addItem( tr( "Top Center" ), static_cast<int>( QgsCallout::LabelTopMiddle ) );
384 mLabelAnchorPointComboBox->addItem( tr( "Top Right" ), static_cast<int>( QgsCallout::LabelTopRight ) );
385 mLabelAnchorPointComboBox->addItem( tr( "Left Middle" ), static_cast<int>( QgsCallout::LabelMiddleLeft ) );
386 mLabelAnchorPointComboBox->addItem( tr( "Right Middle" ), static_cast<int>( QgsCallout::LabelMiddleRight ) );
387 mLabelAnchorPointComboBox->addItem( tr( "Bottom Left" ), static_cast<int>( QgsCallout::LabelBottomLeft ) );
388 mLabelAnchorPointComboBox->addItem( tr( "Bottom Center" ), static_cast<int>( QgsCallout::LabelBottomMiddle ) );
389 mLabelAnchorPointComboBox->addItem( tr( "Bottom Right" ), static_cast<int>( QgsCallout::LabelBottomRight ) );
390 connect( mLabelAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
391
392 connect( mCalloutLineStyleButton, &QgsSymbolButton::changed, this, &QgsCurvedLineCalloutWidget::lineSymbolChanged );
393
394 connect( mCurvatureSlider, &QSlider::valueChanged, this, [this]( int value ) { mCurvatureSpinBox->setValue( value / 10.0 ); } );
395 connect( mCurvatureSpinBox, static_cast<void ( QgsDoubleSpinBox::* )( double )>( &QgsDoubleSpinBox::valueChanged ), this, [this]( double value ) { whileBlocking( mCurvatureSlider )->setValue( value * 10 ); } );
396 connect( mCurvatureSpinBox, static_cast<void ( QgsDoubleSpinBox::* )( double )>( &QgsDoubleSpinBox::valueChanged ), this, [this]( double value ) {
397 mCallout->setCurvature( value / 100.0 );
398 emit changed();
399 } );
400
401 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
402
403 mPlacementDDGroupBox->setVisible( qobject_cast<QgsVectorLayer *>( vl ) );
404}
405
406void QgsCurvedLineCalloutWidget::setCallout( const QgsCallout *callout )
407{
408 if ( !callout )
409 return;
410
411 mCallout.reset( dynamic_cast<QgsCurvedLineCallout *>( callout->clone() ) );
412 if ( !mCallout )
413 return;
414
415 mMinCalloutWidthUnitWidget->blockSignals( true );
416 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
417 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
418 mMinCalloutWidthUnitWidget->blockSignals( false );
419
420 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
421
422 mOffsetFromAnchorUnitWidget->blockSignals( true );
423 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
424 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
425 mOffsetFromAnchorUnitWidget->blockSignals( false );
426 mOffsetFromLabelUnitWidget->blockSignals( true );
427 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
428 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
429 mOffsetFromLabelUnitWidget->blockSignals( false );
430 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
431 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
432
433 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
434
435 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
436
437 whileBlocking( mOrientationComboBox )->setCurrentIndex( mOrientationComboBox->findData( static_cast<int>( mCallout->orientation() ) ) );
438
439 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast<int>( callout->anchorPoint() ) ) );
440 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData( static_cast<int>( callout->labelAnchorPoint() ) ) );
441
442 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
443
444 whileBlocking( mCurvatureSpinBox )->setValue( mCallout->curvature() * 100.0 );
445 whileBlocking( mCurvatureSlider )->setValue( mCallout->curvature() * 1000.0 );
446
447 registerDataDefinedButton( mMinCalloutLengthDDBtn, QgsCallout::Property::MinimumCalloutLength );
448 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
449 registerDataDefinedButton( mOffsetFromLabelDDBtn, QgsCallout::Property::OffsetFromLabel );
450 registerDataDefinedButton( mDrawToAllPartsDDBtn, QgsCallout::Property::DrawCalloutToAllParts );
451 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
452 registerDataDefinedButton( mLabelAnchorPointDDBtn, QgsCallout::Property::LabelAnchorPointPosition );
453 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
454 registerDataDefinedButton( mCalloutCurvatureDDBtn, QgsCallout::Property::Curvature );
455 registerDataDefinedButton( mCalloutOrientationDDBtn, QgsCallout::Property::Orientation );
456
457 registerDataDefinedButton( mOriginXDDBtn, QgsCallout::Property::OriginX );
458 registerDataDefinedButton( mOriginYDDBtn, QgsCallout::Property::OriginY );
459 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
460 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
461}
462
463void QgsCurvedLineCalloutWidget::setGeometryType( Qgis::GeometryType type )
464{
465 const bool isPolygon = type == Qgis::GeometryType::Polygon;
466 mAnchorPointLbl->setEnabled( isPolygon );
467 mAnchorPointLbl->setVisible( isPolygon );
468 mAnchorPointComboBox->setEnabled( isPolygon );
469 mAnchorPointComboBox->setVisible( isPolygon );
470 mAnchorPointDDBtn->setEnabled( isPolygon );
471 mAnchorPointDDBtn->setVisible( isPolygon );
472}
473
474QgsCallout *QgsCurvedLineCalloutWidget::callout()
475{
476 return mCallout.get();
477}
478
479void QgsCurvedLineCalloutWidget::minimumLengthChanged()
480{
481 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
482 emit changed();
483}
484
485void QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged()
486{
487 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
488 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
489 emit changed();
490}
491
492void QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
493{
494 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
495 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
496 emit changed();
497}
498
499void QgsCurvedLineCalloutWidget::offsetFromAnchorChanged()
500{
501 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
502 emit changed();
503}
504
505void QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
506{
507 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
508 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
509 emit changed();
510}
511
512void QgsCurvedLineCalloutWidget::offsetFromLabelChanged()
513{
514 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
515 emit changed();
516}
517
518void QgsCurvedLineCalloutWidget::lineSymbolChanged()
519{
520 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<QgsLineSymbol>() );
521 emit changed();
522}
523
524void QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
525{
526 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
527 emit changed();
528}
529
530void QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged( int index )
531{
532 mCallout->setLabelAnchorPoint( static_cast<QgsCallout::LabelAnchorPoint>( mLabelAnchorPointComboBox->itemData( index ).toInt() ) );
533 emit changed();
534}
535
536void QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
537{
538 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
539 emit changed();
540}
541
542void QgsCurvedLineCalloutWidget::drawToAllPartsToggled( bool active )
543{
544 mCallout->setDrawCalloutToAllParts( active );
545 emit changed();
546}
547
548
549//
550// QgsBalloonCalloutWidget
551//
552
553QgsBalloonCalloutWidget::QgsBalloonCalloutWidget( QgsMapLayer *vl, QWidget *parent )
554 : QgsCalloutWidget( parent, vl )
555{
556 setupUi( this );
557
558 // Callout options - to move to custom widgets when multiple callout styles exist
559 mCalloutFillStyleButton->setSymbolType( Qgis::SymbolType::Fill );
560 mCalloutFillStyleButton->setDialogTitle( tr( "Balloon Symbol" ) );
561 mCalloutFillStyleButton->registerExpressionContextGenerator( this );
562
563 mMarkerSymbolButton->setSymbolType( Qgis::SymbolType::Marker );
564 mMarkerSymbolButton->setDialogTitle( tr( "Marker Symbol" ) );
565 mMarkerSymbolButton->registerExpressionContextGenerator( this );
566 mMarkerSymbolButton->setShowNull( true );
567 mMarkerSymbolButton->setToNull();
568
569 mCalloutFillStyleButton->setLayer( qobject_cast<QgsVectorLayer *>( vl ) );
570 mMarkerSymbolButton->setLayer( qobject_cast<QgsVectorLayer *>( vl ) );
575
576 mSpinBottomMargin->setClearValue( 0 );
577 mSpinTopMargin->setClearValue( 0 );
578 mSpinRightMargin->setClearValue( 0 );
579 mSpinLeftMargin->setClearValue( 0 );
580 mWedgeWidthSpin->setClearValue( 2.64 );
581 mCornerRadiusSpin->setClearValue( 0.0 );
582
583 connect( mOffsetFromAnchorUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged );
584 connect( mOffsetFromAnchorSpin, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsBalloonCalloutWidget::offsetFromAnchorChanged );
585
586 // Anchor point options
587 mAnchorPointComboBox->addItem( tr( "Pole of Inaccessibility" ), static_cast<int>( QgsCallout::PoleOfInaccessibility ) );
588 mAnchorPointComboBox->addItem( tr( "Point on Exterior" ), static_cast<int>( QgsCallout::PointOnExterior ) );
589 mAnchorPointComboBox->addItem( tr( "Point on Surface" ), static_cast<int>( QgsCallout::PointOnSurface ) );
590 mAnchorPointComboBox->addItem( tr( "Centroid" ), static_cast<int>( QgsCallout::Centroid ) );
591 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
592
593 connect( mCalloutFillStyleButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::fillSymbolChanged );
594 connect( mMarkerSymbolButton, &QgsSymbolButton::changed, this, &QgsBalloonCalloutWidget::markerSymbolChanged );
595
596 connect( mSpinBottomMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
597 QgsMargins margins = mCallout->margins();
598 margins.setBottom( value );
599 mCallout->setMargins( margins );
600 emit changed();
601 } );
602 connect( mSpinTopMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
603 QgsMargins margins = mCallout->margins();
604 margins.setTop( value );
605 mCallout->setMargins( margins );
606 emit changed();
607 } );
608 connect( mSpinLeftMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
609 QgsMargins margins = mCallout->margins();
610 margins.setLeft( value );
611 mCallout->setMargins( margins );
612 emit changed();
613 } );
614 connect( mSpinRightMargin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
615 QgsMargins margins = mCallout->margins();
616 margins.setRight( value );
617 mCallout->setMargins( margins );
618 emit changed();
619 } );
620 connect( mMarginUnitWidget, &QgsUnitSelectionWidget::changed, this, [this] {
621 mCallout->setMarginsUnit( mMarginUnitWidget->unit() );
622 emit changed();
623 } );
624
625 connect( mWedgeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, [this] {
626 mCallout->setWedgeWidthUnit( mWedgeWidthUnitWidget->unit() );
627 mCallout->setWedgeWidthMapUnitScale( mWedgeWidthUnitWidget->getMapUnitScale() );
628 emit changed();
629 } );
630 connect( mWedgeWidthSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
631 mCallout->setWedgeWidth( value );
632 emit changed();
633 } );
634
635 connect( mCornerRadiusUnitWidget, &QgsUnitSelectionWidget::changed, this, [this] {
636 mCallout->setCornerRadiusUnit( mCornerRadiusUnitWidget->unit() );
637 mCallout->setCornerRadiusMapUnitScale( mCornerRadiusUnitWidget->getMapUnitScale() );
638 emit changed();
639 } );
640 connect( mCornerRadiusSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [this]( double value ) {
641 mCallout->setCornerRadius( value );
642 emit changed();
643 } );
644
645 connect( mCalloutBlendComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
646
647 mPlacementDDGroupBox->setVisible( qobject_cast<QgsVectorLayer *>( vl ) );
648}
649
650void QgsBalloonCalloutWidget::setCallout( const 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 if ( QgsMarkerSymbol *marker = mCallout->markerSymbol() )
685 whileBlocking( mMarkerSymbolButton )->setSymbol( marker->clone() );
686 else
687 whileBlocking( mMarkerSymbolButton )->setToNull();
688
689 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData( static_cast<int>( callout->anchorPoint() ) ) );
690
691 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
692
693 registerDataDefinedButton( mOffsetFromAnchorDDBtn, QgsCallout::Property::OffsetFromAnchor );
694 registerDataDefinedButton( mAnchorPointDDBtn, QgsCallout::Property::AnchorPointPosition );
695 registerDataDefinedButton( mCalloutBlendModeDDBtn, QgsCallout::Property::BlendMode );
696
697 registerDataDefinedButton( mDestXDDBtn, QgsCallout::Property::DestinationX );
698 registerDataDefinedButton( mDestYDDBtn, QgsCallout::Property::DestinationY );
699 registerDataDefinedButton( mMarginsDDBtn, QgsCallout::Property::Margins );
700 registerDataDefinedButton( mWedgeWidthDDBtn, QgsCallout::Property::WedgeWidth );
701 registerDataDefinedButton( mCornerRadiusDDBtn, QgsCallout::Property::CornerRadius );
702}
703
704void QgsBalloonCalloutWidget::setGeometryType( Qgis::GeometryType type )
705{
706 const bool isPolygon = type == Qgis::GeometryType::Polygon;
707 mAnchorPointLbl->setEnabled( isPolygon );
708 mAnchorPointLbl->setVisible( isPolygon );
709 mAnchorPointComboBox->setEnabled( isPolygon );
710 mAnchorPointComboBox->setVisible( isPolygon );
711 mAnchorPointDDBtn->setEnabled( isPolygon );
712 mAnchorPointDDBtn->setVisible( isPolygon );
713}
714
715QgsCallout *QgsBalloonCalloutWidget::callout()
716{
717 return mCallout.get();
718}
719
720void QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged()
721{
722 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
723 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
724 emit changed();
725}
726
727void QgsBalloonCalloutWidget::offsetFromAnchorChanged()
728{
729 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
730 emit changed();
731}
732
733void QgsBalloonCalloutWidget::fillSymbolChanged()
734{
735 mCallout->setFillSymbol( mCalloutFillStyleButton->clonedSymbol<QgsFillSymbol>() );
736 emit changed();
737}
738
739void QgsBalloonCalloutWidget::markerSymbolChanged()
740{
741 mCallout->setMarkerSymbol( mMarkerSymbolButton->isNull() ? nullptr : mMarkerSymbolButton->clonedSymbol<QgsMarkerSymbol>() );
742 emit changed();
743}
744
745void QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged( int index )
746{
747 mCallout->setAnchorPoint( static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
748 emit changed();
749}
750
751void QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged( int )
752{
753 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
754 emit changed();
755}
756
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
@ Polygon
Polygons.
Definition qgis.h:361
@ Millimeters
Millimeters.
Definition qgis.h:5184
@ Points
Points (e.g., for font sizes).
Definition qgis.h:5188
@ MapUnits
Map units.
Definition qgis.h:5185
@ Pixels
Pixels.
Definition qgis.h:5186
@ Inches
Inches.
Definition qgis.h:5189
@ MetersInMapUnits
Meters value as Map units.
Definition qgis.h:5191
@ Marker
Marker symbol.
Definition qgis.h:611
@ Line
Line symbol.
Definition qgis.h:612
@ Fill
Fill symbol.
Definition qgis.h:613
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
A cartoon talking bubble callout style.
Definition qgscallout.h:881
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:55
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:335
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:365
LabelAnchorPoint labelAnchorPoint() const
Returns the label's anchor point position.
Definition qgscallout.h:398
AnchorPoint
Feature's anchor point position.
Definition qgscallout.h:116
@ PointOnExterior
A point on the surface's outline closest to the label is used as anchor for polygon geometries.
Definition qgscallout.h:118
@ Centroid
The surface's centroid is used as anchor for polygon geometries.
Definition qgscallout.h:120
@ PointOnSurface
A point guaranteed to be on the surface is used as anchor for polygon geometries.
Definition qgscallout.h:119
@ PoleOfInaccessibility
The surface's pole of inaccessibility used as anchor for polygon geometries.
Definition qgscallout.h:117
LabelAnchorPoint
Label's anchor point position.
Definition qgscallout.h:128
@ LabelPointOnExterior
The point on the label's boundary closest to the feature.
Definition qgscallout.h:129
@ LabelBottomLeft
Bottom left corner of the label's boundary.
Definition qgscallout.h:136
@ LabelBottomMiddle
Bottom middle of the label's boundary.
Definition qgscallout.h:137
@ LabelMiddleLeft
Middle left of the label's boundary.
Definition qgscallout.h:134
@ LabelBottomRight
Bottom right corner of the label's boundary.
Definition qgscallout.h:138
@ LabelMiddleRight
Middle right of the label's boundary.
Definition qgscallout.h:135
@ LabelTopMiddle
Top middle of the label's boundary.
Definition qgscallout.h:132
@ LabelTopLeft
Top left corner of the label's boundary.
Definition qgscallout.h:131
@ LabelCentroid
The labe's centroid.
Definition qgscallout.h:130
@ LabelTopRight
Top right corner of the label's boundary.
Definition qgscallout.h:133
Property
Data definable properties.
Definition qgscallout.h:87
@ MinimumCalloutLength
Minimum length of callouts.
Definition qgscallout.h:88
@ LabelAnchorPointPosition
Label's anchor point position.
Definition qgscallout.h:93
@ CornerRadius
Balloon callout corner radius.
Definition qgscallout.h:102
@ OffsetFromAnchor
Distance to offset lines from anchor points.
Definition qgscallout.h:89
@ OffsetFromLabel
Distance to offset lines from label area.
Definition qgscallout.h:90
@ DestinationX
X-coordinate of callout destination (feature anchor).
Definition qgscallout.h:96
@ DestinationY
Y-coordinate of callout destination (feature anchor).
Definition qgscallout.h:97
@ WedgeWidth
Balloon callout wedge width.
Definition qgscallout.h:101
@ AnchorPointPosition
Feature's anchor point position.
Definition qgscallout.h:92
@ OriginX
X-coordinate of callout origin (label anchor).
Definition qgscallout.h:94
@ OriginY
Y-coordinate of callout origin (label anchor).
Definition qgscallout.h:95
@ Curvature
Curvature of curved line callouts.
Definition qgscallout.h:98
@ BlendMode
Callout blend mode.
Definition qgscallout.h:103
@ Orientation
Orientation of curved line callouts.
Definition qgscallout.h:99
@ Margins
Margin from text.
Definition qgscallout.h:100
@ DrawCalloutToAllParts
Whether callout lines should be drawn to all feature parts.
Definition qgscallout.h:91
Draws curved lines as callouts.
Definition qgscallout.h:786
Orientation
Curve orientation.
Definition qgscallout.h:793
@ Clockwise
Curve lines in a clockwise direction.
Definition qgscallout.h:795
@ CounterClockwise
Curve lines in a counter-clockwise direction.
Definition qgscallout.h:796
@ Automatic
Automatically choose most cartographically pleasing orientation based on label and callout arrangemen...
Definition qgscallout.h:794
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:80
void setBottom(double bottom)
Sets the bottom margin to bottom.
Definition qgsmargins.h:114
void setLeft(double left)
Sets the left margin to left.
Definition qgsmargins.h:96
void setRight(double right)
Sets the right margin to right.
Definition qgsmargins.h:108
void setTop(double top)
Sets the top margin to top.
Definition qgsmargins.h:102
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.
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.
void setField(const QString &field)
Sets the field name the property references.
A simple direct line callout style.
Definition qgscallout.h:515
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,...
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 dataset.
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:6511
Single variable definition for use within a QgsExpressionContextScope.