PDA

View Full Version : Resolution Spectrogram



edney
12th April 2010, 17:41
I have a spectrogram, and i want change the resolution of initRaster.
how can i do this ???
i would want see a example of initRaster implementation.
sorry im not good with write english im from brazil

Uwe
12th April 2010, 19:40
I have a spectrogram, and i want change the resolution of initRaster.
The whole things works like this: the spectrogram item calculates the position for each pixel it needs to paint in scale coordinates and requests a value for it from the data object. Your data object (derived from QwtRasterData) has to calculate and return a value. Of course your matrix won't have a value at the requested position, so your data object needs to do something that is called resampling. The most simple algorithm for resampling is returning the value of the next neighbour, but you could also return an average value from all neigbours or whatever you want.

QwtRasterData::initRaster tells your data object about the raster that is used for the next image composition. It can be used to prepare the resampling algorithm f.e. if you have values for the elevation in Brazil in different resolutions stored in files and you know that the values will be requested for your home town in a resolution of 100x100 m you can load the right values into memory in advance. If you don't have anything to initialize you don't need to implement YourRasterData::initRaster/discardRaster. ( It makes no sense to call initRaster() from your application. )

You should implement YourRasterData::boundingRect() to avoid requests for pixels, where you don't have any values. By implementing YourRasterData::rasterHint() you can avoid, that the image resolution is much higher than the resolution of your raster - but this is for performance reasons only. ( And of course you need to implement YourRasterData::value() )

And note: don't try to control the raster of the image - you always have to resample !

Uwe

edney
12th April 2010, 22:26
Sorry again I couldnt explain it

I have a file with 100 points, each point has the coordinates x, y and elevation.
I wanted to make a spectrogram based on these 100 points.
I would like to control the resolution of the spectrogram and I thought it would
be done using the function initRaster, as suggested by the documentation:

void QwtRasterData: initRaster (const QwtDoubleRect &,const QSize & raste) [Virtual]

Initialize the raster.

Before the composition of an image calls QwtPlotSpectrogram initRaster, Announcing the area and Its Will Be That resolution requested.

Implementation The default does nothing, But is That data sets are stored in files, It Might Be good idea to reimplement initRaster, Where the date is resampled and loaded into memory.

I could not even understand how the (value) function works, what the function that inserts values in x and y?, How do I change the pitch between each value of x and y ???
virtual double QwtRasterData:: value (double x, double y) const [pure virtual]

Uwe
13th April 2010, 07:44
I would like to control the resolution of the spectrogram and I thought ...
And once more: you can't - it's the resolution of the target device ( f.e your monitor or printer ) that counts ! And once more: you always have to resample !

Why don't you start with a simple raster data object using a next neighbour algorithm (rounding x,y to the steps of your data resolution) in YourSpectrogram::value() - of course adding an implementation of rasterHint() later makes much sense for a 10x10 matrix.

You are not the first one completely missing how the raster data object works. Maybe it helps to recall that all virtual methods are called from the spectrogram item to support the process of rendering an image in screen resolution. You have to implement these virtual methods, but you will never call them from your application code.

Uwe