Results 1 to 3 of 3

Thread: QwtPlot radians to degrees transformation

  1. #1
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QwtPlot radians to degrees transformation

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot radians to degrees transformation

    Quote Originally Posted by mjfj View Post
    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.

    Qt Code:
    1. class DegreeScaleDraw : public QwtScaleDraw
    2. {
    3. public:
    4. DegreeScaleDraw();
    5.  
    6. QwtText label(double radians) const
    7. {
    8. return QString("%1").arg(radians * (180.0 / PI), 0, 'f', 2)
    9. }
    10. };
    To copy to clipboard, switch view to plain text mode 
    Amos
    Last edited by amoswood; 8th June 2010 at 17:46.

  3. The following user says thank you to amoswood for this useful post:

    mjfj (9th June 2010)

  4. #3
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: QwtPlot radians to degrees transformation

    Thanks, this worked!

Similar Threads

  1. Rotate push button by 90 degrees
    By sasi in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2009, 12:26
  2. Replies: 6
    Last Post: 14th May 2009, 12:02
  3. QPointF transformation
    By dreamer in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2008, 10:11
  4. how can QPixmap transformation to QBitmap faster
    By duduqq in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2008, 04:44
  5. QGraphicsView coordinates transformation
    By mtribaldos in forum Newbie
    Replies: 1
    Last Post: 6th February 2008, 17:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.