Results 1 to 11 of 11

Thread: QwtPlotSpectrogram and QwtRasterData

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QwtPlotSpectrogram and QwtRasterData

    Hello,

    I have a vector that has a structure (x,y,z and value). looking into the spectrogram example, i could not know how to make the x,y in the virtual value method match my x and y.

    also does the raster data has to go through all the x,y in the plot ?? I want it to only go through my x and y and not all the x and y's for the whole plot.

    sorry if i am asking in a stupid way, i just don't know exactly how to do it, and why i can not just give the rasterData my x,y and value immediately, and all the other x,y takes as a default No value. ??

    I would really highly appreciate if some one can provide an example of how i can do this, which is how can i give the raster my x,y's and their values.

    Thank you so much.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,234
    Thanked 857 Times in 806 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    Use QwtMatrixRasterData - have a look at the rasterview example.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    jesse_mark (30th January 2013)

  4. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    I was looking at rasterview example, and we can assigne the the values, but not a long with the x,y position.

    we gave the number of columns, which as I understand , it should be the number of different X's i have. but what if my points are not in order ?? how can it know which x,y that
    should take this value ??

    sorry but i am a bit confused.
    also, we set the intervalY , intervalY to bound the area where i want to spectrogram to be drawn. but what is i have nonRect shape or a Rect but has rotation.

    I hope my questions are clear.

    Thanks so much

  5. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,234
    Thanked 857 Times in 806 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    Quote Originally Posted by jesse_mark View Post
    I hope my questions are clear.
    No, I have absolutely no idea what you need to know.

    Uwe

  6. #5
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    ok
    my first question was, how do I assign x,y a value. in the rasterview example you used :

    Qt Code:
    1. QVector<double> values;
    2. for ( uint i = 0; i < sizeof( matrix ) / sizeof( double ); i++ )
    3. values += matrix[i];
    4.  
    5. const int numColumns = 4;
    6. setValueMatrix( values, numColumns );
    To copy to clipboard, switch view to plain text mode 

    but how do we know which x,y assigned which value?? and what is the affect of NumColumns ??
    as well is there a way to control

    my second question was:
    the area of the spectrogram. in the example you used intervals:

    Qt Code:
    1. setInterval( Qt::XAxis,
    2. QwtInterval( 0.5, 3.5, QwtInterval::ExcludeMaximum ) );
    3. setInterval( Qt::YAxis,
    4. QwtInterval( 0.5, 3.5, QwtInterval::ExcludeMaximum ) );
    5. setInterval( Qt::ZAxis, QwtInterval( 1.0, 6.0 ) );
    To copy to clipboard, switch view to plain text mode 

    this way made the spectrogram a rectangle, but what if its a poly shap or a rectangle that is rotated?? in other way how do i control the area in which i want the map "spectrogram" to be drawn.

  7. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,234
    Thanked 857 Times in 806 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    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

  8. #7
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    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.

  9. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,234
    Thanked 857 Times in 806 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    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.

  10. #9
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    The X/Y intervals have to be from the bounding rectangle of your rotated rect
    ok let us assume my bounding 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 the
    Qt Code:
    1. virtual double value( double x, double y )
    To copy to clipboard, switch view to plain text mode 
    method will be called for every pixel in the bounding rect (the x/y intervals).

    have to translate/rotate x/y so that it finds the value from your value matrix.
    how can i do this ??
    is it like
    Qt Code:
    1. virtual double value( double x, double y )
    2. {
    3. QPoint tp;
    4. tp.setX(x);
    5. tp.setY(y);
    6.  
    7. int p = postions->indexOf(tp)
    8. if (p!=-1)
    9. {
    10. return val->at(p);
    11. }
    12. else
    13. return p;
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 


    Thank you so much for your patience and helping me to understand

  11. #10
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,234
    Thanked 857 Times in 806 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    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.

  12. The following user says thank you to Uwe for this useful post:

    jesse_mark (5th February 2013)

  13. #11
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotSpectrogram and QwtRasterData

    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

Similar Threads

  1. Replies: 2
    Last Post: 1st May 2012, 23:32
  2. QwtRasterData and non-linearly sampled data
    By DizzyMoods in forum Qwt
    Replies: 3
    Last Post: 23rd December 2011, 11:50
  3. Replies: 8
    Last Post: 2nd November 2011, 16:31
  4. QwtRasterData and values
    By DKL1972 in forum Qwt
    Replies: 12
    Last Post: 10th March 2010, 09:53
  5. Convert QwtRasterData to QwtSeriesData
    By bigjoeystud in forum Qwt
    Replies: 3
    Last Post: 25th August 2009, 15:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.