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