KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
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/*
20Simplified(*) 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
34Layout rules:
35
36In principle, every size or existence change in one of the objects listed above must be propagated
37to all other objects. This could change their size.
38There are also settings changes that invalidate the size of other components, where the size changes
39are detected and propagated.
40
41Painting call tree (simplified):
42
43Chart::paint() (from users) / paintEvent() (from framework)
44ChartPrivate::paintAll()-----------------------------------------------\
45CoordinatePlane::paintAll() (from AbstractArea)--------\ Axis::paintAll()-\
46CoordinatePlane::paint() (from AbstractLayoutItem) Grid::drawGrid() Axis::paint()
47Diagram::paint( PaintContext* paintContext )
48
49Note that grids are painted from the coordinate plane, not from the diagram as ownership would suggest.
50
51*/
52
53namespace KDChart {
54
55class BackgroundAttributes;
56class FrameAttributes;
57class AbstractDiagram;
58class AbstractCoordinatePlane;
59class HeaderFooter;
60class Legend;
61
65
83class 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
95public:
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
433Q_SIGNALS:
435 void propertiesChanged();
436 void finishedDrawing();
437
438protected:
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
464private:
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.
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.
QList< AbstractCoordinatePlane * > CoordinatePlaneList
QList< HeaderFooter * > HeaderFooterList
QList< Legend * > LegendList

© 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 on Wed May 1 2024 00:01:10 for KD Chart API Documentation by doxygen 1.9.8