Re: Rendering a scale widget
Quote:
Originally Posted by
moijhd
... but I end up with issues with the font (the tick texts are very small) and the size (the color bar is not thick but I think I can manage this one).
QwtPlotRenderer::render() sets up a scaling for the painter, so that the drawing code can ignore the different paint device resolution. Looks like your scale is not rendered with this painter ?
Uwe
Re: Rendering a scale widget
I actually use the same painter but not the same QwtPlotRenderer which I destroy when I don't have anymore plots to render. Should I keep it alive until I render the scale ?
Re: Rendering a scale widget
This is the painter transformation you have to use for rendering your scale:
Code:
QTransform transform;
transform.scale(
double( painter->device()->logicalDpiX() ) / yourScale->logicalDpiX(),
double( painter->device()->logicalDpiY() ) / yourScale->logicalDpiY() );
Uwe
Re: Rendering a scale widget
Hi,
Could you be more specific about where to transform and how should I render ?
I have the scale widget. I create the QTransform. I apply it to the painter.
And then ? QwtPlotRenderer extracted code ? QWidget::render ? I tried those two but it did not render properly (or rendered nothing).
Since I added a title to the axis, the size of the text is also to fix.
Re: Rendering a scale widget
The axis has to be painted using scaleWidget->scaleDraw()->draw() scaleWidget->drawTitle() and scaleWidget->drawColorBar - like it is done inside of QwtPlotRenderer::renderScale().
But as all geometries are internally stored in screen metrics you have to set up the painter transformation ( see above ), that translates and scales them to paint device coordinates.
If your layout ( including the geometry where you want to render the extra scale ) is in paint device coordinates you have to use the inverted transformation to map the geometry of the scale into screen coordinates. Then you have to assign the transformation to the painter and call a method, that does something similar for your extra scale - like what is done in QwtPlotRenderer::renderScale(). Of course this method could have been won from stripping down the implementation of QwtPlotRenderer::renderScale().
Uwe