41QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
47 mSelector->setDockMode( dockMode() );
50 if ( !mBlockChangedSignal )
58 QVBoxLayout *layout =
new QVBoxLayout();
59 layout->setContentsMargins( 0, 0, 0, 0 );
60 layout->addWidget( mSelector );
61 mSymbolSelectorFrame->setLayout( layout );
65 if ( !mBlockChangedSignal )
74 mPropertiesWidget->updateItem( newItem );
82 polygonItem->
setSymbol( mSymbol->clone() );
83 mPropertiesWidget->updateItem( polygonItem );
87void QgsAnnotationPolygonItemWidget::setDockMode(
bool dockMode )
91 mSelector->setDockMode( dockMode );
98 mSelector->setContext( context );
99 mPropertiesWidget->setContext( context );
102QgsAnnotationPolygonItemWidget::~QgsAnnotationPolygonItemWidget() =
default;
110 mItem.reset( polygonItem->
clone() );
111 if ( mItem->symbol() )
113 mSymbol.reset( mItem->symbol()->clone() );
119 mBlockChangedSignal =
true;
120 mSelector->loadSymbol( mSymbol.get() );
121 mSelector->updatePreview();
122 mPropertiesWidget->setItem( mItem.get() );
123 mBlockChangedSignal =
false;
133QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
139 mSelector->setDockMode( dockMode() );
142 if ( !mBlockChangedSignal )
150 QVBoxLayout *layout =
new QVBoxLayout();
151 layout->setContentsMargins( 0, 0, 0, 0 );
152 layout->addWidget( mSelector );
153 mSymbolSelectorFrame->setLayout( layout );
157 if ( !mBlockChangedSignal )
166 mPropertiesWidget->updateItem( newItem );
175 mPropertiesWidget->updateItem( lineItem );
179void QgsAnnotationLineItemWidget::setDockMode(
bool dockMode )
183 mSelector->setDockMode( dockMode );
190 mSelector->setContext( context );
191 mPropertiesWidget->setContext( context );
194QgsAnnotationLineItemWidget::~QgsAnnotationLineItemWidget() =
default;
202 mItem.reset( lineItem->
clone() );
203 if ( mItem->symbol() )
205 mSymbol.reset( mItem->symbol()->clone() );
211 mBlockChangedSignal =
true;
212 mSelector->loadSymbol( mSymbol.get() );
213 mSelector->updatePreview();
214 mPropertiesWidget->setItem( mItem.get() );
215 mBlockChangedSignal =
false;
225QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
231 mSelector->setDockMode( dockMode() );
234 if ( !mBlockChangedSignal )
242 QVBoxLayout *layout =
new QVBoxLayout();
243 layout->setContentsMargins( 0, 0, 0, 0 );
244 layout->addWidget( mSelector );
245 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;
318QgsAnnotationPointTextItemWidget::QgsAnnotationPointTextItemWidget( QWidget *parent )
324 QVBoxLayout *vLayout =
new QVBoxLayout();
325 vLayout->setContentsMargins( 0, 0, 0, 0 );
326 vLayout->addWidget( mTextFormatWidget );
327 mTextFormatWidgetContainer->setLayout( vLayout );
330 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
332 mSpinTextAngle->setClearValue( 0 );
337 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
339 mTextFormatWidget->setDockMode( dockMode() );
346 if ( !mBlockChangedSignal )
351 if ( !mBlockChangedSignal )
354 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
357 if ( !mBlockChangedSignal )
361 connect( mSpinTextAngle, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, [ = ]
363 if ( !mBlockChangedSignal )
367 connect( mRotationModeCombo, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ]
369 if ( !mBlockChangedSignal )
375 if ( !mBlockChangedSignal )
383 updateItem( newItem );
391 mBlockChangedSignal =
true;
392 pointTextItem->
setFormat( mTextFormatWidget->format() );
393 pointTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
394 pointTextItem->setAngle( mSpinTextAngle->value() );
396 pointTextItem->setAlignment( mAlignmentComboBox->currentAlignment() );
397 mBlockChangedSignal =
false;
398 mPropertiesWidget->updateItem( pointTextItem );
402void QgsAnnotationPointTextItemWidget::setDockMode(
bool dockMode )
405 if ( mTextFormatWidget )
406 mTextFormatWidget->setDockMode( dockMode );
412 if ( mTextFormatWidget )
413 mTextFormatWidget->setContext( context );
414 mPropertiesWidget->setContext( context );
417void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
419 mTextEdit->textEdit()->selectAll();
420 mTextEdit->setFocus();
423QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() =
default;
431 mItem.reset( textItem->
clone() );
433 mBlockChangedSignal =
true;
434 mTextFormatWidget->
setFormat( mItem->format() );
436 mTextEdit->setText( mItem->text() );
437 mSpinTextAngle->setValue( mItem->angle() );
438 mRotationModeCombo->setCurrentIndex( mRotationModeCombo->findData( QVariant::fromValue( mItem->rotationMode() ) ) );
439 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
440 mPropertiesWidget->setItem( mItem.get() );
441 mBlockChangedSignal =
false;
446void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
451 if ( context().expressionContext() )
458 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
459 if ( exprDlg.exec() == QDialog::Accepted )
461 expression = exprDlg.expressionText().trimmed();
462 if ( !expression.isEmpty() )
464 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
474QgsAnnotationLineTextItemWidget::QgsAnnotationLineTextItemWidget( QWidget *parent )
480 QVBoxLayout *vLayout =
new QVBoxLayout();
481 vLayout->setContentsMargins( 0, 0, 0, 0 );
482 vLayout->addWidget( mTextFormatWidget );
483 mTextFormatWidgetContainer->setLayout( vLayout );
486 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
488 mTextFormatWidget->setDockMode( dockMode() );
495 if ( !mBlockChangedSignal )
500 if ( !mBlockChangedSignal )
503 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
506 if ( !mBlockChangedSignal )
512 mSpinOffset->setClearValue( 0.0 );
513 connect( mSpinOffset,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, [ = ]
515 if ( !mBlockChangedSignal )
521 if ( !mBlockChangedSignal )
526QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() =
default;
531 updateItem( newItem );
539 mBlockChangedSignal =
true;
540 lineTextItem->
setFormat( mTextFormatWidget->format() );
541 lineTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
543 lineTextItem->setOffsetFromLine( mSpinOffset->value() );
544 lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
545 lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
547 mBlockChangedSignal =
false;
548 mPropertiesWidget->updateItem( lineTextItem );
552void QgsAnnotationLineTextItemWidget::setDockMode(
bool dockMode )
555 if ( mTextFormatWidget )
556 mTextFormatWidget->setDockMode( dockMode );
562 if ( mTextFormatWidget )
563 mTextFormatWidget->setContext( context );
564 mPropertiesWidget->setContext( context );
567void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
569 mTextEdit->textEdit()->selectAll();
570 mTextEdit->setFocus();
579 mItem.reset( textItem->
clone() );
581 mBlockChangedSignal =
true;
582 mTextFormatWidget->
setFormat( mItem->format() );
584 mTextEdit->setText( mItem->text() );
585 mPropertiesWidget->setItem( mItem.get() );
587 mSpinOffset->setValue( mItem->offsetFromLine() );
588 mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
589 mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
591 mBlockChangedSignal =
false;
596void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
601 if ( context().expressionContext() )
608 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
609 if ( exprDlg.exec() == QDialog::Accepted )
611 expression = exprDlg.expressionText().trimmed();
612 if ( !expression.isEmpty() )
614 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
625QgsAnnotationRectangleTextItemWidget::QgsAnnotationRectangleTextItemWidget( QWidget *parent )
639 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
640 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
642 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
643 mFrameSymbolButton->registerExpressionContextGenerator(
this );
645 mSpinBottomMargin->setClearValue( 0 );
646 mSpinTopMargin->setClearValue( 0 );
647 mSpinRightMargin->setClearValue( 0 );
648 mSpinLeftMargin->setClearValue( 0 );
653 QVBoxLayout *vLayout =
new QVBoxLayout();
654 vLayout->setContentsMargins( 0, 0, 0, 0 );
655 vLayout->addWidget( mTextFormatWidget );
656 mTextFormatWidgetContainer->setLayout( vLayout );
659 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
661 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
662 mVerticalAlignmentComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
664 mTextFormatWidget->setDockMode( dockMode() );
674 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked );
678 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
679 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
680 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
681 connect( mFrameSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
682 connect( mSpinTopMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
683 connect( mSpinRightMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
684 connect( mSpinLeftMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
685 connect( mSpinBottomMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
690 connect( mWidthSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setWidth );
691 connect( mHeightSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setHeight );
693 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationRectangleTextItemWidget::sizeModeChanged );
694 mWidgetFixedSize->hide();
701 updateItem( newItem );
709 mBlockChangedSignal =
true;
710 rectTextItem->
setFormat( mTextFormatWidget->format() );
711 rectTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
712 rectTextItem->setAlignment( mAlignmentComboBox->currentAlignment() | mVerticalAlignmentComboBox->currentAlignment() );
716 rectTextItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
717 rectTextItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
719 rectTextItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
720 rectTextItem->setFrameEnabled( mFrameCheckbox->isChecked() );
721 rectTextItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol >() );
722 rectTextItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol >() );
724 rectTextItem->setMargins(
QgsMargins( mSpinLeftMargin->value(),
725 mSpinTopMargin->value(),
726 mSpinRightMargin->value(),
727 mSpinBottomMargin->value() ) );
728 rectTextItem->setMarginsUnit( mMarginUnitWidget->unit() );
730 if ( mUpdateItemPosition )
732 rectTextItem->setBounds( mItem->bounds() );
733 mUpdateItemPosition =
false;
736 mBlockChangedSignal =
false;
738 mPropertiesWidget->updateItem( rectTextItem );
742void QgsAnnotationRectangleTextItemWidget::setDockMode(
bool dockMode )
745 if ( mTextFormatWidget )
746 mTextFormatWidget->setDockMode( dockMode );
752 if ( mTextFormatWidget )
753 mTextFormatWidget->setContext( context );
754 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
755 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
756 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
757 mFrameSymbolButton->setMessageBar( context.
messageBar() );
758 mPropertiesWidget->setContext( context );
764 if ( context().expressionContext() )
768 return expressionContext;
771void QgsAnnotationRectangleTextItemWidget::focusDefaultWidget()
773 mTextEdit->textEdit()->selectAll();
774 mTextEdit->setFocus();
777QgsAnnotationRectangleTextItemWidget::~QgsAnnotationRectangleTextItemWidget() =
default;
785 mItem.reset( textItem->
clone() );
787 mBlockChangedSignal =
true;
788 mTextFormatWidget->
setFormat( mItem->format() );
790 mTextEdit->setText( mItem->text() );
791 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
792 mVerticalAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignVertical_Mask );
793 mPropertiesWidget->setItem( mItem.get() );
797 mBackgroundSymbolButton->setSymbol( symbol->clone() );
801 mFrameSymbolButton->setSymbol( symbol->clone() );
803 mMarginUnitWidget->setUnit( textItem->
marginsUnit() );
804 mSpinLeftMargin->setValue( textItem->
margins().
left() );
805 mSpinTopMargin->setValue( textItem->
margins().
top() );
806 mSpinRightMargin->setValue( textItem->
margins().
right() );
809 mWidthSpinBox->setValue( textItem->
fixedSize().width() );
810 mHeightSpinBox->setValue( textItem->
fixedSize().height() );
811 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( textItem->
placementMode() ) ) );
813 mBlockChangedSignal =
false;
818void QgsAnnotationRectangleTextItemWidget::onWidgetChanged()
820 if ( !mBlockChangedSignal )
824void QgsAnnotationRectangleTextItemWidget::sizeModeChanged()
830 mWidgetFixedSize->hide();
834 mWidgetFixedSize->show();
845 const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
846 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
848 mUpdateItemPosition =
true;
852 mWidgetFixedSize->hide();
860void QgsAnnotationRectangleTextItemWidget::setWidth()
865void QgsAnnotationRectangleTextItemWidget::setHeight()
870void QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked()
876 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
877 if ( exprDlg.exec() == QDialog::Accepted )
879 expression = exprDlg.expressionText().trimmed();
880 if ( !expression.isEmpty() )
882 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
892QgsAnnotationPictureItemWidget::QgsAnnotationPictureItemWidget( QWidget *parent )
907 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
908 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
910 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
911 mFrameSymbolButton->registerExpressionContextGenerator(
this );
915 if ( !mBlockChangedSignal )
919 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationPictureItemWidget::sizeModeChanged );
921 connect( mRadioSVG, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
922 connect( mRadioRaster, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
925 if ( !mRadioSVG->isChecked() && QFileInfo( source ).suffix().compare( QLatin1String(
"svg" ), Qt::CaseInsensitive ) == 0 )
927 mRadioSVG->setChecked(
true );
933 connect( mLockAspectRatioCheck, &QCheckBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
934 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
935 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
936 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
940 connect( mWidthSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setWidth );
941 connect( mHeightSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setHeight );
945QgsAnnotationPictureItemWidget::~QgsAnnotationPictureItemWidget() =
default;
950 updateItem( newItem );
958 const bool svg = mRadioSVG->isChecked();
960 const QString path = mSourceLineEdit->source();
961 pictureItem->
setPath( newFormat, path );
964 switch ( pictureItem->placementMode() )
967 pictureItem->setLockAspectRatio( mLockAspectRatioCheck->isChecked() );
971 pictureItem->setLockAspectRatio( mLockAspectRatio->isChecked() );
975 pictureItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
976 pictureItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
978 pictureItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
979 pictureItem->setFrameEnabled( mFrameCheckbox->isChecked() );
980 pictureItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol >() );
981 pictureItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol >() );
983 if ( mUpdateItemPosition )
985 pictureItem->setBounds( mItem->bounds() );
986 mUpdateItemPosition =
false;
989 mPropertiesWidget->updateItem( pictureItem );
993void QgsAnnotationPictureItemWidget::setDockMode(
bool dockMode )
1001 mPropertiesWidget->setContext( context );
1002 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
1003 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
1004 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
1005 mFrameSymbolButton->setMessageBar( context.
messageBar() );
1011 if ( context().expressionContext() )
1015 return expressionContext;
1018void QgsAnnotationPictureItemWidget::focusDefaultWidget()
1020 mSourceLineEdit->setFocus();
1029 mItem.reset( pictureItem->
clone() );
1031 mBlockChangedSignal =
true;
1032 mPropertiesWidget->setItem( mItem.get() );
1034 mLockAspectRatioCheck->setChecked( mItem->lockAspectRatio() );
1035 mLockAspectRatio->setLocked( mItem->lockAspectRatio() );
1036 switch ( pictureItem->
format() )
1039 mRadioSVG->setChecked(
true );
1042 mRadioRaster->setChecked(
true );
1048 mSourceLineEdit->setSource( pictureItem->
path() );
1052 mBackgroundSymbolButton->setSymbol( symbol->clone() );
1054 mFrameCheckbox->setChecked( pictureItem->
frameEnabled() );
1056 mFrameSymbolButton->setSymbol( symbol->clone() );
1058 mWidthSpinBox->setValue( pictureItem->
fixedSize().width() );
1059 mHeightSpinBox->setValue( pictureItem->
fixedSize().height() );
1060 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( pictureItem->
placementMode() ) ) );
1063 mBlockChangedSignal =
false;
1068void QgsAnnotationPictureItemWidget::onWidgetChanged()
1070 if ( !mBlockChangedSignal )
1074void QgsAnnotationPictureItemWidget::modeChanged(
bool checked )
1079 const bool svg = mRadioSVG->isChecked();
1089void QgsAnnotationPictureItemWidget::sizeModeChanged()
1095 mSizeStackedWidget->setCurrentWidget( mPageSpatialBounds );
1099 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1107 const QgsRectangle itemBounds = details->boundingBox();
1110 const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
1111 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
1113 mUpdateItemPosition =
true;
1117 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1125void QgsAnnotationPictureItemWidget::setWidth()
1127 if ( mLockAspectRatio->locked() )
1129 const double ratio = pictureAspectRatio();
1131 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1137void QgsAnnotationPictureItemWidget::setHeight()
1139 if ( mLockAspectRatio->locked() )
1141 const double ratio = pictureAspectRatio();
1143 whileBlocking( mWidthSpinBox )->setValue( mHeightSpinBox->value() / ratio );
1149void QgsAnnotationPictureItemWidget::setLockAspectRatio(
bool locked )
1151 if ( locked && !mBlockChangedSignal )
1153 const double ratio = pictureAspectRatio();
1155 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1161double QgsAnnotationPictureItemWidget::pictureAspectRatio()
const
1163 const bool svg = mRadioSVG->isChecked();
1164 const QString path = mSourceLineEdit->source();
1174 if ( size.isValid() && size.width() > 0 )
1175 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 setFormat(const QgsTextFormat &format)
Sets the text format used to render the text.
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.
void setPath(Qgis::PictureFormat format, const QString &path)
Sets the format and path of the image used to render the item.
An annotation item which renders a text string at a point location.
void setFormat(const QgsTextFormat &format)
Sets the text format used to render the text.
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.
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.
void setFormat(const QgsTextFormat &format)
Sets the text format used to render the text.
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.
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 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 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.
The QgsMargins class 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 QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
A class to represent a 2D point.
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.
double width() const
Returns the width of the rectangle.
QgsPointXY center() const
Returns the center point of the rectangle.
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.
A widget for editing rich text documents, with support for user controlled formatting of text and ins...
@ 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.
A widget for customizing text formatting settings.
void widgetChanged()
Emitted when the text format defined by the widget changes.
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.