QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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 ||
154 mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
155
156 //disable anchor point control for certain zoom modes
157 if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
158 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 ||
309 mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
310
311 mAnchorPointComboBox->setCurrentIndex( mAnchorPointComboBox->findData( mPicture->pictureAnchor() ) );
312 //disable anchor point control for certain zoom modes
313 if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom ||
314 mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
315 {
316 mAnchorPointComboBox->setEnabled( true );
317 }
318 else
319 {
320 mAnchorPointComboBox->setEnabled( false );
321 }
322
323 switch ( mPicture->originalMode() )
324 {
327 mRadioSVG->setChecked( true );
328 break;
330 mRadioRaster->setChecked( true );
331 break;
332 }
333
334 mSvgSelectorWidget->setSvgPath( mPicture->picturePath() );
335 mSvgSelectorWidget->setSvgParameters( mPicture->svgDynamicParameters() );
336
337 updateSvgParamGui( false );
338 mFillColorButton->setColor( mPicture->svgFillColor() );
339 mStrokeColorButton->setColor( mPicture->svgStrokeColor() );
340 mStrokeWidthSpinBox->setValue( mPicture->svgStrokeWidth() );
341
342 mRotationFromComposerMapCheckBox->blockSignals( false );
343 mPictureRotationSpinBox->blockSignals( false );
344 mComposerMapComboBox->blockSignals( false );
345 mNorthTypeComboBox->blockSignals( false );
346 mPictureRotationOffsetSpinBox->blockSignals( false );
347 mResizeModeComboBox->blockSignals( false );
348 mAnchorPointComboBox->blockSignals( false );
349 mFillColorButton->blockSignals( false );
350 mStrokeColorButton->blockSignals( false );
351 mStrokeWidthSpinBox->blockSignals( false );
352
354 }
355}
356
357void QgsLayoutPictureWidget::updateSvgParamGui( bool resetValues )
358{
359 if ( !mPicture )
360 return;
361
362 const QString picturePath = mPicture->picturePath();
363
364 //activate gui for svg parameters only if supported by the svg file
365 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
366 QColor defaultFill, defaultStroke;
367 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
368 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
369 QgsApplication::svgCache()->containsParams( picturePath, hasFillParam, hasDefaultFillColor, defaultFill,
370 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
371 hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
372 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
373 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
374
375 if ( resetValues )
376 {
377 QColor fill = mFillColorButton->color();
378 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
379 if ( hasDefaultFillColor )
380 {
381 fill = defaultFill;
382 }
383 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
384 mFillColorButton->setColor( fill );
385 }
386 mFillColorButton->setEnabled( hasFillParam );
387 mFillColorDDBtn->setEnabled( hasFillParam );
388 mFillColorButton->setAllowOpacity( hasFillOpacityParam );
389 if ( resetValues )
390 {
391 QColor stroke = mStrokeColorButton->color();
392 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
393 if ( hasDefaultStrokeColor )
394 {
395 stroke = defaultStroke;
396 }
397 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
398 mStrokeColorButton->setColor( stroke );
399 }
400 mStrokeColorButton->setEnabled( hasStrokeParam );
401 mStrokeColorDDBtn->setEnabled( hasStrokeParam );
402 mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
403 if ( hasDefaultStrokeWidth && resetValues )
404 {
405 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
406 }
407 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
408 mStrokeWidthDDBtn->setEnabled( hasStrokeWidthParam );
409}
410
411void QgsLayoutPictureWidget::mFillColorButton_colorChanged( const QColor &color )
412{
413 mPicture->beginCommand( tr( "Change Picture Fill Color" ), QgsLayoutItem::UndoPictureFillColor );
414 mPicture->setSvgFillColor( color );
415 mPicture->endCommand();
416 mPicture->update();
417}
418
419void QgsLayoutPictureWidget::mStrokeColorButton_colorChanged( const QColor &color )
420{
421 mPicture->beginCommand( tr( "Change Picture Stroke Color" ), QgsLayoutItem::UndoPictureStrokeColor );
422 mPicture->setSvgStrokeColor( color );
423 mPicture->endCommand();
424 mPicture->update();
425}
426
427void QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged( double d )
428{
429 mPicture->beginCommand( tr( "Change Picture Stroke Width" ), QgsLayoutItem::UndoPictureStrokeWidth );
430 mPicture->setSvgStrokeWidth( d );
431 mPicture->endCommand();
432 mPicture->update();
433}
434
435void QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged( double d )
436{
437 mPicture->beginCommand( tr( "Change Picture North Offset" ), QgsLayoutItem::UndoPictureNorthOffset );
438 mPicture->setNorthOffset( d );
439 mPicture->endCommand();
440 mPicture->update();
441}
442
443void QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged( int index )
444{
445 mPicture->beginCommand( tr( "Change Picture North Mode" ) );
446 mPicture->setNorthMode( static_cast< QgsLayoutItemPicture::NorthMode >( mNorthTypeComboBox->itemData( index ).toInt() ) );
447 mPicture->endCommand();
448 mPicture->update();
449}
450
451void QgsLayoutPictureWidget::modeChanged( bool checked )
452{
453 if ( !checked )
454 return;
455
456 const bool svg = mRadioSVG->isChecked();
458
459 if ( svg )
460 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Svg );
461 else
462 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Image );
463
464 mSvgSelectorWidget->setBrowserVisible( svg );
465 mSvgSelectorWidget->setAllowParameters( svg );
466 mSVGParamsGroupBox->setVisible( svg );
467
468 if ( mPicture && mPicture->mode() != newFormat )
469 {
470 mPicture->beginCommand( tr( "Change Picture Type" ) );
471 mPicture->setMode( newFormat );
472 mPicture->endCommand();
473 }
474}
475
476void QgsLayoutPictureWidget::sourceChanged( const QString &source )
477{
478 if ( mPicture )
479 {
480 mPicture->beginCommand( tr( "Change Picture" ) );
481 mPicture->setPicturePath( source, mRadioSVG->isChecked() ? Qgis::PictureFormat::SVG : Qgis::PictureFormat::Raster );
482 mPicture->update();
483 mPicture->endCommand();
484 updateSvgParamGui();
485 }
486}
487
488void QgsLayoutPictureWidget::setSvgDynamicParameters( const QMap<QString, QgsProperty> &parameters )
489{
490 mPicture->beginCommand( tr( "Set SVG parameters" ) );
491 mPicture->setSvgDynamicParameters( parameters );
492 mPicture->update();
493 mPicture->endCommand();
494}
495
497{
498 updateDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton() );
499 updateDataDefinedButton( mFillColorDDBtn );
500 updateDataDefinedButton( mStrokeColorDDBtn );
501 updateDataDefinedButton( mStrokeWidthDDBtn );
502}
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
PictureFormat
Picture formats.
Definition qgis.h:4893
@ 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.