QGIS API Documentation 4.1.0-Master (ca2ac17535b)
Loading...
Searching...
No Matches
qgslayoutchartwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutchartwidget.cpp
3 --------------------------
4 begin : August 2025
5 copyright : (C) 2025 by Mathieu
6 email : mathieu at opengis dot ch
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"
21#include "qgsgui.h"
22#include "qgslayout.h"
23#include "qgslayoutatlas.h"
25#include "qgslayoutitemchart.h"
26#include "qgsplotregistry.h"
27#include "qgsplotwidget.h"
28
29#include "moc_qgslayoutchartwidget.cpp"
30
32 : QgsLayoutItemBaseWidget( nullptr, chartItem )
33 , mChartItem( chartItem )
34{
35 setupUi( this );
36
37 //add widget for general composer item properties
38 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, chartItem );
39 mainLayout->addWidget( mItemPropertiesWidget );
40
41 QMap<QString, QString> plotTypes = QgsApplication::instance()->plotRegistry()->plotTypes();
42 for ( auto plotTypesIterator = plotTypes.keyValueBegin(); plotTypesIterator != plotTypes.keyValueEnd(); ++plotTypesIterator )
43 {
44 mChartTypeComboBox->addItem( plotTypesIterator->second, plotTypesIterator->first );
45 }
46
47 mLayerComboBox->setFilters( Qgis::LayerFilter::VectorLayer );
48
49 connect( mChartTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutChartWidget::mChartTypeComboBox_currentIndexChanged );
50 connect( mChartPropertiesButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mChartPropertiesButton_clicked );
51 connect( mFlipAxesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mFlipAxesCheckBox_stateChanged );
52
53 connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsLayoutChartWidget::changeLayer );
54 connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, mSortExpressionWidget, &QgsFieldExpressionWidget::setLayer );
55 connect( mSortCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mSortCheckBox_stateChanged );
56 connect( mSortExpressionWidget, static_cast<void ( QgsFieldExpressionWidget::* )( const QString &, bool )>( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsLayoutChartWidget::changeSortExpression );
57 connect( mSortDirectionButton, &QToolButton::clicked, this, &QgsLayoutChartWidget::mSortDirectionButton_clicked );
58
59 connect( mGenerateCategoriesFromRendererCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mGenerateCategoriesFromRendererCheckBox_stateChanged );
60 connect( mApplyRendererStyleCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mApplyRendererStyleCheckBox_stateChanged );
61
62 connect( mSeriesListWidget, &QListWidget::currentItemChanged, this, &QgsLayoutChartWidget::mSeriesListWidget_currentItemChanged );
63 connect( mSeriesListWidget, &QListWidget::itemChanged, this, &QgsLayoutChartWidget::mSeriesListWidget_itemChanged );
64 connect( mAddSeriesPushButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mAddSeriesPushButton_clicked );
65 connect( mRemoveSeriesPushButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mRemoveSeriesPushButton_clicked );
66 connect( mSeriesPropertiesButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mSeriesPropertiesButton_clicked );
67
68 mLinkedMapComboBox->setCurrentLayout( mChartItem->layout() );
69 mLinkedMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
70 connect( mLinkedMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutChartWidget::mLinkedMapComboBox_itemChanged );
71
72 connect( mFilterOnlyVisibleFeaturesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mFilterOnlyVisibleFeaturesCheckBox_stateChanged );
73 connect( mIntersectAtlasCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mIntersectAtlasCheckBox_stateChanged );
74
75 setGuiElementValues();
76 updateButtonsState();
77
78 if ( QgsLayoutAtlas *atlas = layoutAtlas() )
79 {
80 connect( atlas, &QgsLayoutAtlas::toggled, this, &QgsLayoutChartWidget::layoutAtlasToggled );
81 layoutAtlasToggled( atlas->enabled() );
82 }
83
84 connect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
85}
86
88{
89 if ( mItemPropertiesWidget )
90 mItemPropertiesWidget->setMasterLayout( masterLayout );
91}
92
94{
96 return false;
97
98 if ( mChartItem )
99 {
100 disconnect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
101 }
102
103 mChartItem = qobject_cast<QgsLayoutItemChart *>( item );
104 mItemPropertiesWidget->setItem( mChartItem );
105
106 if ( mChartItem )
107 {
108 connect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
109 }
110
111 setGuiElementValues();
112
113 return true;
114}
115
116void QgsLayoutChartWidget::setGuiElementValues()
117{
118 if ( mChartItem )
119 {
120 whileBlocking( mChartTypeComboBox )->setCurrentIndex( mChartTypeComboBox->findData( mChartItem->plot()->type() ) );
121 whileBlocking( mLayerComboBox )->setLayer( mChartItem->sourceLayer() );
122
123 Qgs2DXyPlot *plot2DXy = dynamic_cast<Qgs2DXyPlot *>( mChartItem->plot() );
124 if ( plot2DXy )
125 {
126 mFlipAxesCheckBox->setEnabled( true );
127 whileBlocking( mFlipAxesCheckBox )->setChecked( plot2DXy->flipAxes() );
128 }
129 else
130 {
131 mFlipAxesCheckBox->setEnabled( false );
132 whileBlocking( mFlipAxesCheckBox )->setChecked( false );
133 }
134
135 whileBlocking( mGenerateCategoriesFromRendererCheckBox )->setCheckState( mChartItem->generateCategoriesFromRenderer() ? Qt::Checked : Qt::Unchecked );
136 whileBlocking( mApplyRendererStyleCheckBox )->setCheckState( mChartItem->applyRendererStyle() ? Qt::Checked : Qt::Unchecked );
137
138 whileBlocking( mSortCheckBox )->setCheckState( mChartItem->sortFeatures() ? Qt::Checked : Qt::Unchecked );
139 whileBlocking( mSortDirectionButton )->setEnabled( mChartItem->sortFeatures() );
140 whileBlocking( mSortDirectionButton )->setArrowType( mChartItem->sortAscending() ? Qt::UpArrow : Qt::DownArrow );
141 whileBlocking( mSortExpressionWidget )->setEnabled( mChartItem->sortFeatures() );
142 whileBlocking( mSortExpressionWidget )->setLayer( mChartItem->sourceLayer() );
143 whileBlocking( mSortExpressionWidget )->setField( mChartItem->sortExpression() );
144
145 mSeriesListWidget->clear();
146 const QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
147 for ( const QgsLayoutItemChart::SeriesDetails &series : seriesList )
148 {
149 addSeriesListItem( series.name() );
150 }
151
152 if ( !seriesList.isEmpty() )
153 {
154 mSeriesListWidget->setCurrentRow( 0 );
155 }
156 else
157 {
158 mSeriesPropertiesButton->setEnabled( false );
159 }
160
161 whileBlocking( mFilterOnlyVisibleFeaturesCheckBox )->setChecked( mChartItem->filterOnlyVisibleFeatures() );
162 mLinkedMapLabel->setEnabled( mFilterOnlyVisibleFeaturesCheckBox->isChecked() );
163 mLinkedMapComboBox->setEnabled( mFilterOnlyVisibleFeaturesCheckBox->isChecked() );
164 whileBlocking( mLinkedMapComboBox )->setItem( mChartItem->map() );
165
166 whileBlocking( mIntersectAtlasCheckBox )->setChecked( mChartItem->filterToAtlasFeature() );
167 }
168 else
169 {
170 mSeriesListWidget->clear();
171 }
172}
173
174void QgsLayoutChartWidget::mChartTypeComboBox_currentIndexChanged( int )
175{
176 if ( !mChartItem )
177 {
178 return;
179 }
180
181 const QString plotType = mChartTypeComboBox->currentData().toString();
182 if ( mChartItem->plot()->type() == plotType )
183 {
184 return;
185 }
186
187 QgsPlot *oldPlot = mChartItem->plot();
188 QgsPlot *newPlot = QgsApplication::instance()->plotRegistry()->createPlot( plotType );
189 // copy relevant properties from the old plot
190 newPlot->initFromPlot( oldPlot );
191 Qgs2DXyPlot *newPlot2DXy = dynamic_cast<Qgs2DXyPlot *>( newPlot );
192 if ( newPlot2DXy )
193 {
194 mFlipAxesCheckBox->setEnabled( true );
195 mFlipAxesCheckBox->setChecked( newPlot2DXy->flipAxes() );
196 }
197 else
198 {
199 mFlipAxesCheckBox->setEnabled( false );
200 mFlipAxesCheckBox->setChecked( false );
201 }
202
203 mChartItem->beginCommand( tr( "Change Chart Type" ) );
204 mChartItem->setPlot( newPlot );
205 mChartItem->update();
206 mChartItem->endCommand();
207}
208
209void QgsLayoutChartWidget::mChartPropertiesButton_clicked()
210{
211 if ( !mChartItem )
212 {
213 return;
214 }
215
217
218 const QString plotType = mChartTypeComboBox->currentData().toString();
219 QgsPlotAbstractMetadata *abstractMetadata = QgsApplication::instance()->plotRegistry()->plotMetadata( plotType );
220 if ( !abstractMetadata )
221 {
222 return;
223 }
224
225 QgsPlotWidget *widget = abstractMetadata->createPlotWidget( this );
226 if ( !widget )
227 {
228 return;
229 }
230
231 widget->registerExpressionContextGenerator( mChartItem );
232 widget->setPlot( mChartItem->plot() );
233
234 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
235 if ( !mChartItem )
236 {
237 return;
238 }
239
240 mChartItem->beginCommand( tr( "Modify Chart" ) );
241 mChartItem->setPlot( widget->createPlot() );
242 mChartItem->endCommand();
243 mChartItem->update();
244 } );
245
246 openPanel( widget );
247}
248
249void QgsLayoutChartWidget::mFlipAxesCheckBox_stateChanged( int state )
250{
251 if ( !mChartItem )
252 {
253 return;
254 }
255
256 Qgs2DXyPlot *plot2DXy = dynamic_cast<Qgs2DXyPlot *>( mChartItem->plot() );
257 if ( !plot2DXy )
258 {
259 return;
260 }
261
262 mChartItem->beginCommand( tr( "Modify Chart" ) );
263 plot2DXy->setFlipAxes( state == Qt::Checked );
264 mChartItem->endCommand();
265 mChartItem->update();
266}
267
268void QgsLayoutChartWidget::changeLayer( QgsMapLayer *layer )
269{
270 if ( !mChartItem )
271 {
272 return;
273 }
274
275 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
276 if ( !vl )
277 {
278 return;
279 }
280
281 mChartItem->beginCommand( tr( "Change Chart Source Layer" ) );
282 mChartItem->setSourceLayer( vl );
283 mChartItem->update();
284 mChartItem->endCommand();
285 updateButtonsState();
286}
287
288void QgsLayoutChartWidget::changeSortExpression( const QString &expression, bool )
289{
290 if ( !mChartItem )
291 {
292 return;
293 }
294
295 mChartItem->beginCommand( tr( "Change Chart Source Sort Expression" ) );
296 mChartItem->setSortExpression( expression );
297 mChartItem->update();
298 mChartItem->endCommand();
299}
300
301void QgsLayoutChartWidget::mSortCheckBox_stateChanged( int state )
302{
303 if ( !mChartItem )
304 return;
305
306 if ( state == Qt::Checked )
307 {
308 mSortDirectionButton->setEnabled( true );
309 mSortExpressionWidget->setEnabled( true );
310 }
311 else
312 {
313 mSortDirectionButton->setEnabled( false );
314 mSortExpressionWidget->setEnabled( false );
315 }
316
317 mChartItem->beginCommand( tr( "Toggle Atlas Sorting" ) );
318 mChartItem->setSortFeatures( state == Qt::Checked );
319 mChartItem->update();
320 mChartItem->endCommand();
321}
322
323void QgsLayoutChartWidget::mSortDirectionButton_clicked()
324{
325 if ( !mChartItem )
326 {
327 return;
328 }
329
330 Qt::ArrowType at = mSortDirectionButton->arrowType();
331 at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
332 mSortDirectionButton->setArrowType( at );
333
334 mChartItem->beginCommand( tr( "Change Chart Source Sort Direction" ) );
335 mChartItem->setSortAscending( at == Qt::UpArrow );
336 mChartItem->update();
337 mChartItem->endCommand();
338}
339
340QListWidgetItem *QgsLayoutChartWidget::addSeriesListItem( const QString &name )
341{
342 QListWidgetItem *item = new QListWidgetItem( name, nullptr );
343 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
344 mSeriesListWidget->addItem( item );
345 return item;
346}
347
348void QgsLayoutChartWidget::mSeriesListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
349{
350 mSeriesPropertiesButton->setEnabled( static_cast<bool>( current ) );
351}
352
353void QgsLayoutChartWidget::mSeriesListWidget_itemChanged( QListWidgetItem *item )
354{
355 if ( !mChartItem )
356 {
357 return;
358 }
359
360 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
361 const int idx = mSeriesListWidget->row( item );
362 if ( idx >= seriesList.size() )
363 {
364 return;
365 }
366
367 mChartItem->beginCommand( tr( "Rename Chart Series" ) );
368 seriesList[idx].setName( item->text() );
369 mChartItem->setSeriesList( seriesList );
370 mChartItem->endCommand();
371}
372
373void QgsLayoutChartWidget::mAddSeriesPushButton_clicked()
374{
375 if ( !mChartItem )
376 {
377 return;
378 }
379
380 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
381 const QString itemName = tr( "Series %1" ).arg( seriesList.size() + 1 );
382 addSeriesListItem( itemName );
383
384 mChartItem->beginCommand( tr( "Add Chart Series" ) );
385 seriesList << QgsLayoutItemChart::SeriesDetails( itemName );
386 mChartItem->setSeriesList( seriesList );
387 mChartItem->endCommand();
388 mChartItem->update();
389
390 mSeriesListWidget->setCurrentRow( mSeriesListWidget->count() - 1 );
391 mSeriesListWidget_currentItemChanged( mSeriesListWidget->currentItem(), nullptr );
392 updateButtonsState();
393}
394
395void QgsLayoutChartWidget::mRemoveSeriesPushButton_clicked()
396{
397 QListWidgetItem *item = mSeriesListWidget->currentItem();
398 if ( !item || !mChartItem )
399 {
400 return;
401 }
402
403 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
404 const int idx = mSeriesListWidget->row( item );
405 if ( idx >= seriesList.size() )
406 {
407 return;
408 }
409
410 QListWidgetItem *deletedItem = mSeriesListWidget->takeItem( mSeriesListWidget->row( item ) );
411 delete deletedItem;
412
413 mChartItem->beginCommand( tr( "Remove Chart Series" ) );
414 seriesList.removeAt( idx );
415 mChartItem->setSeriesList( seriesList );
416 mChartItem->endCommand();
417 mChartItem->update();
418 updateButtonsState();
419}
420
421void QgsLayoutChartWidget::mSeriesPropertiesButton_clicked()
422{
423 QListWidgetItem *item = mSeriesListWidget->currentItem();
424 if ( !item || !mChartItem )
425 {
426 return;
427 }
428
429 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
430 const int idx = mSeriesListWidget->row( item );
431 if ( idx >= seriesList.size() )
432 {
433 return;
434 }
435
436 QgsLayoutChartSeriesDetailsWidget *widget = new QgsLayoutChartSeriesDetailsWidget( mChartItem->sourceLayer(), idx, seriesList[idx], mGenerateCategoriesFromRendererCheckBox->isChecked(), this );
437 widget->registerExpressionContextGenerator( mChartItem );
438 widget->setPanelTitle( tr( "Series Details" ) );
439 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
440 if ( !mChartItem )
441 {
442 return;
443 }
444
445 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
446 const int idx = widget->index();
447 if ( idx >= seriesList.size() )
448 {
449 return;
450 }
451
452 mChartItem->beginCommand( tr( "Modify Chart Series" ) );
453 seriesList[idx].setXExpression( widget->xExpression() );
454 seriesList[idx].setYExpression( widget->yExpression() );
455 seriesList[idx].setFilterExpression( widget->filterExpression() );
456 mChartItem->setSeriesList( seriesList );
457 mChartItem->endCommand();
458 mChartItem->update();
459 } );
460
461 openPanel( widget );
462}
463
464void QgsLayoutChartWidget::mLinkedMapComboBox_itemChanged( QgsLayoutItem *item )
465{
466 if ( !mChartItem )
467 {
468 return;
469 }
470
471 mChartItem->beginCommand( tr( "Change Chart Map Item" ) );
472 mChartItem->setMap( qobject_cast<QgsLayoutItemMap *>( item ) );
473 mChartItem->endCommand();
474 mChartItem->update();
475}
476
477void QgsLayoutChartWidget::mGenerateCategoriesFromRendererCheckBox_stateChanged( int state )
478{
479 if ( !mChartItem )
480 {
481 return;
482 }
483
484 mChartItem->beginCommand( tr( "Toggle Generate Categories from Layer Renderer" ) );
485 const bool generateCategoriesFromRenderer = ( state == Qt::Checked );
486 mChartItem->setGenerateCategoriesFromRenderer( generateCategoriesFromRenderer );
487 mChartItem->endCommand();
488 mChartItem->update();
489
490 mApplyRendererStyleCheckBox->setEnabled( mGenerateCategoriesFromRendererCheckBox->isChecked() );
491}
492
493void QgsLayoutChartWidget::mApplyRendererStyleCheckBox_stateChanged( int state )
494{
495 if ( !mChartItem )
496 {
497 return;
498 }
499
500 mChartItem->beginCommand( tr( "Toggle Apply Layer Renderer Style" ) );
501 const bool applyRendererStyle = ( state == Qt::Checked );
502 mChartItem->setApplyRendererStyle( applyRendererStyle );
503 mChartItem->endCommand();
504 mChartItem->update();
505}
506
507void QgsLayoutChartWidget::mFilterOnlyVisibleFeaturesCheckBox_stateChanged( int state )
508{
509 if ( !mChartItem )
510 {
511 return;
512 }
513
514 mChartItem->beginCommand( tr( "Toggle Visible Features Only Filter" ) );
515 const bool useOnlyVisibleFeatures = ( state == Qt::Checked );
516 mChartItem->setFilterOnlyVisibleFeatures( useOnlyVisibleFeatures );
517 mChartItem->endCommand();
518 mChartItem->update();
519
520 //enable/disable map combobox based on state of checkbox
521 mLinkedMapComboBox->setEnabled( state == Qt::Checked );
522 mLinkedMapLabel->setEnabled( state == Qt::Checked );
523}
524
525void QgsLayoutChartWidget::mIntersectAtlasCheckBox_stateChanged( int state )
526{
527 if ( !mChartItem )
528 {
529 return;
530 }
531
532 mChartItem->beginCommand( tr( "Toggle Chart Atlas Filter" ) );
533 const bool filterToAtlas = ( state == Qt::Checked );
534 mChartItem->setFilterToAtlasFeature( filterToAtlas );
535 mChartItem->endCommand();
536 mChartItem->update();
537}
538
539void QgsLayoutChartWidget::updateButtonsState()
540{
541 if ( !mChartItem )
542 {
543 return;
544 }
545
546 const bool enable = qobject_cast<QgsVectorLayer *>( mLayerComboBox->currentLayer() ) != nullptr;
547 mGenerateCategoriesFromRendererCheckBox->setEnabled( enable );
548 mApplyRendererStyleCheckBox->setEnabled( enable && mGenerateCategoriesFromRendererCheckBox->isChecked() );
549 mSortCheckBox->setEnabled( enable );
550 mAddSeriesPushButton->setEnabled( enable );
551 mRemoveSeriesPushButton->setEnabled( mSeriesListWidget->count() > 0 );
552}
553
554void QgsLayoutChartWidget::layoutAtlasToggled( bool atlasEnabled )
555{
556 if ( atlasEnabled )
557 {
558 mIntersectAtlasCheckBox->setEnabled( true );
559 }
560 else
561 {
562 mIntersectAtlasCheckBox->setEnabled( false );
563 mIntersectAtlasCheckBox->setChecked( false );
564 }
565}
Base class for 2-dimensional plot/chart/graphs with an X and Y axes.
Definition qgsplot.h:687
void setFlipAxes(bool flipAxes)
Sets whether the X and Y axes are flipped.
Definition qgsplot.cpp:1224
bool flipAxes() const
Returns whether the X and Y axes are flipped.
Definition qgsplot.h:856
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
static QgsPlotRegistry * plotRegistry()
Returns the application's plot registry, used for plot types.
A widget for selection of layer fields or expression creation.
void setLayer(QgsMapLayer *layer)
Sets the layer used to display the fields and expression.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
static void initPlotWidgets()
Initializes plot widgets.
Definition qgsgui.cpp:456
Used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
void toggled(bool enabled)
Emitted when atlas is enabled or disabled.
QString yExpression() const
Returns the Y-axis expression.
QString filterExpression() const
Returns the filter expression.
QString xExpression() const
Returns the X-axis expression.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
QgsLayoutChartWidget(QgsLayoutItemChart *chartItem)
constructor
QgsLayoutAtlas * layoutAtlas() const
Returns the atlas for the layout (if available).
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
A layout item subclass that renders chart plots.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
A widget for controlling the common properties of layout items (e.g.
Base class for graphical items within a QgsLayout.
int type() const override
Returns a unique graphics item type identifier.
void changed()
Emitted when the object's properties change.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Interface for master layout type objects, such as print layouts and reports.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
void widgetChanged()
Emitted when the widget state changes.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
virtual QgsPlotWidget * createPlotWidget(QWidget *parent=nullptr)=0
Creates a widget for configuring plot of this type.
QgsPlot * createPlot(const QString &type) const
Creates a new instance of a plot given the type.
QMap< QString, QString > plotTypes() const
Returns a map of available plot types to translated name.
QgsPlotAbstractMetadata * plotMetadata(const QString &type) const
Returns the metadata for the specified plot type.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
virtual QgsPlot * createPlot()=0
Creates a plot defined by the current settings in the widget.
virtual void setPlot(QgsPlot *plot)=0
Sets the widget to match the settings of the plot.
virtual void initFromPlot(const QgsPlot *plot)
Initializes properties of this plot from an existing plot, transferring all applicable settings.
Definition qgsplot.cpp:101
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:7141