QGIS API Documentation 4.1.0-Master (376402f9aeb)
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 mClipItemComboBox->setCurrentLayout( picture->layout() );
72 mClipItemComboBox->setItemFlags( QgsLayoutItem::FlagProvidesClipPath );
73
74 connect( mPictureRotationSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mPictureRotationSpinBox_valueChanged );
75 connect( mRotationFromComposerMapCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged );
76 connect( mResizeModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mResizeModeComboBox_currentIndexChanged );
77 connect( mAnchorPointComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mAnchorPointComboBox_currentIndexChanged );
78 connect( mFillColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutPictureWidget::mFillColorButton_colorChanged );
79 connect( mStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutPictureWidget::mStrokeColorButton_colorChanged );
80 connect( mStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged );
81 connect( mPictureRotationOffsetSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged );
82 connect( mNorthTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged );
83 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsLayoutPictureWidget::sourceChanged );
84
85 connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsLayoutPictureWidget::setSvgDynamicParameters );
86 connect( mRadioSVG, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
87 connect( mRadioRaster, &QRadioButton::toggled, this, &QgsLayoutPictureWidget::modeChanged );
88
89 connect( mClipToItemCheckBox, &QGroupBox::toggled, this, [this]( bool active ) {
90 mPicture->beginCommand( tr( "Toggle Picture Clipping" ) );
91 mPicture->setClipToItem( active );
92 mPicture->endCommand();
93 } );
94
95 connect( mClipItemComboBox, &QgsLayoutItemComboBox::itemChanged, this, [this]( QgsLayoutItem *item ) {
96 mPicture->beginCommand( tr( "Change Picture Clipping Item" ) );
97 mPicture->setClippingItem( item );
98 mPicture->endCommand();
99 } );
100
101 mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( u"/UI/lastComposerPictureDir"_s );
102
103 setPanelTitle( tr( "Picture Properties" ) );
104
105 mFillColorButton->setAllowOpacity( true );
106 mFillColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
107 mFillColorButton->setContext( u"composer"_s );
108 mStrokeColorButton->setAllowOpacity( true );
109 mStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
110 mStrokeColorButton->setContext( u"composer"_s );
111
112 mFillColorDDBtn->registerLinkedWidget( mFillColorButton );
113 mStrokeColorDDBtn->registerLinkedWidget( mStrokeColorButton );
114
115 mNorthTypeComboBox->blockSignals( true );
116 mNorthTypeComboBox->addItem( tr( "Grid North" ), QgsLayoutItemPicture::GridNorth );
117 mNorthTypeComboBox->addItem( tr( "True North" ), QgsLayoutItemPicture::TrueNorth );
118 mNorthTypeComboBox->blockSignals( false );
119 mPictureRotationOffsetSpinBox->setClearValue( 0.0 );
120 mPictureRotationSpinBox->setClearValue( 0.0 );
121
122 //add widget for general composer item properties
123 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, picture );
124 mainLayout->addWidget( mItemPropertiesWidget );
125
126 if ( mPicture->layout() )
127 {
128 mComposerMapComboBox->setCurrentLayout( mPicture->layout() );
129 mComposerMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
130 connect( mComposerMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutPictureWidget::mapChanged );
131 }
132
133 setGuiElementValues();
134
135 connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
136 connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
137
138 //connections for data defined buttons
139 registerDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton(), QgsLayoutObject::DataDefinedProperty::PictureSource );
143}
144
146{
147 if ( mItemPropertiesWidget )
148 mItemPropertiesWidget->setMasterLayout( masterLayout );
149}
150
151void QgsLayoutPictureWidget::mPictureRotationSpinBox_valueChanged( double d )
152{
153 if ( mPicture )
154 {
155 mPicture->beginCommand( tr( "Change Picture Rotation" ), QgsLayoutItem::UndoPictureRotation );
156 mPicture->setPictureRotation( d );
157 mPicture->endCommand();
158 }
159}
160
161void QgsLayoutPictureWidget::mResizeModeComboBox_currentIndexChanged( int )
162{
163 if ( !mPicture )
164 {
165 return;
166 }
167
168 mPicture->beginCommand( tr( "Change Resize Mode" ) );
169 mPicture->setResizeMode( static_cast<QgsLayoutItemPicture::ResizeMode>( mResizeModeComboBox->currentData().toInt() ) );
170 mPicture->endCommand();
171
172 //disable picture rotation for non-zoom modes
173 mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom || mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
174
175 //disable anchor point control for certain zoom modes
176 if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom || mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
177 {
178 mAnchorPointComboBox->setEnabled( true );
179 }
180 else
181 {
182 mAnchorPointComboBox->setEnabled( false );
183 }
184}
185
186void QgsLayoutPictureWidget::mAnchorPointComboBox_currentIndexChanged( int )
187{
188 if ( !mPicture )
189 {
190 return;
191 }
192
193 mPicture->beginCommand( tr( "Change Placement" ) );
194 mPicture->setPictureAnchor( static_cast<QgsLayoutItem::ReferencePoint>( mAnchorPointComboBox->currentData().toInt() ) );
195 mPicture->endCommand();
196}
197
199{
201 return false;
202
203 if ( mPicture )
204 {
205 disconnect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
206 disconnect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
207 }
208
209 mPicture = qobject_cast<QgsLayoutItemPicture *>( item );
210 mItemPropertiesWidget->setItem( mPicture );
211
212 if ( mPicture )
213 {
214 connect( mPicture, &QgsLayoutObject::changed, this, &QgsLayoutPictureWidget::setGuiElementValues );
215 connect( mPicture, &QgsLayoutItemPicture::pictureRotationChanged, this, &QgsLayoutPictureWidget::setPicRotationSpinValue );
216 }
217
218 setGuiElementValues();
219
220 return true;
221}
222
223void QgsLayoutPictureWidget::mRotationFromComposerMapCheckBox_stateChanged( int state )
224{
225 if ( !mPicture )
226 {
227 return;
228 }
229
230 mPicture->beginCommand( tr( "Toggle Rotation Sync" ) );
231 if ( state == Qt::Unchecked )
232 {
233 mPicture->setLinkedMap( nullptr );
234 mPictureRotationSpinBox->setEnabled( true );
235 mComposerMapComboBox->setEnabled( false );
236 mNorthTypeComboBox->setEnabled( false );
237 mPictureRotationOffsetSpinBox->setEnabled( false );
238 mPicture->setPictureRotation( mPictureRotationSpinBox->value() );
239 }
240 else
241 {
242 QgsLayoutItemMap *map = qobject_cast<QgsLayoutItemMap *>( mComposerMapComboBox->currentItem() );
243 mPicture->setLinkedMap( map );
244 mPictureRotationSpinBox->setEnabled( false );
245 mNorthTypeComboBox->setEnabled( true );
246 mPictureRotationOffsetSpinBox->setEnabled( true );
247 mComposerMapComboBox->setEnabled( true );
248 }
249 mPicture->endCommand();
250}
251
252void QgsLayoutPictureWidget::mapChanged( QgsLayoutItem *item )
253{
254 if ( !mPicture )
255 {
256 return;
257 }
258
259 //get composition
260 const QgsLayout *layout = mPicture->layout();
261 if ( !layout )
262 {
263 return;
264 }
265
266 QgsLayoutItemMap *map = qobject_cast<QgsLayoutItemMap *>( item );
267 if ( !map )
268 {
269 return;
270 }
271
272 mPicture->beginCommand( tr( "Change Rotation Map" ) );
273 mPicture->setLinkedMap( map );
274 mPicture->update();
275 mPicture->endCommand();
276}
277
278void QgsLayoutPictureWidget::setPicRotationSpinValue( double r )
279{
280 mPictureRotationSpinBox->blockSignals( true );
281 mPictureRotationSpinBox->setValue( r );
282 mPictureRotationSpinBox->blockSignals( false );
283}
284
285void QgsLayoutPictureWidget::setGuiElementValues()
286{
287 //set initial gui values
288 if ( mPicture )
289 {
290 mPictureRotationSpinBox->blockSignals( true );
291 mComposerMapComboBox->blockSignals( true );
292 mRotationFromComposerMapCheckBox->blockSignals( true );
293 mNorthTypeComboBox->blockSignals( true );
294 mPictureRotationOffsetSpinBox->blockSignals( true );
295 mResizeModeComboBox->blockSignals( true );
296 mAnchorPointComboBox->blockSignals( true );
297 mFillColorButton->blockSignals( true );
298 mStrokeColorButton->blockSignals( true );
299 mStrokeWidthSpinBox->blockSignals( true );
300 mClipToItemCheckBox->blockSignals( true );
301 mClipItemComboBox->blockSignals( true );
302
303 mPictureRotationSpinBox->setValue( mPicture->pictureRotation() );
304
305 mComposerMapComboBox->setItem( mPicture->linkedMap() );
306
307 if ( mPicture->linkedMap() )
308 {
309 mRotationFromComposerMapCheckBox->setCheckState( Qt::Checked );
310 mPictureRotationSpinBox->setEnabled( false );
311 mComposerMapComboBox->setEnabled( true );
312 mNorthTypeComboBox->setEnabled( true );
313 mPictureRotationOffsetSpinBox->setEnabled( true );
314 }
315 else
316 {
317 mRotationFromComposerMapCheckBox->setCheckState( Qt::Unchecked );
318 mPictureRotationSpinBox->setEnabled( true );
319 mComposerMapComboBox->setEnabled( false );
320 mNorthTypeComboBox->setEnabled( false );
321 mPictureRotationOffsetSpinBox->setEnabled( false );
322 }
323 mNorthTypeComboBox->setCurrentIndex( mNorthTypeComboBox->findData( mPicture->northMode() ) );
324 mPictureRotationOffsetSpinBox->setValue( mPicture->northOffset() );
325
326 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mPicture->resizeMode() ) );
327 //disable picture rotation for non-zoom modes
328 mRotationGroupBox->setEnabled( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom || mPicture->resizeMode() == QgsLayoutItemPicture::ZoomResizeFrame );
329
330 mAnchorPointComboBox->setCurrentIndex( mAnchorPointComboBox->findData( mPicture->pictureAnchor() ) );
331 //disable anchor point control for certain zoom modes
332 if ( mPicture->resizeMode() == QgsLayoutItemPicture::Zoom || mPicture->resizeMode() == QgsLayoutItemPicture::Clip )
333 {
334 mAnchorPointComboBox->setEnabled( true );
335 }
336 else
337 {
338 mAnchorPointComboBox->setEnabled( false );
339 }
340
341 switch ( mPicture->originalMode() )
342 {
345 mRadioSVG->setChecked( true );
346 break;
348 mRadioRaster->setChecked( true );
349 break;
350 }
351
352 mSvgSelectorWidget->setSvgPath( mPicture->picturePath() );
353 mSvgSelectorWidget->setSvgParameters( mPicture->svgDynamicParameters() );
354
355 updateSvgParamGui( false );
356 mFillColorButton->setColor( mPicture->svgFillColor() );
357 mStrokeColorButton->setColor( mPicture->svgStrokeColor() );
358 mStrokeWidthSpinBox->setValue( mPicture->svgStrokeWidth() );
359
360 mClipToItemCheckBox->setChecked( mPicture->clipToItem() );
361 mClipItemComboBox->setItem( mPicture->clippingItem() );
362
363 mRotationFromComposerMapCheckBox->blockSignals( false );
364 mPictureRotationSpinBox->blockSignals( false );
365 mComposerMapComboBox->blockSignals( false );
366 mNorthTypeComboBox->blockSignals( false );
367 mPictureRotationOffsetSpinBox->blockSignals( false );
368 mResizeModeComboBox->blockSignals( false );
369 mAnchorPointComboBox->blockSignals( false );
370 mFillColorButton->blockSignals( false );
371 mStrokeColorButton->blockSignals( false );
372 mStrokeWidthSpinBox->blockSignals( false );
373 mClipToItemCheckBox->blockSignals( false );
374 mClipItemComboBox->blockSignals( false );
375
377 }
378}
379
380void QgsLayoutPictureWidget::updateSvgParamGui( bool resetValues )
381{
382 if ( !mPicture )
383 return;
384
385 const QString picturePath = mPicture->picturePath();
386
387 //activate gui for svg parameters only if supported by the svg file
388 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
389 QColor defaultFill, defaultStroke;
390 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
391 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
393 picturePath,
394 hasFillParam,
395 hasDefaultFillColor,
396 defaultFill,
397 hasFillOpacityParam,
398 hasDefaultFillOpacity,
399 defaultFillOpacity,
400 hasStrokeParam,
401 hasDefaultStrokeColor,
402 defaultStroke,
403 hasStrokeWidthParam,
404 hasDefaultStrokeWidth,
405 defaultStrokeWidth,
406 hasStrokeOpacityParam,
407 hasDefaultStrokeOpacity,
408 defaultStrokeOpacity
409 );
410
411 if ( resetValues )
412 {
413 QColor fill = mFillColorButton->color();
414 const double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
415 if ( hasDefaultFillColor )
416 {
417 fill = defaultFill;
418 }
419 fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
420 mFillColorButton->setColor( fill );
421 }
422 mFillColorButton->setEnabled( hasFillParam );
423 mFillColorDDBtn->setEnabled( hasFillParam );
424 mFillColorButton->setAllowOpacity( hasFillOpacityParam );
425 if ( resetValues )
426 {
427 QColor stroke = mStrokeColorButton->color();
428 const double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
429 if ( hasDefaultStrokeColor )
430 {
431 stroke = defaultStroke;
432 }
433 stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
434 mStrokeColorButton->setColor( stroke );
435 }
436 mStrokeColorButton->setEnabled( hasStrokeParam );
437 mStrokeColorDDBtn->setEnabled( hasStrokeParam );
438 mStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
439 if ( hasDefaultStrokeWidth && resetValues )
440 {
441 mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
442 }
443 mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
444 mStrokeWidthDDBtn->setEnabled( hasStrokeWidthParam );
445}
446
447void QgsLayoutPictureWidget::mFillColorButton_colorChanged( const QColor &color )
448{
449 mPicture->beginCommand( tr( "Change Picture Fill Color" ), QgsLayoutItem::UndoPictureFillColor );
450 mPicture->setSvgFillColor( color );
451 mPicture->endCommand();
452 mPicture->update();
453}
454
455void QgsLayoutPictureWidget::mStrokeColorButton_colorChanged( const QColor &color )
456{
457 mPicture->beginCommand( tr( "Change Picture Stroke Color" ), QgsLayoutItem::UndoPictureStrokeColor );
458 mPicture->setSvgStrokeColor( color );
459 mPicture->endCommand();
460 mPicture->update();
461}
462
463void QgsLayoutPictureWidget::mStrokeWidthSpinBox_valueChanged( double d )
464{
465 mPicture->beginCommand( tr( "Change Picture Stroke Width" ), QgsLayoutItem::UndoPictureStrokeWidth );
466 mPicture->setSvgStrokeWidth( d );
467 mPicture->endCommand();
468 mPicture->update();
469}
470
471void QgsLayoutPictureWidget::mPictureRotationOffsetSpinBox_valueChanged( double d )
472{
473 mPicture->beginCommand( tr( "Change Picture North Offset" ), QgsLayoutItem::UndoPictureNorthOffset );
474 mPicture->setNorthOffset( d );
475 mPicture->endCommand();
476 mPicture->update();
477}
478
479void QgsLayoutPictureWidget::mNorthTypeComboBox_currentIndexChanged( int index )
480{
481 mPicture->beginCommand( tr( "Change Picture North Mode" ) );
482 mPicture->setNorthMode( static_cast<QgsLayoutItemPicture::NorthMode>( mNorthTypeComboBox->itemData( index ).toInt() ) );
483 mPicture->endCommand();
484 mPicture->update();
485}
486
487void QgsLayoutPictureWidget::modeChanged( bool checked )
488{
489 if ( !checked )
490 return;
491
492 const bool svg = mRadioSVG->isChecked();
494
495 if ( svg )
496 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Svg );
497 else
498 mSvgSelectorWidget->sourceLineEdit()->setMode( QgsPictureSourceLineEditBase::Image );
499
500 mSvgSelectorWidget->setBrowserVisible( svg );
501 mSvgSelectorWidget->setAllowParameters( svg );
502 mSVGParamsGroupBox->setVisible( svg );
503
504 if ( mPicture && mPicture->mode() != newFormat )
505 {
506 mPicture->beginCommand( tr( "Change Picture Type" ) );
507 mPicture->setMode( newFormat );
508 mPicture->endCommand();
509 }
510}
511
512void QgsLayoutPictureWidget::sourceChanged( const QString &source )
513{
514 if ( mPicture )
515 {
516 mPicture->beginCommand( tr( "Change Picture" ) );
517 mPicture->setPicturePath( source, mRadioSVG->isChecked() ? Qgis::PictureFormat::SVG : Qgis::PictureFormat::Raster );
518 mPicture->update();
519 mPicture->endCommand();
520 updateSvgParamGui();
521 }
522}
523
524void QgsLayoutPictureWidget::setSvgDynamicParameters( const QMap<QString, QgsProperty> &parameters )
525{
526 mPicture->beginCommand( tr( "Set SVG parameters" ) );
527 mPicture->setSvgDynamicParameters( parameters );
528 mPicture->update();
529 mPicture->endCommand();
530}
531
533{
534 updateDataDefinedButton( mSvgSelectorWidget->propertyOverrideToolButton() );
535 updateDataDefinedButton( mFillColorDDBtn );
536 updateDataDefinedButton( mStrokeColorDDBtn );
537 updateDataDefinedButton( mStrokeWidthDDBtn );
538}
PictureFormat
Picture formats.
Definition qgis.h:5590
@ Raster
Raster image.
Definition qgis.h:5592
@ Unknown
Invalid or unknown image type.
Definition qgis.h:5593
@ SVG
SVG image.
Definition qgis.h:5591
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.
@ FlagProvidesClipPath
Item can act as a clipping path provider (see clipPath()).
const QgsLayout * layout() const
Returns the layout the object is attached to.
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.