Results 1 to 2 of 2

Thread: qwt.6.0.0-svn oscilloscope example and QwtSeriesData

  1. #1

    Default qwt.6.0.0-svn oscilloscope example and QwtSeriesData

    Hey,

    I want to create an updating plot very similar to the oscilloscope example provided with the latest qwt. I'm trying to follow through the source code for the example but I'm a bit lost with QwtSeriesData, and its many subclasses. My application has a couple of threads. A child thread pushes (x,y) data at a fairly high frequency through signals to the parent (gui) thread. The entire series of data sent over the duration of the program needs to be available so I have the child thread signal only the latest data, which is appended to (x,y) vectors in the main thread.

    To plot the data, I tried following bits of the oscilloscope example. Instead of having a timer invoke QwtPlotDirectPainter, I have it setup so the incoming signal with the new (x,y) data will do it. But I'm stuck with which data points object to store my data in and pass over to the QwtPlotCurve object. I have two C++ lib vectors storing the data right now (and they keep increasing in size).

    Also one more quick question -- what exactly does the 'attach' function call do for a lot of the classes in the example? ie. create plot, create grid/attach to plot, create curve/attach to plot, etc.

    Thanks,
    kif

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

    Default Re: qwt.6.0.0-svn oscilloscope example and QwtSeriesData

    Before starting to copy code it might be worth to spend some time with basic thoughts:

    1) Painting is a slow operation ( compared with recording) - maybe too slow to be done in a recording cycle. To avoid, that you miss recording cycles or your user interface becomes unresponsive you should always decouple sampling and refresh rates. ( f.e. your proposed design might flood the event queue followed by hanging updates and an unresponsive GUI ).

    So I strongly recommend to implement the following design:

    a) A sampling thread that does nothing beside recording and storing samples
    b) The user interface periodically updates itsself according to the stored samples

    2) Even if the painting performance doesn't affect the recording anymore you might want to see at least a minimum refresh rate.

    The first thing you should do is to start the refreshtest example to see how many replots per second you can do for a curve with a number of points, that is comparable to your situation. If you are happy with this rate simply call replot() periodically.

    Only if the rate is too low you have to find a strategy to improve the painting performance. The most obvious way is to reduce what needs to be painted. F.e you could reduce the number of points using QwtWeedingCurveFitter ( = Douglas Peucker ). Another option is to paint only new points ( this is what the oscilloscope example does and what QwtPlotDirectPainter is about).

    Note, that the design of your application has an important impact on what is possible or not. F.e. the bottom scale of the oscilloscope example is incremented in fixed time intervals only. Only this way it is possible to paint incrementally. In opposite the cpuplot example always shows the last minute, what requires a full repaint for each update.

    Uwe

Similar Threads

  1. oscilloscope example bug
    By umituzun84 in forum Qwt
    Replies: 1
    Last Post: 17th March 2010, 20:03
  2. Convert QwtRasterData to QwtSeriesData
    By bigjoeystud in forum Qwt
    Replies: 3
    Last Post: 25th August 2009, 16:06
  3. Qwt-5.3.0-svn: oscilloscope
    By PaceyIV in forum Qwt
    Replies: 2
    Last Post: 14th June 2009, 19:56
  4. use qt for oscilloscope
    By dycjiaoda in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 20:46

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.