QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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;
371 picturePath,
372 hasFillParam,
373 hasDefaultFillColor,
374 defaultFill,
375 hasFillOpacityParam,
376 hasDefaultFillOpacity,
377 defaultFillOpacity,
378 hasStrokeParam,
379 hasDefaultStrokeColor,
380 defaultStroke,
381 hasStrokeWidthParam,
382 hasDefaultStrokeWidth,
383 defaultStrokeWidth,
384 hasStrokeOpacityParam,
385 hasDefaultStrokeOpacity,
386 defaultStrokeOpacity
387 );
388
389 if ( resetValues )
390 {
391 QColor fill = mFillColorButton->color();
392 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
393 if ( hasDefaultFillColor )
394 {
395 fill = defaultFill;
396 }
397 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
398 mFillColorButton->setColor( fill );
399 }
400 mFillColorButton->setEnabled( hasFillParam );
401 mFillColorDDBtn->setEnabled( hasFillParam );
402 mFillColorButton->setAllowOpacity( hasFillOpacityParam );
403 if ( resetValues )
404 {
405 QColor stroke = mStrokeColorButton->color();
406 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
407 if ( hasDefaultStrokeColor )
408 {
409 stroke = defaultStroke;
410 }
411 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
412 mStrokeColorButton->setColor( stroke );
413 }
414 mStrokeColorButton->setEnabled( hasStrokeParam );
415 mStrokeColorDDBtn->setEnabled( hasStrokeParam );
416 mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
417 if ( hasDefaultStrokeWidth && resetValues )
418 {
419 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
420 }
421 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
422 mStrokeWidthDDBtn->setEnabled( hasStrokeWidthParam );
423}
424
425void QgsLayoutPictureWidget::mFillColorButton_colorChanged( const QColor &color )
426{
427 mPicture->beginCommand( tr( "Change Picture Fill Color" ), QgsLayoutItem::UndoPictureFillColor );
428 mPicture->setSvgFillColor( color );
429 mPicture->endCommand();
430 mPicture->update();
431}
432
433void QgsLayoutPictureWidget::mStrokeColorButton_colorChanged( const QColor &color )
434{
435 mPicture->beginCommand( tr( "Change Picture Stroke Color" ), QgsLayoutItem::UndoPictureStrokeColor );
436 mPicture->setSvgStrokeColor( color );
437 mPicture->endCommand();
438 mPicture->update();
439}
440
441void QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged( double d )
442{
443 mPicture->beginCommand( tr( "Change Picture Stroke Width" ), QgsLayoutItem::UndoPictureStrokeWidth );
444 mPicture->setSvgStrokeWidth( d );
445 mPicture->endCommand();
446 mPicture->update();
447}
448
449void QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged( double d )
450{
451 mPicture->beginCommand( tr( "Change Picture North Offset" ), QgsLayoutItem::UndoPictureNorthOffset );
452 mPicture->setNorthOffset( d );
453 mPicture->endCommand();
454 mPicture->update();
455}
456
457void QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged( int index )
458{
459 mPicture->beginCommand( tr( "Change Picture North Mode" ) );
460 mPicture->setNorthMode( static_cast<QgsLayoutItemPicture::NorthMode>( mNorthTypeComboBox->itemData( index ).toInt() ) );
461 mPicture->endCommand();
462 mPicture->update();
463}
464
465void QgsLayoutPictureWidget::modeChanged( bool checked )
466{
467 if ( !checked )
468 return;
469
470 const bool svg = mRadioSVG->isChecked();
472
473 if ( svg )
474 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Svg );
475 else
476 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Image );
477
478 mSvgSelectorWidget->setBrowserVisible( svg );
479 mSvgSelectorWidget->setAllowParameters( svg );
480 mSVGParamsGroupBox->setVisible( svg );
481
482 if ( mPicture && mPicture->mode() != newFormat )
483 {
484 mPicture->beginCommand( tr( "Change Picture Type" ) );
485 mPicture->setMode( newFormat );
486 mPicture->endCommand();
487 }
488}
489
490void QgsLayoutPictureWidget::sourceChanged( const QString &source )
491{
492 if ( mPicture )
493 {
494 mPicture->beginCommand( tr( "Change Picture" ) );
495 mPicture->setPicturePath( source, mRadioSVG->isChecked() ? Qgis::PictureFormat::SVG : Qgis::PictureFormat::Raster );
496 mPicture->update();
497 mPicture->endCommand();
498 updateSvgParamGui();
499 }
500}
501
502void QgsLayoutPictureWidget::setSvgDynamicParameters( const QMap<QString, QgsProperty> &parameters )
503{
504 mPicture->beginCommand( tr( "Set SVG parameters" ) );
505 mPicture->setSvgDynamicParameters( parameters );
506 mPicture->update();
507 mPicture->endCommand();
508}
509
511{
512 updateDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton() );
513 updateDataDefinedButton( mFillColorDDBtn );
514 updateDataDefinedButton( mStrokeColorDDBtn );
515 updateDataDefinedButton( mStrokeWidthDDBtn );
516}
PictureFormat
Picture formats.
Definition qgis.h:5434
@ Raster
Raster image.
Definition qgis.h:5436
@ Unknown
Invalid or unknown image type.
Definition qgis.h:5437
@ SVG
SVG image.
Definition qgis.h:5435
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.