bool ValueTrackerAttributes::operator==( const ValueTrackerAttributes& r ) const { return ( pen() == r.pen() && areaBrush() == r.areaBrush() && markerSize() == r.markerSize() && isEnabled() == r.isEnabled() ); }
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 ); }
// this method is factored out from LineDiagram::paint, and contains // the common parts of the method that previously implemented all // chart types in one void LineDiagram::LineDiagramType::paintElements( PaintContext* ctx, DataValueTextInfoList& list, LineAttributesInfoList& lineList, LineAttributes::MissingValuesPolicy policy ) { Q_UNUSED( policy ); // paint all lines and their attributes const PainterSaver painterSaver( ctx->painter() ); if ( diagram()->antiAliasing() ) ctx->painter()->setRenderHint ( QPainter::Antialiasing ); LineAttributesInfoListIterator itline ( lineList ); QBrush curBrush; QPen curPen; QPolygonF points; while ( itline.hasNext() ) { const LineAttributesInfo& lineInfo = itline.next(); const QModelIndex& index = lineInfo.index; const ThreeDLineAttributes td = diagram()->threeDLineAttributes( index ); const ValueTrackerAttributes vt = diagram()->valueTrackerAttributes( index ); if( td.isEnabled() ){ paintThreeDLines( ctx, index, lineInfo.value, lineInfo.nextValue, td.depth() ); } else { const QBrush br( diagram()->brush( index ) ); const QPen pn( diagram()->pen( index ) ); if( points.count() && points.last() == lineInfo.value && curBrush == br && curPen == pn ) { // line goes from last value in points to lineInfo.nextValue reverseMapper().addLine( lineInfo.index.row(), lineInfo.index.column(), points.last(), lineInfo.nextValue ); points << lineInfo.nextValue; } else { if( points.count() ) paintPolyline( ctx, curBrush, curPen, points ); curBrush = br; curPen = pn; points.clear(); // line goes from lineInfo.value to lineInfo,nextValue reverseMapper().addLine( lineInfo.index.row(), lineInfo.index.column(), lineInfo.value, lineInfo.nextValue ); points << lineInfo.value << lineInfo.nextValue; } } if( vt.isEnabled() ) paintValueTracker( ctx, vt, lineInfo.value ); } if( points.count() ) paintPolyline( ctx, curBrush, curPen, points ); // paint all data value texts and the point markers paintDataValueTextsAndMarkers( diagram(), ctx, list, true ); }