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
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:
Code:
Index: src/qwt_scale_widget.cpp
===================================================================
--- src/qwt_scale_widget.cpp (revision 2242)
+++ src/qwt_scale_widget.cpp (working copy)
@@ -670,6 +670,20 @@
}
}
+ if ( d_data->layoutFlags & TitleHorizontal )
+ {
+ {
+ angle += 90;
+ r.setRect( r.x (), r.y () - r.width (), r.height (), r.width () );
+ }
+ {
+ angle -= 90;
+ r.setRect( d_data->titleOffset, r.y (), r.height (), r.width () );
+ }
+ }
+
painter->save();
painter->setFont( font() );
painter
->setPen
( palette
().
color( QPalette::Text ) );
@@ -747,7 +761,8 @@
{
- return qCeil( d_data->title.heightForWidth( width, font() ) );
+ if ( d_data->layoutFlags & TitleHorizontal ) return qCeil ( d_data->title.textSize ().width () );
+ else return qCeil( d_data->title.heightForWidth( width, font() ) );
}
/*!
Index: src/qwt_scale_widget.h
===================================================================
--- src/qwt_scale_widget.h (revision 2242)
+++ src/qwt_scale_widget.h (working copy)
@@ -42,7 +42,8 @@
The title of vertical scales is painted from top to bottom.
Otherwise it is painted from bottom to top.
*/
- TitleInverted = 1
+ TitleInverted = 1,
+ TitleHorizontal = 2
};
//! Layout flags of the title
Re: Rotating Y Axis Title
Please upload your patch at sourceforge - otherwise it might get lost.
Uwe