QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgslayoutpicturewidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutpicturewidget.cpp
3  --------------------------
4  begin : October 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgslayoutpicturewidget.h"
19 #include "qgsapplication.h"
20 #include "qgslayoutitemmap.h"
21 #include "qgslayoutitempicture.h"
22 #include "qgslayout.h"
24 #include "qgssvgcache.h"
25 #include "qgssettings.h"
26 #include "qgssvgselectorwidget.h"
28 
29 #include <QDoubleValidator>
30 #include <QFileDialog>
31 #include <QFileInfo>
32 #include <QImageReader>
33 #include <QMessageBox>
34 #include <QPainter>
35 #include <QProgressDialog>
36 #include <QSvgRenderer>
37 
39  : QgsLayoutItemBaseWidget( nullptr, picture )
40  , mPicture( picture )
41 {
42  setupUi( this );
43 
44  mSvgSelectorWidget->setAllowParameters( true );
45  mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
46  mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
47  mSvgSelectorWidget->initParametersModel( layoutObject(), coverageLayer() );
48 
49  mResizeModeComboBox->addItem( tr( "Zoom" ), QgsLayoutItemPicture::Zoom );
50  mResizeModeComboBox->addItem( tr( "Stretch" ), QgsLayoutItemPicture::Stretch );
51  mResizeModeComboBox->addItem( tr( "Clip" ), QgsLayoutItemPicture::Clip );
52  mResizeModeComboBox->addItem( tr( "Zoom and Resize Frame" ), QgsLayoutItemPicture::ZoomResizeFrame );
53  mResizeModeComboBox->addItem( tr( "Resize Frame to Image Size" ), QgsLayoutItemPicture::FrameToImageSize );
54 
55  mAnchorPointComboBox->addItem( tr( "Top Left" ), QgsLayoutItem::UpperLeft );
56  mAnchorPointComboBox->addItem( tr( "Top Center" ), QgsLayoutItem::UpperMiddle );
57  mAnchorPointComboBox->addItem( tr( "Top Right" ), QgsLayoutItem::UpperRight );
58  mAnchorPointComboBox->addItem( tr( "Middle Left" ), QgsLayoutItem::MiddleLeft );
59  mAnchorPointComboBox->addItem( tr( "Middle" ), QgsLayoutItem::Middle );
60  mAnchorPointComboBox->addItem( tr( "Middle Right" ), QgsLayoutItem::MiddleRight );
61  mAnchorPointComboBox->addItem( tr( "Bottom Left" ), QgsLayoutItem::LowerLeft );
62  mAnchorPointComboBox->addItem( tr( "Bottom Center" ), QgsLayoutItem::LowerMiddle );
63  mAnchorPointComboBox->addItem( tr( "Bottom Right" ), QgsLayoutItem::LowerRight );
64 
65  connect( mPictureRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mPictureRotationSpinBox_valueChanged );
66  connect( mRotationFromComposerMapCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged );
67  connect( mResizeModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mResizeModeComboBox_currentIndexChanged );
68  connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mAnchorPointComboBox_currentIndexChanged );
69  connect( mFillColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutPictureWidget::mFillColorButton_colorChanged );
70  connect( mStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutPictureWidget::mStrokeColorButton_colorChanged );
71  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged );
72  connect( mPictureRotationOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged );
73  connect( mNorthTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged );
74  connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsLayoutPictureWidget::sourceChanged );
75  connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsLayoutPictureWidget::setSvgDynamicParameters );
76  connect( mRadioSVG, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
77  connect( mRadioRaster, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
78 
79  mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastComposerPictureDir" ) );
80 
81  setPanelTitle( tr( "Picture Properties" ) );
82 
83  mFillColorButton->setAllowOpacity( true );
84  mFillColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
85  mFillColorButton->setContext( QStringLiteral( "composer" ) );
86  mStrokeColorButton->setAllowOpacity( true );
87  mStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
88  mStrokeColorButton->setContext( QStringLiteral( "composer" ) );
89 
90  mFillColorDDBtn->registerLinkedWidget( mFillColorButton );
91  mStrokeColorDDBtn->registerLinkedWidget( mStrokeColorButton );
92 
93  mNorthTypeComboBox->blockSignals( true );
94  mNorthTypeComboBox->addItem( tr( "Grid North" ), QgsLayoutItemPicture::GridNorth );
95  mNorthTypeComboBox->addItem( tr( "True North" ), QgsLayoutItemPicture::TrueNorth );
96  mNorthTypeComboBox->blockSignals( false );
97  mPictureRotationOffsetSpinBox->setClearValue( 0.0 );
98  mPictureRotationSpinBox->setClearValue( 0.0 );
99 
100  //add widget for general composer item properties
101  mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, picture );
102  mainLayout->addWidget( mItemPropertiesWidget );
103 
104  if ( mPicture->layout() )
105  {
106  mComposerMapComboBox->setCurrentLayout( mPicture->layout() );
107  mComposerMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
108  connect( mComposerMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutPictureWidget::mapChanged );
109  }
110 
111  setGuiElementValues();
112 
113  switch ( mPicture->mode() )
114  {
117  mRadioSVG->setChecked( true );
118  break;
120  mRadioRaster->setChecked( true );
121  break;
122  }
123 
124  connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
125  connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
126 
127  //connections for data defined buttons
128  registerDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton(), QgsLayoutObject::PictureSource );
132 }
133 
135 {
136  if ( mItemPropertiesWidget )
137  mItemPropertiesWidget->setMasterLayout( masterLayout );
138 }
139 
140 void QgsLayoutPictureWidget::mPictureRotationSpinBox_valueChanged( double d )
141 {
142  if ( mPicture )
143  {
144  mPicture->beginCommand( tr( "Change Picture Rotation" ), QgsLayoutItem::UndoPictureRotation );
145  mPicture->setPictureRotation( d );
146  mPicture->endCommand();
147  }
148 }
149 
150 void QgsLayoutPictureWidget::mResizeModeComboBox_currentIndexChanged( int )
151 {
152  if ( !mPicture )
153  {
154  return;
155  }
156 
157  mPicture->beginCommand( tr( "Change Resize Mode" ) );
158  mPicture->setResizeMode( static_cast< QgsLayoutItemPicture::ResizeMode >( mResizeModeComboBox->currentData().toInt() ) );
159  mPicture->endCommand();
160 
161  //disable picture rotation for non-zoom modes
162  mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
163  mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
164 
165  //disable anchor point control for certain zoom modes
166  if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
167  mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
168  {
169  mAnchorPointComboBox->setEnabled( true );
170  }
171  else
172  {
173  mAnchorPointComboBox->setEnabled( false );
174  }
175 }
176 
177 void QgsLayoutPictureWidget::mAnchorPointComboBox_currentIndexChanged( int )
178 {
179  if ( !mPicture )
180  {
181  return;
182  }
183 
184  mPicture->beginCommand( tr( "Change Placement" ) );
185  mPicture->setPictureAnchor( static_cast< QgsLayoutItem::ReferencePoint >( mAnchorPointComboBox->currentData().toInt() ) );
186  mPicture->endCommand();
187 }
188 
190 {
192  return false;
193 
194  if ( mPicture )
195  {
196  disconnect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
197  disconnect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
198  }
199 
200  mPicture = qobject_cast< QgsLayoutItemPicture * >( item );
201  mItemPropertiesWidget->setItem( mPicture );
202 
203  if ( mPicture )
204  {
205  connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
206  connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
207  }
208 
209  setGuiElementValues();
210 
211  return true;
212 }
213 
214 void QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged( int state )
215 {
216  if ( !mPicture )
217  {
218  return;
219  }
220 
221  mPicture->beginCommand( tr( "Toggle Rotation Sync" ) );
222  if ( state == Qt::Unchecked )
223  {
224  mPicture->setLinkedMap( nullptr );
225  mPictureRotationSpinBox->setEnabled( true );
226  mComposerMapComboBox->setEnabled( false );
227  mNorthTypeComboBox->setEnabled( false );
228  mPictureRotationOffsetSpinBox->setEnabled( false );
229  mPicture->setPictureRotation( mPictureRotationSpinBox->value() );
230  }
231  else
232  {
233  QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( mComposerMapComboBox->currentItem() );
234  mPicture->setLinkedMap( map );
235  mPictureRotationSpinBox->setEnabled( false );
236  mNorthTypeComboBox->setEnabled( true );
237  mPictureRotationOffsetSpinBox->setEnabled( true );
238  mComposerMapComboBox->setEnabled( true );
239  }
240  mPicture->endCommand();
241 }
242 
243 void QgsLayoutPictureWidget::mapChanged( QgsLayoutItem *item )
244 {
245  if ( !mPicture )
246  {
247  return;
248  }
249 
250  //get composition
251  const QgsLayout *layout = mPicture->layout();
252  if ( !layout )
253  {
254  return;
255  }
256 
257  QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap *>( item );
258  if ( !map )
259  {
260  return;
261  }
262 
263  mPicture->beginCommand( tr( "Change Rotation Map" ) );
264  mPicture->setLinkedMap( map );
265  mPicture->update();
266  mPicture->endCommand();
267 }
268 
269 void QgsLayoutPictureWidget::setPicRotationSpinValue( double r )
270 {
271  mPictureRotationSpinBox->blockSignals( true );
272  mPictureRotationSpinBox->setValue( r );
273  mPictureRotationSpinBox->blockSignals( false );
274 }
275 
276 void QgsLayoutPictureWidget::setGuiElementValues()
277 {
278  //set initial gui values
279  if ( mPicture )
280  {
281  mPictureRotationSpinBox->blockSignals( true );
282  mComposerMapComboBox->blockSignals( true );
283  mRotationFromComposerMapCheckBox->blockSignals( true );
284  mNorthTypeComboBox->blockSignals( true );
285  mPictureRotationOffsetSpinBox->blockSignals( true );
286  mResizeModeComboBox->blockSignals( true );
287  mAnchorPointComboBox->blockSignals( true );
288  mFillColorButton->blockSignals( true );
289  mStrokeColorButton->blockSignals( true );
290  mStrokeWidthSpinBox->blockSignals( true );
291 
292  mPictureRotationSpinBox->setValue( mPicture->pictureRotation() );
293 
294  mComposerMapComboBox->setItem( mPicture->linkedMap() );
295 
296  if ( mPicture->linkedMap() )
297  {
298  mRotationFromComposerMapCheckBox->setCheckState( Qt::Checked );
299  mPictureRotationSpinBox->setEnabled( false );
300  mComposerMapComboBox->setEnabled( true );
301  mNorthTypeComboBox->setEnabled( true );
302  mPictureRotationOffsetSpinBox->setEnabled( true );
303  }
304  else
305  {
306  mRotationFromComposerMapCheckBox->setCheckState( Qt::Unchecked );
307  mPictureRotationSpinBox->setEnabled( true );
308  mComposerMapComboBox->setEnabled( false );
309  mNorthTypeComboBox->setEnabled( false );
310  mPictureRotationOffsetSpinBox->setEnabled( false );
311  }
312  mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mPicture->northMode() ) );
313  mPictureRotationOffsetSpinBox->setValue( mPicture->northOffset() );
314 
315  mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mPicture->resizeMode() ) );
316  //disable picture rotation for non-zoom modes
317  mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
318  mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
319 
320  mAnchorPointComboBox->setCurrentIndex( mAnchorPointComboBox->findData( mPicture->pictureAnchor() ) );
321  //disable anchor point control for certain zoom modes
322  if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
323  mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
324  {
325  mAnchorPointComboBox->setEnabled( true );
326  }
327  else
328  {
329  mAnchorPointComboBox->setEnabled( false );
330  }
331 
332  mSvgSelectorWidget->setSvgParameters( mPicture->svgDynamicParameters() );
333 
334  updateSvgParamGui( false );
335  mFillColorButton->setColor( mPicture->svgFillColor() );
336  mStrokeColorButton->setColor( mPicture->svgStrokeColor() );
337  mStrokeWidthSpinBox->setValue( mPicture->svgStrokeWidth() );
338 
339  mRotationFromComposerMapCheckBox->blockSignals( false );
340  mPictureRotationSpinBox->blockSignals( false );
341  mComposerMapComboBox->blockSignals( false );
342  mNorthTypeComboBox->blockSignals( false );
343  mPictureRotationOffsetSpinBox->blockSignals( false );
344  mResizeModeComboBox->blockSignals( false );
345  mAnchorPointComboBox->blockSignals( false );
346  mFillColorButton->blockSignals( false );
347  mStrokeColorButton->blockSignals( false );
348  mStrokeWidthSpinBox->blockSignals( false );
349 
351  }
352 }
353 
354 void QgsLayoutPictureWidget::updateSvgParamGui( bool resetValues )
355 {
356  if ( !mPicture )
357  return;
358 
359  QString picturePath = mPicture->picturePath();
360 
361  //activate gui for svg parameters only if supported by the svg file
362  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
363  QColor defaultFill, defaultStroke;
364  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
365  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
366  QgsApplication::svgCache()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill,
367  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
368  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
369  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
370  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
371 
372  if ( resetValues )
373  {
374  QColor fill = mFillColorButton->color();
375  double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
376  if ( hasDefaultFillColor )
377  {
378  fill = defaultFill;
379  }
380  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
381  mFillColorButton->setColor( fill );
382  }
383  mFillColorButton->setEnabled( hasFillParam );
384  mFillColorButton->setAllowOpacity( hasFillOpacityParam );
385  if ( resetValues )
386  {
387  QColor stroke = mStrokeColorButton->color();
388  double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
389  if ( hasDefaultStrokeColor )
390  {
391  stroke = defaultStroke;
392  }
393  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
394  mStrokeColorButton->setColor( stroke );
395  }
396  mStrokeColorButton->setEnabled( hasStrokeParam );
397  mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
398  if ( hasDefaultStrokeWidth && resetValues )
399  {
400  mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
401  }
402  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
403 }
404 
405 void QgsLayoutPictureWidget::mFillColorButton_colorChanged( const QColor &color )
406 {
407  mPicture->beginCommand( tr( "Change Picture Fill Color" ), QgsLayoutItem::UndoPictureFillColor );
408  mPicture->setSvgFillColor( color );
409  mPicture->endCommand();
410  mPicture->update();
411 }
412 
413 void QgsLayoutPictureWidget::mStrokeColorButton_colorChanged( const QColor &color )
414 {
415  mPicture->beginCommand( tr( "Change Picture Stroke Color" ), QgsLayoutItem::UndoPictureStrokeColor );
416  mPicture->setSvgStrokeColor( color );
417  mPicture->endCommand();
418  mPicture->update();
419 }
420 
421 void QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged( double d )
422 {
423  mPicture->beginCommand( tr( "Change Picture Stroke Width" ), QgsLayoutItem::UndoPictureStrokeWidth );
424  mPicture->setSvgStrokeWidth( d );
425  mPicture->endCommand();
426  mPicture->update();
427 }
428 
429 void QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged( double d )
430 {
431  mPicture->beginCommand( tr( "Change Picture North Offset" ), QgsLayoutItem::UndoPictureNorthOffset );
432  mPicture->setNorthOffset( d );
433  mPicture->endCommand();
434  mPicture->update();
435 }
436 
437 void QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged( int index )
438 {
439  mPicture->beginCommand( tr( "Change Picture North Mode" ) );
440  mPicture->setNorthMode( static_cast< QgsLayoutItemPicture::NorthMode >( mNorthTypeComboBox->itemData( index ).toInt() ) );
441  mPicture->endCommand();
442  mPicture->update();
443 }
444 
445 void QgsLayoutPictureWidget::modeChanged( bool checked )
446 {
447  if ( !checked )
448  return;
449 
450  bool svg = mRadioSVG->isChecked();
452 
453  if ( svg )
454  mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Svg );
455  else
456  mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Image );
457 
458  mSvgSelectorWidget->setBrowserVisible( svg );
459  mSvgSelectorWidget->setAllowParameters( svg );
460  mSVGParamsGroupBox->setVisible( svg );
461 
462  if ( mPicture && mPicture->mode() != newFormat )
463  {
464  mPicture->beginCommand( tr( "Change Picture Type" ) );
465  mPicture->setMode( newFormat );
466  mPicture->endCommand();
467  }
468 }
469 
470 void QgsLayoutPictureWidget::sourceChanged( const QString &source )
471 {
472  if ( mPicture )
473  {
474  mPicture->beginCommand( tr( "Change Picture" ) );
475  mPicture->setPicturePath( source, QgsLayoutItemPicture::FormatSVG );
476  mPicture->update();
477  mPicture->endCommand();
478  updateSvgParamGui();
479  }
480 }
481 
482 void QgsLayoutPictureWidget::setSvgDynamicParameters( const QMap<QString, QgsProperty> &parameters )
483 {
484  mPicture->beginCommand( tr( "Set SVG parameters" ) );
485  mPicture->setSvgDynamicParameters( parameters );
486  mPicture->update();
487  mPicture->endCommand();
488 }
489 
491 {
492  updateDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton() );
493  updateDataDefinedButton( mFillColorDDBtn );
494  updateDataDefinedButton( mStrokeColorDDBtn );
495  updateDataDefinedButton( mStrokeWidthDDBtn );
496 }
497 
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
A base class for property widgets for layout items.
QgsLayoutObject * layoutObject()
Returns the layout object associated with this widget.
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a previously registered data defined button to reflect the item's current properties.
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property)
Registers a data defined button, setting up its initial value, connections and description.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
Layout graphical items for displaying a map.
A layout item subclass that displays SVG files or raster format images (jpg, png, ....
void pictureRotationChanged(double newRotation)
Emitted on picture rotation change.
NorthMode
Method for syncing rotation to a map's North direction.
@ GridNorth
Align to grid north.
@ TrueNorth
Align to true north.
ResizeMode
Controls how pictures are scaled within the item's frame.
@ FrameToImageSize
Sets size of frame to match original size of image without scaling.
@ ZoomResizeFrame
Enlarges image to fit frame, then resizes frame to fit resultant image.
@ Clip
Draws image at original size and clips any portion which falls outside frame.
@ Stretch
Stretches image to fit frame, ignores aspect ratio.
@ Zoom
Enlarges image to fit frame while maintaining aspect ratio of picture.
Format
Format of source image.
@ FormatUnknown
Invalid or unknown image type.
A widget for controlling the common properties of layout items (e.g.
void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
void setItem(QgsLayoutItem *item)
Sets the layout item.
Base class for graphical items within a QgsLayout.
@ UndoPictureStrokeWidth
Picture stroke width.
@ UndoPictureRotation
Picture rotation.
@ UndoPictureFillColor
Picture fill color.
@ UndoPictureNorthOffset
Picture north offset.
@ UndoPictureStrokeColor
Picture stroke color.
ReferencePoint
Fixed position reference point.
@ LowerMiddle
Lower center of item.
@ MiddleLeft
Middle left of item.
@ Middle
Center of item.
@ UpperRight
Upper right corner of item.
@ LowerLeft
Lower left corner of item.
@ UpperLeft
Upper left corner of item.
@ UpperMiddle
Upper center of item.
@ MiddleRight
Middle right of item.
@ LowerRight
Lower right corner of item.
int type() const override
Returns a unique graphics item type identifier.
void changed()
Emitted when the object's properties change.
@ PictureSvgStrokeColor
SVG stroke color.
@ PictureSvgStrokeWidth
SVG stroke width.
@ PictureSvgBackgroundColor
SVG background color.
@ PictureSource
Picture source url.
QgsLayoutPictureWidget(QgsLayoutItemPicture *picture)
constructor
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
void populateDataDefinedButtons()
Initializes data defined buttons to current atlas coverage layer.
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:51
Interface for master layout type objects, such as print layouts and reports.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an SVG file contains parameters for fill, stroke color, stroke width.
void svgParametersChanged(const QMap< QString, QgsProperty > &parameters)
Emitted when the parameters have changed.
void sourceChanged(const QString &source)
Emitted whenever the SVG source is changed in the widget.