KPlotting

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

KDE's Doxygen guidelines are available online.