Results 1 to 2 of 2

Thread: QwtScaleEngine::buildInterval() default values

  1. #1
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    120
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QwtScaleEngine::buildInterval() default values

    My application typically uses Y-axis range in the area of +/-1ps to +/-1us. I'm using auto scaling so that qwt computes the optimum scaling of the traces displayed. This works fine in most cases, but in the pathological case of a trace being constant 0 for all x values auto scaling gives a Y range of [-0.5, 0.5] (seconds) which is not what my users would expect. This behavior is documented in QwtScaleEngine::buildInterval() documentation.

    Unfortunately, buildInterval() method is not virtual. To change the behavior, I have to override QwtLinearScaleEngine::autoScale() method. The override would be the same code as in qwt library with the exception that the call to buildInterval() is replaced by a call to a different method. That approach is working, but not elegant as it reproduces 99% of the original autoScale() code in the override.

    My questions:
    - Is there a better way of using a user defined span for this pathological situation?
    - If not, would it be possible to set a "nullSpan" in the QwtLinearScaleEngine in future releases of qwt?
    - At least, could buildInterval() be changed to a virtual method in future releases?

    Thanks for any suggestions
    ars

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

    Default Re: QwtScaleEngine::buildInterval() default values

    Quote Originally Posted by ars View Post
    I have to override QwtLinearScaleEngine::autoScale() method.
    Yes, nothing wrong about it.

    Uwe

    Qt Code:
    1. class YourScaleEngine: public QwtLinearScaleEngine
    2. {
    3. ...
    4.  
    5. virtual void autoScale( int maxNumSteps,
    6. double &x1, double &x2, double &stepSize ) const
    7. {
    8. if ( x1 == x2 )
    9. {
    10. x1 = ...;
    11. x2 = ...;
    12. stepSize = ...;
    13.  
    14. return;
    15. }
    16.  
    17. QwtLinearScaleEngine::autoScale( maxNumSteps, x1, x2, stepSize );
    18. }
    19. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. text field with default values
    By nuliknol in forum Newbie
    Replies: 1
    Last Post: 19th April 2014, 16:38
  2. model and default columns values
    By m15ch4 in forum Qt Programming
    Replies: 0
    Last Post: 8th May 2011, 21:57
  3. Default values in QXmlSchemaValidator
    By mortalisk in forum Qt Programming
    Replies: 0
    Last Post: 3rd September 2010, 16:11
  4. How to QTableWidget default values on insertion?
    By RawArkanis in forum Qt Programming
    Replies: 1
    Last Post: 20th April 2010, 07:02
  5. C++ and default values for functions
    By guestgulkan in forum General Programming
    Replies: 4
    Last Post: 2nd January 2007, 22:53

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.