25 mCategoryBrush.setStyle( Qt::SolidPattern );
26 mPen.setStyle( Qt::SolidLine );
47 attrVal = expression->
evaluate( &expressionContext );
55 double value = attrVal.toDouble( &ok );
67 return std::max( size.width(), size.height() );
78 Q_UNUSED( attributes );
92 double currentVal = 0;
105 currentVal = expression->
evaluate( &expressionContext ).toDouble();
106 values.push_back( currentVal );
107 valSum += currentVal;
108 if ( currentVal ) valCount++;
112 double totalAngle = 0;
117 double w = spu.width();
118 double h = spu.height();
120 double baseX = position.x();
121 double baseY = position.y() - h;
130 QList<double>::const_iterator valIt = values.constBegin();
131 QList< QColor >::const_iterator colIt = s.
categoryColors.constBegin();
132 for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
136 currentAngle = *valIt / valSum * 360 * 16;
137 mCategoryBrush.setColor( *colIt );
138 p->setBrush( mCategoryBrush );
142 p->drawEllipse( baseX, baseY, w, h );
146 p->drawPie( baseX, baseY, w, h, totalAngle - s.
rotationOffset * 16.0, currentAngle );
148 totalAngle += currentAngle;
155 mCategoryBrush.setColor( Qt::transparent );
156 p->setBrush( mCategoryBrush );
157 p->drawEllipse( baseX, baseY, w, h );
QSizeF sizePainterUnits(QSizeF size, const QgsDiagramSettings &s, const QgsRenderContext &c)
Calculates a size to match the current settings and rendering context.
Class for parsing and evaluation of expressions (formerly called "search strings").
QList< QString > categoryAttributes
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
bool classificationAttributeIsExpression
QVariant evaluate()
Evaluate the feature and return the result.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
double rotationOffset
Rotation offset, in degrees clockwise from horizontal.
QgsPieDiagram * clone() const override
Returns an instance that is equivalent to this one.
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
double legendSize(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is) const override
Returns the size of the legend item for the diagram corresponding to a specified value.
QString classificationAttributeExpression
QgsExpression * getExpression(const QString &expression, const QgsExpressionContext &context)
Returns a prepared expression for the specified context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
QSizeF sizeForValue(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is) const
Returns the scaled size of a diagram for a value, respecting the specified diagram interpolation sett...
QgsExpressionContext & expressionContext()
Gets the expression context.
Additional diagram settings for interpolated size rendering.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
QString classificationField
Name of the field for classification.
bool isEmpty() const
Check whether the container is empty.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position) override
Draws the diagram at the given position (in pixel coordinates)
void setPenWidth(QPen &pen, const QgsDiagramSettings &s, const QgsRenderContext &c)
Changes the pen width to match the current settings and rendering context.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString diagramName() const override
Gets a descriptive name for this diagram type.
QList< QColor > categoryColors
Stores the settings for rendering a single diagram.
QSizeF diagramSize(const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s) override
Returns the size in map units the diagram will use to render.