PDA

View Full Version : Knowing pixel distance between consecutive ticks



kalos80
16th October 2008, 17:50
Hi all,

is there a way to know the distance in pixels between two ticks?

Thank you very much for your help!

Uwe
17th October 2008, 09:44
With plot->axisScaleDiv(...) you find the list of all ticks. With plot_canvasMap(...) you can translate them into pixel positions.

Uwe

kalos80
20th October 2008, 17:08
Uwe, thank you very much for your hints.

frankiefrank
25th January 2011, 19:00
Could anyone please expand on this? I can't understand how to use the QwtScaleMap object to perform said conversion.

d_stranz
29th January 2011, 20:33
Could anyone please expand on this? I can't understand how to use the QwtScaleMap object to perform said conversion.



QwtScaleMap * scaleMap = myPlot->canvasMap( QwtPlot::xBottom );
int distance_in_pixels = scaleMap->transform( xTick2 ) - scaleMap->transform( xTick1 );


(From Qwt 5.2; may be different in 6.0 but probably not).

barrygp
5th October 2012, 19:38
is there a way to define or set the distance in pixels between consecutive ticks?

Uwe
6th October 2012, 10:50
is there a way to define or set the distance in pixels between consecutive ticks?
Unfortunately - no.

Uwe

barrygp
8th October 2012, 14:44
Thanks. If not precise pixels then, is there anyway to change the distance or relative distance between consecutive ticks?

Uwe
8th October 2012, 15:22
Well the ticks even might not be equidistant because of rounding up/down to the closest pixel position ( doubles -> integers ! ).

In general the ticks are related to scale values - never to widget coordinates. So you have to set up an event filter for the plot canvas adjusting the ticks somehow to the geometry of the canvas.

Uwe

barrygp
8th October 2012, 19:41
Thanks Uwe, that makes sense. I used QwtPlot::setAxisScale() with a defined step number and seems I may be able to work with that.

Uwe
8th October 2012, 20:18
Don't know if it helps, but maybe QwtPlotRescaler offers something useful for you.
At least it does something similar: QwtPlot::setAxisScale according to resize events of the canvas.

Uwe