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 )
467 if ( !mBlockChangedSignal )
471 if ( !mBlockChangedSignal )
474 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
476 if ( !mBlockChangedSignal )
480 mOffsetUnitWidget->setUnits(
483 mSpinOffset->setClearValue( 0.0 );
484 connect( mSpinOffset,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [
this] {
485 if ( !mBlockChangedSignal )
490 if ( !mBlockChangedSignal )
495QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() =
default;
500 updateItem( newItem );
508 mBlockChangedSignal =
true;
509 lineTextItem->setFormat( mTextFormatButton->textFormat() );
510 lineTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
512 lineTextItem->setOffsetFromLine( mSpinOffset->value() );
513 lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
514 lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
516 mBlockChangedSignal =
false;
517 mPropertiesWidget->updateItem( lineTextItem );
524 if ( mTextFormatButton )
526 mTextFormatButton->setMapCanvas( context.
mapCanvas() );
527 mTextFormatButton->setMessageBar( context.
messageBar() );
529 mPropertiesWidget->setContext( context );
532void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
534 mTextEdit->textEdit()->selectAll();
535 mTextEdit->setFocus();
544 mItem.reset( textItem->
clone() );
546 mBlockChangedSignal =
true;
547 mTextFormatButton->setTextFormat( mItem->format() );
549 mTextEdit->
setText( mItem->text() );
550 mPropertiesWidget->setItem( mItem.get() );
552 mSpinOffset->setValue( mItem->offsetFromLine() );
553 mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
554 mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
556 mBlockChangedSignal =
false;
561void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
566 if ( context().expressionContext() )
573 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
574 if ( exprDlg.exec() == QDialog::Accepted )
576 expression = exprDlg.expressionText().trimmed();
577 if ( !expression.isEmpty() )
579 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
589QgsAnnotationRectangleTextItemWidget::QgsAnnotationRectangleTextItemWidget( QWidget *parent )
598 mSizeUnitWidget->setUnits(
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 );
613 mMarginUnitWidget->setUnits(
621 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
622 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 )
877 mSizeUnitWidget->setUnits(
882 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
883 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
885 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
886 mFrameSymbolButton->registerExpressionContextGenerator(
this );
889 if ( !mBlockChangedSignal )
893 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationPictureItemWidget::sizeModeChanged );
895 connect( mRadioSVG, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
896 connect( mRadioRaster, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
898 if ( !mRadioSVG->isChecked() && QFileInfo( source ).suffix().compare(
"svg"_L1, Qt::CaseInsensitive ) == 0 )
900 mRadioSVG->setChecked(
true );
906 connect( mLockAspectRatioCheck, &QCheckBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
907 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
908 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
909 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
913 connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setWidth );
914 connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setHeight );
918QgsAnnotationPictureItemWidget::~QgsAnnotationPictureItemWidget() =
default;
923 updateItem( newItem );
931 const bool svg = mRadioSVG->isChecked();
933 const QString path = mSourceLineEdit->source();
934 pictureItem->setPath( newFormat, path );
937 switch ( pictureItem->placementMode() )
940 pictureItem->setLockAspectRatio( mLockAspectRatioCheck->isChecked() );
944 pictureItem->setLockAspectRatio( mLockAspectRatio->isChecked() );
948 pictureItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
949 pictureItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
951 pictureItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
952 pictureItem->setFrameEnabled( mFrameCheckbox->isChecked() );
953 pictureItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
954 pictureItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
956 if ( mUpdateItemPosition )
958 pictureItem->setBounds( mItem->bounds() );
959 mUpdateItemPosition =
false;
962 mPropertiesWidget->updateItem( pictureItem );
966void QgsAnnotationPictureItemWidget::setDockMode(
bool dockMode )
974 mPropertiesWidget->setContext( context );
975 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
976 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
977 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
978 mFrameSymbolButton->setMessageBar( context.
messageBar() );
984 if ( context().expressionContext() )
988 return expressionContext;
991void QgsAnnotationPictureItemWidget::focusDefaultWidget()
993 mSourceLineEdit->setFocus();
1002 mItem.reset( pictureItem->
clone() );
1004 mBlockChangedSignal =
true;
1005 mPropertiesWidget->setItem( mItem.get() );
1007 mLockAspectRatioCheck->setChecked( mItem->lockAspectRatio() );
1008 mLockAspectRatio->setLocked( mItem->lockAspectRatio() );
1009 switch ( pictureItem->
format() )
1012 mRadioSVG->setChecked(
true );
1015 mRadioRaster->setChecked(
true );
1021 mSourceLineEdit->setSource( pictureItem->
path() );
1025 mBackgroundSymbolButton->setSymbol( symbol->clone() );
1027 mFrameCheckbox->setChecked( pictureItem->
frameEnabled() );
1029 mFrameSymbolButton->setSymbol( symbol->clone() );
1031 mWidthSpinBox->setValue( pictureItem->
fixedSize().width() );
1032 mHeightSpinBox->setValue( pictureItem->
fixedSize().height() );
1033 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( pictureItem->
placementMode() ) ) );
1036 mBlockChangedSignal =
false;
1041void QgsAnnotationPictureItemWidget::onWidgetChanged()
1043 if ( !mBlockChangedSignal )
1047void QgsAnnotationPictureItemWidget::modeChanged(
bool checked )
1052 const bool svg = mRadioSVG->isChecked();
1062void QgsAnnotationPictureItemWidget::sizeModeChanged()
1068 mSizeStackedWidget->setCurrentWidget( mPageSpatialBounds );
1072 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1080 const QgsRectangle itemBounds = details->boundingBox();
1083 const double centerX = ( itemBounds.
center().x() - canvas->extent().xMinimum() ) / canvas->extent().width();
1084 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
1086 mUpdateItemPosition =
true;
1090 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1098void QgsAnnotationPictureItemWidget::setWidth()
1100 if ( mLockAspectRatio->locked() )
1102 const double ratio = pictureAspectRatio();
1104 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1110void QgsAnnotationPictureItemWidget::setHeight()
1112 if ( mLockAspectRatio->locked() )
1114 const double ratio = pictureAspectRatio();
1116 whileBlocking( mWidthSpinBox )->setValue( mHeightSpinBox->value() / ratio );
1122void QgsAnnotationPictureItemWidget::setLockAspectRatio(
bool locked )
1124 if ( locked && !mBlockChangedSignal )
1126 const double ratio = pictureAspectRatio();
1128 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1134double QgsAnnotationPictureItemWidget::pictureAspectRatio()
const
1136 const bool svg = mRadioSVG->isChecked();
1137 const QString path = mSourceLineEdit->source();
1147 if ( size.isValid() && size.width() > 0 )
1148 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.