26class KPlotAxis::Private
32 , m_showTickLabels( false )
34 , m_labelFieldWidth( 0 )
42 bool m_showTickLabels : 1;
45 int m_labelFieldWidth;
51 : d( new Private( this ) )
68 d->m_visible = visible;
73 return d->m_showTickLabels;
78 d->m_showTickLabels = b;
93 d->m_labelFieldWidth = fieldWidth;
94 d->m_labelFmt = format;
95 d->m_labelPrec = precision;
100 return d->m_labelFieldWidth;
105 return d->m_labelFmt;
110 return d->m_labelPrec;
114 d->m_MajorTickMarks.clear();
115 d->m_MinorTickMarks.clear();
120 modf( log10( length ), &pwr );
121 double s = pow( 10.0, pwr );
122 double t = length / s;
124 double TickDistance = 0.0;
125 int NumMajorTicks = 0;
126 int NumMinorTicks = 0;
137 NumMajorTicks = int( t );
139 }
else if ( t < 10.0 ) {
140 TickDistance = s * 2.0;
141 NumMajorTicks = int( t / 2.0 );
143 }
else if ( t < 20.0 ) {
144 TickDistance = s * 4.0;
145 NumMajorTicks = int( t / 4.0 );
148 TickDistance = s * 5.0;
149 NumMajorTicks = int( t / 5.0 );
158 double Tick0 = x0 - fmod( x0, TickDistance );
160 Tick0 -= TickDistance;
164 for (
int i=0; i<NumMajorTicks+1; i++ ) {
165 double xmaj = Tick0 + i*TickDistance;
166 if ( xmaj >= x0 && xmaj <= x0 + length ) {
167 d->m_MajorTickMarks.append( xmaj );
170 for (
int j=1; j<NumMinorTicks; j++ ) {
171 double xmin = xmaj + TickDistance*j/NumMinorTicks;
172 if ( xmin >= x0 && xmin <= x0 + length )
173 d->m_MinorTickMarks.append( xmin );
179 if ( d->m_labelFmt ==
't' ) {
180 while ( val < 0.0 ) val += 24.0;
181 while ( val >= 24.0 ) val -= 24.0;
184 int m = int( 60.*(val - h) );
185 return QString(
"%1:%2" ).arg( h, 2, 10, QLatin1Char(
'0') ).arg( m, 2, 10, QLatin1Char(
'0') );
188 return QString(
"%1" ).arg( val, d->m_labelFieldWidth, d->m_labelFmt, d->m_labelPrec );
193 return d->m_MajorTickMarks;
198 return d->m_MinorTickMarks;
QList< double > majorTickMarks() const
void setTickMarks(double x0, double length)
Determine the positions of major and minor tickmarks for this axis.
int tickLabelPrecision() const
char tickLabelFormat() const
void setLabel(const QString &label)
Sets the axis label.
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 ...
KPlotAxis(const QString &label=QString())
Constructor, constructs an axis with the label label.
void setTickLabelsShown(bool b)
Determine whether tick labels will be drawn for this axis.
void setVisible(bool visible)
Sets the "visible" property of the axis.
bool areTickLabelsShown() const
QList< double > minorTickMarks() const
int tickLabelWidth() const
QString tickLabel(double value) const