PDA

View Full Version : spectrogram calls



marc2050
4th August 2011, 21:31
Hi.

I'm referring to the spectrogram calls. The code is as below:



class SpectrogramData: public QwtRasterData
{
public:
SpectrogramData()
{
setInterval( Qt::XAxis, QwtInterval( -1.5, 1.5 ) );
setInterval( Qt::YAxis, QwtInterval( -1.5, 1.5 ) );
setInterval( Qt::ZAxis, QwtInterval( 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);
}
};


... somewhere else...
d_spectrogram = new QwtPlotSpectrogram();



My simple question is, how often is this SpectrogramData function call when drawing out the plot? Is it per pixel?

Thank you. 'm just trying to learn and get more understanding...

Uwe
5th August 2011, 08:52
It depends on the pixelHint(). If SpectrogramData::pixelHint() returns something invalid it is called for each pixel in terms of the target paint device. Otherwise the number of calls may be less, when one data pixel covers more than one target paint device pixel. F.e. QwtMatrixRasterData returns the pixel hint depending on the resampling mode.

But in any case you should have in mind, that SpectrogramData::value is called very often and it's good practice to pre-calculate as much as possible in SpectrogramData::initRaster().

Uwe