PDA

View Full Version : QwtScaleDraw/Widget: Minor Ticks and Step Sizes



bigjoeystud
18th September 2012, 20:11
I have three questions regarding the QwtScaleDraw:

1) Is there a way to label a minor tick?
2) Is there a way to get the current step size from QwtScaleDraw?
3) When I set the step size of the scale engine to something large, my plot is significantly larger than if I go by the defaults. I reason that this is due to the the Qwt plot canvas size being determined by how large the scale is. Is that right? How do I make it keep the usual size it calculates with the defaults, but still have a different number of labels?

I am overriding the QwtScaleDraw with my own stuff, but I am using the standard QwtScaleWidget.

Thanks,
Joey

Uwe
18th September 2012, 21:27
Is there a way to label a minor tick?
You might have layout issues, but beside this you can do the following:


virtual void YourScaleDraw::draw( QPainter *painter,
const QPalette& palette ) const
{
painter->setPen( palette.color( QPalette::Text ) );

const QList<double> ticks = scldiv().ticks( QwtScaleDiv::MinorTick );
for ( int i = 0; i < ticks.count(); i++ )
{
const double v = ticks[i];
if ( d_data->scldiv.contains( v ) )
drawLabel( painter, v );
}

QwtScaleDraw::draw( painter, palette );
}


Is there a way to get the current step size from QwtScaleDraw?
The step size is a parameter that is used for calculating the boundaries and ticks ( QwtScaleDiv ) of a scale, but the scale division might be built manually as well. So a QwtScaleDraw object has no step size !

But when a scale division has been calculated from a scale engine then delta between 2 major steps is usually the value you are looking for. Note, that when you have used a step size of 0 the step size has been calculated using the max major steps parameter instead.


When I set the step size of the scale engine to something large, my plot is significantly larger than if I go by the defaults.
No it isn't - the only effect I can imagine is because the scales are somehow aligned ( depending on the flags of the scale engine ) to multiples of the step size. But this leads to different ticks and boundaries, but not to larger scales.

Larger scales ( in widget coordinates ) might be because of having many major steps and tick labels, where space is needed.

HTH,
Uwe