Results 1 to 13 of 13

Thread: QwtRasterData and values

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Posts
    16
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QwtRasterData and values

    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.

    Qt Code:
    1. class SpectrogramData: public QwtRasterData
    2. {
    3. public:
    4. SpectrogramData
    5. : QwtRasterData(QwtDoubleRect(0., 0., 100., 100.))
    6. {
    7. }
    8. virtual double value(double x, double y) const
    9. {
    10. return myDataArray[(unsigned int) floor(x)][(unsigned int) floor(y)];
    11. }
    12. };
    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.

  2. The following user says thank you to Debilski for this useful post:

    DKL1972 (19th July 2008)

  3. #2
    Join Date
    Jun 2008
    Posts
    7
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QwtRasterData and values

    Thank you. This explains it well for me and is a great start!

Tags for this Thread

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.