Results 1 to 3 of 3

Thread: Issue with QwtLogScaleEngine

  1. #1

    Default Issue with QwtLogScaleEngine

    Hello I have trouble with plot With LogScale.
    My goals is to be able to switch between linearScale and LogScale for QwtPlot::xBottom direction
    Qt Code:
    1. if (logarithmic)
    2. {
    3. m_plotWidget->setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine);
    4. }
    5. else
    6. {
    7. m_plotWidget->setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
    8. }
    To copy to clipboard, switch view to plain text mode 

    But when trying to draw my curve starting by point (0,0)

    in qwtToPolyLineFiltered()
    points[0].rx() = round( xMap.transform( sample0.x() ) );
    points[0].ry() = round( yMap.transform( sample0.y() ) );

    Points is not correctly defined cause transform do not handle values out of bounds: (return d_p1 + ( log(0) - d_ts1 ) * d_cnv;
    The starting point is completely wrong.

    What i am doing wrong? and how could i do it works?

    I am trying to change qwt source and in my case that works
    Qt Code:
    1. inline double QwtScaleMap::transform( double s ) const
    2. {
    3. if ( d_transform )
    4. {
    5. double boundValue = d_transform->bounded(s);
    6. if ( boundValue != s )
    7. {
    8. s = d_ts1;
    9. }
    10. else
    11. {
    12. s = d_transform->transform( s );
    13. }
    14. }
    15.  
    16. return d_p1 + ( s - d_ts1 ) * d_cnv;
    17. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

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

    Default Re: Issue with QwtLogScaleEngine

    logarithmic scales can never go to 0 - by definition.

    Qwt could be smarter with error checks, but in the end it would slow down runtime ( well not that important as log is way more expensive ) without having an option to do something useful.
    One way to get around it is to define a QwtTransform class that uses different transformations for different areas ( f.e linear or something based on pow for -1 <= x <= 1 ).

    If you want to do something like in the posted code you don't need to patch Qwt. Simply derive from QwtTransform and implement your log with range checks in YourTransform::transform. The new transformation can be used by QwtScaleEngine::setTransformation.

    You can get some inspiration from the scaleengine example.

    Uwe

  3. #3

    Default Re: Issue with QwtLogScaleEngine

    Thank Uwe for your quick answer.

    I try that you explain, it looks nice but have to look deeper.

    Have a nice weekend

Similar Threads

  1. Replies: 0
    Last Post: 26th September 2013, 11:05
  2. Replies: 1
    Last Post: 13th September 2013, 08:30
  3. Qt 5.0.1 Issue
    By kiboi in forum Qt-based Software
    Replies: 0
    Last Post: 22nd March 2013, 05:22
  4. Qt 4.7.1 VNC issue?
    By djstava in forum Newbie
    Replies: 0
    Last Post: 14th March 2011, 03:34
  5. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 02:59

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.