41#include "moc_qgsannotationitemwidget_impl.cpp"
43using namespace Qt::StringLiterals;
47QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
53 mSelector->setDockMode( dockMode() );
55 if ( !mBlockChangedSignal )
63 QVBoxLayout *layout =
new QVBoxLayout();
64 layout->setContentsMargins( 0, 0, 0, 0 );
65 layout->addWidget( mSelector );
66 mSymbolSelectorFrame->setLayout( layout );
69 if ( !mBlockChangedSignal )
78 mPropertiesWidget->updateItem( newItem );
86 polygonItem->setSymbol( mSymbol->clone() );
87 mPropertiesWidget->updateItem( polygonItem );
91void QgsAnnotationPolygonItemWidget::setDockMode(
bool dockMode )
95 mSelector->setDockMode( dockMode );
102 mSelector->setContext( context );
103 mPropertiesWidget->setContext( context );
106QgsAnnotationPolygonItemWidget::~QgsAnnotationPolygonItemWidget() =
default;
114 mItem.reset( polygonItem->
clone() );
115 if ( mItem->symbol() )
117 mSymbol.reset( mItem->symbol()->clone() );
123 mBlockChangedSignal =
true;
124 mSelector->loadSymbol( mSymbol.get() );
125 mSelector->updatePreview();
126 mPropertiesWidget->setItem( mItem.get() );
127 mBlockChangedSignal =
false;
137QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
143 mSelector->setDockMode( dockMode() );
145 if ( !mBlockChangedSignal )
153 QVBoxLayout *layout =
new QVBoxLayout();
154 layout->setContentsMargins( 0, 0, 0, 0 );
155 layout->addWidget( mSelector );
156 mSymbolSelectorFrame->setLayout( layout );
159 if ( !mBlockChangedSignal )
168 mPropertiesWidget->updateItem( newItem );
176 lineItem->setSymbol( mSymbol->clone() );
177 mPropertiesWidget->updateItem( lineItem );
181void QgsAnnotationLineItemWidget::setDockMode(
bool dockMode )
185 mSelector->setDockMode( dockMode );
192 mSelector->setContext( context );
193 mPropertiesWidget->setContext( context );
196QgsAnnotationLineItemWidget::~QgsAnnotationLineItemWidget() =
default;
204 mItem.reset( lineItem->
clone() );
205 if ( mItem->symbol() )
207 mSymbol.reset( mItem->symbol()->clone() );
213 mBlockChangedSignal =
true;
214 mSelector->loadSymbol( mSymbol.get() );
215 mSelector->updatePreview();
216 mPropertiesWidget->setItem( mItem.get() );
217 mBlockChangedSignal =
false;
227QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
233 mSelector->setDockMode( dockMode() );
235 if ( !mBlockChangedSignal )
243 QVBoxLayout *layout =
new QVBoxLayout();
244 layout->setContentsMargins( 0, 0, 0, 0 );
245 layout->addWidget( mSelector );
246 mSymbolSelectorFrame->setLayout( layout );
249 if ( !mBlockChangedSignal )
258 mPropertiesWidget->updateItem( newItem );
266 markerItem->setSymbol( mSymbol->clone() );
267 mPropertiesWidget->updateItem( markerItem );
271void QgsAnnotationMarkerItemWidget::setDockMode(
bool dockMode )
275 mSelector->setDockMode( dockMode );
282 mSelector->setContext( context );
283 mPropertiesWidget->setContext( context );
286QgsAnnotationMarkerItemWidget::~QgsAnnotationMarkerItemWidget() =
default;
294 mItem.reset( markerItem->
clone() );
295 if ( mItem->symbol() )
297 mSymbol.reset( mItem->symbol()->clone() );
303 mBlockChangedSignal =
true;
304 mSelector->loadSymbol( mSymbol.get() );
305 mSelector->updatePreview();
306 mPropertiesWidget->setItem( mItem.get() );
307 mBlockChangedSignal =
false;
317QgsAnnotationPointTextItemWidget::QgsAnnotationPointTextItemWidget( QWidget *parent )
326 mSpinTextAngle->setClearValue( 0 );
331 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
336 if ( !mBlockChangedSignal )
340 if ( !mBlockChangedSignal )
343 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
345 if ( !mBlockChangedSignal )
349 connect( mSpinTextAngle, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] {
350 if ( !mBlockChangedSignal )
354 connect( mRotationModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
355 if ( !mBlockChangedSignal )
360 if ( !mBlockChangedSignal )
368 updateItem( newItem );
376 mBlockChangedSignal =
true;
377 pointTextItem->setFormat( mTextFormatButton->textFormat() );
378 pointTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
379 pointTextItem->setAngle( mSpinTextAngle->value() );
381 pointTextItem->setAlignment( mAlignmentComboBox->currentAlignment() );
382 mBlockChangedSignal =
false;
383 mPropertiesWidget->updateItem( pointTextItem );
390 if ( mTextFormatButton )
392 mTextFormatButton->setMapCanvas( context.
mapCanvas() );
393 mTextFormatButton->setMessageBar( context.
messageBar() );
395 mPropertiesWidget->setContext( context );
398void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
400 mTextEdit->textEdit()->selectAll();
401 mTextEdit->setFocus();
404QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() =
default;
412 mItem.reset( textItem->
clone() );
414 mBlockChangedSignal =
true;
415 mTextFormatButton->setTextFormat( mItem->format() );
417 mTextEdit->
setText( mItem->text() );
418 mSpinTextAngle->setValue( mItem->angle() );
419 mRotationModeCombo->setCurrentIndex( mRotationModeCombo->findData( QVariant::fromValue( mItem->rotationMode() ) ) );
420 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
421 mPropertiesWidget->setItem( mItem.get() );
422 mBlockChangedSignal =
false;
427void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
432 if ( context().expressionContext() )
439 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
440 if ( exprDlg.exec() == QDialog::Accepted )
442 expression = exprDlg.expressionText().trimmed();
443 if ( !expression.isEmpty() )
445 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
455QgsAnnotationLineTextItemWidget::QgsAnnotationLineTextItemWidget( QWidget *parent )
471 if ( !mBlockChangedSignal )
475 if ( !mBlockChangedSignal )
478 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
480 if ( !mBlockChangedSignal )
484 mOffsetUnitWidget->setUnits(
487 mSpinOffset->setClearValue( 0.0 );
488 connect( mSpinOffset,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this] {
489 if ( !mBlockChangedSignal )
494 if ( !mBlockChangedSignal )
498 connect( mAlignmentCombo, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [
this] {
499 if ( !mBlockChangedSignal )
504QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() =
default;
509 updateItem( newItem );
517 mBlockChangedSignal =
true;
518 lineTextItem->setFormat( mTextFormatButton->textFormat() );
519 lineTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
521 lineTextItem->setOffsetFromLine( mSpinOffset->value() );
522 lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
523 lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
527 mBlockChangedSignal =
false;
528 mPropertiesWidget->updateItem( lineTextItem );
535 if ( mTextFormatButton )
537 mTextFormatButton->setMapCanvas( context.
mapCanvas() );
538 mTextFormatButton->setMessageBar( context.
messageBar() );
540 mPropertiesWidget->setContext( context );
543void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
545 mTextEdit->textEdit()->selectAll();
546 mTextEdit->setFocus();
555 mItem.reset( textItem->
clone() );
557 mBlockChangedSignal =
true;
558 mTextFormatButton->setTextFormat( mItem->format() );
560 mTextEdit->
setText( mItem->text() );
561 mPropertiesWidget->setItem( mItem.get() );
563 mSpinOffset->setValue( mItem->offsetFromLine() );
564 mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
565 mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
567 mAlignmentCombo->setCurrentIndex( mAlignmentCombo->findData( QVariant::fromValue( mItem->textAnchor() ) ) );
569 mBlockChangedSignal =
false;
574void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
579 if ( context().expressionContext() )
586 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
587 if ( exprDlg.exec() == QDialog::Accepted )
589 expression = exprDlg.expressionText().trimmed();
590 if ( !expression.isEmpty() )
592 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
602QgsAnnotationRectangleTextItemWidget::QgsAnnotationRectangleTextItemWidget( QWidget *parent )
611 mSizeUnitWidget->setUnits(
616 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
617 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
619 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
620 mFrameSymbolButton->registerExpressionContextGenerator(
this );
622 mSpinBottomMargin->setClearValue( 0 );
623 mSpinTopMargin->setClearValue( 0 );
624 mSpinRightMargin->setClearValue( 0 );
625 mSpinLeftMargin->setClearValue( 0 );
626 mMarginUnitWidget->setUnits(
634 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
635 mVerticalAlignmentComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
643 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked );
647 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
648 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
649 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
650 connect( mFrameSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
651 connect( mSpinTopMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
652 connect( mSpinRightMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
653 connect( mSpinLeftMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
654 connect( mSpinBottomMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
659 connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setWidth );
660 connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setHeight );
662 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationRectangleTextItemWidget::sizeModeChanged );
663 mWidgetFixedSize->hide();
670 updateItem( newItem );
678 mBlockChangedSignal =
true;
679 rectTextItem->setFormat( mTextFormatButton->textFormat() );
680 rectTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
681 rectTextItem->setAlignment( mAlignmentComboBox->currentAlignment() | mVerticalAlignmentComboBox->currentAlignment() );
685 rectTextItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
686 rectTextItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
688 rectTextItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
689 rectTextItem->setFrameEnabled( mFrameCheckbox->isChecked() );
690 rectTextItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
691 rectTextItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
693 rectTextItem->setMargins(
QgsMargins( mSpinLeftMargin->value(), mSpinTopMargin->value(), mSpinRightMargin->value(), mSpinBottomMargin->value() ) );
694 rectTextItem->setMarginsUnit( mMarginUnitWidget->unit() );
696 if ( mUpdateItemPosition )
698 rectTextItem->setBounds( mItem->bounds() );
699 mUpdateItemPosition =
false;
702 mBlockChangedSignal =
false;
704 mPropertiesWidget->updateItem( rectTextItem );
711 if ( mTextFormatButton )
713 mTextFormatButton->setMapCanvas( context.
mapCanvas() );
714 mTextFormatButton->setMessageBar( context.
messageBar() );
716 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
717 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
718 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
719 mFrameSymbolButton->setMessageBar( context.
messageBar() );
720 mPropertiesWidget->setContext( context );
726 if ( context().expressionContext() )
730 return expressionContext;
733void QgsAnnotationRectangleTextItemWidget::focusDefaultWidget()
735 mTextEdit->textEdit()->selectAll();
736 mTextEdit->setFocus();
739QgsAnnotationRectangleTextItemWidget::~QgsAnnotationRectangleTextItemWidget() =
default;
747 mItem.reset( textItem->
clone() );
749 mBlockChangedSignal =
true;
750 mTextFormatButton->setTextFormat( mItem->format() );
752 mTextEdit->
setText( mItem->text() );
753 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
754 mVerticalAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignVertical_Mask );
755 mPropertiesWidget->setItem( mItem.get() );
759 mBackgroundSymbolButton->setSymbol( symbol->clone() );
763 mFrameSymbolButton->setSymbol( symbol->clone() );
765 mMarginUnitWidget->setUnit( textItem->
marginsUnit() );
766 mSpinLeftMargin->setValue( textItem->
margins().
left() );
767 mSpinTopMargin->setValue( textItem->
margins().
top() );
768 mSpinRightMargin->setValue( textItem->
margins().
right() );
771 mWidthSpinBox->setValue( textItem->
fixedSize().width() );
772 mHeightSpinBox->setValue( textItem->
fixedSize().height() );
774 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( textItem->
placementMode() ) ) );
776 mBlockChangedSignal =
false;
781void QgsAnnotationRectangleTextItemWidget::onWidgetChanged()
783 if ( !mBlockChangedSignal )
787void QgsAnnotationRectangleTextItemWidget::sizeModeChanged()
793 mWidgetFixedSize->hide();
799 const QgsRectangle itemBoundsMapUnits = details->boundingBox();
802 const QgsPointXY topLeftPixels = canvas->mapSettings().mapToPixel().transform( itemBoundsMapUnits.
xMinimum(), itemBoundsMapUnits.
yMinimum() );
803 const QgsPointXY bottomRightPixels = canvas->mapSettings().mapToPixel().transform( itemBoundsMapUnits.
xMaximum(), itemBoundsMapUnits.
yMaximum() );
804 const double widthPixels = std::abs( bottomRightPixels.
x() - topLeftPixels.
x() );
805 const double heightPixels = std::abs( bottomRightPixels.
y() - topLeftPixels.
y() );
808 const double pixelsPerMm = canvas->mapSettings().outputDpi() / 25.4;
810 mItem->setFixedSize( QSizeF( widthPixels / pixelsPerMm, heightPixels / pixelsPerMm ) );
813 whileBlocking( mWidthSpinBox )->setValue( mItem->fixedSize().width() );
814 whileBlocking( mHeightSpinBox )->setValue( mItem->fixedSize().height() );
815 whileBlocking( mSizeUnitWidget )->setUnit( mItem->fixedSizeUnit() );
817 mUpdateItemPosition =
true;
821 mWidgetFixedSize->show();
832 const double centerX = ( itemBounds.
center().x() - canvas->extent().xMinimum() ) / canvas->extent().width();
833 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
835 mUpdateItemPosition =
true;
839 mWidgetFixedSize->hide();
847void QgsAnnotationRectangleTextItemWidget::setWidth()
852void QgsAnnotationRectangleTextItemWidget::setHeight()
857void QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked()
863 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
864 if ( exprDlg.exec() == QDialog::Accepted )
866 expression = exprDlg.expressionText().trimmed();
867 if ( !expression.isEmpty() )
869 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
879QgsAnnotationPictureItemWidget::QgsAnnotationPictureItemWidget( QWidget *parent )
890 mSizeUnitWidget->setUnits(
895 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
896 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
898 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
899 mFrameSymbolButton->registerExpressionContextGenerator(
this );
902 if ( !mBlockChangedSignal )
906 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationPictureItemWidget::sizeModeChanged );
908 connect( mRadioSVG, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
909 connect( mRadioRaster, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
911 if ( !mRadioSVG->isChecked() && QFileInfo( source ).suffix().compare(
"svg"_L1, Qt::CaseInsensitive ) == 0 )
913 mRadioSVG->setChecked(
true );
919 connect( mLockAspectRatioCheck, &QCheckBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
920 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
921 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
922 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
926 connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setWidth );
927 connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setHeight );
931QgsAnnotationPictureItemWidget::~QgsAnnotationPictureItemWidget() =
default;
936 updateItem( newItem );
944 const bool svg = mRadioSVG->isChecked();
946 const QString path = mSourceLineEdit->source();
947 pictureItem->setPath( newFormat, path );
950 switch ( pictureItem->placementMode() )
953 pictureItem->setLockAspectRatio( mLockAspectRatioCheck->isChecked() );
957 pictureItem->setLockAspectRatio( mLockAspectRatio->isChecked() );
961 pictureItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
962 pictureItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
964 pictureItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
965 pictureItem->setFrameEnabled( mFrameCheckbox->isChecked() );
966 pictureItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
967 pictureItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
969 if ( mUpdateItemPosition )
971 pictureItem->setBounds( mItem->bounds() );
972 mUpdateItemPosition =
false;
975 mPropertiesWidget->updateItem( pictureItem );
979void QgsAnnotationPictureItemWidget::setDockMode(
bool dockMode )
987 mPropertiesWidget->setContext( context );
988 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
989 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
990 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
991 mFrameSymbolButton->setMessageBar( context.
messageBar() );
997 if ( context().expressionContext() )
1001 return expressionContext;
1004void QgsAnnotationPictureItemWidget::focusDefaultWidget()
1006 mSourceLineEdit->setFocus();
1015 mItem.reset( pictureItem->
clone() );
1017 mBlockChangedSignal =
true;
1018 mPropertiesWidget->setItem( mItem.get() );
1020 mLockAspectRatioCheck->setChecked( mItem->lockAspectRatio() );
1021 mLockAspectRatio->setLocked( mItem->lockAspectRatio() );
1022 switch ( pictureItem->
format() )
1025 mRadioSVG->setChecked(
true );
1028 mRadioRaster->setChecked(
true );
1034 mSourceLineEdit->setSource( pictureItem->
path() );
1038 mBackgroundSymbolButton->setSymbol( symbol->clone() );
1040 mFrameCheckbox->setChecked( pictureItem->
frameEnabled() );
1042 mFrameSymbolButton->setSymbol( symbol->clone() );
1044 mWidthSpinBox->setValue( pictureItem->
fixedSize().width() );
1045 mHeightSpinBox->setValue( pictureItem->
fixedSize().height() );
1046 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( pictureItem->
placementMode() ) ) );
1049 mBlockChangedSignal =
false;
1054void QgsAnnotationPictureItemWidget::onWidgetChanged()
1056 if ( !mBlockChangedSignal )
1060void QgsAnnotationPictureItemWidget::modeChanged(
bool checked )
1065 const bool svg = mRadioSVG->isChecked();
1075void QgsAnnotationPictureItemWidget::sizeModeChanged()
1081 mSizeStackedWidget->setCurrentWidget( mPageSpatialBounds );
1085 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1093 const QgsRectangle itemBounds = details->boundingBox();
1096 const double centerX = ( itemBounds.
center().x() - canvas->extent().xMinimum() ) / canvas->extent().width();
1097 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
1099 mUpdateItemPosition =
true;
1103 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1111void QgsAnnotationPictureItemWidget::setWidth()
1113 if ( mLockAspectRatio->locked() )
1115 const double ratio = pictureAspectRatio();
1117 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1123void QgsAnnotationPictureItemWidget::setHeight()
1125 if ( mLockAspectRatio->locked() )
1127 const double ratio = pictureAspectRatio();
1129 whileBlocking( mWidthSpinBox )->setValue( mHeightSpinBox->value() / ratio );
1135void QgsAnnotationPictureItemWidget::setLockAspectRatio(
bool locked )
1137 if ( locked && !mBlockChangedSignal )
1139 const double ratio = pictureAspectRatio();
1141 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1147double QgsAnnotationPictureItemWidget::pictureAspectRatio()
const
1149 const bool svg = mRadioSVG->isChecked();
1150 const QString path = mSourceLineEdit->source();
1160 if ( size.isValid() && size.width() > 0 )
1161 return size.height() / size.width();
SymbolRotationMode
Modes for handling how symbol and text entity rotation is handled when maps are rotated.
@ RespectMapRotation
Entity is rotated along with the map.
@ IgnoreMapRotation
Entity ignores map rotation.
TextAnchorPoint
Anchor point of label text.
@ EndOfText
Anchor using end of text.
@ StartOfText
Anchor using start of text.
@ CenterOfText
Anchor using center of text.
PictureFormat
Picture formats.
@ Unknown
Invalid or unknown image type.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size).
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes).
@ MetersInMapUnits
Meters value as Map units.
AnnotationPlacementMode
Annotation item placement modes.
@ SpatialBounds
Item is rendered inside fixed spatial bounds, and size will depend on map scale.
@ FixedSize
Item is rendered at a fixed size, regardless of map scale. Item's location is georeferenced to a spat...
@ RelativeToMapFrame
Items size and placement is relative to the map's frame, and the item will always be rendered in the ...
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
void changed()
Emitted when the alignment is changed.
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
An annotation item which renders a line symbol along a line geometry.
void setSymbol(QgsLineSymbol *symbol)
Sets the symbol used to render the marker item.
QgsAnnotationLineItem * clone() const override
Returns a clone of the item.
An annotation item which renders text along a line geometry.
QgsAnnotationLineTextItem * clone() const override
Returns a clone of the item.
void setText(const QString &text)
Sets the text rendered by the item.
An annotation item which renders a marker symbol at a point location.
void setSymbol(QgsMarkerSymbol *symbol)
Sets the symbol used to render the marker item.
QgsAnnotationMarkerItem * clone() const override
Returns a clone of the item.
An annotation item which renders a picture.
Qgis::PictureFormat format() const
Returns the picture format.
QString path() const
Returns the path of the image used to render the item.
QgsAnnotationPictureItem * clone() const override
Returns a clone of the item.
An annotation item which renders a text string at a point location.
void setText(const QString &text)
Sets the text rendered by the item.
QgsAnnotationPointTextItem * clone() const override
Returns a clone of the item.
An annotation item which renders a fill symbol for a polygon geometry.
void setSymbol(QgsFillSymbol *symbol)
Sets the symbol used to render the polygon item.
QgsAnnotationPolygonItem * clone() const override
Returns a clone of the item.
Qgis::RenderUnit fixedSizeUnit() const
Returns the units to use for fixed item sizes, when the placementMode() is Qgis::AnnotationPlacementM...
QSizeF fixedSize() const
Returns the fixed size to use for the item, when the placementMode() is Qgis::AnnotationPlacementMode...
bool frameEnabled() const
Returns true if the item's frame should be rendered.
const QgsFillSymbol * frameSymbol() const
Returns the symbol used to render the item's frame.
Qgis::AnnotationPlacementMode placementMode() const
Returns the placement mode for the item.
bool backgroundEnabled() const
Returns true if the item's background should be rendered.
const QgsFillSymbol * backgroundSymbol() const
Returns the symbol used to render the item's background.
An annotation item which renders paragraphs of text within a rectangle.
QgsAnnotationRectangleTextItem * clone() const override
Returns a clone of the item.
const QgsMargins & margins() const
Returns the margins between the outside of the item's frame and the interior text.
void setText(const QString &text)
Sets the text rendered by the item.
Qgis::RenderUnit marginsUnit() const
Returns the units for the margins between the item's frame and the interior text.
static QgsRecentStyleHandler * recentStyleHandler()
Returns the handler for recently used style items.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
A generic dialog for building expression strings.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QString findAndSelectActiveExpression(QgsCodeEditor *editor, const QString &pattern=QString())
Find the expression under the cursor in the given editor and select it.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static std::unique_ptr< QgsFillSymbol > createSimple(const QVariantMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
static std::unique_ptr< QgsLineSymbol > createSimple(const QVariantMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties.
Map canvas is a class for displaying all GIS data types on a canvas.
Defines the four margins of a rectangle.
double top() const
Returns the top margin.
double right() const
Returns the right margin.
double bottom() const
Returns the bottom margin.
double left() const
Returns the left margin.
static std::unique_ptr< QgsMarkerSymbol > createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void pushRecentSymbol(const QString &identifier, QgsSymbol *symbol)
Pushes a recently used symbol with the specified identifier.
A rectangle specified with double values.
static QgsRectangle fromCenterAndSize(const QgsPointXY ¢er, double width, double height)
Creates a new rectangle, given the specified center point and width and height.
Contains information about a rendered annotation item.
@ PlainText
Plain text mode.
@ QgsTextRenderer
QGIS text renderer mode, exposes the HTML/CSS subset supported by the QgsTextRenderer class.
void textChanged()
Emitted when the text contents are changed.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
QSizeF svgViewboxSize(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Calculates the viewbox size of a (possibly cached) SVG file.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
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.
Abstract base class for all rendered symbols.
QList< Qgis::RenderUnit > RenderUnitList
List of render units.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.