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