24 #include "KDChartBarDiagram_p.h" 27 #include "KDChartPainterSaver_p.h" 31 BarDiagram::Private::Private(
const Private& rhs )
36 void BarDiagram::BarDiagramType::paintBars(
PaintContext* ctx,
const QModelIndex& index,
const QRectF& bar, qreal maxDepth )
38 PainterSaver painterSaver( ctx->
painter() );
41 QBrush indexBrush( diagram()->
brush( index ) );
42 QPen indexPen( diagram()->
pen( index ) );
47 indexBrush = threeDAttrs.
threeDBrush( indexBrush, bar );
49 ctx->
painter()->setBrush( indexBrush );
59 const QRectF isoRect = bar.translated( usedDepth, -usedDepth );
63 if ( isoRect.height() < 0 ) {
66 topPoints << isoRect.bottomLeft() << isoRect.bottomRight()
67 << bar.bottomRight() << bar.bottomLeft();
70 reverseMapper().addRect( index.row(), index.column(), isoRect );
71 ctx->
painter()->drawRect( isoRect );
73 topPoints << bar.topLeft() << bar.topRight() << isoRect.topRight() << isoRect.topLeft();
77 bool noClippingForTop =
false;
78 if ( !topPoints.isEmpty() ) {
82 bool hasPointOutside =
false;
83 const QRectF r( ctx->
rectangle().adjusted( 0, -1, 1, 0 ) );
84 KDAB_FOREACH( QPointF pt, topPoints ) {
85 if ( r.contains( pt ) ) {
88 hasPointOutside =
true;
92 const PainterSaver p( ctx->
painter() );
93 noClippingForTop = hasPointOutside && ctx->
painter()->hasClipping();
94 if ( noClippingForTop ) {
95 ctx->
painter()->setClipping(
false );
97 reverseMapper().addPolygon( index.row(), index.column(), topPoints );
98 ctx->
painter()->drawPolygon( topPoints );
102 if ( bar.height() != 0 ) {
103 const PainterSaver p( ctx->
painter() );
104 if ( noClippingForTop ) {
105 ctx->
painter()->setClipping(
false );
107 QPolygonF sidePoints;
108 sidePoints << bar.topRight() << isoRect.topRight()
109 << isoRect.bottomRight() << bar.bottomRight();
110 reverseMapper().addPolygon( index.row(), index.column(), sidePoints );
111 ctx->
painter()->drawPolygon( sidePoints );
115 if ( bar.height() != 0 ) {
116 reverseMapper().addRect( index.row(), index.column(), bar );
117 ctx->
painter()->drawRect( bar );
123 return m_private->attributesModel;
126 QModelIndex BarDiagram::BarDiagramType::attributesModelRootIndex()
const 128 return diagram()->attributesModelRootIndex();
131 BarDiagram* BarDiagram::BarDiagramType::diagram()
const 133 return static_cast< BarDiagram*
>( m_private->diagram );
136 void BarDiagram::BarDiagramType::calculateValueAndGapWidths(
int rowCount,
int colCount,
139 qreal& outSpaceBetweenBars,
140 qreal& outSpaceBetweenGroups )
143 Q_UNUSED( rowCount );
162 qreal unitWidth = groupWidth / units;
165 outBarWidth = unitWidth;
183 return m_private->reverseMapper;
186 CartesianDiagramDataCompressor& BarDiagram::BarDiagramType::compressor()
const 188 return m_private->compressor;
const QRectF rectangle() const
Set of attributes for changing the appearance of bar charts.
Declaring the class KDChart::DataValueAttributes.
bool useFixedBarWidth() const
QPainter * painter() const
BarDiagram defines a common bar diagram.
QBrush brush() const
Retrieve the brush to be used for painting datapoints globally.
The ReverseMapper stores information about objects on a chart and their respective model indexes...
A proxy model used for decorating data with attributes.
bool antiAliasing() const
qreal barGapFactor() const
Base class for diagrams based on a cartesian coordianate system.
Stores information about painting diagrams.
A set of 3D bar attributes.
qreal groupGapFactor() const
QPen pen() const
Retrieve the pen to be used for painting datapoints globally.
virtual QBrush threeDBrush(const QBrush &brush, const QRectF &rect) const
void setDepth(qreal depth)
static QPen scalePen(const QPen &pen)