Hi,
as far as I’ve understood it, you’d give the boundaries when you’re initialising your subclassed QwtRasterData. Qwt would then call the value method with all numbers between those boundaries that are currently displayable. If you stretch the plot to a size of 200 pixels, this will mean that qwt asks for 200 values betwenn 0 and 100, so you will have to use a method to get appropriate integer numbers from those.
{
public:
SpectrogramData
{
}
virtual double value(double x, double y) const
{
return myDataArray[(unsigned int) floor(x)][(unsigned int) floor(y)];
}
};
class SpectrogramData: public QwtRasterData
{
public:
SpectrogramData
: QwtRasterData(QwtDoubleRect(0., 0., 100., 100.))
{
}
virtual double value(double x, double y) const
{
return myDataArray[(unsigned int) floor(x)][(unsigned int) floor(y)];
}
};
To copy to clipboard, switch view to plain text mode
You could also implement a QSize rasterHint() method which returns the maximal resolution possible, so that Qwt only asks for 100 values between 0 and 100 and not like 300-something or however large you drag your plot on screen.
Unfortunately, I do have issues with the code as well (especially when rasterHint is implemented), so it can only serve you as a first idea.
My problem is, that sometimes Qwt would call value(99,100) which of course yields an out-of-range value. And somehow the plot gets shifted in y-direction, too. Strangely, this does not happen in x direction, e.g. Qwt does not call value(100,99) or value(100,100). At least that is not what I observed.
Hopefully, someone could post an insightful solution to this and hint how Qwt determines which arguments it passes to the value(x, y) method.
Nontheless, I hope my first version is of some use for you anyway.
Bookmarks