Results 1 to 5 of 5

Thread: Rendering an image within QwtPlot

  1. #1
    Join Date
    Jan 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.
    Qt Code:
    1. QImage OverlayImagePlot::renderImage(const QwtScaleMap &xMap,
    2. const QwtScaleMap &yMap, const QwtDoubleRect &area) const
    3. {
    4. //return QImage(_filename);
    5. }
    To copy to clipboard, switch view to plain text mode 

    Thanks
    TNG

  2. #2
    Join Date
    Jan 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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
    Qt Code:
    1. QImage OverlayImagePlot::renderImage(const QwtScaleMap &xMap,
    2. const QwtScaleMap &yMap, const QwtDoubleRect &area) const
    3. {
    4. if ( area.isEmpty() )
    5. return QImage();
    6.  
    7. QRect rect = transform(xMap, yMap, area);
    8.  
    9. QPixmap pixmap(rect.width(), rect.height());
    10. pixmap.load(_filename);
    11.  
    12. return pixmap.toImage();
    13. }
    To copy to clipboard, switch view to plain text mode 

    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
    Attached Images Attached Images

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,258
    Thanked 862 Times in 811 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  4. #4
    Join Date
    Jun 2009
    Location
    Metz, France
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: Rendering an image within QwtPlot

    Hello, i have the same problem than ttvo
    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 !

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,258
    Thanked 862 Times in 811 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

Similar Threads

  1. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 16:36
  2. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 03:10
  3. Help needed handling image data
    By toratora in forum General Programming
    Replies: 2
    Last Post: 11th May 2007, 10:24
  4. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 15:39
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 17:36

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.