27 mCategoryBrush.setStyle( Qt::SolidPattern );
28 mPen.setStyle( Qt::SolidLine );
49 attrVal = expression->
evaluate( &expressionContext );
57 const double value = attrVal.toDouble( &ok );
69 return std::max( size.width(), size.height() );
80 Q_UNUSED( attributes )
86 QPainter *p =
c.painter();
94 double currentVal = 0;
107 currentVal = expression->
evaluate( &expressionContext ).toDouble();
108 values.push_back( currentVal );
109 valSum += currentVal;
110 if ( currentVal ) valCount++;
114 double totalAngle = 0;
119 const double w = spu.width();
120 const double h = spu.height();
122 const double baseX = position.x();
123 const double baseY = position.y() - h;
132 QList<double>::const_iterator valIt = values.constBegin();
133 QList< QColor >::const_iterator colIt = s.
categoryColors.constBegin();
134 for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
139 QColor brushColor( *colIt );
140 brushColor.setAlphaF( brushColor.alphaF() * s.
opacity );
141 mCategoryBrush.setColor( brushColor );
142 p->setBrush( mCategoryBrush );
146 p->drawEllipse( QRectF( baseX, baseY, w, h ) );
150 p->drawPie( QRectF( baseX, baseY, w, h ), totalAngle - s.
rotationOffset * 16.0, currentAngle );
152 totalAngle += currentAngle;
159 mCategoryBrush.setColor( Qt::transparent );
160 p->setBrush( mCategoryBrush );
161 p->drawEllipse( QRectF( baseX, baseY, w, h ) );
Additional diagram settings for interpolated size rendering.
bool classificationAttributeIsExpression
QString classificationField
Name of the field for classification.
QString classificationAttributeExpression
Stores the settings for rendering a single diagram.
Direction direction() const
Returns the chart's angular direction.
double opacity
Opacity, from 0 (transparent) to 1.0 (opaque).
QList< QString > categoryAttributes
QList< QColor > categoryColors
double rotationOffset
Rotation offset, in degrees clockwise from horizontal.
@ Clockwise
Clockwise orientation.
void setPenWidth(QPen &pen, const QgsDiagramSettings &s, const QgsRenderContext &c)
Changes the pen width to match the current settings and rendering context.
QSizeF sizePainterUnits(QSizeF size, const QgsDiagramSettings &s, const QgsRenderContext &c)
Calculates a size to match the current settings and rendering context.
QgsExpression * getExpression(const QString &expression, const QgsExpressionContext &context)
Returns a prepared expression for the specified context.
QSizeF sizeForValue(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings) const
Returns the scaled size of a diagram for a value, respecting the specified diagram interpolation sett...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
Handles parsing and evaluation of expressions (formerly called "search strings").
QVariant evaluate()
Evaluate the feature and return the result.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
QSizeF diagramSize(const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s) override
Returns the size in map units the diagram will use to render.
static const QString DIAGRAM_NAME_PIE
QgsPieDiagram * clone() const override
Returns an instance that is equivalent to this one.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position) override
Draws the diagram at the given position (in pixel coordinates).
QString diagramName() const override
Gets a descriptive name for this diagram type.
double legendSize(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings) const override
Returns the size of the legend item for the diagram corresponding to a specified value.
Contains information about the context of a rendering operation.
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