16#include "moc_qgsannotationitemwidget_impl.cpp"
42QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
48 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 );
64 if ( !mBlockChangedSignal )
73 mPropertiesWidget->updateItem( newItem );
81 polygonItem->
setSymbol( mSymbol->clone() );
82 mPropertiesWidget->updateItem( polygonItem );
86void QgsAnnotationPolygonItemWidget::setDockMode(
bool dockMode )
90 mSelector->setDockMode( dockMode );
97 mSelector->setContext( context );
98 mPropertiesWidget->setContext( context );
101QgsAnnotationPolygonItemWidget::~QgsAnnotationPolygonItemWidget() =
default;
109 mItem.reset( polygonItem->
clone() );
110 if ( mItem->symbol() )
112 mSymbol.reset( mItem->symbol()->clone() );
118 mBlockChangedSignal =
true;
119 mSelector->loadSymbol( mSymbol.get() );
120 mSelector->updatePreview();
121 mPropertiesWidget->setItem( mItem.get() );
122 mBlockChangedSignal =
false;
132QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
138 mSelector->setDockMode( dockMode() );
140 if ( !mBlockChangedSignal )
148 QVBoxLayout *layout =
new QVBoxLayout();
149 layout->setContentsMargins( 0, 0, 0, 0 );
150 layout->addWidget( mSelector );
151 mSymbolSelectorFrame->setLayout( layout );
154 if ( !mBlockChangedSignal )
163 mPropertiesWidget->updateItem( newItem );
172 mPropertiesWidget->updateItem( lineItem );
176void QgsAnnotationLineItemWidget::setDockMode(
bool dockMode )
180 mSelector->setDockMode( dockMode );
187 mSelector->setContext( context );
188 mPropertiesWidget->setContext( context );
191QgsAnnotationLineItemWidget::~QgsAnnotationLineItemWidget() =
default;
199 mItem.reset( lineItem->
clone() );
200 if ( mItem->symbol() )
202 mSymbol.reset( mItem->symbol()->clone() );
208 mBlockChangedSignal =
true;
209 mSelector->loadSymbol( mSymbol.get() );
210 mSelector->updatePreview();
211 mPropertiesWidget->setItem( mItem.get() );
212 mBlockChangedSignal =
false;
222QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
228 mSelector->setDockMode( dockMode() );
230 if ( !mBlockChangedSignal )
238 QVBoxLayout *layout =
new QVBoxLayout();
239 layout->setContentsMargins( 0, 0, 0, 0 );
240 layout->addWidget( mSelector );
241 mSymbolSelectorFrame->setLayout( layout );
244 if ( !mBlockChangedSignal )
253 mPropertiesWidget->updateItem( newItem );
261 markerItem->
setSymbol( mSymbol->clone() );
262 mPropertiesWidget->updateItem( markerItem );
266void QgsAnnotationMarkerItemWidget::setDockMode(
bool dockMode )
270 mSelector->setDockMode( dockMode );
277 mSelector->setContext( context );
278 mPropertiesWidget->setContext( context );
281QgsAnnotationMarkerItemWidget::~QgsAnnotationMarkerItemWidget() =
default;
289 mItem.reset( markerItem->
clone() );
290 if ( mItem->symbol() )
292 mSymbol.reset( mItem->symbol()->clone() );
298 mBlockChangedSignal =
true;
299 mSelector->loadSymbol( mSymbol.get() );
300 mSelector->updatePreview();
301 mPropertiesWidget->setItem( mItem.get() );
302 mBlockChangedSignal =
false;
312QgsAnnotationPointTextItemWidget::QgsAnnotationPointTextItemWidget( QWidget *parent )
318 QVBoxLayout *vLayout =
new QVBoxLayout();
319 vLayout->setContentsMargins( 0, 0, 0, 0 );
320 vLayout->addWidget( mTextFormatWidget );
321 mTextFormatWidgetContainer->setLayout( vLayout );
324 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
326 mSpinTextAngle->setClearValue( 0 );
331 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
333 mTextFormatWidget->setDockMode( dockMode() );
339 if ( !mBlockChangedSignal )
343 if ( !mBlockChangedSignal )
346 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
348 if ( !mBlockChangedSignal )
352 connect( mSpinTextAngle, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=] {
353 if ( !mBlockChangedSignal )
357 connect( mRotationModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=] {
358 if ( !mBlockChangedSignal )
363 if ( !mBlockChangedSignal )
371 updateItem( newItem );
379 mBlockChangedSignal =
true;
380 pointTextItem->
setFormat( mTextFormatWidget->format() );
381 pointTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
382 pointTextItem->setAngle( mSpinTextAngle->value() );
384 pointTextItem->setAlignment( mAlignmentComboBox->currentAlignment() );
385 mBlockChangedSignal =
false;
386 mPropertiesWidget->updateItem( pointTextItem );
390void QgsAnnotationPointTextItemWidget::setDockMode(
bool dockMode )
393 if ( mTextFormatWidget )
394 mTextFormatWidget->setDockMode( dockMode );
400 if ( mTextFormatWidget )
401 mTextFormatWidget->setContext( context );
402 mPropertiesWidget->setContext( context );
405void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
407 mTextEdit->textEdit()->selectAll();
408 mTextEdit->setFocus();
411QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() =
default;
419 mItem.reset( textItem->
clone() );
421 mBlockChangedSignal =
true;
422 mTextFormatWidget->
setFormat( mItem->format() );
424 mTextEdit->setText( mItem->text() );
425 mSpinTextAngle->setValue( mItem->angle() );
426 mRotationModeCombo->setCurrentIndex( mRotationModeCombo->findData( QVariant::fromValue( mItem->rotationMode() ) ) );
427 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
428 mPropertiesWidget->setItem( mItem.get() );
429 mBlockChangedSignal =
false;
434void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
439 if ( context().expressionContext() )
446 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
447 if ( exprDlg.exec() == QDialog::Accepted )
449 expression = exprDlg.expressionText().trimmed();
450 if ( !expression.isEmpty() )
452 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
462QgsAnnotationLineTextItemWidget::QgsAnnotationLineTextItemWidget( QWidget *parent )
468 QVBoxLayout *vLayout =
new QVBoxLayout();
469 vLayout->setContentsMargins( 0, 0, 0, 0 );
470 vLayout->addWidget( mTextFormatWidget );
471 mTextFormatWidgetContainer->setLayout( vLayout );
474 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
476 mTextFormatWidget->setDockMode( dockMode() );
482 if ( !mBlockChangedSignal )
486 if ( !mBlockChangedSignal )
489 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
491 if ( !mBlockChangedSignal )
496 mSpinOffset->setClearValue( 0.0 );
497 connect( mSpinOffset,
static_cast<void ( QDoubleSpinBox::* )(
double )
>( &QDoubleSpinBox::valueChanged ),
this, [=] {
498 if ( !mBlockChangedSignal )
503 if ( !mBlockChangedSignal )
508QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() =
default;
513 updateItem( newItem );
521 mBlockChangedSignal =
true;
522 lineTextItem->
setFormat( mTextFormatWidget->format() );
523 lineTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
525 lineTextItem->setOffsetFromLine( mSpinOffset->value() );
526 lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
527 lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
529 mBlockChangedSignal =
false;
530 mPropertiesWidget->updateItem( lineTextItem );
534void QgsAnnotationLineTextItemWidget::setDockMode(
bool dockMode )
537 if ( mTextFormatWidget )
538 mTextFormatWidget->setDockMode( dockMode );
544 if ( mTextFormatWidget )
545 mTextFormatWidget->setContext( context );
546 mPropertiesWidget->setContext( context );
549void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
551 mTextEdit->textEdit()->selectAll();
552 mTextEdit->setFocus();
561 mItem.reset( textItem->
clone() );
563 mBlockChangedSignal =
true;
564 mTextFormatWidget->
setFormat( mItem->format() );
566 mTextEdit->setText( mItem->text() );
567 mPropertiesWidget->setItem( mItem.get() );
569 mSpinOffset->setValue( mItem->offsetFromLine() );
570 mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
571 mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
573 mBlockChangedSignal =
false;
578void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
583 if ( context().expressionContext() )
590 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
591 if ( exprDlg.exec() == QDialog::Accepted )
593 expression = exprDlg.expressionText().trimmed();
594 if ( !expression.isEmpty() )
596 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
606QgsAnnotationRectangleTextItemWidget::QgsAnnotationRectangleTextItemWidget( QWidget *parent )
619 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
620 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
622 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
623 mFrameSymbolButton->registerExpressionContextGenerator(
this );
625 mSpinBottomMargin->setClearValue( 0 );
626 mSpinTopMargin->setClearValue( 0 );
627 mSpinRightMargin->setClearValue( 0 );
628 mSpinLeftMargin->setClearValue( 0 );
632 QVBoxLayout *vLayout =
new QVBoxLayout();
633 vLayout->setContentsMargins( 0, 0, 0, 0 );
634 vLayout->addWidget( mTextFormatWidget );
635 mTextFormatWidgetContainer->setLayout( vLayout );
638 mTextEdit->setMaximumHeight( mTextEdit->fontMetrics().height() * 10 );
640 mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
641 mVerticalAlignmentComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
643 mTextFormatWidget->setDockMode( dockMode() );
652 connect( mInsertExpressionButton, &QPushButton::clicked,
this, &QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked );
656 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
657 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
658 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
659 connect( mFrameSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
660 connect( mSpinTopMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
661 connect( mSpinRightMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
662 connect( mSpinLeftMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
663 connect( mSpinBottomMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
668 connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setWidth );
669 connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationRectangleTextItemWidget::setHeight );
671 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationRectangleTextItemWidget::sizeModeChanged );
672 mWidgetFixedSize->hide();
679 updateItem( newItem );
687 mBlockChangedSignal =
true;
688 rectTextItem->
setFormat( mTextFormatWidget->format() );
689 rectTextItem->setText( mTextFormatWidget->format().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
690 rectTextItem->setAlignment( mAlignmentComboBox->currentAlignment() | mVerticalAlignmentComboBox->currentAlignment() );
694 rectTextItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
695 rectTextItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
697 rectTextItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
698 rectTextItem->setFrameEnabled( mFrameCheckbox->isChecked() );
699 rectTextItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
700 rectTextItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
702 rectTextItem->setMargins(
QgsMargins( mSpinLeftMargin->value(), mSpinTopMargin->value(), mSpinRightMargin->value(), mSpinBottomMargin->value() ) );
703 rectTextItem->setMarginsUnit( mMarginUnitWidget->unit() );
705 if ( mUpdateItemPosition )
707 rectTextItem->setBounds( mItem->bounds() );
708 mUpdateItemPosition =
false;
711 mBlockChangedSignal =
false;
713 mPropertiesWidget->updateItem( rectTextItem );
717void QgsAnnotationRectangleTextItemWidget::setDockMode(
bool dockMode )
720 if ( mTextFormatWidget )
721 mTextFormatWidget->setDockMode( dockMode );
727 if ( mTextFormatWidget )
728 mTextFormatWidget->setContext( context );
729 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
730 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
731 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
732 mFrameSymbolButton->setMessageBar( context.
messageBar() );
733 mPropertiesWidget->setContext( context );
739 if ( context().expressionContext() )
743 return expressionContext;
746void QgsAnnotationRectangleTextItemWidget::focusDefaultWidget()
748 mTextEdit->textEdit()->selectAll();
749 mTextEdit->setFocus();
752QgsAnnotationRectangleTextItemWidget::~QgsAnnotationRectangleTextItemWidget() =
default;
760 mItem.reset( textItem->
clone() );
762 mBlockChangedSignal =
true;
763 mTextFormatWidget->
setFormat( mItem->format() );
765 mTextEdit->setText( mItem->text() );
766 mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
767 mVerticalAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignVertical_Mask );
768 mPropertiesWidget->setItem( mItem.get() );
772 mBackgroundSymbolButton->setSymbol( symbol->clone() );
776 mFrameSymbolButton->setSymbol( symbol->clone() );
778 mMarginUnitWidget->setUnit( textItem->
marginsUnit() );
779 mSpinLeftMargin->setValue( textItem->
margins().
left() );
780 mSpinTopMargin->setValue( textItem->
margins().
top() );
781 mSpinRightMargin->setValue( textItem->
margins().
right() );
784 mWidthSpinBox->setValue( textItem->
fixedSize().width() );
785 mHeightSpinBox->setValue( textItem->
fixedSize().height() );
786 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( textItem->
placementMode() ) ) );
788 mBlockChangedSignal =
false;
793void QgsAnnotationRectangleTextItemWidget::onWidgetChanged()
795 if ( !mBlockChangedSignal )
799void QgsAnnotationRectangleTextItemWidget::sizeModeChanged()
805 mWidgetFixedSize->hide();
809 mWidgetFixedSize->show();
820 const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
821 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
823 mUpdateItemPosition =
true;
827 mWidgetFixedSize->hide();
835void QgsAnnotationRectangleTextItemWidget::setWidth()
840void QgsAnnotationRectangleTextItemWidget::setHeight()
845void QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked()
851 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
852 if ( exprDlg.exec() == QDialog::Accepted )
854 expression = exprDlg.expressionText().trimmed();
855 if ( !expression.isEmpty() )
857 mTextEdit->textEdit()->insertPlainText(
"[%" + expression +
"%]" );
867QgsAnnotationPictureItemWidget::QgsAnnotationPictureItemWidget( QWidget *parent )
881 mBackgroundSymbolButton->setDialogTitle( tr(
"Background" ) );
882 mBackgroundSymbolButton->registerExpressionContextGenerator(
this );
884 mFrameSymbolButton->setDialogTitle( tr(
"Frame" ) );
885 mFrameSymbolButton->registerExpressionContextGenerator(
this );
888 if ( !mBlockChangedSignal )
892 connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsAnnotationPictureItemWidget::sizeModeChanged );
894 connect( mRadioSVG, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
895 connect( mRadioRaster, &QRadioButton::toggled,
this, &QgsAnnotationPictureItemWidget::modeChanged );
897 if ( !mRadioSVG->isChecked() && QFileInfo( source ).suffix().compare( QLatin1String(
"svg" ), Qt::CaseInsensitive ) == 0 )
899 mRadioSVG->setChecked(
true );
905 connect( mLockAspectRatioCheck, &QCheckBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
906 connect( mFrameCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
907 connect( mBackgroundCheckbox, &QGroupBox::toggled,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
908 connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed,
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
912 connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setWidth );
913 connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsAnnotationPictureItemWidget::setHeight );
917QgsAnnotationPictureItemWidget::~QgsAnnotationPictureItemWidget() =
default;
922 updateItem( newItem );
930 const bool svg = mRadioSVG->isChecked();
932 const QString path = mSourceLineEdit->source();
933 pictureItem->
setPath( newFormat, path );
936 switch ( pictureItem->placementMode() )
939 pictureItem->setLockAspectRatio( mLockAspectRatioCheck->isChecked() );
943 pictureItem->setLockAspectRatio( mLockAspectRatio->isChecked() );
947 pictureItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
948 pictureItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
950 pictureItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
951 pictureItem->setFrameEnabled( mFrameCheckbox->isChecked() );
952 pictureItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
953 pictureItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
955 if ( mUpdateItemPosition )
957 pictureItem->setBounds( mItem->bounds() );
958 mUpdateItemPosition =
false;
961 mPropertiesWidget->updateItem( pictureItem );
965void QgsAnnotationPictureItemWidget::setDockMode(
bool dockMode )
973 mPropertiesWidget->setContext( context );
974 mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
975 mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
976 mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
977 mFrameSymbolButton->setMessageBar( context.
messageBar() );
983 if ( context().expressionContext() )
987 return expressionContext;
990void QgsAnnotationPictureItemWidget::focusDefaultWidget()
992 mSourceLineEdit->setFocus();
1001 mItem.reset( pictureItem->
clone() );
1003 mBlockChangedSignal =
true;
1004 mPropertiesWidget->setItem( mItem.get() );
1006 mLockAspectRatioCheck->setChecked( mItem->lockAspectRatio() );
1007 mLockAspectRatio->setLocked( mItem->lockAspectRatio() );
1008 switch ( pictureItem->
format() )
1011 mRadioSVG->setChecked(
true );
1014 mRadioRaster->setChecked(
true );
1020 mSourceLineEdit->setSource( pictureItem->
path() );
1024 mBackgroundSymbolButton->setSymbol( symbol->clone() );
1026 mFrameCheckbox->setChecked( pictureItem->
frameEnabled() );
1028 mFrameSymbolButton->setSymbol( symbol->clone() );
1030 mWidthSpinBox->setValue( pictureItem->
fixedSize().width() );
1031 mHeightSpinBox->setValue( pictureItem->
fixedSize().height() );
1032 mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( pictureItem->
placementMode() ) ) );
1035 mBlockChangedSignal =
false;
1040void QgsAnnotationPictureItemWidget::onWidgetChanged()
1042 if ( !mBlockChangedSignal )
1046void QgsAnnotationPictureItemWidget::modeChanged(
bool checked )
1051 const bool svg = mRadioSVG->isChecked();
1061void QgsAnnotationPictureItemWidget::sizeModeChanged()
1067 mSizeStackedWidget->setCurrentWidget( mPageSpatialBounds );
1071 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1079 const QgsRectangle itemBounds = details->boundingBox();
1082 const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
1083 const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
1085 mUpdateItemPosition =
true;
1089 mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
1097void QgsAnnotationPictureItemWidget::setWidth()
1099 if ( mLockAspectRatio->locked() )
1101 const double ratio = pictureAspectRatio();
1103 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1109void QgsAnnotationPictureItemWidget::setHeight()
1111 if ( mLockAspectRatio->locked() )
1113 const double ratio = pictureAspectRatio();
1115 whileBlocking( mWidthSpinBox )->setValue( mHeightSpinBox->value() / ratio );
1121void QgsAnnotationPictureItemWidget::setLockAspectRatio(
bool locked )
1123 if ( locked && !mBlockChangedSignal )
1125 const double ratio = pictureAspectRatio();
1127 whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
1133double QgsAnnotationPictureItemWidget::pictureAspectRatio()
const
1135 const bool svg = mRadioSVG->isChecked();
1136 const QString path = mSourceLineEdit->source();
1146 if ( size.isValid() && size.width() > 0 )
1147 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.
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.