24 mCategoryBrush.setStyle( Qt::SolidPattern );
25 mPen.setStyle( Qt::SolidLine );
55 maxValue = qMax( expression->
evaluate( feature ).toDouble(), maxValue );
87 if ( attributes.count() == 0 )
92 double maxValue = attributes[0].toDouble();
94 for (
int i = 0; i < attributes.count(); ++i )
96 maxValue = qMax( attributes[i].toDouble(), maxValue );
103 mScaleFactor = maxValue / s.
size.height();
110 mScaleFactor = maxValue / s.
size.width();
126 QList<double> values;
132 double currentVal = expression->
evaluate( feature ).toDouble();
133 values.push_back( currentVal );
134 maxValue = qMax( currentVal, maxValue );
139 double currentOffset = 0;
142 double baseX = position.x();
143 double baseY = position.y();
149 QList<double>::const_iterator valIt = values.constBegin();
150 QList< QColor >::const_iterator colIt = s.
categoryColors.constBegin();
151 for ( ; valIt != values.constEnd(); ++valIt, ++colIt )
155 mCategoryBrush.setColor( *colIt );
156 p->setBrush( mCategoryBrush );
161 p->drawRect( baseX + currentOffset, baseY, scaledWidth, length * -1 );
165 p->drawRect( baseX + currentOffset, baseY - scaledMaxVal, scaledWidth, length );
169 p->drawRect( baseX, baseY - currentOffset, length, scaledWidth * -1 );
173 p->drawRect( baseX + scaledMaxVal, baseY - currentOffset, 0 - length, scaledWidth * -1 );
177 currentOffset += scaledWidth;
Class for parsing and evaluation of expressions (formerly called "search strings").
QSizeF diagramSize(const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s) override
Returns the size in map units the diagram will use to render.
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)
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.
DiagramOrientation diagramOrientation
virtual QgsDiagram * clone() const override
Returns an instance that is equivalent to this one.
const QgsFields * fields() const
Get associated field map.
const QgsAttributes & attributes() const
Base class for all diagram types.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, const QPointF &position) override
Draws the diagram at the given position (in pixel coordinates)
Contains information about the context of a rendering operation.
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