Results 1 to 3 of 3

Thread: Not rounded number on scales / Fixed scaling

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Not rounded number on scales / Fixed scaling

    Hi all,

    I'm using the default QwtScaleEngine for my plot, however I do not like the rounding of the numbers that is done for each grid line. The default QwtScaleEngine is trying to put a grid line on 'nice-looking rounded' numbers.
    I managed to implement my own implementation of QwtScaleEngine that is not using the rounded numbers. That implementation of QwtScaleEngine is then placing grid lines exactly on the numbers and stepsize that has been specified in the setAxisScale also if those numbers are 'strange' (like for example: top: 132.43 and bottom: 54.32)

    Qt Code:
    1. _plot->setAxisScale(QwtPlot::yLeft, bottom, top, (top - bottom) / 10);
    To copy to clipboard, switch view to plain text mode 


    For this implementation it is 'only' necessary to change the behaviour of 'divideInterval' and 'align'. However because these functions are not defined as virtual, it is also necessary to copy the implementation of 'autoScale', 'divideScale', 'buildTicks', 'buildMinorTicks' and 'buildMajorTicks'.

    It would really simplify my implementation if QwtScaleEngine::divideInterval and QwtLinearScaleEngine::align are made 'virtual'.

    In that case the implementation becomes:

    Qt Code:
    1. class FixedScaleEngine : public QwtLinearScaleEngine {
    2. protected:
    3. double divideInterval(double interval, int numSteps) const
    4. { if (numSteps <= 0) return 0.0;
    5. return interval / numSteps; }
    6. QwtDoubleInterval align(const QwtDoubleInterval & interval, double /* stepSize */) const
    7. { return interval; }
    8. };
    To copy to clipboard, switch view to plain text mode 

    Can someone make the functions QwtScaleEngine::divideInterval and QwtLinearScaleEngine::align virtual?

    Thanks!

    By the way, I'm using and have tested this with the SVN revision 443 of Qwt.

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

    Default Re: Not rounded number on scales / Fixed scaling

    When you want to assign a scale explicitely use QwtPlot::setAxisScaleDiv().

    Uwe

  3. #3
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Not rounded number on scales / Fixed scaling

    Hello Uwe,

    In my opinion, the usage of the QwtPlot::setAxisScaleDiv() is too cumbersome, because then I also have to create a QwtScaleDiv object (which is not really a problem), but I also have to calculate multiple lists of QwtValueList including the Tick values that should be stored inside those QwtValueList's.

    The QwtLinearScaleEngine, already has a correct implementation of those calculations (and more: it also contains functionality to include a Reference value, Inversion of the scale and a Symmetric option).

    I only want to modify a slightly different implementation of the rounding that is used in the QwtLinearScaleEngine. And this modification is very simple if only two functions are made virtual, so I can reimplement their behaviour.

    In my opinion there is no drawback to make the proposed functions virtual. But when these functions are made virtual it does allow some very nice and simple implementations for classes that re-implement QwtScaleEngine.

    Thanks,
    Joro

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

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.