1 Attachment(s)
QwtSpectrogram, don't draw from scratch
I want to draw a spectrogram periodically, which means that data come over time, and i just want to add columns to the previous graph (see photo).
What i did is to declare a instance, and i use the setData() function where i pass a SpectrogramData instance:
Code:
private:
std::vector<std::vector<double>> data;
public:
SpectrogramData(int height, int width);
~SpectrogramData();
virtual double value(double x, double y) const;
};
Code:
spectrogram->setData(spectrogram_data);
When new data come, i add them to the data structure, and call replot() in the QwtPlot instance that the QwtSpectrogram is attached to.
Because the spectrogram will ultimately have about 700*22000 size, i don't know what replot() does. Is there a way to tell qwt to only plot a certain column of data or region or rectangular or something in the spectrogram?
Re: QwtSpectrogram, don't draw from scratch
Quote:
Originally Posted by
kkaz
When new data come, i add them to the data structure, and call replot() in the QwtPlot instance that the QwtSpectrogram is attached to.
In case you are changing your vector behind the back of the item ( = no setData ) you might also have to invalidate the paint cache of the item manually.
Quote:
Because the spectrogram will ultimately have about 700*22000 size, i don't know what replot() does.
The spectrogram iterates over the pixels in a resolution, that corresponds to the minimum of screen/data. Assuming a situation, where the plot canvas has a size of 1000x1000 it would be 700x1000.
It is the job of the value() method to do the resampling. The fastest but simplest algo is called nearest neighbour, what simply rounds the requested position to the closest existing one. But you could also use more advanced algos like bilinear interpolation, what is implemented in QwtPlotMatrixData. But be careful with your implementation - value() is called for each pixel and needs to be implemented quite performantly.
Quote:
Is there a way to tell qwt to only plot a certain column of data or region or rectangular or something in the spectrogram?
This is one of the most relevant features, that are missing in Qwt. But it is usually only important, when you need high refresh rates ( several replots per second ). Often it is good enough to decouple the rate of the incoming data from the update rate using a timer.
I recommend to play with the spectrogram example first to find out if full replots are fast enough for your situation. Only if not it is worth to spend some time with shifting columns in the paint cache and repainting only parts of it. If you really have to go this way you should consider to flip the x/y axes because a QImage internally is stored as a sequence of rows and you can shift by memcpy.
Uwe