philwinder
13th June 2008, 10:52
Hi,
Qwt Spectrogram looks great, but by default is uses double x, y, data as if the routine is supposed to perform some sort of maths on them. What I need to do is plot data from a few QList<double>'s. I have half stolen the code from the spectrogram example but I think my problem is in the value routine where it seems to crash. The data I am trying to plot is held in "QList<double> spectData[180];" Could you provide some pointers as to how to do it correctly?
Cheers.
class SpectrogramData: public QwtRasterData
{
public:
QpnwPhasedArrayPlot * parent;
// Provide pointer to QpnwPhasedArrayPlot so we can access the data
SpectrogramData( QpnwPhasedArrayPlot * theParent ):
QwtRasterData(QwtDoubleRect(-90, 0, 180, 2000)) // Left, bottom, width, height
{
parent = theParent;
}
// Left as example
virtual QwtRasterData *copy() const
{
return new SpectrogramData(0);
}
// Left as example
virtual QwtDoubleInterval range() const
{
return QwtDoubleInterval(0.0, 4096);
}
// Return data. Crashes here.
virtual double value(double x, double y) const
{
QMessageBox::information(0,"","A");
return parent->spectData[(unsigned int) x+90].at( (unsigned int) y );
}
};
QpnwPhasedArrayPlot::QpnwPhasedArrayPlot(QwtPlot * thePlot)
{
DEBUG->print(QDateTime::currentDateTime().toString("dd.MM.yy hh:mm:ss.zzz") + ": " + "Initialising Plot");
// Create spectrogram
spectrogram = new QwtPlotSpectrogram();
// Create some fake data
for( int x = 0; x < 180; x++ )
for( int y = 0; y < 2000; y++ )
spectData[x].append(y);
spectData[90].clear();
for( int x = 0; x < 2000; x++ )
spectData[90].append(x);
// Attach the data
spectrogram->setData(SpectrogramData(this));
spectrogram->attach(thePlot);
}
//
Qwt Spectrogram looks great, but by default is uses double x, y, data as if the routine is supposed to perform some sort of maths on them. What I need to do is plot data from a few QList<double>'s. I have half stolen the code from the spectrogram example but I think my problem is in the value routine where it seems to crash. The data I am trying to plot is held in "QList<double> spectData[180];" Could you provide some pointers as to how to do it correctly?
Cheers.
class SpectrogramData: public QwtRasterData
{
public:
QpnwPhasedArrayPlot * parent;
// Provide pointer to QpnwPhasedArrayPlot so we can access the data
SpectrogramData( QpnwPhasedArrayPlot * theParent ):
QwtRasterData(QwtDoubleRect(-90, 0, 180, 2000)) // Left, bottom, width, height
{
parent = theParent;
}
// Left as example
virtual QwtRasterData *copy() const
{
return new SpectrogramData(0);
}
// Left as example
virtual QwtDoubleInterval range() const
{
return QwtDoubleInterval(0.0, 4096);
}
// Return data. Crashes here.
virtual double value(double x, double y) const
{
QMessageBox::information(0,"","A");
return parent->spectData[(unsigned int) x+90].at( (unsigned int) y );
}
};
QpnwPhasedArrayPlot::QpnwPhasedArrayPlot(QwtPlot * thePlot)
{
DEBUG->print(QDateTime::currentDateTime().toString("dd.MM.yy hh:mm:ss.zzz") + ": " + "Initialising Plot");
// Create spectrogram
spectrogram = new QwtPlotSpectrogram();
// Create some fake data
for( int x = 0; x < 180; x++ )
for( int y = 0; y < 2000; y++ )
spectData[x].append(y);
spectData[90].clear();
for( int x = 0; x < 2000; x++ )
spectData[90].append(x);
// Attach the data
spectrogram->setData(SpectrogramData(this));
spectrogram->attach(thePlot);
}
//