KD Chart 2  [rev.2.7]
KDChartChart.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef KDCHARTCHART_H
24 #define KDCHARTCHART_H
25 
26 #include <QWidget>
27 
28 #include "kdchart_export.h"
29 #include "KDChartGlobal.h"
30 
31 /*
32 Simplified(*) overview of object ownership in a chart:
33 
34  Chart is-a QWidget
35  |
36  n CoordinatePlanes is-a AbstractArea is-a AbstractLayoutItem is-a QLayoutItem
37  |
38  n Diagrams is-a QAbstractItemView is-a QWidget
39  / | \
40  AbstractGrid | Axes (can be shared between diagrams) is-a AbstractArea is-a... QLayoutItem
41  (no base class) |
42  Legends is-a AbstractAreaWidget is-a QWidget
43 
44 (*) less important classes, including base classes, removed.
45 
46 
47 Layout rules:
48 
49 In principle, every size or existence change in one of the objects listed above must be propagated
50 to all other objects. This could change their size.
51 There are also settings changes that invalidate the size of other components, where the size changes
52 are detected and propagated.
53 
54 
55 Painting call tree (simplified):
56 
57 Chart::paint() (from users) / paintEvent() (from framework)
58 ChartPrivate::paintAll()-----------------------------------------------\
59 CoordinatePlane::paintAll() (from AbstractArea)--------\ Axis::paintAll()-\
60 CoordinatePlane::paint() (from AbstractLayoutItem) Grid::drawGrid() Axis::paint()
61 Diagram::paint( PaintContext* paintContext )
62 
63 Note that grids are painted from the coordinate plane, not from the diagram as ownership would suggest.
64 
65 */
66 
67 namespace KDChart {
68 
69  class BackgroundAttributes;
70  class FrameAttributes;
71  class AbstractDiagram;
72  class AbstractCoordinatePlane;
73  class HeaderFooter;
74  class Legend;
75 
79 
80 
98  class KDCHART_EXPORT Chart : public QWidget
99  {
100  Q_OBJECT
101  // KD Chart 3.0: leading is inter-line distance of text. this here is MARGIN or SPACING.
102  Q_PROPERTY( int globalLeadingTop READ globalLeadingTop WRITE setGlobalLeadingTop )
103  Q_PROPERTY( int globalLeadingBottom READ globalLeadingBottom WRITE setGlobalLeadingBottom )
104  Q_PROPERTY( int globalLeadingLeft READ globalLeadingLeft WRITE setGlobalLeadingLeft )
105  Q_PROPERTY( int globalLeadingRight READ globalLeadingRight WRITE setGlobalLeadingRight )
106  Q_PROPERTY( bool useNewLayoutSystem READ useNewLayoutSystem WRITE setUseNewLayoutSystem )
107 
109 
110  public:
111  explicit Chart ( QWidget* parent = 0 );
112  ~Chart() override;
113 
122  bool useNewLayoutSystem() const;
123  void setUseNewLayoutSystem( bool value );
124 
137  void setFrameAttributes( const FrameAttributes &a );
138  FrameAttributes frameAttributes() const;
139 
153  void setBackgroundAttributes( const BackgroundAttributes &a );
154  BackgroundAttributes backgroundAttributes() const;
155 
163  AbstractCoordinatePlane* coordinatePlane();
164 
169  CoordinatePlaneList coordinatePlanes();
170 
177  void addCoordinatePlane( AbstractCoordinatePlane* plane );
178 
188  void insertCoordinatePlane( int index, AbstractCoordinatePlane* plane );
189 
207  void replaceCoordinatePlane( AbstractCoordinatePlane* plane,
208  AbstractCoordinatePlane* oldPlane = 0 );
209 
218  void takeCoordinatePlane( AbstractCoordinatePlane* plane );
219 
225  void setCoordinatePlaneLayout( QLayout * layout );
226  QLayout* coordinatePlaneLayout();
227 
233  HeaderFooter* headerFooter();
234 
239  HeaderFooterList headerFooters();
240 
247  void addHeaderFooter( HeaderFooter* headerFooter );
248 
266  void replaceHeaderFooter ( HeaderFooter* headerFooter,
267  HeaderFooter* oldHeaderFooter = 0 );
268 
277  void takeHeaderFooter( HeaderFooter* headerFooter );
278 
283  Legend* legend();
284 
289  LegendList legends();
290 
297  void addLegend( Legend* legend );
298 
322  void replaceLegend ( Legend* legend, Legend* oldLegend = 0 );
323 
332  void takeLegend( Legend* legend );
333 
353  void setGlobalLeading( int left, int top, int right, int bottom );
354 
362  void setGlobalLeadingLeft( int leading );
363 
372  int globalLeadingLeft() const;
373 
381  void setGlobalLeadingTop( int leading );
382 
391  int globalLeadingTop() const;
392 
400  void setGlobalLeadingRight( int leading );
401 
410  int globalLeadingRight() const;
411 
419  void setGlobalLeadingBottom( int leading );
420 
429  int globalLeadingBottom() const;
430 
444  void paint( QPainter* painter, const QRect& target );
445 
446  void reLayoutFloatingLegends();
447 
448  Q_SIGNALS:
450  void propertiesChanged();
451  void finishedDrawing();
452 
453  protected:
457  /* reimp */ void resizeEvent ( QResizeEvent * event ) override;
458 
466  /* reimp */ void paintEvent( QPaintEvent* event ) override;
467 
469  void mousePressEvent( QMouseEvent* event ) override;
471  void mouseDoubleClickEvent( QMouseEvent* event ) override;
473  void mouseMoveEvent( QMouseEvent* event ) override;
475  void mouseReleaseEvent( QMouseEvent* event ) override;
477  bool event( QEvent* event ) override;
478 
479  private:
480  // TODO move this to the private class
481  void addLegendInternal( Legend *legend, bool setMeasures );
482  };
483 
484 // Here we have a few docu block to be included into the API documentation:
510 }
576 #endif
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
A chart with one or more diagrams.
Definition: KDChartChart.h:98
#define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET(X)
Definition: KDChartGlobal.h:93
A set of attributes for frames around items.
Legend defines the interface for the legend drawing class.
Definition: KDChartLegend.h:55
Class only listed here to document inheritance of some KDChart classes.
QList< Legend * > LegendList
Definition: KDChartChart.h:78
QList< HeaderFooter * > HeaderFooterList
Definition: KDChartChart.h:77
QList< AbstractCoordinatePlane * > CoordinatePlaneList
Definition: KDChartChart.h:74
Set of attributes usable for background pixmaps.

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/