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