25 #include <QAbstractItemModel> 32 #include "KDChartNormalLineDiagram_p.h" 33 #include "PaintingHelpers_p.h" 39 : LineDiagramType( d )
50 return compressor().dataBoundaries();
55 reverseMapper().clear();
56 Q_ASSERT( dynamic_cast<CartesianCoordinatePlane*>( ctx->
coordinatePlane() ) );
58 const int columnCount = compressor().modelDataColumns();
59 const int rowCount = compressor().modelDataRows();
60 if ( columnCount == 0 || rowCount == 0 )
return;
63 bool rev = diagram()->reverseDatasetOrder();
65 LineAttributesInfoList lineList;
67 const int step = rev ? -1 : 1;
68 const int end = rev ? -1 : columnCount;
69 for (
int column = rev ? columnCount - 1 : 0; column != end; column += step ) {
71 CartesianDiagramDataCompressor::DataPoint lastPoint;
72 qreal lastAreaBoundingValue = 0;
77 CartesianDiagramDataCompressor::CachePosition previousCellPosition;
78 for (
int row = 0; row < rowCount; ++row ) {
79 const CartesianDiagramDataCompressor::CachePosition position( row, column );
81 CartesianDiagramDataCompressor::DataPoint point = compressor().data( position );
86 const QModelIndex sourceIndex = attributesModel()->mapToSource( point.index );
88 const LineAttributes laCell = diagram()->lineAttributes( sourceIndex );
92 qreal areaBoundingValue;
94 const CartesianDiagramDataCompressor::CachePosition areaBoundingCachePosition( row, laCell.
areaBoundingDataset() );
95 areaBoundingValue = compressor().data( areaBoundingCachePosition ).value;
98 areaBoundingValue = minYValue;
101 if ( ISNAN( point.value ) )
121 if ( !ISNAN( point.value ) ) {
123 const qreal offset = diagram()->centerDataPoints() ? 0.5 : 0;
124 const QPointF a( plane->
translate( QPointF( lastPoint.key + offset, lastPoint.value ) ) );
125 const QPointF b( plane->
translate( QPointF( point.key + offset, point.value ) ) );
126 const QPointF c( plane->
translate( QPointF( lastPoint.key + offset, lastAreaBoundingValue ) ) );
127 const QPointF
d( plane->
translate( QPointF( point.key + offset, areaBoundingValue ) ) );
135 if ( !ISNAN( lastPoint.value ) ) {
136 lineList.append( LineAttributesInfo( sourceIndex, a, b ) );
140 areas << ( QPolygonF() << a << b <<
d << c );
147 previousCellPosition = position;
148 laPreviousCell = laCell;
149 lastAreaBoundingValue = areaBoundingValue;
int areaBoundingDataset() const
KDChartEnums::PositionValue value() const
Returns an integer value corresponding to this Position.
void paintElements(AbstractDiagram::Private *diagramPrivate, PaintContext *ctx, const LabelPaintCache &lpc, const LineAttributesInfoList &lineList)
const QPointF translate(const QPointF &diagramPoint) const
Translate the given point in value space coordinates to a position in pixel space.
AbstractCoordinatePlane * coordinatePlane() const
Set of attributes for changing the appearance of line charts.
void paintAreas(AbstractDiagram::Private *diagramPrivate, PaintContext *ctx, const QModelIndex &index, const QList< QPolygonF > &areas, uint opacity)
static const Position & NorthWest
LineDiagram defines a common line diagram.
Stores information about painting diagrams.
Stores the absolute target points of a Position.
MissingValuesPolicy
MissingValuesPolicy specifies how a missing value will be shown in a line diagram.
Cartesian coordinate plane.
QRectF visibleDataRange() const
Returns the currently visible data range.
uint transparency() const
MissingValuesPolicy missingValuesPolicy() const