Definitely a problem with the value routine. I can stick static values in there and it works ok. So there seems to be a problem accessing its parents data. So I think I need to know a bit more on how it asks for the data. I thought it might just be asking for data that is out of bounds of the array so I put some error checking in, but to no avail.
Then I tried to return a single value, like:
return parent->spectData[90].at(90);
return parent->spectData[90].at(90);
To copy to clipboard, switch view to plain text mode
But that didnt work either. So what else could be causing a crash? Is the parent pointer getting messed up in the copy routine? Or could it be something to do with my multi-dimentional-ness in the data, although it works fine when printf'ing it somewhere.
My most recent code:
{
public:
QpnwPhasedArrayPlot * someParent;
// Provide pointer to QpnwPhasedArrayPlot so we can access the data
SpectrogramData( QpnwPhasedArrayPlot * theParent ):
QwtRasterData(QwtDoubleRect
(0.0,
0.0,
180.0,
1999.0)) // Left, bottom, width, height {
someParent = theParent;
//QMessageBox::information(0,"","Creating Raster");
}
{
return new SpectrogramData(someParent);
}
{
}
virtual double value(double x, double y) const
{
//QMessageBox::information(0,"","Real: " + QString::number(y) + " Round: " + QString::number((unsigned int)y));
if( x < 0 || x > 180 || y < 0.0 || y > 1999.0 )
return 0.0;
else
return someParent->spectData[90].at(90);
}
};
QpnwPhasedArrayPlot
::QpnwPhasedArrayPlot(QwtPlot * thePlot
){
// Create spectrogram
// Create some fake data
for( int x = 0; x < 180; x++ )
for( int y = 0; y < 2000; y++ )
spectData[x].append(y);
// Attach the data
spectrogram->setData(SpectrogramData(this));
spectrogram->attach(thePlot);
}
class SpectrogramData: public QwtRasterData
{
public:
QpnwPhasedArrayPlot * someParent;
// Provide pointer to QpnwPhasedArrayPlot so we can access the data
SpectrogramData( QpnwPhasedArrayPlot * theParent ):
QwtRasterData(QwtDoubleRect(0.0, 0.0, 180.0, 1999.0)) // Left, bottom, width, height
{
someParent = theParent;
//QMessageBox::information(0,"","Creating Raster");
}
virtual QwtRasterData *copy() const
{
return new SpectrogramData(someParent);
}
virtual QwtDoubleInterval range() const
{
return QwtDoubleInterval(0.0, 4096.0);
}
virtual double value(double x, double y) const
{
//QMessageBox::information(0,"","Real: " + QString::number(y) + " Round: " + QString::number((unsigned int)y));
if( x < 0 || x > 180 || y < 0.0 || y > 1999.0 )
return 0.0;
else
return someParent->spectData[90].at(90);
}
};
QpnwPhasedArrayPlot::QpnwPhasedArrayPlot(QwtPlot * thePlot)
{
// 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);
// Attach the data
spectrogram->setData(SpectrogramData(this));
spectrogram->attach(thePlot);
}
To copy to clipboard, switch view to plain text mode
Bookmarks