KPlotting

kplotaxis.h
1 /* -*- C++ -*-
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2005 Andreas Nicolai <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KPLOTAXIS_H
9 #define KPLOTAXIS_H
10 
11 #include <kplotting_export.h>
12 
13 #include <QList>
14 #include <QString>
15 
16 /**
17  * @short Axis for KPlotWidget
18  *
19  * Contains all data for drawing an axis including format specification axis labels.
20  *
21  * @author Andreas Nicolai
22  * @version 1.0
23  */
24 class KPLOTTING_EXPORT KPlotAxis
25 {
26 public:
27  /**
28  * Constructor, constructs an axis with the label @p label.
29  */
30  explicit KPlotAxis(const QString &label = QString());
31 
32  /**
33  * Destructor.
34  */
35  ~KPlotAxis();
36 
37  /**
38  * @return whether the axis is visible or not
39  */
40  bool isVisible() const;
41 
42  /**
43  * Sets the "visible" property of the axis.
44  * @param visible if true, this axis will be drawn on the KPlotWidget
45  */
46  void setVisible(bool visible);
47 
48  /**
49  * @return whether tick labels will be drawn for this axis
50  */
51  bool areTickLabelsShown() const;
52 
53  /**
54  * Determine whether tick labels will be drawn for this axis.
55  * @param b if true, tick labels will be drawn.
56  */
57  void setTickLabelsShown(bool b);
58 
59  /**
60  * Sets the axis label.
61  * Set the label to an empty string to omit the axis label.
62  * @param label a string describing the data plotted on the axis.
63  */
64  void setLabel(const QString &label);
65 
66  /**
67  * @return the label string for this axis
68  */
69  QString label() const;
70 
71  /**
72  * @return the ticklabel string for the given value, rendered according
73  * to the current format specification.
74  * @param the value to be rendered as a tick label.
75  * @sa setTickLabelFormat()
76  */
77  QString tickLabel(double value) const;
78 
79  /**
80  * Set the display format for converting the double value of the
81  * tick's position to the QString for the tick label.
82  *
83  * Normally, the format character is one of 'e', 'E', 'f', 'g', or 'G'
84  * (see the documentation for QString::arg(double) for details).
85  *
86  * In addition, it is possible to set the format character to 't';
87  * in this case the tickmark value is interpreted as a time in hours,
88  * and the ticklabel string will be in "hh:mm" clock format.
89  * Note that when the format character is 't', the fieldWidth and prec
90  * values are ignored.
91  *
92  * @param format the format specification character
93  * @param fieldWidth the number of characters in the output string.
94  * If set to 0, the string will be as wide as it needs to be to fully
95  * render the value.
96  * @param precision the number of characters following the decimal point.
97  */
98  void setTickLabelFormat(char format = 'g', int fieldWidth = 0, int precision = -1);
99 
100  /**
101  * @return the field width of the tick labels
102  */
103  int tickLabelWidth() const;
104 
105  /**
106  * @return the number format of the tick labels
107  */
108  char tickLabelFormat() const;
109 
110  /**
111  * @return the number precision of the tick labels
112  */
113  int tickLabelPrecision() const;
114 
115  /**
116  * Determine the positions of major and minor tickmarks for this axis.
117  * @note this function is called by KPlotWidget whenever the plot's
118  * limits are modified.
119  * @param x0 the minimum data coordinate of the axis.
120  * @param length the range covered by the axis, in data units.
121  * @sa majorTickMarks()
122  * @sa minorTickMarks()
123  */
124  void setTickMarks(double x0, double length);
125 
126  /**
127  * @return the list of coordinates of the major tickmarks for this axis
128  * @note the positions of tickmarks are automatically computed by setTickMarks().
129  * @sa setTickMarks()
130  * @sa minorTickMarks()
131  */
132  QList<double> majorTickMarks() const;
133 
134  /**
135  * @return the list with the minor tickmarks
136  * @note the positions of tickmarks are automatically computed by setTickMarks().
137  * @sa setTickMarks()
138  * @sa majorTickMarks()
139  */
140  QList<double> minorTickMarks() const;
141 
142 private:
143  class Private;
144  Private *const d;
145 
146  Q_DISABLE_COPY(KPlotAxis)
147 };
148 
149 #endif // KPLOTAXIS_H
Axis for KPlotWidget.
Definition: kplotaxis.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Nov 28 2023 03:52:13 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.