Results 1 to 2 of 2

Thread: Determine if axis is log scaled?

  1. #1
    Join Date
    Sep 2007
    Posts
    61
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Determine if axis is log scaled?

    Hello Uwe,

    I am trying to convert my code to use the new Qwt trunk, and I noticed the changes to QwtScaleTransform. I used to do something like this:

    QwtScaleTransformation *qse = qwtplot->axisScaleEngine (axisId)->transformation ();
    bool axisLog = ((int) (qse->type ()) == 1);

    Is there something equivalent that I can do now to determine if an axis is log scaled?

    Thanks,
    Joey

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

    Default Re: Determine if axis is log scaled?

    Quote Originally Posted by bigjoeystud View Post
    Is there something equivalent that I can do now to determine if an axis is log scaled?
    Note that QwtTransform is different to QwtScaleTransformation:

    QwtScaleTransformation implemented the mapping between scale and paint device coordinates, while QwtTransform implements some "stretch" function, that can be used to manipulate the mapping implemented in QwtScaleMap. You might have noticed, that I have added QwtPowerTransform - an implementation using pow() - and in playground you find the scaleengine example that shows a transformation that extents the scales for an interval of interest ( here 300 - 500 ). Click on the legend to see what all these transformations do.

    I have dropped the inlining in QwtScaleMap for logarithmic scales ( because log/exp are too expensive calls and the effect was it not worth ) to have a cleaner API without having an additional RTTI flag ( what the type enum was ). Instead QwtScaleMap implements an inlined linear mapping, when it has no transformation ( QwtLinearScaleEngine::transformation() returns NULL now ! ).

    Note that the modification is not 100% in SVN yet. QwtLog10ScaleEngine will become QwtLogScaleEngine( double base ) - f.e for log2 based scales.

    Back to your question - you can do the following:

    Qt Code:
    1. bool axisLog = qwtplot->axisScaleEngine (axisId)->transformation () != NULL;
    To copy to clipboard, switch view to plain text mode 
    Of course the code above implies, that non linear transformations are always logarithmic - so, when you are allowed to use C++ rtti it would be better to write someting like this:

    Qt Code:
    1. bool axisLog = dynamic_cast<const QwtLogTransform *>( qwtplot->axisScaleEngine (axisId)->transformation () ) != NULL;
    To copy to clipboard, switch view to plain text mode 
    Uwe

Similar Threads

  1. Replies: 9
    Last Post: 3rd May 2011, 21:21
  2. Replies: 0
    Last Post: 9th August 2010, 10:46
  3. How to get Scaled size
    By rogerholmes in forum Newbie
    Replies: 3
    Last Post: 20th March 2010, 16:12
  4. Font is scaled
    By lni in forum Qt Programming
    Replies: 11
    Last Post: 30th January 2009, 21:54
  5. How to put scaled QGraphicsItems next to eachother
    By profoX in forum Qt Programming
    Replies: 6
    Last Post: 3rd June 2008, 07:44

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.