KChart

KChartAbstractCartesianDiagram.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 KCHARTABSTRACTCARTESIANDIAGRAM_H
21 #define KCHARTABSTRACTCARTESIANDIAGRAM_H
22 
23 #include "KChartCartesianCoordinatePlane.h"
24 #include "KChartAbstractDiagram.h"
25 #include "KChartCartesianAxis.h"
26 
27 namespace KChart {
28 
29  class GridAttributes;
30 
31  /**
32  * @brief Base class for diagrams based on a cartesian coordianate system.
33  *
34  * The AbstractCartesianDiagram interface adds those elements that are
35  * specific to diagrams based on a cartesian coordinate system to the
36  * basic AbstractDiagram interface.
37  */
38  class KCHART_EXPORT AbstractCartesianDiagram : public AbstractDiagram
39  {
40  Q_OBJECT
41  Q_DISABLE_COPY( AbstractCartesianDiagram )
42  KCHART_DECLARE_DERIVED_DIAGRAM( AbstractCartesianDiagram, CartesianCoordinatePlane )
43 
44  public:
45  explicit AbstractCartesianDiagram( QWidget* parent = nullptr, CartesianCoordinatePlane* plane = nullptr );
46  virtual ~AbstractCartesianDiagram();
47 
48  /**
49  * Returns true if both diagrams have the same settings.
50  */
51  bool compare( const AbstractCartesianDiagram* other ) const;
52 
53 #if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
54  virtual const int numberOfAbscissaSegments() const = 0;
55  virtual const int numberOfOrdinateSegments() const = 0;
56 #else
57  virtual int numberOfAbscissaSegments() const = 0;
58  virtual int numberOfOrdinateSegments() const = 0;
59 #endif
60  /**
61  * Add the axis to the diagram. The diagram takes ownership of the axis
62  * and will delete it.
63  *
64  * To gain back ownership (e.g. for assigning the axis to another diagram)
65  * use the takeAxis method, before calling addAxis on the other diagram.
66  *
67  * \sa takeAxis
68  */
69  virtual void addAxis( CartesianAxis * axis );
70  /**
71  * Removes the axis from the diagram, without deleting it.
72  *
73  * The diagram no longer owns the axis, so it is
74  * the caller's responsibility to delete the axis.
75  *
76  * \sa addAxis
77  */
78  virtual void takeAxis( CartesianAxis * axis );
79  /**
80  * @return a list of all axes added to the diagram
81  */
82  virtual KChart::CartesianAxisList axes() const;
83 
84  /**
85  * Triggers layouting of all coordinate planes on the current chart.
86  * Normally you don't need to call this method. It's handled automatically for you.
87  */
88  virtual void layoutPlanes();
89  /** \reimpl */
90  void setCoordinatePlane( AbstractCoordinatePlane* plane ) override;
91 
92  /**
93  * Makes this diagram use another diagram \a diagram as reference diagram with relative offset
94  * \a offset.
95  * To share cartesian axes between different diagrams there might be cases when you need that.
96  * Normally you don't.
97  * \sa examples/SharedAbscissa
98  */
99  virtual void setReferenceDiagram( AbstractCartesianDiagram* diagram, const QPointF& offset = QPointF() );
100  /**
101  * @return this diagram's reference diagram
102  * \sa setReferenceDiagram
103  */
104  virtual AbstractCartesianDiagram* referenceDiagram() const;
105  /**
106  * @return the relative offset of this diagram's reference diagram
107  * \sa setReferenceDiagram
108  */
109  virtual QPointF referenceDiagramOffset() const;
110 
111  /* reimpl */
112  void setModel( QAbstractItemModel* model ) override;
113  /* reimpl */
114  void setRootIndex( const QModelIndex& index ) override;
115  /* reimpl */
116  void setAttributesModel( AttributesModel* model ) override;
117 
118  protected Q_SLOTS:
119  void connectAttributesModel( AttributesModel* );
120 
121  protected:
122  /** @return the 3D item depth of the model index \a index */
123  virtual qreal threeDItemDepth( const QModelIndex& index ) const = 0;
124  /** @return the 3D item depth of the data set \a column */
125  virtual qreal threeDItemDepth( int column ) const = 0;
126  };
127 }
128 
129 #endif
Class only listed here to document inheritance of some KChart classes.
AbstractDiagram defines the interface for diagram classes.
The class for cartesian axes.
Base class for diagrams based on a cartesian coordianate system.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
A proxy model used for decorating data with attributes.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Apr 10 2021 22:36:39 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.