158  QPainter *p = 
c.painter();
 
  164  QList< QPair<double, QColor> > values;
 
  165  QList< QPair<double, QColor> > negativeValues;
 
  174  double negativeTotal = 0;
 
  176  QList< QColor >::const_iterator colIt = s.
categoryColors.constBegin();
 
  180    double currentVal = expression->
evaluate( &expressionContext ).toDouble();
 
  181    total += fabs( currentVal );
 
  182    if ( currentVal >= 0 )
 
  184      values.push_back( qMakePair( currentVal, *colIt ) );
 
  188      negativeTotal += currentVal;
 
  189      negativeValues.push_back( qMakePair( -currentVal, *colIt ) );
 
  196  const double totalSpacing = std::max( 0, 
static_cast<int>( s.
categoryAttributes.size() ) - 1 ) * spacing;
 
  198  double scaledMaxVal = 0;
 
  211  if ( mApplySpacingAdjust )
 
  212    scaledMaxVal -= totalSpacing;
 
  214  double axisOffset = 0;
 
  215  if ( !negativeValues.isEmpty() )
 
  217    axisOffset = -negativeTotal / total * scaledMaxVal + ( negativeValues.size() - 1 ) * spacing;
 
  221  double baseX = position.x();
 
  222  double baseY = position.y();
 
  237  while ( !negativeValues.isEmpty() )
 
  239    values.push_front( negativeValues.takeLast() );
 
  242  double currentOffset = 0;
 
  243  QList< QPair<double, QColor> >::const_iterator valIt = values.constBegin();
 
  244  for ( ; valIt != values.constEnd(); ++valIt )
 
  246    double length = valIt->first / total * scaledMaxVal;
 
  248    QColor brushColor( valIt->second );
 
  249    brushColor.setAlphaF( brushColor.alphaF() * s.
opacity );
 
  250    mCategoryBrush.setColor( brushColor );
 
  251    p->setBrush( mCategoryBrush );
 
  256        p->drawRect( QRectF( baseX, baseY - currentOffset, scaledWidth, length * -1 ) );
 
  260        p->drawRect( QRectF( baseX, baseY + currentOffset - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ), scaledWidth, length ) );
 
  264        p->drawRect( QRectF( baseX + currentOffset, baseY - scaledWidth, length, scaledWidth ) );
 
  268        p->drawRect( QRectF( baseX + scaledMaxVal - currentOffset + spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ), baseY - scaledWidth, 0 - length, scaledWidth ) );
 
  272    currentOffset += length + spacing;
 
  278    QPolygonF axisPoints;
 
  282        axisPoints << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) )
 
  283                   << QPointF( baseX, baseY - axisOffset )
 
  284                   << QPointF( baseX + scaledWidth, baseY - axisOffset );
 
  288        axisPoints << QPointF( baseX, baseY )
 
  289                   << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) + axisOffset )
 
  290                   << QPointF( baseX + scaledWidth, baseY - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) + axisOffset );
 
  294        axisPoints << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ), baseY - scaledWidth )
 
  295                   << QPointF( baseX + axisOffset, baseY - scaledWidth )
 
  296                   << QPointF( baseX + axisOffset, baseY );
 
  300        axisPoints << QPointF( baseX, baseY - scaledWidth )
 
  301                   << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) - axisOffset, baseY - scaledWidth )
 
  302                   << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) - axisOffset, baseY );
 
 
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.
Contains information about the context of a rendering operation.