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