void paintAreas( AbstractDiagram::Private* diagramPrivate, PaintContext* ctx, const QModelIndex& index, const QList< QPolygonF >& areas, uint opacity ) { AbstractDiagram* diagram = diagramPrivate->diagram; QPainterPath path; for ( int i = 0; i < areas.count(); ++i ) { const QPolygonF& p = areas[ i ]; path.addPolygon( p ); diagramPrivate->reverseMapper.addPolygon( index.row(), index.column(), p ); path.closeSubpath(); } ThreeDLineAttributes threeDAttrs = threeDLineAttributes( diagram, index ); QBrush trans = diagram->brush( index ); if ( threeDAttrs.isEnabled() ) { trans = threeDAttrs.threeDBrush( trans, path.boundingRect() ); } QColor transColor = trans.color(); transColor.setAlpha( opacity ); trans.setColor(transColor); QPen indexPen = diagram->pen(index); indexPen.setBrush( trans ); const PainterSaver painterSaver( ctx->painter() ); ctx->painter()->setRenderHint( QPainter::Antialiasing, diagram->antiAliasing() ); ctx->painter()->setPen( PrintingParameters::scalePen( indexPen ) ); ctx->painter()->setBrush( trans ); ctx->painter()->drawPath( path ); }
void paintElements( AbstractDiagram::Private *diagramPrivate, PaintContext* ctx, const LabelPaintCache& lpc, const LineAttributesInfoList& lineList ) { AbstractDiagram* diagram = diagramPrivate->diagram; // paint all lines and their attributes const PainterSaver painterSaver( ctx->painter() ); ctx->painter()->setRenderHint( QPainter::Antialiasing, diagram->antiAliasing() ); QBrush curBrush; QPen curPen; QPolygonF points; KDAB_FOREACH ( const LineAttributesInfo& lineInfo, lineList ) { const QModelIndex& index = lineInfo.index; const ThreeDLineAttributes td = threeDLineAttributes( diagram, index ); if ( td.isEnabled() ) { PaintingHelpers::paintThreeDLines( ctx, diagram, index, lineInfo.value, lineInfo.nextValue, td, &diagramPrivate->reverseMapper ); } else { const QBrush brush( diagram->brush( index ) ); const QPen pen( diagram->pen( index ) ); // line goes from lineInfo.value to lineInfo.nextValue diagramPrivate->reverseMapper.addLine( lineInfo.index.row(), lineInfo.index.column(), lineInfo.value, lineInfo.nextValue ); if ( points.count() && points.last() == lineInfo.value && curBrush == brush && curPen == pen ) { // continue the current run of lines } else { // different painter settings or discontinuous line: start a new run of lines if ( points.count() ) { PaintingHelpers::paintPolyline( ctx, curBrush, curPen, points ); } curBrush = brush; curPen = pen; points.clear(); points << lineInfo.value; } points << lineInfo.nextValue; } } if ( points.count() ) { // the last run of lines is yet to be painted - do it now PaintingHelpers::paintPolyline( ctx, curBrush, curPen, points ); } KDAB_FOREACH ( const LineAttributesInfo& lineInfo, lineList ) { const ValueTrackerAttributes vt = valueTrackerAttributes( diagram, lineInfo.index ); if ( vt.isEnabled() ) { PaintingHelpers::paintValueTracker( ctx, vt, lineInfo.nextValue ); } } // paint all data value texts and the point markers diagramPrivate->paintDataValueTextsAndMarkers( ctx, lpc, true ); }