correct steps to display x axis labels on specific x axis points
Brought to you by:
rathmann
|
From: Giacomo <gia...@el...> - 2011-06-27 15:04:28
|
Hi to all.
Using Qwt 5.2.0, I reimplemented QwtScaleEngine's divideScale() method
as follows:
QwtScaleDiv AxisScaleEngine::divideScale (double x1, double x2, int
numMajorSteps, int numMinorSteps, double stepSize) const
{
/* m_valueList is a QList<double> containing the x axis points on which
I want to place MajorTicks and labels
*/
QwtScaleDiv scaleDiv;
scaleDiv.setInterval(x1, x2);
scaleDiv.setTicks(QwtScaleDiv::MajorTick, m_valueList);
return scaleDiv;
}
and called setScaleEngine on the plot with an instance of
AxisScaleEngine.
Then, in order to have the correct labels under the x axis, i
reimplemented
virtual QwtText label(double v) const
method of QwtScaleDraw, returning the correct label corresponding to the
values in m_valueList above mentioned.
I installed my ScaleDraw on the plot with setScaleDraw() , after
setScaleEngine()
The result is that AxisScaleEngine::divideScale() is correctly invoked
and the plot grid shows the grid in correspondance of the m_valueList
points.
But no labels nor ticks are drawn on the x axis scale.
Reimplementing ScaleDraw::drawLabel (QPainter *p, double val) I see that
it isn't called at all...
so there must be something wrong with what I am doing..
My expected behaviour was that AxisScaleEngine was used to divide the
interval and to know where to put the labels, then QwtScaleDraw would
have drawn the ticks in the correct place and the labels with the text
provided by the label() method.
Thanks in advance for any help.
Giacomo S.
Elettra - Synchrotron Radiation Facility
Trieste, Italy.
|