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 )
 
  321  mSpinTextAngle->setClearValue( 0 );
 
  326  mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight );
 
  333    if ( !mBlockChangedSignal )
 
  337    if ( !mBlockChangedSignal )
 
  340  connect( mInsertExpressionButton, &QPushButton::clicked, 
this, &QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked );
 
  342    if ( !mBlockChangedSignal )
 
  346  connect( mSpinTextAngle, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, [
this] {
 
  347    if ( !mBlockChangedSignal )
 
  351  connect( mRotationModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, [
this] {
 
  352    if ( !mBlockChangedSignal )
 
  357    if ( !mBlockChangedSignal )
 
  365  updateItem( newItem );
 
  373    mBlockChangedSignal = 
true;
 
  374    pointTextItem->
setFormat( mTextFormatButton->textFormat() );
 
  375    pointTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
 
  376    pointTextItem->setAngle( mSpinTextAngle->value() );
 
  378    pointTextItem->setAlignment( mAlignmentComboBox->currentAlignment() );
 
  379    mBlockChangedSignal = 
false;
 
  380    mPropertiesWidget->updateItem( pointTextItem );
 
  387  if ( mTextFormatButton )
 
  389    mTextFormatButton->setMapCanvas( context.
mapCanvas() );
 
  390    mTextFormatButton->setMessageBar( context.
messageBar() );
 
  392  mPropertiesWidget->setContext( context );
 
  395void QgsAnnotationPointTextItemWidget::focusDefaultWidget()
 
  397  mTextEdit->textEdit()->selectAll();
 
  398  mTextEdit->setFocus();
 
  401QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() = 
default;
 
  409  mItem.reset( textItem->
clone() );
 
  411  mBlockChangedSignal = 
true;
 
  412  mTextFormatButton->setTextFormat( mItem->format() );
 
  414  mTextEdit->
setText( mItem->text() );
 
  415  mSpinTextAngle->setValue( mItem->angle() );
 
  416  mRotationModeCombo->setCurrentIndex( mRotationModeCombo->findData( QVariant::fromValue( mItem->rotationMode() ) ) );
 
  417  mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
 
  418  mPropertiesWidget->setItem( mItem.get() );
 
  419  mBlockChangedSignal = 
false;
 
  424void QgsAnnotationPointTextItemWidget::mInsertExpressionButton_clicked()
 
  429  if ( context().expressionContext() )
 
  436  exprDlg.setWindowTitle( tr( 
"Insert Expression" ) );
 
  437  if ( exprDlg.exec() == QDialog::Accepted )
 
  439    expression = exprDlg.expressionText().trimmed();
 
  440    if ( !expression.isEmpty() )
 
  442      mTextEdit->textEdit()->insertPlainText( 
"[%" + expression + 
"%]" );
 
  452QgsAnnotationLineTextItemWidget::QgsAnnotationLineTextItemWidget( QWidget *parent )
 
  466    if ( !mBlockChangedSignal )
 
  470    if ( !mBlockChangedSignal )
 
  473  connect( mInsertExpressionButton, &QPushButton::clicked, 
this, &QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked );
 
  475    if ( !mBlockChangedSignal )
 
  480  mSpinOffset->setClearValue( 0.0 );
 
  481  connect( mSpinOffset, 
static_cast<void ( QDoubleSpinBox::* )( 
double )
>( &QDoubleSpinBox::valueChanged ), 
this, [
this] {
 
  482    if ( !mBlockChangedSignal )
 
  487    if ( !mBlockChangedSignal )
 
  492QgsAnnotationLineTextItemWidget::~QgsAnnotationLineTextItemWidget() = 
default;
 
  497  updateItem( newItem );
 
  505    mBlockChangedSignal = 
true;
 
  506    lineTextItem->
setFormat( mTextFormatButton->textFormat() );
 
  507    lineTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
 
  509    lineTextItem->setOffsetFromLine( mSpinOffset->value() );
 
  510    lineTextItem->setOffsetFromLineUnit( mOffsetUnitWidget->unit() );
 
  511    lineTextItem->setOffsetFromLineMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
 
  513    mBlockChangedSignal = 
false;
 
  514    mPropertiesWidget->updateItem( lineTextItem );
 
  521  if ( mTextFormatButton )
 
  523    mTextFormatButton->setMapCanvas( context.
mapCanvas() );
 
  524    mTextFormatButton->setMessageBar( context.
messageBar() );
 
  526  mPropertiesWidget->setContext( context );
 
  529void QgsAnnotationLineTextItemWidget::focusDefaultWidget()
 
  531  mTextEdit->textEdit()->selectAll();
 
  532  mTextEdit->setFocus();
 
  541  mItem.reset( textItem->
clone() );
 
  543  mBlockChangedSignal = 
true;
 
  544  mTextFormatButton->setTextFormat( mItem->format() );
 
  546  mTextEdit->
setText( mItem->text() );
 
  547  mPropertiesWidget->setItem( mItem.get() );
 
  549  mSpinOffset->setValue( mItem->offsetFromLine() );
 
  550  mOffsetUnitWidget->setUnit( mItem->offsetFromLineUnit() );
 
  551  mOffsetUnitWidget->setMapUnitScale( mItem->offsetFromLineMapUnitScale() );
 
  553  mBlockChangedSignal = 
false;
 
  558void QgsAnnotationLineTextItemWidget::mInsertExpressionButton_clicked()
 
  563  if ( context().expressionContext() )
 
  570  exprDlg.setWindowTitle( tr( 
"Insert Expression" ) );
 
  571  if ( exprDlg.exec() == QDialog::Accepted )
 
  573    expression = exprDlg.expressionText().trimmed();
 
  574    if ( !expression.isEmpty() )
 
  576      mTextEdit->textEdit()->insertPlainText( 
"[%" + expression + 
"%]" );
 
  586QgsAnnotationRectangleTextItemWidget::QgsAnnotationRectangleTextItemWidget( QWidget *parent )
 
  598  mBackgroundSymbolButton->setDialogTitle( tr( 
"Background" ) );
 
  599  mBackgroundSymbolButton->registerExpressionContextGenerator( 
this );
 
  601  mFrameSymbolButton->setDialogTitle( tr( 
"Frame" ) );
 
  602  mFrameSymbolButton->registerExpressionContextGenerator( 
this );
 
  604  mSpinBottomMargin->setClearValue( 0 );
 
  605  mSpinTopMargin->setClearValue( 0 );
 
  606  mSpinRightMargin->setClearValue( 0 );
 
  607  mSpinLeftMargin->setClearValue( 0 );
 
  614  mAlignmentComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
 
  615  mVerticalAlignmentComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
 
  625  connect( mInsertExpressionButton, &QPushButton::clicked, 
this, &QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked );
 
  629  connect( mFrameCheckbox, &QGroupBox::toggled, 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  630  connect( mBackgroundCheckbox, &QGroupBox::toggled, 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  631  connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed, 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  632  connect( mFrameSymbolButton, &
QgsSymbolButton::changed, 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  633  connect( mSpinTopMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  634  connect( mSpinRightMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  635  connect( mSpinLeftMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  636  connect( mSpinBottomMargin, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationRectangleTextItemWidget::onWidgetChanged );
 
  641  connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationRectangleTextItemWidget::setWidth );
 
  642  connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationRectangleTextItemWidget::setHeight );
 
  644  connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, &QgsAnnotationRectangleTextItemWidget::sizeModeChanged );
 
  645  mWidgetFixedSize->hide();
 
  652  updateItem( newItem );
 
  660    mBlockChangedSignal = 
true;
 
  661    rectTextItem->
setFormat( mTextFormatButton->textFormat() );
 
  662    rectTextItem->setText( mTextFormatButton->textFormat().allowHtmlFormatting() ? mTextEdit->toHtml() : mTextEdit->toPlainText() );
 
  663    rectTextItem->setAlignment( mAlignmentComboBox->currentAlignment() | mVerticalAlignmentComboBox->currentAlignment() );
 
  667    rectTextItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
 
  668    rectTextItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
 
  670    rectTextItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
 
  671    rectTextItem->setFrameEnabled( mFrameCheckbox->isChecked() );
 
  672    rectTextItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
 
  673    rectTextItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
 
  675    rectTextItem->setMargins( 
QgsMargins( mSpinLeftMargin->value(), mSpinTopMargin->value(), mSpinRightMargin->value(), mSpinBottomMargin->value() ) );
 
  676    rectTextItem->setMarginsUnit( mMarginUnitWidget->unit() );
 
  678    if ( mUpdateItemPosition )
 
  680      rectTextItem->setBounds( mItem->bounds() );
 
  681      mUpdateItemPosition = 
false;
 
  684    mBlockChangedSignal = 
false;
 
  686    mPropertiesWidget->updateItem( rectTextItem );
 
  693  if ( mTextFormatButton )
 
  695    mTextFormatButton->setMapCanvas( context.
mapCanvas() );
 
  696    mTextFormatButton->setMessageBar( context.
messageBar() );
 
  698  mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
 
  699  mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
 
  700  mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
 
  701  mFrameSymbolButton->setMessageBar( context.
messageBar() );
 
  702  mPropertiesWidget->setContext( context );
 
  708  if ( context().expressionContext() )
 
  712  return expressionContext;
 
  715void QgsAnnotationRectangleTextItemWidget::focusDefaultWidget()
 
  717  mTextEdit->textEdit()->selectAll();
 
  718  mTextEdit->setFocus();
 
  721QgsAnnotationRectangleTextItemWidget::~QgsAnnotationRectangleTextItemWidget() = 
default;
 
  729  mItem.reset( textItem->
clone() );
 
  731  mBlockChangedSignal = 
true;
 
  732  mTextFormatButton->setTextFormat( mItem->format() );
 
  734  mTextEdit->
setText( mItem->text() );
 
  735  mAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignHorizontal_Mask );
 
  736  mVerticalAlignmentComboBox->setCurrentAlignment( mItem->alignment() & Qt::AlignVertical_Mask );
 
  737  mPropertiesWidget->setItem( mItem.get() );
 
  741    mBackgroundSymbolButton->setSymbol( symbol->clone() );
 
  745    mFrameSymbolButton->setSymbol( symbol->clone() );
 
  747  mMarginUnitWidget->setUnit( textItem->
marginsUnit() );
 
  748  mSpinLeftMargin->setValue( textItem->
margins().
left() );
 
  749  mSpinTopMargin->setValue( textItem->
margins().
top() );
 
  750  mSpinRightMargin->setValue( textItem->
margins().
right() );
 
  753  mWidthSpinBox->setValue( textItem->
fixedSize().width() );
 
  754  mHeightSpinBox->setValue( textItem->
fixedSize().height() );
 
  756  mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( textItem->
placementMode() ) ) );
 
  758  mBlockChangedSignal = 
false;
 
  763void QgsAnnotationRectangleTextItemWidget::onWidgetChanged()
 
  765  if ( !mBlockChangedSignal )
 
  769void QgsAnnotationRectangleTextItemWidget::sizeModeChanged()
 
  775      mWidgetFixedSize->hide();
 
  781        const QgsRectangle itemBoundsMapUnits = details->boundingBox();
 
  784          const QgsPointXY topLeftPixels = canvas->mapSettings().mapToPixel().transform( itemBoundsMapUnits.
xMinimum(), itemBoundsMapUnits.
yMinimum() );
 
  785          const QgsPointXY bottomRightPixels = canvas->mapSettings().mapToPixel().transform( itemBoundsMapUnits.
xMaximum(), itemBoundsMapUnits.
yMaximum() );
 
  786          const double widthPixels = std::abs( bottomRightPixels.
x() - topLeftPixels.
x() );
 
  787          const double heightPixels = std::abs( bottomRightPixels.
y() - topLeftPixels.
y() );
 
  790          const double pixelsPerMm = canvas->mapSettings().outputDpi() / 25.4;
 
  792          mItem->setFixedSize( QSizeF( widthPixels / pixelsPerMm, heightPixels / pixelsPerMm ) );
 
  795          whileBlocking( mWidthSpinBox )->setValue( mItem->fixedSize().width() );
 
  796          whileBlocking( mHeightSpinBox )->setValue( mItem->fixedSize().height() );
 
  797          whileBlocking( mSizeUnitWidget )->setUnit( mItem->fixedSizeUnit() );
 
  799          mUpdateItemPosition = 
true;
 
  803      mWidgetFixedSize->show();
 
  814          const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
 
  815          const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
 
  817          mUpdateItemPosition = 
true;
 
  821      mWidgetFixedSize->hide();
 
  829void QgsAnnotationRectangleTextItemWidget::setWidth()
 
  834void QgsAnnotationRectangleTextItemWidget::setHeight()
 
  839void QgsAnnotationRectangleTextItemWidget::mInsertExpressionButton_clicked()
 
  845  exprDlg.setWindowTitle( tr( 
"Insert Expression" ) );
 
  846  if ( exprDlg.exec() == QDialog::Accepted )
 
  848    expression = exprDlg.expressionText().trimmed();
 
  849    if ( !expression.isEmpty() )
 
  851      mTextEdit->textEdit()->insertPlainText( 
"[%" + expression + 
"%]" );
 
  861QgsAnnotationPictureItemWidget::QgsAnnotationPictureItemWidget( QWidget *parent )
 
  875  mBackgroundSymbolButton->setDialogTitle( tr( 
"Background" ) );
 
  876  mBackgroundSymbolButton->registerExpressionContextGenerator( 
this );
 
  878  mFrameSymbolButton->setDialogTitle( tr( 
"Frame" ) );
 
  879  mFrameSymbolButton->registerExpressionContextGenerator( 
this );
 
  882    if ( !mBlockChangedSignal )
 
  886  connect( mSizeModeCombo, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, &QgsAnnotationPictureItemWidget::sizeModeChanged );
 
  888  connect( mRadioSVG, &QRadioButton::toggled, 
this, &QgsAnnotationPictureItemWidget::modeChanged );
 
  889  connect( mRadioRaster, &QRadioButton::toggled, 
this, &QgsAnnotationPictureItemWidget::modeChanged );
 
  891    if ( !mRadioSVG->isChecked() && QFileInfo( source ).suffix().compare( QLatin1String( 
"svg" ), Qt::CaseInsensitive ) == 0 )
 
  893      mRadioSVG->setChecked( 
true );
 
  899  connect( mLockAspectRatioCheck, &QCheckBox::toggled, 
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
 
  900  connect( mFrameCheckbox, &QGroupBox::toggled, 
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
 
  901  connect( mBackgroundCheckbox, &QGroupBox::toggled, 
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
 
  902  connect( mBackgroundSymbolButton, &
QgsSymbolButton::changed, 
this, &QgsAnnotationPictureItemWidget::onWidgetChanged );
 
  906  connect( mWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationPictureItemWidget::setWidth );
 
  907  connect( mHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, &QgsAnnotationPictureItemWidget::setHeight );
 
  911QgsAnnotationPictureItemWidget::~QgsAnnotationPictureItemWidget() = 
default;
 
  916  updateItem( newItem );
 
  924    const bool svg = mRadioSVG->isChecked();
 
  926    const QString path = mSourceLineEdit->source();
 
  927    pictureItem->
setPath( newFormat, path );
 
  930    switch ( pictureItem->placementMode() )
 
  933        pictureItem->setLockAspectRatio( mLockAspectRatioCheck->isChecked() );
 
  937        pictureItem->setLockAspectRatio( mLockAspectRatio->isChecked() );
 
  941    pictureItem->setFixedSize( QSizeF( mWidthSpinBox->value(), mHeightSpinBox->value() ) );
 
  942    pictureItem->setFixedSizeUnit( mSizeUnitWidget->unit() );
 
  944    pictureItem->setBackgroundEnabled( mBackgroundCheckbox->isChecked() );
 
  945    pictureItem->setFrameEnabled( mFrameCheckbox->isChecked() );
 
  946    pictureItem->setBackgroundSymbol( mBackgroundSymbolButton->clonedSymbol<
QgsFillSymbol>() );
 
  947    pictureItem->setFrameSymbol( mFrameSymbolButton->clonedSymbol<
QgsFillSymbol>() );
 
  949    if ( mUpdateItemPosition )
 
  951      pictureItem->setBounds( mItem->bounds() );
 
  952      mUpdateItemPosition = 
false;
 
  955    mPropertiesWidget->updateItem( pictureItem );
 
  959void QgsAnnotationPictureItemWidget::setDockMode( 
bool dockMode )
 
  967  mPropertiesWidget->setContext( context );
 
  968  mBackgroundSymbolButton->setMapCanvas( context.
mapCanvas() );
 
  969  mBackgroundSymbolButton->setMessageBar( context.
messageBar() );
 
  970  mFrameSymbolButton->setMapCanvas( context.
mapCanvas() );
 
  971  mFrameSymbolButton->setMessageBar( context.
messageBar() );
 
  977  if ( context().expressionContext() )
 
  981  return expressionContext;
 
  984void QgsAnnotationPictureItemWidget::focusDefaultWidget()
 
  986  mSourceLineEdit->setFocus();
 
  995  mItem.reset( pictureItem->
clone() );
 
  997  mBlockChangedSignal = 
true;
 
  998  mPropertiesWidget->setItem( mItem.get() );
 
 1000  mLockAspectRatioCheck->setChecked( mItem->lockAspectRatio() );
 
 1001  mLockAspectRatio->setLocked( mItem->lockAspectRatio() );
 
 1002  switch ( pictureItem->
format() )
 
 1005      mRadioSVG->setChecked( 
true );
 
 1008      mRadioRaster->setChecked( 
true );
 
 1014  mSourceLineEdit->setSource( pictureItem->
path() );
 
 1018    mBackgroundSymbolButton->setSymbol( symbol->clone() );
 
 1020  mFrameCheckbox->setChecked( pictureItem->
frameEnabled() );
 
 1022    mFrameSymbolButton->setSymbol( symbol->clone() );
 
 1024  mWidthSpinBox->setValue( pictureItem->
fixedSize().width() );
 
 1025  mHeightSpinBox->setValue( pictureItem->
fixedSize().height() );
 
 1026  mSizeModeCombo->setCurrentIndex( mSizeModeCombo->findData( QVariant::fromValue( pictureItem->
placementMode() ) ) );
 
 1029  mBlockChangedSignal = 
false;
 
 1034void QgsAnnotationPictureItemWidget::onWidgetChanged()
 
 1036  if ( !mBlockChangedSignal )
 
 1040void QgsAnnotationPictureItemWidget::modeChanged( 
bool checked )
 
 1045  const bool svg = mRadioSVG->isChecked();
 
 1055void QgsAnnotationPictureItemWidget::sizeModeChanged()
 
 1061      mSizeStackedWidget->setCurrentWidget( mPageSpatialBounds );
 
 1065      mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
 
 1073        const QgsRectangle itemBounds = details->boundingBox();
 
 1076          const double centerX = ( itemBounds.
center().
x() - canvas->extent().xMinimum() ) / canvas->extent().
width();
 
 1077          const double centerY = ( canvas->extent().yMaximum() - itemBounds.
center().
y() ) / canvas->extent().height();
 
 1079          mUpdateItemPosition = 
true;
 
 1083      mSizeStackedWidget->setCurrentWidget( mPageFixedSize );
 
 1091void QgsAnnotationPictureItemWidget::setWidth()
 
 1093  if ( mLockAspectRatio->locked() )
 
 1095    const double ratio = pictureAspectRatio();
 
 1097      whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
 
 1103void QgsAnnotationPictureItemWidget::setHeight()
 
 1105  if ( mLockAspectRatio->locked() )
 
 1107    const double ratio = pictureAspectRatio();
 
 1109      whileBlocking( mWidthSpinBox )->setValue( mHeightSpinBox->value() / ratio );
 
 1115void QgsAnnotationPictureItemWidget::setLockAspectRatio( 
bool locked )
 
 1117  if ( locked && !mBlockChangedSignal )
 
 1119    const double ratio = pictureAspectRatio();
 
 1121      whileBlocking( mHeightSpinBox )->setValue( mWidthSpinBox->value() * ratio );
 
 1127double QgsAnnotationPictureItemWidget::pictureAspectRatio()
 const 
 1129  const bool svg = mRadioSVG->isChecked();
 
 1130  const QString path = mSourceLineEdit->source();
 
 1140  if ( size.isValid() && size.width() > 0 )
 
 1141    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.
 
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 setText(const QString &text)
Sets the text rendered by the item.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.