KD Chart API Documentation  3.1
KDChartChart.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Chart library.
4 **
5 ** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #ifndef KDCHARTCHART_H
12 #define KDCHARTCHART_H
13 
14 #include <QWidget>
15 
16 #include "KDChartGlobal.h"
17 #include "kdchart_export.h"
18 
19 /*
20 Simplified(*) overview of object ownership in a chart:
21 
22  Chart is-a QWidget
23  |
24  n CoordinatePlanes is-a AbstractArea is-a AbstractLayoutItem is-a QLayoutItem
25  |
26  n Diagrams is-a QAbstractItemView is-a QWidget
27  / | \
28  AbstractGrid | Axes (can be shared between diagrams) is-a AbstractArea is-a... QLayoutItem
29  (no base class) |
30  Legends is-a AbstractAreaWidget is-a QWidget
31 
32 (*) less important classes, including base classes, removed.
33 
34 Layout rules:
35 
36 In principle, every size or existence change in one of the objects listed above must be propagated
37 to all other objects. This could change their size.
38 There are also settings changes that invalidate the size of other components, where the size changes
39 are detected and propagated.
40 
41 Painting call tree (simplified):
42 
43 Chart::paint() (from users) / paintEvent() (from framework)
44 ChartPrivate::paintAll()-----------------------------------------------\
45 CoordinatePlane::paintAll() (from AbstractArea)--------\ Axis::paintAll()-\
46 CoordinatePlane::paint() (from AbstractLayoutItem) Grid::drawGrid() Axis::paint()
47 Diagram::paint( PaintContext* paintContext )
48 
49 Note that grids are painted from the coordinate plane, not from the diagram as ownership would suggest.
50 
51 */
52 
53 namespace KDChart {
54 
55 class BackgroundAttributes;
56 class FrameAttributes;
57 class AbstractDiagram;
58 class AbstractCoordinatePlane;
59 class HeaderFooter;
60 class Legend;
61 
62 typedef QList<AbstractCoordinatePlane *> CoordinatePlaneList;
63 typedef QList<HeaderFooter *> HeaderFooterList;
64 typedef QList<Legend *> LegendList;
65 
83 class KDCHART_EXPORT Chart : public QWidget
84 {
85  Q_OBJECT
86  // KD Chart 3.0: leading is inter-line distance of text. this here is MARGIN or SPACING.
87  Q_PROPERTY(int globalLeadingTop READ globalLeadingTop WRITE setGlobalLeadingTop)
88  Q_PROPERTY(int globalLeadingBottom READ globalLeadingBottom WRITE setGlobalLeadingBottom)
89  Q_PROPERTY(int globalLeadingLeft READ globalLeadingLeft WRITE setGlobalLeadingLeft)
90  Q_PROPERTY(int globalLeadingRight READ globalLeadingRight WRITE setGlobalLeadingRight)
91  Q_PROPERTY(bool useNewLayoutSystem READ useNewLayoutSystem WRITE setUseNewLayoutSystem)
92 
94 
95 public:
96  explicit Chart(QWidget *parent = nullptr);
97  ~Chart() override;
98 
107  bool useNewLayoutSystem() const;
108  void setUseNewLayoutSystem(bool value);
109 
122  void setFrameAttributes(const FrameAttributes &a);
123  FrameAttributes frameAttributes() const;
124 
138  void setBackgroundAttributes(const BackgroundAttributes &a);
139  BackgroundAttributes backgroundAttributes() const;
140 
148  AbstractCoordinatePlane *coordinatePlane();
149 
154  CoordinatePlaneList coordinatePlanes();
155 
162  void addCoordinatePlane(AbstractCoordinatePlane *plane);
163 
173  void insertCoordinatePlane(int index, AbstractCoordinatePlane *plane);
174 
192  void replaceCoordinatePlane(AbstractCoordinatePlane *plane,
193  AbstractCoordinatePlane *oldPlane = nullptr);
194 
203  void takeCoordinatePlane(AbstractCoordinatePlane *plane);
204 
210  void setCoordinatePlaneLayout(QLayout *layout);
211  QLayout *coordinatePlaneLayout();
212 
218  HeaderFooter *headerFooter();
219 
224  HeaderFooterList headerFooters();
225 
232  void addHeaderFooter(HeaderFooter *headerFooter);
233 
251  void replaceHeaderFooter(HeaderFooter *headerFooter,
252  HeaderFooter *oldHeaderFooter = nullptr);
253 
262  void takeHeaderFooter(HeaderFooter *headerFooter);
263 
268  Legend *legend();
269 
274  LegendList legends() const;
275 
282  void addLegend(Legend *legend);
283 
307  void replaceLegend(Legend *legend, Legend *oldLegend = nullptr);
308 
317  void takeLegend(Legend *legend);
318 
338  void setGlobalLeading(int left, int top, int right, int bottom);
339 
347  void setGlobalLeadingLeft(int leading);
348 
357  int globalLeadingLeft() const;
358 
366  void setGlobalLeadingTop(int leading);
367 
376  int globalLeadingTop() const;
377 
385  void setGlobalLeadingRight(int leading);
386 
395  int globalLeadingRight() const;
396 
404  void setGlobalLeadingBottom(int leading);
405 
414  int globalLeadingBottom() const;
415 
429  void paint(QPainter *painter, const QRect &target);
430 
431  void reLayoutFloatingLegends();
432 
433 Q_SIGNALS:
437 
438 protected:
442  /* reimp */ void resizeEvent(QResizeEvent *event) override;
443 
451  /* reimp */ void paintEvent(QPaintEvent *event) override;
452 
454  void mousePressEvent(QMouseEvent *event) override;
456  void mouseDoubleClickEvent(QMouseEvent *event) override;
458  void mouseMoveEvent(QMouseEvent *event) override;
460  void mouseReleaseEvent(QMouseEvent *event) override;
462  bool event(QEvent *event) override;
463 
464 private:
465  // TODO move this to the private class
466  void addLegendInternal(Legend *legend, bool setMeasures);
467 };
468 
469 // Here we have a few docu block to be included into the API documentation:
495 }
496 
497 #endif
Contains KDChart macros.
#define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET(X)
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
A chart with one or more diagrams.
Definition: KDChartChart.h:84
void propertiesChanged()
void finishedDrawing()
A set of attributes for frames around items.
A header or footer displaying text above or below charts.
Legend defines the interface for the legend drawing class.
Definition: KDChartLegend.h:44
QList< AbstractCoordinatePlane * > CoordinatePlaneList
Definition: KDChartChart.h:60
QList< HeaderFooter * > HeaderFooterList
Definition: KDChartChart.h:63
QList< Legend * > LegendList
Definition: KDChartChart.h:64

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated by doxygen 1.9.1