Results 1 to 4 of 4

Thread: Rotating Y Axis Title

  1. #1
    Join Date
    Sep 2007
    Posts
    61
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Rotating Y Axis Title

    Hello Uwe,

    Is it possible to add an interface to rotating the title of an axis?

    Right now, the value is hard coded based on which axis it is. It would be nice to have a method where we could change that angle. Right now, I'd like to just rotate the title by 90, but I suppose there be some value to having any angle in there.

    Or is there another way to do it? Or is there a better reason not to do it?

    I could subclass QwtScaleWidget and overload drawTitle, but seems like a method might be nice.

    Thanks,
    Joey

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Rotating Y Axis Title

    There is already a feature request ( http://sourceforge.net/p/qwt/feature-requests/38 ) but I have not scheduled anything so far.
    I remember there once was another request for rotating the axis title by 180° ( according to some DIN norm left and right axis need to be in the same orientation ), but I never heard from a use case, where a random angle is useful.

    Uwe

  3. #3
    Join Date
    Sep 2007
    Posts
    61
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Rotating Y Axis Title

    Yes, I suppose there really isn't a use case for any angle, but it seemed like just changing the angle in drawTitle would be enough. Unfortunately, that wasn't the case!

    Anyway, here's a start for just rotating the title horizontal in case anyone else needs it. Would be nice to have at least this in the distribution:

    Qt Code:
    1. Index: src/qwt_scale_widget.cpp
    2. ===================================================================
    3. --- src/qwt_scale_widget.cpp (revision 2242)
    4. +++ src/qwt_scale_widget.cpp (working copy)
    5. @@ -670,6 +670,20 @@
    6. }
    7. }
    8.  
    9. + if ( d_data->layoutFlags & TitleHorizontal )
    10. + {
    11. + if ( align == QwtScaleDraw::LeftScale )
    12. + {
    13. + angle += 90;
    14. + r.setRect( r.x (), r.y () - r.width (), r.height (), r.width () );
    15. + }
    16. + else if ( align == QwtScaleDraw::RightScale )
    17. + {
    18. + angle -= 90;
    19. + r.setRect( d_data->titleOffset, r.y (), r.height (), r.width () );
    20. + }
    21. + }
    22. +
    23. painter->save();
    24. painter->setFont( font() );
    25. painter->setPen( palette().color( QPalette::Text ) );
    26. @@ -747,7 +761,8 @@
    27.  
    28. int QwtScaleWidget::titleHeightForWidth( int width ) const
    29. {
    30. - return qCeil( d_data->title.heightForWidth( width, font() ) );
    31. + if ( d_data->layoutFlags & TitleHorizontal ) return qCeil ( d_data->title.textSize ().width () );
    32. + else return qCeil( d_data->title.heightForWidth( width, font() ) );
    33. }
    34.  
    35. /*!
    36. Index: src/qwt_scale_widget.h
    37. ===================================================================
    38. --- src/qwt_scale_widget.h (revision 2242)
    39. +++ src/qwt_scale_widget.h (working copy)
    40. @@ -42,7 +42,8 @@
    41.   The title of vertical scales is painted from top to bottom.
    42.   Otherwise it is painted from bottom to top.
    43.   */
    44. - TitleInverted = 1
    45. + TitleInverted = 1,
    46. + TitleHorizontal = 2
    47. };
    48.  
    49. //! Layout flags of the title
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Rotating Y Axis Title

    Please upload your patch at sourceforge - otherwise it might get lost.

    Uwe

Similar Threads

  1. QwtPolar - Title for Radius Axis
    By Crowley in forum Qwt
    Replies: 3
    Last Post: 23rd May 2014, 07:14
  2. How to rotate right axis title?
    By beckjoh in forum Qwt
    Replies: 2
    Last Post: 6th May 2014, 07:12
  3. Axis Title to axis label alignment
    By ROCKSTAR in forum Qwt
    Replies: 0
    Last Post: 5th February 2014, 12:47
  4. how rotate axis title
    By Andell in forum Qwt
    Replies: 2
    Last Post: 1st October 2012, 00:11
  5. Set axis title on the right side
    By pospiech in forum Qwt
    Replies: 1
    Last Post: 14th March 2008, 07:26

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.