Results 1 to 5 of 5

Thread: Problem with a QwtPlot with big axes values

  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question Problem with a QwtPlot with big axes values

    I have a QwtPlot which axes values I set myself based on the values that I need to plot. Now, it may happen that I the axes values are set to +/- DBL_MAX. Now, when replotting (QwtPlot::replot()), updateAxes() is called which, in turn, eventually calls QwtLinearScaleEngine::divideScale() and this is where a problem occurs. Basically, that method will call buildTicks() if stepSize is different from zero, but with my big axes values, stepSize has here a non-finite value. The end result is that the call to buildTicks() never returns and the application eventually crashes.

    Now, ideally, QwtLinearScaleEngine::divideScale() would check that stepSize is of a finite value and do something sensible if not. For now, all I personally to avoid the problem is:

    Qt Code:
    1. if ( qIsFinite ( stepSize ) )
    2. buildTicks( interval, stepSize, maxMinorSteps, ticks );
    To copy to clipboard, switch view to plain text mode 
    But this means that I don't get any tick at all while, ideally, I would still get some...

  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: Problem with a QwtPlot with big axes values

    An infinite step size doesn't happen somehow - you have assigned it explicitly. So this is your code:

    Qt Code:
    1. if ( !qIsFinite ( stepSize ) )
    2. stepSize = -1;
    3.  
    4. plot->setAxisScale( ..., stepSize ):
    To copy to clipboard, switch view to plain text mode 
    It is not the job of Qwt to deal with any type of nonsense the application code does. When passing a double it has to be valid otherwise the result is undefined.

    Uwe

  3. #3
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with a QwtPlot with big axes values

    I completely agree with you that "it is not the job of Qwt to deal with any type of nonsense the application code does". However, as far as I can tell, my code provides valid double values. Also, my code doesn't provide any step size to setAxisScale(). It only does something like:

    Qt Code:
    1. myPlot->setAxisScale(QwtPlot::xBottom, xMin, xMax);
    To copy to clipboard, switch view to plain text mode 
    and xMin might be equal to -DBL_MAX and xMax to DBL_MAX (both of which being valid double values indeed). So, in some cases, my call to setAxisScale() might be something like:

    Qt Code:
    1. myPlot->setAxisScale(QwtPlot::xBottom, -DBL_MAX, DBL_MAX);
    To copy to clipboard, switch view to plain text mode 
    and it is in this kind of case that QwtPlot will crash my application, unless I edit the Qwt code as I mentioned in my original message.

  4. #4
    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: Problem with a QwtPlot with big axes values

    I'm pretty sure that when using [-DBL_MAX DBL_MAX] you will run into code that does ( max - min ) - the right thing to do is to find these places and to fix them: please file a bug report.

    Your workaround might fix a crash but doesn't lead to useful results. Guess a better workaround is to set a reasonable step size manually:

    Qt Code:
    1. myPlot->setAxisScale(QwtPlot::xBottom, -DBL_MAX, DBL_MAX, stepSize );
    To copy to clipboard, switch view to plain text mode 
    But of course this is no solution for zooming panning in combination with a range above DBL_MAX. So the best workaround is to limit the range to something like [-0.5 * DBL_MAX, 0.5 * DBL_MAX ].

    Uwe

  5. #5
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with a QwtPlot with big axes values

    My work around was a temporary solution to a crash I was experiencing. As for the code, it does indeed use max-min here and there. I was able to fix a couple of such instances, but then there it the way ticks are computed (i.e. minValue + i * stepSize) which would cause problems, etc. So, in the end, I decided to use your recommended workaround even though [-0.5*DBL_MAX, 0.5*DBL_MAX] still doesn't work for me (but [-0.3*DBL_MAX, 0.3*DBL_MAX] does). No ticks get shown and labels get overlapped. Anyway, as you requested, I am going to file a bug report.


    Added after 55 minutes:


    Here is the bug report: http://sourceforge.net/p/qwt/bugs/186/.
    Last edited by agarny; 18th March 2013 at 06:01.

Similar Threads

  1. Replies: 2
    Last Post: 5th May 2020, 20:40
  2. Replies: 2
    Last Post: 20th July 2012, 14:51
  3. Skip NaN values in qwtplot
    By ivareske in forum Qwt
    Replies: 0
    Last Post: 12th October 2011, 15:01
  4. Qwt axes and really small/large values
    By bigjoeystud in forum Qwt
    Replies: 1
    Last Post: 19th January 2011, 07:46
  5. Replies: 1
    Last Post: 4th November 2010, 08:00

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.