KChart

KChartCartesianAxis.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 KCHARTCARTESIANAXIS_H
10#define KCHARTCARTESIANAXIS_H
11
12#include <QList>
13
14#include "KChartAbstractAxis.h"
15
16namespace KChart {
17
19
20 /**
21 * The class for cartesian axes.
22 *
23 * For being useful, axes need to be assigned to a diagram, see
24 * AbstractCartesianDiagram::addAxis and AbstractCartesianDiagram::takeAxis.
25 *
26 * \sa PolarAxis, AbstractCartesianDiagram
27 */
28 class KCHART_EXPORT CartesianAxis : public AbstractAxis
29 {
31
32 Q_DISABLE_COPY( CartesianAxis )
33 KCHART_DECLARE_PRIVATE_DERIVED_PARENT( CartesianAxis, AbstractDiagram* )
34
35 public:
36 enum Position {
37 Bottom,
38 Top,
39 Right,
40 Left
41 };
42 Q_ENUM(Position)
43
44 /**
45 * C'tor of the class for cartesian axes.
46 *
47 * \note If you pass a null parent to the constructor, you need to call
48 * your diagram's addAxis function to add your axis to the diagram.
49 * Otherwise there is no need to call addAxis, since the constructor
50 * does it already.
51 *
52 * \sa AbstractCartesianDiagram::addAxis
53 */
54 explicit CartesianAxis ( AbstractCartesianDiagram* diagram = nullptr );
55 ~CartesianAxis() override;
56
57 /**
58 * Returns true if both axes have the same settings.
59 */
60 bool compare( const CartesianAxis* other ) const;
61
62 /** reimpl */
63 void paint( QPainter* ) override;
64 /** reimpl */
65 void paintCtx( PaintContext* ) override;
66
67 /**
68 * Sets the optional text displayed as axis title.
69 */
70 void setTitleText( const QString& text );
71 QString titleText() const;
72
73 /**
74 * \deprecated
75 * Sets the spacing between the title and the diagram.
76 * Be aware that setting this value can lead to
77 * collisions between axis labels and the title
78 */
79 void setTitleSpace( qreal value );
80 /// \deprecated
81 qreal titleSpace() const;
82
83 /// \deprecated \brief use setTitleTextAttributes() instead
84 void setTitleSize(qreal value);
85 /// \deprecated
86 qreal titleSize() const;
87
88 void setTitleTextAttributes( const TextAttributes &a );
89 /**
90 * Returns the text attributes that will be used for displaying the
91 * title text.
92 * This is either the text attributes as specified by setTitleTextAttributes,
93 * or (if setTitleTextAttributes() was not called) the default text attributes.
94 * \sa resetTitleTextAttributes, hasDefaultTitleTextAttributes
95 */
97 /**
98 * Reset the title text attributes to the built-in default:
99 *
100 * Same font and pen as AbstractAxis::textAttributes()
101 * and 1.5 times their size.
102 */
104 bool hasDefaultTitleTextAttributes() const;
105
106 virtual void setPosition ( Position p );
107#if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
108 virtual const Position position () const;
109#else
110 virtual Position position () const;
111#endif
112
113 virtual void layoutPlanes();
114
115 virtual bool isAbscissa() const;
116 virtual bool isOrdinate() const;
117
118 /**
119 * Sets the axis annotations to \a annotations.
120 * Annotations are a QMap of qreals and QStrings defining special
121 * markers and their position.
122 * If you use annotations, the normal ticks and values will be invisible.
123 * To unset the annotations, pass an empty QMap.
124 */
126 /**
127 * Returns the currently set axis annotations.
128 */
130
131 /**
132 * Sets custom ticks on the axis.
133 * Ticks are a QList of qreals defining their special position.
134 */
135 void setCustomTicks( const QList< qreal >& ticksPostions );
136 /**
137 * Returns the currently set custom ticks on the axis.
138 */
140
141 /**
142 * Sets the length of custom ticks on the axis.
143 */
144 void setCustomTickLength(int value);
145 /**
146 * Returns the length of custom ticks on the axis.
147 */
148 int customTickLength() const;
149
150 /** pure virtual in QLayoutItem */
151 bool isEmpty() const override;
152 /** pure virtual in QLayoutItem */
153 Qt::Orientations expandingDirections() const override;
154 /** pure virtual in QLayoutItem */
155 QSize maximumSize() const override;
156 /** pure virtual in QLayoutItem */
157 QSize minimumSize() const override;
158 /** pure virtual in QLayoutItem */
159 QSize sizeHint() const override;
160 /** pure virtual in QLayoutItem */
161 void setGeometry( const QRect& r ) override;
162 /** pure virtual in QLayoutItem */
163 QRect geometry() const override;
164
165 virtual int tickLength( bool subUnitTicks = false ) const;
166
167 public Q_SLOTS:
168 void setCachedSizeDirty() const;
169
170 private Q_SLOTS:
171 void slotCoordinateSystemChanged();
172 };
173
174 typedef QList<CartesianAxis*> CartesianAxisList;
175}
176
177#if !defined(QT_NO_DEBUG_STREAM)
178KCHART_EXPORT QDebug operator<<(QDebug dbg, KChart::CartesianAxis::Position pos);
179#endif
180
181#endif
Base class for diagrams based on a cartesian coordianate system.
AbstractDiagram defines the interface for diagram classes.
void resetTitleTextAttributes()
Reset the title text attributes to the built-in default:
bool isEmpty() const override
pure virtual in QLayoutItem
void setCustomTickLength(int value)
Sets the length of custom ticks on the axis.
void setGeometry(const QRect &r) override
pure virtual in QLayoutItem
QSize maximumSize() const override
pure virtual in QLayoutItem
QList< qreal > customTicks() const
Returns the currently set custom ticks on the axis.
QMap< qreal, QString > annotations() const
Returns the currently set axis annotations.
CartesianAxis(AbstractCartesianDiagram *diagram=nullptr)
C'tor of the class for cartesian axes.
int customTickLength() const
Returns the length of custom ticks on the axis.
void paintCtx(PaintContext *) override
reimpl
QSize sizeHint() const override
pure virtual in QLayoutItem
QSize minimumSize() const override
pure virtual in QLayoutItem
Qt::Orientations expandingDirections() const override
pure virtual in QLayoutItem
bool compare(const CartesianAxis *other) const
Returns true if both axes have the same settings.
QRect geometry() const override
pure virtual in QLayoutItem
TextAttributes titleTextAttributes() const
Returns the text attributes that will be used for displaying the title text.
void paint(QPainter *) override
reimpl
void setTitleText(const QString &text)
Sets the optional text displayed as axis title.
void setCustomTicks(const QList< qreal > &ticksPostions)
Sets custom ticks on the axis.
void setAnnotations(const QMap< qreal, QString > &annotations)
Sets the axis annotations to annotations.
void setTitleSpace(qreal value)
void setTitleSize(qreal value)
use setTitleTextAttributes() instead
Stores information about painting diagrams.
A set of text attributes.
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
typedef Orientations
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:56:24 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.