Results 1 to 3 of 3

Thread: how to plot second curve on QWT 's oscillocope example ?

  1. #1
    Join Date
    Mar 2014
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Windows

    Default how to plot second curve on QWT 's oscillocope example ?

    hi,everyone
    oscilloscope example plots sinus waveform on the cavas .Now I have got it.
    Then I want to add a second independant waveform for example square waveform or triangular waveform on the canvas which could be a comparison with the sampling curve.
    when I study the Oscillocope's example , the sinus waveform is genereted in this function

    double SamplingThread::value( double timeStamp ) const
    {
    const double period = 1.0 / d_frequency;

    const double x = ::fmod( timeStamp, period );
    const double v = d_amplitude * qFastSin( x / period * 2 * M_PI );

    return v;
    }
    how can I implement it ?
    how can I to produce the data for thesecond dynamic wave ( square wave , triangular or sinus ) which is synchronous with the sampling curve?

    any Help would be appreciated

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

    Default Re: how to plot second curve on QWT 's oscillocope example ?

    Quote Originally Posted by Bangalaman View Post
    oscilloscope example plots sinus waveform on the canvas.
    Well, the example shows how to display samples in "real time", that are collected and emitted from a sampling thread. As it is an example only it generates some synthetic samples ( here using the sinus ) but in a real world use case this thread would be connected to some device, where it reads samples periodically. So this example is not intended to display any type of waveform - it is about how to display samples as they arrive.

    how can I to produce the data for thesecond dynamic wave ( square wave , triangular or sinus ) which is synchronous with the sampling curve?
    Note that this example is more a demo of how you could do realtime updates of a "heavy" plot with almost no CPU usage - it was never intended as introduction to Qwt ( like the simpleplot example ).

    So you need to understand the code, when you want to extend the functionality of this demo. F.e. if you want to display the same samples in different ways you need to have several curves connected to the same data object. If the curves have to display different sets of samples, you probably need to introduce one sampling thread for each of these sets too. In both cases the curves are in sync, when the coordinates of the samples ( in the demo x values are time stamps ) are in sync.

    When don't have any sort of data acquisition or "real time" requirements there are much easier ways how to display curves on a plot than it is done in the oscilloscope demo.

    Uwe

  3. #3
    Join Date
    Mar 2014
    Posts
    11
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Windows

    Default Re: how to plot second curve on QWT 's oscillocope example ?

    thank you Uwe , my future intention is plot signal from microphone in real time

Similar Threads

  1. Plot x^2 curve
    By qt_developer in forum Qwt
    Replies: 4
    Last Post: 14th June 2012, 08:17
  2. [Qwt] selection of curve/plot/...
    By packman2012 in forum Qt-based Software
    Replies: 0
    Last Post: 5th April 2012, 09:39
  3. getting attached curve to a plot
    By corrado1972 in forum Qwt
    Replies: 2
    Last Post: 22nd June 2011, 09:35
  4. How to plot tan(x) curve?
    By Name in forum Qwt
    Replies: 1
    Last Post: 17th September 2010, 13:20
  5. Replies: 2
    Last Post: 8th January 2010, 14:09

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.