PDA

View Full Version : How to know scale span in QwtScaleDraw class



pkj
14th September 2011, 07:41
I want to display labels on x-axis according to the x-axis span. So if x-axis goes from 0-1000 I want to show label in certain format. However, if x-axis span is from 0-10000, I want the format to be different. I know that I need to derive from QwtScaleDraw and reimplement QwtScaleDraw::label(double) function to change the label. However, I cannot find a way to know what is the span of x-axis so that I send the requisite text format type.
Is there a way to know it from this class? If not, is there a work-around?

Uwe
14th September 2011, 07:46
I know that I need to derive from QwtScaleDraw and reimplement QwtScaleDraw::label(double) function to change the label. However, I cannot find a way to know what is the span of x-axis so that I send the requisite text format type.

const QwtScaleDiv& QwtAbstractScaleDraw::scaleDiv() const;
Uwe

pkj
14th September 2011, 07:53
I think that QwtAbstractScaleDraw::scaleDiv().lowerBound and QwtAbstractScaleDraw::scaleDiv().upperBound() will give me the scales. But going through this thread (http://www.qtcentre.org/threads/43114-access-plot-rectangle-before-QwtScaleDraw-label-is-called) it seems that lower bound is first set, and then upperbound is set. So does that mean the first time this class is implicitly asked for label, since its upper and lower bounds are not set by that time, the logic to send text based on bounds will fail?