KPlotting
12 class KPlotAxis::Private
18 , m_showTickLabels(false)
20 , m_labelFieldWidth(0)
28 bool m_showTickLabels : 1;
31 int m_labelFieldWidth;
37 : d(new Private(this))
54 d->m_visible = visible;
59 return d->m_showTickLabels;
64 d->m_showTickLabels = b;
79 d->m_labelFieldWidth = fieldWidth;
80 d->m_labelFmt = format;
81 d->m_labelPrec = precision;
86 return d->m_labelFieldWidth;
96 return d->m_labelPrec;
101 d->m_MajorTickMarks.clear();
102 d->m_MinorTickMarks.clear();
107 modf(log10(length), &pwr);
108 double s = pow(10.0, pwr);
109 double t = length / s;
111 double TickDistance = 0.0;
112 int NumMajorTicks = 0;
113 int NumMinorTicks = 0;
124 NumMajorTicks = int(t);
126 }
else if (t < 10.0) {
127 TickDistance = s * 2.0;
128 NumMajorTicks = int(t / 2.0);
130 }
else if (t < 20.0) {
131 TickDistance = s * 4.0;
132 NumMajorTicks = int(t / 4.0);
135 TickDistance = s * 5.0;
136 NumMajorTicks = int(t / 5.0);
145 double Tick0 = x0 - fmod(x0, TickDistance);
147 Tick0 -= TickDistance;
151 for (
int i = 0; i < NumMajorTicks + 2; i++) {
152 double xmaj = Tick0 + i * TickDistance;
153 if (xmaj >= x0 && xmaj <= x0 + length) {
154 d->m_MajorTickMarks.append(xmaj);
157 for (
int j = 1; j < NumMinorTicks; j++) {
158 double xmin = xmaj + TickDistance * j / NumMinorTicks;
159 if (xmin >= x0 && xmin <= x0 + length) {
160 d->m_MinorTickMarks.append(xmin);
168 if (d->m_labelFmt ==
't') {
172 while (val >= 24.0) {
177 int m = int(60. * (val - h));
181 return QStringLiteral(
"%1").arg(val, d->m_labelFieldWidth, d->m_labelFmt, d->m_labelPrec);
186 return d->m_MajorTickMarks;
191 return d->m_MinorTickMarks;
void setTickLabelsShown(bool b)
Determine whether tick labels will be drawn for this axis.
bool areTickLabelsShown() const
QList< double > majorTickMarks() const
char tickLabelFormat() const
void setLabel(const QString &label)
Sets the axis label.
void setVisible(bool visible)
Sets the "visible" property of the axis.
int tickLabelWidth() const
void setTickLabelFormat(char format='g', int fieldWidth=0, int precision=-1)
Set the display format for converting the double value of the tick's position to the QString for the ...
int tickLabelPrecision() const
QList< double > minorTickMarks() const
void setTickMarks(double x0, double length)
Determine the positions of major and minor tickmarks for this axis.
KPlotAxis(const QString &label=QString())
Constructor, constructs an axis with the label label.
QString tickLabel(double value) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 03:52:27 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.