KChart

KChartBarDiagram.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 KCHARTBARDIAGRAM_H
21 #define KCHARTBARDIAGRAM_H
22 
23 #include "KChartAbstractCartesianDiagram.h"
24 #include "KChartBarAttributes.h"
25 
26 QT_BEGIN_NAMESPACE
27 class QPainter;
28 QT_END_NAMESPACE
29 
30 namespace KChart {
31 
32  class ThreeDBarAttributes;
33 
39 class KCHART_EXPORT BarDiagram : public AbstractCartesianDiagram
40 {
41  Q_OBJECT
42 
43  Q_DISABLE_COPY( BarDiagram )
44 
45  KCHART_DECLARE_DERIVED_DIAGRAM( BarDiagram, CartesianCoordinatePlane )
46 
47 public:
48  class BarDiagramType;
49  friend class BarDiagramType;
50 
51  explicit BarDiagram(
52  QWidget* parent = nullptr, CartesianCoordinatePlane* plane = nullptr );
53  virtual ~BarDiagram();
54 
55 
59  virtual BarDiagram * clone() const;
63  bool compare( const BarDiagram* other ) const;
64 
65  enum BarType { Normal,
66  Stacked,
67  Percent,
68  Rows
69  };
70 
71 
76  void setType( const BarType type );
77 
81  BarType type() const;
82 
83 
87  void setOrientation( Qt::Orientation orientation );
88 
92  Qt::Orientation orientation() const;
93 
94 
98  void setBarAttributes( const BarAttributes & a );
99 
103  void setBarAttributes( int column, const BarAttributes & a );
104 
108  void setBarAttributes( const QModelIndex & index, const BarAttributes & a );
109 
113  BarAttributes barAttributes() const;
114 
118  BarAttributes barAttributes( int column ) const;
119 
123  BarAttributes barAttributes( const QModelIndex & index ) const;
124 
125 
129  void setThreeDBarAttributes( const ThreeDBarAttributes & a );
130 
134  void setThreeDBarAttributes( int column, const ThreeDBarAttributes & a );
135 
139  void setThreeDBarAttributes( const QModelIndex & index,
140  const ThreeDBarAttributes & a );
141 
145  ThreeDBarAttributes threeDBarAttributes() const;
146 
150  ThreeDBarAttributes threeDBarAttributes( int column ) const;
151 
155  ThreeDBarAttributes threeDBarAttributes( const QModelIndex & index ) const;
156 
157 #if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
158  // implement AbstractCartesianDiagram
160  const int numberOfAbscissaSegments () const;
162  const int numberOfOrdinateSegments () const;
163 #else
164  // implement AbstractCartesianDiagram
166  int numberOfAbscissaSegments () const override;
168  int numberOfOrdinateSegments () const override;
169 #endif
170 
171 protected:
172  void paint ( PaintContext* paintContext ) override;
173 
174 public:
175  void resize ( const QSizeF& area ) override;
176 
177 protected:
178  qreal threeDItemDepth( const QModelIndex & index ) const override;
179  qreal threeDItemDepth( int column ) const override;
181  const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
182  void paintEvent ( QPaintEvent* ) override;
183  void resizeEvent ( QResizeEvent* ) override;
184 private:
185 
186  void calculateValueAndGapWidths( int rowCount, int colCount,
187  qreal groupWidth,
188  qreal& barWidth,
189  qreal& spaceBetweenBars,
190  qreal& spaceBetweenGroups );
191 }; // End of class BarDiagram
192 
193 }
194 
195 #endif // KCHARTBARDIAGRAM_H
Class only listed here to document inheritance of some KChart classes.
Set of attributes for changing the appearance of bar charts.
Stores information about painting diagrams.
Base class for diagrams based on a cartesian coordianate system.
BarDiagram defines a common bar diagram.
Orientation
Global namespace.
A set of 3D bar attributes.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 22 2020 22:36:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.