30 return *lExpressionContext;
35 expContext << symbolScope;
55 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
56 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
58 unitWidget->setMapCanvas( mContext.
mapCanvas() );
60 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
63 symbolWidget->setMapCanvas( mContext.
mapCanvas() );
64 symbolWidget->setMessageBar( mContext.
messageBar() );
82 void QgsCalloutWidget::createAuxiliaryField()
108 property.setActive(
true );
117 void QgsCalloutWidget::updateDataDefinedProperty()
131 QgsSimpleLineCalloutWidget::QgsSimpleLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
138 mCalloutLineStyleButton->setDialogTitle( tr(
"Callout Symbol" ) );
139 mCalloutLineStyleButton->registerExpressionContextGenerator(
this );
141 mCalloutLineStyleButton->setLayer( vl );
150 connect( mMinCalloutLengthSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::minimumLengthChanged );
153 connect( mOffsetFromAnchorSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::offsetFromAnchorChanged );
155 connect( mOffsetFromLabelSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::offsetFromLabelChanged );
157 connect( mDrawToAllPartsCheck, &QCheckBox::toggled,
this, &QgsSimpleLineCalloutWidget::drawToAllPartsToggled );
164 connect( mAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
176 connect( mLabelAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
178 connect( mCalloutLineStyleButton, &
QgsSymbolButton::changed,
this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
180 connect( mCalloutBlendComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
183 void QgsSimpleLineCalloutWidget::setCallout(
QgsCallout *callout )
192 mMinCalloutWidthUnitWidget->blockSignals(
true );
193 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
194 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
195 mMinCalloutWidthUnitWidget->blockSignals(
false );
197 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
199 mOffsetFromAnchorUnitWidget->blockSignals(
true );
200 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
201 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
202 mOffsetFromAnchorUnitWidget->blockSignals(
false );
203 mOffsetFromLabelUnitWidget->blockSignals(
true );
204 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
205 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
206 mOffsetFromLabelUnitWidget->blockSignals(
false );
207 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
208 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
210 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
212 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
214 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData(
static_cast< int >( callout->
anchorPoint() ) ) );
215 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData(
static_cast< int >( callout->
labelAnchorPoint() ) ) );
217 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
236 mAnchorPointLbl->setEnabled( isPolygon );
237 mAnchorPointLbl->setVisible( isPolygon );
238 mAnchorPointComboBox->setEnabled( isPolygon );
239 mAnchorPointComboBox->setVisible( isPolygon );
240 mAnchorPointDDBtn->setEnabled( isPolygon );
241 mAnchorPointDDBtn->setVisible( isPolygon );
244 QgsCallout *QgsSimpleLineCalloutWidget::callout()
246 return mCallout.get();
249 void QgsSimpleLineCalloutWidget::minimumLengthChanged()
251 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
255 void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
257 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
258 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
262 void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
264 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
265 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
269 void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
271 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
275 void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
277 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
278 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
282 void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
284 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
288 void QgsSimpleLineCalloutWidget::lineSymbolChanged()
290 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<
QgsLineSymbol >() );
294 void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged(
int index )
296 mCallout->setAnchorPoint(
static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
300 void QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged(
int index )
306 void QgsSimpleLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged(
int )
308 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
312 void QgsSimpleLineCalloutWidget::drawToAllPartsToggled(
bool active )
314 mCallout->setDrawCalloutToAllParts( active );
323 QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
324 : QgsSimpleLineCalloutWidget( vl, parent )
334 QgsCurvedLineCalloutWidget::QgsCurvedLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
341 mCalloutLineStyleButton->setDialogTitle( tr(
"Callout Symbol" ) );
342 mCalloutLineStyleButton->registerExpressionContextGenerator(
this );
344 mCalloutLineStyleButton->setLayer( vl );
353 connect( mMinCalloutLengthSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsCurvedLineCalloutWidget::minimumLengthChanged );
356 connect( mOffsetFromAnchorSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsCurvedLineCalloutWidget::offsetFromAnchorChanged );
358 connect( mOffsetFromLabelSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsCurvedLineCalloutWidget::offsetFromLabelChanged );
360 connect( mDrawToAllPartsCheck, &QCheckBox::toggled,
this, &QgsCurvedLineCalloutWidget::drawToAllPartsToggled );
365 connect( mOrientationComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int index )
376 connect( mAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
388 connect( mLabelAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
390 connect( mCalloutLineStyleButton, &
QgsSymbolButton::changed,
this, &QgsCurvedLineCalloutWidget::lineSymbolChanged );
392 connect( mCurvatureSlider, &QSlider::valueChanged,
this, [ = ](
int value ) { mCurvatureSpinBox->setValue( value / 10.0 ); } );
393 connect( mCurvatureSpinBox,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
double value ) {
whileBlocking( mCurvatureSlider )->setValue( value * 10 ); } );
394 connect( mCurvatureSpinBox,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
396 mCallout->setCurvature( value / 100.0 );
400 connect( mCalloutBlendComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
403 void QgsCurvedLineCalloutWidget::setCallout(
QgsCallout *callout )
412 mMinCalloutWidthUnitWidget->blockSignals(
true );
413 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
414 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
415 mMinCalloutWidthUnitWidget->blockSignals(
false );
417 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
419 mOffsetFromAnchorUnitWidget->blockSignals(
true );
420 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
421 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
422 mOffsetFromAnchorUnitWidget->blockSignals(
false );
423 mOffsetFromLabelUnitWidget->blockSignals(
true );
424 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
425 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
426 mOffsetFromLabelUnitWidget->blockSignals(
false );
427 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
428 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
430 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
432 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
434 whileBlocking( mOrientationComboBox )->setCurrentIndex( mOrientationComboBox->findData(
static_cast< int >( mCallout->orientation() ) ) );
436 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData(
static_cast< int >( callout->
anchorPoint() ) ) );
437 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData(
static_cast< int >( callout->
labelAnchorPoint() ) ) );
439 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
441 whileBlocking( mCurvatureSpinBox )->setValue( mCallout->curvature() * 100.0 );
442 whileBlocking( mCurvatureSlider )->setValue( mCallout->curvature() * 1000.0 );
463 mAnchorPointLbl->setEnabled( isPolygon );
464 mAnchorPointLbl->setVisible( isPolygon );
465 mAnchorPointComboBox->setEnabled( isPolygon );
466 mAnchorPointComboBox->setVisible( isPolygon );
467 mAnchorPointDDBtn->setEnabled( isPolygon );
468 mAnchorPointDDBtn->setVisible( isPolygon );
471 QgsCallout *QgsCurvedLineCalloutWidget::callout()
473 return mCallout.get();
476 void QgsCurvedLineCalloutWidget::minimumLengthChanged()
478 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
482 void QgsCurvedLineCalloutWidget::minimumLengthUnitWidgetChanged()
484 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
485 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
489 void QgsCurvedLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
491 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
492 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
496 void QgsCurvedLineCalloutWidget::offsetFromAnchorChanged()
498 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
502 void QgsCurvedLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
504 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
505 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
509 void QgsCurvedLineCalloutWidget::offsetFromLabelChanged()
511 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
515 void QgsCurvedLineCalloutWidget::lineSymbolChanged()
517 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<
QgsLineSymbol >() );
521 void QgsCurvedLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged(
int index )
523 mCallout->setAnchorPoint(
static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
527 void QgsCurvedLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged(
int index )
533 void QgsCurvedLineCalloutWidget::mCalloutBlendComboBox_currentIndexChanged(
int )
535 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );
539 void QgsCurvedLineCalloutWidget::drawToAllPartsToggled(
bool active )
541 mCallout->setDrawCalloutToAllParts( active );
550 QgsBalloonCalloutWidget::QgsBalloonCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
557 mCalloutFillStyleButton->setDialogTitle( tr(
"Balloon Symbol" ) );
558 mCalloutFillStyleButton->registerExpressionContextGenerator(
this );
560 mCalloutFillStyleButton->setLayer( vl );
570 mSpinBottomMargin->setClearValue( 0 );
571 mSpinTopMargin->setClearValue( 0 );
572 mSpinRightMargin->setClearValue( 0 );
573 mSpinLeftMargin->setClearValue( 0 );
574 mWedgeWidthSpin->setClearValue( 2.64 );
575 mCornerRadiusSpin->setClearValue( 0.0 );
578 connect( mOffsetFromAnchorSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsBalloonCalloutWidget::offsetFromAnchorChanged );
585 connect( mAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
589 connect( mSpinBottomMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
593 mCallout->setMargins( margins );
596 connect( mSpinTopMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
600 mCallout->setMargins( margins );
603 connect( mSpinLeftMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
607 mCallout->setMargins( margins );
610 connect( mSpinRightMargin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
614 mCallout->setMargins( margins );
619 mCallout->setMarginsUnit( mMarginUnitWidget->unit() );
625 mCallout->setWedgeWidthUnit( mWedgeWidthUnitWidget->unit() );
626 mCallout->setWedgeWidthMapUnitScale( mWedgeWidthUnitWidget->getMapUnitScale() );
629 connect( mWedgeWidthSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
631 mCallout->setWedgeWidth( value );
637 mCallout->setCornerRadiusUnit( mCornerRadiusUnitWidget->unit() );
638 mCallout->setCornerRadiusMapUnitScale( mCornerRadiusUnitWidget->getMapUnitScale() );
641 connect( mCornerRadiusSpin, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double value )
643 mCallout->setCornerRadius( value );
647 connect( mCalloutBlendComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged );
650 void QgsBalloonCalloutWidget::setCallout(
QgsCallout *callout )
659 mOffsetFromAnchorUnitWidget->blockSignals(
true );
660 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
661 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
662 mOffsetFromAnchorUnitWidget->blockSignals(
false );
663 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
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() );
671 mWedgeWidthUnitWidget->blockSignals(
true );
672 mWedgeWidthUnitWidget->setUnit( mCallout->wedgeWidthUnit() );
673 mWedgeWidthUnitWidget->setMapUnitScale( mCallout->wedgeWidthMapUnitScale() );
674 mWedgeWidthUnitWidget->blockSignals(
false );
675 whileBlocking( mWedgeWidthSpin )->setValue( mCallout->wedgeWidth() );
677 mCornerRadiusUnitWidget->blockSignals(
true );
678 mCornerRadiusUnitWidget->setUnit( mCallout->cornerRadiusUnit() );
679 mCornerRadiusUnitWidget->setMapUnitScale( mCallout->cornerRadiusMapUnitScale() );
680 mCornerRadiusUnitWidget->blockSignals(
false );
681 whileBlocking( mCornerRadiusSpin )->setValue( mCallout->cornerRadius() );
683 whileBlocking( mCalloutFillStyleButton )->setSymbol( mCallout->fillSymbol()->clone() );
685 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData(
static_cast< int >( callout->
anchorPoint() ) ) );
687 whileBlocking( mCalloutBlendComboBox )->setBlendMode( mCallout->blendMode() );
703 mAnchorPointLbl->setEnabled( isPolygon );
704 mAnchorPointLbl->setVisible( isPolygon );
705 mAnchorPointComboBox->setEnabled( isPolygon );
706 mAnchorPointComboBox->setVisible( isPolygon );
707 mAnchorPointDDBtn->setEnabled( isPolygon );
708 mAnchorPointDDBtn->setVisible( isPolygon );
711 QgsCallout *QgsBalloonCalloutWidget::callout()
713 return mCallout.get();
716 void QgsBalloonCalloutWidget::offsetFromAnchorUnitWidgetChanged()
718 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
719 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
723 void QgsBalloonCalloutWidget::offsetFromAnchorChanged()
725 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
729 void QgsBalloonCalloutWidget::fillSymbolChanged()
731 mCallout->setFillSymbol( mCalloutFillStyleButton->clonedSymbol<
QgsFillSymbol >() );
735 void QgsBalloonCalloutWidget::mAnchorPointComboBox_currentIndexChanged(
int index )
737 mCallout->setAnchorPoint(
static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
741 void QgsBalloonCalloutWidget::mCalloutBlendComboBox_currentIndexChanged(
int )
743 mCallout->setBlendMode( mCalloutBlendComboBox->blendMode() );