KChart

KChartPolarCoordinatePlane.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 KCHART_POLAR_COORDINATEPLANE_H
21 #define KCHART_POLAR_COORDINATEPLANE_H
22 
23 #include "KChartAbstractCoordinatePlane.h"
24 
25 namespace KChart {
26 
27  class Chart;
28  class PaintContext;
29 
30  /**
31  * @brief Polar coordinate plane
32  */
33  class KCHART_EXPORT PolarCoordinatePlane : public AbstractCoordinatePlane
34  {
35  Q_OBJECT
36 
37  Q_DISABLE_COPY( PolarCoordinatePlane )
38  KCHART_DECLARE_PRIVATE_DERIVED_PARENT( PolarCoordinatePlane, Chart* )
39 
40  public:
43 
44  explicit PolarCoordinatePlane ( Chart* parent = nullptr );
46 
47  void addDiagram ( AbstractDiagram* diagram ) override;
48 
49  const QPointF translate ( const QPointF& diagramPoint ) const override;
50  const QPointF translatePolar ( const QPointF& diagramPoint ) const;
51 
52  /** \brief Specify the rotation of the coordinate plane.
53  *
54  * In a pie diagram this indicates the position where the first pie starts,
55  * in a polar diagram it specifies the Zero position of the circular axis:
56  *
57  * \image html polar-plane-start-position.png "Illustration of \"start position\" property"
58  *
59  * \sa startPosition
60  */
61  void setStartPosition( qreal degrees );
62  /** Retrieve the rotation of the coordinate plane.
63  * \sa setStartPosition
64  */
65  qreal startPosition() const;
66 
67  qreal zoomFactorX() const override;
68  qreal zoomFactorY() const override;
69 
70  void setZoomFactors( qreal factorX, qreal factorY ) override;
71  void setZoomFactorX( qreal factor ) override;
72  void setZoomFactorY( qreal factor ) override;
73 
74  QPointF zoomCenter() const override;
75 
76  void setZoomCenter( const QPointF& center ) override;
77 
78  /**
79  * Set the attributes to be used for grid lines drawn in circular
80  * direction (or in sagittal direction, resp.).
81  *
82  * To disable circular grid painting, for example, your code should like this:
83  * \code
84  * GridAttributes ga = plane->gridAttributes( bool );
85  * ga.setGridVisible( false );
86  * plane-setGridAttributes( bool, ga );
87  * \endcode
88  *
89  * \note setGridAttributes overwrites the global attributes that
90  * were set by AbstractCoordinatePlane::setGlobalGridAttributes.
91  * To re-activate these global attributes you can call
92  * resetGridAttributes.
93  *
94  * \sa resetGridAttributes, gridAttributes
95  * \sa AbstractCoordinatePlane::setGlobalGridAttributes
96  * \sa hasOwnGridAttributes
97  */
98  void setGridAttributes( bool circular, const GridAttributes & );
99 
100  /**
101  * Reset the attributes to be used for grid lines drawn in circular
102  * direction (or in sagittal direction, resp.).
103  * By calling this method you specify that the global attributes set by
104  * AbstractCoordinatePlane::setGlobalGridAttributes be used.
105  *
106  * \sa setGridAttributes, gridAttributes
107  * \sa AbstractCoordinatePlane::globalGridAttributes
108  * \sa hasOwnGridAttributes
109  */
110  void resetGridAttributes( bool circular );
111 
112  /**
113  * \return The attributes used for grid lines drawn in circular
114  * direction (or in sagittal direction, resp.).
115  *
116  * \note This function always returns a valid set of grid attributes:
117  * If no special grid attributes were set for this direction
118  * the global attributes are returned, as returned by
119  * AbstractCoordinatePlane::globalGridAttributes.
120  *
121  * \sa setGridAttributes
122  * \sa resetGridAttributes
123  * \sa AbstractCoordinatePlane::globalGridAttributes
124  * \sa hasOwnGridAttributes
125  */
126  const GridAttributes gridAttributes( bool circular ) const;
127 
128  /**
129  * \return Returns whether the grid attributes have been set for the
130  * respective direction via setGridAttributes( bool circular ).
131  *
132  * If false, the grid will use the global attributes set
133  * by AbstractCoordinatePlane::globalGridAttributes (or the default
134  * attributes, resp.)
135  *
136  * \sa setGridAttributes
137  * \sa resetGridAttributes
138  * \sa AbstractCoordinatePlane::globalGridAttributes
139  */
140  bool hasOwnGridAttributes( bool circular ) const;
141 
142  qreal angleUnit() const;
143  qreal radiusUnit() const;
144 
145  /** reimpl */
146  void paint( QPainter* ) override;
147 
148  protected:
149  DataDimensionsList getDataDimensionsList() const override;
150  void paintEvent ( QPaintEvent* );
151  void resizeEvent ( QResizeEvent* );
152 
153  void layoutDiagrams() override;
154  protected Q_SLOTS:
155  void slotLayoutChanged( AbstractDiagram* diagram );
156  void adjustZoomAndRepaint();
157 
158  private:
159  void setHasOwnGridAttributes( bool circular, bool on );
160  };
161 
162 }
163 
164 #endif
AbstractDiagram defines the interface for diagram classes.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
A set of attributes controlling the appearance of grids.
A chart with one or more diagrams.
Definition: KChartChart.h:95
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:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.