How to adddata for qwtspectrogram
Hi,
I'm centroid and I'm newbie in qwt. I have to create a plot similar to the qwt example spectrogram, in that example , it defines a class SpectrogramData (codes followed in ps),and it use the data like this,d_spectrogram->setData(SpectrogramData());
but I want to use the data from files or matrix,how can I do this with Qwt?
Thank you in advance.
regards,
centroid
ps.
class SpectrogramData: public QwtRasterData
{
public:
SpectrogramData():
QwtRasterData(QwtDoubleRect(0.0, 0.0, 3.0, 3.0))
{
}
virtual QwtRasterData *copy() const
{
return new SpectrogramData();
}
virtual QwtDoubleInterval range() const
{
return QwtDoubleInterval(0.0, 10.0);
}
virtual double value(double x, double y) const
{
const double c = 0.842;
const double v1 = x * x + (y-c) * (y+c);
const double v2 = x * (y+c) + x * (y+c);
return 1.0 / (v1 * v1 + v2 * v2);
}
};
it uses the data like this
Plot::Plot(QWidget *parent):
QwtPlot(parent)
{
d_spectrogram = new QwtPlotSpectrogram();
...
d_spectrogram->setData(SpectrogramData());
d_spectrogram->attach(this);
...
}
Reading the Qwt User's Guide 5.2.1,I find this in QwtRasterData Class Reference:
void QwtRasterData::initRaster(const QwtDoubleRect & ,const QSize & raster) [virtual]
Initialize a raster.
Before the composition of an image QwtPlotSpectrogram calls initRaster, announcing the area and its resolution that will be requested.
The default implementation does nothing, but for data sets that are stored in files, it might be good idea to reimplement initRaster, where the data is resampled and loaded into memory.
Parameters:
rect Area of the raster
raster Number of horizontal and vertical pixels
See also:
initRaster(), value()
maybe it is useful,but how can I reimplement initRaster?
Hope for your help.Thank you!
Re: How to adddata for qwtspectrogram
I have explained these questions several times in this forum. Please spend some time with readingfirst and come back with the questions, that are left.
Uwe
Re: How to adddata for qwtspectrogram
Thank you all the same,I will read it first,but I have a question about this ,this maybe a common problem we are confronted,so why Qwt could not offer a better API for data input,like the QwtPlot3D?Maybe Qwt could do it better in this aspect.
Thank again.