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 );
338 if ( !mBlockChangedSignal )
342 if ( !mBlockChangedSignal )
345 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
347 if ( !mBlockChangedSignal )
351 connect( mSpinTextAngle, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [
this] {
352 if ( !mBlockChangedSignal )
356 connect( mRotationModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this] {
357 if ( !mBlockChangedSignal )
362 if ( !mBlockChangedSignal )
370 updateItem( newItem );
378 mBlockChangedSignal =
true;
379 pointTextItem->setFormat( mTextFormatButton->textFormat() );
380 pointTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
381 pointTextItem->setAngle( mSpinTextAngle->value() );
383 pointTextItem->setAlignment( mAlignmentComboBox->currentAlignment() );
384 mBlockChangedSignal =
false;
385 mPropertiesWidget->updateItem( pointTextItem );
392 if ( mTextFormatButton )
394 mTextFormatButton->setMapCanvas( context.
mapCanvas() );
395 mTextFormatButton->setMessageBar( context.
messageBar() );
397 mPropertiesWidget->setContext( context );
400void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
402 mTextEdit->textEdit()->selectAll();
403 mTextEdit->setFocus();
406QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() =
default;
414 mItem.reset( textItem->
clone() );
416 mBlockChangedSignal =
true;
417 mTextFormatButton->setTextFormat( mItem->format() );
419 mTextEdit->
setText( mItem->text() );
420 mSpinTextAngle->setValue( mItem->angle() );
421 mRotationModeCombo->setCurrentIndex( mRotationModeCombo->findData( QVariant::fromValue( mItem->rotationMode() ) ) );
422 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
423 mPropertiesWidget->setItem( mItem.get() );
424 mBlockChangedSignal =
false;
429void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
434 if ( context().expressionContext() )
441 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
442 if ( exprDlg.exec() == QDialog::Accepted )
444 expression = exprDlg.expressionText().trimmed();
445 if ( !expression.isEmpty() )
447 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
457QgsAnnotationLineTextItemWidget::QgsAnnotationLineTextItemWidget( QWidget *parent )
471 if ( !mBlockChangedSignal )
475 if ( !mBlockChangedSignal )
478 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
480 if ( !mBlockChangedSignal )
485 mSpinOffset->setClearValue( 0.0 );
486 connect( mSpinOffset,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this] {
487 if ( !mBlockChangedSignal )
492 if ( !mBlockChangedSignal )
497QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() =
default;
502 updateItem( newItem );
510 mBlockChangedSignal =
true;
511 lineTextItem->setFormat( mTextFormatButton->textFormat() );
512 lineTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
514 lineTextItem->setOffsetFromLine( mSpinOffset->value() );
515 lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
516 lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
518 mBlockChangedSignal =
false;
519 mPropertiesWidget->updateItem( lineTextItem );
526 if ( mTextFormatButton )
528 mTextFormatButton->setMapCanvas( context.
mapCanvas() );
529 mTextFormatButton->setMessageBar( context.
messageBar() );
531 mPropertiesWidget->setContext( context );
534void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
536 mTextEdit->textEdit()->selectAll();
537 mTextEdit->setFocus();
546 mItem.reset( textItem->
clone() );
548 mBlockChangedSignal =
true;
549 mTextFormatButton->setTextFormat( mItem->format() );
551 mTextEdit->
setText( mItem->text() );
552 mPropertiesWidget->setItem( mItem.get() );
554 mSpinOffset->setValue( mItem->offsetFromLine() );
555 mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
556 mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
558 mBlockChangedSignal =
false;
563void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
568 if ( context().expressionContext() )
575 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
576 if ( exprDlg.exec() == QDialog::Accepted )
578 expression = exprDlg.expressionText().trimmed();
579 if ( !expression.isEmpty() )
581 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
591QgsAnnotationRectangleTextItemWidget::QgsAnnotationRectangleTextItemWidget( QWidget *parent )
603 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
604 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
606 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
607 mFrameSymbolButton->registerExpressionContextGenerator(
this );
609 mSpinBottomMargin->setClearValue( 0 );
610 mSpinTopMargin->setClearValue( 0 );
611 mSpinRightMargin->setClearValue( 0 );
612 mSpinLeftMargin->setClearValue( 0 );
619 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
620 mVerticalAlignmentComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
630 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked );
634 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
635 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
636 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
637 connect( mFrameSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
638 connect( mSpinTopMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
639 connect( mSpinRightMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
640 connect( mSpinLeftMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
641 connect( mSpinBottomMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
646 connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setWidth );
647 connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setHeight );
649 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationRectangleTextItemWidget::sizeModeChanged );
650 mWidgetFixedSize->hide();
657 updateItem( newItem );
665 mBlockChangedSignal =
true;
666 rectTextItem->setFormat( mTextFormatButton->textFormat() );
667 rectTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
668 rectTextItem->setAlignment( mAlignmentComboBox->currentAlignment() | mVerticalAlignmentComboBox->currentAlignment() );
672 rectTextItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
673 rectTextItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
675 rectTextItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
676 rectTextItem->setFrameEnabled( mFrameCheckbox->isChecked() );
677 rectTextItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
678 rectTextItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
680 rectTextItem->setMargins(
QgsMargins( mSpinLeftMargin->value(), mSpinTopMargin->value(), mSpinRightMargin->value(), mSpinBottomMargin->value() ) );
681 rectTextItem->setMarginsUnit( mMarginUnitWidget->unit() );
683 if ( mUpdateItemPosition )
685 rectTextItem->setBounds( mItem->bounds() );
686 mUpdateItemPosition =
false;
689 mBlockChangedSignal =
false;
691 mPropertiesWidget->updateItem( rectTextItem );
698 if ( mTextFormatButton )
700 mTextFormatButton->setMapCanvas( context.
mapCanvas() );
701 mTextFormatButton->setMessageBar( context.
messageBar() );
703 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
704 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
705 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
706 mFrameSymbolButton->setMessageBar( context.
messageBar() );
707 mPropertiesWidget->setContext( context );
713 if ( context().expressionContext() )
717 return expressionContext;
720void QgsAnnotationRectangleTextItemWidget::focusDefaultWidget()
722 mTextEdit->textEdit()->selectAll();
723 mTextEdit->setFocus();
726QgsAnnotationRectangleTextItemWidget::~QgsAnnotationRectangleTextItemWidget() =
default;
734 mItem.reset( textItem->
clone() );
736 mBlockChangedSignal =
true;
737 mTextFormatButton->setTextFormat( mItem->format() );
739 mTextEdit->
setText( mItem->text() );
740 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
741 mVerticalAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignVertical_Mask );
742 mPropertiesWidget->setItem( mItem.get() );
746 mBackgroundSymbolButton->setSymbol( symbol->clone() );
750 mFrameSymbolButton->setSymbol( symbol->clone() );
752 mMarginUnitWidget->setUnit( textItem->
marginsUnit() );
753 mSpinLeftMargin->setValue( textItem->
margins().
left() );
754 mSpinTopMargin->setValue( textItem->
margins().
top() );
755 mSpinRightMargin->setValue( textItem->
margins().
right() );
758 mWidthSpinBox->setValue( textItem->
fixedSize().width() );
759 mHeightSpinBox->setValue( textItem->
fixedSize().height() );
761 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( textItem->
placementMode() ) ) );
763 mBlockChangedSignal =
false;
768void QgsAnnotationRectangleTextItemWidget::onWidgetChanged()
770 if ( !mBlockChangedSignal )
774void QgsAnnotationRectangleTextItemWidget::sizeModeChanged()
780 mWidgetFixedSize->hide();
786 const QgsRectangle itemBoundsMapUnits = details->boundingBox();
789 const QgsPointXY topLeftPixels = canvas->mapSettings().mapToPixel().transform( itemBoundsMapUnits.
xMinimum(), itemBoundsMapUnits.
yMinimum() );
790 const QgsPointXY bottomRightPixels = canvas->mapSettings().mapToPixel().transform( itemBoundsMapUnits.
xMaximum(), itemBoundsMapUnits.
yMaximum() );
791 const double widthPixels = std::abs( bottomRightPixels.
x() - topLeftPixels.
x() );
792 const double heightPixels = std::abs( bottomRightPixels.
y() - topLeftPixels.
y() );
795 const double pixelsPerMm = canvas->mapSettings().outputDpi() / 25.4;
797 mItem->setFixedSize( QSizeF( widthPixels / pixelsPerMm, heightPixels / pixelsPerMm ) );
800 whileBlocking( mWidthSpinBox )->setValue( mItem->fixedSize().width() );
801 whileBlocking( mHeightSpinBox )->setValue( mItem->fixedSize().height() );
802 whileBlocking( mSizeUnitWidget )->setUnit( mItem->fixedSizeUnit() );
804 mUpdateItemPosition =
true;
808 mWidgetFixedSize->show();
819 const double centerX = ( itemBounds.
center().x() - canvas->extent().xMinimum() ) / canvas->extent().width();
820 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
822 mUpdateItemPosition =
true;
826 mWidgetFixedSize->hide();
834void QgsAnnotationRectangleTextItemWidget::setWidth()
839void QgsAnnotationRectangleTextItemWidget::setHeight()
844void QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked()
850 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
851 if ( exprDlg.exec() == QDialog::Accepted )
853 expression = exprDlg.expressionText().trimmed();
854 if ( !expression.isEmpty() )
856 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
866QgsAnnotationPictureItemWidget::QgsAnnotationPictureItemWidget( QWidget *parent )
880 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
881 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
883 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
884 mFrameSymbolButton->registerExpressionContextGenerator(
this );
887 if ( !mBlockChangedSignal )
891 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationPictureItemWidget::sizeModeChanged );
893 connect( mRadioSVG, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
894 connect( mRadioRaster, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
896 if ( !mRadioSVG->isChecked() && QFileInfo( source ).suffix().compare(
"svg"_L1, Qt::CaseInsensitive ) == 0 )
898 mRadioSVG->setChecked(
true );
904 connect( mLockAspectRatioCheck, &QCheckBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
905 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
906 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
907 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
911 connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setWidth );
912 connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setHeight );
916QgsAnnotationPictureItemWidget::~QgsAnnotationPictureItemWidget() =
default;
921 updateItem( newItem );
929 const bool svg = mRadioSVG->isChecked();
931 const QString path = mSourceLineEdit->source();
932 pictureItem->setPath( newFormat, path );
935 switch ( pictureItem->placementMode() )
938 pictureItem->setLockAspectRatio( mLockAspectRatioCheck->isChecked() );
942 pictureItem->setLockAspectRatio( mLockAspectRatio->isChecked() );
946 pictureItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
947 pictureItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
949 pictureItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
950 pictureItem->setFrameEnabled( mFrameCheckbox->isChecked() );
951 pictureItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
952 pictureItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
954 if ( mUpdateItemPosition )
956 pictureItem->setBounds( mItem->bounds() );
957 mUpdateItemPosition =
false;
960 mPropertiesWidget->updateItem( pictureItem );
964void QgsAnnotationPictureItemWidget::setDockMode(
bool dockMode )
972 mPropertiesWidget->setContext( context );
973 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
974 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
975 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
976 mFrameSymbolButton->setMessageBar( context.
messageBar() );
982 if ( context().expressionContext() )
986 return expressionContext;
989void QgsAnnotationPictureItemWidget::focusDefaultWidget()
991 mSourceLineEdit->setFocus();
1000 mItem.reset( pictureItem->
clone() );
1002 mBlockChangedSignal =
true;
1003 mPropertiesWidget->setItem( mItem.get() );
1005 mLockAspectRatioCheck->setChecked( mItem->lockAspectRatio() );
1006 mLockAspectRatio->setLocked( mItem->lockAspectRatio() );
1007 switch ( pictureItem->
format() )
1010 mRadioSVG->setChecked(
true );
1013 mRadioRaster->setChecked(
true );
1019 mSourceLineEdit->setSource( pictureItem->
path() );
1023 mBackgroundSymbolButton->setSymbol( symbol->clone() );
1025 mFrameCheckbox->setChecked( pictureItem->
frameEnabled() );
1027 mFrameSymbolButton->setSymbol( symbol->clone() );
1029 mWidthSpinBox->setValue( pictureItem->
fixedSize().width() );
1030 mHeightSpinBox->setValue( pictureItem->
fixedSize().height() );
1031 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( pictureItem->
placementMode() ) ) );
1034 mBlockChangedSignal =
false;
1039void QgsAnnotationPictureItemWidget::onWidgetChanged()
1041 if ( !mBlockChangedSignal )
1045void QgsAnnotationPictureItemWidget::modeChanged(
bool checked )
1050 const bool svg = mRadioSVG->isChecked();
1060void QgsAnnotationPictureItemWidget::sizeModeChanged()
1066 mSizeStackedWidget->setCurrentWidget( mPageSpatialBounds );
1070 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1078 const QgsRectangle itemBounds = details->boundingBox();
1081 const double centerX = ( itemBounds.
center().x() - canvas->extent().xMinimum() ) / canvas->extent().width();
1082 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
1084 mUpdateItemPosition =
true;
1088 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1096void QgsAnnotationPictureItemWidget::setWidth()
1098 if ( mLockAspectRatio->locked() )
1100 const double ratio = pictureAspectRatio();
1102 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1108void QgsAnnotationPictureItemWidget::setHeight()
1110 if ( mLockAspectRatio->locked() )
1112 const double ratio = pictureAspectRatio();
1114 whileBlocking( mWidthSpinBox )->setValue( mHeightSpinBox->value() / ratio );
1120void QgsAnnotationPictureItemWidget::setLockAspectRatio(
bool locked )
1122 if ( locked && !mBlockChangedSignal )
1124 const double ratio = pictureAspectRatio();
1126 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1132double QgsAnnotationPictureItemWidget::pictureAspectRatio()
const
1134 const bool svg = mRadioSVG->isChecked();
1135 const QString path = mSourceLineEdit->source();
1145 if ( size.isValid() && size.width() > 0 )
1146 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.
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.