Thanks for the reply. I did a quick hack to see what would happen if I change the rectangle for the data, and what I get is the data plotted hard up against the left hand side as the x-axis scale is now many times larget than the data index. It was however only called 1024 times within sample().
I am not sure I have understood your suggestions therefore. Changing the bounding rectangle has sort of done what I expected. The plot has used it to scale the x-axis, but the data is not expanded to fill this range. The data index is being treated as the x-axis value, hence the data being all squashed up on the left side.
Maybe the answer is in your Note at the bottom, but I don't quite understand what you mean by the x1-x2, y representation.
Would I be better off picking a different representation for my data? You kindly suggested this format in a post a while back and up till trying to plot the data against slightly adjusted axis it has worked very well, excellent library.
Just to be clear about what I have implemented so far, as it is possible I have done this bit wrong. I took the QwtSeriesData class and derived MyPlotData (all Qwt 6 still). I have added various members to this class to allow me to reallocate memory when my sample data lengths change. Therefore when I start a capture of data (time domain samples) I call a resize() member to reallocate the internal buffer and set the size() member and a default bounding box. I then get the pointer to that data with a call to samples(). This buffer is passed to a class outside the GUI space which collects data from a sensor based on a regular sampling clock for say 1024 periods, therefore I get a float array with 1024 values in it.
When the capture is complete the GUI gets called to do a replot. For the raw data this can be plotted as is, i.e. the values stored in the array are the y-axis values, and the array index the x-axis points. Raw data plots show the data magnitude (y axis) against sample number (x-axis). The data is then FFT'd to give another MyPlotData object. This is allocated the correct size for the FFT result, the FFT calculated from the raw MyPlotData class and placed into the FFT MyPlotData class object. Again this is still a series data object. As said before, the value in the array is the FFT magnitude, and the array index the FFT bin number, which is just a linear contiguous count from 0, just like the original raw datas sample index.
All I really need to do is change how the series datas array index is interpreted. Instead if being a contiguous array I need it to be sparse. Data points will still be connected pint to point, and will look exactly as if the x-axis was the array index.
Changing the bounding rectangle just seems to change the plottable area the plot widgets canvas covers, hence when the series data is requested with sample(index), the index is used by the plot widget as the x-axis value. I can't modify this index in the sample() call so can't change how the plot widget uses this value.
I could effectively oversample the series data array by claiming to the plot widget that the size is say 500,000,000 but internally for each sample(index) request map N values to a single underlying data value in the actual FFT data array, which lets say is 1024 in size. This would kill performance however.
I guess back to my earlier question, am I using the wrong data type for doing this operation, or can I acheive the effect I am after by a bit of back door manipulation of the x-axis thereby avoiding the need to modify the data itself.
At some point soon I also need to add zooming and panning to this so I may be back
Thanks for the help it is much appreciated.






Reply With Quote

Bookmarks