QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsdiagramproperties.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdiagramproperties.cpp
3  Adjust the properties for diagrams
4  -------------------
5  begin : August 2012
6  copyright : (C) Matthias Kuhn
7  email : matthias at opengis dot ch
8 
9  ***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
19 #include "diagram/qgspiediagram.h"
20 #include "diagram/qgstextdiagram.h"
22 
23 #include "qgsproject.h"
24 #include "qgsapplication.h"
27 #include "qgsdiagramproperties.h"
28 #include "qgsdiagramrenderer.h"
30 #include "qgsmessagebar.h"
32 #include "qgsvectordataprovider.h"
33 #include "qgsfeatureiterator.h"
34 #include "qgscolordialog.h"
35 #include "qgsguiutils.h"
37 #include "qgsstyle.h"
38 #include "qgsmapcanvas.h"
40 #include "qgslogger.h"
41 #include "qgssettings.h"
43 #include "qgsauxiliarystorage.h"
45 #include "qgspropertytransformer.h"
46 #include "qgspainteffectregistry.h"
47 #include "qgspainteffect.h"
48 #include "qgslinesymbol.h"
49 
50 #include <QList>
51 #include <QMessageBox>
52 #include <QStyledItemDelegate>
53 #include <QRandomGenerator>
54 
59 class EditBlockerDelegate: public QStyledItemDelegate
60 {
61  public:
62  EditBlockerDelegate( QObject *parent = nullptr )
63  : QStyledItemDelegate( parent )
64  {}
65 
66  QWidget *createEditor( QWidget *, const QStyleOptionViewItem &, const QModelIndex & ) const override
67  {
68  return nullptr;
69  }
70 };
71 
72 
73 QgsExpressionContext QgsDiagramProperties::createExpressionContext() const
74 {
75  QgsExpressionContext expContext;
81 
82  return expContext;
83 }
84 
86  : QWidget( parent )
87  , mMapCanvas( canvas )
88 {
89  mLayer = layer;
90  if ( !layer )
91  {
92  return;
93  }
94 
95  setupUi( this );
96  connect( mDiagramTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsDiagramProperties::mDiagramTypeComboBox_currentIndexChanged );
97  connect( mAddCategoryPushButton, &QPushButton::clicked, this, &QgsDiagramProperties::mAddCategoryPushButton_clicked );
98  connect( mAttributesTreeWidget, &QTreeWidget::itemDoubleClicked, this, &QgsDiagramProperties::mAttributesTreeWidget_itemDoubleClicked );
99  connect( mFindMaximumValueButton, &QPushButton::clicked, this, &QgsDiagramProperties::mFindMaximumValueButton_clicked );
100  connect( mRemoveCategoryPushButton, &QPushButton::clicked, this, &QgsDiagramProperties::mRemoveCategoryPushButton_clicked );
101  connect( mDiagramAttributesTreeWidget, &QTreeWidget::itemDoubleClicked, this, &QgsDiagramProperties::mDiagramAttributesTreeWidget_itemDoubleClicked );
102  connect( mEngineSettingsButton, &QPushButton::clicked, this, &QgsDiagramProperties::mEngineSettingsButton_clicked );
103  connect( mDiagramStackedWidget, &QStackedWidget::currentChanged, this, &QgsDiagramProperties::mDiagramStackedWidget_currentChanged );
104 
105  // get rid of annoying outer focus rect on Mac
106  mDiagramOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );
107 
108  mBarSpacingSpinBox->setClearValue( 0 );
111 
112  mDiagramFontButton->setMode( QgsFontButton::ModeQFont );
113 
114  mDiagramTypeComboBox->blockSignals( true );
115  QIcon icon = QgsApplication::getThemeIcon( QStringLiteral( "diagramNone.svg" ) );
116  mDiagramTypeComboBox->addItem( icon, tr( "No Diagrams" ), "None" );
117  icon = QgsApplication::getThemeIcon( QStringLiteral( "pie-chart.svg" ) );
118  mDiagramTypeComboBox->addItem( icon, tr( "Pie Chart" ), DIAGRAM_NAME_PIE );
119  icon = QgsApplication::getThemeIcon( QStringLiteral( "text.svg" ) );
120  mDiagramTypeComboBox->addItem( icon, tr( "Text Diagram" ), DIAGRAM_NAME_TEXT );
121  icon = QgsApplication::getThemeIcon( QStringLiteral( "histogram.svg" ) );
122  mDiagramTypeComboBox->addItem( icon, tr( "Histogram" ), DIAGRAM_NAME_HISTOGRAM );
123  icon = QgsApplication::getThemeIcon( QStringLiteral( "stacked-bar.svg" ) );
124  mDiagramTypeComboBox->addItem( icon, tr( "Stacked Bars" ), DIAGRAM_NAME_STACKED );
125  mDiagramTypeComboBox->blockSignals( false );
126 
127  mAxisLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
128  mAxisLineStyleButton->setDialogTitle( tr( "Axis Line Symbol" ) );
129 
130  mScaleRangeWidget->setMapCanvas( mMapCanvas );
131  mSizeFieldExpressionWidget->registerExpressionContextGenerator( this );
132 
133  mBackgroundColorButton->setColorDialogTitle( tr( "Select Background Color" ) );
134  mBackgroundColorButton->setAllowOpacity( true );
135  mBackgroundColorButton->setContext( QStringLiteral( "symbology" ) );
136  mBackgroundColorButton->setShowNoColor( true );
137  mBackgroundColorButton->setNoColorString( tr( "Transparent Background" ) );
138  mDiagramPenColorButton->setColorDialogTitle( tr( "Select Pen Color" ) );
139  mDiagramPenColorButton->setAllowOpacity( true );
140  mDiagramPenColorButton->setContext( QStringLiteral( "symbology" ) );
141  mDiagramPenColorButton->setShowNoColor( true );
142  mDiagramPenColorButton->setNoColorString( tr( "Transparent Stroke" ) );
143 
144  mMaxValueSpinBox->setShowClearButton( false );
145  mSizeSpinBox->setClearValue( 5 );
146 
147  mDiagramAttributesTreeWidget->setItemDelegateForColumn( ColumnAttributeExpression, new EditBlockerDelegate( this ) );
148  mDiagramAttributesTreeWidget->setItemDelegateForColumn( ColumnColor, new QgsColorSwatchDelegate( this ) );
149 
150  mDiagramAttributesTreeWidget->setColumnWidth( ColumnColor, Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 6.6 );
151 
152  connect( mFixedSizeRadio, &QRadioButton::toggled, this, &QgsDiagramProperties::scalingTypeChanged );
153  connect( mAttributeBasedScalingRadio, &QRadioButton::toggled, this, &QgsDiagramProperties::scalingTypeChanged );
154 
159 
160  const QgsWkbTypes::GeometryType layerType = layer->geometryType();
161  if ( layerType == QgsWkbTypes::UnknownGeometry || layerType == QgsWkbTypes::NullGeometry )
162  {
163  mDiagramTypeComboBox->setEnabled( false );
164  mDiagramFrame->setEnabled( false );
165  }
166 
167  // set placement methods page based on geometry type
168 
169  switch ( layerType )
170  {
172  stackedPlacement->setCurrentWidget( pagePoint );
173  mLinePlacementFrame->setVisible( false );
174  break;
176  stackedPlacement->setCurrentWidget( pageLine );
177  mLinePlacementFrame->setVisible( true );
178  break;
180  stackedPlacement->setCurrentWidget( pagePolygon );
181  mLinePlacementFrame->setVisible( false );
182  break;
185  break;
186  }
187 
188  //insert placement options
189  // setup point placement button group
190  mPlacePointBtnGrp = new QButtonGroup( this );
191  mPlacePointBtnGrp->addButton( radAroundPoint );
192  mPlacePointBtnGrp->addButton( radOverPoint );
193  mPlacePointBtnGrp->setExclusive( true );
194  connect( mPlacePointBtnGrp, qOverload< QAbstractButton * >( &QButtonGroup::buttonClicked ), this, &QgsDiagramProperties::updatePlacementWidgets );
195 
196  // setup line placement button group
197  mPlaceLineBtnGrp = new QButtonGroup( this );
198  mPlaceLineBtnGrp->addButton( radAroundLine );
199  mPlaceLineBtnGrp->addButton( radOverLine );
200  mPlaceLineBtnGrp->setExclusive( true );
201  connect( mPlaceLineBtnGrp, qOverload< QAbstractButton * >( &QButtonGroup::buttonClicked ), this, &QgsDiagramProperties::updatePlacementWidgets );
202 
203  // setup polygon placement button group
204  mPlacePolygonBtnGrp = new QButtonGroup( this );
205  mPlacePolygonBtnGrp->addButton( radAroundCentroid );
206  mPlacePolygonBtnGrp->addButton( radOverCentroid );
207  mPlacePolygonBtnGrp->addButton( radPolygonPerimeter );
208  mPlacePolygonBtnGrp->addButton( radInsidePolygon );
209  mPlacePolygonBtnGrp->setExclusive( true );
210  connect( mPlacePolygonBtnGrp, qOverload< QAbstractButton * >( &QButtonGroup::buttonClicked ), this, &QgsDiagramProperties::updatePlacementWidgets );
211 
212  mLabelPlacementComboBox->addItem( tr( "Height" ), QgsDiagramSettings::Height );
213  mLabelPlacementComboBox->addItem( tr( "x-height" ), QgsDiagramSettings::XHeight );
214 
215  mScaleDependencyComboBox->addItem( tr( "Area" ), true );
216  mScaleDependencyComboBox->addItem( tr( "Diameter" ), false );
217 
218  mAngleOffsetComboBox->addItem( tr( "Top" ), 270 );
219  mAngleOffsetComboBox->addItem( tr( "Right" ), 0 );
220  mAngleOffsetComboBox->addItem( tr( "Bottom" ), 90 );
221  mAngleOffsetComboBox->addItem( tr( "Left" ), 180 );
222 
223  mAngleDirectionComboBox->addItem( tr( "Clockwise" ), QgsDiagramSettings::Clockwise );
224  mAngleDirectionComboBox->addItem( tr( "Counter-clockwise" ), QgsDiagramSettings::Counterclockwise );
225 
226  const QgsSettings settings;
227 
228  // reset horiz stretch of left side of options splitter (set to 1 for previewing in Qt Designer)
229  QSizePolicy policy( mDiagramOptionsListFrame->sizePolicy() );
230  policy.setHorizontalStretch( 0 );
231  mDiagramOptionsListFrame->setSizePolicy( policy );
232  if ( !settings.contains( QStringLiteral( "/Windows/Diagrams/OptionsSplitState" ) ) )
233  {
234  // set left list widget width on initial showing
235  QList<int> splitsizes;
236  splitsizes << 115;
237  mDiagramOptionsSplitter->setSizes( splitsizes );
238  }
239 
240  // restore dialog, splitters and current tab
241  mDiagramOptionsSplitter->restoreState( settings.value( QStringLiteral( "Windows/Diagrams/OptionsSplitState" ) ).toByteArray() );
242  mDiagramOptionsListWidget->setCurrentRow( settings.value( QStringLiteral( "Windows/Diagrams/Tab" ), 0 ).toInt() );
243 
244  // field combo and expression button
245  mSizeFieldExpressionWidget->setLayer( mLayer );
246  QgsDistanceArea myDa;
247  myDa.setSourceCrs( mLayer->crs(), QgsProject::instance()->transformContext() );
248  myDa.setEllipsoid( QgsProject::instance()->ellipsoid() );
249  mSizeFieldExpressionWidget->setGeomCalculator( myDa );
250 
251  //insert all attributes into the combo boxes
252  const QgsFields &layerFields = layer->fields();
253  for ( int idx = 0; idx < layerFields.count(); ++idx )
254  {
255  QTreeWidgetItem *newItem = new QTreeWidgetItem( mAttributesTreeWidget );
256  const QString name = QStringLiteral( "\"%1\"" ).arg( layerFields.at( idx ).name() );
257  newItem->setText( 0, name );
258  newItem->setData( 0, RoleAttributeExpression, name );
259  newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );
260  }
261 
262  mPaintEffect.reset( QgsPaintEffectRegistry::defaultStack() );
263  mPaintEffect->setEnabled( false );
264 
265  syncToLayer();
266 
267  connect( mAddAttributeExpression, &QPushButton::clicked, this, &QgsDiagramProperties::showAddAttributeExpressionDialog );
268  registerDataDefinedButton( mBackgroundColorDDBtn, QgsDiagramLayerSettings::BackgroundColor );
269  registerDataDefinedButton( mLineColorDDBtn, QgsDiagramLayerSettings::StrokeColor );
270  registerDataDefinedButton( mLineWidthDDBtn, QgsDiagramLayerSettings::StrokeWidth );
271  registerDataDefinedButton( mCoordXDDBtn, QgsDiagramLayerSettings::PositionX );
272  registerDataDefinedButton( mCoordYDDBtn, QgsDiagramLayerSettings::PositionY );
273  registerDataDefinedButton( mDistanceDDBtn, QgsDiagramLayerSettings::Distance );
274  registerDataDefinedButton( mPriorityDDBtn, QgsDiagramLayerSettings::Priority );
275  registerDataDefinedButton( mZOrderDDBtn, QgsDiagramLayerSettings::ZIndex );
276  registerDataDefinedButton( mShowDiagramDDBtn, QgsDiagramLayerSettings::Show );
277  registerDataDefinedButton( mAlwaysShowDDBtn, QgsDiagramLayerSettings::AlwaysShow );
278  registerDataDefinedButton( mIsObstacleDDBtn, QgsDiagramLayerSettings::IsObstacle );
279  registerDataDefinedButton( mStartAngleDDBtn, QgsDiagramLayerSettings::StartAngle );
280 
281  connect( mButtonSizeLegendSettings, &QPushButton::clicked, this, &QgsDiagramProperties::showSizeLegendDialog );
282 }
283 
285 {
286  mDiagramAttributesTreeWidget->clear();
287 
288  const QgsDiagramRenderer *dr = mLayer->diagramRenderer();
289  if ( !dr ) //no diagram renderer yet, insert reasonable default
290  {
291  mDiagramTypeComboBox->blockSignals( true );
292  mDiagramTypeComboBox->setCurrentIndex( 0 );
293  mDiagramTypeComboBox->blockSignals( false );
294  mFixedSizeRadio->setChecked( true );
295  mDiagramUnitComboBox->setUnit( QgsUnitTypes::RenderMillimeters );
296  mDiagramLineUnitComboBox->setUnit( QgsUnitTypes::RenderMillimeters );
297  mLabelPlacementComboBox->setCurrentIndex( mLabelPlacementComboBox->findText( tr( "x-height" ) ) );
298  mDiagramSizeSpinBox->setEnabled( true );
299  mDiagramSizeSpinBox->setValue( 15 );
300  mLinearScaleFrame->setEnabled( false );
301  mIncreaseMinimumSizeSpinBox->setEnabled( false );
302  mIncreaseMinimumSizeLabel->setEnabled( false );
303  mBarWidthSpinBox->setValue( 5 );
304  mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
305  mScaleRangeWidget->setScaleRange( mLayer->minimumScale(), mLayer->maximumScale() );
306  mShowAllCheckBox->setChecked( true );
307  mCheckBoxAttributeLegend->setChecked( true );
308 
309  switch ( mLayer->geometryType() )
310  {
312  radAroundPoint->setChecked( true );
313  break;
314 
316  radAroundLine->setChecked( true );
317  chkLineAbove->setChecked( true );
318  chkLineBelow->setChecked( false );
319  chkLineOn->setChecked( false );
320  chkLineOrientationDependent->setChecked( false );
321  break;
322 
324  radOverCentroid->setChecked( true );
325  mDiagramDistanceLabel->setEnabled( false );
326  mDiagramDistanceSpinBox->setEnabled( false );
327  mDistanceDDBtn->setEnabled( false );
328  break;
329 
332  break;
333  }
334  mBackgroundColorButton->setColor( QColor( 255, 255, 255, 255 ) );
335  //force a refresh of widget status to match diagram type
336  mDiagramTypeComboBox_currentIndexChanged( mDiagramTypeComboBox->currentIndex() );
337 
338  }
339  else // already a diagram renderer present
340  {
341  //single category renderer or interpolated one?
342  if ( dr->rendererName() == QLatin1String( "SingleCategory" ) )
343  {
344  mFixedSizeRadio->setChecked( true );
345  }
346  else
347  {
348  mAttributeBasedScalingRadio->setChecked( true );
349  }
350  mDiagramSizeSpinBox->setEnabled( mFixedSizeRadio->isChecked() );
351  mLinearScaleFrame->setEnabled( mAttributeBasedScalingRadio->isChecked() );
352  mCheckBoxAttributeLegend->setChecked( dr->attributeLegend() );
353 
354  //assume single category or linearly interpolated diagram renderer for now
355  const QList<QgsDiagramSettings> settingList = dr->diagramSettings();
356  if ( !settingList.isEmpty() )
357  {
358  mDiagramFrame->setEnabled( settingList.at( 0 ).enabled );
359  mDiagramFontButton->setCurrentFont( settingList.at( 0 ).font );
360  const QSizeF size = settingList.at( 0 ).size;
361  mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor );
362  mOpacityWidget->setOpacity( settingList.at( 0 ).opacity );
363  mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor );
364  mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth );
365  mDiagramSizeSpinBox->setValue( ( size.width() + size.height() ) / 2.0 );
366  mScaleRangeWidget->setScaleRange( ( settingList.at( 0 ).minimumScale > 0 ? settingList.at( 0 ).minimumScale : mLayer->minimumScale() ),
367  ( settingList.at( 0 ).maximumScale > 0 ? settingList.at( 0 ).maximumScale : mLayer->maximumScale() ) );
368  mScaleVisibilityGroupBox->setChecked( settingList.at( 0 ).scaleBasedVisibility );
369  mDiagramUnitComboBox->setUnit( settingList.at( 0 ).sizeType );
370  mDiagramUnitComboBox->setMapUnitScale( settingList.at( 0 ).sizeScale );
371  mDiagramLineUnitComboBox->setUnit( settingList.at( 0 ).lineSizeUnit );
372  mDiagramLineUnitComboBox->setMapUnitScale( settingList.at( 0 ).lineSizeScale );
373 
374  if ( settingList.at( 0 ).labelPlacementMethod == QgsDiagramSettings::Height )
375  {
376  mLabelPlacementComboBox->setCurrentIndex( 0 );
377  }
378  else
379  {
380  mLabelPlacementComboBox->setCurrentIndex( 1 );
381  }
382 
383  if ( settingList.at( 0 ).paintEffect() )
384  mPaintEffect.reset( settingList.at( 0 ).paintEffect()->clone() );
385 
386  mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).rotationOffset ) );
387  mAngleDirectionComboBox->setCurrentIndex( mAngleDirectionComboBox->findData( settingList.at( 0 ).direction() ) );
388 
389  mOrientationLeftButton->setProperty( "direction", QgsDiagramSettings::Left );
390  mOrientationRightButton->setProperty( "direction", QgsDiagramSettings::Right );
391  mOrientationUpButton->setProperty( "direction", QgsDiagramSettings::Up );
392  mOrientationDownButton->setProperty( "direction", QgsDiagramSettings::Down );
393  switch ( settingList.at( 0 ).diagramOrientation )
394  {
396  mOrientationLeftButton->setChecked( true );
397  break;
398 
400  mOrientationRightButton->setChecked( true );
401  break;
402 
404  mOrientationUpButton->setChecked( true );
405  break;
406 
408  mOrientationDownButton->setChecked( true );
409  break;
410  }
411 
412  mBarWidthSpinBox->setValue( settingList.at( 0 ).barWidth );
413  mBarSpacingSpinBox->setValue( settingList.at( 0 ).spacing() );
414  mBarSpacingUnitComboBox->setUnit( settingList.at( 0 ).spacingUnit() );
415  mBarSpacingUnitComboBox->setMapUnitScale( settingList.at( 0 ).spacingMapUnitScale() );
416 
417  mShowAxisGroupBox->setChecked( settingList.at( 0 ).showAxis() );
418  if ( settingList.at( 0 ).axisLineSymbol() )
419  mAxisLineStyleButton->setSymbol( settingList.at( 0 ).axisLineSymbol()->clone() );
420 
421  mIncreaseSmallDiagramsCheck->setChecked( settingList.at( 0 ).minimumSize != 0 );
422  mIncreaseMinimumSizeSpinBox->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() );
423  mIncreaseMinimumSizeLabel->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() );
424 
425  mIncreaseMinimumSizeSpinBox->setValue( settingList.at( 0 ).minimumSize );
426 
427  if ( settingList.at( 0 ).scaleByArea )
428  {
429  mScaleDependencyComboBox->setCurrentIndex( 0 );
430  }
431  else
432  {
433  mScaleDependencyComboBox->setCurrentIndex( 1 );
434  }
435 
436  const QList< QColor > categoryColors = settingList.at( 0 ).categoryColors;
437  const QList< QString > categoryAttributes = settingList.at( 0 ).categoryAttributes;
438  const QList< QString > categoryLabels = settingList.at( 0 ).categoryLabels;
439  QList< QString >::const_iterator catIt = categoryAttributes.constBegin();
440  QList< QColor >::const_iterator coIt = categoryColors.constBegin();
441  QList< QString >::const_iterator labIt = categoryLabels.constBegin();
442  for ( ; catIt != categoryAttributes.constEnd(); ++catIt, ++coIt, ++labIt )
443  {
444  QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );
445  newItem->setText( 0, *catIt );
446  newItem->setData( 0, RoleAttributeExpression, *catIt );
447  newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled );
448  newItem->setData( ColumnColor, Qt::EditRole, *coIt );
449  newItem->setText( 2, *labIt );
450  newItem->setFlags( newItem->flags() | Qt::ItemIsEditable );
451  }
452  }
453 
454  if ( dr->rendererName() == QLatin1String( "LinearlyInterpolated" ) )
455  {
456  const QgsLinearlyInterpolatedDiagramRenderer *lidr = dynamic_cast<const QgsLinearlyInterpolatedDiagramRenderer *>( dr );
457  if ( lidr )
458  {
459  mDiagramSizeSpinBox->setEnabled( false );
460  mLinearScaleFrame->setEnabled( true );
461  mMaxValueSpinBox->setValue( lidr->upperValue() );
462  mSizeSpinBox->setValue( ( lidr->upperSize().width() + lidr->upperSize().height() ) / 2 );
464  {
465  mSizeFieldExpressionWidget->setField( lidr->classificationAttributeExpression() );
466  }
467  else
468  {
469  mSizeFieldExpressionWidget->setField( lidr->classificationField() );
470  }
471 
472  mSizeLegend.reset( lidr->dataDefinedSizeLegend() ? new QgsDataDefinedSizeLegend( *lidr->dataDefinedSizeLegend() ) : nullptr );
473  }
474  }
475 
476  const QgsDiagramLayerSettings *dls = mLayer->diagramLayerSettings();
477  if ( dls )
478  {
479  mDiagramDistanceSpinBox->setValue( dls->distance() );
480  mPrioritySlider->setValue( dls->priority() );
481  mZIndexSpinBox->setValue( dls->zIndex() );
482 
483  switch ( dls->placement() )
484  {
486  radAroundPoint->setChecked( true );
487  radAroundCentroid->setChecked( true );
488  break;
489 
491  radOverPoint->setChecked( true );
492  radOverCentroid->setChecked( true );
493  break;
494 
496  radAroundLine->setChecked( true );
497  radPolygonPerimeter->setChecked( true );
498  break;
499 
501  radOverLine->setChecked( true );
502  radInsidePolygon->setChecked( true );
503  break;
504 
505  default:
506  break;
507  }
508 
509  chkLineAbove->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::AboveLine );
510  chkLineBelow->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::BelowLine );
511  chkLineOn->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::OnLine );
513  chkLineOrientationDependent->setChecked( true );
515 
516  mShowAllCheckBox->setChecked( dls->showAllDiagrams() );
517 
518  mDataDefinedProperties = dls->dataDefinedProperties();
519  }
520 
521  if ( dr->diagram() )
522  {
523  mDiagramType = dr->diagram()->diagramName();
524 
525  mDiagramTypeComboBox->blockSignals( true );
526  mDiagramTypeComboBox->setCurrentIndex( settingList.at( 0 ).enabled ? mDiagramTypeComboBox->findData( mDiagramType ) : 0 );
527  mDiagramTypeComboBox->blockSignals( false );
528  //force a refresh of widget status to match diagram type
529  mDiagramTypeComboBox_currentIndexChanged( mDiagramTypeComboBox->currentIndex() );
530  if ( mDiagramTypeComboBox->currentIndex() == -1 )
531  {
532  QMessageBox::warning( this, tr( "Diagram Properties" ),
533  tr( "The diagram type '%1' is unknown. A default type is selected for you." ).arg( mDiagramType ), QMessageBox::Ok );
534  mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData( DIAGRAM_NAME_PIE ) );
535  }
536  }
537  }
538  mPaintEffectWidget->setPaintEffect( mPaintEffect.get() );
539 }
540 
542 {
543  QgsSettings settings;
544  settings.setValue( QStringLiteral( "Windows/Diagrams/OptionsSplitState" ), mDiagramOptionsSplitter->saveState() );
545  settings.setValue( QStringLiteral( "Windows/Diagrams/Tab" ), mDiagramOptionsListWidget->currentRow() );
546 }
547 
548 void QgsDiagramProperties::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsDiagramLayerSettings::Property key )
549 {
550  button->init( key, mDataDefinedProperties, QgsDiagramLayerSettings::propertyDefinitions(), mLayer, true );
551  connect( button, &QgsPropertyOverrideButton::changed, this, &QgsDiagramProperties::updateProperty );
552  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsDiagramProperties::createAuxiliaryField );
553  button->registerExpressionContextGenerator( this );
554 }
555 
556 void QgsDiagramProperties::updateProperty()
557 {
558  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
560  mDataDefinedProperties.setProperty( key, button->toProperty() );
561 }
562 
564 {
565  if ( index == 0 )
566  {
567  mDiagramFrame->setEnabled( false );
568  }
569  else
570  {
571  mDiagramFrame->setEnabled( true );
572 
573  mDiagramType = mDiagramTypeComboBox->itemData( index ).toString();
574 
575  if ( DIAGRAM_NAME_TEXT == mDiagramType )
576  {
577  mTextOptionsFrame->show();
578  mBackgroundColorLabel->show();
579  mBackgroundColorButton->show();
580  mBackgroundColorDDBtn->show();
581  mDiagramFontButton->show();
582  }
583  else
584  {
585  mTextOptionsFrame->hide();
586  mBackgroundColorLabel->hide();
587  mBackgroundColorButton->hide();
588  mBackgroundColorDDBtn->hide();
589  mDiagramFontButton->hide();
590  }
591 
592  if ( DIAGRAM_NAME_HISTOGRAM == mDiagramType || DIAGRAM_NAME_STACKED == mDiagramType )
593  {
594  mBarWidthLabel->show();
595  mBarWidthSpinBox->show();
596  mBarSpacingLabel->show();
597  mBarSpacingSpinBox->show();
598  mBarSpacingUnitComboBox->show();
599  mBarOptionsFrame->show();
600  mShowAxisGroupBox->show();
601  if ( DIAGRAM_NAME_HISTOGRAM == mDiagramType )
602  mAttributeBasedScalingRadio->setChecked( true );
603  mFixedSizeRadio->setEnabled( DIAGRAM_NAME_STACKED == mDiagramType );
604  mDiagramSizeSpinBox->setEnabled( DIAGRAM_NAME_STACKED == mDiagramType );
605  mLinearlyScalingLabel->setText( tr( "Bar length: Scale linearly, so that the following value matches the specified bar length:" ) );
606  mSizeLabel->setText( tr( "Bar length" ) );
607  mFrameIncreaseSize->setVisible( false );
608  }
609  else
610  {
611  mBarWidthLabel->hide();
612  mBarWidthSpinBox->hide();
613  mBarSpacingLabel->hide();
614  mBarSpacingSpinBox->hide();
615  mBarSpacingUnitComboBox->hide();
616  mShowAxisGroupBox->hide();
617  mBarOptionsFrame->hide();
618  mLinearlyScalingLabel->setText( tr( "Scale linearly between 0 and the following attribute value / diagram size:" ) );
619  mSizeLabel->setText( tr( "Size" ) );
620  mAttributeBasedScalingRadio->setEnabled( true );
621  mFixedSizeRadio->setEnabled( true );
622  mDiagramSizeSpinBox->setEnabled( mFixedSizeRadio->isChecked() );
623  mFrameIncreaseSize->setVisible( true );
624  }
625 
626  if ( DIAGRAM_NAME_TEXT == mDiagramType || DIAGRAM_NAME_PIE == mDiagramType )
627  {
628  mScaleDependencyComboBox->show();
629  mScaleDependencyLabel->show();
630  }
631  else
632  {
633  mScaleDependencyComboBox->hide();
634  mScaleDependencyLabel->hide();
635  }
636 
637  if ( DIAGRAM_NAME_PIE == mDiagramType )
638  {
639  mAngleOffsetComboBox->show();
640  mAngleDirectionComboBox->show();
641  mAngleDirectionLabel->show();
642  mAngleOffsetLabel->show();
643  mStartAngleDDBtn->show();
644  }
645  else
646  {
647  mAngleOffsetComboBox->hide();
648  mAngleDirectionComboBox->hide();
649  mAngleDirectionLabel->hide();
650  mAngleOffsetLabel->hide();
651  mStartAngleDDBtn->hide();
652  }
653  }
654 }
655 QString QgsDiagramProperties::guessLegendText( const QString &expression )
656 {
657  //trim unwanted characters from expression text for legend
658  QString text = expression.mid( expression.startsWith( '\"' ) ? 1 : 0 );
659  if ( text.endsWith( '\"' ) )
660  text.chop( 1 );
661  return text;
662 }
663 
664 void QgsDiagramProperties::addAttribute( QTreeWidgetItem *item )
665 {
666  QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );
667 
668  newItem->setText( 0, item->text( 0 ) );
669  newItem->setText( 2, guessLegendText( item->text( 0 ) ) );
670  newItem->setData( 0, RoleAttributeExpression, item->data( 0, RoleAttributeExpression ) );
671  newItem->setFlags( ( newItem->flags() | Qt::ItemIsEditable ) & ~Qt::ItemIsDropEnabled );
672 
673  //set initial color for diagram category
674  QRandomGenerator colorGenerator;
675  const int red = colorGenerator.bounded( 1, 256 );
676  const int green = colorGenerator.bounded( 1, 256 );
677  const int blue = colorGenerator.bounded( 1, 256 );
678  const QColor randomColor( red, green, blue );
679  newItem->setData( ColumnColor, Qt::EditRole, randomColor );
680  mDiagramAttributesTreeWidget->addTopLevelItem( newItem );
681 }
682 
684 {
685  const auto constSelectedItems = mAttributesTreeWidget->selectedItems();
686  for ( QTreeWidgetItem *attributeItem : constSelectedItems )
687  {
688  addAttribute( attributeItem );
689  }
690 }
691 
692 void QgsDiagramProperties::mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column )
693 {
694  Q_UNUSED( column )
695  addAttribute( item );
696 }
697 
699 {
700  const auto constSelectedItems = mDiagramAttributesTreeWidget->selectedItems();
701  for ( QTreeWidgetItem *attributeItem : constSelectedItems )
702  {
703  delete attributeItem;
704  }
705 }
706 
708 {
709  if ( !mLayer )
710  return;
711 
712  float maxValue = 0.0;
713 
714  bool isExpression;
715  const QString sizeFieldNameOrExp = mSizeFieldExpressionWidget->currentField( &isExpression );
716  if ( isExpression )
717  {
718  QgsExpression exp( sizeFieldNameOrExp );
719  QgsExpressionContext context;
724 
725  exp.prepare( &context );
726  if ( !exp.hasEvalError() )
727  {
728  QgsFeature feature;
729  QgsFeatureIterator features = mLayer->getFeatures();
730  while ( features.nextFeature( *&feature ) )
731  {
732  context.setFeature( feature );
733  maxValue = std::max( maxValue, exp.evaluate( &context ).toFloat() );
734  }
735  }
736  else
737  {
738  QgsDebugMsgLevel( "Prepare error:" + exp.evalErrorString(), 4 );
739  }
740  }
741  else
742  {
743  const int attributeNumber = mLayer->fields().lookupField( sizeFieldNameOrExp );
744  maxValue = mLayer->maximumValue( attributeNumber ).toFloat();
745  }
746 
747  mMaxValueSpinBox->setValue( maxValue );
748 }
749 
751 {
752  switch ( column )
753  {
754  case ColumnAttributeExpression:
755  {
756  const QString currentExpression = item->data( 0, RoleAttributeExpression ).toString();
757 
758  const QString newExpression = showExpressionBuilder( currentExpression );
759  if ( !newExpression.isEmpty() )
760  {
761  item->setData( 0, Qt::DisplayRole, newExpression );
762  item->setData( 0, RoleAttributeExpression, newExpression );
763  }
764  break;
765  }
766 
767  case ColumnColor:
768  break;
769 
770  case ColumnLegendText:
771  break;
772  }
773 }
774 
776 {
778  if ( panel && panel->dockMode() )
779  {
780  QgsLabelEngineConfigWidget *widget = new QgsLabelEngineConfigWidget( mMapCanvas );
782  panel->openPanel( widget );
783  }
784  else
785  {
786  QgsLabelEngineConfigDialog dialog( mMapCanvas, this );
787  dialog.exec();
788  // reactivate button's window
789  activateWindow();
790  }
791 }
792 
794 {
795  const int index = mDiagramTypeComboBox->currentIndex();
796  const bool diagramsEnabled = ( index != 0 );
797 
798  std::unique_ptr< QgsDiagram > diagram;
799 
800  if ( diagramsEnabled && 0 == mDiagramAttributesTreeWidget->topLevelItemCount() )
801  {
802  QMessageBox::warning( this, tr( "Diagrams: No attributes added." ),
803  tr( "You did not add any attributes to this diagram layer. Please specify the attributes to visualize on the diagrams or disable diagrams." ) );
804  }
805 
806  if ( mDiagramType == DIAGRAM_NAME_TEXT )
807  {
808  diagram = std::make_unique< QgsTextDiagram >();
809  }
810  else if ( mDiagramType == DIAGRAM_NAME_PIE )
811  {
812  diagram = std::make_unique< QgsPieDiagram >();
813  }
814  else if ( mDiagramType == DIAGRAM_NAME_STACKED )
815  {
816  diagram = std::make_unique< QgsStackedBarDiagram >();
817  }
818  else // if ( diagramType == DIAGRAM_NAME_HISTOGRAM )
819  {
820  diagram = std::make_unique< QgsHistogramDiagram >();
821  }
822 
824  ds.enabled = ( mDiagramTypeComboBox->currentIndex() != 0 );
825  ds.font = mDiagramFontButton->currentFont();
826  ds.opacity = mOpacityWidget->opacity();
827 
828  QList<QColor> categoryColors;
829  QList<QString> categoryAttributes;
830  QList<QString> categoryLabels;
831  categoryColors.reserve( mDiagramAttributesTreeWidget->topLevelItemCount() );
832  categoryAttributes.reserve( mDiagramAttributesTreeWidget->topLevelItemCount() );
833  categoryLabels.reserve( mDiagramAttributesTreeWidget->topLevelItemCount() );
834  for ( int i = 0; i < mDiagramAttributesTreeWidget->topLevelItemCount(); ++i )
835  {
836  QColor color = mDiagramAttributesTreeWidget->topLevelItem( i )->data( ColumnColor, Qt::EditRole ).value<QColor>();
837  categoryColors.append( color );
838  categoryAttributes.append( mDiagramAttributesTreeWidget->topLevelItem( i )->data( 0, RoleAttributeExpression ).toString() );
839  categoryLabels.append( mDiagramAttributesTreeWidget->topLevelItem( i )->text( 2 ) );
840  }
841  ds.categoryColors = categoryColors;
842  ds.categoryAttributes = categoryAttributes;
843  ds.categoryLabels = categoryLabels;
844  ds.size = QSizeF( mDiagramSizeSpinBox->value(), mDiagramSizeSpinBox->value() );
845  ds.sizeType = mDiagramUnitComboBox->unit();
846  ds.sizeScale = mDiagramUnitComboBox->getMapUnitScale();
847  ds.lineSizeUnit = mDiagramLineUnitComboBox->unit();
848  ds.lineSizeScale = mDiagramLineUnitComboBox->getMapUnitScale();
849  ds.labelPlacementMethod = static_cast<QgsDiagramSettings::LabelPlacementMethod>( mLabelPlacementComboBox->currentData().toInt() );
850  ds.scaleByArea = ( mDiagramType == DIAGRAM_NAME_STACKED ) ? false : mScaleDependencyComboBox->currentData().toBool();
851 
852  if ( mIncreaseSmallDiagramsCheck->isChecked() )
853  {
854  ds.minimumSize = mIncreaseMinimumSizeSpinBox->value();
855  }
856  else
857  {
858  ds.minimumSize = 0;
859  }
860 
861  ds.backgroundColor = mBackgroundColorButton->color();
862  ds.penColor = mDiagramPenColorButton->color();
863  ds.penWidth = mPenWidthSpinBox->value();
864  ds.minimumScale = mScaleRangeWidget->minimumScale();
865  ds.maximumScale = mScaleRangeWidget->maximumScale();
866  ds.scaleBasedVisibility = mScaleVisibilityGroupBox->isChecked();
867 
868  // Diagram angle offset (pie)
869  ds.rotationOffset = mAngleOffsetComboBox->currentData().toInt();
870  ds.setDirection( static_cast< QgsDiagramSettings::Direction>( mAngleDirectionComboBox->currentData().toInt() ) );
871 
872  // Diagram orientation (histogram)
873  ds.diagramOrientation = static_cast<QgsDiagramSettings::DiagramOrientation>( mOrientationButtonGroup->checkedButton()->property( "direction" ).toInt() );
874 
875  ds.barWidth = mBarWidthSpinBox->value();
876 
877  ds.setAxisLineSymbol( mAxisLineStyleButton->clonedSymbol< QgsLineSymbol >() );
878  ds.setShowAxis( mShowAxisGroupBox->isChecked() );
879 
880  ds.setSpacing( mBarSpacingSpinBox->value() );
881  ds.setSpacingUnit( mBarSpacingUnitComboBox->unit() );
882  ds.setSpacingMapUnitScale( mBarSpacingUnitComboBox->getMapUnitScale() );
883 
884  if ( mPaintEffect && ( !QgsPaintEffectRegistry::isDefaultStack( mPaintEffect.get() ) || mPaintEffect->enabled() ) )
885  ds.setPaintEffect( mPaintEffect->clone() );
886  else
887  ds.setPaintEffect( nullptr );
888 
889  QgsDiagramRenderer *renderer = nullptr;
890  if ( mFixedSizeRadio->isChecked() )
891  {
893  dr->setDiagramSettings( ds );
894  renderer = dr;
895  }
896  else
897  {
899  dr->setLowerValue( 0.0 );
900  dr->setLowerSize( QSizeF( 0.0, 0.0 ) );
901  dr->setUpperValue( mMaxValueSpinBox->value() );
902  dr->setUpperSize( QSizeF( mSizeSpinBox->value(), mSizeSpinBox->value() ) );
903 
904  bool isExpression;
905  const QString sizeFieldNameOrExp = mSizeFieldExpressionWidget->currentField( &isExpression );
906  dr->setClassificationAttributeIsExpression( isExpression );
907  if ( isExpression )
908  {
909  dr->setClassificationAttributeExpression( sizeFieldNameOrExp );
910  }
911  else
912  {
913  dr->setClassificationField( sizeFieldNameOrExp );
914  }
915  dr->setDiagramSettings( ds );
916 
917  dr->setDataDefinedSizeLegend( mSizeLegend ? new QgsDataDefinedSizeLegend( *mSizeLegend ) : nullptr );
918 
919  renderer = dr;
920  }
921  renderer->setDiagram( diagram.release() );
922  renderer->setAttributeLegend( mCheckBoxAttributeLegend->isChecked() );
923  mLayer->setDiagramRenderer( renderer );
924 
926  dls.setDataDefinedProperties( mDataDefinedProperties );
927  dls.setDistance( mDiagramDistanceSpinBox->value() );
928  dls.setPriority( mPrioritySlider->value() );
929  dls.setZIndex( mZIndexSpinBox->value() );
930  dls.setShowAllDiagrams( mShowAllCheckBox->isChecked() );
931 
932  QWidget *curWdgt = stackedPlacement->currentWidget();
933  if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
934  || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
935  {
937  }
938  else if ( ( curWdgt == pagePoint && radOverPoint->isChecked() )
939  || ( curWdgt == pagePolygon && radOverCentroid->isChecked() ) )
940  {
942  }
943  else if ( ( curWdgt == pageLine && radAroundLine->isChecked() )
944  || ( curWdgt == pagePolygon && radPolygonPerimeter->isChecked() ) )
945  {
947  }
948  else if ( ( curWdgt == pageLine && radOverLine->isChecked() )
949  || ( curWdgt == pagePolygon && radInsidePolygon->isChecked() ) )
950  {
952  }
953  else
954  {
955  qFatal( "Invalid settings" );
956  }
957 
958  QgsDiagramLayerSettings::LinePlacementFlags flags = QgsDiagramLayerSettings::LinePlacementFlags();
959  if ( chkLineAbove->isChecked() )
961  if ( chkLineBelow->isChecked() )
963  if ( chkLineOn->isChecked() )
965  if ( ! chkLineOrientationDependent->isChecked() )
967  dls.setLinePlacementFlags( flags );
968 
969  mLayer->setDiagramLayerSettings( dls );
970 
971  // refresh
972  QgsProject::instance()->setDirty( true );
973  mLayer->triggerRepaint();
974 }
975 
976 QString QgsDiagramProperties::showExpressionBuilder( const QString &initialExpression )
977 {
978  QgsExpressionContext context;
984 
985  QgsExpressionBuilderDialog dlg( mLayer, initialExpression, this, QStringLiteral( "generic" ), context );
986  dlg.setWindowTitle( tr( "Expression Based Attribute" ) );
987 
988  QgsDistanceArea myDa;
989  myDa.setSourceCrs( mLayer->crs(), QgsProject::instance()->transformContext() );
990  myDa.setEllipsoid( QgsProject::instance()->ellipsoid() );
991  dlg.setGeomCalculator( myDa );
992 
993  if ( dlg.exec() == QDialog::Accepted )
994  {
995  return dlg.expressionText();
996  }
997  else
998  {
999  return QString();
1000  }
1001 }
1002 
1004 {
1005  QString expression;
1006  QList<QTreeWidgetItem *> selections = mAttributesTreeWidget->selectedItems();
1007  if ( !selections.empty() )
1008  {
1009  expression = selections[0]->text( 0 );
1010  }
1011 
1012  const QString newExpression = showExpressionBuilder( expression );
1013 
1014  //Only add the expression if the user has entered some text.
1015  if ( !newExpression.isEmpty() )
1016  {
1017  QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget );
1018 
1019  newItem->setText( 0, newExpression );
1020  newItem->setText( 2, newExpression );
1021  newItem->setData( 0, RoleAttributeExpression, newExpression );
1022  newItem->setFlags( ( newItem->flags() | Qt::ItemIsEditable ) & ~Qt::ItemIsDropEnabled );
1023 
1024  //set initial color for diagram category
1025  QRandomGenerator colorGenerator;
1026  const int red = colorGenerator.bounded( 1, 256 );
1027  const int green = colorGenerator.bounded( 1, 256 );
1028  const int blue = colorGenerator.bounded( 1, 256 );
1029 
1030  const QColor randomColor( red, green, blue );
1031  newItem->setData( ColumnColor, Qt::EditRole, randomColor );
1032  mDiagramAttributesTreeWidget->addTopLevelItem( newItem );
1033  }
1034  activateWindow(); // set focus back parent
1035 }
1036 
1038 {
1039  mDiagramOptionsListWidget->blockSignals( true );
1040  mDiagramOptionsListWidget->setCurrentRow( index );
1041  mDiagramOptionsListWidget->blockSignals( false );
1042 }
1043 
1045 {
1046  QWidget *curWdgt = stackedPlacement->currentWidget();
1047 
1048  if ( ( curWdgt == pagePoint && radAroundPoint->isChecked() )
1049  || ( curWdgt == pageLine && radAroundLine->isChecked() )
1050  || ( curWdgt == pagePolygon && radAroundCentroid->isChecked() ) )
1051  {
1052  mDiagramDistanceLabel->setEnabled( true );
1053  mDiagramDistanceSpinBox->setEnabled( true );
1054  mDistanceDDBtn->setEnabled( true );
1055  }
1056  else
1057  {
1058  mDiagramDistanceLabel->setEnabled( false );
1059  mDiagramDistanceSpinBox->setEnabled( false );
1060  mDistanceDDBtn->setEnabled( false );
1061  }
1062 
1063  const bool linePlacementEnabled = mLayer->geometryType() == QgsWkbTypes::LineGeometry && ( curWdgt == pageLine && radAroundLine->isChecked() );
1064  chkLineAbove->setEnabled( linePlacementEnabled );
1065  chkLineBelow->setEnabled( linePlacementEnabled );
1066  chkLineOn->setEnabled( linePlacementEnabled );
1067  chkLineOrientationDependent->setEnabled( linePlacementEnabled );
1068 }
1069 
1071 {
1072  mButtonSizeLegendSettings->setEnabled( mAttributeBasedScalingRadio->isChecked() );
1073 }
1074 
1076 {
1077  // prepare size transformer
1078  bool isExpression;
1079  const QString sizeFieldNameOrExp = mSizeFieldExpressionWidget->currentField( &isExpression );
1080  QgsProperty ddSize = isExpression ? QgsProperty::fromExpression( sizeFieldNameOrExp ) : QgsProperty::fromField( sizeFieldNameOrExp );
1081  const bool scaleByArea = mScaleDependencyComboBox->currentData().toBool();
1083  0.0, mMaxValueSpinBox->value(), 0.0, mSizeSpinBox->value() ) );
1084 
1085  QgsDataDefinedSizeLegendWidget *panel = new QgsDataDefinedSizeLegendWidget( mSizeLegend.get(), ddSize, nullptr, mMapCanvas );
1086 
1087  QDialog dlg;
1088  dlg.setLayout( new QVBoxLayout() );
1089  dlg.setWindowTitle( panel->panelTitle() );
1090  dlg.layout()->addWidget( panel );
1091  QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
1092  connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1093  connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDiagramProperties::showHelp );
1094  connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1095  dlg.layout()->addWidget( buttonBox );
1096  if ( dlg.exec() )
1097  mSizeLegend.reset( panel->dataDefinedSizeLegend() );
1098 }
1099 
1100 void QgsDiagramProperties::showHelp()
1101 {
1102  QgsHelp::openHelp( QStringLiteral( "working_with_vector/vector_properties.html#legend" ) );
1103 }
1104 
1105 void QgsDiagramProperties::createAuxiliaryField()
1106 {
1107  // try to create an auxiliary layer if not yet created
1108  if ( !mLayer->auxiliaryLayer() )
1109  {
1110  QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
1111  dlg.exec();
1112  }
1113 
1114  // return if still not exists
1115  if ( !mLayer->auxiliaryLayer() )
1116  return;
1117 
1118  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
1121 
1122  // create property in auxiliary storage if necessary
1123  if ( !mLayer->auxiliaryLayer()->exists( def ) )
1124  mLayer->auxiliaryLayer()->addAuxiliaryField( def );
1125 
1126  // update property with join field name from auxiliary storage
1127  QgsProperty property = button->toProperty();
1128  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
1129  property.setActive( true );
1130  button->updateFieldLists();
1131  button->setToProperty( property );
1132  mDataDefinedProperties.setProperty( key, button->toProperty() );
1133 
1134  emit auxiliaryFieldCreated();
1135 }
QgsDiagramSettings::backgroundColor
QColor backgroundColor
Definition: qgsdiagramrenderer.h:450
QgsProperty::setTransformer
void setTransformer(QgsPropertyTransformer *transformer)
Sets an optional transformer to use for manipulating the calculated values for the property.
Definition: qgsproperty.cpp:865
DIAGRAM_NAME_HISTOGRAM
#define DIAGRAM_NAME_HISTOGRAM
Definition: qgshistogramdiagram.h:19
QgsVectorLayer::setDiagramRenderer
void setDiagramRenderer(QgsDiagramRenderer *r)
Sets diagram rendering object (takes ownership)
Definition: qgsvectorlayer.cpp:712
QgsVectorLayer::getFeatures
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
Definition: qgsvectorlayer.cpp:1052
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:79
QgsDiagramLayerSettings::showAllDiagrams
bool showAllDiagrams() const
Returns whether the layer should show all diagrams, including overlapping diagrams.
Definition: qgsdiagramrenderer.h:267
QgsDiagramProperties::mDiagramAttributesTreeWidget_itemDoubleClicked
void mDiagramAttributesTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
Definition: qgsdiagramproperties.cpp:750
QgsDiagramProperties::updatePlacementWidgets
void updatePlacementWidgets()
Definition: qgsdiagramproperties.cpp:1044
qgsexpressioncontextutils.h
QgsLinearlyInterpolatedDiagramRenderer::upperValue
double upperValue() const
Definition: qgsdiagramrenderer.h:882
QgsDiagramSettings::scaleBasedVisibility
bool scaleBasedVisibility
Definition: qgsdiagramrenderer.h:468
QgsUnitTypes::RenderInches
@ RenderInches
Inches.
Definition: qgsunittypes.h:174
DIAGRAM_NAME_TEXT
#define DIAGRAM_NAME_TEXT
Definition: qgstextdiagram.h:18
QgsProperty::fromField
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
Definition: qgsproperty.cpp:245
QgsLinearlyInterpolatedDiagramRenderer::upperSize
QSizeF upperSize() const
Definition: qgsdiagramrenderer.h:888
QgsDiagramLayerSettings::StartAngle
@ StartAngle
Angle offset for pie diagram.
Definition: qgsdiagramrenderer.h:103
QgsDiagramLayerSettings::BelowLine
@ BelowLine
Definition: qgsdiagramrenderer.h:81
QgsProperty
A store for object properties.
Definition: qgsproperty.h:230
Qgis::SymbolType::Line
@ Line
Line symbol.
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:161
QgsExpressionContextUtils::globalScope
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Definition: qgsexpressioncontextutils.cpp:40
QgsLinearlyInterpolatedDiagramRenderer::classificationAttributeExpression
QString classificationAttributeExpression() const
Definition: qgsdiagramrenderer.h:904
QgsDiagramLayerSettings::priority
int priority() const
Returns the diagram priority.
Definition: qgsdiagramrenderer.h:164
QgsDiagramLayerSettings::OverPoint
@ OverPoint
Definition: qgsdiagramrenderer.h:69
QgsDiagramSettings::setSpacingMapUnitScale
void setSpacingMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the content spacing.
Definition: qgsdiagramrenderer.h:542
QgsExpression::evalErrorString
QString evalErrorString() const
Returns evaluation error.
Definition: qgsexpression.cpp:383
qgsmapcanvas.h
QgsWkbTypes::NullGeometry
@ NullGeometry
Definition: qgswkbtypes.h:146
QgsDiagramLayerSettings::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the diagram's property collection, used for data defined overrides.
Definition: qgsdiagramrenderer.h:309
qgspropertytransformer.h
QgsColorSwatchDelegate
A delegate for showing a color swatch in a list.
Definition: qgscolorschemelist.h:36
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsDiagramSettings::categoryColors
QList< QColor > categoryColors
Definition: qgsdiagramrenderer.h:421
QgsPropertyOverrideButton::changed
void changed()
Emitted when property definition changes.
QgsPanelWidget::findParentPanel
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
Definition: qgspanelwidget.cpp:54
QgsLinearlyInterpolatedDiagramRenderer::classificationField
QString classificationField() const
Returns the field name used for interpolating the diagram size.
Definition: qgsdiagramrenderer.h:895
QgsDiagramSettings::penColor
QColor penColor
Definition: qgsdiagramrenderer.h:451
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:437
QgsLabelEngineConfigWidget
Widget for configuring the labeling engine.
Definition: qgslabelengineconfigdialog.h:37
QgsDiagramSettings::Clockwise
@ Clockwise
Clockwise orientation.
Definition: qgsdiagramrenderer.h:406
QgsDiagramProperties::showAddAttributeExpressionDialog
void showAddAttributeExpressionDialog()
Definition: qgsdiagramproperties.cpp:1003
QgsDiagramSettings::Up
@ Up
Definition: qgsdiagramrenderer.h:394
QgsAuxiliaryLayer::exists
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
Definition: qgsauxiliarystorage.cpp:135
QgsDiagramProperties::mDiagramTypeComboBox_currentIndexChanged
void mDiagramTypeComboBox_currentIndexChanged(int index)
Definition: qgsdiagramproperties.cpp:563
QgsUnitTypes::RenderPoints
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
QgsDiagramSettings::labelPlacementMethod
LabelPlacementMethod labelPlacementMethod
Definition: qgsdiagramrenderer.h:453
QgsDiagramSettings::diagramOrientation
DiagramOrientation diagramOrientation
Definition: qgsdiagramrenderer.h:454
qgsfeatureiterator.h
QgsFields::count
int count() const
Returns number of items.
Definition: qgsfields.cpp:133
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:334
QgsDiagramLayerSettings::setZIndex
void setZIndex(double index)
Sets the diagram z-index.
Definition: qgsdiagramrenderer.h:191
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsDiagramLayerSettings::AboveLine
@ AboveLine
Definition: qgsdiagramrenderer.h:80
QgsDiagramSettings::minimumSize
double minimumSize
Scale diagrams smaller than mMinimumSize to mMinimumSize.
Definition: qgsdiagramrenderer.h:487
QgsPanelWidget::openPanel
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
Definition: qgspanelwidget.cpp:84
QgsDiagram::diagramName
virtual QString diagramName() const =0
Gets a descriptive name for this diagram type.
QgsProject::transformContext
QgsCoordinateTransformContext transformContext
Definition: qgsproject.h:110
QgsDataDefinedSizeLegend
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Definition: qgsdatadefinedsizelegend.h:42
QgsDiagramSettings::XHeight
@ XHeight
Definition: qgsdiagramrenderer.h:388
QgsExpressionContextUtils::mapSettingsScope
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
Definition: qgsexpressioncontextutils.cpp:427
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:480
QgsLabelEngineConfigWidget::apply
void apply()
Applies the changes.
Definition: qgslabelengineconfigdialog.cpp:109
QgsDiagramLayerSettings::setDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the diagram's property collection, used for data defined overrides.
Definition: qgsdiagramrenderer.h:327
QgsVectorLayer::auxiliaryLayer
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
Definition: qgsvectorlayer.cpp:5520
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsPropertyOverrideButton::createAuxiliaryField
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
QgsPropertyOverrideButton::propertyKey
int propertyKey() const
Returns the property key linked to the button.
Definition: qgspropertyoverridebutton.h:123
QgsVectorLayer::setDiagramLayerSettings
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
Definition: qgsvectorlayer.cpp:5213
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:61
qgspainteffectregistry.h
qgsdatadefinedsizelegendwidget.h
QgsDiagramRenderer::setAttributeLegend
void setAttributeLegend(bool enabled)
Sets whether the renderer will show legend items for diagram attributes.
Definition: qgsdiagramrenderer.h:772
QgsDiagramSettings::maximumScale
double maximumScale
The maximum map scale (i.e.
Definition: qgsdiagramrenderer.h:476
QgsProperty::fromExpression
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
Definition: qgsproperty.cpp:237
QgsVectorLayer::diagramRenderer
const QgsDiagramRenderer * diagramRenderer() const
Definition: qgsvectorlayer.h:892
qgspainteffect.h
QgsPaintEffectRegistry::defaultStack
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
Definition: qgspainteffectregistry.cpp:114
QgsDiagramSettings::opacity
double opacity
Opacity, from 0 (transparent) to 1.0 (opaque)
Definition: qgsdiagramrenderer.h:458
QgsDiagramProperties::mEngineSettingsButton_clicked
void mEngineSettingsButton_clicked()
Definition: qgsdiagramproperties.cpp:775
QgsDiagramProperties::addAttribute
void addAttribute(QTreeWidgetItem *item)
Adds an attribute from the list of available attributes to the assigned attributes with a random colo...
Definition: qgsdiagramproperties.cpp:664
QgsDiagramLayerSettings::Show
@ Show
Whether to show the diagram.
Definition: qgsdiagramrenderer.h:101
QgsField::name
QString name
Definition: qgsfield.h:60
QgsDiagramSettings::setPaintEffect
void setPaintEffect(QgsPaintEffect *effect)
Sets the paint effect to use while rendering diagrams.
Definition: qgsdiagramrenderer.cpp:845
QgsDiagramRenderer::rendererName
virtual QString rendererName() const =0
QgsPanelWidget::dockMode
bool dockMode()
Returns the dock mode state.
Definition: qgspanelwidget.h:93
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:144
QgsDiagramSettings::Down
@ Down
Definition: qgsdiagramrenderer.h:395
QgsPropertyOverrideButton::setToProperty
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
Definition: qgspropertyoverridebutton.cpp:270
QgsDiagramSettings::setShowAxis
void setShowAxis(bool showAxis)
Sets whether the diagram axis should be shown.
Definition: qgsdiagramrenderer.cpp:835
QgsDiagramLayerSettings::PositionY
@ PositionY
Y-coordinate data defined diagram position.
Definition: qgsdiagramrenderer.h:96
QgsLinearlyInterpolatedDiagramRenderer::setLowerValue
void setLowerValue(double val)
Definition: qgsdiagramrenderer.h:878
QgsPropertyOverrideButton
A button for controlling property overrides which may apply to a widget.
Definition: qgspropertyoverridebutton.h:50
qgsauxiliarystorage.h
QgsDiagramSettings::scaleByArea
bool scaleByArea
Definition: qgsdiagramrenderer.h:460
qgsapplication.h
qgsnewauxiliarylayerdialog.h
QgsDiagramLayerSettings::ZIndex
@ ZIndex
Z-index for diagram ordering.
Definition: qgsdiagramrenderer.h:99
QgsMapLayer::triggerRepaint
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
Definition: qgsmaplayer.cpp:2114
QgsDiagramSettings::DiagramOrientation
DiagramOrientation
Orientation of histogram.
Definition: qgsdiagramrenderer.h:392
QgsLinearlyInterpolatedDiagramRenderer::setClassificationField
void setClassificationField(const QString &field)
Sets the field name used for interpolating the diagram size.
Definition: qgsdiagramrenderer.h:902
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition: qgsvectorlayer.cpp:3436
QgsDiagramLayerSettings::Line
@ Line
Definition: qgsdiagramrenderer.h:70
QgsDiagramLayerSettings::setShowAllDiagrams
void setShowAllDiagrams(bool showAllDiagrams)
Sets whether the layer should show all diagrams, including overlapping diagrams.
Definition: qgsdiagramrenderer.h:275
QgsDistanceArea::setEllipsoid
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Definition: qgsdistancearea.cpp:89
QgsExpressionContextUtils::projectScope
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
Definition: qgsexpressioncontextutils.cpp:291
QgsLinearlyInterpolatedDiagramRenderer::setDiagramSettings
void setDiagramSettings(const QgsDiagramSettings &s)
Definition: qgsdiagramrenderer.h:870
QgsExpression::hasEvalError
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
Definition: qgsexpression.cpp:378
QgsPaintEffectRegistry::isDefaultStack
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
Definition: qgspainteffectregistry.cpp:134
QgsLinearlyInterpolatedDiagramRenderer::setDataDefinedSizeLegend
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend.
Definition: qgsdiagramrenderer.cpp:1004
QgsLinearlyInterpolatedDiagramRenderer::setUpperSize
void setUpperSize(QSizeF s)
Definition: qgsdiagramrenderer.h:887
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsDiagramLayerSettings::MapOrientation
@ MapOrientation
Definition: qgsdiagramrenderer.h:82
QgsProperty::setField
void setField(const QString &field)
Sets the field name the property references.
Definition: qgsproperty.cpp:349
QgsLinearlyInterpolatedDiagramRenderer::classificationAttributeIsExpression
bool classificationAttributeIsExpression() const
Definition: qgsdiagramrenderer.h:907
QgsDiagramSettings::setDirection
void setDirection(Direction direction)
Sets the chart's angular direction.
Definition: qgsdiagramrenderer.cpp:933
QgsDiagramProperties::apply
void apply()
Definition: qgsdiagramproperties.cpp:793
QgsDiagramProperties::mAttributesTreeWidget_itemDoubleClicked
void mAttributesTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
Definition: qgsdiagramproperties.cpp:692
QgsPropertyOverrideButton::updateFieldLists
void updateFieldLists()
Updates list of fields.
Definition: qgspropertyoverridebutton.cpp:152
QgsDiagramLayerSettings::Distance
@ Distance
Distance to diagram from feature.
Definition: qgsdiagramrenderer.h:97
QgsDiagramSettings::rotationOffset
double rotationOffset
Rotation offset, in degrees clockwise from horizontal.
Definition: qgsdiagramrenderer.h:466
qgshistogramdiagram.h
QgsDiagramSettings::Left
@ Left
Definition: qgsdiagramrenderer.h:396
QgsLinearlyInterpolatedDiagramRenderer::setClassificationAttributeExpression
void setClassificationAttributeExpression(const QString &expression)
Definition: qgsdiagramrenderer.h:905
QgsDiagramProperties::auxiliaryFieldCreated
void auxiliaryFieldCreated()
QgsDiagramSettings::LabelPlacementMethod
LabelPlacementMethod
Definition: qgsdiagramrenderer.h:385
QgsExpressionBuilderDialog
A generic dialog for building expression strings.
Definition: qgsexpressionbuilderdialog.h:30
QgsSizeScaleTransformer
QgsPropertyTransformer subclass for scaling a value into a size according to various scaling methods.
Definition: qgspropertytransformer.h:461
QgsLinearlyInterpolatedDiagramRenderer::dataDefinedSizeLegend
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend.
Definition: qgsdiagramrenderer.cpp:1010
QgsLinearlyInterpolatedDiagramRenderer::setClassificationAttributeIsExpression
void setClassificationAttributeIsExpression(bool isExpression)
Definition: qgsdiagramrenderer.h:908
QgsDiagramProperties::mAddCategoryPushButton_clicked
void mAddCategoryPushButton_clicked()
Definition: qgsdiagramproperties.cpp:683
qgspiediagram.h
qgsvectordataprovider.h
QgsPanelWidget::widgetChanged
void widgetChanged()
Emitted when the widget state changes.
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
qgsstackedbardiagram.h
QgsDiagramLayerSettings
Stores the settings for rendering of all diagrams for a layer.
Definition: qgsdiagramrenderer.h:61
QgsPropertyOverrideButton::toProperty
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
Definition: qgspropertyoverridebutton.cpp:192
QgsPropertyDefinition
Definition for a property.
Definition: qgsproperty.h:46
QgsDiagramRenderer::attributeLegend
bool attributeLegend() const
Returns true if renderer will show legend items for diagram attributes.
Definition: qgsdiagramrenderer.h:764
QgsVectorLayer::maximumValue
QVariant maximumValue(int index) const FINAL
Returns the maximum value for an attribute column or an invalid variant in case of error.
Definition: qgsvectorlayer.cpp:4377
Qgis::UI_SCALE_FACTOR
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:2043
QgsDiagramRenderer
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Definition: qgsdiagramrenderer.h:684
QgsDiagramSettings::Counterclockwise
@ Counterclockwise
Counter-clockwise orientation.
Definition: qgsdiagramrenderer.h:407
QgsDiagramLayerSettings::BackgroundColor
@ BackgroundColor
Diagram background color.
Definition: qgsdiagramrenderer.h:92
QgsProject::setDirty
void setDirty(bool b=true)
Flag the project as dirty (modified).
Definition: qgsproject.cpp:576
QgsDiagramSettings::Right
@ Right
Definition: qgsdiagramrenderer.h:397
qgsmessagebar.h
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:279
QgsMapLayer::hasScaleBasedVisibility
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
Definition: qgsmaplayer.cpp:839
QgsDiagramLayerSettings::OnLine
@ OnLine
Definition: qgsdiagramrenderer.h:79
QgsDiagramProperties::QgsDiagramProperties
QgsDiagramProperties(QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas)
Definition: qgsdiagramproperties.cpp:85
QgsDistanceArea::setSourceCrs
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
Definition: qgsdistancearea.cpp:83
QgsDiagramSettings::Height
@ Height
Definition: qgsdiagramrenderer.h:387
QgsDiagramRenderer::diagramSettings
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
qgsdiagramrenderer.h
QgsExpression::prepare
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
Definition: qgsexpression.cpp:327
QgsMapLayer::minimumScale
double minimumScale() const
Returns the minimum map scale (i.e.
Definition: qgsmaplayer.cpp:904
QgsLinearlyInterpolatedDiagramRenderer::setUpperValue
void setUpperValue(double val)
Definition: qgsdiagramrenderer.h:881
QgsPropertyOverrideButton::init
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout).
Definition: qgspropertyoverridebutton.cpp:96
QgsMapLayer::maximumScale
double maximumScale() const
Returns the maximum map scale (i.e.
Definition: qgsmaplayer.cpp:888
QgsDiagramRenderer::diagram
QgsDiagram * diagram() const
Definition: qgsdiagramrenderer.h:733
QgsExpression::evaluate
QVariant evaluate()
Evaluate the feature and return the result.
Definition: qgsexpression.cpp:350
QgsDiagramLayerSettings::placement
Placement placement() const
Returns the diagram placement.
Definition: qgsdiagramrenderer.h:129
QgsDiagramLayerSettings::zIndex
double zIndex() const
Returns the diagram z-index.
Definition: qgsdiagramrenderer.h:182
DIAGRAM_NAME_PIE
#define DIAGRAM_NAME_PIE
Definition: qgspiediagram.h:18
qgssymbolselectordialog.h
qgsstyle.h
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
QgsLinearlyInterpolatedDiagramRenderer
Definition: qgsdiagramrenderer.h:855
QgsSingleCategoryDiagramRenderer::setDiagramSettings
void setDiagramSettings(const QgsDiagramSettings &s)
Definition: qgsdiagramrenderer.h:833
QgsDiagramProperties::syncToLayer
void syncToLayer()
Updates the widget to reflect the layer's current diagram settings.
Definition: qgsdiagramproperties.cpp:284
qgscolordialog.h
QgsDiagramSettings::minimumScale
double minimumScale
The minimum map scale (i.e.
Definition: qgsdiagramrenderer.h:484
QgsDiagramSettings::lineSizeScale
QgsMapUnitScale lineSizeScale
Line unit scale.
Definition: qgsdiagramrenderer.h:448
QgsDiagramSettings::categoryLabels
QList< QString > categoryLabels
Definition: qgsdiagramrenderer.h:424
QgsDiagramSettings::size
QSizeF size
Definition: qgsdiagramrenderer.h:425
QgsVectorLayer::diagramLayerSettings
const QgsDiagramLayerSettings * diagramLayerSettings() const
Definition: qgsvectorlayer.h:895
QgsSingleCategoryDiagramRenderer
Renders the diagrams for all features with the same settings.
Definition: qgsdiagramrenderer.h:820
QgsFontButton::ModeQFont
@ ModeQFont
Configure font settings for use with QFont objects.
Definition: qgsfontbutton.h:62
QgsDiagramSettings::setSpacingUnit
void setSpacingUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the content spacing.
Definition: qgsdiagramrenderer.h:523
QgsDiagramLayerSettings::linePlacementFlags
LinePlacementFlags linePlacementFlags() const
Returns the diagram placement flags.
Definition: qgsdiagramrenderer.h:145
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:143
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsDiagramLayerSettings::StrokeColor
@ StrokeColor
Stroke color.
Definition: qgsdiagramrenderer.h:93
QgsDiagramProperties::mDiagramStackedWidget_currentChanged
void mDiagramStackedWidget_currentChanged(int index)
Definition: qgsdiagramproperties.cpp:1037
QgsSizeScaleTransformer::Area
@ Area
Area based scaling.
Definition: qgspropertytransformer.h:469
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
QgsSizeScaleTransformer::Linear
@ Linear
Linear scaling.
Definition: qgspropertytransformer.h:468
QgsDiagramSettings::font
QFont font
Definition: qgsdiagramrenderer.h:420
QgsDiagramLayerSettings::Horizontal
@ Horizontal
Definition: qgsdiagramrenderer.h:72
QgsFeatureIterator::nextFeature
bool nextFeature(QgsFeature &f)
Definition: qgsfeatureiterator.h:399
QgsDiagramSettings::sizeScale
QgsMapUnitScale sizeScale
Diagram size unit scale.
Definition: qgsdiagramrenderer.h:436
QgsDiagramLayerSettings::distance
double distance() const
Returns the distance between the diagram and the feature (in mm).
Definition: qgsdiagramrenderer.h:213
QgsHelp::openHelp
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition: qgshelp.cpp:36
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsPropertyOverrideButton::registerExpressionContextGenerator
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
Definition: qgspropertyoverridebutton.cpp:945
QgsDiagramSettings::barWidth
double barWidth
Definition: qgsdiagramrenderer.h:455
QgsDiagramProperties::showSizeLegendDialog
void showSizeLegendDialog()
Definition: qgsdiagramproperties.cpp:1075
QgsDiagramSettings::setSpacing
void setSpacing(double spacing)
Sets the spacing between diagram contents.
Definition: qgsdiagramrenderer.h:513
QgsDiagramLayerSettings::setLinePlacementFlags
void setLinePlacementFlags(LinePlacementFlags flags)
Sets the the diagram placement flags.
Definition: qgsdiagramrenderer.h:154
qgssettings.h
EditBlockerDelegate::EditBlockerDelegate
EditBlockerDelegate(QObject *parent=nullptr)
Definition: qgsdiagramproperties.cpp:62
QgsUnitTypes::RenderMetersInMapUnits
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:176
QgsDiagramSettings::penWidth
double penWidth
Definition: qgsdiagramrenderer.h:452
QgsWkbTypes::UnknownGeometry
@ UnknownGeometry
Definition: qgswkbtypes.h:145
QgsAuxiliaryLayer::nameFromProperty
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
Definition: qgsauxiliarystorage.cpp:440
QgsDiagramLayerSettings::propertyDefinitions
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the diagram property definitions.
Definition: qgsdiagramrenderer.cpp:62
QgsDiagramProperties::mRemoveCategoryPushButton_clicked
void mRemoveCategoryPushButton_clicked()
Definition: qgsdiagramproperties.cpp:698
QgsExpressionContextUtils::atlasScope
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
Definition: qgsexpressioncontextutils.cpp:660
QgsDiagramSettings::Direction
Direction
Angular directions.
Definition: qgsdiagramrenderer.h:404
QgsDiagramLayerSettings::setPriority
void setPriority(int value)
Sets the diagram priority.
Definition: qgsdiagramrenderer.h:172
QgsDiagramSettings::sizeType
QgsUnitTypes::RenderUnit sizeType
Diagram size unit.
Definition: qgsdiagramrenderer.h:430
QgsDistanceArea
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Definition: qgsdistancearea.h:52
QgsDiagramProperties::~QgsDiagramProperties
~QgsDiagramProperties() override
Definition: qgsdiagramproperties.cpp:541
QgsDiagramLayerSettings::setPlacement
void setPlacement(Placement value)
Sets the diagram placement.
Definition: qgsdiagramrenderer.h:137
QgsDiagramRenderer::setDiagram
void setDiagram(QgsDiagram *d)
Definition: qgsdiagramrenderer.cpp:441
QgsSettings::contains
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
Definition: qgssettings.cpp:175
QgsDiagramLayerSettings::setDistance
void setDistance(double distance)
Sets the distance between the diagram and the feature.
Definition: qgsdiagramrenderer.h:221
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsPropertyCollection::setProperty
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
Definition: qgspropertycollection.cpp:187
qgsdatadefinedsizelegend.h
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Definition: qgsapplication.cpp:693
QgsDiagramLayerSettings::AroundPoint
@ AroundPoint
Definition: qgsdiagramrenderer.h:68
qgslabelengineconfigdialog.h
EditBlockerDelegate::createEditor
QWidget * createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override
Definition: qgsdiagramproperties.cpp:66
QgsDiagramLayerSettings::AlwaysShow
@ AlwaysShow
Whether the diagram should always be shown, even if it overlaps other diagrams/labels.
Definition: qgsdiagramrenderer.h:102
QgsDiagramSettings::lineSizeUnit
QgsUnitTypes::RenderUnit lineSizeUnit
Line unit index.
Definition: qgsdiagramrenderer.h:442
qgslogger.h
QgsLabelEngineConfigDialog
Dialog for configuring the labeling engine.
Definition: qgslabelengineconfigdialog.h:70
QgsUnitTypes::RenderUnitList
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:240
QgsDiagramLayerSettings::PositionX
@ PositionX
X-coordinate data defined diagram position.
Definition: qgsdiagramrenderer.h:95
qgsguiutils.h
QgsAuxiliaryLayer::addAuxiliaryField
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
Definition: qgsauxiliarystorage.cpp:140
QgsFields::lookupField
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Definition: qgsfields.cpp:349
QgsFields::at
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Definition: qgsfields.cpp:163
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings")....
Definition: qgsexpression.h:102
qgsdiagramproperties.h
QgsDiagramProperties::scalingTypeChanged
void scalingTypeChanged()
Definition: qgsdiagramproperties.cpp:1070
DIAGRAM_NAME_STACKED
#define DIAGRAM_NAME_STACKED
Definition: qgsstackedbardiagram.h:19
QgsDiagramLayerSettings::Property
Property
Data definable properties.
Definition: qgsdiagramrenderer.h:90
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:289
QgsDiagramSettings::setAxisLineSymbol
void setAxisLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol to use for rendering axis in diagrams.
Definition: qgsdiagramrenderer.cpp:824
QgsVectorLayer::geometryType
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
Definition: qgsvectorlayer.cpp:720
EditBlockerDelegate
Definition: qgsdiagramproperties.cpp:59
QgsDiagramLayerSettings::StrokeWidth
@ StrokeWidth
Stroke width.
Definition: qgsdiagramrenderer.h:94
QgsDiagramSettings::categoryAttributes
QList< QString > categoryAttributes
Definition: qgsdiagramrenderer.h:422
QgsDiagramLayerSettings::IsObstacle
@ IsObstacle
Whether diagram features act as obstacles for other diagrams/labels.
Definition: qgsdiagramrenderer.h:100
QgsDiagramProperties::mFindMaximumValueButton_clicked
void mFindMaximumValueButton_clicked()
Definition: qgsdiagramproperties.cpp:707
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
QgsNewAuxiliaryLayerDialog
A dialog to create a new auxiliary layer.
Definition: qgsnewauxiliarylayerdialog.h:34
QgsDiagramLayerSettings::Priority
@ Priority
Diagram priority (between 0 and 10)
Definition: qgsdiagramrenderer.h:98
QgsDiagramSettings::enabled
bool enabled
Definition: qgsdiagramrenderer.h:419
qgsproject.h
qgsvectorlayerproperties.h
QgsDiagramSettings
Stores the settings for rendering a single diagram.
Definition: qgsdiagramrenderer.h:381
qgstextdiagram.h
qgslinesymbol.h
QgsLinearlyInterpolatedDiagramRenderer::setLowerSize
void setLowerSize(QSizeF s)
Definition: qgsdiagramrenderer.h:884
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:525
qgsexpressionbuilderdialog.h