QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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
20#include "qgsapplication.h"
23#include "qgslayout.h"
24#include "qgslayoutitemmap.h"
26#include "qgssettings.h"
27#include "qgssvgcache.h"
29
30#include <QDoubleValidator>
31#include <QFileDialog>
32#include <QFileInfo>
33#include <QImageReader>
34#include <QMessageBox>
35#include <QPainter>
36#include <QProgressDialog>
37#include <QSvgRenderer>
38
39#include "moc_qgslayoutpicturewidget.cpp"
40
42 : QgsLayoutItemBaseWidget( nullptr, picture )
43 , mPicture( picture )
44{
45 setupUi( this );
46
47 mSvgSelectorWidget->setAllowParameters( true );
48 mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
49 mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
50 mSvgSelectorWidget->initParametersModel( layoutObject(), coverageLayer() );
51
52 mResizeModeComboBox->addItem( tr( "Zoom" ), QgsLayoutItemPicture::Zoom );
53 mResizeModeComboBox->addItem( tr( "Stretch" ), QgsLayoutItemPicture::Stretch );
54 mResizeModeComboBox->addItem( tr( "Clip" ), QgsLayoutItemPicture::Clip );
55 mResizeModeComboBox->addItem( tr( "Zoom and Resize Frame" ), QgsLayoutItemPicture::ZoomResizeFrame );
56 mResizeModeComboBox->addItem( tr( "Resize Frame to Image Size" ), QgsLayoutItemPicture::FrameToImageSize );
57
58 mAnchorPointComboBox->addItem( tr( "Top Left" ), QgsLayoutItem::UpperLeft );
59 mAnchorPointComboBox->addItem( tr( "Top Center" ), QgsLayoutItem::UpperMiddle );
60 mAnchorPointComboBox->addItem( tr( "Top Right" ), QgsLayoutItem::UpperRight );
61 mAnchorPointComboBox->addItem( tr( "Middle Left" ), QgsLayoutItem::MiddleLeft );
62 mAnchorPointComboBox->addItem( tr( "Middle" ), QgsLayoutItem::Middle );
63 mAnchorPointComboBox->addItem( tr( "Middle Right" ), QgsLayoutItem::MiddleRight );
64 mAnchorPointComboBox->addItem( tr( "Bottom Left" ), QgsLayoutItem::LowerLeft );
65 mAnchorPointComboBox->addItem( tr( "Bottom Center" ), QgsLayoutItem::LowerMiddle );
66 mAnchorPointComboBox->addItem( tr( "Bottom Right" ), QgsLayoutItem::LowerRight );
67
68 connect( mPictureRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mPictureRotationSpinBox_valueChanged );
69 connect( mRotationFromComposerMapCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged );
70 connect( mResizeModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mResizeModeComboBox_currentIndexChanged );
71 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mAnchorPointComboBox_currentIndexChanged );
72 connect( mFillColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutPictureWidget::mFillColorButton_colorChanged );
73 connect( mStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutPictureWidget::mStrokeColorButton_colorChanged );
74 connect( mStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged );
75 connect( mPictureRotationOffsetSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged );
76 connect( mNorthTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged );
77 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsLayoutPictureWidget::sourceChanged );
78
79 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsLayoutPictureWidget::setSvgDynamicParameters );
80 connect( mRadioSVG, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
81 connect( mRadioRaster, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
82
83 mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastComposerPictureDir" ) );
84
85 setPanelTitle( tr( "Picture Properties" ) );
86
87 mFillColorButton->setAllowOpacity( true );
88 mFillColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
89 mFillColorButton->setContext( QStringLiteral( "composer" ) );
90 mStrokeColorButton->setAllowOpacity( true );
91 mStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
92 mStrokeColorButton->setContext( QStringLiteral( "composer" ) );
93
94 mFillColorDDBtn->registerLinkedWidget( mFillColorButton );
95 mStrokeColorDDBtn->registerLinkedWidget( mStrokeColorButton );
96
97 mNorthTypeComboBox->blockSignals( true );
98 mNorthTypeComboBox->addItem( tr( "Grid North" ), QgsLayoutItemPicture::GridNorth );
99 mNorthTypeComboBox->addItem( tr( "True North" ), QgsLayoutItemPicture::TrueNorth );
100 mNorthTypeComboBox->blockSignals( false );
101 mPictureRotationOffsetSpinBox->setClearValue( 0.0 );
102 mPictureRotationSpinBox->setClearValue( 0.0 );
103
104 //add widget for general composer item properties
105 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, picture );
106 mainLayout->addWidget( mItemPropertiesWidget );
107
108 if ( mPicture->layout() )
109 {
110 mComposerMapComboBox->setCurrentLayout( mPicture->layout() );
111 mComposerMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
112 connect( mComposerMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutPictureWidget::mapChanged );
113 }
114
115 setGuiElementValues();
116
117 connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
118 connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
119
120 //connections for data defined buttons
121 registerDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton(), QgsLayoutObject::DataDefinedProperty::PictureSource );
125}
126
128{
129 if ( mItemPropertiesWidget )
130 mItemPropertiesWidget->setMasterLayout( masterLayout );
131}
132
133void QgsLayoutPictureWidget::mPictureRotationSpinBox_valueChanged( double d )
134{
135 if ( mPicture )
136 {
137 mPicture->beginCommand( tr( "Change Picture Rotation" ), QgsLayoutItem::UndoPictureRotation );
138 mPicture->setPictureRotation( d );
139 mPicture->endCommand();
140 }
141}
142
143void QgsLayoutPictureWidget::mResizeModeComboBox_currentIndexChanged( int )
144{
145 if ( !mPicture )
146 {
147 return;
148 }
149
150 mPicture->beginCommand( tr( "Change Resize Mode" ) );
151 mPicture->setResizeMode( static_cast<QgsLayoutItemPicture::ResizeMode>( mResizeModeComboBox->currentData().toInt() ) );
152 mPicture->endCommand();
153
154 //disable picture rotation for non-zoom modes
155 mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom || mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
156
157 //disable anchor point control for certain zoom modes
158 if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom || mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
159 {
160 mAnchorPointComboBox->setEnabled( true );
161 }
162 else
163 {
164 mAnchorPointComboBox->setEnabled( false );
165 }
166}
167
168void QgsLayoutPictureWidget::mAnchorPointComboBox_currentIndexChanged( int )
169{
170 if ( !mPicture )
171 {
172 return;
173 }
174
175 mPicture->beginCommand( tr( "Change Placement" ) );
176 mPicture->setPictureAnchor( static_cast<QgsLayoutItem::ReferencePoint>( mAnchorPointComboBox->currentData().toInt() ) );
177 mPicture->endCommand();
178}
179
181{
183 return false;
184
185 if ( mPicture )
186 {
187 disconnect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
188 disconnect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
189 }
190
191 mPicture = qobject_cast<QgsLayoutItemPicture *>( item );
192 mItemPropertiesWidget->setItem( mPicture );
193
194 if ( mPicture )
195 {
196 connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
197 connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
198 }
199
200 setGuiElementValues();
201
202 return true;
203}
204
205void QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged( int state )
206{
207 if ( !mPicture )
208 {
209 return;
210 }
211
212 mPicture->beginCommand( tr( "Toggle Rotation Sync" ) );
213 if ( state == Qt::Unchecked )
214 {
215 mPicture->setLinkedMap( nullptr );
216 mPictureRotationSpinBox->setEnabled( true );
217 mComposerMapComboBox->setEnabled( false );
218 mNorthTypeComboBox->setEnabled( false );
219 mPictureRotationOffsetSpinBox->setEnabled( false );
220 mPicture->setPictureRotation( mPictureRotationSpinBox->value() );
221 }
222 else
223 {
224 QgsLayoutItemMap *map = qobject_cast<QgsLayoutItemMap *>( mComposerMapComboBox->currentItem() );
225 mPicture->setLinkedMap( map );
226 mPictureRotationSpinBox->setEnabled( false );
227 mNorthTypeComboBox->setEnabled( true );
228 mPictureRotationOffsetSpinBox->setEnabled( true );
229 mComposerMapComboBox->setEnabled( true );
230 }
231 mPicture->endCommand();
232}
233
234void QgsLayoutPictureWidget::mapChanged( QgsLayoutItem *item )
235{
236 if ( !mPicture )
237 {
238 return;
239 }
240
241 //get composition
242 const QgsLayout *layout = mPicture->layout();
243 if ( !layout )
244 {
245 return;
246 }
247
248 QgsLayoutItemMap *map = qobject_cast<QgsLayoutItemMap *>( item );
249 if ( !map )
250 {
251 return;
252 }
253
254 mPicture->beginCommand( tr( "Change Rotation Map" ) );
255 mPicture->setLinkedMap( map );
256 mPicture->update();
257 mPicture->endCommand();
258}
259
260void QgsLayoutPictureWidget::setPicRotationSpinValue( double r )
261{
262 mPictureRotationSpinBox->blockSignals( true );
263 mPictureRotationSpinBox->setValue( r );
264 mPictureRotationSpinBox->blockSignals( false );
265}
266
267void QgsLayoutPictureWidget::setGuiElementValues()
268{
269 //set initial gui values
270 if ( mPicture )
271 {
272 mPictureRotationSpinBox->blockSignals( true );
273 mComposerMapComboBox->blockSignals( true );
274 mRotationFromComposerMapCheckBox->blockSignals( true );
275 mNorthTypeComboBox->blockSignals( true );
276 mPictureRotationOffsetSpinBox->blockSignals( true );
277 mResizeModeComboBox->blockSignals( true );
278 mAnchorPointComboBox->blockSignals( true );
279 mFillColorButton->blockSignals( true );
280 mStrokeColorButton->blockSignals( true );
281 mStrokeWidthSpinBox->blockSignals( true );
282
283 mPictureRotationSpinBox->setValue( mPicture->pictureRotation() );
284
285 mComposerMapComboBox->setItem( mPicture->linkedMap() );
286
287 if ( mPicture->linkedMap() )
288 {
289 mRotationFromComposerMapCheckBox->setCheckState( Qt::Checked );
290 mPictureRotationSpinBox->setEnabled( false );
291 mComposerMapComboBox->setEnabled( true );
292 mNorthTypeComboBox->setEnabled( true );
293 mPictureRotationOffsetSpinBox->setEnabled( true );
294 }
295 else
296 {
297 mRotationFromComposerMapCheckBox->setCheckState( Qt::Unchecked );
298 mPictureRotationSpinBox->setEnabled( true );
299 mComposerMapComboBox->setEnabled( false );
300 mNorthTypeComboBox->setEnabled( false );
301 mPictureRotationOffsetSpinBox->setEnabled( false );
302 }
303 mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mPicture->northMode() ) );
304 mPictureRotationOffsetSpinBox->setValue( mPicture->northOffset() );
305
306 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mPicture->resizeMode() ) );
307 //disable picture rotation for non-zoom modes
308 mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom || 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 || mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
313 {
314 mAnchorPointComboBox->setEnabled( true );
315 }
316 else
317 {
318 mAnchorPointComboBox->setEnabled( false );
319 }
320
321 switch ( mPicture->originalMode() )
322 {
325 mRadioSVG->setChecked( true );
326 break;
328 mRadioRaster->setChecked( true );
329 break;
330 }
331
332 mSvgSelectorWidget->setSvgPath( mPicture->picturePath() );
333 mSvgSelectorWidget->setSvgParameters( mPicture->svgDynamicParameters() );
334
335 updateSvgParamGui( false );
336 mFillColorButton->setColor( mPicture->svgFillColor() );
337 mStrokeColorButton->setColor( mPicture->svgStrokeColor() );
338 mStrokeWidthSpinBox->setValue( mPicture->svgStrokeWidth() );
339
340 mRotationFromComposerMapCheckBox->blockSignals( false );
341 mPictureRotationSpinBox->blockSignals( false );
342 mComposerMapComboBox->blockSignals( false );
343 mNorthTypeComboBox->blockSignals( false );
344 mPictureRotationOffsetSpinBox->blockSignals( false );
345 mResizeModeComboBox->blockSignals( false );
346 mAnchorPointComboBox->blockSignals( false );
347 mFillColorButton->blockSignals( false );
348 mStrokeColorButton->blockSignals( false );
349 mStrokeWidthSpinBox->blockSignals( false );
350
352 }
353}
354
355void QgsLayoutPictureWidget::updateSvgParamGui( bool resetValues )
356{
357 if ( !mPicture )
358 return;
359
360 const QString picturePath = mPicture->picturePath();
361
362 //activate gui for svg parameters only if supported by the svg file
363 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
364 QColor defaultFill, defaultStroke;
365 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
366 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
367 QgsApplication::svgCache()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasStrokeParam, hasDefaultStrokeColor, defaultStroke, hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
368
369 if ( resetValues )
370 {
371 QColor fill = mFillColorButton->color();
372 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
373 if ( hasDefaultFillColor )
374 {
375 fill = defaultFill;
376 }
377 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
378 mFillColorButton->setColor( fill );
379 }
380 mFillColorButton->setEnabled( hasFillParam );
381 mFillColorDDBtn->setEnabled( hasFillParam );
382 mFillColorButton->setAllowOpacity( hasFillOpacityParam );
383 if ( resetValues )
384 {
385 QColor stroke = mStrokeColorButton->color();
386 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
387 if ( hasDefaultStrokeColor )
388 {
389 stroke = defaultStroke;
390 }
391 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
392 mStrokeColorButton->setColor( stroke );
393 }
394 mStrokeColorButton->setEnabled( hasStrokeParam );
395 mStrokeColorDDBtn->setEnabled( hasStrokeParam );
396 mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
397 if ( hasDefaultStrokeWidth && resetValues )
398 {
399 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
400 }
401 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
402 mStrokeWidthDDBtn->setEnabled( hasStrokeWidthParam );
403}
404
405void 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
413void 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
421void 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
429void 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
437void 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
445void QgsLayoutPictureWidget::modeChanged( bool checked )
446{
447 if ( !checked )
448 return;
449
450 const 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
470void QgsLayoutPictureWidget::sourceChanged( const QString &source )
471{
472 if ( mPicture )
473 {
474 mPicture->beginCommand( tr( "Change Picture" ) );
475 mPicture->setPicturePath( source, mRadioSVG->isChecked() ? Qgis::PictureFormat::SVG : Qgis::PictureFormat::Raster );
476 mPicture->update();
477 mPicture->endCommand();
478 updateSvgParamGui();
479 }
480}
481
482void 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}
PictureFormat
Picture formats.
Definition qgis.h:5272
@ Raster
Raster image.
Definition qgis.h:5274
@ Unknown
Invalid or unknown image type.
Definition qgis.h:5275
@ SVG
SVG image.
Definition qgis.h:5273
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.
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.
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
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.
A widget for controlling the common properties of layout items (e.g.
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.
@ PictureSvgBackgroundColor
SVG background color.
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.
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)
Emitted when an SVG is selected in the widget.