Results 1 to 5 of 5

Thread: Plot rendering in thread

  1. #1
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Plot rendering in thread

    Hi,

    I just want to know if it is possible to make Qwt do the curve rendering in a thread ?
    I have curves with a lot of point to render and thus, it is quite slow and freeze the user interface.

    Regards,

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Plot rendering in thread

    Hi, you can do your calculations in a separate thread, but you cannot draw directly into the gui thread, instead send some kind of notification message if one calculation is complete.

    Ginsengelf

  3. #3
    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: Plot rendering in thread

    As long as you didn't disable QwtPlotCanvas::PaintCached the content of the canvas is rendered to a pixmap cache, before it is painted to the widget. So what you can try is to overload YourPlot::drawCanvas, where you somehow delegate QwtPlot::drawCanvas to a temporary pixmap into a different thread. When it is done you can replace the canvas paint cache with your pixmap.

    But I guess it is easier to optimize the performance of your replot operations. QwtPlotCurve::PaintFiltered might help. If this is not enough you should implement something like level of details ( skipping of points, depending on the zoom level ).

    Uwe

  4. The following user says thank you to Uwe for this useful post:

    viridis (3rd October 2008)

  5. #4
    Join Date
    Feb 2008
    Posts
    26
    Thanks
    5
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Plot rendering in thread

    I noticed that the rendering occurs in a pixmap and that why I though of the thread possibility.
    I will give it a try if I have enough time.

    For the level of details, I though about it too. Indeed it was the second question of my previous post, but I removed it as I noticed what I need is a low pass filter with resampling... which is quite complicated !
    I have tried to skip points, but it is really not appropriate for my data. I have tried to draw a point only if it is far enough of the previous one too. This last one works very well for some curves (~500 points instead of 120000 !) but not for all (~88000 points instead of 120000 which too big).

    A related problem is that I retrieve my data directly from a QAbstractItemModel, which works with QVariants, and its seems really slow for this problem. I will try to implement a cache for my "double" values here to avoid the QVariant.

  6. #5
    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: Plot rendering in thread

    Quote Originally Posted by viridis View Post
    A related problem is that I retrieve my data directly from a QAbstractItemModel, which works with QVariants, and its seems really slow for this problem. I will try to implement a cache for my "double" values here to avoid the QVariant.
    You can access almost everything through the QAbstractItemModel API, but of course such a design can't be as effective as a array of points.

    I recommend to store your values in something like a QVector<QPointF> and to implement/use a model ( for your Qt widgets ) + a QwtData object ( for QwtPlot ) on top of it.

    Uwe

Similar Threads

  1. GUI and non-GUI thread problem
    By dimaz in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 21:25
  2. Replies: 5
    Last Post: 17th January 2008, 21:49
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Replies: 10
    Last Post: 20th March 2007, 22:19
  5. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49

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.