QGIS API Documentation 4.1.0-Master (376402f9aeb)
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"
24#include "qgslayoutitemchart.h"
25#include "qgsplotregistry.h"
26#include "qgsplotwidget.h"
27
28#include "moc_qgslayoutchartwidget.cpp"
29
31 : QgsLayoutItemBaseWidget( nullptr, chartItem )
32 , mChartItem( chartItem )
33{
34 setupUi( this );
35
36 //add widget for general composer item properties
37 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, chartItem );
38 mainLayout->addWidget( mItemPropertiesWidget );
39
40 QMap<QString, QString> plotTypes = QgsApplication::instance()->plotRegistry()->plotTypes();
41 for ( auto plotTypesIterator = plotTypes.keyValueBegin(); plotTypesIterator != plotTypes.keyValueEnd(); ++plotTypesIterator )
42 {
43 mChartTypeComboBox->addItem( plotTypesIterator->second, plotTypesIterator->first );
44 }
45
46 mLayerComboBox->setFilters( Qgis::LayerFilter::VectorLayer );
47
48 connect( mChartTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutChartWidget::mChartTypeComboBox_currentIndexChanged );
49 connect( mChartPropertiesButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mChartPropertiesButton_clicked );
50 connect( mFlipAxesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mFlipAxesCheckBox_stateChanged );
51
52 connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsLayoutChartWidget::changeLayer );
53 connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, mSortExpressionWidget, &QgsFieldExpressionWidget::setLayer );
54 connect( mSortCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mSortCheckBox_stateChanged );
55 connect( mSortExpressionWidget, static_cast<void ( QgsFieldExpressionWidget::* )( const QString &, bool )>( &QgsFieldExpressionWidget::fieldChanged ), this, &QgsLayoutChartWidget::changeSortExpression );
56 connect( mSortDirectionButton, &QToolButton::clicked, this, &QgsLayoutChartWidget::mSortDirectionButton_clicked );
57
58 connect( mGenerateCategoriesFromRendererCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mGenerateCategoriesFromRendererCheckBox_stateChanged );
59 connect( mApplyRendererStyleCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mApplyRendererStyleCheckBox_stateChanged );
60
61 connect( mSeriesListWidget, &QListWidget::currentItemChanged, this, &QgsLayoutChartWidget::mSeriesListWidget_currentItemChanged );
62 connect( mSeriesListWidget, &QListWidget::itemChanged, this, &QgsLayoutChartWidget::mSeriesListWidget_itemChanged );
63 connect( mAddSeriesPushButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mAddSeriesPushButton_clicked );
64 connect( mRemoveSeriesPushButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mRemoveSeriesPushButton_clicked );
65 connect( mSeriesPropertiesButton, &QPushButton::clicked, this, &QgsLayoutChartWidget::mSeriesPropertiesButton_clicked );
66
67 mLinkedMapComboBox->setCurrentLayout( mChartItem->layout() );
68 mLinkedMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
69 connect( mLinkedMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutChartWidget::mLinkedMapComboBox_itemChanged );
70
71 connect( mFilterOnlyVisibleFeaturesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mFilterOnlyVisibleFeaturesCheckBox_stateChanged );
72 connect( mIntersectAtlasCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutChartWidget::mIntersectAtlasCheckBox_stateChanged );
73
74 setGuiElementValues();
75 updateButtonsState();
76
77 connect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
78}
79
81{
82 if ( mItemPropertiesWidget )
83 mItemPropertiesWidget->setMasterLayout( masterLayout );
84}
85
87{
89 return false;
90
91 if ( mChartItem )
92 {
93 disconnect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
94 }
95
96 mChartItem = qobject_cast<QgsLayoutItemChart *>( item );
97 mItemPropertiesWidget->setItem( mChartItem );
98
99 if ( mChartItem )
100 {
101 connect( mChartItem, &QgsLayoutObject::changed, this, &QgsLayoutChartWidget::setGuiElementValues );
102 }
103
104 setGuiElementValues();
105
106 return true;
107}
108
109void QgsLayoutChartWidget::setGuiElementValues()
110{
111 if ( mChartItem )
112 {
113 whileBlocking( mChartTypeComboBox )->setCurrentIndex( mChartTypeComboBox->findData( mChartItem->plot()->type() ) );
114 whileBlocking( mLayerComboBox )->setLayer( mChartItem->sourceLayer() );
115
116 Qgs2DXyPlot *plot2DXy = dynamic_cast<Qgs2DXyPlot *>( mChartItem->plot() );
117 if ( plot2DXy )
118 {
119 mFlipAxesCheckBox->setEnabled( true );
120 whileBlocking( mFlipAxesCheckBox )->setChecked( plot2DXy->flipAxes() );
121 }
122 else
123 {
124 mFlipAxesCheckBox->setEnabled( false );
125 whileBlocking( mFlipAxesCheckBox )->setChecked( false );
126 }
127
128 whileBlocking( mGenerateCategoriesFromRendererCheckBox )->setCheckState( mChartItem->generateCategoriesFromRenderer() ? Qt::Checked : Qt::Unchecked );
129 whileBlocking( mApplyRendererStyleCheckBox )->setCheckState( mChartItem->applyRendererStyle() ? Qt::Checked : Qt::Unchecked );
130
131 whileBlocking( mSortCheckBox )->setCheckState( mChartItem->sortFeatures() ? Qt::Checked : Qt::Unchecked );
132 whileBlocking( mSortDirectionButton )->setEnabled( mChartItem->sortFeatures() );
133 whileBlocking( mSortDirectionButton )->setArrowType( mChartItem->sortAscending() ? Qt::UpArrow : Qt::DownArrow );
134 whileBlocking( mSortExpressionWidget )->setEnabled( mChartItem->sortFeatures() );
135 whileBlocking( mSortExpressionWidget )->setLayer( mChartItem->sourceLayer() );
136 whileBlocking( mSortExpressionWidget )->setField( mChartItem->sortExpression() );
137
138 mSeriesListWidget->clear();
139 const QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
140 for ( const QgsLayoutItemChart::SeriesDetails &series : seriesList )
141 {
142 addSeriesListItem( series.name() );
143 }
144
145 if ( !seriesList.isEmpty() )
146 {
147 mSeriesListWidget->setCurrentRow( 0 );
148 }
149 else
150 {
151 mSeriesPropertiesButton->setEnabled( false );
152 }
153
154 whileBlocking( mFilterOnlyVisibleFeaturesCheckBox )->setChecked( mChartItem->filterOnlyVisibleFeatures() );
155 mLinkedMapLabel->setEnabled( mFilterOnlyVisibleFeaturesCheckBox->isChecked() );
156 mLinkedMapComboBox->setEnabled( mFilterOnlyVisibleFeaturesCheckBox->isChecked() );
157 whileBlocking( mLinkedMapComboBox )->setItem( mChartItem->map() );
158
159 whileBlocking( mIntersectAtlasCheckBox )->setChecked( mChartItem->filterToAtlasFeature() );
160 }
161 else
162 {
163 mSeriesListWidget->clear();
164 }
165}
166
167void QgsLayoutChartWidget::mChartTypeComboBox_currentIndexChanged( int )
168{
169 if ( !mChartItem )
170 {
171 return;
172 }
173
174 const QString plotType = mChartTypeComboBox->currentData().toString();
175 if ( mChartItem->plot()->type() == plotType )
176 {
177 return;
178 }
179
180 QgsPlot *oldPlot = mChartItem->plot();
181 QgsPlot *newPlot = QgsApplication::instance()->plotRegistry()->createPlot( plotType );
182 // copy relevant properties from the old plot
183 newPlot->initFromPlot( oldPlot );
184 Qgs2DXyPlot *newPlot2DXy = dynamic_cast<Qgs2DXyPlot *>( newPlot );
185 if ( newPlot2DXy )
186 {
187 mFlipAxesCheckBox->setEnabled( true );
188 mFlipAxesCheckBox->setChecked( newPlot2DXy->flipAxes() );
189 }
190 else
191 {
192 mFlipAxesCheckBox->setEnabled( false );
193 mFlipAxesCheckBox->setChecked( false );
194 }
195
196 mChartItem->beginCommand( tr( "Change Chart Type" ) );
197 mChartItem->setPlot( newPlot );
198 mChartItem->update();
199 mChartItem->endCommand();
200}
201
202void QgsLayoutChartWidget::mChartPropertiesButton_clicked()
203{
204 if ( !mChartItem )
205 {
206 return;
207 }
208
210
211 const QString plotType = mChartTypeComboBox->currentData().toString();
212 QgsPlotAbstractMetadata *abstractMetadata = QgsApplication::instance()->plotRegistry()->plotMetadata( plotType );
213 if ( !abstractMetadata )
214 {
215 return;
216 }
217
218 QgsPlotWidget *widget = abstractMetadata->createPlotWidget( this );
219 if ( !widget )
220 {
221 return;
222 }
223
224 widget->registerExpressionContextGenerator( mChartItem );
225 widget->setPlot( mChartItem->plot() );
226
227 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
228 if ( !mChartItem )
229 {
230 return;
231 }
232
233 mChartItem->beginCommand( tr( "Modify Chart" ) );
234 mChartItem->setPlot( widget->createPlot() );
235 mChartItem->endCommand();
236 mChartItem->update();
237 } );
238
239 openPanel( widget );
240}
241
242void QgsLayoutChartWidget::mFlipAxesCheckBox_stateChanged( int state )
243{
244 if ( !mChartItem )
245 {
246 return;
247 }
248
249 Qgs2DXyPlot *plot2DXy = dynamic_cast<Qgs2DXyPlot *>( mChartItem->plot() );
250 if ( !plot2DXy )
251 {
252 return;
253 }
254
255 mChartItem->beginCommand( tr( "Modify Chart" ) );
256 plot2DXy->setFlipAxes( state == Qt::Checked );
257 mChartItem->endCommand();
258 mChartItem->update();
259}
260
261void QgsLayoutChartWidget::changeLayer( QgsMapLayer *layer )
262{
263 if ( !mChartItem )
264 {
265 return;
266 }
267
268 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
269 if ( !vl )
270 {
271 return;
272 }
273
274 mChartItem->beginCommand( tr( "Change Chart Source Layer" ) );
275 mChartItem->setSourceLayer( vl );
276 mChartItem->update();
277 mChartItem->endCommand();
278 updateButtonsState();
279}
280
281void QgsLayoutChartWidget::changeSortExpression( const QString &expression, bool )
282{
283 if ( !mChartItem )
284 {
285 return;
286 }
287
288 mChartItem->beginCommand( tr( "Change Chart Source Sort Expression" ) );
289 mChartItem->setSortExpression( expression );
290 mChartItem->update();
291 mChartItem->endCommand();
292}
293
294void QgsLayoutChartWidget::mSortCheckBox_stateChanged( int state )
295{
296 if ( !mChartItem )
297 return;
298
299 if ( state == Qt::Checked )
300 {
301 mSortDirectionButton->setEnabled( true );
302 mSortExpressionWidget->setEnabled( true );
303 }
304 else
305 {
306 mSortDirectionButton->setEnabled( false );
307 mSortExpressionWidget->setEnabled( false );
308 }
309
310 mChartItem->beginCommand( tr( "Toggle Atlas Sorting" ) );
311 mChartItem->setSortFeatures( state == Qt::Checked );
312 mChartItem->update();
313 mChartItem->endCommand();
314}
315
316void QgsLayoutChartWidget::mSortDirectionButton_clicked()
317{
318 if ( !mChartItem )
319 {
320 return;
321 }
322
323 Qt::ArrowType at = mSortDirectionButton->arrowType();
324 at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
325 mSortDirectionButton->setArrowType( at );
326
327 mChartItem->beginCommand( tr( "Change Chart Source Sort Direction" ) );
328 mChartItem->setSortAscending( at == Qt::UpArrow );
329 mChartItem->update();
330 mChartItem->endCommand();
331}
332
333QListWidgetItem *QgsLayoutChartWidget::addSeriesListItem( const QString &name )
334{
335 QListWidgetItem *item = new QListWidgetItem( name, nullptr );
336 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
337 mSeriesListWidget->addItem( item );
338 return item;
339}
340
341void QgsLayoutChartWidget::mSeriesListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
342{
343 mSeriesPropertiesButton->setEnabled( static_cast<bool>( current ) );
344}
345
346void QgsLayoutChartWidget::mSeriesListWidget_itemChanged( QListWidgetItem *item )
347{
348 if ( !mChartItem )
349 {
350 return;
351 }
352
353 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
354 const int idx = mSeriesListWidget->row( item );
355 if ( idx >= seriesList.size() )
356 {
357 return;
358 }
359
360 mChartItem->beginCommand( tr( "Rename Chart Series" ) );
361 seriesList[idx].setName( item->text() );
362 mChartItem->setSeriesList( seriesList );
363 mChartItem->endCommand();
364}
365
366void QgsLayoutChartWidget::mAddSeriesPushButton_clicked()
367{
368 if ( !mChartItem )
369 {
370 return;
371 }
372
373 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
374 const QString itemName = tr( "Series %1" ).arg( seriesList.size() + 1 );
375 addSeriesListItem( itemName );
376
377 mChartItem->beginCommand( tr( "Add Chart Series" ) );
378 seriesList << QgsLayoutItemChart::SeriesDetails( itemName );
379 mChartItem->setSeriesList( seriesList );
380 mChartItem->endCommand();
381 mChartItem->update();
382
383 mSeriesListWidget->setCurrentRow( mSeriesListWidget->count() - 1 );
384 mSeriesListWidget_currentItemChanged( mSeriesListWidget->currentItem(), nullptr );
385 updateButtonsState();
386}
387
388void QgsLayoutChartWidget::mRemoveSeriesPushButton_clicked()
389{
390 QListWidgetItem *item = mSeriesListWidget->currentItem();
391 if ( !item || !mChartItem )
392 {
393 return;
394 }
395
396 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
397 const int idx = mSeriesListWidget->row( item );
398 if ( idx >= seriesList.size() )
399 {
400 return;
401 }
402
403 QListWidgetItem *deletedItem = mSeriesListWidget->takeItem( mSeriesListWidget->row( item ) );
404 delete deletedItem;
405
406 mChartItem->beginCommand( tr( "Remove Chart Series" ) );
407 seriesList.removeAt( idx );
408 mChartItem->setSeriesList( seriesList );
409 mChartItem->endCommand();
410 mChartItem->update();
411 updateButtonsState();
412}
413
414void QgsLayoutChartWidget::mSeriesPropertiesButton_clicked()
415{
416 QListWidgetItem *item = mSeriesListWidget->currentItem();
417 if ( !item || !mChartItem )
418 {
419 return;
420 }
421
422 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
423 const int idx = mSeriesListWidget->row( item );
424 if ( idx >= seriesList.size() )
425 {
426 return;
427 }
428
429 QgsLayoutChartSeriesDetailsWidget *widget = new QgsLayoutChartSeriesDetailsWidget( mChartItem->sourceLayer(), idx, seriesList[idx], mGenerateCategoriesFromRendererCheckBox->isChecked(), this );
430 widget->registerExpressionContextGenerator( mChartItem );
431 widget->setPanelTitle( tr( "Series Details" ) );
432 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
433 if ( !mChartItem )
434 {
435 return;
436 }
437
438 QList<QgsLayoutItemChart::SeriesDetails> seriesList = mChartItem->seriesList();
439 const int idx = widget->index();
440 if ( idx >= seriesList.size() )
441 {
442 return;
443 }
444
445 mChartItem->beginCommand( tr( "Modify Chart Series" ) );
446 seriesList[idx].setXExpression( widget->xExpression() );
447 seriesList[idx].setYExpression( widget->yExpression() );
448 seriesList[idx].setFilterExpression( widget->filterExpression() );
449 mChartItem->setSeriesList( seriesList );
450 mChartItem->endCommand();
451 mChartItem->update();
452 } );
453
454 openPanel( widget );
455}
456
457void QgsLayoutChartWidget::mLinkedMapComboBox_itemChanged( QgsLayoutItem *item )
458{
459 if ( !mChartItem )
460 {
461 return;
462 }
463
464 mChartItem->beginCommand( tr( "Change Chart Map Item" ) );
465 mChartItem->setMap( qobject_cast<QgsLayoutItemMap *>( item ) );
466 mChartItem->endCommand();
467 mChartItem->update();
468}
469
470void QgsLayoutChartWidget::mGenerateCategoriesFromRendererCheckBox_stateChanged( int state )
471{
472 if ( !mChartItem )
473 {
474 return;
475 }
476
477 mChartItem->beginCommand( tr( "Toggle Generate Categories from Layer Renderer" ) );
478 const bool generateCategoriesFromRenderer = ( state == Qt::Checked );
479 mChartItem->setGenerateCategoriesFromRenderer( generateCategoriesFromRenderer );
480 mChartItem->endCommand();
481 mChartItem->update();
482
483 mApplyRendererStyleCheckBox->setEnabled( mGenerateCategoriesFromRendererCheckBox->isChecked() );
484}
485
486void QgsLayoutChartWidget::mApplyRendererStyleCheckBox_stateChanged( int state )
487{
488 if ( !mChartItem )
489 {
490 return;
491 }
492
493 mChartItem->beginCommand( tr( "Toggle Apply Layer Renderer Style" ) );
494 const bool applyRendererStyle = ( state == Qt::Checked );
495 mChartItem->setApplyRendererStyle( applyRendererStyle );
496 mChartItem->endCommand();
497 mChartItem->update();
498}
499
500void QgsLayoutChartWidget::mFilterOnlyVisibleFeaturesCheckBox_stateChanged( int state )
501{
502 if ( !mChartItem )
503 {
504 return;
505 }
506
507 mChartItem->beginCommand( tr( "Toggle Visible Features Only Filter" ) );
508 const bool useOnlyVisibleFeatures = ( state == Qt::Checked );
509 mChartItem->setFilterOnlyVisibleFeatures( useOnlyVisibleFeatures );
510 mChartItem->endCommand();
511 mChartItem->update();
512
513 //enable/disable map combobox based on state of checkbox
514 mLinkedMapComboBox->setEnabled( state == Qt::Checked );
515 mLinkedMapLabel->setEnabled( state == Qt::Checked );
516}
517
518void QgsLayoutChartWidget::mIntersectAtlasCheckBox_stateChanged( int state )
519{
520 if ( !mChartItem )
521 {
522 return;
523 }
524
525 mChartItem->beginCommand( tr( "Toggle Chart Atlas Filter" ) );
526 const bool filterToAtlas = ( state == Qt::Checked );
527 mChartItem->setFilterToAtlasFeature( filterToAtlas );
528 mChartItem->endCommand();
529 mChartItem->update();
530}
531
532void QgsLayoutChartWidget::updateButtonsState()
533{
534 if ( !mChartItem )
535 {
536 return;
537 }
538
539 const bool enable = qobject_cast<QgsVectorLayer *>( mLayerComboBox->currentLayer() ) != nullptr;
540 mGenerateCategoriesFromRendererCheckBox->setEnabled( enable );
541 mApplyRendererStyleCheckBox->setEnabled( enable && mGenerateCategoriesFromRendererCheckBox->isChecked() );
542 mSortCheckBox->setEnabled( enable );
543 mAddSeriesPushButton->setEnabled( enable );
544 mRemoveSeriesPushButton->setEnabled( mSeriesListWidget->count() > 0 );
545}
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
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
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:7039