KChart

KChartPieDiagram.h
1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHARTPIEDIAGRAM_H
21 #define KCHARTPIEDIAGRAM_H
22 
23 #include "KChartAbstractPieDiagram.h"
24 
25 namespace KChart {
26 
27  class LabelPaintCache;
28 
32 class KCHART_EXPORT PieDiagram : public AbstractPieDiagram
33 {
34  Q_OBJECT
35 
36  Q_DISABLE_COPY( PieDiagram )
37  KCHART_DECLARE_DERIVED_DIAGRAM( PieDiagram, PolarCoordinatePlane )
38 
39 public:
40  explicit PieDiagram(
41  QWidget* parent = nullptr, PolarCoordinatePlane* plane = nullptr );
42  virtual ~PieDiagram();
43 
44 protected:
45  // Implement AbstractDiagram
47  void paint( PaintContext* paintContext ) override;
48 
49 public:
54  NoDecoration = 0,
55  FrameDecoration = 1,
56  LineFromSliceDecoration = 2
57  };
58  Q_DECLARE_FLAGS( LabelDecorations, LabelDecoration )
60  void setLabelDecorations( LabelDecorations decorations );
62  LabelDecorations labelDecorations() const;
63 
68  void setLabelCollisionAvoidanceEnabled( bool enabled );
70  bool isLabelCollisionAvoidanceEnabled() const;
71 
73  void resize ( const QSizeF& area ) override;
74 
75  // Implement AbstractPolarDiagram
77  qreal valueTotals () const override;
79  qreal numberOfValuesPerDataset() const override;
81  qreal numberOfGridRings() const override;
82 
83 
87  virtual PieDiagram * clone() const;
88 
89 protected:
91  const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
92  void paintEvent( QPaintEvent* ) override;
93  void resizeEvent( QResizeEvent* ) override;
94 
95 private:
96  // ### move to private class?
97  void placeLabels( PaintContext* paintContext );
98  // Solve problems with label overlap by changing label positions inside d->labelPaintCache.
99  void shuffleLabels( QRectF* textBoundingRect );
100  void paintInternal( PaintContext* paintContext );
101 
110  void drawSlice( QPainter* painter, const QRectF& drawPosition, uint slice );
111 
119  void drawSliceSurface( QPainter* painter, const QRectF& drawPosition, uint slice );
120  void addSliceLabel( LabelPaintCache* lpc, const QRectF& drawPosition, uint slice );
121 
129  void draw3DEffect( QPainter* painter, const QRectF& drawPosition, uint slice );
130 
140  void draw3dCutSurface( QPainter* painter,
141  const QRectF& rect,
142  qreal threeDHeight,
143  qreal angle );
144 
154  void draw3dOuterRim( QPainter* painter,
155  const QRectF& rect,
156  qreal threeDHeight,
157  qreal startAngle,
158  qreal endAngle );
159  void calcSliceAngles();
160  void calcPieSize( const QRectF &contentsRect );
161  QRectF twoDPieRect( const QRectF &contentsRect, const ThreeDPieAttributes& threeDAttrs ) const;
162  QRectF explodedDrawPosition( const QRectF& drawPosition, uint slice ) const;
163 
170  uint findSliceAt( qreal angle, int columnCount );
171 
178  uint findLeftSlice( uint slice, int columnCount );
179 
186  uint findRightSlice( uint slice, int columnCount );
187 
192  QPointF pointOnEllipse( const QRectF& boundingBox, qreal angle );
193 }; // End of class KChartPieDiagram
194 
195 Q_DECLARE_OPERATORS_FOR_FLAGS( PieDiagram::LabelDecorations )
196 
197 }
198 #endif // KCHARTPIEDIAGRAM_H
Class only listed here to document inheritance of some KChart classes.
PieDiagram defines a common pie diagram.
Stores information about painting diagrams.
A set of 3D pie attributes.
Base class for any diagram type.
LabelDecoration
Describes which decorations are painted around data labels.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 22 2020 22:36:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.