Results 1 to 11 of 11

Thread: QwtPlotSpectrogram and QwtRasterData

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 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

  2. #2
    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.

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 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.

  4. #4
    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

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 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.

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

    jesse_mark (5th February 2013)

  7. #6
    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
  •  
Qt is a trademark of The Qt Company.