Results 1 to 2 of 2

Thread: Qwt Plot Curve and Marker Precision with Doubles

  1. #1
    Join Date
    Oct 2016
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Qwt Plot Curve and Marker Precision with Doubles

    Hi,

    I am working on a plot where the X axis is a 24 hour clock. Each 1.0 on the X axis equates to 1 second. But I also work with milliseconds, e.g 12.3. Basically, I am trying to place markers on the curve with millisecond precision, however after several zoom levels the markers diverge from the curve coordinates.

    A sample of my code is:

    for (int i = 0; i < curve->dataSize(); i++)
    {
    if (12.3 < curve->sample(i).x())
    {
    xDist = std::abs(curve->sample(i).x() - 12.3);
    yDist = std::abs(curve->sample(i).y() - curve->sample(i + 1).y();
    yValue = (yDist * xDist) + curve->sample(i).y();
    break;
    }
    }

    If there are syntax/spelling mistakes it is probably because I had to type this on my phone. However, this code partly does what I want. As at the highest level it looks perfect, but when I zoom in to values on my y axis with 3 or more decimal places the marker no longer follows the curve, instead hovering around the curve.

    Therefore, I am looking for some advice on this. Is there a better/more precise way to find the y value of a curve based on its x axis value? Or is there some way to limit the level of zoom I can apply to a plot? I would prefer the former solution but am happy for any help.

    Thanks in advance.

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

    Default Re: Qwt Plot Curve and Marker Precision with Doubles

    Quote Originally Posted by Krippy View Post
    Basically, I am trying to place markers on the curve with millisecond precision, however after several zoom levels the markers diverge from the curve coordinates.
    Better overload one of the QwtPlotCurve::draw methods and do your interpolation in paint device coordinates. QPainter::drawLine does all you need.

    Uwe

Similar Threads

  1. Replies: 1
    Last Post: 24th July 2016, 10:44
  2. Replies: 10
    Last Post: 7th March 2014, 10:40
  3. Replies: 2
    Last Post: 12th September 2012, 08:43
  4. Zooming the plot without the marker
    By raghvendramisra in forum Qwt
    Replies: 1
    Last Post: 17th May 2012, 18:24
  5. Moving plot marker with the mouse
    By viridis in forum Qwt
    Replies: 2
    Last Post: 23rd September 2008, 21:39

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.