PDA

View Full Version : how to plot second curve on QWT 's oscillocope example ?



Bangalaman
12th May 2014, 07:27
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

Uwe
14th May 2014, 14:30
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

Bangalaman
15th May 2014, 09:13
thank you Uwe , my future intention is plot signal from microphone in real time