Results 1 to 4 of 4

Thread: Oscilloscope + realtime

  1. #1
    Join Date
    Nov 2013
    Posts
    2
    Thanks
    1

    Default Oscilloscope + realtime

    Hello.
    I spent a lot of time while reading related topics before asking the question, but unfortunately didn't find the answer.
    Situation:
    I need an oscilloscope window in my app. It has to show the data from outside, time period between any two neighbour points is the same (f.e. 0.1 sec). bottom axis is a time axis. user can vary this interval in a big range (from 30 seconds to 8 hours), so the number of points can be big enough. I need to show the last points in setted time interval, so after filling all the plot area i have to move my plot by 1 point to the left and add a point at the right edge of my curve (like in refresh example of qwt), without changing grid and any axis. First I realized my oscilliscope like in refreshtest example, and it works fine but i pointed time needed to add next point to the curve depends on point count very much.
    its not siutable for me. this is because of "replot" function call for every added point. I changed the way of painting by using QwtDirectPainter to paint incrementally. It works fine with huge amount of point adding incrementally while all this points suit my time interval. but i have no idea how to scroll painted area in this case(remove first painted point and then incrementally add new point to the end of painted curve). is it possible.

    another one variant is still use variant of shifting from refreshtest example but to filter points before putting them into the curve in the case of big time interval. this will decrease point count while replotting.
    does exist more simple way to solve my problem.

    Thanks for your answers.
    PS qwt 6.1.0; qt4.8.4 MSVC compiler, WinXP-Win7

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

    Default Re: Oscilloscope + realtime

    In your situation you have two options:

    a) reducing the number of points f.e. with using an algo like it is implemented QwtWeedingCurveFitter - maybe depending on the current axis interval.
    b) implementing some tricks to avoid, that all points need to be repainted for each new point.

    F.e. the trick used in the oscilloscope example is to draw the curve always from left to right ( incrementally ), where the scale gets incremented by some step when the curve has reached its end. This implementation works with almost no CPU usage for trillions of points.

    Another implementation I can imagine ( when there is time I will implement it in another demo ) is to add some painting cache (a pixmap with a transparent background), that is larger, than the canvas. The idea is to draw the curve incrementally to the pixmap and then to draw the part of the pixmap that is currently inside the axis scales.

    This way you have full repaints of the curve only when the pixmap has been shifted to its end and the next cycle starts. F.e if the interval of the scale is 1h and your pixmap has an interval of 1:10 it will happen once every 10 minutes.

    But having an update rate of 100ms for a plot that shows an interval of several hours doesn't make much sense to me. So something you should do in any case is to decouple the refresh rate of the plot from the sample rate !

    Uwe

  3. #3
    Join Date
    Nov 2013
    Posts
    2
    Thanks
    1

    Default Re: Oscilloscope + realtime

    Thanks for answer, Uwe.

    When I made almost the same oscilloscope with WinAPI, I painted my curve on special pixmap before painting to screen. So when I needed to shift my curve for a new point, I just copied this pixmap to itself with the calculated shift removing its left part, erasing its right side and after that added new point to it and only then i put all the stuff to the screen. Such kind of an algorithm is independent from point count on the screen.
    Is it possible to implement such kind of an algorithm with Qt+Qwt.
    One more thing: actually I understand that there is no need to add more point to the curve which can be fitted in 1 pixel on the screen. How can get an active width in pixels of the canvas to calculate the koefficient between my x axis pixel width and its time interval. I can collect all the points outside the Qwt and add a new point to the plot only if curve shift is really needed. In this case refresh rate will depend on selected time interval of the plot.

    Once again, thanks for answers and attention. You are making a vary great job with your qwt...)

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: Oscilloscope + realtime

    Well, aren't both of your questions more or less answered in my previous mail ?

    Uwe

Similar Threads

  1. Oscilloscope
    By P@u1 in forum Qwt
    Replies: 1
    Last Post: 1st July 2011, 15:21
  2. QWT oscilloscope example
    By Pablo220372 in forum Qwt
    Replies: 2
    Last Post: 10th June 2011, 08:19
  3. oscilloscope example bug
    By umituzun84 in forum Qwt
    Replies: 1
    Last Post: 17th March 2010, 19:03
  4. Qwt-5.3.0-svn: oscilloscope
    By PaceyIV in forum Qwt
    Replies: 2
    Last Post: 14th June 2009, 18:56
  5. use qt for oscilloscope
    By dycjiaoda in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 19: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
  •  
Qt is a trademark of The Qt Company.