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