33 expContext << symbolScope;
53 const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
54 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
56 unitWidget->setMapCanvas( mContext.
mapCanvas() );
58 const auto symbolButtonWidgets = findChildren<QgsSymbolButton *>();
61 symbolWidget->setMapCanvas( mContext.
mapCanvas() );
62 symbolWidget->setMessageBar( mContext.
messageBar() );
80 void QgsCalloutWidget::createAuxiliaryField()
101 if ( dlg.exec() == QDialog::Accepted )
102 def = dlg.propertyDefinition();
112 property.setActive(
true );
121 void QgsCalloutWidget::updateDataDefinedProperty()
135 QgsSimpleLineCalloutWidget::QgsSimpleLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
142 mCalloutLineStyleButton->setDialogTitle( tr(
"Callout Symbol" ) );
143 mCalloutLineStyleButton->registerExpressionContextGenerator(
this );
145 mCalloutLineStyleButton->setLayer( vl );
154 connect( mMinCalloutLengthSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::minimumLengthChanged );
157 connect( mOffsetFromAnchorSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::offsetFromAnchorChanged );
159 connect( mOffsetFromLabelSpin,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsSimpleLineCalloutWidget::offsetFromLabelChanged );
161 connect( mDrawToAllPartsCheck, &QCheckBox::toggled,
this, &QgsSimpleLineCalloutWidget::drawToAllPartsToggled );
168 connect( mAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged );
180 connect( mLabelAnchorPointComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged );
182 connect( mCalloutLineStyleButton, &
QgsSymbolButton::changed,
this, &QgsSimpleLineCalloutWidget::lineSymbolChanged );
185 void QgsSimpleLineCalloutWidget::setCallout(
QgsCallout *callout )
194 mMinCalloutWidthUnitWidget->blockSignals(
true );
195 mMinCalloutWidthUnitWidget->setUnit( mCallout->minimumLengthUnit() );
196 mMinCalloutWidthUnitWidget->setMapUnitScale( mCallout->minimumLengthMapUnitScale() );
197 mMinCalloutWidthUnitWidget->blockSignals(
false );
199 whileBlocking( mMinCalloutLengthSpin )->setValue( mCallout->minimumLength() );
201 mOffsetFromAnchorUnitWidget->blockSignals(
true );
202 mOffsetFromAnchorUnitWidget->setUnit( mCallout->offsetFromAnchorUnit() );
203 mOffsetFromAnchorUnitWidget->setMapUnitScale( mCallout->offsetFromAnchorMapUnitScale() );
204 mOffsetFromAnchorUnitWidget->blockSignals(
false );
205 mOffsetFromLabelUnitWidget->blockSignals(
true );
206 mOffsetFromLabelUnitWidget->setUnit( mCallout->offsetFromLabelUnit() );
207 mOffsetFromLabelUnitWidget->setMapUnitScale( mCallout->offsetFromLabelMapUnitScale() );
208 mOffsetFromLabelUnitWidget->blockSignals(
false );
209 whileBlocking( mOffsetFromAnchorSpin )->setValue( mCallout->offsetFromAnchor() );
210 whileBlocking( mOffsetFromLabelSpin )->setValue( mCallout->offsetFromLabel() );
212 whileBlocking( mCalloutLineStyleButton )->setSymbol( mCallout->lineSymbol()->clone() );
214 whileBlocking( mDrawToAllPartsCheck )->setChecked( mCallout->drawCalloutToAllParts() );
216 whileBlocking( mAnchorPointComboBox )->setCurrentIndex( mAnchorPointComboBox->findData(
static_cast< int >( callout->
anchorPoint() ) ) );
217 whileBlocking( mLabelAnchorPointComboBox )->setCurrentIndex( mLabelAnchorPointComboBox->findData(
static_cast< int >( callout->
labelAnchorPoint() ) ) );
230 mAnchorPointLbl->setEnabled( isPolygon );
231 mAnchorPointLbl->setVisible( isPolygon );
232 mAnchorPointComboBox->setEnabled( isPolygon );
233 mAnchorPointComboBox->setVisible( isPolygon );
234 mAnchorPointDDBtn->setEnabled( isPolygon );
235 mAnchorPointDDBtn->setVisible( isPolygon );
238 QgsCallout *QgsSimpleLineCalloutWidget::callout()
240 return mCallout.get();
243 void QgsSimpleLineCalloutWidget::minimumLengthChanged()
245 mCallout->setMinimumLength( mMinCalloutLengthSpin->value() );
249 void QgsSimpleLineCalloutWidget::minimumLengthUnitWidgetChanged()
251 mCallout->setMinimumLengthUnit( mMinCalloutWidthUnitWidget->unit() );
252 mCallout->setMinimumLengthMapUnitScale( mMinCalloutWidthUnitWidget->getMapUnitScale() );
256 void QgsSimpleLineCalloutWidget::offsetFromAnchorUnitWidgetChanged()
258 mCallout->setOffsetFromAnchorUnit( mOffsetFromAnchorUnitWidget->unit() );
259 mCallout->setOffsetFromAnchorMapUnitScale( mOffsetFromAnchorUnitWidget->getMapUnitScale() );
263 void QgsSimpleLineCalloutWidget::offsetFromAnchorChanged()
265 mCallout->setOffsetFromAnchor( mOffsetFromAnchorSpin->value() );
269 void QgsSimpleLineCalloutWidget::offsetFromLabelUnitWidgetChanged()
271 mCallout->setOffsetFromLabelUnit( mOffsetFromLabelUnitWidget->unit() );
272 mCallout->setOffsetFromLabelMapUnitScale( mOffsetFromLabelUnitWidget->getMapUnitScale() );
276 void QgsSimpleLineCalloutWidget::offsetFromLabelChanged()
278 mCallout->setOffsetFromLabel( mOffsetFromLabelSpin->value() );
282 void QgsSimpleLineCalloutWidget::lineSymbolChanged()
284 mCallout->setLineSymbol( mCalloutLineStyleButton->clonedSymbol<
QgsLineSymbol >() );
288 void QgsSimpleLineCalloutWidget::mAnchorPointComboBox_currentIndexChanged(
int index )
290 mCallout->setAnchorPoint(
static_cast<QgsCallout::AnchorPoint>( mAnchorPointComboBox->itemData( index ).toInt() ) );
294 void QgsSimpleLineCalloutWidget::mLabelAnchorPointComboBox_currentIndexChanged(
int index )
300 void QgsSimpleLineCalloutWidget::drawToAllPartsToggled(
bool active )
302 mCallout->setDrawCalloutToAllParts( active );
311 QgsManhattanLineCalloutWidget::QgsManhattanLineCalloutWidget(
QgsVectorLayer *vl, QWidget *parent )
312 : QgsSimpleLineCalloutWidget( vl, parent )