QGIS API Documentation 3.27.0-Master (9c08adf5ef)
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
19#include "qgsapplication.h"
20#include "qgslayoutitemmap.h"
22#include "qgslayout.h"
24#include "qgssvgcache.h"
25#include "qgssettings.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, &QgsSvgSelectorWidget::svgSelected, this, &QgsLayoutPictureWidget::sourceChanged );
75
76 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsLayoutPictureWidget::setSvgDynamicParameters );
77 connect( mRadioSVG, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
78 connect( mRadioRaster, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
79
80 mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastComposerPictureDir" ) );
81
82 setPanelTitle( tr( "Picture Properties" ) );
83
84 mFillColorButton->setAllowOpacity( true );
85 mFillColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
86 mFillColorButton->setContext( QStringLiteral( "composer" ) );
87 mStrokeColorButton->setAllowOpacity( true );
88 mStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
89 mStrokeColorButton->setContext( QStringLiteral( "composer" ) );
90
91 mFillColorDDBtn->registerLinkedWidget( mFillColorButton );
92 mStrokeColorDDBtn->registerLinkedWidget( mStrokeColorButton );
93
94 mNorthTypeComboBox->blockSignals( true );
95 mNorthTypeComboBox->addItem( tr( "Grid North" ), QgsLayoutItemPicture::GridNorth );
96 mNorthTypeComboBox->addItem( tr( "True North" ), QgsLayoutItemPicture::TrueNorth );
97 mNorthTypeComboBox->blockSignals( false );
98 mPictureRotationOffsetSpinBox->setClearValue( 0.0 );
99 mPictureRotationSpinBox->setClearValue( 0.0 );
100
101 //add widget for general composer item properties
102 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, picture );
103 mainLayout->addWidget( mItemPropertiesWidget );
104
105 if ( mPicture->layout() )
106 {
107 mComposerMapComboBox->setCurrentLayout( mPicture->layout() );
108 mComposerMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
109 connect( mComposerMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutPictureWidget::mapChanged );
110 }
111
112 setGuiElementValues();
113
114 connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
115 connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
116
117 //connections for data defined buttons
118 registerDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton(), QgsLayoutObject::PictureSource );
122}
123
125{
126 if ( mItemPropertiesWidget )
127 mItemPropertiesWidget->setMasterLayout( masterLayout );
128}
129
130void QgsLayoutPictureWidget::mPictureRotationSpinBox_valueChanged( double d )
131{
132 if ( mPicture )
133 {
134 mPicture->beginCommand( tr( "Change Picture Rotation" ), QgsLayoutItem::UndoPictureRotation );
135 mPicture->setPictureRotation( d );
136 mPicture->endCommand();
137 }
138}
139
140void QgsLayoutPictureWidget::mResizeModeComboBox_currentIndexChanged( int )
141{
142 if ( !mPicture )
143 {
144 return;
145 }
146
147 mPicture->beginCommand( tr( "Change Resize Mode" ) );
148 mPicture->setResizeMode( static_cast< QgsLayoutItemPicture::ResizeMode >( mResizeModeComboBox->currentData().toInt() ) );
149 mPicture->endCommand();
150
151 //disable picture rotation for non-zoom modes
152 mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
153 mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
154
155 //disable anchor point control for certain zoom modes
156 if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
157 mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
158 {
159 mAnchorPointComboBox->setEnabled( true );
160 }
161 else
162 {
163 mAnchorPointComboBox->setEnabled( false );
164 }
165}
166
167void QgsLayoutPictureWidget::mAnchorPointComboBox_currentIndexChanged( int )
168{
169 if ( !mPicture )
170 {
171 return;
172 }
173
174 mPicture->beginCommand( tr( "Change Placement" ) );
175 mPicture->setPictureAnchor( static_cast< QgsLayoutItem::ReferencePoint >( mAnchorPointComboBox->currentData().toInt() ) );
176 mPicture->endCommand();
177}
178
180{
182 return false;
183
184 if ( mPicture )
185 {
186 disconnect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
187 disconnect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
188 }
189
190 mPicture = qobject_cast< QgsLayoutItemPicture * >( item );
191 mItemPropertiesWidget->setItem( mPicture );
192
193 if ( mPicture )
194 {
195 connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
196 connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
197 }
198
199 setGuiElementValues();
200
201 return true;
202}
203
204void QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged( int state )
205{
206 if ( !mPicture )
207 {
208 return;
209 }
210
211 mPicture->beginCommand( tr( "Toggle Rotation Sync" ) );
212 if ( state == Qt::Unchecked )
213 {
214 mPicture->setLinkedMap( nullptr );
215 mPictureRotationSpinBox->setEnabled( true );
216 mComposerMapComboBox->setEnabled( false );
217 mNorthTypeComboBox->setEnabled( false );
218 mPictureRotationOffsetSpinBox->setEnabled( false );
219 mPicture->setPictureRotation( mPictureRotationSpinBox->value() );
220 }
221 else
222 {
223 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap * >( mComposerMapComboBox->currentItem() );
224 mPicture->setLinkedMap( map );
225 mPictureRotationSpinBox->setEnabled( false );
226 mNorthTypeComboBox->setEnabled( true );
227 mPictureRotationOffsetSpinBox->setEnabled( true );
228 mComposerMapComboBox->setEnabled( true );
229 }
230 mPicture->endCommand();
231}
232
233void QgsLayoutPictureWidget::mapChanged( QgsLayoutItem *item )
234{
235 if ( !mPicture )
236 {
237 return;
238 }
239
240 //get composition
241 const QgsLayout *layout = mPicture->layout();
242 if ( !layout )
243 {
244 return;
245 }
246
247 QgsLayoutItemMap *map = qobject_cast< QgsLayoutItemMap *>( item );
248 if ( !map )
249 {
250 return;
251 }
252
253 mPicture->beginCommand( tr( "Change Rotation Map" ) );
254 mPicture->setLinkedMap( map );
255 mPicture->update();
256 mPicture->endCommand();
257}
258
259void QgsLayoutPictureWidget::setPicRotationSpinValue( double r )
260{
261 mPictureRotationSpinBox->blockSignals( true );
262 mPictureRotationSpinBox->setValue( r );
263 mPictureRotationSpinBox->blockSignals( false );
264}
265
266void QgsLayoutPictureWidget::setGuiElementValues()
267{
268 //set initial gui values
269 if ( mPicture )
270 {
271 mPictureRotationSpinBox->blockSignals( true );
272 mComposerMapComboBox->blockSignals( true );
273 mRotationFromComposerMapCheckBox->blockSignals( true );
274 mNorthTypeComboBox->blockSignals( true );
275 mPictureRotationOffsetSpinBox->blockSignals( true );
276 mResizeModeComboBox->blockSignals( true );
277 mAnchorPointComboBox->blockSignals( true );
278 mFillColorButton->blockSignals( true );
279 mStrokeColorButton->blockSignals( true );
280 mStrokeWidthSpinBox->blockSignals( true );
281
282 mPictureRotationSpinBox->setValue( mPicture->pictureRotation() );
283
284 mComposerMapComboBox->setItem( mPicture->linkedMap() );
285
286 if ( mPicture->linkedMap() )
287 {
288 mRotationFromComposerMapCheckBox->setCheckState( Qt::Checked );
289 mPictureRotationSpinBox->setEnabled( false );
290 mComposerMapComboBox->setEnabled( true );
291 mNorthTypeComboBox->setEnabled( true );
292 mPictureRotationOffsetSpinBox->setEnabled( true );
293 }
294 else
295 {
296 mRotationFromComposerMapCheckBox->setCheckState( Qt::Unchecked );
297 mPictureRotationSpinBox->setEnabled( true );
298 mComposerMapComboBox->setEnabled( false );
299 mNorthTypeComboBox->setEnabled( false );
300 mPictureRotationOffsetSpinBox->setEnabled( false );
301 }
302 mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mPicture->northMode() ) );
303 mPictureRotationOffsetSpinBox->setValue( mPicture->northOffset() );
304
305 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mPicture->resizeMode() ) );
306 //disable picture rotation for non-zoom modes
307 mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
308 mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
309
310 mAnchorPointComboBox->setCurrentIndex( mAnchorPointComboBox->findData( mPicture->pictureAnchor() ) );
311 //disable anchor point control for certain zoom modes
312 if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
313 mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
314 {
315 mAnchorPointComboBox->setEnabled( true );
316 }
317 else
318 {
319 mAnchorPointComboBox->setEnabled( false );
320 }
321
322 switch ( mPicture->mode() )
323 {
326 mRadioSVG->setChecked( true );
327 break;
329 mRadioRaster->setChecked( true );
330 break;
331 }
332
333 mSvgSelectorWidget->setSvgPath( mPicture->picturePath() );
334 mSvgSelectorWidget->setSvgParameters( mPicture->svgDynamicParameters() );
335
336 updateSvgParamGui( false );
337 mFillColorButton->setColor( mPicture->svgFillColor() );
338 mStrokeColorButton->setColor( mPicture->svgStrokeColor() );
339 mStrokeWidthSpinBox->setValue( mPicture->svgStrokeWidth() );
340
341 mRotationFromComposerMapCheckBox->blockSignals( false );
342 mPictureRotationSpinBox->blockSignals( false );
343 mComposerMapComboBox->blockSignals( false );
344 mNorthTypeComboBox->blockSignals( false );
345 mPictureRotationOffsetSpinBox->blockSignals( false );
346 mResizeModeComboBox->blockSignals( false );
347 mAnchorPointComboBox->blockSignals( false );
348 mFillColorButton->blockSignals( false );
349 mStrokeColorButton->blockSignals( false );
350 mStrokeWidthSpinBox->blockSignals( false );
351
353 }
354}
355
356void QgsLayoutPictureWidget::updateSvgParamGui( bool resetValues )
357{
358 if ( !mPicture )
359 return;
360
361 const QString picturePath = mPicture->picturePath();
362
363 //activate gui for svg parameters only if supported by the svg file
364 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
365 QColor defaultFill, defaultStroke;
366 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
367 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
368 QgsApplication::svgCache()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill,
369 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
370 hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
371 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
372 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
373
374 if ( resetValues )
375 {
376 QColor fill = mFillColorButton->color();
377 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
378 if ( hasDefaultFillColor )
379 {
380 fill = defaultFill;
381 }
382 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
383 mFillColorButton->setColor( fill );
384 }
385 mFillColorButton->setEnabled( hasFillParam );
386 mFillColorDDBtn->setEnabled( hasFillParam );
387 mFillColorButton->setAllowOpacity( hasFillOpacityParam );
388 if ( resetValues )
389 {
390 QColor stroke = mStrokeColorButton->color();
391 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
392 if ( hasDefaultStrokeColor )
393 {
394 stroke = defaultStroke;
395 }
396 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
397 mStrokeColorButton->setColor( stroke );
398 }
399 mStrokeColorButton->setEnabled( hasStrokeParam );
400 mStrokeColorDDBtn->setEnabled( hasStrokeParam );
401 mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
402 if ( hasDefaultStrokeWidth && resetValues )
403 {
404 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
405 }
406 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
407 mStrokeWidthDDBtn->setEnabled( hasStrokeWidthParam );
408}
409
410void QgsLayoutPictureWidget::mFillColorButton_colorChanged( const QColor &color )
411{
412 mPicture->beginCommand( tr( "Change Picture Fill Color" ), QgsLayoutItem::UndoPictureFillColor );
413 mPicture->setSvgFillColor( color );
414 mPicture->endCommand();
415 mPicture->update();
416}
417
418void QgsLayoutPictureWidget::mStrokeColorButton_colorChanged( const QColor &color )
419{
420 mPicture->beginCommand( tr( "Change Picture Stroke Color" ), QgsLayoutItem::UndoPictureStrokeColor );
421 mPicture->setSvgStrokeColor( color );
422 mPicture->endCommand();
423 mPicture->update();
424}
425
426void QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged( double d )
427{
428 mPicture->beginCommand( tr( "Change Picture Stroke Width" ), QgsLayoutItem::UndoPictureStrokeWidth );
429 mPicture->setSvgStrokeWidth( d );
430 mPicture->endCommand();
431 mPicture->update();
432}
433
434void QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged( double d )
435{
436 mPicture->beginCommand( tr( "Change Picture North Offset" ), QgsLayoutItem::UndoPictureNorthOffset );
437 mPicture->setNorthOffset( d );
438 mPicture->endCommand();
439 mPicture->update();
440}
441
442void QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged( int index )
443{
444 mPicture->beginCommand( tr( "Change Picture North Mode" ) );
445 mPicture->setNorthMode( static_cast< QgsLayoutItemPicture::NorthMode >( mNorthTypeComboBox->itemData( index ).toInt() ) );
446 mPicture->endCommand();
447 mPicture->update();
448}
449
450void QgsLayoutPictureWidget::modeChanged( bool checked )
451{
452 if ( !checked )
453 return;
454
455 const bool svg = mRadioSVG->isChecked();
457
458 if ( svg )
459 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Svg );
460 else
461 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Image );
462
463 mSvgSelectorWidget->setBrowserVisible( svg );
464 mSvgSelectorWidget->setAllowParameters( svg );
465 mSVGParamsGroupBox->setVisible( svg );
466
467 if ( mPicture && mPicture->mode() != newFormat )
468 {
469 mPicture->beginCommand( tr( "Change Picture Type" ) );
470 mPicture->setMode( newFormat );
471 mPicture->endCommand();
472 }
473}
474
475void QgsLayoutPictureWidget::sourceChanged( const QString &source )
476{
477 if ( mPicture )
478 {
479 mPicture->beginCommand( tr( "Change Picture" ) );
480 mPicture->setPicturePath( source, mRadioSVG->isChecked() ? QgsLayoutItemPicture::FormatSVG : QgsLayoutItemPicture::FormatRaster );
481 mPicture->update();
482 mPicture->endCommand();
483 updateSvgParamGui();
484 }
485}
486
487void QgsLayoutPictureWidget::setSvgDynamicParameters( const QMap<QString, QgsProperty> &parameters )
488{
489 mPicture->beginCommand( tr( "Set SVG parameters" ) );
490 mPicture->setSvgDynamicParameters( parameters );
491 mPicture->update();
492 mPicture->endCommand();
493}
494
496{
497 updateDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton() );
498 updateDataDefinedButton( mFillColorDDBtn );
499 updateDataDefinedButton( mStrokeColorDDBtn );
500 updateDataDefinedButton( mStrokeWidthDDBtn );
501}
502
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 svgSelected(const QString &path)