25 mCategoryBrush.setStyle( Qt::SolidPattern );
26 mPen.setStyle( Qt::SolidLine );
46 attrVal = expression->
evaluate( feature );
53 if ( !attrVal.isValid() )
58 double scaledValue = attrVal.toDouble();
61 double scaledLowerSizeWidth = is.
lowerSize.width();
62 double scaledLowerSizeHeight = is.
lowerSize.height();
63 double scaledUpperSizeWidth = is.
upperSize.width();
64 double scaledUpperSizeHeight = is.
upperSize.height();
69 scaledValue = sqrt( scaledValue );
70 scaledLowerValue = sqrt( scaledLowerValue );
71 scaledUpperValue = sqrt( scaledUpperValue );
72 scaledLowerSizeWidth = sqrt( scaledLowerSizeWidth );
73 scaledLowerSizeHeight = sqrt( scaledLowerSizeHeight );
74 scaledUpperSizeWidth = sqrt( scaledUpperSizeWidth );
75 scaledUpperSizeHeight = sqrt( scaledUpperSizeHeight );
79 double scaledRatio = ( scaledValue - scaledLowerValue ) / ( scaledUpperValue - scaledLowerValue );
81 QSizeF size = QSizeF( is.
upperSize.width() * scaledRatio + is.
lowerSize.width() * ( 1 - scaledRatio ),
88 if ( size.width() == size.height() )
95 size.setWidth( size.height() );
104 Q_UNUSED( attributes );
108 int QgsPieDiagram::sCount = 0;
119 QList<double> values;
120 double currentVal = 0;
128 currentVal = expression->
evaluate( feature ).toDouble();
129 values.push_back( currentVal );
130 valSum += currentVal;
131 if ( currentVal ) valCount++;
135 double totalAngle = 0;
140 double w = spu.width();
141 double h = spu.height();
143 double baseX = position.x();
144 double baseY = position.y() - h;
153 QList<double>::const_iterator valIt = values.constBegin();
154 QList< QColor >::const_iterator colIt = s.
categoryColors.constBegin();
155 for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
159 currentAngle = *valIt / valSum * 360 * 16;
160 mCategoryBrush.setColor( *colIt );
161 p->setBrush( mCategoryBrush );
165 p->drawEllipse( baseX, baseY, w, h );
169 p->drawPie( baseX, baseY, w, h, totalAngle + s.
angleOffset, currentAngle );
171 totalAngle += currentAngle;
178 mCategoryBrush.setColor( Qt::transparent );
179 p->setBrush( mCategoryBrush );
180 p->drawEllipse( baseX, baseY, w, h );
Class for parsing and evaluation of expressions (formerly called "search strings").
double minimumSize
Scale diagrams smaller than mMinimumSize to mMinimumSize.
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
QList< QString > categoryAttributes
QgsExpression * getExpression(const QString &expression, const QgsFields *fields)
bool classificationAttributeIsExpression
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QSizeF sizePainterUnits(const QSizeF &size, const QgsDiagramSettings &s, const QgsRenderContext &c)
Calculates a size to match the current settings and rendering context.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, const QPointF &position) override
Draws the diagram at the given position (in pixel coordinates)
QString classificationAttributeExpression
const QgsFields * fields() const
Get associated field map.
virtual QgsDiagram * clone() const override
Returns an instance that is equivalent to this one.
const QgsAttributes & attributes() const
Base class for all diagram types.
Contains information about the context of a rendering operation.
int classificationAttribute
Index of the classification attribute.
void setPenWidth(QPen &pen, const QgsDiagramSettings &s, const QgsRenderContext &c)
Changes the pen width to match the current settings and rendering context.
QList< QColor > categoryColors
QSizeF diagramSize(const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s) override
Returns the size in map units the diagram will use to render.