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 
16 namespace KChart {
17 
18  class AbstractCartesianDiagram;
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  {
30  Q_OBJECT
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  */
96  TextAttributes titleTextAttributes() const;
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  */
103  void resetTitleTextAttributes();
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  */
125  void setAnnotations( const QMap< qreal, QString >& annotations );
126  /**
127  * Returns the currently set axis annotations.
128  */
129  QMap< qreal, QString > annotations() const;
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  */
139  QList< qreal > customTicks() const;
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 
175 }
176 
177 #if !defined(QT_NO_DEBUG_STREAM)
178 KCHART_EXPORT QDebug operator<<(QDebug dbg, KChart::CartesianAxis::Position pos);
179 #endif
180 
181 #endif
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Stores information about painting diagrams.
typedef Orientations
The class for cartesian axes.
AbstractDiagram defines the interface for diagram classes.
The base class for axes.
A set of text attributes.
Base class for diagrams based on a cartesian coordianate system.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 23 2023 03:54:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.