Results 1 to 3 of 3

Thread: Persistence with QwtPlot

  1. #1
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Persistence with QwtPlot

    I'd like to add persistence to my QwtPlot. For instance, when I plot a QwtPlotCurve, I'd like the original curve to fade at some rate when I plot new data. I can see a couple ways to do this:

    - I could keep up with N plot items, where item 0 has the highest intensity, and N-1 has the lowest, but then I have to keep all of the plotted data in memory, and this could get prohibitive if I want to fade very slowly (which would require a large number of plot items).

    - I could reimplement the appropriate methods in QwtPlot to draw everything to an image, then manipulate the image (gradually fade to background color each time replot is called with new data), and apply this cached image image to the canvas. Not quite how much work would be involved with this option.

    Has anyone implemented this type of plot behavior before? Any tips would be appreciated.

    Thanks!

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Persistence with QwtPlot

    Not sure if I completely got what you are trying to do, but let's try: at some rate - let's say every second - you receive a data set from somewhere, that you need to display as a curve. Then you have some period in time - let's say 10 seconds - where you want to display previous curves. To indicate that data is from the past you decrease the alpha value of the corresponding curve pen, right ?

    Implementation for this would be easy - simply store the date of each data set and start a timer, that updates the curve pen each second and removes curves, when the alpha value goes below 0.

    You wrote about expecting performance/memory issues, because of having too many curves with this approach. Here you need to be more specific about what refresh rate and amount of lines we are talking about.

    Concerning your idea of rendering curves to an image: you would have to iterate over all pixels of this image for each replot decrementing the alpha values, before drawing the new curve on top. Implementation is not very difficult and could be done multithreaded, but of course only doable if there is nothing else on the plot ( like grid lines ). Advantage of this approach is that you have a known penalty for updating the alpha values - independend from the number of curves/samples. Disadvantage is of course, that you always have this penalty and for environments, where you don't run the raster paint engine you would turn vector graphics into raster graphics, what means: no hardware acceleration in case of OpenGL or Qt4/X11 ( remote X11 will just suck ), and unscalable output in case of PDF.

    Uwe

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

    MSUdom5 (21st April 2015)

  4. #3
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Persistence with QwtPlot

    Uwe,

    Yep, that's exactly what I want to do.

    As far as update rate, I'm looking at 10-30 updates a second, and a 10-20 second persistence. I guess I could limit the update rate and persistence time to make option 1 more feasible. I'll give it a shot.

    Eventually, however, I'd like to implement something of this sort:

    persistence.jpg

    for spectrum monitoring. I can do this with a raster plot, but not efficiently.

Similar Threads

  1. QxOrm : Persistence (ORM), Serialization, Reflection
    By QxOrm in forum Qt-based Software
    Replies: 19
    Last Post: 27th January 2014, 04:36
  2. QColumnView persistence
    By Festus Hagen in forum Qt Programming
    Replies: 2
    Last Post: 17th August 2013, 12:52
  3. Replies: 9
    Last Post: 25th October 2012, 19:55
  4. Replies: 4
    Last Post: 10th November 2010, 07:53
  5. Replies: 6
    Last Post: 14th May 2009, 12:02

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
  •  
Qt is a trademark of The Qt Company.