PDA

View Full Version : How can I tell which scale is used on an axis?



steve123
14th January 2011, 18:45
Hi! I've created a Qwt Plot with the ability to switch between log scale and arithmetic scale. I'd like to be able to exclude any 0s in the data when I am in log scale mode. I set the scale this way:


plot->setAxisScaleEngine(QwtPlot::yLeft, new QwtLog10ScaleEngine());

Then later on when data comes in, I need to filter out the zeros. How can I figure out which scale engine is currently in use? Thanks!

d_stranz
14th January 2011, 23:51
How do you switch? Using a push button or other GUI component that the user clicks? Connect to its clicked() signal and record which scale type is being used in some member variable.

The other, ugly way is to call plot->axisScaleEngine() and dynamic_cast<> it to determine the type.

Uwe
15th January 2011, 12:51
Or: plot->axisScaleEngine()->transformation()->type()

Uwe

d_stranz
15th January 2011, 15:21
Or: plot->axisScaleEngine()->transformation()->type()

I should have guessed there would be something like that... Next time, I should use a shovel with a longer handle so I can dig deeper. This one was too short - I could only go one level down in the method hierarchy. :o

Uwe
16th January 2011, 10:32
By the way: I don't have bad feelings about dynamic casts or consider them as ugly.

But for ( nowadays maybe obsolete ) memory reasons I take care, that Qwt doesn't need to be compiled with RTTI. So you can always expect to find a solution without dynamic casts.

Uwe