Let's do it the other way round: what type of values do you have an how do you want to display them on the plot ?
Uwe
Let's do it the other way round: what type of values do you have an how do you want to display them on the plot ?
Uwe
Spectrogram.pdf
see the attachment:
I have a map (x ,y and value) for the colored rectangle.
Let’s assume the origin point of the colored rectangle is (5000, 2000). The map will be for points only
inside the colored rectangle, with fixed distance between each point.
Map will be:
X
Y
Value
// for all points in the colored rectangle.
If (value = -1) that means NO value assigned.
O.k. then you have to use QwtRasterData like in the spectrogram example.
The X/Y intervals have to be from the bounding rectangle of your rotated rect. In the implementation of YourRasterData::value() you have to translate/rotate x/y so that it finds the value from your value matrix.
For the positions inside of the bounding rectangle but outside of your rotated rectangle do the same as for other positions, where you don't have values: return -1.
Then use a color map that maps values <0 to qRgba( 0, 0, 0, 0 ).
Uwe
PS: be careful with your implementation of YourRasterData::value() as it will be called very often. So try to avoid doing heavy calculations there. Maybe it is better to build a rotated matrix ( probably with a different - higher - resolution ) in advance.
ok let us assume my bounding rect :The X/Y intervals have to be from the bounding rectangle of your rotated rect
for X-interval (0,40,000)
for Y-interval (0,35,000)
the values (Z-interval) (0-5000)
Also lets say that i have
QVector<QPoint> postions
QVector<double> val; // the value of postions->at(i) is val->at(i)
as I understood from the spectrogram example:
now themethod will be called for every pixel in the bounding rect (the x/y intervals).Qt Code:
virtual double value( double x, double y )To copy to clipboard, switch view to plain text mode
how can i do this ??have to translate/rotate x/y so that it finds the value from your value matrix.
is it like
Qt Code:
virtual double value( double x, double y ) { QPoint tp; tp.setX(x); tp.setY(y); int p = postions->indexOf(tp) if (p!=-1) { return val->at(p); } else return p; }To copy to clipboard, switch view to plain text mode
Thank you so much for your patience and helping me to understand
x/y are values from the scales. How your values are related to the scale coordinates is something I can't tell you.
The implementation of "value()" you have posted will be way to slow. It will be called for each pixel of the canvas ( when there is no pixelHint() ). You can't have an operation like indexOf() there.
Also indexOf() will fail for almost all values as the position of the pixels usually never meet the position, where you have a value. So you usually have a to do something called resampling. Mostly it is a nearest neighbor algorithm, but you might use some sort of interpolation as well.
F.e. QwtMatrixRasterData offers nearest neighbor and bilinear interpolation.
Uwe
PS: If all you want to do is to map values at a specific position to a colored dot QwtPlotSpectroCurve might be what you are looking for.
jesse_mark (5th February 2013)
QwtPlotSpectroCurve was close to what I want to do, but as I have too many points QwtPlotSpectroCurve is a bit slow when zooming or when dropping it after panning.
about QwtMatrixRasterData, so to use it we just assign a matrix of values to it.
how does it assign these values to the points ???
what is the affect of number of columns ??
other thing is as a I have -1 means no color, I tried the addColorStop(-1,qRgba(0,0,0,0)) but the colors still show even with QwtPlotSpectroCurve.
Thanks
Bookmarks