Rendering an image within QwtPlot
Hi all,
How can I attach an image file to QwtPlot as if it's a QwtPlotCurve so that I'll get to use the axis, legend, selection, zoom, etc ...
It seems that subclassing the QwtPlotRasterItem may be it, but I don't know how to override the renderImage method.
Code:
const QwtScaleMap &yMap,
const QwtDoubleRect
&area
) const {
//return QImage(_filename);
}
Thanks
4 Attachment(s)
Re: Rendering an image within QwtPlot
I'm adding more information for clarity
How can I attach an image file, pix1.JPG, to QwtPlot as if it's a QwtPlotCurve so that I'll get to use the axis, legend, selection, zoom, etc ... see the attached image3.JPG
It seems that subclassing QwtPlotRasterItem, but I must haven't written the renderImage method correctly
Code:
const QwtScaleMap &yMap,
const QwtDoubleRect
&area
) const {
if ( area.isEmpty() )
QRect rect
= transform
(xMap, yMap, area
);
QPixmap pixmap
(rect.
width(), rect.
height());
pixmap.load(_filename);
return pixmap.toImage();
}
Two problems that I'm facing:
1) the grid is drawn on top of the image, see pix4.JPG
2) when drawing this pix1.JPG on top of a QwtPlot that already contains a red standard curve and a blue custom rectangle [as in pix2.JPG snapshot] results in a very strange behavior: the red standard curve draws fine, but the blue custom rectangle disappeared (or being drawn behind the image) , pix3.JPG
Re: Rendering an image within QwtPlot
QwtPlotRasterItem is for displaying raster data - something you don't have. In your case I would recommend to implement a special type of image item ( or combine it with your selection item ), where you simply do a QPainter::drawPixmap().
The painting order of depends on the z-value of the plot items.
Uwe
Re: Rendering an image within QwtPlot
Hello, i have the same problem than ttvo
Quote:
In your case I would recommend to implement a special type of image item ( or combine it with your selection item ), where you simply do a QPainter::drawPixmap().
Could you, please be more clear in your explanation Uwe?
Thanks in advance, and congratulations, Qwt jusks rocks ! ;)
Re: Rendering an image within QwtPlot
In the examples you find implementations for some individual plot items. But probably the code of QwtPlotSvgItem should be enough ( strip the draw method down to a QPainter::drawPixmap ).
AFAIR I had already posted some code here or at the mailing list.
Uwe