PDA

View Full Version : Virtual axis ?



viridis
30th June 2008, 12:55
Hello,

I have multiple curves with very different min/max values. Thus, when I plot them, I have curves which are displayed as horizontal lines which is quite useless...

As Qwt does not support multiple Y axis (I have lot of curves so 2 axis is not sufficient),
what I want to do is to graduate the YAxis according to the selected curve in the legend (assuming that we can selected only one curve at a time) but display all the curve with their own axis which will be invisible.
This way, all curves will be displayed "maximized" and to know the value of a curve point, I will just have to selected the corresponding curve in the legend and then look at the YAxis.

I did not find a easy way to do this. As I a my own QwtData, I think about returning "faked" Y values according to the selected curve and the zoom rect, but there is maybe an better way to do this ?

Idealy I want a zoom which works on all curves, not only the selected one, but I can do without that.

Regards,

Uwe
30th June 2008, 20:10
Thw QwtScaleMaps are responsible for translating curve points into pixel positions. What you could try is to overload QwtPlotCurve::draw and manipulate the scale interval of the y-map individually for each curve.

Uwe

viridis
1st July 2008, 16:28
Thanks a lot, it works !

I have redefine :



void MyPlotCurve::draw (QPainter* painter, const QwtScaleMap& xMap, const QwtScaleMap& yMap, int from, int to) const
{
QwtScaleMap newYMap (yMap);
newYMap.setScaleInterval (minYValue (), maxYValue ());
QwtPlotCurve::draw (painter, xMap, newYMap, from, to);
}


and for each of my curves I do

myCurve->setItemAttribute (QwtPlotItem::AutoScale, false)

next, each time I want to change the grading to correspond to a curve, I just do

myPlot->setAxisScale (QwtPlot::yLeft, myCurve->minYValue (), myCurve->maxYValue ())