KChart

KChartChart.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 KCHARTCHART_H
21 #define KCHARTCHART_H
22 
23 #include <QWidget>
24 
25 #include "kchart_export.h"
26 #include "KChartGlobal.h"
27 
28 /*
29 Simplified(*) overview of object ownership in a chart:
30 
31  Chart is-a QWidget
32  |
33  n CoordinatePlanes is-a AbstractArea is-a AbstractLayoutItem is-a QLayoutItem
34  |
35  n Diagrams is-a QAbstractItemView is-a QWidget
36  / | \
37  AbstractGrid | Axes (can be shared between diagrams) is-a AbstractArea is-a... QLayoutItem
38  (no base class) |
39  Legends is-a AbstractAreaWidget is-a QWidget
40 
41 (*) less important classes, including base classes, removed.
42 
43 
44 Layout rules:
45 
46 In principle, every size or existence change in one of the objects listed above must be propagated
47 to all other objects. This could change their size.
48 There are also settings changes that invalidate the size of other components, where the size changes
49 are detected and propagated.
50 
51 
52 Painting call tree (simplified):
53 
54 Chart::paint() (from users) / paintEvent() (from framework)
55 ChartPrivate::paintAll()-----------------------------------------------\
56 CoordinatePlane::paintAll() (from AbstractArea)--------\ Axis::paintAll()-\
57 CoordinatePlane::paint() (from AbstractLayoutItem) Grid::drawGrid() Axis::paint()
58 Diagram::paint( PaintContext* paintContext )
59 
60 Note that grids are painted from the coordinate plane, not from the diagram as ownership would suggest.
61 
62 */
63 
64 namespace KChart {
65 
66  class BackgroundAttributes;
67  class FrameAttributes;
68  class AbstractDiagram;
69  class AbstractCoordinatePlane;
70  class HeaderFooter;
71  class Legend;
72 
73  typedef QList<AbstractCoordinatePlane*> CoordinatePlaneList;
74  typedef QList<HeaderFooter*> HeaderFooterList;
75  typedef QList<Legend*> LegendList;
76 
77 
95  class KCHART_EXPORT Chart : public QWidget
96  {
97  Q_OBJECT
98  // KD Chart 3.0: leading is inter-line distance of text. this here is MARGIN or SPACING.
99  Q_PROPERTY( int globalLeadingTop READ globalLeadingTop WRITE setGlobalLeadingTop )
100  Q_PROPERTY( int globalLeadingBottom READ globalLeadingBottom WRITE setGlobalLeadingBottom )
101  Q_PROPERTY( int globalLeadingLeft READ globalLeadingLeft WRITE setGlobalLeadingLeft )
102  Q_PROPERTY( int globalLeadingRight READ globalLeadingRight WRITE setGlobalLeadingRight )
103  Q_PROPERTY( bool useNewLayoutSystem READ useNewLayoutSystem WRITE setUseNewLayoutSystem )
104 
105  KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( Chart )
106 
107  public:
108  explicit Chart ( QWidget* parent = nullptr );
109  ~Chart();
110 
119  bool useNewLayoutSystem() const;
120  void setUseNewLayoutSystem( bool value );
121 
134  void setFrameAttributes( const FrameAttributes &a );
135  FrameAttributes frameAttributes() const;
136 
150  void setBackgroundAttributes( const BackgroundAttributes &a );
151  BackgroundAttributes backgroundAttributes() const;
152 
160  AbstractCoordinatePlane* coordinatePlane();
161 
166  CoordinatePlaneList coordinatePlanes();
167 
174  void addCoordinatePlane( AbstractCoordinatePlane* plane );
175 
185  void insertCoordinatePlane( int index, AbstractCoordinatePlane* plane );
186 
204  void replaceCoordinatePlane( AbstractCoordinatePlane* plane,
205  AbstractCoordinatePlane* oldPlane = nullptr );
206 
215  void takeCoordinatePlane( AbstractCoordinatePlane* plane );
216 
222  void setCoordinatePlaneLayout( QLayout * layout );
223  QLayout* coordinatePlaneLayout();
224 
230  HeaderFooter* headerFooter();
231 
236  HeaderFooterList headerFooters();
237 
244  void addHeaderFooter( HeaderFooter* headerFooter );
245 
263  void replaceHeaderFooter ( HeaderFooter* headerFooter,
264  HeaderFooter* oldHeaderFooter = nullptr );
265 
274  void takeHeaderFooter( HeaderFooter* headerFooter );
275 
280  Legend* legend();
281 
286  LegendList legends();
287 
294  void addLegend( Legend* legend );
295 
319  void replaceLegend ( Legend* legend, Legend* oldLegend = nullptr );
320 
329  void takeLegend( Legend* legend );
330 
350  void setGlobalLeading( int left, int top, int right, int bottom );
351 
359  void setGlobalLeadingLeft( int leading );
360 
369  int globalLeadingLeft() const;
370 
378  void setGlobalLeadingTop( int leading );
379 
388  int globalLeadingTop() const;
389 
397  void setGlobalLeadingRight( int leading );
398 
407  int globalLeadingRight() const;
408 
416  void setGlobalLeadingBottom( int leading );
417 
426  int globalLeadingBottom() const;
427 
441  void paint( QPainter* painter, const QRect& rect );
442 
443  void reLayoutFloatingLegends();
444 
445  Q_SIGNALS:
447  void propertiesChanged();
448  void finishedDrawing();
449 
450  protected:
454  /* reimp */ void resizeEvent ( QResizeEvent * event ) override;
455 
463  /* reimp */ void paintEvent( QPaintEvent* event ) override;
464 
466  void mousePressEvent( QMouseEvent* event ) override;
468  void mouseDoubleClickEvent( QMouseEvent* event ) override;
470  void mouseMoveEvent( QMouseEvent* event ) override;
472  void mouseReleaseEvent( QMouseEvent* event ) override;
474  bool event( QEvent* event ) override;
475 
476  private:
477  // TODO move this to the private class
478  void addLegendInternal( Legend *legend, bool setMeasures );
479  };
480 
481 // Here we have a few docu block to be included into the API documentation:
507 }
573 #endif
Class only listed here to document inheritance of some KChart classes.
Legend defines the interface for the legend drawing class.
Definition: KChartLegend.h:52
Contains KChart macros.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
Set of attributes usable for background pixmaps.
A header or footer displaying text above or below charts.
A chart with one or more diagrams.
Definition: KChartChart.h:95
Global namespace.
A set of attributes for frames around items.
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.