PDA

View Full Version : QwtPlot radians to degrees transformation



mjfj
8th June 2010, 11:28
Hello,
I am plotting a QwtPlotCurve in a QwtPlot that displays values for an angle from which the input data is in radians. However, I'd like to show the angle values in degrees.
I've looked into QwtLinearScaleEngine to see if I could do something with transformation. I see that it implements the transformation() function that returns a QwtScaleTransformation class. The xForm function seems to do what I need. Basically it needs to convert the range -3.14 - 3.14 to -180 - 180, so I think the QwtScaleTransformation class can be used for this. But how do I pass these ranges to the QwtLinearScaleEngine, so that it uses this transformation?

Or am I looking in the wrong direction and should I do this differently?

Thanks in advance,
Michiel

amoswood
8th June 2010, 17:20
Or am I looking in the wrong direction and should I do this differently?
You should be looking in the direction of the QwtScaleDraw class.


class DegreeScaleDraw : public QwtScaleDraw
{
public:
DegreeScaleDraw();

QwtText label(double radians) const
{
return QString("%1").arg(radians * (180.0 / PI), 0, 'f', 2)
}
};
Amos

mjfj
9th June 2010, 09:39
Thanks, this worked!