QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsdiagramrenderer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdiagramrenderer.cpp
3  ---------------------
4  begin : March 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "qgsdiagramrenderer.h"
16 
18 #include "qgsvectorlayer.h"
19 #include "diagram/qgstextdiagram.h"
20 #include "diagram/qgspiediagram.h"
23 #include "qgsrendercontext.h"
25 #include "qgsfontutils.h"
26 #include "qgssymbollayerutils.h"
27 #include "qgspainteffectregistry.h"
28 #include "qgspainteffect.h"
29 #include "qgsapplication.h"
30 #include "qgslinesymbol.h"
31 #include "qgsmarkersymbol.h"
32 
33 #include <QDomElement>
34 #include <QPainter>
35 
36 QgsPropertiesDefinition QgsDiagramLayerSettings::sPropertyDefinitions;
37 
38 void QgsDiagramLayerSettings::initPropertyDefinitions()
39 {
40  if ( !sPropertyDefinitions.isEmpty() )
41  return;
42 
43  const QString origin = QStringLiteral( "diagram" );
44 
45  sPropertyDefinitions = QgsPropertiesDefinition
46  {
47  { QgsDiagramLayerSettings::BackgroundColor, QgsPropertyDefinition( "backgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha, origin ) },
48  { QgsDiagramLayerSettings::StrokeColor, QgsPropertyDefinition( "strokeColor", QObject::tr( "Stroke color" ), QgsPropertyDefinition::ColorWithAlpha, origin ) },
49  { QgsDiagramLayerSettings::StrokeWidth, QgsPropertyDefinition( "strokeWidth", QObject::tr( "Stroke width" ), QgsPropertyDefinition::StrokeWidth, origin ) },
50  { QgsDiagramLayerSettings::PositionX, QgsPropertyDefinition( "positionX", QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double, origin ) },
51  { QgsDiagramLayerSettings::PositionY, QgsPropertyDefinition( "positionY", QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double, origin ) },
52  { QgsDiagramLayerSettings::Distance, QgsPropertyDefinition( "distance", QObject::tr( "Placement distance" ), QgsPropertyDefinition::DoublePositive, origin ) },
53  { QgsDiagramLayerSettings::Priority, QgsPropertyDefinition( "priority", QObject::tr( "Placement priority" ), QgsPropertyDefinition::DoublePositive, origin ) },
54  { QgsDiagramLayerSettings::ZIndex, QgsPropertyDefinition( "zIndex", QObject::tr( "Placement z-index" ), QgsPropertyDefinition::Double, origin ) },
55  { QgsDiagramLayerSettings::IsObstacle, QgsPropertyDefinition( "isObstacle", QObject::tr( "Diagram is an obstacle" ), QgsPropertyDefinition::Boolean, origin ) },
56  { QgsDiagramLayerSettings::Show, QgsPropertyDefinition( "show", QObject::tr( "Show diagram" ), QgsPropertyDefinition::Boolean, origin ) },
57  { QgsDiagramLayerSettings::AlwaysShow, QgsPropertyDefinition( "alwaysShow", QObject::tr( "Always show diagram" ), QgsPropertyDefinition::Boolean, origin ) },
58  { QgsDiagramLayerSettings::StartAngle, QgsPropertyDefinition( "startAngle", QObject::tr( "Pie chart start angle" ), QgsPropertyDefinition::Rotation, origin ) },
59  };
60 }
61 
63 {
64  initPropertyDefinitions();
65  return sPropertyDefinitions;
66 }
67 
69 {
70  initPropertyDefinitions();
71 }
72 
74  : mCt( rh.mCt )
75  , mPlacement( rh.mPlacement )
76  , mPlacementFlags( rh.mPlacementFlags )
77  , mPriority( rh.mPriority )
78  , mZIndex( rh.mZIndex )
79  , mObstacle( rh.mObstacle )
80  , mDistance( rh.mDistance )
81  , mRenderer( rh.mRenderer ? rh.mRenderer->clone() : nullptr )
82  , mShowAll( rh.mShowAll )
83  , mDataDefinedProperties( rh.mDataDefinedProperties )
84 {
85  initPropertyDefinitions();
86 }
87 
89 {
90  mPlacement = rh.mPlacement;
91  mPlacementFlags = rh.mPlacementFlags;
92  mPriority = rh.mPriority;
93  mZIndex = rh.mZIndex;
94  mObstacle = rh.mObstacle;
95  mDistance = rh.mDistance;
96  mRenderer = rh.mRenderer ? rh.mRenderer->clone() : nullptr;
97  mCt = rh.mCt;
98  mShowAll = rh.mShowAll;
99  mDataDefinedProperties = rh.mDataDefinedProperties;
100  return *this;
101 }
102 
104 {
105  delete mRenderer;
106 }
107 
109 {
110  if ( diagramRenderer == mRenderer )
111  return;
112 
113  delete mRenderer;
114  mRenderer = diagramRenderer;
115 }
116 
118 {
119  mCt = transform;
120 }
121 
122 void QgsDiagramLayerSettings::readXml( const QDomElement &elem )
123 {
124  const QDomNodeList propertyElems = elem.elementsByTagName( QStringLiteral( "properties" ) );
125  if ( !propertyElems.isEmpty() )
126  {
127  ( void )mDataDefinedProperties.readXml( propertyElems.at( 0 ).toElement(), sPropertyDefinitions );
128  }
129  else
130  {
131  mDataDefinedProperties.clear();
132  }
133 
134  mPlacement = static_cast< Placement >( elem.attribute( QStringLiteral( "placement" ) ).toInt() );
135  mPlacementFlags = static_cast< LinePlacementFlag >( elem.attribute( QStringLiteral( "linePlacementFlags" ) ).toInt() );
136  mPriority = elem.attribute( QStringLiteral( "priority" ) ).toInt();
137  mZIndex = elem.attribute( QStringLiteral( "zIndex" ) ).toDouble();
138  mObstacle = elem.attribute( QStringLiteral( "obstacle" ) ).toInt();
139  mDistance = elem.attribute( QStringLiteral( "dist" ) ).toDouble();
140  mShowAll = ( elem.attribute( QStringLiteral( "showAll" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
141 }
142 
143 void QgsDiagramLayerSettings::writeXml( QDomElement &layerElem, QDomDocument &doc ) const
144 {
145  QDomElement diagramLayerElem = doc.createElement( QStringLiteral( "DiagramLayerSettings" ) );
146  QDomElement propertiesElem = doc.createElement( QStringLiteral( "properties" ) );
147  ( void )mDataDefinedProperties.writeXml( propertiesElem, sPropertyDefinitions );
148  diagramLayerElem.appendChild( propertiesElem );
149  diagramLayerElem.setAttribute( QStringLiteral( "placement" ), mPlacement );
150  diagramLayerElem.setAttribute( QStringLiteral( "linePlacementFlags" ), mPlacementFlags );
151  diagramLayerElem.setAttribute( QStringLiteral( "priority" ), mPriority );
152  diagramLayerElem.setAttribute( QStringLiteral( "zIndex" ), mZIndex );
153  diagramLayerElem.setAttribute( QStringLiteral( "obstacle" ), mObstacle );
154  diagramLayerElem.setAttribute( QStringLiteral( "dist" ), QString::number( mDistance ) );
155  diagramLayerElem.setAttribute( QStringLiteral( "showAll" ), mShowAll );
156  layerElem.appendChild( diagramLayerElem );
157 }
158 
160 {
161  return mDataDefinedProperties.prepare( context );
162 }
163 
165 {
166  QSet< QString > referenced;
167  if ( mRenderer )
168  referenced = mRenderer->referencedFields( context );
169 
170  //add the ones needed for data defined settings
171  referenced.unite( mDataDefinedProperties.referencedFields( context ) );
172 
173  return referenced;
174 }
175 
176 void QgsDiagramSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
177 {
178  enabled = ( elem.attribute( QStringLiteral( "enabled" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) );
179  if ( !QgsFontUtils::setFromXmlChildNode( font, elem, QStringLiteral( "fontProperties" ) ) )
180  {
181  font.fromString( elem.attribute( QStringLiteral( "font" ) ) );
182  }
183  backgroundColor.setNamedColor( elem.attribute( QStringLiteral( "backgroundColor" ) ) );
184  backgroundColor.setAlpha( elem.attribute( QStringLiteral( "backgroundAlpha" ) ).toInt() );
185  size.setWidth( elem.attribute( QStringLiteral( "width" ) ).toDouble() );
186  size.setHeight( elem.attribute( QStringLiteral( "height" ) ).toDouble() );
187  if ( elem.hasAttribute( QStringLiteral( "transparency" ) ) )
188  {
189  opacity = 1 - elem.attribute( QStringLiteral( "transparency" ), QStringLiteral( "0" ) ).toInt() / 255.0;
190  }
191  else
192  {
193  opacity = elem.attribute( QStringLiteral( "opacity" ), QStringLiteral( "1.00" ) ).toDouble();
194  }
195 
196  penColor.setNamedColor( elem.attribute( QStringLiteral( "penColor" ) ) );
197  const int penAlpha = elem.attribute( QStringLiteral( "penAlpha" ), QStringLiteral( "255" ) ).toInt();
198  penColor.setAlpha( penAlpha );
199  penWidth = elem.attribute( QStringLiteral( "penWidth" ) ).toDouble();
200 
201  mDirection = static_cast< Direction >( elem.attribute( QStringLiteral( "direction" ), QStringLiteral( "1" ) ).toInt() );
202 
203  maximumScale = elem.attribute( QStringLiteral( "minScaleDenominator" ), QStringLiteral( "-1" ) ).toDouble();
204  minimumScale = elem.attribute( QStringLiteral( "maxScaleDenominator" ), QStringLiteral( "-1" ) ).toDouble();
205  if ( elem.hasAttribute( QStringLiteral( "scaleBasedVisibility" ) ) )
206  {
207  scaleBasedVisibility = ( elem.attribute( QStringLiteral( "scaleBasedVisibility" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) );
208  }
209  else
210  {
212  }
213 
214  //diagram size unit type and scale
215  if ( elem.attribute( QStringLiteral( "sizeType" ) ) == QLatin1String( "MapUnits" ) )
216  {
217  //compatibility with pre-2.16 project files
219  }
220  else
221  {
222  sizeType = QgsUnitTypes::decodeRenderUnit( elem.attribute( QStringLiteral( "sizeType" ) ) );
223  }
224  sizeScale = QgsSymbolLayerUtils::decodeMapUnitScale( elem.attribute( QStringLiteral( "sizeScale" ) ) );
225 
226  //line width unit type and scale
227  lineSizeUnit = QgsUnitTypes::decodeRenderUnit( elem.attribute( QStringLiteral( "lineSizeType" ) ) );
228  lineSizeScale = QgsSymbolLayerUtils::decodeMapUnitScale( elem.attribute( QStringLiteral( "lineSizeScale" ) ) );
229 
230  mSpacing = elem.attribute( QStringLiteral( "spacing" ) ).toDouble();
231  mSpacingUnit = QgsUnitTypes::decodeRenderUnit( elem.attribute( QStringLiteral( "spacingUnit" ) ) );
232  mSpacingMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( elem.attribute( QStringLiteral( "spacingUnitScale" ) ) );
233 
234  //label placement method
235  if ( elem.attribute( QStringLiteral( "labelPlacementMethod" ) ) == QLatin1String( "Height" ) )
236  {
238  }
239  else
240  {
242  }
243 
244  // orientation
245  if ( elem.attribute( QStringLiteral( "diagramOrientation" ) ) == QLatin1String( "Left" ) )
246  {
248  }
249  else if ( elem.attribute( QStringLiteral( "diagramOrientation" ) ) == QLatin1String( "Right" ) )
250  {
252  }
253  else if ( elem.attribute( QStringLiteral( "diagramOrientation" ) ) == QLatin1String( "Down" ) )
254  {
256  }
257  else
258  {
260  }
261 
262  // scale dependency
263  if ( elem.attribute( QStringLiteral( "scaleDependency" ) ) == QLatin1String( "Diameter" ) )
264  {
265  scaleByArea = false;
266  }
267  else
268  {
269  scaleByArea = true;
270  }
271 
272  barWidth = elem.attribute( QStringLiteral( "barWidth" ) ).toDouble();
273 
274  if ( elem.hasAttribute( QStringLiteral( "angleOffset" ) ) )
275  rotationOffset = std::fmod( 360.0 - elem.attribute( QStringLiteral( "angleOffset" ) ).toInt() / 16.0, 360.0 );
276  else
277  rotationOffset = elem.attribute( QStringLiteral( "rotationOffset" ) ).toDouble();
278 
279  minimumSize = elem.attribute( QStringLiteral( "minimumSize" ) ).toDouble();
280 
281  const QDomNodeList axisSymbolNodes = elem.elementsByTagName( QStringLiteral( "axisSymbol" ) );
282  if ( axisSymbolNodes.count() > 0 )
283  {
284  const QDomElement axisSymbolElem = axisSymbolNodes.at( 0 ).toElement().firstChildElement();
285  mAxisLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( axisSymbolElem, context ) );
286  }
287  else
288  {
289  mAxisLineSymbol = std::make_unique< QgsLineSymbol >();
290  }
291 
292  mShowAxis = elem.attribute( QStringLiteral( "showAxis" ), QStringLiteral( "0" ) ).toInt();
293 
294  //colors
295  categoryColors.clear();
296  const QDomNodeList attributes = elem.elementsByTagName( QStringLiteral( "attribute" ) );
297 
298 
299  if ( attributes.length() > 0 )
300  {
301  for ( int i = 0; i < attributes.size(); i++ )
302  {
303  const QDomElement attrElem = attributes.at( i ).toElement();
304  QColor newColor( attrElem.attribute( QStringLiteral( "color" ) ) );
305  newColor.setAlphaF( attrElem.attribute( QStringLiteral( "colorOpacity" ), QStringLiteral( "1.0" ) ).toDouble() );
306  categoryColors.append( newColor );
307  categoryAttributes.append( attrElem.attribute( QStringLiteral( "field" ) ) );
308  categoryLabels.append( attrElem.attribute( QStringLiteral( "label" ) ) );
309  if ( categoryLabels.constLast().isEmpty() )
310  {
311  categoryLabels.back() = categoryAttributes.back();
312  }
313  }
314  }
315  else
316  {
317  // Restore old format attributes and colors
318 
319  const QStringList colorList = elem.attribute( QStringLiteral( "colors" ) ).split( '/' );
320  QStringList::const_iterator colorIt = colorList.constBegin();
321  for ( ; colorIt != colorList.constEnd(); ++colorIt )
322  {
323  QColor newColor( *colorIt );
324  categoryColors.append( QColor( newColor ) );
325  }
326 
327  //attribute indices
328  categoryAttributes.clear();
329  const QStringList catList = elem.attribute( QStringLiteral( "categories" ) ).split( '/' );
330  QStringList::const_iterator catIt = catList.constBegin();
331  for ( ; catIt != catList.constEnd(); ++catIt )
332  {
333  categoryAttributes.append( *catIt );
334  categoryLabels.append( *catIt );
335  }
336  }
337 
338  const QDomElement effectElem = elem.firstChildElement( QStringLiteral( "effect" ) );
339  if ( !effectElem.isNull() )
340  setPaintEffect( QgsApplication::paintEffectRegistry()->createEffect( effectElem ) );
341  else
343 }
344 
345 void QgsDiagramSettings::writeXml( QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context ) const
346 {
347  QDomElement categoryElem = doc.createElement( QStringLiteral( "DiagramCategory" ) );
348  categoryElem.setAttribute( QStringLiteral( "enabled" ), enabled );
349  categoryElem.appendChild( QgsFontUtils::toXmlElement( font, doc, QStringLiteral( "fontProperties" ) ) );
350  categoryElem.setAttribute( QStringLiteral( "backgroundColor" ), backgroundColor.name() );
351  categoryElem.setAttribute( QStringLiteral( "backgroundAlpha" ), backgroundColor.alpha() );
352  categoryElem.setAttribute( QStringLiteral( "width" ), QString::number( size.width() ) );
353  categoryElem.setAttribute( QStringLiteral( "height" ), QString::number( size.height() ) );
354  categoryElem.setAttribute( QStringLiteral( "penColor" ), penColor.name() );
355  categoryElem.setAttribute( QStringLiteral( "penAlpha" ), penColor.alpha() );
356  categoryElem.setAttribute( QStringLiteral( "penWidth" ), QString::number( penWidth ) );
357  categoryElem.setAttribute( QStringLiteral( "scaleBasedVisibility" ), scaleBasedVisibility );
358  categoryElem.setAttribute( QStringLiteral( "minScaleDenominator" ), QString::number( maximumScale ) );
359  categoryElem.setAttribute( QStringLiteral( "maxScaleDenominator" ), QString::number( minimumScale ) );
360  categoryElem.setAttribute( QStringLiteral( "opacity" ), QString::number( opacity ) );
361  categoryElem.setAttribute( QStringLiteral( "spacing" ), QString::number( mSpacing ) );
362  categoryElem.setAttribute( QStringLiteral( "spacingUnit" ), QgsUnitTypes::encodeUnit( mSpacingUnit ) );
363  categoryElem.setAttribute( QStringLiteral( "spacingUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( mSpacingMapUnitScale ) );
364  categoryElem.setAttribute( QStringLiteral( "direction" ), QString::number( mDirection ) );
365 
366  //diagram size unit type and scale
367  categoryElem.setAttribute( QStringLiteral( "sizeType" ), QgsUnitTypes::encodeUnit( sizeType ) );
368  categoryElem.setAttribute( QStringLiteral( "sizeScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( sizeScale ) );
369 
370  //line width unit type and scale
371  categoryElem.setAttribute( QStringLiteral( "lineSizeType" ), QgsUnitTypes::encodeUnit( lineSizeUnit ) );
372  categoryElem.setAttribute( QStringLiteral( "lineSizeScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( lineSizeScale ) );
373 
374  // label placement method (text diagram)
375  if ( labelPlacementMethod == Height )
376  {
377  categoryElem.setAttribute( QStringLiteral( "labelPlacementMethod" ), QStringLiteral( "Height" ) );
378  }
379  else
380  {
381  categoryElem.setAttribute( QStringLiteral( "labelPlacementMethod" ), QStringLiteral( "XHeight" ) );
382  }
383 
384  if ( scaleByArea )
385  {
386  categoryElem.setAttribute( QStringLiteral( "scaleDependency" ), QStringLiteral( "Area" ) );
387  }
388  else
389  {
390  categoryElem.setAttribute( QStringLiteral( "scaleDependency" ), QStringLiteral( "Diameter" ) );
391  }
392 
393  // orientation (histogram)
394  switch ( diagramOrientation )
395  {
396  case Left:
397  categoryElem.setAttribute( QStringLiteral( "diagramOrientation" ), QStringLiteral( "Left" ) );
398  break;
399 
400  case Right:
401  categoryElem.setAttribute( QStringLiteral( "diagramOrientation" ), QStringLiteral( "Right" ) );
402  break;
403 
404  case Down:
405  categoryElem.setAttribute( QStringLiteral( "diagramOrientation" ), QStringLiteral( "Down" ) );
406  break;
407 
408  case Up:
409  categoryElem.setAttribute( QStringLiteral( "diagramOrientation" ), QStringLiteral( "Up" ) );
410  break;
411  }
412 
413  categoryElem.setAttribute( QStringLiteral( "barWidth" ), QString::number( barWidth ) );
414  categoryElem.setAttribute( QStringLiteral( "minimumSize" ), QString::number( minimumSize ) );
415  categoryElem.setAttribute( QStringLiteral( "rotationOffset" ), QString::number( rotationOffset ) );
416 
417  const int nCats = std::min( categoryColors.size(), categoryAttributes.size() );
418  for ( int i = 0; i < nCats; ++i )
419  {
420  QDomElement attributeElem = doc.createElement( QStringLiteral( "attribute" ) );
421 
422  attributeElem.setAttribute( QStringLiteral( "field" ), categoryAttributes.at( i ) );
423  attributeElem.setAttribute( QStringLiteral( "color" ), categoryColors.at( i ).name() );
424  attributeElem.setAttribute( QStringLiteral( "colorOpacity" ), QString::number( categoryColors.at( i ).alphaF() ) );
425  attributeElem.setAttribute( QStringLiteral( "label" ), categoryLabels.at( i ) );
426  categoryElem.appendChild( attributeElem );
427  }
428 
429  categoryElem.setAttribute( QStringLiteral( "showAxis" ), mShowAxis ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
430  QDomElement axisSymbolElem = doc.createElement( QStringLiteral( "axisSymbol" ) );
431  const QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QString(), mAxisLineSymbol.get(), doc, context );
432  axisSymbolElem.appendChild( symbolElem );
433  categoryElem.appendChild( axisSymbolElem );
434 
435  if ( mPaintEffect && !QgsPaintEffectRegistry::isDefaultStack( mPaintEffect.get() ) )
436  mPaintEffect->saveProperties( doc, categoryElem );
437 
438  rendererElem.appendChild( categoryElem );
439 }
440 
442 {
443  if ( mDiagram.get() == d )
444  return;
445 
446  mDiagram.reset( d );
447 }
448 
450  : mDiagram( other.mDiagram ? other.mDiagram->clone() : nullptr )
451  , mShowAttributeLegend( other.mShowAttributeLegend )
452 {
453 }
454 
456 {
457  mDiagram.reset( other.mDiagram ? other.mDiagram->clone() : nullptr );
459  return *this;
460 }
461 
462 void QgsDiagramRenderer::renderDiagram( const QgsFeature &feature, QgsRenderContext &c, QPointF pos, const QgsPropertyCollection &properties ) const
463 {
464  if ( !mDiagram )
465  {
466  return;
467  }
468 
470  if ( !diagramSettings( feature, c, s ) )
471  {
472  return;
473  }
474 
475  if ( properties.hasActiveProperties() )
476  {
477  c.expressionContext().setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( s.backgroundColor ) );
479  c.expressionContext().setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( s.penColor ) );
480  s.penColor = properties.valueAsColor( QgsDiagramLayerSettings::StrokeColor, c.expressionContext(), s.penColor );
481  c.expressionContext().setOriginalValueVariable( s.penWidth );
482  s.penWidth = properties.valueAsDouble( QgsDiagramLayerSettings::StrokeWidth, c.expressionContext(), s.penWidth );
483  c.expressionContext().setOriginalValueVariable( s.rotationOffset );
484  s.rotationOffset = properties.valueAsDouble( QgsDiagramLayerSettings::StartAngle, c.expressionContext(), s.rotationOffset );
485  }
486 
487  QgsPaintEffect *effect = s.paintEffect();
488  std::unique_ptr< QgsEffectPainter > effectPainter;
489  if ( effect && effect->enabled() )
490  {
491  effectPainter = std::make_unique< QgsEffectPainter >( c, effect );
492  }
493 
494  mDiagram->renderDiagram( feature, c, s, pos );
495 }
496 
497 QSizeF QgsDiagramRenderer::sizeMapUnits( const QgsFeature &feature, const QgsRenderContext &c ) const
498 {
500  if ( !diagramSettings( feature, c, s ) )
501  {
502  return QSizeF();
503  }
504 
505  QSizeF size = diagramSize( feature, c );
506  if ( size.isValid() )
507  {
508  const double width = c.convertToMapUnits( size.width(), s.sizeType, s.sizeScale );
509  size.rheight() *= width / size.width();
510  size.setWidth( width );
511  }
512  return size;
513 }
514 
515 QSet<QString> QgsDiagramRenderer::referencedFields( const QgsExpressionContext &context ) const
516 {
517  QSet< QString > referenced;
518 
519  if ( !mDiagram )
520  return referenced;
521 
522  const auto constDiagramAttributes = diagramAttributes();
523  for ( const QString &att : constDiagramAttributes )
524  {
525  QgsExpression *expression = mDiagram->getExpression( att, context );
526  const auto constReferencedColumns = expression->referencedColumns();
527  for ( const QString &field : constReferencedColumns )
528  {
529  referenced << field;
530  }
531  }
532  return referenced;
533 }
534 
535 void QgsDiagramRenderer::convertSizeToMapUnits( QSizeF &size, const QgsRenderContext &context ) const
536 {
537  if ( !size.isValid() )
538  {
539  return;
540  }
541 
542  const double pixelToMap = context.scaleFactor() * context.mapToPixel().mapUnitsPerPixel();
543  size.rwidth() *= pixelToMap;
544  size.rheight() *= pixelToMap;
545 }
546 
547 int QgsDiagramRenderer::dpiPaintDevice( const QPainter *painter )
548 {
549  if ( painter )
550  {
551  QPaintDevice *device = painter->device();
552  if ( device )
553  {
554  return device->logicalDpiX();
555  }
556  }
557  return -1;
558 }
559 
560 void QgsDiagramRenderer::_readXml( const QDomElement &elem, const QgsReadWriteContext &context )
561 {
562  Q_UNUSED( context )
563  mDiagram.reset();
564  const QString diagramType = elem.attribute( QStringLiteral( "diagramType" ) );
565  if ( diagramType == QLatin1String( "Pie" ) )
566  {
567  mDiagram.reset( new QgsPieDiagram() );
568  }
569  else if ( diagramType == QLatin1String( "Text" ) )
570  {
571  mDiagram.reset( new QgsTextDiagram() );
572  }
573  else if ( diagramType == QLatin1String( "Histogram" ) )
574  {
575  mDiagram.reset( new QgsHistogramDiagram() );
576  }
577  else if ( diagramType == QLatin1String( "Stacked" ) )
578  {
579  mDiagram.reset( new QgsStackedBarDiagram() );
580  }
581  else
582  {
583  // unknown diagram type -- default to histograms
584  mDiagram.reset( new QgsHistogramDiagram() );
585  }
586  mShowAttributeLegend = ( elem.attribute( QStringLiteral( "attributeLegend" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) );
587 }
588 
589 void QgsDiagramRenderer::_writeXml( QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context ) const
590 {
591  Q_UNUSED( doc )
592  Q_UNUSED( context )
593 
594  if ( mDiagram )
595  {
596  rendererElem.setAttribute( QStringLiteral( "diagramType" ), mDiagram->diagramName() );
597  }
598  rendererElem.setAttribute( QStringLiteral( "attributeLegend" ), mShowAttributeLegend );
599 }
600 
602 {
603  return new QgsSingleCategoryDiagramRenderer( *this );
604 }
605 
607 {
608  Q_UNUSED( c )
609  s = mSettings;
610  return true;
611 }
612 
614 {
615  return mDiagram->diagramSize( feature.attributes(), c, mSettings );
616 }
617 
618 QList<QgsDiagramSettings> QgsSingleCategoryDiagramRenderer::diagramSettings() const
619 {
620  QList<QgsDiagramSettings> settingsList;
621  settingsList.push_back( mSettings );
622  return settingsList;
623 }
624 
625 void QgsSingleCategoryDiagramRenderer::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
626 {
627  const QDomElement categoryElem = elem.firstChildElement( QStringLiteral( "DiagramCategory" ) );
628  if ( categoryElem.isNull() )
629  {
630  return;
631  }
632 
633  mSettings.readXml( categoryElem, context );
634  _readXml( elem, context );
635 }
636 
637 void QgsSingleCategoryDiagramRenderer::writeXml( QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context ) const
638 {
639  QDomElement rendererElem = doc.createElement( QStringLiteral( "SingleCategoryDiagramRenderer" ) );
640  mSettings.writeXml( rendererElem, doc, context );
641  _writeXml( rendererElem, doc, context );
642  layerElem.appendChild( rendererElem );
643 }
644 
645 
647 {
648  mInterpolationSettings.classificationAttributeIsExpression = false;
649 }
650 
652  : QgsDiagramRenderer( other )
653  , mSettings( other.mSettings )
654  , mInterpolationSettings( other.mInterpolationSettings )
655  , mDataDefinedSizeLegend( other.mDataDefinedSizeLegend ? new QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegend ) : nullptr )
656 {
657 }
658 
660 {
661  delete mDataDefinedSizeLegend;
662 }
663 
665 {
666  if ( &other == this )
667  {
668  return *this;
669  }
670  mSettings = other.mSettings;
671  mInterpolationSettings = other.mInterpolationSettings;
672  delete mDataDefinedSizeLegend;
673  mDataDefinedSizeLegend = new QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegend );
674  return *this;
675 }
676 
678 {
679  return new QgsLinearlyInterpolatedDiagramRenderer( *this );
680 }
681 
683 {
684  QList<QgsDiagramSettings> settingsList;
685  settingsList.push_back( mSettings );
686  return settingsList;
687 }
688 
690 {
691  s = mSettings;
692  s.size = diagramSize( feature, c );
693  return true;
694 }
695 
697 {
698  return mSettings.categoryAttributes;
699 }
700 
702 {
703  QSet< QString > referenced = QgsDiagramRenderer::referencedFields( context );
704  if ( mInterpolationSettings.classificationAttributeIsExpression )
705  {
706  QgsExpression *expression = mDiagram->getExpression( mInterpolationSettings.classificationAttributeExpression, context );
707  const auto constReferencedColumns = expression->referencedColumns();
708  for ( const QString &field : constReferencedColumns )
709  {
710  referenced << field;
711  }
712  }
713  else
714  {
715  referenced << mInterpolationSettings.classificationField;
716  }
717  return referenced;
718 }
719 
721 {
722  return mDiagram->diagramSize( feature, c, mSettings, mInterpolationSettings );
723 }
724 
725 void QgsLinearlyInterpolatedDiagramRenderer::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
726 {
727  mInterpolationSettings.lowerValue = elem.attribute( QStringLiteral( "lowerValue" ) ).toDouble();
728  mInterpolationSettings.upperValue = elem.attribute( QStringLiteral( "upperValue" ) ).toDouble();
729  mInterpolationSettings.lowerSize.setWidth( elem.attribute( QStringLiteral( "lowerWidth" ) ).toDouble() );
730  mInterpolationSettings.lowerSize.setHeight( elem.attribute( QStringLiteral( "lowerHeight" ) ).toDouble() );
731  mInterpolationSettings.upperSize.setWidth( elem.attribute( QStringLiteral( "upperWidth" ) ).toDouble() );
732  mInterpolationSettings.upperSize.setHeight( elem.attribute( QStringLiteral( "upperHeight" ) ).toDouble() );
733  mInterpolationSettings.classificationAttributeIsExpression = elem.hasAttribute( QStringLiteral( "classificationAttributeExpression" ) );
734  if ( mInterpolationSettings.classificationAttributeIsExpression )
735  {
736  mInterpolationSettings.classificationAttributeExpression = elem.attribute( QStringLiteral( "classificationAttributeExpression" ) );
737  }
738  else
739  {
740  mInterpolationSettings.classificationField = elem.attribute( QStringLiteral( "classificationField" ) );
741  }
742  const QDomElement settingsElem = elem.firstChildElement( QStringLiteral( "DiagramCategory" ) );
743  if ( !settingsElem.isNull() )
744  {
745  mSettings.readXml( settingsElem );
746  }
747 
748  delete mDataDefinedSizeLegend;
749 
750  const QDomElement ddsLegendSizeElem = elem.firstChildElement( QStringLiteral( "data-defined-size-legend" ) );
751  if ( !ddsLegendSizeElem.isNull() )
752  {
753  mDataDefinedSizeLegend = QgsDataDefinedSizeLegend::readXml( ddsLegendSizeElem, context );
754  }
755  else
756  {
757  // pre-3.0 projects
758  if ( elem.attribute( QStringLiteral( "sizeLegend" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) )
759  {
760  mDataDefinedSizeLegend = new QgsDataDefinedSizeLegend();
761  const QDomElement sizeLegendSymbolElem = elem.firstChildElement( QStringLiteral( "symbol" ) );
762  if ( !sizeLegendSymbolElem.isNull() && sizeLegendSymbolElem.attribute( QStringLiteral( "name" ) ) == QLatin1String( "sizeSymbol" ) )
763  {
764  mDataDefinedSizeLegend->setSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( sizeLegendSymbolElem, context ) );
765  }
766  }
767  else
768  {
769  mDataDefinedSizeLegend = nullptr;
770  }
771  }
772 
773  _readXml( elem, context );
774 }
775 
776 void QgsLinearlyInterpolatedDiagramRenderer::writeXml( QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context ) const
777 {
778  QDomElement rendererElem = doc.createElement( QStringLiteral( "LinearlyInterpolatedDiagramRenderer" ) );
779  rendererElem.setAttribute( QStringLiteral( "lowerValue" ), QString::number( mInterpolationSettings.lowerValue ) );
780  rendererElem.setAttribute( QStringLiteral( "upperValue" ), QString::number( mInterpolationSettings.upperValue ) );
781  rendererElem.setAttribute( QStringLiteral( "lowerWidth" ), QString::number( mInterpolationSettings.lowerSize.width() ) );
782  rendererElem.setAttribute( QStringLiteral( "lowerHeight" ), QString::number( mInterpolationSettings.lowerSize.height() ) );
783  rendererElem.setAttribute( QStringLiteral( "upperWidth" ), QString::number( mInterpolationSettings.upperSize.width() ) );
784  rendererElem.setAttribute( QStringLiteral( "upperHeight" ), QString::number( mInterpolationSettings.upperSize.height() ) );
785  if ( mInterpolationSettings.classificationAttributeIsExpression )
786  {
787  rendererElem.setAttribute( QStringLiteral( "classificationAttributeExpression" ), mInterpolationSettings.classificationAttributeExpression );
788  }
789  else
790  {
791  rendererElem.setAttribute( QStringLiteral( "classificationField" ), mInterpolationSettings.classificationField );
792  }
793  mSettings.writeXml( rendererElem, doc );
794 
795  if ( mDataDefinedSizeLegend )
796  {
797  QDomElement ddsLegendElem = doc.createElement( QStringLiteral( "data-defined-size-legend" ) );
798  mDataDefinedSizeLegend->writeXml( ddsLegendElem, context );
799  rendererElem.appendChild( ddsLegendElem );
800  }
801 
802  _writeXml( rendererElem, doc, context );
803  layerElem.appendChild( rendererElem );
804 }
805 
806 QList< QgsLayerTreeModelLegendNode * > QgsDiagramSettings::legendItems( QgsLayerTreeLayer *nodeLayer ) const
807 {
808  QList< QgsLayerTreeModelLegendNode * > list;
809  list.reserve( categoryLabels.size() );
810  for ( int i = 0; i < categoryLabels.size(); ++i )
811  {
812  QPixmap pix( 16, 16 );
813  pix.fill( categoryColors[i] );
814  list << new QgsSimpleLegendNode( nodeLayer, categoryLabels[i], QIcon( pix ), nullptr, QStringLiteral( "diagram_%1" ).arg( QString::number( i ) ) );
815  }
816  return list;
817 }
818 
820 {
821  return mAxisLineSymbol.get();
822 }
823 
825 {
826  if ( axisLineSymbol != mAxisLineSymbol.get() )
827  mAxisLineSymbol.reset( axisLineSymbol );
828 }
829 
831 {
832  return mShowAxis;
833 }
834 
835 void QgsDiagramSettings::setShowAxis( bool showAxis )
836 {
837  mShowAxis = showAxis;
838 }
839 
841 {
842  return mPaintEffect.get();
843 }
844 
846 {
847  if ( effect != mPaintEffect.get() )
848  mPaintEffect.reset( effect );
849 }
850 
852  : mAxisLineSymbol( std::make_unique< QgsLineSymbol >() )
853 {
854 }
855 
857 
859  : enabled( other.enabled )
860  , font( other.font )
861  , categoryColors( other.categoryColors )
862  , categoryAttributes( other.categoryAttributes )
863  , categoryLabels( other.categoryLabels )
864  , size( other.size )
865  , sizeType( other.sizeType )
866  , sizeScale( other.sizeScale )
867  , lineSizeUnit( other.lineSizeUnit )
868  , lineSizeScale( other.lineSizeScale )
869  , backgroundColor( other.backgroundColor )
870  , penColor( other.penColor )
871  , penWidth( other.penWidth )
872  , labelPlacementMethod( other.labelPlacementMethod )
873  , diagramOrientation( other.diagramOrientation )
874  , barWidth( other.barWidth )
875  , opacity( other.opacity )
876  , scaleByArea( other.scaleByArea )
877  , rotationOffset( other.rotationOffset )
878  , scaleBasedVisibility( other.scaleBasedVisibility )
879  , maximumScale( other.maximumScale )
880  , minimumScale( other.minimumScale )
881  , minimumSize( other.minimumSize )
882  , mSpacing( other.mSpacing )
883  , mSpacingUnit( other.mSpacingUnit )
884  , mSpacingMapUnitScale( other.mSpacingMapUnitScale )
885  , mDirection( other.mDirection )
886  , mShowAxis( other.mShowAxis )
887  , mAxisLineSymbol( other.mAxisLineSymbol ? other.mAxisLineSymbol->clone() : nullptr )
888  , mPaintEffect( other.mPaintEffect ? other.mPaintEffect->clone() : nullptr )
889 {
890 
891 }
892 
894 {
895  enabled = other.enabled;
896  font = other.font;
900  size = other.size;
901  sizeType = other.sizeType;
902  sizeScale = other.sizeScale;
903  lineSizeUnit = other.lineSizeUnit;
906  penColor = other.penColor;
907  penWidth = other.penWidth;
910  barWidth = other.barWidth;
911  opacity = other.opacity;
912  scaleByArea = other.scaleByArea;
915  maximumScale = other.maximumScale;
916  minimumScale = other.minimumScale;
917  minimumSize = other.minimumSize;
918  mSpacing = other.mSpacing;
919  mSpacingUnit = other.mSpacingUnit;
920  mSpacingMapUnitScale = other.mSpacingMapUnitScale;
921  mDirection = other.mDirection;
922  mAxisLineSymbol.reset( other.mAxisLineSymbol ? other.mAxisLineSymbol->clone() : nullptr );
923  mShowAxis = other.mShowAxis;
924  mPaintEffect.reset( other.mPaintEffect ? other.mPaintEffect->clone() : nullptr );
925  return *this;
926 }
927 
929 {
930  return mDirection;
931 }
932 
934 {
935  mDirection = direction;
936 }
937 
938 QList< QgsLayerTreeModelLegendNode * > QgsDiagramRenderer::legendItems( QgsLayerTreeLayer * ) const
939 {
940  return QList< QgsLayerTreeModelLegendNode * >();
941 }
942 
943 QList< QgsLayerTreeModelLegendNode * > QgsSingleCategoryDiagramRenderer::legendItems( QgsLayerTreeLayer *nodeLayer ) const
944 {
945  QList< QgsLayerTreeModelLegendNode * > nodes;
946  if ( mShowAttributeLegend )
947  nodes = mSettings.legendItems( nodeLayer );
948 
949  return nodes;
950 }
951 
952 QList< QgsLayerTreeModelLegendNode * > QgsLinearlyInterpolatedDiagramRenderer::legendItems( QgsLayerTreeLayer *nodeLayer ) const
953 {
954  QList< QgsLayerTreeModelLegendNode * > nodes;
955  if ( mShowAttributeLegend )
956  nodes = mSettings.legendItems( nodeLayer );
957 
958  if ( mDataDefinedSizeLegend && mDiagram )
959  {
960  // add size legend
961  QgsMarkerSymbol *legendSymbol = mDataDefinedSizeLegend->symbol() ? mDataDefinedSizeLegend->symbol()->clone() : QgsMarkerSymbol::createSimple( QVariantMap() );
962  legendSymbol->setSizeUnit( mSettings.sizeType );
963  legendSymbol->setSizeMapUnitScale( mSettings.sizeScale );
964 
965  QgsDataDefinedSizeLegend ddSizeLegend( *mDataDefinedSizeLegend );
966  ddSizeLegend.setSymbol( legendSymbol ); // transfers ownership
967 
968  QList<QgsDataDefinedSizeLegend::SizeClass> sizeClasses;
969  if ( ddSizeLegend.classes().isEmpty() )
970  {
971  // automatic class creation if the classes are not defined manually
972  const auto prettyBreaks { QgsSymbolLayerUtils::prettyBreaks( mInterpolationSettings.lowerValue, mInterpolationSettings.upperValue, 4 ) };
973  for ( const double v : prettyBreaks )
974  {
975  const double size = mDiagram->legendSize( v, mSettings, mInterpolationSettings );
976  sizeClasses << QgsDataDefinedSizeLegend::SizeClass( size, QString::number( v ) );
977  }
978  }
979  else
980  {
981  // manual classes need to get size scaled because the QgsSizeScaleTransformer is not used in diagrams :-(
982  const auto constClasses = ddSizeLegend.classes();
983  for ( const QgsDataDefinedSizeLegend::SizeClass &sc : constClasses )
984  {
985  const double size = mDiagram->legendSize( sc.size, mSettings, mInterpolationSettings );
986  sizeClasses << QgsDataDefinedSizeLegend::SizeClass( size, sc.label );
987  }
988  }
989  ddSizeLegend.setClasses( sizeClasses );
990 
991  const auto constLegendSymbolList = ddSizeLegend.legendSymbolList();
992  for ( const QgsLegendSymbolItem &si : constLegendSymbolList )
993  {
994  if ( auto *lDataDefinedSizeLegendSettings = si.dataDefinedSizeLegendSettings() )
995  nodes << new QgsDataDefinedSizeLegendNode( nodeLayer, *lDataDefinedSizeLegendSettings );
996  else
997  nodes << new QgsSymbolLegendNode( nodeLayer, si );
998  }
999  }
1000 
1001  return nodes;
1002 }
1003 
1005 {
1006  delete mDataDefinedSizeLegend;
1007  mDataDefinedSizeLegend = settings;
1008 }
1009 
1011 {
1012  return mDataDefinedSizeLegend;
1013 }
QgsDiagramSettings::backgroundColor
QColor backgroundColor
Definition: qgsdiagramrenderer.h:450
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsDiagramInterpolationSettings::upperSize
QSizeF upperSize
Definition: qgsdiagramrenderer.h:666
QgsDiagramSettings::scaleBasedVisibility
bool scaleBasedVisibility
Definition: qgsdiagramrenderer.h:468
QgsPropertyCollection::prepare
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const override
Prepares the collection against a specified expression context.
Definition: qgspropertycollection.cpp:240
QgsDiagram
Base class for all diagram types.
Definition: qgsdiagram.h:39
QgsAbstractPropertyCollection::valueAsDouble
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
Definition: qgspropertycollection.cpp:66
QgsLinearlyInterpolatedDiagramRenderer::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads diagram state from a DOM element.
Definition: qgsdiagramrenderer.cpp:725
QgsDiagramLayerSettings::StartAngle
@ StartAngle
Angle offset for pie diagram.
Definition: qgsdiagramrenderer.h:103
QgsSymbolLayerUtils::encodeColor
static QString encodeColor(const QColor &color)
Definition: qgssymbollayerutils.cpp:64
QgsDataDefinedSizeLegend::setSymbol
void setSymbol(QgsMarkerSymbol *symbol SIP_TRANSFER)
Sets marker symbol that will be used to draw markers in legend.
Definition: qgsdatadefinedsizelegend.cpp:68
QgsRenderContext::mapToPixel
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Definition: qgsrendercontext.h:258
QgsLinearlyInterpolatedDiagramRenderer::clone
QgsLinearlyInterpolatedDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
Definition: qgsdiagramrenderer.cpp:677
QgsDiagramRenderer::mDiagram
std::unique_ptr< QgsDiagram > mDiagram
Reference to the object that does the real diagram rendering.
Definition: qgsdiagramrenderer.h:810
qgslayertreemodellegendnode.h
QgsMapToPixel::mapUnitsPerPixel
double mapUnitsPerPixel() const
Returns the current map units per pixel.
Definition: qgsmaptopixel.h:229
QgsSingleCategoryDiagramRenderer::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads diagram state from a DOM element.
Definition: qgsdiagramrenderer.cpp:625
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsExpression::referencedColumns
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
Definition: qgsexpression.cpp:221
QgsDiagramRenderer::_readXml
void _readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads internal QgsDiagramRenderer state from a DOM element.
Definition: qgsdiagramrenderer.cpp:560
QgsSymbolLayerUtils::encodeMapUnitScale
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Definition: qgssymbollayerutils.cpp:666
QgsDiagramInterpolationSettings::lowerValue
double lowerValue
Definition: qgsdiagramrenderer.h:667
QgsDiagramSettings::categoryColors
QList< QColor > categoryColors
Definition: qgsdiagramrenderer.h:421
QgsLinearlyInterpolatedDiagramRenderer::diagramSettings
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
Definition: qgsdiagramrenderer.cpp:682
QgsDiagramSettings::penColor
QColor penColor
Definition: qgsdiagramrenderer.h:451
QgsDiagramRenderer::mShowAttributeLegend
bool mShowAttributeLegend
Whether to show an attribute legend for the diagrams.
Definition: qgsdiagramrenderer.h:813
QgsLinearlyInterpolatedDiagramRenderer::writeXml
void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Writes diagram state to a DOM element.
Definition: qgsdiagramrenderer.cpp:776
QgsDiagramSettings::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads diagram settings from XML.
Definition: qgsdiagramrenderer.cpp:176
QgsSimpleLegendNode
Implementation of legend node interface for displaying arbitrary label with icon.
Definition: qgslayertreemodellegendnode.h:544
QgsDiagramSettings::QgsDiagramSettings
QgsDiagramSettings()
Constructor for QgsDiagramSettings.
Definition: qgsdiagramrenderer.cpp:851
QgsSingleCategoryDiagramRenderer::diagramSize
QSizeF diagramSize(const QgsFeature &, const QgsRenderContext &c) const override
Returns size of the diagram (in painter units) or an invalid size in case of error.
Definition: qgsdiagramrenderer.cpp:613
QgsSingleCategoryDiagramRenderer::QgsSingleCategoryDiagramRenderer
QgsSingleCategoryDiagramRenderer()=default
Constructor for QgsSingleCategoryDiagramRenderer.
QgsDiagramRenderer::_writeXml
void _writeXml(QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes internal QgsDiagramRenderer diagram state to a DOM element.
Definition: qgsdiagramrenderer.cpp:589
QgsDiagramSettings::Up
@ Up
Definition: qgsdiagramrenderer.h:394
QgsDiagramSettings::labelPlacementMethod
LabelPlacementMethod labelPlacementMethod
Definition: qgsdiagramrenderer.h:453
QgsSingleCategoryDiagramRenderer::writeXml
void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const override
Writes diagram state to a DOM element.
Definition: qgsdiagramrenderer.cpp:637
qgssymbollayerutils.h
QgsAbstractPropertyCollection::readXml
virtual bool readXml(const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
Reads property collection state from an XML element.
Definition: qgspropertycollection.cpp:108
QgsDiagramSettings::diagramOrientation
DiagramOrientation diagramOrientation
Definition: qgsdiagramrenderer.h:454
QgsDiagramRenderer::referencedFields
virtual QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
Returns the set of any fields required for diagram rendering.
Definition: qgsdiagramrenderer.cpp:515
QgsDiagramSettings::minimumSize
double minimumSize
Scale diagrams smaller than mMinimumSize to mMinimumSize.
Definition: qgsdiagramrenderer.h:487
QgsMarkerSymbol::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale) const
Sets the size map unit scale for the whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:279
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
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsPropertyDefinition::Double
@ Double
Double value (including negative values)
Definition: qgsproperty.h:57
QgsDiagramLayerSettings::Placement
Placement
Definition: qgsdiagramrenderer.h:66
qgspainteffectregistry.h
QgsDiagramSettings::maximumScale
double maximumScale
The maximum map scale (i.e.
Definition: qgsdiagramrenderer.h:476
field
const QgsField & field
Definition: qgsfield.h:463
QgsDiagramRenderer::sizeMapUnits
virtual QSizeF sizeMapUnits(const QgsFeature &feature, const QgsRenderContext &c) const
Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error.
Definition: qgsdiagramrenderer.cpp:497
qgsfontutils.h
qgspainteffect.h
QgsDataDefinedSizeLegendNode
Produces legend node with a marker symbol.
Definition: qgslayertreemodellegendnode.h:707
QgsRenderContext::scaleFactor
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
Definition: qgsrendercontext.h:266
QgsDataDefinedSizeLegend::setClasses
void setClasses(const QList< QgsDataDefinedSizeLegend::SizeClass > &classes)
Sets list of classes: each class is a pair of symbol size (in units used by the symbol) and label.
Definition: qgsdatadefinedsizelegend.h:116
QgsDiagramInterpolationSettings::classificationField
QString classificationField
Name of the field for classification.
Definition: qgsdiagramrenderer.h:671
QgsSingleCategoryDiagramRenderer::clone
QgsSingleCategoryDiagramRenderer * clone() const override
Returns new instance that is equivalent to this one.
Definition: qgsdiagramrenderer.cpp:601
QgsPropertyCollection::clear
void clear() override
Removes all properties from the collection.
Definition: qgspropertycollection.cpp:178
QgsPaintEffectRegistry::defaultStack
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
Definition: qgspainteffectregistry.cpp:114
QgsDiagramLayerSettings::~QgsDiagramLayerSettings
~QgsDiagramLayerSettings()
Definition: qgsdiagramrenderer.cpp:103
QgsDiagramSettings::opacity
double opacity
Opacity, from 0 (transparent) to 1.0 (opaque)
Definition: qgsdiagramrenderer.h:458
QgsDiagramLayerSettings::Show
@ Show
Whether to show the diagram.
Definition: qgsdiagramrenderer.h:101
QgsDiagramRenderer::convertSizeToMapUnits
void convertSizeToMapUnits(QSizeF &size, const QgsRenderContext &context) const
Converts size from mm to map units.
Definition: qgsdiagramrenderer.cpp:535
QgsDiagramSettings::setPaintEffect
void setPaintEffect(QgsPaintEffect *effect)
Sets the paint effect to use while rendering diagrams.
Definition: qgsdiagramrenderer.cpp:845
QgsDiagramLayerSettings::referencedFields
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
Returns the set of any fields referenced by the layer's diagrams.
Definition: qgsdiagramrenderer.cpp:164
QgsDiagramSettings::Down
@ Down
Definition: qgsdiagramrenderer.h:395
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
QgsMarkerSymbol::clone
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
Definition: qgsmarkersymbol.cpp:523
QgsDiagramInterpolationSettings::upperValue
double upperValue
Definition: qgsdiagramrenderer.h:668
QgsDiagramLayerSettings::QgsDiagramLayerSettings
QgsDiagramLayerSettings()
Constructor for QgsDiagramLayerSettings.
Definition: qgsdiagramrenderer.cpp:68
QgsDiagramSettings::scaleByArea
bool scaleByArea
Definition: qgsdiagramrenderer.h:460
qgsapplication.h
QgsUnitTypes::decodeRenderUnit
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
Definition: qgsunittypes.cpp:2948
QgsPropertyDefinition::Rotation
@ Rotation
Rotation (value between 0-360 degrees)
Definition: qgsproperty.h:60
QgsDiagramLayerSettings::writeXml
void writeXml(QDomElement &layerElem, QDomDocument &doc) const
Writes the diagram settings to a DOM element.
Definition: qgsdiagramrenderer.cpp:143
QgsLinearlyInterpolatedDiagramRenderer::QgsLinearlyInterpolatedDiagramRenderer
QgsLinearlyInterpolatedDiagramRenderer()
Definition: qgsdiagramrenderer.cpp:646
QgsDataDefinedSizeLegend::SizeClass
Definition of one class for the legend.
Definition: qgsdatadefinedsizelegend.h:72
QgsDiagramLayerSettings::ZIndex
@ ZIndex
Z-index for diagram ordering.
Definition: qgsdiagramrenderer.h:99
QgsHistogramDiagram
A histogram style diagram.
Definition: qgshistogramdiagram.h:40
QgsLegendSymbolItem
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Definition: qgslegendsymbolitem.h:36
QgsTextDiagram
A text based diagram.
Definition: qgstextdiagram.h:38
QgsPropertiesDefinition
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Definition: qgspropertycollection.h:29
QgsDataDefinedSizeLegend::legendSymbolList
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
Definition: qgsdatadefinedsizelegend.cpp:122
QgsDiagramRenderer::diagramAttributes
virtual QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
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
QgsPieDiagram
A pie chart diagram.
Definition: qgspiediagram.h:38
QgsUnitTypes::encodeUnit
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
Definition: qgsunittypes.cpp:122
QgsDiagramLayerSettings::readXml
void readXml(const QDomElement &elem)
Reads the diagram settings from a DOM element.
Definition: qgsdiagramrenderer.cpp:122
QgsDiagramSettings::writeXml
void writeXml(QDomElement &rendererElem, QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes diagram settings to XML.
Definition: qgsdiagramrenderer.cpp:345
QgsDiagramInterpolationSettings::lowerSize
QSizeF lowerSize
Definition: qgsdiagramrenderer.h:665
QgsMarkerSymbol::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit) const
Sets the size units for the whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:241
QgsDiagramRenderer::renderDiagram
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, QPointF pos, const QgsPropertyCollection &properties=QgsPropertyCollection()) const
Renders the diagram for a specified feature at a specific position in the passed render context.
Definition: qgsdiagramrenderer.cpp:462
QgsDiagramLayerSettings::prepare
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const
Prepares the diagrams for a specified expression context.
Definition: qgsdiagramrenderer.cpp:159
QgsLinearlyInterpolatedDiagramRenderer::referencedFields
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const override
Returns the set of any fields required for diagram rendering.
Definition: qgsdiagramrenderer.cpp:701
QgsDiagramSettings::setDirection
void setDirection(Direction direction)
Sets the chart's angular direction.
Definition: qgsdiagramrenderer.cpp:933
QgsDiagramRenderer::legendItems
virtual QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
Definition: qgsdiagramrenderer.cpp:938
QgsPropertyCollection::hasActiveProperties
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
Definition: qgspropertycollection.cpp:304
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
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
QgsPropertyDefinition::ColorWithAlpha
@ ColorWithAlpha
Color with alpha channel.
Definition: qgsproperty.h:64
qgshistogramdiagram.h
QgsDiagramSettings::Left
@ Left
Definition: qgsdiagramrenderer.h:396
QgsLinearlyInterpolatedDiagramRenderer::~QgsLinearlyInterpolatedDiagramRenderer
~QgsLinearlyInterpolatedDiagramRenderer() override
Definition: qgsdiagramrenderer.cpp:659
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:43
QgsLinearlyInterpolatedDiagramRenderer::operator=
QgsLinearlyInterpolatedDiagramRenderer & operator=(const QgsLinearlyInterpolatedDiagramRenderer &other)
Definition: qgsdiagramrenderer.cpp:664
QgsDiagramRenderer::dpiPaintDevice
static int dpiPaintDevice(const QPainter *)
Returns the paint device dpi (or -1 in case of error.
Definition: qgsdiagramrenderer.cpp:547
QgsLinearlyInterpolatedDiagramRenderer::dataDefinedSizeLegend
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend.
Definition: qgsdiagramrenderer.cpp:1010
QgsSingleCategoryDiagramRenderer::diagramSettings
QList< QgsDiagramSettings > diagramSettings() const override
Returns list with all diagram settings in the renderer.
Definition: qgsdiagramrenderer.cpp:618
qgspiediagram.h
qgsrendercontext.h
QgsDiagramSettings::operator=
QgsDiagramSettings & operator=(const QgsDiagramSettings &other)
Definition: qgsdiagramrenderer.cpp:893
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
QgsDiagramRenderer::clone
virtual QgsDiagramRenderer * clone() const =0
Returns new instance that is equivalent to this one.
QgsSymbolLayerUtils::prettyBreaks
static QList< double > prettyBreaks(double minimum, double maximum, int classes)
Computes a sequence of about 'classes' equally spaced round values which cover the range of values fr...
Definition: qgssymbollayerutils.cpp:4580
QgsPropertyDefinition
Definition for a property.
Definition: qgsproperty.h:46
QgsDiagramRenderer
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Definition: qgsdiagramrenderer.h:684
QgsDiagramLayerSettings::BackgroundColor
@ BackgroundColor
Diagram background color.
Definition: qgsdiagramrenderer.h:92
QgsDiagramSettings::direction
Direction direction() const
Returns the chart's angular direction.
Definition: qgsdiagramrenderer.cpp:928
QgsDiagramSettings::Right
@ Right
Definition: qgsdiagramrenderer.h:397
QgsDiagramSettings::Height
@ Height
Definition: qgsdiagramrenderer.h:387
QgsPropertyCollection::referencedFields
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const override
Returns the set of any fields referenced by the active properties from the collection.
Definition: qgspropertycollection.cpp:254
QgsDiagramRenderer::diagramSettings
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
qgsdiagramrenderer.h
QgsFeature::attributes
QgsAttributes attributes
Definition: qgsfeature.h:69
QgsDiagramInterpolationSettings::classificationAttributeIsExpression
bool classificationAttributeIsExpression
Definition: qgsdiagramrenderer.h:674
QgsLinearlyInterpolatedDiagramRenderer
Definition: qgsdiagramrenderer.h:855
qgsvectorlayer.h
QgsDiagramSettings::~QgsDiagramSettings
~QgsDiagramSettings()
QgsDiagramRenderer::QgsDiagramRenderer
QgsDiagramRenderer()=default
Constructor for QgsDiagramRenderer.
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
QgsDiagramLayerSettings::setRenderer
void setRenderer(QgsDiagramRenderer *diagramRenderer)
Sets the diagram renderer associated with the layer.
Definition: qgsdiagramrenderer.cpp:108
QgsDiagramSettings::size
QSizeF size
Definition: qgsdiagramrenderer.h:425
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
QgsSingleCategoryDiagramRenderer
Renders the diagrams for all features with the same settings.
Definition: qgsdiagramrenderer.h:820
QgsFontUtils::setFromXmlChildNode
static bool setFromXmlChildNode(QFont &font, const QDomElement &element, const QString &childNode)
Sets the properties of a font to match the properties stored in an XML child node.
Definition: qgsfontutils.cpp:400
QgsSingleCategoryDiagramRenderer::legendItems
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
Definition: qgsdiagramrenderer.cpp:943
QgsDiagramLayerSettings::StrokeColor
@ StrokeColor
Stroke color.
Definition: qgsdiagramrenderer.h:93
QgsFontUtils::toXmlElement
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
Definition: qgsfontutils.cpp:354
QgsDiagramLayerSettings::LinePlacementFlag
LinePlacementFlag
Line placement flags for controlling line based placements.
Definition: qgsdiagramrenderer.h:77
QgsApplication::paintEffectRegistry
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
Definition: qgsapplication.cpp:2315
QgsDiagramSettings::font
QFont font
Definition: qgsdiagramrenderer.h:420
QgsPropertyDefinition::Boolean
@ Boolean
Boolean value.
Definition: qgsproperty.h:53
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsDiagramSettings::sizeScale
QgsMapUnitScale sizeScale
Diagram size unit scale.
Definition: qgsdiagramrenderer.h:436
QgsLinearlyInterpolatedDiagramRenderer::diagramAttributes
QList< QString > diagramAttributes() const override
Returns attribute indices needed for diagram rendering.
Definition: qgsdiagramrenderer.cpp:696
QgsLinearlyInterpolatedDiagramRenderer::diagramSize
QSizeF diagramSize(const QgsFeature &, const QgsRenderContext &c) const override
Returns size of the diagram (in painter units) or an invalid size in case of error.
Definition: qgsdiagramrenderer.cpp:720
QgsDiagramSettings::barWidth
double barWidth
Definition: qgsdiagramrenderer.h:455
qgsmarkersymbol.h
QgsDiagramSettings::showAxis
bool showAxis() const
Returns true if the diagram axis should be shown.
Definition: qgsdiagramrenderer.cpp:830
QgsStackedBarDiagram
A stacked bar chart diagram.
Definition: qgsstackedbardiagram.h:43
QgsLinearlyInterpolatedDiagramRenderer::legendItems
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const override
Returns list of legend nodes for the diagram.
Definition: qgsdiagramrenderer.cpp:952
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:52
QgsDiagramSettings::paintEffect
QgsPaintEffect * paintEffect() const
Returns the paint effect to use while rendering diagrams.
Definition: qgsdiagramrenderer.cpp:840
QgsDiagramSettings::axisLineSymbol
QgsLineSymbol * axisLineSymbol() const
Returns the line symbol to use for rendering axis in diagrams.
Definition: qgsdiagramrenderer.cpp:819
QgsDiagramSettings::penWidth
double penWidth
Definition: qgsdiagramrenderer.h:452
QgsDataDefinedSizeLegend::symbol
QgsMarkerSymbol * symbol() const
Returns marker symbol that will be used to draw markers in legend.
Definition: qgsdatadefinedsizelegend.cpp:73
QgsDiagramLayerSettings::propertyDefinitions
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the diagram property definitions.
Definition: qgsdiagramrenderer.cpp:62
QgsDataDefinedSizeLegend::writeXml
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes configuration to the given XML element.
Definition: qgsdatadefinedsizelegend.cpp:423
QgsDiagramLayerSettings::operator=
QgsDiagramLayerSettings & operator=(const QgsDiagramLayerSettings &rh)
Definition: qgsdiagramrenderer.cpp:88
QgsDiagramSettings::Direction
Direction
Angular directions.
Definition: qgsdiagramrenderer.h:404
QgsDataDefinedSizeLegend::classes
QList< QgsDataDefinedSizeLegend::SizeClass > classes() const
Returns list of classes: each class is a pair of symbol size (in units used by the symbol) and label.
Definition: qgsdatadefinedsizelegend.h:118
QgsDiagramSettings::sizeType
QgsUnitTypes::RenderUnit sizeType
Diagram size unit.
Definition: qgsdiagramrenderer.h:430
QgsDiagramRenderer::setDiagram
void setDiagram(QgsDiagram *d)
Definition: qgsdiagramrenderer.cpp:441
QgsDataDefinedSizeLegend::readXml
static QgsDataDefinedSizeLegend * readXml(const QDomElement &elem, const QgsReadWriteContext &context) SIP_FACTORY
Creates instance from given element and returns it (caller takes ownership). Returns nullptr on error...
Definition: qgsdatadefinedsizelegend.cpp:364
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
qgsdatadefinedsizelegend.h
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
QgsDiagramLayerSettings::PositionX
@ PositionX
X-coordinate data defined diagram position.
Definition: qgsdiagramrenderer.h:95
QgsPaintEffect::enabled
bool enabled() const
Returns whether the effect is enabled.
Definition: qgspainteffect.h:197
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings")....
Definition: qgsexpression.h:102
QgsDiagramSettings::legendItems
QList< QgsLayerTreeModelLegendNode * > legendItems(QgsLayerTreeLayer *nodeLayer) const
Returns list of legend nodes for the diagram.
Definition: qgsdiagramrenderer.cpp:806
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsSymbolLegendNode
Implementation of legend node interface for displaying preview of vector symbols and their labels and...
Definition: qgslayertreemodellegendnode.h:358
QgsDiagramSettings::setAxisLineSymbol
void setAxisLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol to use for rendering axis in diagrams.
Definition: qgsdiagramrenderer.cpp:824
QgsMarkerSymbol::createSimple
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
Definition: qgsmarkersymbol.cpp:22
QgsDiagramLayerSettings::StrokeWidth
@ StrokeWidth
Stroke width.
Definition: qgsdiagramrenderer.h:94
QgsDiagramRenderer::diagramSize
virtual QSizeF diagramSize(const QgsFeature &features, const QgsRenderContext &c) const =0
Returns size of the diagram (in painter units) or an invalid size in case of error.
QgsPropertyDefinition::StrokeWidth
@ StrokeWidth
Line stroke width.
Definition: qgsproperty.h:72
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
QgsSymbolLayerUtils::saveSymbol
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
Definition: qgssymbollayerutils.cpp:1397
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
QgsDiagramLayerSettings::Priority
@ Priority
Diagram priority (between 0 and 10)
Definition: qgsdiagramrenderer.h:98
QgsDiagramSettings::enabled
bool enabled
Definition: qgsdiagramrenderer.h:419
QgsSymbolLayerUtils::decodeMapUnitScale
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
Definition: qgssymbollayerutils.cpp:676
QgsDiagramRenderer::operator=
QgsDiagramRenderer & operator=(const QgsDiagramRenderer &other)
Definition: qgsdiagramrenderer.cpp:455
QgsDiagramInterpolationSettings::classificationAttributeExpression
QString classificationAttributeExpression
Definition: qgsdiagramrenderer.h:673
QgsDiagramLayerSettings::setCoordinateTransform
void setCoordinateTransform(const QgsCoordinateTransform &transform)
Sets the coordinate transform associated with the layer.
Definition: qgsdiagramrenderer.cpp:117
QgsAbstractPropertyCollection::writeXml
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.
Definition: qgspropertycollection.cpp:99
QgsAbstractPropertyCollection::valueAsColor
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color.
Definition: qgspropertycollection.cpp:54
QgsDiagramSettings
Stores the settings for rendering a single diagram.
Definition: qgsdiagramrenderer.h:381
qgstextdiagram.h
qgslinesymbol.h
QgsPropertyDefinition::DoublePositive
@ DoublePositive
Positive double value (including 0)
Definition: qgsproperty.h:58