KChart

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

KDE's Doxygen guidelines are available online.