23 #include "PaintingHelpers_p.h"
28 #include "KDChartAbstractDiagram_p.h"
33 #include "KDChartPainterSaver_p.h"
40 namespace PaintingHelpers {
52 return QPointF( point.x() * cos( yrad ) + tdAttributes.
depth() * sin( yrad ),
53 point.y() * cos( xrad ) - tdAttributes.
depth() * sin( xrad ) );
58 ctx->
painter()->setBrush( brush );
60 QPen( pen.color(), pen.width(), pen.style(), Qt::FlatCap, Qt::MiterJoin ) ) );
61 #if QT_VERSION > 0x040299
62 ctx->
painter()->drawPolyline( points );
67 for (
int i = 0; i < points.size()-1; ++i ) {
68 ctx->
painter()->drawLine( points.at( i ), points.at( i + 1 ) );
77 const QPointF topLeft =
project( from, tdAttributes );
78 const QPointF topRight =
project ( to, tdAttributes );
79 const QPolygonF segment = QPolygonF() << from << topLeft << topRight << to;
81 QBrush indexBrush( diagram->
brush( index ) );
82 indexBrush = tdAttributes.
threeDBrush( indexBrush, QRectF(topLeft, topRight) );
84 const PainterSaver painterSaver( ctx->
painter() );
87 ctx->
painter()->setBrush( indexBrush );
90 reverseMapper->
addPolygon( index.row(), index.column(), segment );
91 ctx->
painter()->drawPolygon( segment );
103 gridDimensions.at( 0 ).end :
104 gridDimensions.at( 0 ).start,
106 gridDimensions.at( 1 ).end :
107 gridDimensions.at( 1 ).start ) ) );
110 gridDimensions.at( 0 ).start :
111 gridDimensions.at( 0 ).end,
113 gridDimensions.at( 1 ).start :
114 gridDimensions.at( 1 ).end ) ) );
115 const QPointF markerPoint = at;
119 startPoint = QPointF( bottomLeft.x(), at.y() );
121 startPoint = QPointF( at.x(), topRight.y() );
126 endPoint = QPointF( at.x(), bottomLeft.y() );
128 endPoint = QPointF( topRight.x(), at.y() );
132 const QRectF ellipseMarker = QRectF( at.x() - markerSize.width() / 2,
133 at.y() - markerSize.height() / 2,
134 markerSize.width(), markerSize.height() );
136 QPointF startMarker[3];
138 startMarker[0] = startPoint + QPointF( 0, markerSize.height() / 2 );
139 startMarker[1] = startPoint + QPointF( markerSize.width() / 2, 0 );
140 startMarker[2] = startPoint - QPointF( 0, markerSize.height() / 2 );
142 startMarker[0] = startPoint + QPointF( 0, markerSize.height() / 2 );
143 startMarker[1] = startPoint + QPointF( markerSize.width() / 2, 0 );
144 startMarker[2] = startPoint - QPointF( markerSize.width() / 2, 0 );
147 QPointF endMarker[3];
150 endMarker[0] = endPoint + QPointF( markerSize.width() / 2, 0 );
151 endMarker[1] = endPoint - QPointF( 0, markerSize.height() / 2 );
152 endMarker[2] = endPoint - QPointF( markerSize.width() / 2, 0 );
154 endMarker[0] = endPoint + QPointF( 0, markerSize.width() / 2 );
155 endMarker[1] = endPoint - QPointF( 0, markerSize.height() / 2 );
156 endMarker[2] = endPoint - QPointF( markerSize.width() / 2, 0 );
159 QPointF topLeft = startPoint;
160 QPointF bottomRightOffset = endPoint - topLeft;
161 QSizeF size( bottomRightOffset.x(), bottomRightOffset.y() );
162 QRectF area( topLeft, size );
164 PainterSaver painterSaver( ctx->
painter() );
166 ctx->
painter()->setBrush( QBrush() );
167 ctx->
painter()->drawLine( markerPoint, startPoint );
168 ctx->
painter()->drawLine( markerPoint, endPoint );
174 ctx->
painter()->drawEllipse( ellipseMarker );
178 ctx->
painter()->drawPolygon( startMarker, 3 );
179 ctx->
painter()->drawPolygon( endMarker, 3 );
186 if (
Plotter *plotter = qobject_cast< Plotter* >( diagram ) ) {
187 return plotter->threeDLineAttributes( index );
188 }
else if (
LineDiagram *lineDiagram = qobject_cast< LineDiagram* >( diagram ) ) {
189 return lineDiagram->threeDLineAttributes( index );
197 if (
Plotter *plotter = qobject_cast< Plotter* >( diagram ) ) {
198 return plotter->valueTrackerAttributes( index );
199 }
else if (
LineDiagram *lineDiagram = qobject_cast< LineDiagram* >( diagram ) ) {
200 return lineDiagram->valueTrackerAttributes( index );
207 const LabelPaintCache& lpc,
const LineAttributesInfoList& lineList )
211 const PainterSaver painterSaver( ctx->
painter() );
217 KDAB_FOREACH (
const LineAttributesInfo& lineInfo, lineList ) {
218 const QModelIndex& index = lineInfo.index;
223 lineInfo.nextValue, td, &diagramPrivate->reverseMapper );
225 const QBrush brush( diagram->
brush( index ) );
226 const QPen pen( diagram->
pen( index ) );
229 diagramPrivate->reverseMapper.addLine( lineInfo.index.row(), lineInfo.index.column(),
230 lineInfo.value, lineInfo.nextValue );
232 if ( points.count() && points.last() == lineInfo.value && curBrush == brush && curPen == pen ) {
236 if ( points.count() ) {
242 points << lineInfo.value;
244 points << lineInfo.nextValue;
247 if ( points.count() ) {
252 KDAB_FOREACH (
const LineAttributesInfo& lineInfo, lineList ) {
260 diagramPrivate->paintDataValueTextsAndMarkers( ctx, lpc,
true );
268 for (
int i = 0; i < areas.count(); ++i )
270 const QPolygonF& p = areas[ i ];
271 path.addPolygon( p );
272 diagramPrivate->reverseMapper.addPolygon( index.row(), index.column(), p );
277 QBrush trans = diagram->
brush( index );
279 trans = threeDAttrs.
threeDBrush( trans, path.boundingRect() );
281 QColor transColor = trans.color();
282 transColor.setAlpha( opacity );
283 trans.setColor(transColor);
284 QPen indexPen = diagram->
pen(index);
285 indexPen.setBrush( trans );
286 const PainterSaver painterSaver( ctx->
painter() );
290 ctx->
painter()->setBrush( trans );
292 ctx->
painter()->drawPath( path );