16#include "moc_qgsannotationitemwidget_impl.cpp"
42QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
48 mSelector->setDockMode( dockMode() );
51 if ( !mBlockChangedSignal )
59 QVBoxLayout *layout =
new QVBoxLayout();
60 layout->setContentsMargins( 0, 0, 0, 0 );
61 layout->addWidget( mSelector );
62 mSymbolSelectorFrame->setLayout( layout );
66 if ( !mBlockChangedSignal )
75 mPropertiesWidget->updateItem( newItem );
83 polygonItem->
setSymbol( mSymbol->clone() );
84 mPropertiesWidget->updateItem( polygonItem );
88void QgsAnnotationPolygonItemWidget::setDockMode(
bool dockMode )
92 mSelector->setDockMode( dockMode );
99 mSelector->setContext( context );
100 mPropertiesWidget->setContext( context );
103QgsAnnotationPolygonItemWidget::~QgsAnnotationPolygonItemWidget() =
default;
111 mItem.reset( polygonItem->
clone() );
112 if ( mItem->symbol() )
114 mSymbol.reset( mItem->symbol()->clone() );
120 mBlockChangedSignal =
true;
121 mSelector->loadSymbol( mSymbol.get() );
122 mSelector->updatePreview();
123 mPropertiesWidget->setItem( mItem.get() );
124 mBlockChangedSignal =
false;
134QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
140 mSelector->setDockMode( dockMode() );
143 if ( !mBlockChangedSignal )
151 QVBoxLayout *layout =
new QVBoxLayout();
152 layout->setContentsMargins( 0, 0, 0, 0 );
153 layout->addWidget( mSelector );
154 mSymbolSelectorFrame->setLayout( layout );
158 if ( !mBlockChangedSignal )
167 mPropertiesWidget->updateItem( newItem );
176 mPropertiesWidget->updateItem( lineItem );
180void QgsAnnotationLineItemWidget::setDockMode(
bool dockMode )
184 mSelector->setDockMode( dockMode );
191 mSelector->setContext( context );
192 mPropertiesWidget->setContext( context );
195QgsAnnotationLineItemWidget::~QgsAnnotationLineItemWidget() =
default;
203 mItem.reset( lineItem->
clone() );
204 if ( mItem->symbol() )
206 mSymbol.reset( mItem->symbol()->clone() );
212 mBlockChangedSignal =
true;
213 mSelector->loadSymbol( mSymbol.get() );
214 mSelector->updatePreview();
215 mPropertiesWidget->setItem( mItem.get() );
216 mBlockChangedSignal =
false;
226QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
232 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 );
250 if ( !mBlockChangedSignal )
259 mPropertiesWidget->updateItem( newItem );
267 markerItem->
setSymbol( mSymbol->clone() );
268 mPropertiesWidget->updateItem( markerItem );
272void QgsAnnotationMarkerItemWidget::setDockMode(
bool dockMode )
276 mSelector->setDockMode( dockMode );
283 mSelector->setContext( context );
284 mPropertiesWidget->setContext( context );
287QgsAnnotationMarkerItemWidget::~QgsAnnotationMarkerItemWidget() =
default;
295 mItem.reset( markerItem->
clone() );
296 if ( mItem->symbol() )
298 mSymbol.reset( mItem->symbol()->clone() );
304 mBlockChangedSignal =
true;
305 mSelector->loadSymbol( mSymbol.get() );
306 mSelector->updatePreview();
307 mPropertiesWidget->setItem( mItem.get() );
308 mBlockChangedSignal =
false;
319QgsAnnotationPointTextItemWidget::QgsAnnotationPointTextItemWidget( QWidget *parent )
325 QVBoxLayout *vLayout =
new QVBoxLayout();
326 vLayout->setContentsMargins( 0, 0, 0, 0 );
327 vLayout->addWidget( mTextFormatWidget );
328 mTextFormatWidgetContainer->setLayout( vLayout );
331 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
333 mSpinTextAngle->setClearValue( 0 );
338 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
340 mTextFormatWidget->setDockMode( dockMode() );
347 if ( !mBlockChangedSignal )
352 if ( !mBlockChangedSignal )
355 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
358 if ( !mBlockChangedSignal )
362 connect( mSpinTextAngle, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, [ = ]
364 if ( !mBlockChangedSignal )
368 connect( mRotationModeCombo, qOverload< int >( &QComboBox::currentIndexChanged ),
this, [ = ]
370 if ( !mBlockChangedSignal )
376 if ( !mBlockChangedSignal )
384 updateItem( newItem );
392 mBlockChangedSignal =
true;
393 pointTextItem->
setFormat( mTextFormatWidget->format() );
394 pointTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
395 pointTextItem->setAngle( mSpinTextAngle->value() );
397 pointTextItem->setAlignment( mAlignmentComboBox->currentAlignment() );
398 mBlockChangedSignal =
false;
399 mPropertiesWidget->updateItem( pointTextItem );
403void QgsAnnotationPointTextItemWidget::setDockMode(
bool dockMode )
406 if ( mTextFormatWidget )
407 mTextFormatWidget->setDockMode( dockMode );
413 if ( mTextFormatWidget )
414 mTextFormatWidget->setContext( context );
415 mPropertiesWidget->setContext( context );
418void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
420 mTextEdit->textEdit()->selectAll();
421 mTextEdit->setFocus();
424QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() =
default;
432 mItem.reset( textItem->
clone() );
434 mBlockChangedSignal =
true;
435 mTextFormatWidget->
setFormat( mItem->format() );
437 mTextEdit->setText( mItem->text() );
438 mSpinTextAngle->setValue( mItem->angle() );
439 mRotationModeCombo->setCurrentIndex( mRotationModeCombo->findData( QVariant::fromValue( mItem->rotationMode() ) ) );
440 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
441 mPropertiesWidget->setItem( mItem.get() );
442 mBlockChangedSignal =
false;
447void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
452 if ( context().expressionContext() )
459 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
460 if ( exprDlg.exec() == QDialog::Accepted )
462 expression = exprDlg.expressionText().trimmed();
463 if ( !expression.isEmpty() )
465 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
475QgsAnnotationLineTextItemWidget::QgsAnnotationLineTextItemWidget( QWidget *parent )
481 QVBoxLayout *vLayout =
new QVBoxLayout();
482 vLayout->setContentsMargins( 0, 0, 0, 0 );
483 vLayout->addWidget( mTextFormatWidget );
484 mTextFormatWidgetContainer->setLayout( vLayout );
487 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
489 mTextFormatWidget->setDockMode( dockMode() );
496 if ( !mBlockChangedSignal )
501 if ( !mBlockChangedSignal )
504 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
507 if ( !mBlockChangedSignal )
513 mSpinOffset->setClearValue( 0.0 );
514 connect( mSpinOffset,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, [ = ]
516 if ( !mBlockChangedSignal )
522 if ( !mBlockChangedSignal )
527QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() =
default;
532 updateItem( newItem );
540 mBlockChangedSignal =
true;
541 lineTextItem->
setFormat( mTextFormatWidget->format() );
542 lineTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
544 lineTextItem->setOffsetFromLine( mSpinOffset->value() );
545 lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
546 lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
548 mBlockChangedSignal =
false;
549 mPropertiesWidget->updateItem( lineTextItem );
553void QgsAnnotationLineTextItemWidget::setDockMode(
bool dockMode )
556 if ( mTextFormatWidget )
557 mTextFormatWidget->setDockMode( dockMode );
563 if ( mTextFormatWidget )
564 mTextFormatWidget->setContext( context );
565 mPropertiesWidget->setContext( context );
568void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
570 mTextEdit->textEdit()->selectAll();
571 mTextEdit->setFocus();
580 mItem.reset( textItem->
clone() );
582 mBlockChangedSignal =
true;
583 mTextFormatWidget->
setFormat( mItem->format() );
585 mTextEdit->setText( mItem->text() );
586 mPropertiesWidget->setItem( mItem.get() );
588 mSpinOffset->setValue( mItem->offsetFromLine() );
589 mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
590 mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
592 mBlockChangedSignal =
false;
597void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
602 if ( context().expressionContext() )
609 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
610 if ( exprDlg.exec() == QDialog::Accepted )
612 expression = exprDlg.expressionText().trimmed();
613 if ( !expression.isEmpty() )
615 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
626QgsAnnotationRectangleTextItemWidget::QgsAnnotationRectangleTextItemWidget( QWidget *parent )
640 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
641 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
643 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
644 mFrameSymbolButton->registerExpressionContextGenerator(
this );
646 mSpinBottomMargin->setClearValue( 0 );
647 mSpinTopMargin->setClearValue( 0 );
648 mSpinRightMargin->setClearValue( 0 );
649 mSpinLeftMargin->setClearValue( 0 );
654 QVBoxLayout *vLayout =
new QVBoxLayout();
655 vLayout->setContentsMargins( 0, 0, 0, 0 );
656 vLayout->addWidget( mTextFormatWidget );
657 mTextFormatWidgetContainer->setLayout( vLayout );
660 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
662 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
663 mVerticalAlignmentComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
665 mTextFormatWidget->setDockMode( dockMode() );
675 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked );
679 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
680 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
681 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
682 connect( mFrameSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
683 connect( mSpinTopMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
684 connect( mSpinRightMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
685 connect( mSpinLeftMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
686 connect( mSpinBottomMargin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
691 connect( mWidthSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setWidth );
692 connect( mHeightSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setHeight );
694 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationRectangleTextItemWidget::sizeModeChanged );
695 mWidgetFixedSize->hide();
702 updateItem( newItem );
710 mBlockChangedSignal =
true;
711 rectTextItem->
setFormat( mTextFormatWidget->format() );
712 rectTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
713 rectTextItem->setAlignment( mAlignmentComboBox->currentAlignment() | mVerticalAlignmentComboBox->currentAlignment() );
717 rectTextItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
718 rectTextItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
720 rectTextItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
721 rectTextItem->setFrameEnabled( mFrameCheckbox->isChecked() );
722 rectTextItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol >() );
723 rectTextItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol >() );
725 rectTextItem->setMargins(
QgsMargins( mSpinLeftMargin->value(),
726 mSpinTopMargin->value(),
727 mSpinRightMargin->value(),
728 mSpinBottomMargin->value() ) );
729 rectTextItem->setMarginsUnit( mMarginUnitWidget->unit() );
731 if ( mUpdateItemPosition )
733 rectTextItem->setBounds( mItem->bounds() );
734 mUpdateItemPosition =
false;
737 mBlockChangedSignal =
false;
739 mPropertiesWidget->updateItem( rectTextItem );
743void QgsAnnotationRectangleTextItemWidget::setDockMode(
bool dockMode )
746 if ( mTextFormatWidget )
747 mTextFormatWidget->setDockMode( dockMode );
753 if ( mTextFormatWidget )
754 mTextFormatWidget->setContext( context );
755 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
756 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
757 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
758 mFrameSymbolButton->setMessageBar( context.
messageBar() );
759 mPropertiesWidget->setContext( context );
765 if ( context().expressionContext() )
769 return expressionContext;
772void QgsAnnotationRectangleTextItemWidget::focusDefaultWidget()
774 mTextEdit->textEdit()->selectAll();
775 mTextEdit->setFocus();
778QgsAnnotationRectangleTextItemWidget::~QgsAnnotationRectangleTextItemWidget() =
default;
786 mItem.reset( textItem->
clone() );
788 mBlockChangedSignal =
true;
789 mTextFormatWidget->
setFormat( mItem->format() );
791 mTextEdit->setText( mItem->text() );
792 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
793 mVerticalAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignVertical_Mask );
794 mPropertiesWidget->setItem( mItem.get() );
798 mBackgroundSymbolButton->setSymbol( symbol->clone() );
802 mFrameSymbolButton->setSymbol( symbol->clone() );
804 mMarginUnitWidget->setUnit( textItem->
marginsUnit() );
805 mSpinLeftMargin->setValue( textItem->
margins().
left() );
806 mSpinTopMargin->setValue( textItem->
margins().
top() );
807 mSpinRightMargin->setValue( textItem->
margins().
right() );
810 mWidthSpinBox->setValue( textItem->
fixedSize().width() );
811 mHeightSpinBox->setValue( textItem->
fixedSize().height() );
812 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( textItem->
placementMode() ) ) );
814 mBlockChangedSignal =
false;
819void QgsAnnotationRectangleTextItemWidget::onWidgetChanged()
821 if ( !mBlockChangedSignal )
825void QgsAnnotationRectangleTextItemWidget::sizeModeChanged()
831 mWidgetFixedSize->hide();
835 mWidgetFixedSize->show();
846 const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
847 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
849 mUpdateItemPosition =
true;
853 mWidgetFixedSize->hide();
861void QgsAnnotationRectangleTextItemWidget::setWidth()
866void QgsAnnotationRectangleTextItemWidget::setHeight()
871void QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked()
877 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
878 if ( exprDlg.exec() == QDialog::Accepted )
880 expression = exprDlg.expressionText().trimmed();
881 if ( !expression.isEmpty() )
883 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
893QgsAnnotationPictureItemWidget::QgsAnnotationPictureItemWidget( QWidget *parent )
908 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
909 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
911 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
912 mFrameSymbolButton->registerExpressionContextGenerator(
this );
916 if ( !mBlockChangedSignal )
920 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationPictureItemWidget::sizeModeChanged );
922 connect( mRadioSVG, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
923 connect( mRadioRaster, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
926 if ( !mRadioSVG->isChecked() && QFileInfo( source ).suffix().compare( QLatin1String(
"svg" ), Qt::CaseInsensitive ) == 0 )
928 mRadioSVG->setChecked(
true );
934 connect( mLockAspectRatioCheck, &QCheckBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
935 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
936 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
937 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
941 connect( mWidthSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setWidth );
942 connect( mHeightSpinBox, qOverload< double >( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setHeight );
946QgsAnnotationPictureItemWidget::~QgsAnnotationPictureItemWidget() =
default;
951 updateItem( newItem );
959 const bool svg = mRadioSVG->isChecked();
961 const QString path = mSourceLineEdit->source();
962 pictureItem->
setPath( newFormat, path );
965 switch ( pictureItem->placementMode() )
968 pictureItem->setLockAspectRatio( mLockAspectRatioCheck->isChecked() );
972 pictureItem->setLockAspectRatio( mLockAspectRatio->isChecked() );
976 pictureItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
977 pictureItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
979 pictureItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
980 pictureItem->setFrameEnabled( mFrameCheckbox->isChecked() );
981 pictureItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol >() );
982 pictureItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol >() );
984 if ( mUpdateItemPosition )
986 pictureItem->setBounds( mItem->bounds() );
987 mUpdateItemPosition =
false;
990 mPropertiesWidget->updateItem( pictureItem );
994void QgsAnnotationPictureItemWidget::setDockMode(
bool dockMode )
1002 mPropertiesWidget->setContext( context );
1003 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
1004 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
1005 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
1006 mFrameSymbolButton->setMessageBar( context.
messageBar() );
1012 if ( context().expressionContext() )
1016 return expressionContext;
1019void QgsAnnotationPictureItemWidget::focusDefaultWidget()
1021 mSourceLineEdit->setFocus();
1030 mItem.reset( pictureItem->
clone() );
1032 mBlockChangedSignal =
true;
1033 mPropertiesWidget->setItem( mItem.get() );
1035 mLockAspectRatioCheck->setChecked( mItem->lockAspectRatio() );
1036 mLockAspectRatio->setLocked( mItem->lockAspectRatio() );
1037 switch ( pictureItem->
format() )
1040 mRadioSVG->setChecked(
true );
1043 mRadioRaster->setChecked(
true );
1049 mSourceLineEdit->setSource( pictureItem->
path() );
1053 mBackgroundSymbolButton->setSymbol( symbol->clone() );
1055 mFrameCheckbox->setChecked( pictureItem->
frameEnabled() );
1057 mFrameSymbolButton->setSymbol( symbol->clone() );
1059 mWidthSpinBox->setValue( pictureItem->
fixedSize().width() );
1060 mHeightSpinBox->setValue( pictureItem->
fixedSize().height() );
1061 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( pictureItem->
placementMode() ) ) );
1064 mBlockChangedSignal =
false;
1069void QgsAnnotationPictureItemWidget::onWidgetChanged()
1071 if ( !mBlockChangedSignal )
1075void QgsAnnotationPictureItemWidget::modeChanged(
bool checked )
1080 const bool svg = mRadioSVG->isChecked();
1090void QgsAnnotationPictureItemWidget::sizeModeChanged()
1096 mSizeStackedWidget->setCurrentWidget( mPageSpatialBounds );
1100 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1108 const QgsRectangle itemBounds = details->boundingBox();
1111 const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
1112 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
1114 mUpdateItemPosition =
true;
1118 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1126void QgsAnnotationPictureItemWidget::setWidth()
1128 if ( mLockAspectRatio->locked() )
1130 const double ratio = pictureAspectRatio();
1132 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1138void QgsAnnotationPictureItemWidget::setHeight()
1140 if ( mLockAspectRatio->locked() )
1142 const double ratio = pictureAspectRatio();
1144 whileBlocking( mWidthSpinBox )->setValue( mHeightSpinBox->value() / ratio );
1150void QgsAnnotationPictureItemWidget::setLockAspectRatio(
bool locked )
1152 if ( locked && !mBlockChangedSignal )
1154 const double ratio = pictureAspectRatio();
1156 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1162double QgsAnnotationPictureItemWidget::pictureAspectRatio()
const
1164 const bool svg = mRadioSVG->isChecked();
1165 const QString path = mSourceLineEdit->source();
1175 if ( size.isValid() && size.width() > 0 )
1176 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.