160  QPainter *p = 
c.painter();
 
  166  QList< QPair<double, QColor> > values;
 
  167  QList< QPair<double, QColor> > negativeValues;
 
  176  double negativeTotal = 0;
 
  178  QList< QColor >::const_iterator colIt = s.
categoryColors.constBegin();
 
  182    double currentVal = expression->
evaluate( &expressionContext ).toDouble();
 
  183    total += fabs( currentVal );
 
  184    if ( currentVal >= 0 )
 
  186      values.push_back( qMakePair( currentVal, *colIt ) );
 
  190      negativeTotal += currentVal;
 
  191      negativeValues.push_back( qMakePair( -currentVal, *colIt ) );
 
  198  const double totalSpacing = std::max( 0, 
static_cast<int>( s.
categoryAttributes.size() ) - 1 ) * spacing;
 
  200  double scaledMaxVal = 0;
 
  213  if ( mApplySpacingAdjust )
 
  214    scaledMaxVal -= totalSpacing;
 
  216  double axisOffset = 0;
 
  217  if ( !negativeValues.isEmpty() )
 
  219    axisOffset = -negativeTotal / total * scaledMaxVal + ( negativeValues.size() - 1 ) * spacing;
 
  223  double baseX = position.x();
 
  224  double baseY = position.y();
 
  239  while ( !negativeValues.isEmpty() )
 
  241    values.push_front( negativeValues.takeLast() );
 
  244  double currentOffset = 0;
 
  245  QList< QPair<double, QColor> >::const_iterator valIt = values.constBegin();
 
  246  for ( ; valIt != values.constEnd(); ++valIt )
 
  248    double length = valIt->first / total * scaledMaxVal;
 
  250    QColor brushColor( valIt->second );
 
  251    brushColor.setAlphaF( brushColor.alphaF() * s.
opacity );
 
  252    mCategoryBrush.setColor( brushColor );
 
  253    p->setBrush( mCategoryBrush );
 
  258        p->drawRect( QRectF( baseX, baseY - currentOffset, scaledWidth, length * -1 ) );
 
  262        p->drawRect( QRectF( baseX, baseY + currentOffset - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ), scaledWidth, length ) );
 
  266        p->drawRect( QRectF( baseX + currentOffset, baseY - scaledWidth, length, scaledWidth ) );
 
  270        p->drawRect( QRectF( baseX + scaledMaxVal - currentOffset + spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ), baseY - scaledWidth, 0 - length, scaledWidth ) );
 
  274    currentOffset += length + spacing;
 
  280    QPolygonF axisPoints;
 
  284        axisPoints << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) )
 
  285                   << QPointF( baseX, baseY - axisOffset )
 
  286                   << QPointF( baseX + scaledWidth, baseY - axisOffset );
 
  290        axisPoints << QPointF( baseX, baseY )
 
  291                   << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) + axisOffset )
 
  292                   << QPointF( baseX + scaledWidth, baseY - scaledMaxVal - spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) + axisOffset );
 
  296        axisPoints << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ), baseY - scaledWidth )
 
  297                   << QPointF( baseX + axisOffset, baseY - scaledWidth )
 
  298                   << QPointF( baseX + axisOffset, baseY );
 
  302        axisPoints << QPointF( baseX, baseY - scaledWidth )
 
  303                   << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, 
static_cast<int>( values.size() ) - 1 ) - axisOffset, baseY - scaledWidth )
 
  304                   << 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.